diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-03-22 02:47:44 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-03-22 03:40:11 +0400 |
commit | 967facb6950549d0cc4e0ba79a056ebc6f93a049 (patch) | |
tree | 872266e5d486be0ab8cf9e378bf567c191fba71a /libavcodec/libgsm.c | |
parent | f1fdd208cc0a1fce7aaaf6b0fe72b013525f49e0 (diff) | |
parent | 6aba117f1273c7704312c6d892c9f552fa0661bb (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (26 commits)
adxenc: use AVCodec.encode2()
adxenc: Use the AVFrame in ADXContext for coded_frame
indeo4: fix out-of-bounds function call.
configure: Restructure help output.
configure: Internal-only components should not be command-line selectable.
vorbisenc: use AVCodec.encode2()
libvorbis: use AVCodec.encode2()
libopencore-amrnbenc: use AVCodec.encode2()
ra144enc: use AVCodec.encode2()
nellymoserenc: use AVCodec.encode2()
roqaudioenc: use AVCodec.encode2()
libspeex: use AVCodec.encode2()
libvo_amrwbenc: use AVCodec.encode2()
libvo_aacenc: use AVCodec.encode2()
wmaenc: use AVCodec.encode2()
mpegaudioenc: use AVCodec.encode2()
libmp3lame: use AVCodec.encode2()
libgsmenc: use AVCodec.encode2()
libfaac: use AVCodec.encode2()
g726enc: use AVCodec.encode2()
...
Conflicts:
configure
libavcodec/Makefile
libavcodec/ac3enc.c
libavcodec/adxenc.c
libavcodec/libgsm.c
libavcodec/libvorbis.c
libavcodec/vorbisenc.c
libavcodec/wmaenc.c
tests/ref/acodec/g722
tests/ref/lavf/asf
tests/ref/lavf/ffm
tests/ref/lavf/mkv
tests/ref/lavf/mpg
tests/ref/lavf/rm
tests/ref/lavf/ts
tests/ref/seek/lavf_asf
tests/ref/seek/lavf_ffm
tests/ref/seek/lavf_mkv
tests/ref/seek/lavf_mpg
tests/ref/seek/lavf_rm
tests/ref/seek/lavf_ts
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libgsm.c')
-rw-r--r-- | libavcodec/libgsm.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c index 1a2145581a..8a5ad0024f 100644 --- a/libavcodec/libgsm.c +++ b/libavcodec/libgsm.c @@ -30,10 +30,13 @@ #include <gsm/gsm.h> #include "avcodec.h" +#include "internal.h" #include "gsm.h" static av_cold int libgsm_encode_close(AVCodecContext *avctx) { +#if FF_API_OLD_ENCODE_AUDIO av_freep(&avctx->coded_frame); +#endif gsm_destroy(avctx->priv_data); avctx->priv_data = NULL; return 0; @@ -78,9 +81,11 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) { } } +#if FF_API_OLD_ENCODE_AUDIO avctx->coded_frame= avcodec_alloc_frame(); if (!avctx->coded_frame) goto error; +#endif return 0; error: @@ -88,20 +93,29 @@ error: return -1; } -static int libgsm_encode_frame(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) { - // we need a full block - if(buf_size < avctx->block_align) return 0; +static int libgsm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr) +{ + int ret; + gsm_signal *samples = (gsm_signal *)frame->data[0]; + struct gsm_state *state = avctx->priv_data; + + if ((ret = ff_alloc_packet(avpkt, avctx->block_align))) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); + return ret; + } switch(avctx->codec_id) { case CODEC_ID_GSM: - gsm_encode(avctx->priv_data,data,frame); + gsm_encode(state, samples, avpkt->data); break; case CODEC_ID_GSM_MS: - gsm_encode(avctx->priv_data,data,frame); - gsm_encode(avctx->priv_data,((short*)data)+GSM_FRAME_SIZE,frame+32); + gsm_encode(state, samples, avpkt->data); + gsm_encode(state, samples + GSM_FRAME_SIZE, avpkt->data + 32); } - return avctx->block_align; + + *got_packet_ptr = 1; + return 0; } @@ -110,7 +124,7 @@ AVCodec ff_libgsm_encoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_GSM, .init = libgsm_encode_init, - .encode = libgsm_encode_frame, + .encode2 = libgsm_encode_frame, .close = libgsm_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), @@ -121,7 +135,7 @@ AVCodec ff_libgsm_ms_encoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_GSM_MS, .init = libgsm_encode_init, - .encode = libgsm_encode_frame, + .encode2 = libgsm_encode_frame, .close = libgsm_encode_close, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), |