diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2010-09-06 17:53:29 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2010-09-06 17:53:29 +0000 |
commit | 6974952d241b148a608e47b1c516145c34c421ff (patch) | |
tree | e9c46e637219f8a5944df119bfcaa164d90337e7 | |
parent | 1b4d327b1c7ab01495ea896cf9034d5eed8c4893 (diff) | |
download | ffmpeg-6974952d241b148a608e47b1c516145c34c421ff.tar.gz |
VP3/Theora: validate aspect and reduce it before exporting it
via the context.
Originally committed as revision 25050 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/vp3.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 9b9cbd9be7..7e1a8ef95d 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1965,7 +1965,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) Vp3DecodeContext *s = avctx->priv_data; int visible_width, visible_height, colorspace; int offset_x = 0, offset_y = 0; - AVRational fps; + AVRational fps, aspect; s->theora = get_bits_long(gb, 24); av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora); @@ -2002,8 +2002,13 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) fps.den, fps.num, 1<<30); } - avctx->sample_aspect_ratio.num = get_bits_long(gb, 24); - avctx->sample_aspect_ratio.den = get_bits_long(gb, 24); + aspect.num = get_bits_long(gb, 24); + aspect.den = get_bits_long(gb, 24); + if (aspect.num && aspect.den) { + av_reduce(&avctx->sample_aspect_ratio.num, + &avctx->sample_aspect_ratio.den, + aspect.num, aspect.den, 1<<30); + } if (s->theora < 0x030200) skip_bits(gb, 5); /* keyframe frequency force */ |