aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-25 01:43:26 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-05 14:17:03 +0200
commit27b0a5204d7d1a56abba1bf981123cc29a9f17bc (patch)
tree79365f8efd17d0b73c241036cf866e5ec5807dcf
parent1dc8f237872daed6bca9a2e444fd60c5bbf72b44 (diff)
downloadffmpeg-27b0a5204d7d1a56abba1bf981123cc29a9f17bc.tar.gz
avcodec/v308enc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/v308enc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c
index f3fb617a7b..6b58bb102c 100644
--- a/libavcodec/v308enc.c
+++ b/libavcodec/v308enc.c
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
+#include "encode.h"
#include "internal.h"
static av_cold int v308_encode_init(AVCodecContext *avctx)
@@ -44,7 +45,8 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint8_t *y, *u, *v;
int i, j, ret;
- if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 3, 0)) < 0)
+ ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0);
+ if (ret < 0)
return ret;
dst = pkt->data;
@@ -73,6 +75,7 @@ const AVCodec ff_v308_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_V308,
+ .capabilities = AV_CODEC_CAP_DR1,
.init = v308_encode_init,
.encode2 = v308_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE },