aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/adxenc.c
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 12:27:04 +0200
commitad232c6833d9f192324c9e99c19d1b4dd7852828 (patch)
treef343cf249ae02ce4a43adef0e199739dd95b0a0c /libavcodec/adxenc.c
parent39bb36d7231b4dd5eec8105903cd8e323b2c0474 (diff)
downloadffmpeg-ad232c6833d9f192324c9e99c19d1b4dd7852828.tar.gz
avcodec/adxenc: 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/adxenc.c')
-rw-r--r--libavcodec/adxenc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
index fecc0ce384..c5849a40a1 100644
--- a/libavcodec/adxenc.c
+++ b/libavcodec/adxenc.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "adx.h"
#include "bytestream.h"
+#include "encode.h"
#include "internal.h"
#include "put_bits.h"
@@ -148,7 +149,7 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (!samples) {
if (c->eof)
return 0;
- if ((ret = ff_alloc_packet2(avctx, avpkt, 18, 0)) < 0)
+ if ((ret = ff_get_encode_buffer(avctx, avpkt, 18, 0)) < 0)
return ret;
c->eof = 1;
dst = avpkt->data;
@@ -162,7 +163,7 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
}
out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed * HEADER_SIZE;
- if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0)
+ if ((ret = ff_get_encode_buffer(avctx, avpkt, out_size, 0)) < 0)
return ret;
dst = avpkt->data;
@@ -192,10 +193,10 @@ const AVCodec ff_adpcm_adx_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_ADPCM_ADX,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.priv_data_size = sizeof(ADXContext),
.init = adx_encode_init,
.encode2 = adx_encode_frame,
- .capabilities = AV_CODEC_CAP_DELAY,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,