diff options
author | Limin Wang <lance.lmwang@gmail.com> | 2020-06-11 12:50:46 +0800 |
---|---|---|
committer | Limin Wang <lance.lmwang@gmail.com> | 2020-06-15 07:19:55 +0800 |
commit | 4b3b217e3074687f2b55a1dfb3e6942c9f261908 (patch) | |
tree | ffa158876fd22ce7c5d2975d668d250a0274dbbd /libavcodec/h264_sei.c | |
parent | 567d571b2015819abbb5de953ebb30bca69645a8 (diff) |
avcodec/h264: create user data unregistered SEI side data for H.264
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavcodec/h264_sei.c')
-rw-r--r-- | libavcodec/h264_sei.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 870dd90717..7b8e6bd7ba 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -52,6 +52,10 @@ void ff_h264_sei_uninit(H264SEIContext *h) h->afd.present = 0; av_buffer_unref(&h->a53_caption.buf_ref); + for (int i = 0; i < h->unregistered.nb_buf_ref; i++) + av_buffer_unref(&h->unregistered.buf_ref[i]); + h->unregistered.nb_buf_ref = 0; + av_freep(&h->unregistered.buf_ref); } int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps, @@ -260,25 +264,34 @@ static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext * { uint8_t *user_data; int e, build, i; + AVBufferRef *buf_ref, **tmp; if (size < 16 || size >= INT_MAX - 1) return AVERROR_INVALIDDATA; - user_data = av_malloc(size + 1); - if (!user_data) + tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref)); + if (!tmp) return AVERROR(ENOMEM); + h->buf_ref = tmp; + + buf_ref = av_buffer_alloc(size + 1); + if (!buf_ref) + return AVERROR(ENOMEM); + user_data = buf_ref->data; for (i = 0; i < size; i++) user_data[i] = get_bits(gb, 8); user_data[i] = 0; + buf_ref->size = size; + h->buf_ref[h->nb_buf_ref++] = buf_ref; + e = sscanf(user_data + 16, "x264 - core %d", &build); if (e == 1 && build > 0) h->x264_build = build; if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core 0000", 16)) h->x264_build = 67; - av_free(user_data); return 0; } |