[FFmpeg-devel] determining the reference frame for motion_val

Martin Luessi mluessi
Wed Aug 22 16:21:25 CEST 2007


Hi,

For my work I need to extract motion vectors from h264 video. By
looking at the function ff_print_debug_info in mpegvideo.c and
previous posts on this list, I figured out how to do that. Right now
my motion vector extraction function accesses the motion_val table of
the returned AVFrame and creates a table with one motion vector for
each 8x8 block. However, I still have the following questions:

1)
How can I determine which reference frame is used for a given motion
vector? I use the USES_LIST macro to find out if there is a forward or
backward motion vector assigned to a a given block. Let's say we have
a forward motion vector, how can I find out which previous frame  is
used as reference? If the current frame is a P-frame and the previous
one was an I-frame, obviously the previous frame is used. But what
about if the current frame is a B-frame and the previous frame is B as
well. As you know h264 has an option to support using B frames as
reference, so the reference frame could be the previous B-frame or a
I/P frame further back in the past. I hope you see what I'm getting
at.

2)
Is there an easy way to find out if a block uses 4x4 partitions in
h264, if yes how can I access the motion vectors?

Thanks for your help and keep up the good work.. I really hope one day
I will discover a bug in ffmpeg and fix it, but so far I had no luck
with that ;)

Martin




More information about the ffmpeg-devel mailing list