Log in

View Full Version : motion estimation


new in imaging
17th December 2007, 04:51
Hi all,

I have developed a new block based motion estimation algorithm. It gives a good PSNR and have small search no.

Now i want to integrate it with some video codec and test the bitrate verses PSNR at different QPs.

But i do not have any idea how to do it.

There are many reference softwares available like of that of H264 etc from the internet but i do not know how to start ,.

is there some way where i just input my motion estimation code and then integarte it easily with the video codec to get above results.

Any guidance will be highly appreciated.

Thanks

Dark Shikari
17th December 2007, 05:06
With x264, its quite simple, actually.

Go to encoder/me.c, and check the x264_me_search_ref function: void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int *p_halfpel_thresh ).

h is the main struct containing frame information, m is the macroblock analysis struct, mvc[] is an array of predictors, i_mvc is the number of predictors, and p_halfpel_thresh is a threshold used to terminate early (before qpel) in the case where a threshold isn't met.

When you read the following:

switch( h->mb.i_me_method )
{

You've begun the main fullpel ME section of the code. Here's a sample example of an algorithm, diamond search, from the code:

case X264_ME_DIA:
/* diamond search, radius 1 */
for( i = 0; i < i_me_range; i++ )
{
omx = bmx; omy = bmy;\
COST_MV_X4( 0,-1, 0,1, -1,0, 1,0 );\
if( bmx == omx && bmy == omy )
break;
if( !CHECK_MVRANGE(bmx, bmy) )
break;
}
break;
i_me_range is the --merange parameter (note this is clamped to 4 <= merange <= 16 when HEX or DIA are selected).

OMX and OMY are the base from which COST_MV_X4 works; it centers on those locations, and then in this case searches the relative locations (0,1),(0,-1),(1,0), and (-1,0). COST_MV_X4 runs the SAD operation for each location, and if the cost is lower than the current best candidate, it replaces bcost with the new cost, bmx with the new best x, and bmy with the new best y.

Then, if bmx == omx and bmy == omy (i.e. DIA did not find a new best candidate in the neighbors) it breaks. Otherwise, it runs again. MVRange is also checked to make sure the MV is within range--note that there is a 5-pixel buffer for fullpel search, so you can go up to 5 pixels away from the last time you checked MVrange without checking again.

Note that creating a good fullpel ME algorithm is very difficult; you will find it quite difficult to outpace HEX in speed-vs-quality, for example, and you will also find it hard to beat UMH's quality without going even slower.

Some general pointers:
1) COST_MV_X4 is faster than COST_MV run 4 times.
2) COST_MV doesn't use relative coordinates, all multiple-SAD COST_MVs do.
3) One 16x16 SAD takes about 48 clock cycles on a Core 2 Duo. If you would prefer to use SATD, this takes about 6-8 times as many.

new in imaging
17th December 2007, 08:39
Thanks a lot.

I will try and get back to u if there are other problems....

new in imaging
31st December 2007, 04:46
Hi,

I have downloaded H.264/AVC reference software from teh following site, versions 13.2 and 9.8.

http://iphome.hhi.de/suehring/tml/download/

IN 9.8 version there is no file named as me.c however there is one as fast_ me.c and in 13.2 there r many me algorithm files.

so which version do u think will be easier to handle, or should i go to previous versions.

Thanks

new in imaging
31st December 2007, 09:12
hi

now i have downloaded x.264 and got the me.c file.

Hope i will be able to do something.

Thanks

Dark Shikari
31st December 2007, 15:18
hi

now i have downloaded x.264 and got the me.c file.

Hope i will be able to do something.

ThanksGood move. Using the reference software is generally not advised due to its incredibly slow speed and inefficient algorithms; indeed, Akupengiun has said that if a proposed ME algorithm compares itself to the reference, that algorithm is almost certainly too slow to be useful ;)

new in imaging
3rd January 2008, 13:33
hi,

i have downloaded x264 from
http://forum.doom9.org/showthread.php?t=89979

but i do not get any info from it neither i am able to compile it.

i cannot understand what is .svn folder for.

if i try to compile encoder only, it requires a inttypes.h file that is not present..

seems i am at loss... need help

thanks

nm
3rd January 2008, 14:33
hi,

i have downloaded x264 from
http://forum.doom9.org/showthread.php?t=89979
The official homepage of x264 is http://www.videolan.org/developers/x264.html and the unpatched source code is also available there as daily snapshots or through Subversion (SVN).

but i do not get any info from it neither i am able to compile it.
Compiling is done in the common Linux/Unix style: ./configure [possible options]
make
On Windows, you need to either install a Unix-like shell environment or find/make a project file for whatever compiler or development environment you are using. This thread should contain more tips and pointers: http://forum.doom9.org/showthread.php?s=&threadid=92726

i cannot understand what is .svn folder for.
It's used by the Subversion (http://subversion.tigris.org/) revision control system. You might want to read more about SVN and other similar tools to make your life easier with x264 and many other open-source projects.