summaryrefslogtreecommitdiff
path: root/libavcodec/adpcm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-24 22:37:24 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-24 22:39:52 +0200
commiteae3cf06a5410cf6d06235de4ceea28e33e53be3 (patch)
tree126512350cc96249cd1d157969a87a0018f6ab53 /libavcodec/adpcm.c
parent0f2297a9b958b8598b17f139e7ec2d7e593a0a7c (diff)
parent2b4e49d4281690db67073ba644ad2ffc17767cdf (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: flvdec: Fix invalid pointer deferences when parsing index configure: disable hardware capabilities ELF section with suncc on Solaris x86 Use explicit struct initializers for AVCodec declarations. Use explicit struct initializers for AVOutputFormat/AVInputFormat declarations. adpcmenc: Set bits_per_coded_sample adpcmenc: fix QT IMA ADPCM encoder adpcmdec: Fix QT IMA ADPCM decoder permit decoding of multichannel ADPCM_EA_XAS Fix input buffer size check in adpcm_ea decoder. fft: avoid a signed overflow mpegps: Handle buffer exhaustion when reading packets. Conflicts: libavcodec/adpcm.c libavcodec/adpcmenc.c libavdevice/alsa-audio-enc.c libavformat/flvdec.c libavformat/mpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r--libavcodec/adpcm.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 77e1ef63b2..3cb62e31ed 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -666,11 +666,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
}
break;
case CODEC_ID_ADPCM_EA:
- if (buf_size < 12 || AV_RL32(src) > (buf_size - 12)/30*28) {
- src += buf_size;
- break;
+ /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
+ each coding 28 stereo samples. */
+ if (buf_size < 12) {
+ av_log(avctx, AV_LOG_ERROR, "frame too small\n");
+ return AVERROR(EINVAL);
}
samples_in_chunk = AV_RL32(src);
+ if (samples_in_chunk / 28 > (buf_size - 12) / 30) {
+ av_log(avctx, AV_LOG_ERROR, "invalid frame\n");
+ return AVERROR(EINVAL);
+ }
src += 4;
current_left_sample = (int16_t)bytestream_get_le16(&src);
previous_left_sample = (int16_t)bytestream_get_le16(&src);
@@ -1080,17 +1086,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
}
-#define ADPCM_DECODER(id,name,long_name_) \
-AVCodec ff_ ## name ## _decoder = { \
- #name, \
- AVMEDIA_TYPE_AUDIO, \
- id, \
- sizeof(ADPCMDecodeContext), \
- adpcm_decode_init, \
- NULL, \
- NULL, \
- adpcm_decode_frame, \
- .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
+#define ADPCM_DECODER(id_, name_, long_name_) \
+AVCodec ff_ ## name_ ## _decoder = { \
+ .name = #name_, \
+ .type = AVMEDIA_TYPE_AUDIO, \
+ .id = id_, \
+ .priv_data_size = sizeof(ADPCMDecodeContext), \
+ .init = adpcm_decode_init, \
+ .decode = adpcm_decode_frame, \
+ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
}
/* Note: Do not forget to add new entries to the Makefile as well. */