[FFmpeg-devel] [PATCH 41/46] avcodec/vc2enc: Allow user-supplied buffers

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Apr 30 02:57:12 EEST 2021


Trivial for an encoder that has a very good estimate of the size
of the output packet in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/vc2enc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index ca5cebb742..2de6d4b17a 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -22,6 +22,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
 #include "dirac.h"
+#include "encode.h"
 #include "put_bits.h"
 #include "internal.h"
 #include "version.h"
@@ -914,9 +915,8 @@ static int encode_frame(VC2EncContext *s, AVPacket *avpkt, const AVFrame *frame,
     max_frame_bytes = header_size + calc_slice_sizes(s);
 
     if (field < 2) {
-        ret = ff_alloc_packet2(s->avctx, avpkt,
-                               max_frame_bytes << s->interlaced,
-                               max_frame_bytes << s->interlaced);
+        ret = ff_get_encode_buffer(s->avctx, avpkt,
+                                   max_frame_bytes << s->interlaced, 0);
         if (ret) {
             av_log(s->avctx, AV_LOG_ERROR, "Error getting output packet.\n");
             return ret;
@@ -1231,10 +1231,10 @@ const AVCodec ff_vc2_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("SMPTE VC-2"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_DIRAC,
+    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
     .priv_data_size = sizeof(VC2EncContext),
     .init           = vc2_encode_init,
     .close          = vc2_encode_end,
-    .capabilities   = AV_CODEC_CAP_SLICE_THREADS,
     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .encode2        = vc2_encode_frame,
     .priv_class     = &vc2enc_class,
-- 
2.27.0



More information about the ffmpeg-devel mailing list