[FFmpeg-devel] [PATCH 2/2] avcodec/mpeg4_unpack_bframes: allocate a new packet when data needs to be changed
James Almer
jamrial at gmail.com
Mon Mar 19 04:25:33 EET 2018
Nothing currently guarantees that the packet will be writtable.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavcodec/mpeg4_unpack_bframes_bsf.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c
index ba970794c5..00cc35c2ab 100644
--- a/libavcodec/mpeg4_unpack_bframes_bsf.c
+++ b/libavcodec/mpeg4_unpack_bframes_bsf.c
@@ -149,8 +149,14 @@ static int mpeg4_unpack_bframes_filter(AVBSFContext *ctx, AVPacket *out)
av_packet_move_ref(out, in);
out->size = pos_vop2;
} else if (pos_p >= 0) {
+ ret = av_new_packet(out, in->size);
+ if (ret < 0)
+ goto fail;
+ ret = av_packet_copy_props(out, in);
+ if (ret < 0)
+ goto fail;
+ memcpy(out->data, in->data, in->size);
av_log(ctx, AV_LOG_DEBUG, "Updating DivX userdata (remove trailing 'p').\n");
- av_packet_move_ref(out, in);
/* remove 'p' (packed) from the end of the (DivX) userdata string */
out->data[pos_p] = '\0';
} else {
--
2.16.2
More information about the ffmpeg-devel
mailing list