Mercurial > libavcodec.hg
comparison h263.c @ 666:f5b8b5dd50d7 libavcodec
interlaced b frames cleanup
author | michaelni |
---|---|
date | Fri, 13 Sep 2002 11:24:58 +0000 |
parents | 00a882f626bd |
children | 5446a41a00fe |
comparison
equal
deleted
inserted
replaced
665:5e5a05077680 | 666:f5b8b5dd50d7 |
---|---|
2810 s->mv[1][0][1] = 0; | 2810 s->mv[1][0][1] = 0; |
2811 PRINT_MB_TYPE("s"); | 2811 PRINT_MB_TYPE("s"); |
2812 return 0; | 2812 return 0; |
2813 } | 2813 } |
2814 | 2814 |
2815 modb1= get_bits1(&s->gb); | 2815 modb1= get_bits1(&s->gb); |
2816 if(modb1==0){ | 2816 if(modb1){ |
2817 mb_type=4; //like MB_TYPE_B_DIRECT but no vectors coded | |
2818 cbp=0; | |
2819 }else{ | |
2820 int field_mv; | |
2821 | |
2817 modb2= get_bits1(&s->gb); | 2822 modb2= get_bits1(&s->gb); |
2818 mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1); | 2823 mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1); |
2819 if(modb2==0) cbp= get_bits(&s->gb, 6); | 2824 if(modb2) cbp= 0; |
2820 else cbp=0; | 2825 else cbp= get_bits(&s->gb, 6); |
2821 if (mb_type && cbp) { | 2826 |
2827 if (mb_type!=MB_TYPE_B_DIRECT && cbp) { | |
2822 if(get_bits1(&s->gb)){ | 2828 if(get_bits1(&s->gb)){ |
2823 s->qscale +=get_bits1(&s->gb)*4 - 2; | 2829 s->qscale +=get_bits1(&s->gb)*4 - 2; |
2824 if (s->qscale < 1) | 2830 if (s->qscale < 1) |
2825 s->qscale = 1; | 2831 s->qscale = 1; |
2826 else if (s->qscale > 31) | 2832 else if (s->qscale > 31) |
2827 s->qscale = 31; | 2833 s->qscale = 31; |
2828 h263_dc_scale(s); | 2834 h263_dc_scale(s); |
2829 } | 2835 } |
2830 } | 2836 } |
2831 s->mv_type= MV_TYPE_16X16; //might be changed to 8X8 or FIELD later | 2837 field_mv=0; |
2832 | 2838 |
2833 if(!s->progressive_sequence){ | 2839 if(!s->progressive_sequence){ |
2834 if(cbp) | 2840 if(cbp) |
2835 s->interlaced_dct= get_bits1(&s->gb); | 2841 s->interlaced_dct= get_bits1(&s->gb); |
2836 | 2842 |
2837 if(mb_type!=MB_TYPE_B_DIRECT){ | 2843 if(mb_type!=MB_TYPE_B_DIRECT && get_bits1(&s->gb)) |
2838 if(get_bits1(&s->gb)){ | 2844 field_mv=1; |
2839 s->mv_type= MV_TYPE_FIELD; | 2845 } |
2840 | 2846 |
2841 if(mb_type!=MB_TYPE_B_BACKW){ | 2847 if(mb_type!=MB_TYPE_B_DIRECT && !field_mv){ |
2842 s->field_select[0][0]= get_bits1(&s->gb); //FIXME move down | 2848 s->mv_type= MV_TYPE_16X16; |
2843 s->field_select[0][1]= get_bits1(&s->gb); | 2849 if(mb_type!=MB_TYPE_B_BACKW){ |
2844 } | 2850 s->mv_dir = MV_DIR_FORWARD; |
2845 if(mb_type!=MB_TYPE_B_FORW){ | 2851 |
2846 s->field_select[1][0]= get_bits1(&s->gb); | 2852 mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code); |
2847 s->field_select[1][1]= get_bits1(&s->gb); | 2853 my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); |
2848 } | 2854 s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx; |
2855 s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my; | |
2856 }else | |
2857 s->mv_dir = 0; | |
2858 | |
2859 if(mb_type!=MB_TYPE_B_FORW){ | |
2860 s->mv_dir |= MV_DIR_BACKWARD; | |
2861 | |
2862 mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code); | |
2863 my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code); | |
2864 s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx; | |
2865 s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my; | |
2866 } | |
2867 if(mb_type!=MB_TYPE_B_DIRECT) | |
2868 PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "F" : (mb_type==MB_TYPE_B_BACKW ? "B" : "T")); | |
2869 }else if(mb_type!=MB_TYPE_B_DIRECT){ | |
2870 s->mv_type= MV_TYPE_FIELD; | |
2871 if(mb_type!=MB_TYPE_B_BACKW){ | |
2872 s->mv_dir = MV_DIR_FORWARD; | |
2873 s->field_select[0][0]= get_bits1(&s->gb); | |
2874 s->field_select[0][1]= get_bits1(&s->gb); | |
2875 | |
2876 for(i=0; i<2; i++){ | |
2877 mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code); | |
2878 my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code); | |
2879 s->last_mv[0][i][0]= s->mv[0][i][0] = mx; | |
2880 s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2; | |
2849 } | 2881 } |
2850 } | 2882 }else |
2851 } | 2883 s->mv_dir = 0; |
2852 }else{ | 2884 |
2853 s->mv_type= MV_TYPE_16X16; //might be changed to 8X8 later | 2885 if(mb_type!=MB_TYPE_B_FORW){ |
2854 mb_type=4; //like MB_TYPE_B_DIRECT but no vectors coded | 2886 s->mv_dir |= MV_DIR_BACKWARD; |
2855 cbp=0; | 2887 s->field_select[1][0]= get_bits1(&s->gb); |
2856 } | 2888 s->field_select[1][1]= get_bits1(&s->gb); |
2857 | 2889 |
2858 mx=my=0; | 2890 for(i=0; i<2; i++){ |
2859 if(mb_type==MB_TYPE_B_DIRECT){ | 2891 mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code); |
2860 mx = h263_decode_motion(s, 0, 1); | 2892 my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code); |
2861 my = h263_decode_motion(s, 0, 1); | 2893 s->last_mv[1][i][0]= s->mv[1][i][0] = mx; |
2862 } | 2894 s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2; |
2863 | 2895 } |
2864 if(s->mv_type==MV_TYPE_16X16){ | 2896 } |
2865 if(mb_type==MB_TYPE_B_FORW || mb_type==MB_TYPE_B_BIDIR){ | 2897 if(mb_type!=MB_TYPE_B_DIRECT) |
2866 s->mv_dir = MV_DIR_FORWARD; | 2898 PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "f" : (mb_type==MB_TYPE_B_BACKW ? "b" : "t")); |
2867 mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code); | 2899 } |
2868 my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); | 2900 } |
2869 s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx; | 2901 |
2870 s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my; | |
2871 }else | |
2872 s->mv_dir = 0; | |
2873 | |
2874 if(mb_type==MB_TYPE_B_BACKW || mb_type==MB_TYPE_B_BIDIR){ | |
2875 s->mv_dir |= MV_DIR_BACKWARD; | |
2876 mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code); | |
2877 my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code); | |
2878 s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx; | |
2879 s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my; | |
2880 } | |
2881 if(mb_type!=4 && mb_type!=MB_TYPE_B_DIRECT) | |
2882 PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "F" : (mb_type==MB_TYPE_B_BACKW ? "B" : "T")); | |
2883 }else{ | |
2884 /* MV_TYPE_FIELD */ | |
2885 if(mb_type==MB_TYPE_B_FORW || mb_type==MB_TYPE_B_BIDIR){ | |
2886 s->mv_dir = MV_DIR_FORWARD; | |
2887 for(i=0; i<2; i++){ | |
2888 mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code); | |
2889 my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code); | |
2890 s->last_mv[0][i][0]= s->mv[0][i][0] = mx; | |
2891 s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2; | |
2892 } | |
2893 }else | |
2894 s->mv_dir = 0; | |
2895 | |
2896 if(mb_type==MB_TYPE_B_BACKW || mb_type==MB_TYPE_B_BIDIR){ | |
2897 s->mv_dir |= MV_DIR_BACKWARD; | |
2898 for(i=0; i<2; i++){ | |
2899 mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code); | |
2900 my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code); | |
2901 s->last_mv[1][i][0]= s->mv[1][i][0] = mx; | |
2902 s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2; | |
2903 } | |
2904 } | |
2905 if(mb_type!=4 && mb_type!=MB_TYPE_B_DIRECT) | |
2906 PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "f" : (mb_type==MB_TYPE_B_BACKW ? "b" : "t")); | |
2907 } | |
2908 | |
2909 if(mb_type==4 || mb_type==MB_TYPE_B_DIRECT){ | 2902 if(mb_type==4 || mb_type==MB_TYPE_B_DIRECT){ |
2910 int mb_index= s->mb_x + s->mb_y*s->mb_width; | 2903 int mb_index= s->mb_x + s->mb_y*s->mb_width; |
2911 int i; | 2904 int i; |
2905 | |
2906 if(mb_type==4) | |
2907 mx=my=0; | |
2908 else{ | |
2909 mx = h263_decode_motion(s, 0, 1); | |
2910 my = h263_decode_motion(s, 0, 1); | |
2911 } | |
2912 | 2912 |
2913 s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; | 2913 s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; |
2914 xy= s->block_index[0]; | 2914 xy= s->block_index[0]; |
2915 time_pp= s->pp_time; | 2915 time_pp= s->pp_time; |
2916 time_pb= s->pb_time; | 2916 time_pb= s->pb_time; |
2917 | 2917 |
2918 //FIXME avoid divides | 2918 //FIXME avoid divides |
2919 switch(s->co_located_type_table[mb_index]){ | 2919 switch(s->co_located_type_table[mb_index]){ |
2920 case 0: | 2920 case 0: |
2921 s->mv_type= MV_TYPE_16X16; | |
2921 s->mv[0][0][0] = s->motion_val[xy][0]*time_pb/time_pp + mx; | 2922 s->mv[0][0][0] = s->motion_val[xy][0]*time_pb/time_pp + mx; |
2922 s->mv[0][0][1] = s->motion_val[xy][1]*time_pb/time_pp + my; | 2923 s->mv[0][0][1] = s->motion_val[xy][1]*time_pb/time_pp + my; |
2923 s->mv[1][0][0] = mx ? s->mv[0][0][0] - s->motion_val[xy][0] | 2924 s->mv[1][0][0] = mx ? s->mv[0][0][0] - s->motion_val[xy][0] |
2924 : s->motion_val[xy][0]*(time_pb - time_pp)/time_pp; | 2925 : s->motion_val[xy][0]*(time_pb - time_pp)/time_pp; |
2925 s->mv[1][0][1] = my ? s->mv[0][0][1] - s->motion_val[xy][1] | 2926 s->mv[1][0][1] = my ? s->mv[0][0][1] - s->motion_val[xy][1] |