comparison vc1.c @ 6481:493dc59d469a libavcodec

add FF_ prefix to all (frame)_TYPE usage
author aurel
date Sun, 09 Mar 2008 23:31:02 +0000
parents 8e63d869a904
children 48759bfbd073
comparison
equal deleted inserted replaced
6480:6f01a499e785 6481:493dc59d469a
398 398
399 mx = s->mv[dir][0][0]; 399 mx = s->mv[dir][0][0];
400 my = s->mv[dir][0][1]; 400 my = s->mv[dir][0][1];
401 401
402 // store motion vectors for further use in B frames 402 // store motion vectors for further use in B frames
403 if(s->pict_type == P_TYPE) { 403 if(s->pict_type == FF_P_TYPE) {
404 s->current_picture.motion_val[1][s->block_index[0]][0] = mx; 404 s->current_picture.motion_val[1][s->block_index[0]][0] = mx;
405 s->current_picture.motion_val[1][s->block_index[0]][1] = my; 405 s->current_picture.motion_val[1][s->block_index[0]][1] = my;
406 } 406 }
407 uvmx = (mx + ((mx & 3) == 3)) >> 1; 407 uvmx = (mx + ((mx & 3) == 3)) >> 1;
408 uvmy = (my + ((my & 3) == 3)) >> 1; 408 uvmy = (my + ((my & 3) == 3)) >> 1;
1039 v->rangeredfrm = 0; 1039 v->rangeredfrm = 0;
1040 if (v->rangered) v->rangeredfrm = get_bits1(gb); 1040 if (v->rangered) v->rangeredfrm = get_bits1(gb);
1041 v->s.pict_type = get_bits1(gb); 1041 v->s.pict_type = get_bits1(gb);
1042 if (v->s.avctx->max_b_frames) { 1042 if (v->s.avctx->max_b_frames) {
1043 if (!v->s.pict_type) { 1043 if (!v->s.pict_type) {
1044 if (get_bits1(gb)) v->s.pict_type = I_TYPE; 1044 if (get_bits1(gb)) v->s.pict_type = FF_I_TYPE;
1045 else v->s.pict_type = B_TYPE; 1045 else v->s.pict_type = FF_B_TYPE;
1046 } else v->s.pict_type = P_TYPE; 1046 } else v->s.pict_type = FF_P_TYPE;
1047 } else v->s.pict_type = v->s.pict_type ? P_TYPE : I_TYPE; 1047 } else v->s.pict_type = v->s.pict_type ? FF_P_TYPE : FF_I_TYPE;
1048 1048
1049 v->bi_type = 0; 1049 v->bi_type = 0;
1050 if(v->s.pict_type == B_TYPE) { 1050 if(v->s.pict_type == FF_B_TYPE) {
1051 v->bfraction = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); 1051 v->bfraction = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
1052 v->bfraction = ff_vc1_bfraction_lut[v->bfraction]; 1052 v->bfraction = ff_vc1_bfraction_lut[v->bfraction];
1053 if(v->bfraction == 0) { 1053 if(v->bfraction == 0) {
1054 v->s.pict_type = BI_TYPE; 1054 v->s.pict_type = FF_BI_TYPE;
1055 } 1055 }
1056 } 1056 }
1057 if(v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) 1057 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
1058 skip_bits(gb, 7); // skip buffer fullness 1058 skip_bits(gb, 7); // skip buffer fullness
1059 1059
1060 /* calculate RND */ 1060 /* calculate RND */
1061 if(v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) 1061 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
1062 v->rnd = 1; 1062 v->rnd = 1;
1063 if(v->s.pict_type == P_TYPE) 1063 if(v->s.pict_type == FF_P_TYPE)
1064 v->rnd ^= 1; 1064 v->rnd ^= 1;
1065 1065
1066 /* Quantizer stuff */ 1066 /* Quantizer stuff */
1067 pqindex = get_bits(gb, 5); 1067 pqindex = get_bits(gb, 5);
1068 if(!pqindex) return -1; 1068 if(!pqindex) return -1;
1090 if (v->profile == PROFILE_ADVANCED) 1090 if (v->profile == PROFILE_ADVANCED)
1091 { 1091 {
1092 if (v->postprocflag) v->postproc = get_bits1(gb); 1092 if (v->postprocflag) v->postproc = get_bits1(gb);
1093 } 1093 }
1094 else 1094 else
1095 if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2); 1095 if (v->multires && v->s.pict_type != FF_B_TYPE) v->respic = get_bits(gb, 2);
1096 1096
1097 if(v->res_x8 && (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)){ 1097 if(v->res_x8 && (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)){
1098 v->x8_type = get_bits1(gb); 1098 v->x8_type = get_bits1(gb);
1099 }else v->x8_type = 0; 1099 }else v->x8_type = 0;
1100 //av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n", 1100 //av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
1101 // (v->s.pict_type == P_TYPE) ? 'P' : ((v->s.pict_type == I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm); 1101 // (v->s.pict_type == FF_P_TYPE) ? 'P' : ((v->s.pict_type == FF_I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm);
1102 1102
1103 if(v->s.pict_type == I_TYPE || v->s.pict_type == P_TYPE) v->use_ic = 0; 1103 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_P_TYPE) v->use_ic = 0;
1104 1104
1105 switch(v->s.pict_type) { 1105 switch(v->s.pict_type) {
1106 case P_TYPE: 1106 case FF_P_TYPE:
1107 if (v->pq < 5) v->tt_index = 0; 1107 if (v->pq < 5) v->tt_index = 0;
1108 else if(v->pq < 13) v->tt_index = 1; 1108 else if(v->pq < 13) v->tt_index = 1;
1109 else v->tt_index = 2; 1109 else v->tt_index = 2;
1110 1110
1111 lowquant = (v->pq > 12) ? 0 : 1; 1111 lowquant = (v->pq > 12) ? 0 : 1;
1184 } else { 1184 } else {
1185 v->ttmbf = 1; 1185 v->ttmbf = 1;
1186 v->ttfrm = TT_8X8; 1186 v->ttfrm = TT_8X8;
1187 } 1187 }
1188 break; 1188 break;
1189 case B_TYPE: 1189 case FF_B_TYPE:
1190 if (v->pq < 5) v->tt_index = 0; 1190 if (v->pq < 5) v->tt_index = 0;
1191 else if(v->pq < 13) v->tt_index = 1; 1191 else if(v->pq < 13) v->tt_index = 1;
1192 else v->tt_index = 2; 1192 else v->tt_index = 2;
1193 1193
1194 lowquant = (v->pq > 12) ? 0 : 1; 1194 lowquant = (v->pq > 12) ? 0 : 1;
1231 1231
1232 if(!v->x8_type) 1232 if(!v->x8_type)
1233 { 1233 {
1234 /* AC Syntax */ 1234 /* AC Syntax */
1235 v->c_ac_table_index = decode012(gb); 1235 v->c_ac_table_index = decode012(gb);
1236 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) 1236 if (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
1237 { 1237 {
1238 v->y_ac_table_index = decode012(gb); 1238 v->y_ac_table_index = decode012(gb);
1239 } 1239 }
1240 /* DC Syntax */ 1240 /* DC Syntax */
1241 v->s.dc_table_index = get_bits1(gb); 1241 v->s.dc_table_index = get_bits1(gb);
1242 } 1242 }
1243 1243
1244 if(v->s.pict_type == BI_TYPE) { 1244 if(v->s.pict_type == FF_BI_TYPE) {
1245 v->s.pict_type = B_TYPE; 1245 v->s.pict_type = FF_B_TYPE;
1246 v->bi_type = 1; 1246 v->bi_type = 1;
1247 } 1247 }
1248 return 0; 1248 return 0;
1249 } 1249 }
1250 1250
1259 v->fcm = decode012(gb); 1259 v->fcm = decode012(gb);
1260 if(v->fcm) return -1; // interlaced frames/fields are not implemented 1260 if(v->fcm) return -1; // interlaced frames/fields are not implemented
1261 } 1261 }
1262 switch(get_unary(gb, 0, 4)) { 1262 switch(get_unary(gb, 0, 4)) {
1263 case 0: 1263 case 0:
1264 v->s.pict_type = P_TYPE; 1264 v->s.pict_type = FF_P_TYPE;
1265 break; 1265 break;
1266 case 1: 1266 case 1:
1267 v->s.pict_type = B_TYPE; 1267 v->s.pict_type = FF_B_TYPE;
1268 break; 1268 break;
1269 case 2: 1269 case 2:
1270 v->s.pict_type = I_TYPE; 1270 v->s.pict_type = FF_I_TYPE;
1271 break; 1271 break;
1272 case 3: 1272 case 3:
1273 v->s.pict_type = BI_TYPE; 1273 v->s.pict_type = FF_BI_TYPE;
1274 break; 1274 break;
1275 case 4: 1275 case 4:
1276 v->s.pict_type = P_TYPE; // skipped pic 1276 v->s.pict_type = FF_P_TYPE; // skipped pic
1277 v->p_frame_skipped = 1; 1277 v->p_frame_skipped = 1;
1278 return 0; 1278 return 0;
1279 } 1279 }
1280 if(v->tfcntrflag) 1280 if(v->tfcntrflag)
1281 skip_bits(gb, 8); 1281 skip_bits(gb, 8);
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_bits1(gb); 1296 if(v->finterpflag) v->interpfrm = get_bits1(gb);
1297 if(v->s.pict_type == B_TYPE) { 1297 if(v->s.pict_type == FF_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 = FF_BI_TYPE; /* XXX: should not happen here */
1302 } 1302 }
1303 } 1303 }
1304 pqindex = get_bits(gb, 5); 1304 pqindex = get_bits(gb, 5);
1305 if(!pqindex) return -1; 1305 if(!pqindex) return -1;
1306 v->pqindex = pqindex; 1306 v->pqindex = pqindex;
1318 if (pqindex < 9) v->halfpq = get_bits1(gb); 1318 if (pqindex < 9) v->halfpq = get_bits1(gb);
1319 else v->halfpq = 0; 1319 else v->halfpq = 0;
1320 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) 1320 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
1321 v->pquantizer = get_bits1(gb); 1321 v->pquantizer = get_bits1(gb);
1322 1322
1323 if(v->s.pict_type == I_TYPE || v->s.pict_type == P_TYPE) v->use_ic = 0; 1323 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_P_TYPE) v->use_ic = 0;
1324 1324
1325 switch(v->s.pict_type) { 1325 switch(v->s.pict_type) {
1326 case I_TYPE: 1326 case FF_I_TYPE:
1327 case BI_TYPE: 1327 case FF_BI_TYPE:
1328 status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v); 1328 status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);
1329 if (status < 0) return -1; 1329 if (status < 0) return -1;
1330 av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: " 1330 av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: "
1331 "Imode: %i, Invert: %i\n", status>>1, status&1); 1331 "Imode: %i, Invert: %i\n", status>>1, status&1);
1332 v->condover = CONDOVER_NONE; 1332 v->condover = CONDOVER_NONE;
1338 av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: " 1338 av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: "
1339 "Imode: %i, Invert: %i\n", status>>1, status&1); 1339 "Imode: %i, Invert: %i\n", status>>1, status&1);
1340 } 1340 }
1341 } 1341 }
1342 break; 1342 break;
1343 case P_TYPE: 1343 case FF_P_TYPE:
1344 if(v->postprocflag) 1344 if(v->postprocflag)
1345 v->postproc = get_bits1(gb); 1345 v->postproc = get_bits1(gb);
1346 if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); 1346 if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3);
1347 else v->mvrange = 0; 1347 else v->mvrange = 0;
1348 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 1348 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
1429 } else { 1429 } else {
1430 v->ttmbf = 1; 1430 v->ttmbf = 1;
1431 v->ttfrm = TT_8X8; 1431 v->ttfrm = TT_8X8;
1432 } 1432 }
1433 break; 1433 break;
1434 case B_TYPE: 1434 case FF_B_TYPE:
1435 if(v->postprocflag) 1435 if(v->postprocflag)
1436 v->postproc = get_bits1(gb); 1436 v->postproc = get_bits1(gb);
1437 if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); 1437 if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3);
1438 else v->mvrange = 0; 1438 else v->mvrange = 0;
1439 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 1439 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
1483 break; 1483 break;
1484 } 1484 }
1485 1485
1486 /* AC Syntax */ 1486 /* AC Syntax */
1487 v->c_ac_table_index = decode012(gb); 1487 v->c_ac_table_index = decode012(gb);
1488 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) 1488 if (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
1489 { 1489 {
1490 v->y_ac_table_index = decode012(gb); 1490 v->y_ac_table_index = decode012(gb);
1491 } 1491 }
1492 /* DC Syntax */ 1492 /* DC Syntax */
1493 v->s.dc_table_index = get_bits1(gb); 1493 v->s.dc_table_index = get_bits1(gb);
1494 if ((v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) && v->dquant) { 1494 if ((v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE) && v->dquant) {
1495 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); 1495 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
1496 vop_dquant_decoding(v); 1496 vop_dquant_decoding(v);
1497 } 1497 }
1498 1498
1499 v->bi_type = 0; 1499 v->bi_type = 0;
1500 if(v->s.pict_type == BI_TYPE) { 1500 if(v->s.pict_type == FF_BI_TYPE) {
1501 v->s.pict_type = B_TYPE; 1501 v->s.pict_type = FF_B_TYPE;
1502 v->bi_type = 1; 1502 v->bi_type = 1;
1503 } 1503 }
1504 return 0; 1504 return 0;
1505 } 1505 }
1506 1506
3734 memcpy(s->dest[1], s->last_picture.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); 3734 memcpy(s->dest[1], s->last_picture.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
3735 memcpy(s->dest[2], s->last_picture.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); 3735 memcpy(s->dest[2], s->last_picture.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
3736 ff_draw_horiz_band(s, s->mb_y * 16, 16); 3736 ff_draw_horiz_band(s, s->mb_y * 16, 16);
3737 s->first_slice_line = 0; 3737 s->first_slice_line = 0;
3738 } 3738 }
3739 s->pict_type = P_TYPE; 3739 s->pict_type = FF_P_TYPE;
3740 } 3740 }
3741 3741
3742 static void vc1_decode_blocks(VC1Context *v) 3742 static void vc1_decode_blocks(VC1Context *v)
3743 { 3743 {
3744 3744
3746 if(v->x8_type){ 3746 if(v->x8_type){
3747 ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) ); 3747 ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) );
3748 }else{ 3748 }else{
3749 3749
3750 switch(v->s.pict_type) { 3750 switch(v->s.pict_type) {
3751 case I_TYPE: 3751 case FF_I_TYPE:
3752 if(v->profile == PROFILE_ADVANCED) 3752 if(v->profile == PROFILE_ADVANCED)
3753 vc1_decode_i_blocks_adv(v); 3753 vc1_decode_i_blocks_adv(v);
3754 else 3754 else
3755 vc1_decode_i_blocks(v); 3755 vc1_decode_i_blocks(v);
3756 break; 3756 break;
3757 case P_TYPE: 3757 case FF_P_TYPE:
3758 if(v->p_frame_skipped) 3758 if(v->p_frame_skipped)
3759 vc1_decode_skip_blocks(v); 3759 vc1_decode_skip_blocks(v);
3760 else 3760 else
3761 vc1_decode_p_blocks(v); 3761 vc1_decode_p_blocks(v);
3762 break; 3762 break;
3763 case B_TYPE: 3763 case FF_B_TYPE:
3764 if(v->bi_type){ 3764 if(v->bi_type){
3765 if(v->profile == PROFILE_ADVANCED) 3765 if(v->profile == PROFILE_ADVANCED)
3766 vc1_decode_i_blocks_adv(v); 3766 vc1_decode_i_blocks_adv(v);
3767 else 3767 else
3768 vc1_decode_i_blocks(v); 3768 vc1_decode_i_blocks(v);
4028 av_free(buf2); 4028 av_free(buf2);
4029 return -1; 4029 return -1;
4030 } 4030 }
4031 } 4031 }
4032 4032
4033 if(s->pict_type != I_TYPE && !v->res_rtm_flag){ 4033 if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){
4034 av_free(buf2); 4034 av_free(buf2);
4035 return -1; 4035 return -1;
4036 } 4036 }
4037 4037
4038 // for hurry_up==5 4038 // for hurry_up==5
4039 s->current_picture.pict_type= s->pict_type; 4039 s->current_picture.pict_type= s->pict_type;
4040 s->current_picture.key_frame= s->pict_type == I_TYPE; 4040 s->current_picture.key_frame= s->pict_type == FF_I_TYPE;
4041 4041
4042 /* skip B-frames if we don't have reference frames */ 4042 /* skip B-frames if we don't have reference frames */
4043 if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)){ 4043 if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){
4044 av_free(buf2); 4044 av_free(buf2);
4045 return -1;//buf_size; 4045 return -1;//buf_size;
4046 } 4046 }
4047 /* skip b frames if we are in a hurry */ 4047 /* skip b frames if we are in a hurry */
4048 if(avctx->hurry_up && s->pict_type==B_TYPE) return -1;//buf_size; 4048 if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return -1;//buf_size;
4049 if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) 4049 if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE)
4050 || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) 4050 || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE)
4051 || avctx->skip_frame >= AVDISCARD_ALL) { 4051 || avctx->skip_frame >= AVDISCARD_ALL) {
4052 av_free(buf2); 4052 av_free(buf2);
4053 return buf_size; 4053 return buf_size;
4054 } 4054 }
4055 /* skip everything if we are in a hurry>=5 */ 4055 /* skip everything if we are in a hurry>=5 */
4057 av_free(buf2); 4057 av_free(buf2);
4058 return -1;//buf_size; 4058 return -1;//buf_size;
4059 } 4059 }
4060 4060
4061 if(s->next_p_frame_damaged){ 4061 if(s->next_p_frame_damaged){
4062 if(s->pict_type==B_TYPE) 4062 if(s->pict_type==FF_B_TYPE)
4063 return buf_size; 4063 return buf_size;
4064 else 4064 else
4065 s->next_p_frame_damaged=0; 4065 s->next_p_frame_damaged=0;
4066 } 4066 }
4067 4067
4084 4084
4085 MPV_frame_end(s); 4085 MPV_frame_end(s);
4086 4086
4087 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); 4087 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
4088 assert(s->current_picture.pict_type == s->pict_type); 4088 assert(s->current_picture.pict_type == s->pict_type);
4089 if (s->pict_type == B_TYPE || s->low_delay) { 4089 if (s->pict_type == FF_B_TYPE || s->low_delay) {
4090 *pict= *(AVFrame*)s->current_picture_ptr; 4090 *pict= *(AVFrame*)s->current_picture_ptr;
4091 } else if (s->last_picture_ptr != NULL) { 4091 } else if (s->last_picture_ptr != NULL) {
4092 *pict= *(AVFrame*)s->last_picture_ptr; 4092 *pict= *(AVFrame*)s->last_picture_ptr;
4093 } 4093 }
4094 4094