summaryrefslogtreecommitdiff
path: root/libavformat/oggparsetheora.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/oggparsetheora.c')
-rw-r--r--libavformat/oggparsetheora.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 9052bbbea0..c2045ce17e 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -53,6 +53,7 @@ theora_header (AVFormatContext * s, int idx)
if (os->buf[os->pstart] == 0x80) {
GetBitContext gb;
+ int width, height;
int version;
init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
@@ -70,13 +71,21 @@ theora_header (AVFormatContext * s, int idx)
return -1;
}
- st->codec->width = get_bits(&gb, 16) << 4;
- st->codec->height = get_bits(&gb, 16) << 4;
+ width = get_bits(&gb, 16) << 4;
+ height = get_bits(&gb, 16) << 4;
+ avcodec_set_dimensions(st->codec, width, height);
if (version >= 0x030400)
- skip_bits(&gb, 164);
- else if (version >= 0x030200)
- skip_bits(&gb, 64);
+ skip_bits(&gb, 100);
+
+ width = get_bits_long(&gb, 24);
+ height = get_bits_long(&gb, 24);
+ if ( width <= st->codec->width && width > st->codec->width-16
+ && height <= st->codec->height && height > st->codec->height-16)
+ avcodec_set_dimensions(st->codec, width, height);
+
+ if (version >= 0x030200)
+ skip_bits(&gb, 16);
st->codec->time_base.den = get_bits(&gb, 32);
st->codec->time_base.num = get_bits(&gb, 32);
st->time_base = st->codec->time_base;