summaryrefslogtreecommitdiff
path: root/libavcodec/libgsmenc.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-23 14:42:02 +0200
commit91567c28fc178d8f3c226b66dd40572f4eadd35c (patch)
tree35bae0b2fc27e7a12d305d8e34782ca203286204 /libavcodec/libgsmenc.c
parent398822a70edf860cd47514e34e15c80c2dfca584 (diff)
avcodec/libgsmenc: 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/libgsmenc.c')
-rw-r--r--libavcodec/libgsmenc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c
index 850963e8f6..97ba789046 100644
--- a/libavcodec/libgsmenc.c
+++ b/libavcodec/libgsmenc.c
@@ -37,6 +37,7 @@
#include "libavutil/common.h"
#include "avcodec.h"
+#include "encode.h"
#include "internal.h"
#include "gsm.h"
@@ -98,7 +99,7 @@ static int libgsm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
gsm_signal *samples = (gsm_signal *)frame->data[0];
struct gsm_state *state = avctx->priv_data;
- if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0)) < 0)
+ if ((ret = ff_get_encode_buffer(avctx, avpkt, avctx->block_align, 0)) < 0)
return ret;
switch(avctx->codec_id) {
@@ -125,6 +126,7 @@ const AVCodec ff_libgsm_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_GSM,
+ .capabilities = AV_CODEC_CAP_DR1,
.init = libgsm_encode_init,
.encode2 = libgsm_encode_frame,
.close = libgsm_encode_close,
@@ -141,6 +143,7 @@ const AVCodec ff_libgsm_ms_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_GSM_MS,
+ .capabilities = AV_CODEC_CAP_DR1,
.init = libgsm_encode_init,
.encode2 = libgsm_encode_frame,
.close = libgsm_encode_close,