diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-25 01:43:26 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-05-05 14:17:03 +0200 |
commit | fbfae5eb36db0b0be1a8b9c715388e9fcfea0c0f (patch) | |
tree | 3d9b4c154ca92e68a3104a406c381503335cac3d /libavcodec/s302menc.c | |
parent | 7bb7161f86c6524e3eb1cb3fdd48f39e5bd942b8 (diff) | |
download | ffmpeg-fbfae5eb36db0b0be1a8b9c715388e9fcfea0c0f.tar.gz |
avcodec/s302menc: 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>
Diffstat (limited to 'libavcodec/s302menc.c')
-rw-r--r-- | libavcodec/s302menc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c index b9f35fb0cb..33633627f6 100644 --- a/libavcodec/s302menc.c +++ b/libavcodec/s302menc.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "mathops.h" #include "put_bits.h" @@ -83,7 +84,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, return AVERROR(EINVAL); } - if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, buf_size, 0)) < 0) return ret; o = avpkt->data; @@ -172,13 +173,14 @@ const AVCodec ff_s302m_encoder = { .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_S302M, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | + AV_CODEC_CAP_VARIABLE_FRAME_SIZE, .priv_data_size = sizeof(S302MEncContext), .init = s302m_encode_init, .encode2 = s302m_encode2_frame, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE | AV_CODEC_CAP_EXPERIMENTAL, .supported_samplerates = (const int[]) { 48000, 0 }, /* .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_QUAD, |