Mercurial > libavcodec.hg
comparison vp3.c @ 12459:b3f8dba49d1f libavcodec
VP3/Theora: validate aspect and reduce it before exporting it
via the context.
author | reimar |
---|---|
date | Mon, 06 Sep 2010 17:53:29 +0000 |
parents | 914f484bb476 |
children | 7106d2c8f142 |
comparison
equal
deleted
inserted
replaced
12458:4a425a99f543 | 12459:b3f8dba49d1f |
---|---|
1963 static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) | 1963 static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) |
1964 { | 1964 { |
1965 Vp3DecodeContext *s = avctx->priv_data; | 1965 Vp3DecodeContext *s = avctx->priv_data; |
1966 int visible_width, visible_height, colorspace; | 1966 int visible_width, visible_height, colorspace; |
1967 int offset_x = 0, offset_y = 0; | 1967 int offset_x = 0, offset_y = 0; |
1968 AVRational fps; | 1968 AVRational fps, aspect; |
1969 | 1969 |
1970 s->theora = get_bits_long(gb, 24); | 1970 s->theora = get_bits_long(gb, 24); |
1971 av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora); | 1971 av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora); |
1972 | 1972 |
1973 /* 3.2.0 aka alpha3 has the same frame orientation as original vp3 */ | 1973 /* 3.2.0 aka alpha3 has the same frame orientation as original vp3 */ |
2000 if (fps.num && fps.den) { | 2000 if (fps.num && fps.den) { |
2001 av_reduce(&avctx->time_base.num, &avctx->time_base.den, | 2001 av_reduce(&avctx->time_base.num, &avctx->time_base.den, |
2002 fps.den, fps.num, 1<<30); | 2002 fps.den, fps.num, 1<<30); |
2003 } | 2003 } |
2004 | 2004 |
2005 avctx->sample_aspect_ratio.num = get_bits_long(gb, 24); | 2005 aspect.num = get_bits_long(gb, 24); |
2006 avctx->sample_aspect_ratio.den = get_bits_long(gb, 24); | 2006 aspect.den = get_bits_long(gb, 24); |
2007 if (aspect.num && aspect.den) { | |
2008 av_reduce(&avctx->sample_aspect_ratio.num, | |
2009 &avctx->sample_aspect_ratio.den, | |
2010 aspect.num, aspect.den, 1<<30); | |
2011 } | |
2007 | 2012 |
2008 if (s->theora < 0x030200) | 2013 if (s->theora < 0x030200) |
2009 skip_bits(gb, 5); /* keyframe frequency force */ | 2014 skip_bits(gb, 5); /* keyframe frequency force */ |
2010 colorspace = get_bits(gb, 8); | 2015 colorspace = get_bits(gb, 8); |
2011 skip_bits(gb, 24); /* bitrate */ | 2016 skip_bits(gb, 24); /* bitrate */ |