aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vmdav.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-02-23 13:11:07 -0500
committerRonald S. Bultje <rsbultje@gmail.com>2011-02-23 21:12:39 -0500
commit2d213695fce86e740800ddcf43d8d0864d2ecea5 (patch)
tree56c245c16180825e4212fd12945d65b59b31b5e5 /libavcodec/vmdav.c
parent7a4fb3fd9357dfdd27431a0a8d7250dab54a9938 (diff)
downloadffmpeg-2d213695fce86e740800ddcf43d8d0864d2ecea5.tar.gz
vmdaudio: simplify buffer pointer and header size handling.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/vmdav.c')
-rw-r--r--libavcodec/vmdav.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index 1407c96588..5ee4248ab7 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -511,9 +511,6 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
int block_type;
unsigned char *output_samples = (unsigned char *)data;
- /* point to the start of the encoded data */
- const unsigned char *p = buf + 16;
-
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
@@ -525,29 +522,33 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
+ buf += 16;
+ buf_size -= 16;
if (block_type == BLOCK_TYPE_AUDIO) {
/* the chunk contains audio */
- *data_size = vmdaudio_loadsound(s, output_samples, p, 0, buf_size - 16);
+ *data_size = vmdaudio_loadsound(s, output_samples, buf, 0, buf_size);
} else if (block_type == BLOCK_TYPE_INITIAL) {
/* initial chunk, may contain audio and silence */
- uint32_t flags = AV_RB32(p);
+ 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);
- if(*data_size < (s->block_align*silent_chunks + buf_size - 20) * 2)
+ 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, p + 4, 0, buf_size - 20);
+ *data_size += vmdaudio_loadsound(s, output_samples, buf, 0, buf_size);
} else if (block_type == BLOCK_TYPE_SILENCE) {
/* silent chunk */
- *data_size = vmdaudio_loadsound(s, output_samples, p, 1, s->block_align);
+ *data_size = vmdaudio_loadsound(s, output_samples, buf, 1, s->block_align);
}
- return buf_size;
+ return avpkt->size;
}