X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264.c;h=a9a10513e39e4ba7ea7e94876673a21645a77802;hb=1ce1578e4e6e4c79eff87b997668779e50e4be33;hp=109a1095308487e9301db4fd814ca41e4e4eed62;hpb=63ccd466873b0863d466f5846a305eb908fe3b80;p=ffmpeg diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 109a1095308..a9a10513e39 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1530,7 +1530,11 @@ static void decode_postinit(H264Context *h, int setup_finished){ h->next_outputed_poc = INT_MIN; } } else { - h->next_outputed_poc = out->poc; + if (out_idx == 0 && pics > 1 && h->delayed_pic[0]->f.key_frame) { + h->next_outputed_poc = INT_MIN; + } else { + h->next_outputed_poc = out->poc; + } } h->mmco_reset = 0; }else{ @@ -3755,7 +3759,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ int consumed; int dst_length; int bit_length; - const uint8_t *ptr; + uint8_t *ptr; int i, nalsize = 0; int err; @@ -3805,6 +3809,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ } if (h->is_avc && (nalsize != consumed) && nalsize){ + // set trailing bits in the last partial byte to zero + if (bit_length & 7) + ptr[bit_length >> 3] = ptr[bit_length >> 3] & (0xff << 8 - (bit_length & 7)); av_log(h->s.avctx, AV_LOG_DEBUG, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize); }