comparison h263.c @ 2646:c735e3e60ca7 libavcodec

Even More spelling errors. patch by (Kevin Baragona <kevinmb500 gawab com)
author michael
date Thu, 05 May 2005 14:34:47 +0000
parents e2780f828440
children d1609cfeb1d0
comparison
equal deleted inserted replaced
2645:42528c1f0246 2646:c735e3e60ca7
108 max level: 53/16 108 max level: 53/16
109 max run: 29/41 109 max run: 29/41
110 */ 110 */
111 #endif 111 #endif
112 112
113 #if 0 //3IV1 is quite rare and tis slows things down a tiny bit 113 #if 0 //3IV1 is quite rare and it slows things down a tiny bit
114 #define IS_3IV1 s->avctx->codec_tag == ff_get_fourcc("3IV1") 114 #define IS_3IV1 s->avctx->codec_tag == ff_get_fourcc("3IV1")
115 #else 115 #else
116 #define IS_3IV1 0 116 #define IS_3IV1 0
117 #endif 117 #endif
118 118
521 521
522 ff_clean_h263_qscales(s); 522 ff_clean_h263_qscales(s);
523 523
524 if(s->pict_type== B_TYPE){ 524 if(s->pict_type== B_TYPE){
525 int odd=0; 525 int odd=0;
526 /* ok, come on, this isnt funny anymore, theres more code for handling this mpeg4 mess than 526 /* ok, come on, this isn't funny anymore, there's more code for handling this mpeg4 mess than for the actual adaptive quantization */
527 for the actual adaptive quantization */
528 527
529 for(i=0; i<s->mb_num; i++){ 528 for(i=0; i<s->mb_num; i++){
530 int mb_xy= s->mb_index2xy[i]; 529 int mb_xy= s->mb_index2xy[i];
531 odd += qscale_table[mb_xy]&1; 530 odd += qscale_table[mb_xy]&1;
532 } 531 }
613 } 612 }
614 } 613 }
615 614
616 void ff_h263_update_motion_val(MpegEncContext * s){ 615 void ff_h263_update_motion_val(MpegEncContext * s){
617 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; 616 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
618 //FIXME a lot of thet is only needed for !low_delay 617 //FIXME a lot of that is only needed for !low_delay
619 const int wrap = s->b8_stride; 618 const int wrap = s->b8_stride;
620 const int xy = s->block_index[0]; 619 const int xy = s->block_index[0];
621 620
622 s->current_picture.mbskip_table[mb_xy]= s->mb_skipped; 621 s->current_picture.mbskip_table[mb_xy]= s->mb_skipped;
623 622
860 s->skip_count++; 859 s->skip_count++;
861 s->mv[0][0][0]= 860 s->mv[0][0][0]=
862 s->mv[0][0][1]= 861 s->mv[0][0][1]=
863 s->mv[1][0][0]= 862 s->mv[1][0][0]=
864 s->mv[1][0][1]= 0; 863 s->mv[1][0][1]= 0;
865 s->mv_dir= MV_DIR_FORWARD; //doesnt matter 864 s->mv_dir= MV_DIR_FORWARD; //doesn't matter
866 s->qscale -= s->dquant; 865 s->qscale -= s->dquant;
867 // s->mb_skipped=1; 866 // s->mb_skipped=1;
868 867
869 return; 868 return;
870 } 869 }
885 return; 884 return;
886 } 885 }
887 886
888 put_bits(&s->pb, 1, 0); /* mb coded modb1=0 */ 887 put_bits(&s->pb, 1, 0); /* mb coded modb1=0 */
889 put_bits(&s->pb, 1, cbp ? 0 : 1); /* modb2 */ //FIXME merge 888 put_bits(&s->pb, 1, cbp ? 0 : 1); /* modb2 */ //FIXME merge
890 put_bits(&s->pb, mb_type+1, 1); // this table is so simple that we dont need it :) 889 put_bits(&s->pb, mb_type+1, 1); // this table is so simple that we don't need it :)
891 if(cbp) put_bits(&s->pb, 6, cbp); 890 if(cbp) put_bits(&s->pb, 6, cbp);
892 891
893 if(cbp && mb_type){ 892 if(cbp && mb_type){
894 if(s->dquant) 893 if(s->dquant)
895 put_bits(&s->pb, 2, (s->dquant>>2)+3); 894 put_bits(&s->pb, 2, (s->dquant>>2)+3);
899 s->qscale -= s->dquant; 898 s->qscale -= s->dquant;
900 899
901 if(!s->progressive_sequence){ 900 if(!s->progressive_sequence){
902 if(cbp) 901 if(cbp)
903 put_bits(&s->pb, 1, s->interlaced_dct); 902 put_bits(&s->pb, 1, s->interlaced_dct);
904 if(mb_type) // not diect mode 903 if(mb_type) // not direct mode
905 put_bits(&s->pb, 1, s->mv_type == MV_TYPE_FIELD); 904 put_bits(&s->pb, 1, s->mv_type == MV_TYPE_FIELD);
906 } 905 }
907 906
908 if(interleaved_stats){ 907 if(interleaved_stats){
909 s->misc_bits+= get_bits_diff(s); 908 s->misc_bits+= get_bits_diff(s);
974 }else{ /* s->pict_type==B_TYPE */ 973 }else{ /* s->pict_type==B_TYPE */
975 cbp= get_p_cbp(s, block, motion_x, motion_y); 974 cbp= get_p_cbp(s, block, motion_x, motion_y);
976 975
977 if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) { 976 if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
978 /* check if the B frames can skip it too, as we must skip it if we skip here 977 /* check if the B frames can skip it too, as we must skip it if we skip here
979 why didnt they just compress the skip-mb bits instead of reusing them ?! */ 978 why didn't they just compress the skip-mb bits instead of reusing them ?! */
980 if(s->max_b_frames>0){ 979 if(s->max_b_frames>0){
981 int i; 980 int i;
982 int x,y, offset; 981 int x,y, offset;
983 uint8_t *p_pic; 982 uint8_t *p_pic;
984 983
1621 mot_val = s->current_picture.motion_val[dir] + s->block_index[block]; 1620 mot_val = s->current_picture.motion_val[dir] + s->block_index[block];
1622 1621
1623 A = mot_val[ - 1]; 1622 A = mot_val[ - 1];
1624 /* special case for first (slice) line */ 1623 /* special case for first (slice) line */
1625 if (s->first_slice_line && block<3) { 1624 if (s->first_slice_line && block<3) {
1626 // we cant just change some MVs to simulate that as we need them for the B frames (and ME) 1625 // we can't just change some MVs to simulate that as we need them for the B frames (and ME)
1627 // and if we ever support non rectangular objects than we need to do a few ifs here anyway :( 1626 // and if we ever support non rectangular objects than we need to do a few ifs here anyway :(
1628 if(block==0){ //most common case 1627 if(block==0){ //most common case
1629 if(s->mb_x == s->resync_mb_x){ //rare 1628 if(s->mb_x == s->resync_mb_x){ //rare
1630 *px= *py = 0; 1629 *px= *py = 0;
1631 }else if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare 1630 }else if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
2052 s->max_qcoeff= 127; 2051 s->max_qcoeff= 127;
2053 } 2052 }
2054 s->y_dc_scale_table= 2053 s->y_dc_scale_table=
2055 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; 2054 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
2056 break; 2055 break;
2057 default: //nothing needed default table allready set in mpegvideo.c 2056 default: //nothing needed - default table already set in mpegvideo.c
2058 s->min_qcoeff= -127; 2057 s->min_qcoeff= -127;
2059 s->max_qcoeff= 127; 2058 s->max_qcoeff= 127;
2060 s->y_dc_scale_table= 2059 s->y_dc_scale_table=
2061 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; 2060 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
2062 } 2061 }
2507 */ 2506 */
2508 a = dc_val[ - 1]; 2507 a = dc_val[ - 1];
2509 b = dc_val[ - 1 - wrap]; 2508 b = dc_val[ - 1 - wrap];
2510 c = dc_val[ - wrap]; 2509 c = dc_val[ - wrap];
2511 2510
2512 /* outside slice handling (we cant do that by memset as we need the dc for error resilience) */ 2511 /* outside slice handling (we can't do that by memset as we need the dc for error resilience) */
2513 if(s->first_slice_line && n!=3){ 2512 if(s->first_slice_line && n!=3){
2514 if(n!=2) b=c= 1024; 2513 if(n!=2) b=c= 1024;
2515 if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024; 2514 if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024;
2516 } 2515 }
2517 if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1){ 2516 if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1){
3240 skip_bits(&s->gb, 2); /* vop coding type */ 3239 skip_bits(&s->gb, 2); /* vop coding type */
3241 //FIXME not rect stuff here 3240 //FIXME not rect stuff here
3242 3241
3243 if(s->shape != BIN_ONLY_SHAPE){ 3242 if(s->shape != BIN_ONLY_SHAPE){
3244 skip_bits(&s->gb, 3); /* intra dc vlc threshold */ 3243 skip_bits(&s->gb, 3); /* intra dc vlc threshold */
3245 //FIXME dont just ignore everything 3244 //FIXME don't just ignore everything
3246 if(s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ 3245 if(s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
3247 mpeg4_decode_sprite_trajectory(s, &s->gb); 3246 mpeg4_decode_sprite_trajectory(s, &s->gb);
3248 av_log(s->avctx, AV_LOG_ERROR, "untested\n"); 3247 av_log(s->avctx, AV_LOG_ERROR, "untested\n");
3249 } 3248 }
3250 3249
3291 memset(s->ac_val[0] + l_xy, 0, (l_wrap*2+1)*16*sizeof(int16_t)); 3290 memset(s->ac_val[0] + l_xy, 0, (l_wrap*2+1)*16*sizeof(int16_t));
3292 memset(s->ac_val[1] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t)); 3291 memset(s->ac_val[1] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
3293 memset(s->ac_val[2] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t)); 3292 memset(s->ac_val[2] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
3294 3293
3295 /* clean MV */ 3294 /* clean MV */
3296 // we cant clear the MVs as they might be needed by a b frame 3295 // we can't clear the MVs as they might be needed by a b frame
3297 // memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(int16_t)); 3296 // memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(int16_t));
3298 // memset(s->motion_val, 0, 2*sizeof(int16_t)*(2 + s->mb_width*2)*(2 + s->mb_height*2)); 3297 // memset(s->motion_val, 0, 2*sizeof(int16_t)*(2 + s->mb_width*2)*(2 + s->mb_height*2));
3299 s->last_mv[0][0][0]= 3298 s->last_mv[0][0][0]=
3300 s->last_mv[0][0][1]= 3299 s->last_mv[0][0][1]=
3301 s->last_mv[1][0][0]= 3300 s->last_mv[1][0][0]=
3320 else 3319 else
3321 ret= h263_decode_gob_header(s); 3320 ret= h263_decode_gob_header(s);
3322 if(ret>=0) 3321 if(ret>=0)
3323 return 0; 3322 return 0;
3324 } 3323 }
3325 //ok, its not where its supposed to be ... 3324 //ok, it's not where its supposed to be ...
3326 s->gb= s->last_resync_gb; 3325 s->gb= s->last_resync_gb;
3327 align_get_bits(&s->gb); 3326 align_get_bits(&s->gb);
3328 left= s->gb.size_in_bits - get_bits_count(&s->gb); 3327 left= s->gb.size_in_bits - get_bits_count(&s->gb);
3329 3328
3330 for(;left>16+1+5+5; left-=8){ 3329 for(;left>16+1+5+5; left-=8){
4649 level = -level; 4648 level = -level;
4650 } 4649 }
4651 i += run; 4650 i += run;
4652 if (i >= 64){ 4651 if (i >= 64){
4653 if(s->alt_inter_vlc && rl == &rl_inter && !s->mb_intra){ 4652 if(s->alt_inter_vlc && rl == &rl_inter && !s->mb_intra){
4654 //looks like a hack but no, its the way its supposed to work ... 4653 //looks like a hack but no, it's the way its supposed to work ...
4655 rl = &rl_intra_aic; 4654 rl = &rl_intra_aic;
4656 i = 0; 4655 i = 0;
4657 s->gb= gb; 4656 s->gb= gb;
4658 memset(block, 0, sizeof(DCTELEM)*64); 4657 memset(block, 0, sizeof(DCTELEM)*64);
4659 goto retry; 4658 goto retry;
5296 while((1<<alpha)<w) alpha++; 5295 while((1<<alpha)<w) alpha++;
5297 while((1<<beta )<h) beta++; // there seems to be a typo in the mpeg4 std for the definition of w' and h' 5296 while((1<<beta )<h) beta++; // there seems to be a typo in the mpeg4 std for the definition of w' and h'
5298 w2= 1<<alpha; 5297 w2= 1<<alpha;
5299 h2= 1<<beta; 5298 h2= 1<<beta;
5300 5299
5301 // Note, the 4th point isnt used for GMC 5300 // Note, the 4th point isn't used for GMC
5302 if(s->divx_version==500 && s->divx_build==413){ 5301 if(s->divx_version==500 && s->divx_build==413){
5303 sprite_ref[0][0]= a*vop_ref[0][0] + d[0][0]; 5302 sprite_ref[0][0]= a*vop_ref[0][0] + d[0][0];
5304 sprite_ref[0][1]= a*vop_ref[0][1] + d[0][1]; 5303 sprite_ref[0][1]= a*vop_ref[0][1] + d[0][1];
5305 sprite_ref[1][0]= a*vop_ref[1][0] + d[0][0] + d[1][0]; 5304 sprite_ref[1][0]= a*vop_ref[1][0] + d[0][0] + d[1][0];
5306 sprite_ref[1][1]= a*vop_ref[1][1] + d[0][1] + d[1][1]; 5305 sprite_ref[1][1]= a*vop_ref[1][1] + d[0][1] + d[1][1];
5521 skip_bits1(gb); /* marker */ 5520 skip_bits1(gb); /* marker */
5522 get_bits(gb, 15); /* latter_half_vbv_occupancy */ 5521 get_bits(gb, 15); /* latter_half_vbv_occupancy */
5523 skip_bits1(gb); /* marker */ 5522 skip_bits1(gb); /* marker */
5524 } 5523 }
5525 }else{ 5524 }else{
5526 // set low delay flag only once so the smart? low delay detection wont be overriden 5525 // set low delay flag only once the smartest? low delay detection won't be overriden
5527 if(s->picture_number==0) 5526 if(s->picture_number==0)
5528 s->low_delay=0; 5527 s->low_delay=0;
5529 } 5528 }
5530 5529
5531 s->shape = get_bits(gb, 2); /* vol shape */ 5530 s->shape = get_bits(gb, 2); /* vol shape */
5961 } 5960 }
5962 }else{ 5961 }else{
5963 if(s->enhancement_type){ 5962 if(s->enhancement_type){
5964 int load_backward_shape= get_bits1(gb); 5963 int load_backward_shape= get_bits1(gb);
5965 if(load_backward_shape){ 5964 if(load_backward_shape){
5966 av_log(s->avctx, AV_LOG_ERROR, "load backward shape isnt supported\n"); 5965 av_log(s->avctx, AV_LOG_ERROR, "load backward shape isn't supported\n");
5967 } 5966 }
5968 } 5967 }
5969 skip_bits(gb, 2); //ref_select_code 5968 skip_bits(gb, 2); //ref_select_code
5970 } 5969 }
5971 } 5970 }
5972 /* detect buggy encoders which dont set the low_delay flag (divx4/xvid/opendivx)*/ 5971 /* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/
5973 // note we cannot detect divx5 without b-frames easyly (allthough its buggy too) 5972 // note we cannot detect divx5 without b-frames easily (although it's buggy too)
5974 if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){ 5973 if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){
5975 av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); 5974 av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
5976 s->low_delay=1; 5975 s->low_delay=1;
5977 } 5976 }
5978 5977
5979 s->picture_number++; // better than pic number==0 allways ;) 5978 s->picture_number++; // better than pic number==0 always ;)
5980 5979
5981 s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support 5980 s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
5982 s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table; 5981 s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
5983 5982
5984 if(s->workaround_bugs&FF_BUG_EDGE){ 5983 if(s->workaround_bugs&FF_BUG_EDGE){