diff mbox series

[FFmpeg-devel,13/39] avcodec/libwebpenc: Allow user-supplied buffers

Message ID HE1PR0301MB2154653A3E419ED769C66D628F299@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit ad26efbf5268daec2b8c00e06568a984d3fa1b3a
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/libwebpenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c
index 2e5b811455..97adacb6b2 100644
--- a/libavcodec/libwebpenc.c
+++ b/libavcodec/libwebpenc.c
@@ -24,6 +24,7 @@ 
  * WebP encoder using libwebp (WebPEncode API)
  */
 
+#include "encode.h"
 #include "libwebpenc_common.h"
 
 typedef LibWebPContextCommon LibWebPContext;
@@ -57,7 +58,7 @@  static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         goto end;
     }
 
-    ret = ff_alloc_packet2(avctx, pkt, mw.size, mw.size);
+    ret = ff_get_encode_buffer(avctx, pkt, mw.size, 0);
     if (ret < 0)
         goto end;
     memcpy(pkt->data, mw.mem, mw.size);
@@ -98,6 +99,7 @@  const AVCodec ff_libwebp_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("libwebp WebP image"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_WEBP,
+    .capabilities   = AV_CODEC_CAP_DR1,
     .priv_data_size = sizeof(LibWebPContext),
     .init           = libwebp_encode_init,
     .encode2        = libwebp_encode_frame,