[FFmpeg-devel] [PATCH 30/46] avcodec/r210enc: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Fri Apr 30 02:57:01 EEST 2021
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 at outlook.com>
---
libavcodec/r210enc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index 89518bce29..b143f516c1 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -21,6 +21,7 @@
*/
#include "avcodec.h"
+#include "encode.h"
#include "internal.h"
#include "bytestream.h"
@@ -46,7 +47,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint8_t *srcr_line, *srcg_line, *srcb_line;
uint8_t *dst;
- if ((ret = ff_alloc_packet2(avctx, pkt, 4 * aligned_width * avctx->height, 0)) < 0)
+ ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0);
+ if (ret < 0)
return ret;
srcg_line = pic->data[0];
@@ -91,6 +93,7 @@ const AVCodec ff_r210_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_R210,
+ .capabilities = AV_CODEC_CAP_DR1,
.init = encode_init,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },
@@ -102,6 +105,7 @@ const AVCodec ff_r10k_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_R10K,
+ .capabilities = AV_CODEC_CAP_DR1,
.init = encode_init,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },
@@ -113,6 +117,7 @@ const AVCodec ff_avrp_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_AVRP,
+ .capabilities = AV_CODEC_CAP_DR1,
.init = encode_init,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },
--
2.27.0
More information about the ffmpeg-devel
mailing list