[PATCH 0/3] h264 random access fixes
This patch series fixes some issues with trash being displayed after seeking Please test, especially with samples that had issues with seeking in the past I will commit this tomorrow if noone finds a bug in it or has objections.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> --- libavcodec/h264.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index f6fcc84..7665021 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1327,6 +1327,7 @@ int ff_h264_frame_start(H264Context *h){ * See decode_nal_units(). */ s->current_picture_ptr->f.key_frame = 0; + s->current_picture_ptr->sync = 0; s->current_picture_ptr->mmco_reset= 0; assert(s->linesize && s->uvlinesize); -- 1.7.5.4
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> --- libavcodec/h264.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 7665021..cb5025b 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3896,7 +3896,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ break; if ( h->sei_recovery_frame_cnt >= 0 - && ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt) { + && ( h->recovery_frame<0 + || ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt)) { h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) % (1 << h->sps.log2_max_frame_num); } -- 1.7.5.4
It seems I have misunderstood the spec when I implemented this originally. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> --- libavcodec/h264.c | 8 +++----- libavcodec/h264_refs.c | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index cb5025b..604b8cf 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3906,13 +3906,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ (hx->nal_unit_type == NAL_IDR_SLICE); if (h->recovery_frame == h->frame_num) { - h->sync |= 1; + s->current_picture_ptr->sync |= 1; h->recovery_frame = -1; } h->sync |= !!s->current_picture_ptr->f.key_frame; h->sync |= 3*!!(s->flags2 & CODEC_FLAG2_SHOW_ALL); - s->current_picture_ptr->sync = h->sync; + s->current_picture_ptr->sync |= h->sync; if (h->current_slice == 1) { if(!(s->flags2 & CODEC_FLAG2_CHUNKS)) { @@ -4129,11 +4129,9 @@ not_extra: field_end(h, 0); *data_size = 0; /* Wait for second field. */ - if (h->next_output_pic && h->next_output_pic->sync) { - if(h->sync>1 || h->next_output_pic->f.pict_type != AV_PICTURE_TYPE_B){ + if (h->next_output_pic && (h->next_output_pic->sync || h->sync>1)) { *data_size = sizeof(AVFrame); *pict = *(AVFrame*)h->next_output_pic; - } } } diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index d030fec..8432a8a 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -654,8 +654,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ print_long_term(h); if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){ - h->sync |= 1; - s->current_picture_ptr->sync |= h->sync; + s->current_picture_ptr->sync |= 1; } return (h->s.avctx->err_recognition & AV_EF_EXPLODE) ? err : 0; -- 1.7.5.4
On Sat, Dec 31, 2011 at 10:23:33PM +0100, Michael Niedermayer wrote:
This patch series fixes some issues with trash being displayed after seeking Please test, especially with samples that had issues with seeking in the past I will commit this tomorrow if noone finds a bug in it or has objections.
applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire
participants (1)
-
Michael Niedermayer