diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 12:14:46 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 12:14:46 +0100 |
commit | afe30fe0600824b0dcda8318f09a5a4e376b99c3 (patch) | |
tree | 06921b98421767cea958eed3943b10fb71e4997d /libavcodec/libopusdec.c | |
parent | 5459cf411412c7a1d2da7ce6a6955c7d57490a55 (diff) | |
parent | 86bfcfcf2364bc837b7bb582c66a8a15a332414f (diff) | |
download | ffmpeg-afe30fe0600824b0dcda8318f09a5a4e376b99c3.tar.gz |
Merge commit '86bfcfcf2364bc837b7bb582c66a8a15a332414f'
* commit '86bfcfcf2364bc837b7bb582c66a8a15a332414f':
mace: decode directly to the user-provided AVFrame
libspeex: decode directly to the user-provided AVFrame
libopus: decode directly to the user-provided AVFrame
libopencore-amr: decode directly to the user-provided AVFrame
libgsm: decode directly to the user-provided AVFrame
Conflicts:
libavcodec/libopusdec.c
libavcodec/mace.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libopusdec.c')
-rw-r--r-- | libavcodec/libopusdec.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index f603bdf186..686b8a6798 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -32,7 +32,6 @@ struct libopus_context { OpusMSDecoder *dec; - AVFrame frame; int pre_skip; #ifndef OPUS_SET_GAIN union { int i; double d; } gain; @@ -111,8 +110,7 @@ static av_cold int libopus_decode_init(AVCodecContext *avc) avc->internal->skip_samples = opus->pre_skip; avc->delay = 3840; /* Decoder delay (in samples) at 48kHz */ - avcodec_get_frame_defaults(&opus->frame); - avc->coded_frame = &opus->frame; + return 0; } @@ -126,14 +124,15 @@ static av_cold int libopus_decode_close(AVCodecContext *avc) #define MAX_FRAME_SIZE (960 * 6) -static int libopus_decode(AVCodecContext *avc, void *frame, +static int libopus_decode(AVCodecContext *avc, void *data, int *got_frame_ptr, AVPacket *pkt) { struct libopus_context *opus = avc->priv_data; + AVFrame *frame = data; int ret, nb_samples; - opus->frame.nb_samples = MAX_FRAME_SIZE; - ret = ff_get_buffer(avc, &opus->frame); + frame->nb_samples = MAX_FRAME_SIZE; + ret = ff_get_buffer(avc, frame); if (ret < 0) { av_log(avc, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; @@ -141,12 +140,12 @@ static int libopus_decode(AVCodecContext *avc, void *frame, if (avc->sample_fmt == AV_SAMPLE_FMT_S16) nb_samples = opus_multistream_decode(opus->dec, pkt->data, pkt->size, - (opus_int16 *)opus->frame.data[0], - opus->frame.nb_samples, 0); + (opus_int16 *)frame->data[0], + frame->nb_samples, 0); else nb_samples = opus_multistream_decode_float(opus->dec, pkt->data, pkt->size, - (float *)opus->frame.data[0], - opus->frame.nb_samples, 0); + (float *)frame->data[0], + frame->nb_samples, 0); if (nb_samples < 0) { av_log(avc, AV_LOG_ERROR, "Decoding error: %s\n", @@ -158,20 +157,20 @@ static int libopus_decode(AVCodecContext *avc, void *frame, { int i = avc->channels * nb_samples; if (avc->sample_fmt == AV_SAMPLE_FMT_FLT) { - float *pcm = (float *)opus->frame.data[0]; + float *pcm = (float *)frame->data[0]; for (; i > 0; i--, pcm++) *pcm = av_clipf(*pcm * opus->gain.d, -1, 1); } else { - int16_t *pcm = (int16_t *)opus->frame.data[0]; + int16_t *pcm = (int16_t *)frame->data[0]; for (; i > 0; i--, pcm++) *pcm = av_clip_int16(((int64_t)opus->gain.i * *pcm) >> 16); } } #endif - opus->frame.nb_samples = nb_samples; - *(AVFrame *)frame = opus->frame; - *got_frame_ptr = 1; + frame->nb_samples = nb_samples; + *got_frame_ptr = 1; + return pkt->size; } |