comparison vc1.c @ 5513:9f8219a3b86f libavcodec

use get_bits1(..) instead get_bits(.., 1)
author alex
date Thu, 09 Aug 2007 00:13:31 +0000
parents 7617e066481e
children b790f8c0ee24
comparison
equal deleted inserted replaced
5512:28dcc5cd79d2 5513:9f8219a3b86f
147 */ 147 */
148 static void decode_rowskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){ 148 static void decode_rowskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){
149 int x, y; 149 int x, y;
150 150
151 for (y=0; y<height; y++){ 151 for (y=0; y<height; y++){
152 if (!get_bits(gb, 1)) //rowskip 152 if (!get_bits1(gb)) //rowskip
153 memset(plane, 0, width); 153 memset(plane, 0, width);
154 else 154 else
155 for (x=0; x<width; x++) 155 for (x=0; x<width; x++)
156 plane[x] = get_bits(gb, 1); 156 plane[x] = get_bits1(gb);
157 plane += stride; 157 plane += stride;
158 } 158 }
159 } 159 }
160 160
161 /** Decode columns by checking if they are skipped 161 /** Decode columns by checking if they are skipped
167 */ 167 */
168 static void decode_colskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){ 168 static void decode_colskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){
169 int x, y; 169 int x, y;
170 170
171 for (x=0; x<width; x++){ 171 for (x=0; x<width; x++){
172 if (!get_bits(gb, 1)) //colskip 172 if (!get_bits1(gb)) //colskip
173 for (y=0; y<height; y++) 173 for (y=0; y<height; y++)
174 plane[y*stride] = 0; 174 plane[y*stride] = 0;
175 else 175 else
176 for (y=0; y<height; y++) 176 for (y=0; y<height; y++)
177 plane[y*stride] = get_bits(gb, 1); 177 plane[y*stride] = get_bits1(gb);
178 plane ++; 178 plane ++;
179 } 179 }
180 } 180 }
181 181
182 /** Decode a bitplane's bits 182 /** Decode a bitplane's bits
194 int width, height, stride; 194 int width, height, stride;
195 195
196 width = v->s.mb_width; 196 width = v->s.mb_width;
197 height = v->s.mb_height; 197 height = v->s.mb_height;
198 stride = v->s.mb_stride; 198 stride = v->s.mb_stride;
199 invert = get_bits(gb, 1); 199 invert = get_bits1(gb);
200 imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); 200 imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);
201 201
202 *raw_flag = 0; 202 *raw_flag = 0;
203 switch (imode) 203 switch (imode)
204 { 204 {
208 return invert; 208 return invert;
209 case IMODE_DIFF2: 209 case IMODE_DIFF2:
210 case IMODE_NORM2: 210 case IMODE_NORM2:
211 if ((height * width) & 1) 211 if ((height * width) & 1)
212 { 212 {
213 *planep++ = get_bits(gb, 1); 213 *planep++ = get_bits1(gb);
214 offset = 1; 214 offset = 1;
215 } 215 }
216 else offset = 0; 216 else offset = 0;
217 // decode bitplane as one long line 217 // decode bitplane as one long line
218 for (y = offset; y < height * width; y += 2) { 218 for (y = offset; y < height * width; y += 2) {
327 if (pqdiff == 7) v->altpq = get_bits(gb, 5); 327 if (pqdiff == 7) v->altpq = get_bits(gb, 5);
328 else v->altpq = v->pq + pqdiff + 1; 328 else v->altpq = v->pq + pqdiff + 1;
329 } 329 }
330 else 330 else
331 { 331 {
332 v->dquantfrm = get_bits(gb, 1); 332 v->dquantfrm = get_bits1(gb);
333 if ( v->dquantfrm ) 333 if ( v->dquantfrm )
334 { 334 {
335 v->dqprofile = get_bits(gb, 2); 335 v->dqprofile = get_bits(gb, 2);
336 switch (v->dqprofile) 336 switch (v->dqprofile)
337 { 337 {
338 case DQPROFILE_SINGLE_EDGE: 338 case DQPROFILE_SINGLE_EDGE:
339 case DQPROFILE_DOUBLE_EDGES: 339 case DQPROFILE_DOUBLE_EDGES:
340 v->dqsbedge = get_bits(gb, 2); 340 v->dqsbedge = get_bits(gb, 2);
341 break; 341 break;
342 case DQPROFILE_ALL_MBS: 342 case DQPROFILE_ALL_MBS:
343 v->dqbilevel = get_bits(gb, 1); 343 v->dqbilevel = get_bits1(gb);
344 default: break; //Forbidden ? 344 default: break; //Forbidden ?
345 } 345 }
346 if (v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS) 346 if (v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS)
347 { 347 {
348 pqdiff = get_bits(gb, 3); 348 pqdiff = get_bits(gb, 3);
795 795
796 // (fps-2)/4 (->30) 796 // (fps-2)/4 (->30)
797 v->frmrtq_postproc = get_bits(gb, 3); //common 797 v->frmrtq_postproc = get_bits(gb, 3); //common
798 // (bitrate-32kbps)/64kbps 798 // (bitrate-32kbps)/64kbps
799 v->bitrtq_postproc = get_bits(gb, 5); //common 799 v->bitrtq_postproc = get_bits(gb, 5); //common
800 v->s.loop_filter = get_bits(gb, 1); //common 800 v->s.loop_filter = get_bits1(gb); //common
801 if(v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE) 801 if(v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE)
802 { 802 {
803 av_log(avctx, AV_LOG_ERROR, 803 av_log(avctx, AV_LOG_ERROR,
804 "LOOPFILTER shell not be enabled in simple profile\n"); 804 "LOOPFILTER shell not be enabled in simple profile\n");
805 } 805 }
806 806
807 v->res_x8 = get_bits(gb, 1); //reserved 807 v->res_x8 = get_bits1(gb); //reserved
808 if (v->res_x8) 808 if (v->res_x8)
809 { 809 {
810 av_log(avctx, AV_LOG_ERROR, 810 av_log(avctx, AV_LOG_ERROR,
811 "1 for reserved RES_X8 is forbidden\n"); 811 "1 for reserved RES_X8 is forbidden\n");
812 //return -1; 812 //return -1;
813 } 813 }
814 v->multires = get_bits(gb, 1); 814 v->multires = get_bits1(gb);
815 v->res_fasttx = get_bits(gb, 1); 815 v->res_fasttx = get_bits1(gb);
816 if (!v->res_fasttx) 816 if (!v->res_fasttx)
817 { 817 {
818 av_log(avctx, AV_LOG_ERROR, 818 av_log(avctx, AV_LOG_ERROR,
819 "0 for reserved RES_FASTTX is forbidden\n"); 819 "0 for reserved RES_FASTTX is forbidden\n");
820 //return -1; 820 //return -1;
821 } 821 }
822 822
823 v->fastuvmc = get_bits(gb, 1); //common 823 v->fastuvmc = get_bits1(gb); //common
824 if (!v->profile && !v->fastuvmc) 824 if (!v->profile && !v->fastuvmc)
825 { 825 {
826 av_log(avctx, AV_LOG_ERROR, 826 av_log(avctx, AV_LOG_ERROR,
827 "FASTUVMC unavailable in Simple Profile\n"); 827 "FASTUVMC unavailable in Simple Profile\n");
828 return -1; 828 return -1;
829 } 829 }
830 v->extended_mv = get_bits(gb, 1); //common 830 v->extended_mv = get_bits1(gb); //common
831 if (!v->profile && v->extended_mv) 831 if (!v->profile && v->extended_mv)
832 { 832 {
833 av_log(avctx, AV_LOG_ERROR, 833 av_log(avctx, AV_LOG_ERROR,
834 "Extended MVs unavailable in Simple Profile\n"); 834 "Extended MVs unavailable in Simple Profile\n");
835 return -1; 835 return -1;
836 } 836 }
837 v->dquant = get_bits(gb, 2); //common 837 v->dquant = get_bits(gb, 2); //common
838 v->vstransform = get_bits(gb, 1); //common 838 v->vstransform = get_bits1(gb); //common
839 839
840 v->res_transtab = get_bits(gb, 1); 840 v->res_transtab = get_bits1(gb);
841 if (v->res_transtab) 841 if (v->res_transtab)
842 { 842 {
843 av_log(avctx, AV_LOG_ERROR, 843 av_log(avctx, AV_LOG_ERROR,
844 "1 for reserved RES_TRANSTAB is forbidden\n"); 844 "1 for reserved RES_TRANSTAB is forbidden\n");
845 return -1; 845 return -1;
846 } 846 }
847 847
848 v->overlap = get_bits(gb, 1); //common 848 v->overlap = get_bits1(gb); //common
849 849
850 v->s.resync_marker = get_bits(gb, 1); 850 v->s.resync_marker = get_bits1(gb);
851 v->rangered = get_bits(gb, 1); 851 v->rangered = get_bits1(gb);
852 if (v->rangered && v->profile == PROFILE_SIMPLE) 852 if (v->rangered && v->profile == PROFILE_SIMPLE)
853 { 853 {
854 av_log(avctx, AV_LOG_INFO, 854 av_log(avctx, AV_LOG_INFO,
855 "RANGERED should be set to 0 in simple profile\n"); 855 "RANGERED should be set to 0 in simple profile\n");
856 } 856 }
857 857
858 v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common 858 v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common
859 v->quantizer_mode = get_bits(gb, 2); //common 859 v->quantizer_mode = get_bits(gb, 2); //common
860 860
861 v->finterpflag = get_bits(gb, 1); //common 861 v->finterpflag = get_bits1(gb); //common
862 v->res_rtm_flag = get_bits(gb, 1); //reserved 862 v->res_rtm_flag = get_bits1(gb); //reserved
863 if (!v->res_rtm_flag) 863 if (!v->res_rtm_flag)
864 { 864 {
865 // av_log(avctx, AV_LOG_ERROR, 865 // av_log(avctx, AV_LOG_ERROR,
866 // "0 for reserved RES_RTM_FLAG is forbidden\n"); 866 // "0 for reserved RES_RTM_FLAG is forbidden\n");
867 av_log(avctx, AV_LOG_ERROR, 867 av_log(avctx, AV_LOG_ERROR,
901 901
902 // (fps-2)/4 (->30) 902 // (fps-2)/4 (->30)
903 v->frmrtq_postproc = get_bits(gb, 3); //common 903 v->frmrtq_postproc = get_bits(gb, 3); //common
904 // (bitrate-32kbps)/64kbps 904 // (bitrate-32kbps)/64kbps
905 v->bitrtq_postproc = get_bits(gb, 5); //common 905 v->bitrtq_postproc = get_bits(gb, 5); //common
906 v->postprocflag = get_bits(gb, 1); //common 906 v->postprocflag = get_bits1(gb); //common
907 907
908 v->s.avctx->coded_width = (get_bits(gb, 12) + 1) << 1; 908 v->s.avctx->coded_width = (get_bits(gb, 12) + 1) << 1;
909 v->s.avctx->coded_height = (get_bits(gb, 12) + 1) << 1; 909 v->s.avctx->coded_height = (get_bits(gb, 12) + 1) << 1;
910 v->s.avctx->width = v->s.avctx->coded_width; 910 v->s.avctx->width = v->s.avctx->coded_width;
911 v->s.avctx->height = v->s.avctx->coded_height; 911 v->s.avctx->height = v->s.avctx->coded_height;
1036 1036
1037 static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) 1037 static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
1038 { 1038 {
1039 int pqindex, lowquant, status; 1039 int pqindex, lowquant, status;
1040 1040
1041 if(v->finterpflag) v->interpfrm = get_bits(gb, 1); 1041 if(v->finterpflag) v->interpfrm = get_bits1(gb);
1042 skip_bits(gb, 2); //framecnt unused 1042 skip_bits(gb, 2); //framecnt unused
1043 v->rangeredfrm = 0; 1043 v->rangeredfrm = 0;
1044 if (v->rangered) v->rangeredfrm = get_bits(gb, 1); 1044 if (v->rangered) v->rangeredfrm = get_bits1(gb);
1045 v->s.pict_type = get_bits(gb, 1); 1045 v->s.pict_type = get_bits1(gb);
1046 if (v->s.avctx->max_b_frames) { 1046 if (v->s.avctx->max_b_frames) {
1047 if (!v->s.pict_type) { 1047 if (!v->s.pict_type) {
1048 if (get_bits(gb, 1)) v->s.pict_type = I_TYPE; 1048 if (get_bits1(gb)) v->s.pict_type = I_TYPE;
1049 else v->s.pict_type = B_TYPE; 1049 else v->s.pict_type = B_TYPE;
1050 } else v->s.pict_type = P_TYPE; 1050 } else v->s.pict_type = P_TYPE;
1051 } else v->s.pict_type = v->s.pict_type ? P_TYPE : I_TYPE; 1051 } else v->s.pict_type = v->s.pict_type ? P_TYPE : I_TYPE;
1052 1052
1053 v->bi_type = 0; 1053 v->bi_type = 0;
1078 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) 1078 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
1079 v->pquantizer = pqindex < 9; 1079 v->pquantizer = pqindex < 9;
1080 if (v->quantizer_mode == QUANT_NON_UNIFORM) 1080 if (v->quantizer_mode == QUANT_NON_UNIFORM)
1081 v->pquantizer = 0; 1081 v->pquantizer = 0;
1082 v->pqindex = pqindex; 1082 v->pqindex = pqindex;
1083 if (pqindex < 9) v->halfpq = get_bits(gb, 1); 1083 if (pqindex < 9) v->halfpq = get_bits1(gb);
1084 else v->halfpq = 0; 1084 else v->halfpq = 0;
1085 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) 1085 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
1086 v->pquantizer = get_bits(gb, 1); 1086 v->pquantizer = get_bits1(gb);
1087 v->dquantfrm = 0; 1087 v->dquantfrm = 0;
1088 if (v->extended_mv == 1) v->mvrange = get_unary(gb, 0, 3); 1088 if (v->extended_mv == 1) v->mvrange = get_unary(gb, 0, 3);
1089 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 1089 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
1090 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 1090 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
1091 v->range_x = 1 << (v->k_x - 1); 1091 v->range_x = 1 << (v->k_x - 1);
1092 v->range_y = 1 << (v->k_y - 1); 1092 v->range_y = 1 << (v->k_y - 1);
1093 if (v->profile == PROFILE_ADVANCED) 1093 if (v->profile == PROFILE_ADVANCED)
1094 { 1094 {
1095 if (v->postprocflag) v->postproc = get_bits(gb, 1); 1095 if (v->postprocflag) v->postproc = get_bits1(gb);
1096 } 1096 }
1097 else 1097 else
1098 if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2); 1098 if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2);
1099 1099
1100 if(v->res_x8 && (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)){ 1100 if(v->res_x8 && (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)){
1177 } 1177 }
1178 1178
1179 v->ttfrm = 0; //FIXME Is that so ? 1179 v->ttfrm = 0; //FIXME Is that so ?
1180 if (v->vstransform) 1180 if (v->vstransform)
1181 { 1181 {
1182 v->ttmbf = get_bits(gb, 1); 1182 v->ttmbf = get_bits1(gb);
1183 if (v->ttmbf) 1183 if (v->ttmbf)
1184 { 1184 {
1185 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; 1185 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
1186 } 1186 }
1187 } else { 1187 } else {
1218 } 1218 }
1219 1219
1220 v->ttfrm = 0; 1220 v->ttfrm = 0;
1221 if (v->vstransform) 1221 if (v->vstransform)
1222 { 1222 {
1223 v->ttmbf = get_bits(gb, 1); 1223 v->ttmbf = get_bits1(gb);
1224 if (v->ttmbf) 1224 if (v->ttmbf)
1225 { 1225 {
1226 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; 1226 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
1227 } 1227 }
1228 } else { 1228 } else {
1237 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) 1237 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)
1238 { 1238 {
1239 v->y_ac_table_index = decode012(gb); 1239 v->y_ac_table_index = decode012(gb);
1240 } 1240 }
1241 /* DC Syntax */ 1241 /* DC Syntax */
1242 v->s.dc_table_index = get_bits(gb, 1); 1242 v->s.dc_table_index = get_bits1(gb);
1243 1243
1244 if(v->s.pict_type == BI_TYPE) { 1244 if(v->s.pict_type == BI_TYPE) {
1245 v->s.pict_type = B_TYPE; 1245 v->s.pict_type = B_TYPE;
1246 v->bi_type = 1; 1246 v->bi_type = 1;
1247 } 1247 }
1291 //... 1291 //...
1292 } 1292 }
1293 v->rnd = get_bits1(gb); 1293 v->rnd = get_bits1(gb);
1294 if(v->interlace) 1294 if(v->interlace)
1295 v->uvsamp = get_bits1(gb); 1295 v->uvsamp = get_bits1(gb);
1296 if(v->finterpflag) v->interpfrm = get_bits(gb, 1); 1296 if(v->finterpflag) v->interpfrm = get_bits1(gb);
1297 if(v->s.pict_type == B_TYPE) { 1297 if(v->s.pict_type == B_TYPE) {
1298 v->bfraction = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); 1298 v->bfraction = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
1299 v->bfraction = ff_vc1_bfraction_lut[v->bfraction]; 1299 v->bfraction = ff_vc1_bfraction_lut[v->bfraction];
1300 if(v->bfraction == 0) { 1300 if(v->bfraction == 0) {
1301 v->s.pict_type = BI_TYPE; /* XXX: should not happen here */ 1301 v->s.pict_type = BI_TYPE; /* XXX: should not happen here */
1312 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) 1312 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
1313 v->pquantizer = pqindex < 9; 1313 v->pquantizer = pqindex < 9;
1314 if (v->quantizer_mode == QUANT_NON_UNIFORM) 1314 if (v->quantizer_mode == QUANT_NON_UNIFORM)
1315 v->pquantizer = 0; 1315 v->pquantizer = 0;
1316 v->pqindex = pqindex; 1316 v->pqindex = pqindex;
1317 if (pqindex < 9) v->halfpq = get_bits(gb, 1); 1317 if (pqindex < 9) v->halfpq = get_bits1(gb);
1318 else v->halfpq = 0; 1318 else v->halfpq = 0;
1319 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) 1319 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
1320 v->pquantizer = get_bits(gb, 1); 1320 v->pquantizer = get_bits1(gb);
1321 1321
1322 if(v->s.pict_type == I_TYPE || v->s.pict_type == P_TYPE) v->use_ic = 0; 1322 if(v->s.pict_type == I_TYPE || v->s.pict_type == P_TYPE) v->use_ic = 0;
1323 1323
1324 switch(v->s.pict_type) { 1324 switch(v->s.pict_type) {
1325 case I_TYPE: 1325 case I_TYPE:
1418 } 1418 }
1419 1419
1420 v->ttfrm = 0; //FIXME Is that so ? 1420 v->ttfrm = 0; //FIXME Is that so ?
1421 if (v->vstransform) 1421 if (v->vstransform)
1422 { 1422 {
1423 v->ttmbf = get_bits(gb, 1); 1423 v->ttmbf = get_bits1(gb);
1424 if (v->ttmbf) 1424 if (v->ttmbf)
1425 { 1425 {
1426 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; 1426 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
1427 } 1427 }
1428 } else { 1428 } else {
1468 } 1468 }
1469 1469
1470 v->ttfrm = 0; 1470 v->ttfrm = 0;
1471 if (v->vstransform) 1471 if (v->vstransform)
1472 { 1472 {
1473 v->ttmbf = get_bits(gb, 1); 1473 v->ttmbf = get_bits1(gb);
1474 if (v->ttmbf) 1474 if (v->ttmbf)
1475 { 1475 {
1476 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; 1476 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
1477 } 1477 }
1478 } else { 1478 } else {
1487 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) 1487 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)
1488 { 1488 {
1489 v->y_ac_table_index = decode012(gb); 1489 v->y_ac_table_index = decode012(gb);
1490 } 1490 }
1491 /* DC Syntax */ 1491 /* DC Syntax */
1492 v->s.dc_table_index = get_bits(gb, 1); 1492 v->s.dc_table_index = get_bits1(gb);
1493 if ((v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) && v->dquant) { 1493 if ((v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) && v->dquant) {
1494 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); 1494 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
1495 vop_dquant_decoding(v); 1495 vop_dquant_decoding(v);
1496 } 1496 }
1497 1497
1520 int edges = 0; \ 1520 int edges = 0; \
1521 if (v->dqprofile == DQPROFILE_ALL_MBS) \ 1521 if (v->dqprofile == DQPROFILE_ALL_MBS) \
1522 { \ 1522 { \
1523 if (v->dqbilevel) \ 1523 if (v->dqbilevel) \
1524 { \ 1524 { \
1525 mquant = (get_bits(gb, 1)) ? v->altpq : v->pq; \ 1525 mquant = (get_bits1(gb)) ? v->altpq : v->pq; \
1526 } \ 1526 } \
1527 else \ 1527 else \
1528 { \ 1528 { \
1529 mqdiff = get_bits(gb, 3); \ 1529 mqdiff = get_bits(gb, 3); \
1530 if (mqdiff != 7) mquant = v->pq + mqdiff; \ 1530 if (mqdiff != 7) mquant = v->pq + mqdiff; \
2271 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); 2271 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
2272 if (index != vc1_ac_sizes[codingset] - 1) { 2272 if (index != vc1_ac_sizes[codingset] - 1) {
2273 run = vc1_index_decode_table[codingset][index][0]; 2273 run = vc1_index_decode_table[codingset][index][0];
2274 level = vc1_index_decode_table[codingset][index][1]; 2274 level = vc1_index_decode_table[codingset][index][1];
2275 lst = index >= vc1_last_decode_table[codingset]; 2275 lst = index >= vc1_last_decode_table[codingset];
2276 if(get_bits(gb, 1)) 2276 if(get_bits1(gb))
2277 level = -level; 2277 level = -level;
2278 } else { 2278 } else {
2279 escape = decode210(gb); 2279 escape = decode210(gb);
2280 if (escape != 2) { 2280 if (escape != 2) {
2281 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); 2281 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
2291 if(lst) 2291 if(lst)
2292 run += vc1_last_delta_run_table[codingset][level] + 1; 2292 run += vc1_last_delta_run_table[codingset][level] + 1;
2293 else 2293 else
2294 run += vc1_delta_run_table[codingset][level] + 1; 2294 run += vc1_delta_run_table[codingset][level] + 1;
2295 } 2295 }
2296 if(get_bits(gb, 1)) 2296 if(get_bits1(gb))
2297 level = -level; 2297 level = -level;
2298 } else { 2298 } else {
2299 int sign; 2299 int sign;
2300 lst = get_bits(gb, 1); 2300 lst = get_bits1(gb);
2301 if(v->s.esc3_level_length == 0) { 2301 if(v->s.esc3_level_length == 0) {
2302 if(v->pq < 8 || v->dquantfrm) { // table 59 2302 if(v->pq < 8 || v->dquantfrm) { // table 59
2303 v->s.esc3_level_length = get_bits(gb, 3); 2303 v->s.esc3_level_length = get_bits(gb, 3);
2304 if(!v->s.esc3_level_length) 2304 if(!v->s.esc3_level_length)
2305 v->s.esc3_level_length = get_bits(gb, 2) + 8; 2305 v->s.esc3_level_length = get_bits(gb, 2) + 8;
2307 v->s.esc3_level_length = get_unary(gb, 1, 6) + 2; 2307 v->s.esc3_level_length = get_unary(gb, 1, 6) + 2;
2308 } 2308 }
2309 v->s.esc3_run_length = 3 + get_bits(gb, 2); 2309 v->s.esc3_run_length = 3 + get_bits(gb, 2);
2310 } 2310 }
2311 run = get_bits(gb, v->s.esc3_run_length); 2311 run = get_bits(gb, v->s.esc3_run_length);
2312 sign = get_bits(gb, 1); 2312 sign = get_bits1(gb);
2313 level = get_bits(gb, v->s.esc3_level_length); 2313 level = get_bits(gb, v->s.esc3_level_length);
2314 if(sign) 2314 if(sign)
2315 level = -level; 2315 level = -level;
2316 } 2316 }
2317 } 2317 }
2359 else 2359 else
2360 { 2360 {
2361 if (v->pq == 1) 2361 if (v->pq == 1)
2362 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; 2362 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
2363 else if (v->pq == 2) 2363 else if (v->pq == 2)
2364 dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; 2364 dcdiff = (dcdiff<<1) + get_bits1(gb) - 1;
2365 } 2365 }
2366 if (get_bits(gb, 1)) 2366 if (get_bits1(gb))
2367 dcdiff = -dcdiff; 2367 dcdiff = -dcdiff;
2368 } 2368 }
2369 2369
2370 /* Prediction */ 2370 /* Prediction */
2371 dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir); 2371 dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir);
2529 else 2529 else
2530 { 2530 {
2531 if (mquant == 1) 2531 if (mquant == 1)
2532 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; 2532 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
2533 else if (mquant == 2) 2533 else if (mquant == 2)
2534 dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; 2534 dcdiff = (dcdiff<<1) + get_bits1(gb) - 1;
2535 } 2535 }
2536 if (get_bits(gb, 1)) 2536 if (get_bits1(gb))
2537 dcdiff = -dcdiff; 2537 dcdiff = -dcdiff;
2538 } 2538 }
2539 2539
2540 /* Prediction */ 2540 /* Prediction */
2541 dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir); 2541 dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
2733 else 2733 else
2734 { 2734 {
2735 if (mquant == 1) 2735 if (mquant == 1)
2736 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; 2736 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
2737 else if (mquant == 2) 2737 else if (mquant == 2)
2738 dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; 2738 dcdiff = (dcdiff<<1) + get_bits1(gb) - 1;
2739 } 2739 }
2740 if (get_bits(gb, 1)) 2740 if (get_bits1(gb))
2741 dcdiff = -dcdiff; 2741 dcdiff = -dcdiff;
2742 } 2742 }
2743 2743
2744 /* Prediction */ 2744 /* Prediction */
2745 dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir); 2745 dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
3052 3052
3053 /* FIXME Set DC val for inter block ? */ 3053 /* FIXME Set DC val for inter block ? */
3054 if (s->mb_intra && !mb_has_coeffs) 3054 if (s->mb_intra && !mb_has_coeffs)
3055 { 3055 {
3056 GET_MQUANT(); 3056 GET_MQUANT();
3057 s->ac_pred = get_bits(gb, 1); 3057 s->ac_pred = get_bits1(gb);
3058 cbp = 0; 3058 cbp = 0;
3059 } 3059 }
3060 else if (mb_has_coeffs) 3060 else if (mb_has_coeffs)
3061 { 3061 {
3062 if (s->mb_intra) s->ac_pred = get_bits(gb, 1); 3062 if (s->mb_intra) s->ac_pred = get_bits1(gb);
3063 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); 3063 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
3064 GET_MQUANT(); 3064 GET_MQUANT();
3065 } 3065 }
3066 else 3066 else
3067 { 3067 {
3174 || ((s->mb_x || (i==1 || i==3)) && v->mb_type[0][s->block_index[i] - 1])) { 3174 || ((s->mb_x || (i==1 || i==3)) && v->mb_type[0][s->block_index[i] - 1])) {
3175 intrapred = 1; 3175 intrapred = 1;
3176 break; 3176 break;
3177 } 3177 }
3178 } 3178 }
3179 if(intrapred)s->ac_pred = get_bits(gb, 1); 3179 if(intrapred)s->ac_pred = get_bits1(gb);
3180 else s->ac_pred = 0; 3180 else s->ac_pred = 0;
3181 } 3181 }
3182 if (!v->ttmbf && coded_inter) 3182 if (!v->ttmbf && coded_inter)
3183 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); 3183 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
3184 for (i=0; i<6; i++) 3184 for (i=0; i<6; i++)
3447 s->current_picture.motion_val[1][s->block_index[0]][0] = 0; 3447 s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
3448 s->current_picture.motion_val[1][s->block_index[0]][1] = 0; 3448 s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
3449 3449
3450 // do actual MB decoding and displaying 3450 // do actual MB decoding and displaying
3451 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); 3451 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
3452 v->s.ac_pred = get_bits(&v->s.gb, 1); 3452 v->s.ac_pred = get_bits1(&v->s.gb);
3453 3453
3454 for(k = 0; k < 6; k++) { 3454 for(k = 0; k < 6; k++) {
3455 val = ((cbp >> (5 - k)) & 1); 3455 val = ((cbp >> (5 - k)) & 1);
3456 3456
3457 if (k < 4) { 3457 if (k < 4) {
3559 s->current_picture.motion_val[1][s->block_index[0]][1] = 0; 3559 s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
3560 3560
3561 // do actual MB decoding and displaying 3561 // do actual MB decoding and displaying
3562 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); 3562 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
3563 if(v->acpred_is_raw) 3563 if(v->acpred_is_raw)
3564 v->s.ac_pred = get_bits(&v->s.gb, 1); 3564 v->s.ac_pred = get_bits1(&v->s.gb);
3565 else 3565 else
3566 v->s.ac_pred = v->acpred_plane[mb_pos]; 3566 v->s.ac_pred = v->acpred_plane[mb_pos];
3567 3567
3568 if(v->condover == CONDOVER_SELECT) { 3568 if(v->condover == CONDOVER_SELECT) {
3569 if(v->overflg_is_raw) 3569 if(v->overflg_is_raw)
3570 overlap = get_bits(&v->s.gb, 1); 3570 overlap = get_bits1(&v->s.gb);
3571 else 3571 else
3572 overlap = v->over_flags_plane[mb_pos]; 3572 overlap = v->over_flags_plane[mb_pos];
3573 } else 3573 } else
3574 overlap = (v->condover == CONDOVER_ALL); 3574 overlap = (v->condover == CONDOVER_ALL);
3575 3575