Mercurial > libavcodec.hg
comparison h263.c @ 2628:511e3afc43e1 libavcodec
Ministry of English Composition, reporting for duty (and the word is "skipped", not "skiped"; "skiped" would rhyme with "hyped")
author | melanson |
---|---|
date | Sun, 24 Apr 2005 17:21:11 +0000 |
parents | 0d88e3f89379 |
children | 67171616ead6 |
comparison
equal
deleted
inserted
replaced
2627:bf158d23bbcc | 2628:511e3afc43e1 |
---|---|
617 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; | 617 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 | 618 //FIXME a lot of thet is only needed for !low_delay |
619 const int wrap = s->b8_stride; | 619 const int wrap = s->b8_stride; |
620 const int xy = s->block_index[0]; | 620 const int xy = s->block_index[0]; |
621 | 621 |
622 s->current_picture.mbskip_table[mb_xy]= s->mb_skiped; | 622 s->current_picture.mbskip_table[mb_xy]= s->mb_skipped; |
623 | 623 |
624 if(s->mv_type != MV_TYPE_8X8){ | 624 if(s->mv_type != MV_TYPE_8X8){ |
625 int motion_x, motion_y; | 625 int motion_x, motion_y; |
626 if (s->mb_intra) { | 626 if (s->mb_intra) { |
627 motion_x = 0; | 627 motion_x = 0; |
853 | 853 |
854 assert(s->dquant>=-2 && s->dquant<=2); | 854 assert(s->dquant>=-2 && s->dquant<=2); |
855 assert((s->dquant&1)==0); | 855 assert((s->dquant&1)==0); |
856 assert(mb_type>=0); | 856 assert(mb_type>=0); |
857 | 857 |
858 /* nothing to do if this MB was skiped in the next P Frame */ | 858 /* nothing to do if this MB was skipped in the next P Frame */ |
859 if(s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]){ //FIXME avoid DCT & ... | 859 if(s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]){ //FIXME avoid DCT & ... |
860 s->skip_count++; | 860 s->skip_count++; |
861 s->mv[0][0][0]= | 861 s->mv[0][0][0]= |
862 s->mv[0][0][1]= | 862 s->mv[0][0][1]= |
863 s->mv[1][0][0]= | 863 s->mv[1][0][0]= |
864 s->mv[1][0][1]= 0; | 864 s->mv[1][0][1]= 0; |
865 s->mv_dir= MV_DIR_FORWARD; //doesnt matter | 865 s->mv_dir= MV_DIR_FORWARD; //doesnt matter |
866 s->qscale -= s->dquant; | 866 s->qscale -= s->dquant; |
867 // s->mb_skiped=1; | 867 // s->mb_skipped=1; |
868 | 868 |
869 return; | 869 return; |
870 } | 870 } |
871 | 871 |
872 cbp= get_b_cbp(s, block, motion_x, motion_y, mb_type); | 872 cbp= get_b_cbp(s, block, motion_x, motion_y, mb_type); |
988 if(y+16 > s->height) y= s->height-16; | 988 if(y+16 > s->height) y= s->height-16; |
989 | 989 |
990 offset= x + y*s->linesize; | 990 offset= x + y*s->linesize; |
991 p_pic= s->new_picture.data[0] + offset; | 991 p_pic= s->new_picture.data[0] + offset; |
992 | 992 |
993 s->mb_skiped=1; | 993 s->mb_skipped=1; |
994 for(i=0; i<s->max_b_frames; i++){ | 994 for(i=0; i<s->max_b_frames; i++){ |
995 uint8_t *b_pic; | 995 uint8_t *b_pic; |
996 int diff; | 996 int diff; |
997 Picture *pic= s->reordered_input_picture[i+1]; | 997 Picture *pic= s->reordered_input_picture[i+1]; |
998 | 998 |
999 if(pic==NULL || pic->pict_type!=B_TYPE) break; | 999 if(pic==NULL || pic->pict_type!=B_TYPE) break; |
1000 | 1000 |
1001 b_pic= pic->data[0] + offset + 16; //FIXME +16 | 1001 b_pic= pic->data[0] + offset + 16; //FIXME +16 |
1002 diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16); | 1002 diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16); |
1003 if(diff>s->qscale*70){ //FIXME check that 70 is optimal | 1003 if(diff>s->qscale*70){ //FIXME check that 70 is optimal |
1004 s->mb_skiped=0; | 1004 s->mb_skipped=0; |
1005 break; | 1005 break; |
1006 } | 1006 } |
1007 } | 1007 } |
1008 }else | 1008 }else |
1009 s->mb_skiped=1; | 1009 s->mb_skipped=1; |
1010 | 1010 |
1011 if(s->mb_skiped==1){ | 1011 if(s->mb_skipped==1){ |
1012 /* skip macroblock */ | 1012 /* skip macroblock */ |
1013 put_bits(&s->pb, 1, 1); | 1013 put_bits(&s->pb, 1, 1); |
1014 | 1014 |
1015 if(interleaved_stats){ | 1015 if(interleaved_stats){ |
1016 s->misc_bits++; | 1016 s->misc_bits++; |
3209 av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num); | 3209 av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num); |
3210 return -1; | 3210 return -1; |
3211 } | 3211 } |
3212 if(s->pict_type == B_TYPE){ | 3212 if(s->pict_type == B_TYPE){ |
3213 while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) mb_num++; | 3213 while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) mb_num++; |
3214 if(mb_num >= s->mb_num) return -1; // slice contains just skiped MBs which where allready decoded | 3214 if(mb_num >= s->mb_num) return -1; // slice contains just skipped MBs which where allready decoded |
3215 } | 3215 } |
3216 | 3216 |
3217 s->mb_x= mb_num % s->mb_width; | 3217 s->mb_x= mb_num % s->mb_width; |
3218 s->mb_y= mb_num / s->mb_width; | 3218 s->mb_y= mb_num / s->mb_width; |
3219 | 3219 |
3727 s->block_last_index[i] = -1; | 3727 s->block_last_index[i] = -1; |
3728 s->mv_dir = MV_DIR_FORWARD; | 3728 s->mv_dir = MV_DIR_FORWARD; |
3729 s->mv_type = MV_TYPE_16X16; | 3729 s->mv_type = MV_TYPE_16X16; |
3730 if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ | 3730 if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ |
3731 s->mcsel=1; | 3731 s->mcsel=1; |
3732 s->mb_skiped = 0; | 3732 s->mb_skipped = 0; |
3733 }else{ | 3733 }else{ |
3734 s->mcsel=0; | 3734 s->mcsel=0; |
3735 s->mb_skiped = 1; | 3735 s->mb_skipped = 1; |
3736 } | 3736 } |
3737 }else if(s->mb_intra){ | 3737 }else if(s->mb_intra){ |
3738 s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); | 3738 s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); |
3739 }else if(!s->mb_intra){ | 3739 }else if(!s->mb_intra){ |
3740 // s->mcsel= 0; //FIXME do we need to init that | 3740 // s->mcsel= 0; //FIXME do we need to init that |
3908 s->mv_dir = MV_DIR_FORWARD; | 3908 s->mv_dir = MV_DIR_FORWARD; |
3909 s->mv_type = MV_TYPE_16X16; | 3909 s->mv_type = MV_TYPE_16X16; |
3910 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; | 3910 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; |
3911 s->mv[0][0][0] = 0; | 3911 s->mv[0][0][0] = 0; |
3912 s->mv[0][0][1] = 0; | 3912 s->mv[0][0][1] = 0; |
3913 s->mb_skiped = !(s->obmc | s->loop_filter); | 3913 s->mb_skipped = !(s->obmc | s->loop_filter); |
3914 goto end; | 3914 goto end; |
3915 } | 3915 } |
3916 cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); | 3916 cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); |
3917 //fprintf(stderr, "\tCBPC: %d", cbpc); | 3917 //fprintf(stderr, "\tCBPC: %d", cbpc); |
3918 if (cbpc < 0){ | 3918 if (cbpc < 0){ |
4173 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0; | 4173 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0; |
4174 s->mcsel=1; | 4174 s->mcsel=1; |
4175 s->mv[0][0][0]= get_amv(s, 0); | 4175 s->mv[0][0][0]= get_amv(s, 0); |
4176 s->mv[0][0][1]= get_amv(s, 1); | 4176 s->mv[0][0][1]= get_amv(s, 1); |
4177 | 4177 |
4178 s->mb_skiped = 0; | 4178 s->mb_skipped = 0; |
4179 }else{ | 4179 }else{ |
4180 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; | 4180 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; |
4181 s->mcsel=0; | 4181 s->mcsel=0; |
4182 s->mv[0][0][0] = 0; | 4182 s->mv[0][0][0] = 0; |
4183 s->mv[0][0][1] = 0; | 4183 s->mv[0][0][1] = 0; |
4184 s->mb_skiped = 1; | 4184 s->mb_skipped = 1; |
4185 } | 4185 } |
4186 goto end; | 4186 goto end; |
4187 } | 4187 } |
4188 cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); | 4188 cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); |
4189 //fprintf(stderr, "\tCBPC: %d", cbpc); | 4189 //fprintf(stderr, "\tCBPC: %d", cbpc); |
4292 s->last_mv[i][1][1]= 0; | 4292 s->last_mv[i][1][1]= 0; |
4293 } | 4293 } |
4294 } | 4294 } |
4295 | 4295 |
4296 /* if we skipped it in the future P Frame than skip it now too */ | 4296 /* if we skipped it in the future P Frame than skip it now too */ |
4297 s->mb_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC | 4297 s->mb_skipped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC |
4298 | 4298 |
4299 if(s->mb_skiped){ | 4299 if(s->mb_skipped){ |
4300 /* skip mb */ | 4300 /* skip mb */ |
4301 for(i=0;i<6;i++) | 4301 for(i=0;i<6;i++) |
4302 s->block_last_index[i] = -1; | 4302 s->block_last_index[i] = -1; |
4303 | 4303 |
4304 s->mv_dir = MV_DIR_FORWARD; | 4304 s->mv_dir = MV_DIR_FORWARD; |
5584 // FIXME sadct disable bit if verid!=1 && shape not rect | 5584 // FIXME sadct disable bit if verid!=1 && shape not rect |
5585 | 5585 |
5586 if (get_bits1(gb) == 1) { /* not_8_bit */ | 5586 if (get_bits1(gb) == 1) { /* not_8_bit */ |
5587 s->quant_precision = get_bits(gb, 4); /* quant_precision */ | 5587 s->quant_precision = get_bits(gb, 4); /* quant_precision */ |
5588 if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */ | 5588 if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */ |
5589 if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precission %d\n", s->quant_precision); | 5589 if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precision %d\n", s->quant_precision); |
5590 } else { | 5590 } else { |
5591 s->quant_precision = 5; | 5591 s->quant_precision = 5; |
5592 } | 5592 } |
5593 | 5593 |
5594 // FIXME a bunch of grayscale shape things | 5594 // FIXME a bunch of grayscale shape things |
5776 static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ | 5776 static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ |
5777 int time_incr, time_increment; | 5777 int time_incr, time_increment; |
5778 | 5778 |
5779 s->pict_type = get_bits(gb, 2) + I_TYPE; /* pict type: I = 0 , P = 1 */ | 5779 s->pict_type = get_bits(gb, 2) + I_TYPE; /* pict type: I = 0 , P = 1 */ |
5780 if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){ | 5780 if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){ |
5781 av_log(s->avctx, AV_LOG_ERROR, "low_delay flag set, but shouldnt, clearing it\n"); | 5781 av_log(s->avctx, AV_LOG_ERROR, "low_delay flag incorrectly, clearing it\n"); |
5782 s->low_delay=0; | 5782 s->low_delay=0; |
5783 } | 5783 } |
5784 | 5784 |
5785 s->partitioned_frame= s->data_partitioning && s->pict_type!=B_TYPE; | 5785 s->partitioned_frame= s->data_partitioning && s->pict_type!=B_TYPE; |
5786 if(s->partitioned_frame) | 5786 if(s->partitioned_frame) |
5797 time_incr++; | 5797 time_incr++; |
5798 | 5798 |
5799 check_marker(gb, "before time_increment"); | 5799 check_marker(gb, "before time_increment"); |
5800 | 5800 |
5801 if(s->time_increment_bits==0){ | 5801 if(s->time_increment_bits==0){ |
5802 av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers arnt complete, trying to guess time_increment_bits\n"); | 5802 av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers are not complete, trying to guess time_increment_bits\n"); |
5803 | 5803 |
5804 for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){ | 5804 for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){ |
5805 if(show_bits(gb, s->time_increment_bits+1)&1) break; | 5805 if(show_bits(gb, s->time_increment_bits+1)&1) break; |
5806 } | 5806 } |
5807 | 5807 |
5828 s->last_non_b_time= s->time; | 5828 s->last_non_b_time= s->time; |
5829 }else{ | 5829 }else{ |
5830 s->time= (s->last_time_base + time_incr)*s->time_increment_resolution + time_increment; | 5830 s->time= (s->last_time_base + time_incr)*s->time_increment_resolution + time_increment; |
5831 s->pb_time= s->pp_time - (s->last_non_b_time - s->time); | 5831 s->pb_time= s->pp_time - (s->last_non_b_time - s->time); |
5832 if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ | 5832 if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ |
5833 // printf("messed up order, seeking?, skiping current b frame\n"); | 5833 // printf("messed up order, maybe after seeking? skipping current b frame\n"); |
5834 return FRAME_SKIPED; | 5834 return FRAME_SKIPPED; |
5835 } | 5835 } |
5836 | 5836 |
5837 if(s->t_frame==0) s->t_frame= s->pb_time; | 5837 if(s->t_frame==0) s->t_frame= s->pb_time; |
5838 if(s->t_frame==0) s->t_frame=1; // 1/0 protection | 5838 if(s->t_frame==0) s->t_frame=1; // 1/0 protection |
5839 s->pp_field_time= ( ROUNDED_DIV(s->last_non_b_time, s->t_frame) | 5839 s->pp_field_time= ( ROUNDED_DIV(s->last_non_b_time, s->t_frame) |
5851 | 5851 |
5852 /* vop coded */ | 5852 /* vop coded */ |
5853 if (get_bits1(gb) != 1){ | 5853 if (get_bits1(gb) != 1){ |
5854 if(s->avctx->debug&FF_DEBUG_PICT_INFO) | 5854 if(s->avctx->debug&FF_DEBUG_PICT_INFO) |
5855 av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n"); | 5855 av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n"); |
5856 return FRAME_SKIPED; | 5856 return FRAME_SKIPPED; |
5857 } | 5857 } |
5858 //printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->time_increment_resolution, s->time_base, | 5858 //printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->time_increment_resolution, s->time_base, |
5859 //s->time, s->last_non_b_time, s->last_non_b_time - s->pp_time); | 5859 //s->time, s->last_non_b_time, s->last_non_b_time - s->pp_time); |
5860 if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == P_TYPE | 5860 if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == P_TYPE |
5861 || (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) { | 5861 || (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) { |
6001 startcode = ((startcode << 8) | v) & 0xffffffff; | 6001 startcode = ((startcode << 8) | v) & 0xffffffff; |
6002 | 6002 |
6003 if(get_bits_count(gb) >= gb->size_in_bits){ | 6003 if(get_bits_count(gb) >= gb->size_in_bits){ |
6004 if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){ | 6004 if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){ |
6005 av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits); | 6005 av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits); |
6006 return FRAME_SKIPED; //divx bug | 6006 return FRAME_SKIPPED; //divx bug |
6007 }else | 6007 }else |
6008 return -1; //end of stream | 6008 return -1; //end of stream |
6009 } | 6009 } |
6010 | 6010 |
6011 if((startcode&0xFFFFFF00) != 0x100) | 6011 if((startcode&0xFFFFFF00) != 0x100) |
6030 else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); | 6030 else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); |
6031 else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); | 6031 else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); |
6032 else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); | 6032 else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); |
6033 else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); | 6033 else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); |
6034 else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); | 6034 else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); |
6035 else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Textutre Object start"); | 6035 else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); |
6036 else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Spatial Layer start"); | 6036 else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); |
6037 else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Textutre SNR Layer start"); | 6037 else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); |
6038 else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Tile start"); | 6038 else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); |
6039 else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Shape Layer start"); | 6039 else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); |
6040 else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); | 6040 else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); |
6041 else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); | 6041 else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); |
6042 else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); | 6042 else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); |
6043 av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); | 6043 av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); |
6044 } | 6044 } |