diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-02-23 13:11:08 -0500 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-02-26 03:16:03 +0100 |
commit | fb0e3c2b9696c7adc71db872f847a4d6497b5eed (patch) | |
tree | 750a06ffea6495a23a1e5148e711f52b3c7d2be2 | |
parent | 6f3c837f40a672cbf9805b0d6af41fa654072dea (diff) | |
download | ffmpeg-fb0e3c2b9696c7adc71db872f847a4d6497b5eed.tar.gz |
vmdaudio: move all silence chunk handling to vmdaudio_loadsound().
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 762b386e4aafc7bbdbec367bc652cf1199e81f51)
-rw-r--r-- | libavcodec/vmdav.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 48739a726b..b3103ec220 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -477,13 +477,15 @@ static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data, } static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data, - const uint8_t *buf, int silence, int data_size) + const uint8_t *buf, int silent_chunks, int data_size) { int i; + int silent_size = s->block_align * silent_chunks * 2; - if (silence) { - memset(data, 0, data_size * 2); - } else { + if (silent_chunks) { + memset(data, 0, silent_size); + data += silent_size; + } if (s->bits == 16) vmdaudio_decode_audio(s, data, buf, data_size, s->channels == 2); else { @@ -493,9 +495,8 @@ static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data, *data++ = buf[i] + 0x80; } } - } - return data_size * 2; + return silent_size + data_size * 2; } static int vmdaudio_decode_frame(AVCodecContext *avctx, @@ -528,21 +529,15 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, } else if (block_type == BLOCK_TYPE_INITIAL) { /* initial chunk, may contain audio and silence */ uint32_t flags = AV_RB32(buf); - int raw_block_size = s->block_align * - (av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8); int silent_chunks = av_popcount(flags); buf += 4; buf_size -= 4; if(*data_size < (s->block_align*silent_chunks + buf_size) * 2) return -1; - *data_size = 0; - memset(output_samples, 0, raw_block_size * silent_chunks); - output_samples += raw_block_size * silent_chunks; - *data_size = raw_block_size * silent_chunks; - *data_size += vmdaudio_loadsound(s, output_samples, buf, 0, buf_size); + *data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size); } else if (block_type == BLOCK_TYPE_SILENCE) { /* silent chunk */ - *data_size = vmdaudio_loadsound(s, output_samples, buf, 1, s->block_align); + *data_size = vmdaudio_loadsound(s, output_samples, buf, 1, 0); } return avpkt->size; |