X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264_sei.c;h=43593d34d2d3438372350afb4904fe6c0a34066c;hb=35498c124a81d4207e34e115840138d71307c2e3;hp=9defcb80b9a440e19edbc013ffcf5b713d7cf1e4;hpb=4339c94364f8ff143d051fcace3e5801625db607;p=ffmpeg diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 9defcb80b9a..43593d34d2d 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -51,8 +51,7 @@ void ff_h264_sei_uninit(H264SEIContext *h) h->display_orientation.present = 0; h->afd.present = 0; - h->a53_caption.a53_caption_size = 0; - av_freep(&h->a53_caption.a53_caption); + av_buffer_unref(&h->a53_caption.buf_ref); } static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb, @@ -169,7 +168,8 @@ static int decode_registered_user_data_closed_caption(H264SEIA53Caption *h, size -= 2; if (cc_count && size >= cc_count * 3) { - const uint64_t new_size = (h->a53_caption_size + cc_count + int old_size = h->buf_ref ? h->buf_ref->size : 0; + const uint64_t new_size = (old_size + cc_count * UINT64_C(3)); int i, ret; @@ -177,14 +177,15 @@ static int decode_registered_user_data_closed_caption(H264SEIA53Caption *h, return AVERROR(EINVAL); /* Allow merging of the cc data from two fields. */ - ret = av_reallocp(&h->a53_caption, new_size); + ret = av_buffer_realloc(&h->buf_ref, new_size); if (ret < 0) return ret; + /* Use of av_buffer_realloc assumes buffer is writeable */ for (i = 0; i < cc_count; i++) { - h->a53_caption[h->a53_caption_size++] = get_bits(gb, 8); - h->a53_caption[h->a53_caption_size++] = get_bits(gb, 8); - h->a53_caption[h->a53_caption_size++] = get_bits(gb, 8); + h->buf_ref->data[old_size++] = get_bits(gb, 8); + h->buf_ref->data[old_size++] = get_bits(gb, 8); + h->buf_ref->data[old_size++] = get_bits(gb, 8); } skip_bits(gb, 8); // marker_bits @@ -261,10 +262,16 @@ static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext * return 0; } -static int decode_recovery_point(H264SEIRecoveryPoint *h, GetBitContext *gb) +static int decode_recovery_point(H264SEIRecoveryPoint *h, GetBitContext *gb, void *logctx) { - h->recovery_frame_cnt = get_ue_golomb_long(gb); + unsigned recovery_frame_cnt = get_ue_golomb_long(gb); + if (recovery_frame_cnt >= (1<recovery_frame_cnt = recovery_frame_cnt; /* 1b exact_match_flag, * 1b broken_link_flag, * 2b changing_slice_group_idc */ @@ -429,7 +436,7 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, ret = decode_unregistered_user_data(&h->unregistered, gb, logctx, size); break; case H264_SEI_TYPE_RECOVERY_POINT: - ret = decode_recovery_point(&h->recovery_point, gb); + ret = decode_recovery_point(&h->recovery_point, gb, logctx); break; case H264_SEI_TYPE_BUFFERING_PERIOD: ret = decode_buffering_period(&h->buffering_period, gb, ps, logctx);