summaryrefslogtreecommitdiff
path: root/libavcodec/vmdav.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-03 02:08:55 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-03 03:00:30 +0100
commite4de71677f3adeac0f74b89ac8df5d417364df2c (patch)
tree4792dd8d85d24f0f4eaddabb65f6044727907daa /libavcodec/vmdav.c
parent12804348f5babf56a315fa01751eea1ffdddf98a (diff)
parentd268b79e3436107c11ee8bcdf9f3645368bb3fcd (diff)
downloadffmpeg-e4de71677f3adeac0f74b89ac8df5d417364df2c.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: aac_latm: reconfigure decoder on audio specific config changes latmdec: fix audio specific config parsing Add avcodec_decode_audio4(). avcodec: change number of plane pointers from 4 to 8 at next major bump. Update developers documentation with coding conventions. svq1dec: avoid undefined get_bits(0) call ARM: h264dsp_neon cosmetics ARM: make some NEON macros reusable Do not memcpy raw video frames when using null muxer fate: update asf seektest vp8: flush buffers on size changes. doc: improve general documentation for MacOSX asf: use packet dts as approximation of pts asf: do not call av_read_frame rtsp: Initialize the media_type_mask in the rtp guessing demuxer Cleaned up alacenc.c Conflicts: doc/APIchanges doc/developer.texi libavcodec/8svx.c libavcodec/aacdec.c libavcodec/ac3dec.c libavcodec/avcodec.h libavcodec/nellymoserdec.c libavcodec/tta.c libavcodec/utils.c libavcodec/version.h libavcodec/wmadec.c libavformat/asfdec.c tests/ref/seek/lavf_asf Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vmdav.c')
-rw-r--r--libavcodec/vmdav.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index 06c6255cc5..ec7c967f74 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -466,6 +466,7 @@ static av_cold int vmdvideo_decode_end(AVCodecContext *avctx)
#define BLOCK_TYPE_SILENCE 3
typedef struct VmdAudioContext {
+ AVFrame frame;
int out_bps;
int chunk_size;
} VmdAudioContext;
@@ -507,6 +508,9 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx)
s->chunk_size = avctx->block_align + avctx->channels * (s->out_bps == 2);
+ avcodec_get_frame_defaults(&s->frame);
+ avctx->coded_frame = &s->frame;
+
av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "
"block align = %d, sample rate = %d\n",
avctx->channels, avctx->bits_per_coded_sample, avctx->block_align,
@@ -544,22 +548,21 @@ static void decode_audio_s16(int16_t *out, const uint8_t *buf, int buf_size,
}
}
-static int vmdaudio_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
+static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks, audio_chunks;
- int nb_samples, out_size;
- uint8_t *output_samples_u8 = data;
- int16_t *output_samples_s16 = data;
+ int ret;
+ uint8_t *output_samples_u8;
+ int16_t *output_samples_s16;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
- *data_size = 0;
+ *got_frame_ptr = 0;
return buf_size;
}
@@ -590,10 +593,15 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
/* ensure output buffer is large enough */
audio_chunks = buf_size / s->chunk_size;
- nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
- out_size = nb_samples * avctx->channels * s->out_bps;
- if (*data_size < out_size)
- return -1;
+
+ /* get output buffer */
+ s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
+ if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+ output_samples_u8 = s->frame.data[0];
+ output_samples_s16 = (int16_t *)s->frame.data[0];
/* decode silent chunks */
if (silent_chunks > 0) {
@@ -623,7 +631,9 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
}
}
- *data_size = out_size;
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = s->frame;
+
return avpkt->size;
}
@@ -651,5 +661,6 @@ AVCodec ff_vmdaudio_decoder = {
.priv_data_size = sizeof(VmdAudioContext),
.init = vmdaudio_decode_init,
.decode = vmdaudio_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"),
};