summaryrefslogtreecommitdiff
path: root/libavcodec/tta.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-10-23 16:25:02 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-25 11:22:02 -0400
commitb5050539c9e78186fc090a5c8b6b767590484c59 (patch)
tree8c6d3357f251e4e6955eda8395346034d70a549d /libavcodec/tta.c
parentc6056d40049c2be6450982e9c6ce0b9571bd2403 (diff)
tta: use correct frame_length calculation.
using a floating-point calculation is not necessary.
Diffstat (limited to 'libavcodec/tta.c')
-rw-r--r--libavcodec/tta.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index b7b20e459b..ddfcb2ebc1 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -217,10 +217,6 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
avctx->bits_per_coded_sample = get_bits(&s->gb, 16);
s->bps = (avctx->bits_per_coded_sample + 7) / 8;
avctx->sample_rate = get_bits_long(&s->gb, 32);
- if(avctx->sample_rate > 1000000){ //prevent FRAME_TIME * avctx->sample_rate from overflowing and sanity check
- av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n");
- return -1;
- }
s->data_length = get_bits_long(&s->gb, 32);
skip_bits(&s->gb, 32); // CRC32 of header
@@ -238,9 +234,12 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
return AVERROR_INVALIDDATA;
}
- // FIXME: horribly broken, but directly from reference source
-#define FRAME_TIME 1.04489795918367346939
- s->frame_length = (int)(FRAME_TIME * avctx->sample_rate);
+ // prevent overflow
+ if (avctx->sample_rate > 0x7FFFFF) {
+ av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n");
+ return AVERROR(EINVAL);
+ }
+ s->frame_length = 256 * avctx->sample_rate / 245;
s->last_frame_length = s->data_length % s->frame_length;
s->total_frames = s->data_length / s->frame_length +