diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-03-02 16:10:00 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-03-03 18:20:09 -0500 |
commit | c2b8dea1828f35c808adcf12615893d5c740bc0a (patch) | |
tree | 57cbc44632ece14ac7c01a539cf7c9fcc8dd80bd | |
parent | b7beabab4b78cc253d06c0a33f15b8ff79866e85 (diff) | |
download | ffmpeg-c2b8dea1828f35c808adcf12615893d5c740bc0a.tar.gz |
wmaenc: limit block_align to MAX_CODED_SUPERFRAME_SIZE
This is near the theoretical limit for wma frame size and is the most that
our decoder can handle. Allowing higher bit rates will just end up padding
each frame with empty bytes.
Fixes invalid writes for avconv when using very high bit rates.
CC:libav-stable@libav.org
-rw-r--r-- | libavcodec/wmaenc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index c762a723b9..e24a3f4205 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -71,8 +71,12 @@ static int encode_init(AVCodecContext * avctx){ for(i = 0; i < s->nb_block_sizes; i++) ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0); - avctx->block_align= - s->block_align= avctx->bit_rate*(int64_t)s->frame_len / (avctx->sample_rate*8); + s->block_align = avctx->bit_rate * (int64_t)s->frame_len / + (avctx->sample_rate * 8); + s->block_align = FFMIN(s->block_align, MAX_CODED_SUPERFRAME_SIZE); + avctx->block_align = s->block_align; + avctx->bit_rate = avctx->block_align * 8LL * avctx->sample_rate / + s->frame_len; //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", s->block_align, avctx->bit_rate, s->frame_len, avctx->sample_rate); avctx->frame_size= s->frame_len; |