summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_mpeg2.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-03-05 11:04:59 -0300
committerJames Almer <jamrial@gmail.com>2018-03-05 11:44:51 -0300
commitdf3a2ff7670a76c808fa015559b867aecbbdcd54 (patch)
tree506f724c1d1662a8269b21bafed66843dc30c43b /libavcodec/cbs_mpeg2.c
parent69995a94d8409a704361dce9bc16ede7f88bdf1a (diff)
avcodec/cbs: use a reference to the assembled CodedBitstreamFragment buffer when writing packets
This saves one malloc + memcpy per packet The CodedBitstreamFragment buffer is padded to follow the requirements of AVPacket. Reviewed-by: jkqxz Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r--libavcodec/cbs_mpeg2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 5bb2e1e107..bfb64a0851 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -369,7 +369,7 @@ static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx,
for (i = 0; i < frag->nb_units; i++)
size += 3 + frag->units[i].data_size;
- frag->data_ref = av_buffer_alloc(size);
+ frag->data_ref = av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!frag->data_ref)
return AVERROR(ENOMEM);
data = frag->data_ref->data;
@@ -388,6 +388,7 @@ static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx,
av_assert0(dp == size);
+ memset(data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
frag->data = data;
frag->data_size = size;