diff mbox series

[FFmpeg-devel,33/46] avcodec/rawenc: Allow user-supplied buffers

Message ID HE1PR0301MB215462B4B1B25255C38135DC8F5F9@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,01/46] avcodec/a64multienc: Avoid intermediate buffer
Related show

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 April 29, 2021, 11:57 p.m. UTC
Trivial for an encoder that knows the size of the output packet in advance.

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

Patch

diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index baaab749fd..eec304448e 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -25,6 +25,7 @@ 
  */
 
 #include "avcodec.h"
+#include "encode.h"
 #include "raw.h"
 #include "internal.h"
 #include "libavutil/pixdesc.h"
@@ -53,7 +54,7 @@  static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
     if (ret < 0)
         return ret;
 
-    if ((ret = ff_alloc_packet2(avctx, pkt, ret, ret)) < 0)
+    if ((ret = ff_get_encode_buffer(avctx, pkt, ret, 0)) < 0)
         return ret;
     if ((ret = av_image_copy_to_buffer(pkt->data, pkt->size,
                                        (const uint8_t **)frame->data, frame->linesize,
@@ -85,6 +86,7 @@  const AVCodec ff_rawvideo_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("raw video"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_RAWVIDEO,
+    .capabilities   = AV_CODEC_CAP_DR1,
     .init           = raw_encode_init,
     .encode2        = raw_encode,
 };