Mercurial > libavcodec.hg
comparison h263.c @ 1639:3e2b774edce4 libavcodec
rv20 decoder
author | michael |
---|---|
date | Sun, 30 Nov 2003 14:35:35 +0000 |
parents | 7799582dc9b8 |
children | 0226cad80fc2 |
comparison
equal
deleted
inserted
replaced
1638:e389d57db630 | 1639:3e2b774edce4 |
---|---|
183 put_bits(&s->pb, 5, s->qscale); /* Quantizer */ | 183 put_bits(&s->pb, 5, s->qscale); /* Quantizer */ |
184 put_bits(&s->pb, 1, 0); /* ExtraInformation */ | 184 put_bits(&s->pb, 1, 0); /* ExtraInformation */ |
185 | 185 |
186 if(s->h263_aic){ | 186 if(s->h263_aic){ |
187 s->y_dc_scale_table= | 187 s->y_dc_scale_table= |
188 s->c_dc_scale_table= h263_aic_dc_scale_table; | 188 s->c_dc_scale_table= ff_aic_dc_scale_table; |
189 }else{ | 189 }else{ |
190 s->y_dc_scale_table= | 190 s->y_dc_scale_table= |
191 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; | 191 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; |
192 } | 192 } |
193 } | 193 } |
286 | 286 |
287 put_bits(&s->pb, 1, 0); /* no PEI */ | 287 put_bits(&s->pb, 1, 0); /* no PEI */ |
288 | 288 |
289 if(s->h263_aic){ | 289 if(s->h263_aic){ |
290 s->y_dc_scale_table= | 290 s->y_dc_scale_table= |
291 s->c_dc_scale_table= h263_aic_dc_scale_table; | 291 s->c_dc_scale_table= ff_aic_dc_scale_table; |
292 }else{ | 292 }else{ |
293 s->y_dc_scale_table= | 293 s->y_dc_scale_table= |
294 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; | 294 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; |
295 } | 295 } |
296 } | 296 } |
1137 if(interleaved_stats){ | 1137 if(interleaved_stats){ |
1138 s->mv_bits+= get_bits_diff(s); | 1138 s->mv_bits+= get_bits_diff(s); |
1139 } | 1139 } |
1140 } else { | 1140 } else { |
1141 int li = s->h263_aic ? 0 : 1; | 1141 int li = s->h263_aic ? 0 : 1; |
1142 assert(s->mb_intra); | |
1142 | 1143 |
1143 cbp = 0; | 1144 cbp = 0; |
1144 for(i=0; i<6; i++) { | 1145 for(i=0; i<6; i++) { |
1145 /* Predict DC */ | 1146 /* Predict DC */ |
1146 if (s->h263_aic && s->mb_intra) { | 1147 if (s->h263_aic) { |
1147 int16_t level = block[i][0]; | 1148 int16_t level = block[i][0]; |
1148 | 1149 |
1149 pred_dc = h263_pred_dc(s, i, &dc_ptr[i]); | 1150 pred_dc = h263_pred_dc(s, i, &dc_ptr[i]); |
1150 level -= pred_dc; | 1151 level -= pred_dc; |
1151 /* Quant */ | 1152 /* Quant */ |
1284 int16_t *dc_val, *ac_val, *ac_val1; | 1285 int16_t *dc_val, *ac_val, *ac_val1; |
1285 | 1286 |
1286 /* find prediction */ | 1287 /* find prediction */ |
1287 if (n < 4) { | 1288 if (n < 4) { |
1288 x = 2 * s->mb_x + 1 + (n & 1); | 1289 x = 2 * s->mb_x + 1 + (n & 1); |
1289 y = 2 * s->mb_y + 1 + ((n & 2) >> 1); | 1290 y = 2 * s->mb_y + 1 + (n>> 1); |
1290 wrap = s->mb_width * 2 + 2; | 1291 wrap = s->mb_width * 2 + 2; |
1291 dc_val = s->dc_val[0]; | 1292 dc_val = s->dc_val[0]; |
1292 ac_val = s->ac_val[0][0]; | 1293 ac_val = s->ac_val[0][0]; |
1293 scale = s->y_dc_scale; | 1294 scale = s->y_dc_scale; |
1294 } else { | 1295 } else { |
1308 */ | 1309 */ |
1309 a = dc_val[(x - 1) + (y) * wrap]; | 1310 a = dc_val[(x - 1) + (y) * wrap]; |
1310 c = dc_val[(x) + (y - 1) * wrap]; | 1311 c = dc_val[(x) + (y - 1) * wrap]; |
1311 | 1312 |
1312 /* No prediction outside GOB boundary */ | 1313 /* No prediction outside GOB boundary */ |
1313 if (s->first_slice_line && ((n < 2) || (n > 3))) | 1314 if(s->first_slice_line && n!=3){ |
1314 c = 1024; | 1315 if(n!=2) c= 1024; |
1315 pred_dc = 1024; | 1316 if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024; |
1317 } | |
1318 | |
1316 if (s->ac_pred) { | 1319 if (s->ac_pred) { |
1320 pred_dc = 1024; | |
1317 if (s->h263_aic_dir) { | 1321 if (s->h263_aic_dir) { |
1318 /* left prediction */ | 1322 /* left prediction */ |
1319 if (a != 1024) { | 1323 if (a != 1024) { |
1320 ac_val -= 16; | 1324 ac_val -= 16; |
1321 for(i=1;i<8;i++) { | 1325 for(i=1;i<8;i++) { |
1346 /* we assume pred is positive */ | 1350 /* we assume pred is positive */ |
1347 block[0]=block[0]*scale + pred_dc; | 1351 block[0]=block[0]*scale + pred_dc; |
1348 | 1352 |
1349 if (block[0] < 0) | 1353 if (block[0] < 0) |
1350 block[0] = 0; | 1354 block[0] = 0; |
1351 else if (!(block[0] & 1)) | 1355 else |
1352 block[0]++; | 1356 block[0] |= 1; |
1353 | 1357 |
1354 /* Update AC/DC tables */ | 1358 /* Update AC/DC tables */ |
1355 dc_val[(x) + (y) * wrap] = block[0]; | 1359 dc_val[(x) + (y) * wrap] = block[0]; |
1356 | 1360 |
1357 /* left copy */ | 1361 /* left copy */ |
3515 if(s->alt_inter_vlc==0 || (cbpc & 3)!=3) | 3519 if(s->alt_inter_vlc==0 || (cbpc & 3)!=3) |
3516 cbpy ^= 0xF; | 3520 cbpy ^= 0xF; |
3517 | 3521 |
3518 cbp = (cbpc & 3) | (cbpy << 2); | 3522 cbp = (cbpc & 3) | (cbpy << 2); |
3519 if (dquant) { | 3523 if (dquant) { |
3520 change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); | 3524 if(s->modified_quant){ |
3525 if(get_bits1(&s->gb)) | |
3526 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ]; | |
3527 else | |
3528 s->qscale= get_bits(&s->gb, 5); | |
3529 }else | |
3530 s->qscale += quant_tab[get_bits(&s->gb, 2)]; | |
3531 change_qscale(s, 0); | |
3521 } | 3532 } |
3522 if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE))) | 3533 if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE))) |
3523 s->interlaced_dct= get_bits1(&s->gb); | 3534 s->interlaced_dct= get_bits1(&s->gb); |
3524 | 3535 |
3525 s->mv_dir = MV_DIR_FORWARD; | 3536 s->mv_dir = MV_DIR_FORWARD; |
3770 av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); | 3781 av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); |
3771 return -1; | 3782 return -1; |
3772 } | 3783 } |
3773 cbp = (cbpc & 3) | (cbpy << 2); | 3784 cbp = (cbpc & 3) | (cbpy << 2); |
3774 if (dquant) { | 3785 if (dquant) { |
3775 change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); | 3786 if(s->modified_quant){ |
3787 if(get_bits1(&s->gb)) | |
3788 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ]; | |
3789 else | |
3790 s->qscale= get_bits(&s->gb, 5); | |
3791 }else | |
3792 s->qscale += quant_tab[get_bits(&s->gb, 2)]; | |
3793 change_qscale(s, 0); | |
3776 } | 3794 } |
3777 | 3795 |
3778 if(!s->progressive_sequence) | 3796 if(!s->progressive_sequence) |
3779 s->interlaced_dct= get_bits1(&s->gb); | 3797 s->interlaced_dct= get_bits1(&s->gb); |
3780 | 3798 |
4457 } | 4475 } |
4458 if (get_bits1(&s->gb) != 0) { | 4476 if (get_bits1(&s->gb) != 0) { |
4459 av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); | 4477 av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); |
4460 } | 4478 } |
4461 s->alt_inter_vlc= get_bits1(&s->gb); | 4479 s->alt_inter_vlc= get_bits1(&s->gb); |
4462 if (get_bits1(&s->gb) != 0) { | 4480 s->modified_quant= get_bits1(&s->gb); |
4463 av_log(s->avctx, AV_LOG_ERROR, "Modified Quantization not supported\n"); | |
4464 } | |
4465 | 4481 |
4466 skip_bits(&s->gb, 1); /* Prevent start code emulation */ | 4482 skip_bits(&s->gb, 1); /* Prevent start code emulation */ |
4467 | 4483 |
4468 skip_bits(&s->gb, 3); /* Reserved */ | 4484 skip_bits(&s->gb, 3); /* Reserved */ |
4469 } else if (ufep != 0) { | 4485 } else if (ufep != 0) { |
4530 } | 4546 } |
4531 s->f_code = 1; | 4547 s->f_code = 1; |
4532 | 4548 |
4533 if(s->h263_aic){ | 4549 if(s->h263_aic){ |
4534 s->y_dc_scale_table= | 4550 s->y_dc_scale_table= |
4535 s->c_dc_scale_table= h263_aic_dc_scale_table; | 4551 s->c_dc_scale_table= ff_aic_dc_scale_table; |
4536 }else{ | 4552 }else{ |
4537 s->y_dc_scale_table= | 4553 s->y_dc_scale_table= |
4538 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; | 4554 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; |
4539 } | 4555 } |
4540 | 4556 |
4541 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ | 4557 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ |
4542 av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s\n", | 4558 av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s\n", |
4543 s->qscale, av_get_pict_type_char(s->pict_type), | 4559 s->qscale, av_get_pict_type_char(s->pict_type), |
4544 s->gb.size_in_bits, 1-s->no_rounding, | 4560 s->gb.size_in_bits, 1-s->no_rounding, |
4545 s->obmc ? " AP" : "", | 4561 s->obmc ? " AP" : "", |
4546 s->umvplus ? " UMV" : "", | 4562 s->umvplus ? " UMV" : "", |
4547 s->h263_long_vectors ? " LONG" : "", | 4563 s->h263_long_vectors ? " LONG" : "", |
4548 s->h263_plus ? " +" : "", | 4564 s->h263_plus ? " +" : "", |
4549 s->h263_aic ? " AIC" : "", | 4565 s->h263_aic ? " AIC" : "", |
4550 s->alt_inter_vlc ? " AIV" : "" | 4566 s->alt_inter_vlc ? " AIV" : "", |
4567 s->modified_quant ? " MQ" : "" | |
4551 ); | 4568 ); |
4552 } | 4569 } |
4553 #if 1 | 4570 #if 1 |
4554 if (s->pict_type == I_TYPE && s->avctx->codec_tag == ff_get_fourcc("ZYGO")){ | 4571 if (s->pict_type == I_TYPE && s->avctx->codec_tag == ff_get_fourcc("ZYGO")){ |
4555 int i,j; | 4572 int i,j; |