comparison pcm.c @ 7628:2f5ed95d1039 libavcodec

Fix PCM DVD divide by zero bug introduced in r14659. Patch supplied by lars dot taeuber at gmx dot net.
author pross
date Wed, 20 Aug 2008 11:05:15 +0000
parents ff395fe35161
children 3db125934e60
comparison
equal deleted inserted replaced
7627:93c5703328d6 7628:2f5ed95d1039
348 return -1; 348 return -1;
349 } 349 }
350 350
351 sample_size = av_get_bits_per_sample(avctx->codec_id)/8; 351 sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
352 352
353 n = avctx->channels * sample_size;
354 /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ 353 /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */
355 if (CODEC_ID_PCM_DVD == avctx->codec_id) 354 if (CODEC_ID_PCM_DVD == avctx->codec_id)
356 /* 2 samples are interleaved per block in PCM_DVD */ 355 /* 2 samples are interleaved per block in PCM_DVD */
357 n = 2 * avctx->channels * avctx->bits_per_sample/8; 356 sample_size = avctx->bits_per_sample * 2 / 8;
357
358 n = avctx->channels * sample_size;
358 359
359 if(n && buf_size % n){ 360 if(n && buf_size % n){
360 av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); 361 av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
361 return -1; 362 return -1;
362 } 363 }