X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264_slice.c;h=fa7a639053edb2b3fc1f42e2ae46716d6192dabf;hb=fbfa78508bec11e231b3e276dcc716fe654baca3;hp=db7302a8b52682f0508d4252bb2ed5be88520d8a;hpb=184fc42b46cb6068af2735d4d888b3254c2db652;p=ffmpeg diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index db7302a8b52..fa7a639053e 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -325,29 +325,22 @@ int ff_h264_update_thread_context(AVCodecContext *dst, // SPS/PPS for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++) { - av_buffer_unref(&h->ps.sps_list[i]); - if (h1->ps.sps_list[i]) { - h->ps.sps_list[i] = av_buffer_ref(h1->ps.sps_list[i]); - if (!h->ps.sps_list[i]) - return AVERROR(ENOMEM); - } + ret = av_buffer_replace(&h->ps.sps_list[i], h1->ps.sps_list[i]); + if (ret < 0) + return ret; } for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) { - av_buffer_unref(&h->ps.pps_list[i]); - if (h1->ps.pps_list[i]) { - h->ps.pps_list[i] = av_buffer_ref(h1->ps.pps_list[i]); - if (!h->ps.pps_list[i]) - return AVERROR(ENOMEM); - } + ret = av_buffer_replace(&h->ps.pps_list[i], h1->ps.pps_list[i]); + if (ret < 0) + return ret; } - av_buffer_unref(&h->ps.pps_ref); + ret = av_buffer_replace(&h->ps.pps_ref, h1->ps.pps_ref); + if (ret < 0) + return ret; h->ps.pps = NULL; h->ps.sps = NULL; if (h1->ps.pps_ref) { - h->ps.pps_ref = av_buffer_ref(h1->ps.pps_ref); - if (!h->ps.pps_ref) - return AVERROR(ENOMEM); h->ps.pps = (const PPS*)h->ps.pps_ref->data; h->ps.sps = h->ps.pps->sps; } @@ -432,12 +425,9 @@ int ff_h264_update_thread_context(AVCodecContext *dst, h->frame_recovered = h1->frame_recovered; - av_buffer_unref(&h->sei.a53_caption.buf_ref); - if (h1->sei.a53_caption.buf_ref) { - h->sei.a53_caption.buf_ref = av_buffer_ref(h1->sei.a53_caption.buf_ref); - if (!h->sei.a53_caption.buf_ref) - return AVERROR(ENOMEM); - } + ret = av_buffer_replace(&h->sei.a53_caption.buf_ref, h1->sei.a53_caption.buf_ref); + if (ret < 0) + return ret; for (i = 0; i < h->sei.unregistered.nb_buf_ref; i++) av_buffer_unref(&h->sei.unregistered.buf_ref[i]); @@ -1616,7 +1606,7 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, prev->f->format, prev->f->width, prev->f->height); - h->short_ref[0]->poc = prev->poc + 2; + h->short_ref[0]->poc = prev->poc + 2U; } else if (!h->frame_recovered && !h->avctx->hwaccel) ff_color_frame(h->short_ref[0]->f, c); h->short_ref[0]->frame_num = h->poc.prev_frame_num;