diff mbox series

[FFmpeg-devel,05/39] avcodec/libkvazaar: Allow user-supplied buffers

Message ID HE1PR0301MB2154ECA78F7C39DF02924C0B8F299@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 95c8a859d97e9902388f5acf5c735b16417a2609
Headers show
Series [FFmpeg-devel,01/39] avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1 | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 21, 2021, 9:17 a.m. UTC
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/libkvazaar.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 14eabe4e05..aabe446a28 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -36,6 +36,7 @@ 
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
+#include "encode.h"
 #include "internal.h"
 #include "packet_internal.h"
 
@@ -237,7 +238,7 @@  static int libkvazaar_encode(AVCodecContext *avctx,
         kvz_data_chunk *chunk = NULL;
         uint64_t written = 0;
 
-        retval = ff_alloc_packet2(avctx, avpkt, len_out, len_out);
+        retval = ff_get_encode_buffer(avctx, avpkt, len_out, 0);
         if (retval < 0) {
             av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
             goto done;
@@ -316,7 +317,8 @@  const AVCodec ff_libkvazaar_encoder = {
     .long_name        = NULL_IF_CONFIG_SMALL("libkvazaar H.265 / HEVC"),
     .type             = AVMEDIA_TYPE_VIDEO,
     .id               = AV_CODEC_ID_HEVC,
-    .capabilities     = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
+    .capabilities     = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+                        AV_CODEC_CAP_OTHER_THREADS,
     .pix_fmts         = pix_fmts,
 
     .priv_class       = &class,