summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_mpeg2.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-04-25 19:35:46 -0300
committerJames Almer <jamrial@gmail.com>2018-04-26 20:05:00 -0300
commit05c0f620bf1431f3959399234a543838050941f2 (patch)
treea2eeec806537974bb61d21280f8da2cac39e6c90 /libavcodec/cbs_mpeg2.c
parentdff1fb27aaf076da1912366191e593834cecf841 (diff)
downloadffmpeg-05c0f620bf1431f3959399234a543838050941f2.tar.gz
avcodec/cbs_mpeg2: use existing buffer reference when splitting fragments
Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r--libavcodec/cbs_mpeg2.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 94b9591b21..989daf0a4d 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -146,18 +146,12 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx,
unit_size = (end - 4) - (start - 1);
}
- unit_data = av_malloc(unit_size + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!unit_data)
- return AVERROR(ENOMEM);
- memcpy(unit_data, start - 1, unit_size);
- memset(unit_data + unit_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+ unit_data = (uint8_t *)start - 1;
err = ff_cbs_insert_unit_data(ctx, frag, i, unit_type,
- unit_data, unit_size, NULL);
- if (err < 0) {
- av_freep(&unit_data);
+ unit_data, unit_size, frag->data_ref);
+ if (err < 0)
return err;
- }
if (end == frag->data + frag->data_size)
break;