[Ffmpeg-devel] Motion Estimation in snow.c for Waevelet encoded frames (DWT)

Loren Merritt lorenm
Fri Mar 30 21:00:45 CEST 2007


On Fri, 30 Mar 2007, Aniket Joshi wrote:

> I am trying to implement a new motion estimation algorithm for wavelet
> encoded frames (DWT). The command I use for encoding the raw file is:
> ffmpeg -t 60 -s 176x144 -i formulaone_64kbps_5fps.yuv -f rawvideo -pix_fmt
> yuv420p -strict -2 -vcodec snow -b 600 -an -f mp4 play.mp4.
>
> I have some queries about the motion search part:
>
>
> - Could you please tell me what exactly the cmp function defined at
> line 106 of motion_est.c does? Does it compare two macroblocks?

It compares two blocks, which may be full macroblocks or may be partitions 
thereof. Though snow doesn't have macroblocks in the same sense as 
mpeg-like codecs, so you can consider all blocks to be partitions of 
various sizes.

> - What does the " int best[2]={0, 0};" variable in function
> epzs_motion_search_internal (line 994 in motion_est_template.c) do? I see
> that it gets passed as argument to the diamond_search function which inturn
> passes it into small_diamond_search. I know best[0] stands for x-coordinate
> & best[1] for y, but these are coordinates of what?

coordinates of the motion vector. i.e. the difference between the position 
of the block current being encoded and the position of the block chosen 
to predict it from.

> - In the same above function, what does the 'dmin' variable stand for?

d is a the score (cmp + penalty) of any given mv.
dmin is the best value of d, i.e. the score corresponding to the mv stored 
in best[].

> - In the same function, what does the 'penalty_factor' variable stand
> for? The penalty_factor & pre_penalty factor are declared in the
> MotionEstContext structure, but there's no explanation as to what do they
> mean?

It's an estimate of the bits required to code a given mv value, e.g. (1,0) 
takes more bits than (0,0). We have to estimate whether any reduction in 
residual is worth the extra bits.

> - What does the P[10][2] argument that is passed to the same function
> stand for? P[10][2] is first defined in encode_q_branch function in
> snow.c & then passed to the ff_epzs_motion_search function.

a list of candidate mvs to check before starting the iterative search. If 
one of the candidates is close to the optimal mv, then it takes fewer 
iterations. And it increases the chance that we find the optimal mv.

> - What does the variable 'dia_size' used in the diamond_search
> function (defined on line 974 in mostion_est_template) stand for? Does it
> refer to the step-size required for the diamond search?

I don't know what you mean by "required", but it is the step size.

> Also, where is this value set?

in avctx, by the user/application

> - In small_diamond_search, where is the actual difference between
> reference and current frame calculated? The ref_index & src_index values
> are always zero here.

CHECK_MV_DIR

--Loren Merritt




More information about the ffmpeg-devel mailing list