Mercurial > libavcodec.hg
comparison vp3.c @ 4935:b34f448e1a12 libavcodec
fix display of theora videos with visible size smaller than encoded size
author | aurel |
---|---|
date | Mon, 07 May 2007 15:43:01 +0000 |
parents | 9ca9a53a848b |
children | 2e400c0e99f6 |
comparison
equal
deleted
inserted
replaced
4934:feba7e1adac5 | 4935:b34f448e1a12 |
---|---|
2369 | 2369 |
2370 #ifdef CONFIG_THEORA_DECODER | 2370 #ifdef CONFIG_THEORA_DECODER |
2371 static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) | 2371 static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) |
2372 { | 2372 { |
2373 Vp3DecodeContext *s = avctx->priv_data; | 2373 Vp3DecodeContext *s = avctx->priv_data; |
2374 int visible_width, visible_height; | |
2374 | 2375 |
2375 s->theora = get_bits_long(gb, 24); | 2376 s->theora = get_bits_long(gb, 24); |
2376 av_log(avctx, AV_LOG_INFO, "Theora bitstream version %X\n", s->theora); | 2377 av_log(avctx, AV_LOG_INFO, "Theora bitstream version %X\n", s->theora); |
2377 | 2378 |
2378 /* 3.2.0 aka alpha3 has the same frame orientation as original vp3 */ | 2379 /* 3.2.0 aka alpha3 has the same frame orientation as original vp3 */ |
2397 skip_bits(gb, 32); /* total number of superblocks in a frame */ | 2398 skip_bits(gb, 32); /* total number of superblocks in a frame */ |
2398 // fixme, the next field is 36bits long | 2399 // fixme, the next field is 36bits long |
2399 skip_bits(gb, 32); /* total number of blocks in a frame */ | 2400 skip_bits(gb, 32); /* total number of blocks in a frame */ |
2400 skip_bits(gb, 4); /* total number of blocks in a frame */ | 2401 skip_bits(gb, 4); /* total number of blocks in a frame */ |
2401 skip_bits(gb, 32); /* total number of macroblocks in a frame */ | 2402 skip_bits(gb, 32); /* total number of macroblocks in a frame */ |
2402 | 2403 } |
2403 skip_bits(gb, 24); /* frame width */ | 2404 |
2404 skip_bits(gb, 24); /* frame height */ | 2405 visible_width = get_bits_long(gb, 24); |
2405 } | 2406 visible_height = get_bits_long(gb, 24); |
2406 else | |
2407 { | |
2408 skip_bits(gb, 24); /* frame width */ | |
2409 skip_bits(gb, 24); /* frame height */ | |
2410 } | |
2411 | 2407 |
2412 if (s->theora >= 0x030200) { | 2408 if (s->theora >= 0x030200) { |
2413 skip_bits(gb, 8); /* offset x */ | 2409 skip_bits(gb, 8); /* offset x */ |
2414 skip_bits(gb, 8); /* offset y */ | 2410 skip_bits(gb, 8); /* offset y */ |
2415 } | 2411 } |
2436 skip_bits(gb, 5); /* spare bits */ | 2432 skip_bits(gb, 5); /* spare bits */ |
2437 } | 2433 } |
2438 | 2434 |
2439 // align_get_bits(gb); | 2435 // align_get_bits(gb); |
2440 | 2436 |
2441 avctx->width = s->width; | 2437 if ( visible_width <= s->width && visible_width > s->width-16 |
2442 avctx->height = s->height; | 2438 && visible_height <= s->height && visible_height > s->height-16) |
2439 avcodec_set_dimensions(avctx, visible_width, visible_height); | |
2440 else | |
2441 avcodec_set_dimensions(avctx, s->width, s->height); | |
2443 | 2442 |
2444 return 0; | 2443 return 0; |
2445 } | 2444 } |
2446 | 2445 |
2447 static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb) | 2446 static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb) |