[FFmpeg-devel] [PATCH] Implement PAFF in H.264
Mon Oct 1 21:20:08 CEST 2007
On Fri, 28 Sep 2007, Neil Brown wrote:
> Why is the IDR frame missed? Well with PAFF, it is an IDR field of
> course. The first field of a complementary-field-pair is 'IDR', the
> second isn't. So this line:
> s->current_picture_ptr->key_frame = (hx->nal_unit_type == NAL_IDR_SLICE);
Yes, indeed. Thanks for tracking this down.
> My proposed fix (which "works for me") is:
> Index: ffmpeg/libavcodec/h264.c
> --- ffmpeg.orig/libavcodec/h264.c 2007-09-23 13:37:14.000000000 +1000
> +++ ffmpeg/libavcodec/h264.c 2007-09-28 11:16:00.000000000 +1000
> @@ -7581,7 +7581,7 @@ static int decode_nal_units(H264Context
> if((err = decode_slice_header(hx, h)))
> - s->current_picture_ptr->key_frame= (hx->nal_unit_type == NAL_IDR_SLICE);
> + s->current_picture_ptr->key_frame |= (hx->nal_unit_type == NAL_IDR_SLICE);
> if(hx->redundant_pic_count==0 && hx->s.hurry_up < 5
> && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
> && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type!=B_TYPE)
This is half the solution. Problem here is that key_frame is wrong from
the get-go (see MPV_frame_start and decode_slice_header() comments about
s->pict_type). It is based on the slice type being I Type or not, which
is incorrect for H.264 because I slices can exist in non-IDR frames.
The original line overrides the bad value computed in MPV_frame_start.
I fixed this in my latest patches (coming soon) by combining this with an
override (to zero) of the bad value from MPV_frame_start. I would've
corrected the setting of pict_type, but that's used in several places.
Thanks again for looking at this and providing the fix.
More information about the ffmpeg-devel