Revision 7146d2c2
libavcodec/vp3.c  

2407  2407 

2408  2408 
if (s>theora && get_bits1(&gb)) 
2409  2409 
{ 
2410 
int ptype = get_bits(&gb, 7); 

2410 
#if 1 

2411 
av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n"); 

2412 
return 1; 

2413 
#else 

2414 
int ptype = get_bits(&gb, 7); 

2411  2415  
2412  2416 
skip_bits(&gb, 6*8); /* "theora" */ 
2413  2417 

...  ...  
2424  2428 
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype); 
2425  2429 
} 
2426  2430 
return buf_size; 
2431 
#endif 

2427  2432 
} 
2428  2433  
2429  2434 
s>keyframe = !get_bits1(&gb); 
...  ...  
2667  2672 
s>height = get_bits(&gb, 16) << 4; 
2668  2673 

2669  2674 
if(avcodec_check_dimensions(avctx, s>width, s>height)){ 
2675 
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", s>width, s>height); 

2670  2676 
s>width= s>height= 0; 
2671  2677 
return 1; 
2672  2678 
} 
2673 


2674 
skip_bits(&gb, 24); /* frame width */ 

2675 
skip_bits(&gb, 24); /* frame height */ 

2679  
2680 
if (s>theora >= 0x030400) 

2681 
{ 

2682 
skip_bits(&gb, 32); /* total number of superblocks in a frame */ 

2683 
// fixme, the next field is 36bits long 

2684 
skip_bits(&gb, 32); /* total number of blocks in a frame */ 

2685 
skip_bits(&gb, 4); /* total number of blocks in a frame */ 

2686 
skip_bits(&gb, 32); /* total number of macroblocks in a frame */ 

2687 


2688 
skip_bits(&gb, 24); /* frame width */ 

2689 
skip_bits(&gb, 24); /* frame height */ 

2690 
} 

2691 
else 

2692 
{ 

2693 
skip_bits(&gb, 24); /* frame width */ 

2694 
skip_bits(&gb, 24); /* frame height */ 

2695 
} 

2676  2696  
2677  2697 
skip_bits(&gb, 8); /* offset x */ 
2678  2698 
skip_bits(&gb, 8); /* offset y */ 
...  ...  
2685  2705 
if (s>theora < 0x030200) 
2686  2706 
skip_bits(&gb, 5); /* keyframe frequency force */ 
2687  2707 
skip_bits(&gb, 8); /* colorspace */ 
2708 
if (s>theora >= 0x030400) 

2709 
skip_bits(&gb, 2); /* pixel format: 420,res,422,444 */ 

2688  2710 
skip_bits(&gb, 24); /* bitrate */ 
2689  2711  
2690 
skip_bits(&gb, 6); /* last(?) quality index */


2712 
skip_bits(&gb, 6); /* quality hint */


2691  2713 

2692  2714 
if (s>theora >= 0x030200) 
2693  2715 
{ 
2694  2716 
skip_bits(&gb, 5); /* keyframe frequency force */ 
2695 
skip_bits(&gb, 5); /* spare bits */ 

2717 


2718 
if (s>theora < 0x030400) 

2719 
skip_bits(&gb, 5); /* spare bits */ 

2696  2720 
} 
2697  2721 

2698  2722 
// align_get_bits(&gb); 
...  ...  
2703  2727 
return 0; 
2704  2728 
} 
2705  2729  
2706 
static int theora_decode_comments(AVCodecContext *avctx, GetBitContext gb)


2730 
static inline int theora_get_32bit(GetBitContext gb)


2707  2731 
{ 
2708 
int nb_comments, i, tmp; 

2732 
int ret = get_bits(&gb, 8); 

2733 
ret += get_bits(&gb, 8) << 8; 

2734 
ret += get_bits(&gb, 8) << 16; 

2735 
ret += get_bits(&gb, 8) << 24; 

2736 


2737 
return ret; 

2738 
} 

2709  2739  
2710 
tmp = get_bits_long(&gb, 32);


2711 
tmp = be2me_32(tmp);


2712 
while(tmp)


2713 
skip_bits(&gb, 8);


2740 
static int theora_decode_comments(AVCodecContext *avctx, GetBitContext gb)


2741 
{


2742 
Vp3DecodeContext *s = avctx>priv_data;


2743 
int len;


2714  2744  
2715 
nb_comments = get_bits_long(&gb, 32); 

2716 
nb_comments = be2me_32(nb_comments); 

2717 
for (i = 0; i < nb_comments; i++) 

2745 
if (s>theora <= 0x030200) 

2718  2746 
{ 
2719 
tmp = get_bits_long(&gb, 32); 

2720 
tmp = be2me_32(tmp); 

2721 
while(tmp) 

2747 
int i, comments; 

2748  
2749 
// vendor string 

2750 
len = get_bits_long(&gb, 32); 

2751 
len = le2me_32(len); 

2752 
while(len) 

2722  2753 
skip_bits(&gb, 8); 
2754  
2755 
// user comments 

2756 
comments = get_bits_long(&gb, 32); 

2757 
comments = le2me_32(comments); 

2758 
for (i = 0; i < comments; i++) 

2759 
{ 

2760 
len = get_bits_long(&gb, 32); 

2761 
len = be2me_32(len); 

2762 
while(len) 

2763 
skip_bits(&gb, 8); 

2764 
} 

2723  2765 
} 
2724 


2766 
else 

2767 
{ 

2768 
do { 

2769 
len = get_bits_long(&gb, 32); 

2770 
len = le2me_32(len); 

2771 
if (len <= 0) 

2772 
break; 

2773 
while (len) 

2774 
skip_bits(&gb, 8); 

2775 
} while (1); 

2776 
} 

2725  2777 
return 0; 
2726  2778 
} 
2727  2779  
...  ...  
2758  2810 
else 
2759  2811 
n = 3; 
2760  2812 
if (n != 3) { 
2761 
av_log(NULL,AV_LOG_ERROR, "unsupported nbms : %d\n", n);


2813 
av_log(avctx,AV_LOG_ERROR, "unsupported nbms : %d\n", n);


2762  2814 
return 1; 
2763  2815 
} 
2764  2816 
/* y coeffs */ 
...  ...  
2793  2845 
skip_bits(&gb, av_log2(2)+1); 
2794  2846 
} 
2795  2847 
if (qi > 63) 
2796 
av_log(NULL, AV_LOG_ERROR, "error...\n");


2848 
av_log(avctx, AV_LOG_ERROR, "invalid qi %d > 63\n", qi);


2797  2849 
} 
2798  2850 
} 
2799  2851 
} 
...  ...  
2825  2877 
s>theora = 1; 
2826  2878  
2827  2879 
if (!avctx>extradata_size) 
2880 
{ 

2881 
av_log(avctx, AV_LOG_ERROR, "Missing extradata!\n"); 

2828  2882 
return 1; 
2883 
} 

2829  2884  
2830  2885 
for(i=0;i<3;i++) { 
2831  2886 
op_bytes = *(p++)<<8; 
...  ...  
2837  2892 
ptype = get_bits(&gb, 8); 
2838  2893 
debug_vp3("Theora headerpacket type: %x\n", ptype); 
2839  2894 

2840 
if (!(ptype & 0x80)) 

2895 
if (!(ptype & 0x80)) 

2896 
{ 

2897 
av_log(avctx, AV_LOG_ERROR, "Invalid extradata!\n"); 

2841  2898 
return 1; 
2842 


2899 
} 

2900  
2901 
// FIXME: check for this aswell 

2843  2902 
skip_bits(&gb, 6*8); /* "theora" */ 
2844  2903 

2845  2904 
switch(ptype) 
...  ...  
2853  2912 
case 0x82: 
2854  2913 
theora_decode_tables(avctx, gb); 
2855  2914 
break; 
2915 
default: 

2916 
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80); 

2917 
break; 

2856  2918 
} 
2857  2919 
} 
2858  2920 
Also available in: Unified diff