[Ffmpeg-devel] access to motion vectors

Alireza Ghane ghane
Mon Feb 12 18:10:52 CET 2007

I want to access the motion vectors for some blocks in a P frame. I am
decoding H.264 video sequence and MV accuracy is 4X4 pixels and the size
of each MB is 16X16.  I wrote this code to access the Forward MV for the
first 4X4 sub-block of the MB at the position (mb_x, mb_y) in a P frame;
But it seems to generate wrong answer. Please help me to correct it.

curr_pic = s->current_picture_ptr;

mv_sample_log2= 4 - curr_pic->motion_subsample_log2;
mb_width= (w+15)>>4; // w is the width of the frames
mv_stride= (mb_width << mv_sample_log2) + 1;

mv_x = mb_x << mv_sample_log2;
mv_y = mb_y << mv_sample_log2;
mv = curr_pic->motion_val[0][(mv_x) + (mv_y)*mv_stride];

More information about the ffmpeg-devel mailing list