[FFmpeg-cvslog] s302m: fix arithmetic exception
Andreas Cadhalpun
git at videolan.org
Thu Nov 26 01:46:57 CET 2015
ffmpeg | branch: release/2.6 | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Fri Jun 26 19:31:03 2015 +0200| [1d852105c200a313f9db34d2038dca6875a96780] | committer: Andreas Cadhalpun
s302m: fix arithmetic exception
If nb_samples is zero, the bit_rate calculation results in a division by
zero.
Since ff_get_buffer fails if frame->nb_samples is zero, this can be
fixed by moving the bit_rate calculation after that function call.
That also makes it possible to reuse the already calculated
frame->nb_samples value.
Reviewed-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
(cherry picked from commit 04dfbc9441beed93984568c1547f1ed588122627)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1d852105c200a313f9db34d2038dca6875a96780
---
libavcodec/s302m.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index 2ce1038..61c0fe8 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -79,10 +79,6 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
case 8:
avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK | AV_CH_LAYOUT_STEREO_DOWNMIX;
}
- avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) +
- 32 * (48000 / (buf_size * 8 /
- (avctx->channels *
- (avctx->bits_per_raw_sample + 4))));
return frame_size;
}
@@ -108,6 +104,8 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
+ avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) +
+ 32 * 48000 / frame->nb_samples;
buf_size = (frame->nb_samples * avctx->channels / 2) * block_size;
if (avctx->bits_per_raw_sample == 24) {
More information about the ffmpeg-cvslog
mailing list