[FFmpeg-devel] [PATCH 2/3] avcodec/evc_frame_merge_bsf: use av_new_packet()

James Almer jamrial at gmail.com
Sat Jun 17 18:18:47 EEST 2023


This ensures the buffer is padded as required by the AVPacket API.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/evc_frame_merge_bsf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c
index 827f114f0b..540bb63631 100644
--- a/libavcodec/evc_frame_merge_bsf.c
+++ b/libavcodec/evc_frame_merge_bsf.c
@@ -114,14 +114,14 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
     av_packet_unref(in);
 
     if (au_end_found) {
-        uint8_t *data = av_memdup(ctx->au_buffer.data, ctx->au_buffer.data_size);
         size_t data_size = ctx->au_buffer.data_size;
 
         ctx->au_buffer.data_size = 0;
-        if (!data)
-            return AVERROR(ENOMEM);
+        err = av_new_packet(out, data_size);
+        if (err < 0)
+            return err;
 
-        err = av_packet_from_data(out, data, data_size);
+        memcpy(out->data, ctx->au_buffer.data, data_size);
     } else
         err = AVERROR(EAGAIN);
 
-- 
2.41.0



More information about the ffmpeg-devel mailing list