aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pcm.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-09-27 19:49:25 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-26 12:01:06 -0400
commitd94e29cac94d1f938cf3a25320522cc9de0a6b86 (patch)
treecbe83c8a3dd527e5e9517fe06a15d959bf8fc72c /libavcodec/pcm.c
parent83efd7652e6bf916bfecfc0ff4c961df928d228e (diff)
downloadffmpeg-d94e29cac94d1f938cf3a25320522cc9de0a6b86.tar.gz
pcmdec: move number of channels check to pcm_decode_init()
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r--libavcodec/pcm.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index c0d093015a..2a50a8146d 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -213,6 +213,11 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx)
PCMDecode *s = avctx->priv_data;
int i;
+ if (avctx->channels <= 0 || avctx->channels > MAX_CHANNELS) {
+ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
+ return AVERROR(EINVAL);
+ }
+
switch(avctx->codec->id) {
case CODEC_ID_PCM_ALAW:
for(i=0;i<256;i++)
@@ -266,11 +271,6 @@ static int pcm_decode_frame(AVCodecContext *avctx,
samples = data;
src = buf;
- if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){
- av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
- return -1;
- }
-
sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
/* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */