mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
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>
This commit is contained in:
parent
398822a70e
commit
91567c28fc
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user