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-23 14:41:28 +0200 |
commit | 398822a70edf860cd47514e34e15c80c2dfca584 (patch) | |
tree | c7a5ee741c672b1cfd1625939c4ec7984f249e7b /libavcodec/libcodec2.c | |
parent | 044daa7c450b132f4f5cdecb738089b3dd7db3f7 (diff) | |
download | ffmpeg-398822a70edf860cd47514e34e15c80c2dfca584.tar.gz |
avcodec/libcodec2: 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.
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/libcodec2.c')
-rw-r--r-- | libavcodec/libcodec2.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 562a616f59..2996dc42f5 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -22,6 +22,7 @@ #include <codec2/codec2.h> #include "avcodec.h" #include "libavutil/opt.h" +#include "encode.h" #include "internal.h" #include "codec2utils.h" @@ -169,7 +170,7 @@ static int libcodec2_encode(AVCodecContext *avctx, AVPacket *avpkt, LibCodec2Context *c2 = avctx->priv_data; int16_t *samples = (int16_t *)frame->data[0]; - int ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0); + int ret = ff_get_encode_buffer(avctx, avpkt, avctx->block_align, 0); if (ret < 0) { return ret; } @@ -201,11 +202,11 @@ const AVCodec ff_libcodec2_encoder = { .long_name = NULL_IF_CONFIG_SMALL("codec2 encoder using libcodec2"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_CODEC2, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(LibCodec2Context), .init = libcodec2_init_encoder, .close = libcodec2_close, .encode2 = libcodec2_encode, - .capabilities = 0, .supported_samplerates = (const int[]){ 8000, 0 }, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, |