1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2025-03-04 19:48:19 +00:00

avcodec/r210enc: 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>
This commit is contained in:
Andreas Rheinhardt 2021-04-25 01:43:26 +02:00
parent 0788069cb1
commit 5cb64caadf

View File

@ -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 },
@ -103,6 +106,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 },
@ -115,6 +119,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 },