Revision ce5e49b0 libavcodec/mpeg4videodec.c
libavcodec/mpeg4videodec.c  

118  118 
} 
119  119  
120  120 
while(v<=0xFF){ 
121 
if(s>pict_type==FF_B_TYPE  (v>>(8s>pict_type)!=1)  s>partitioned_frame)


121 
if(s>pict_type==AV_PICTURE_TYPE_B  (v>>(8s>pict_type)!=1)  s>partitioned_frame)


122  122 
break; 
123  123 
skip_bits(&s>gb, 8+s>pict_type); 
124  124 
bits_count+= 8+s>pict_type; 
...  ...  
373  373 
av_log(s>avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s>mb_num); 
374  374 
return 1; 
375  375 
} 
376 
if(s>pict_type == FF_B_TYPE){


376 
if(s>pict_type == AV_PICTURE_TYPE_B){


377  377 
int mb_x = 0, mb_y = 0; 
378  378  
379  379 
while(s>next_picture.mbskip_table[ s>mb_index2xy[ mb_num ] ]) { 
...  ...  
413  413 
if(s>shape != BIN_ONLY_SHAPE){ 
414  414 
skip_bits(&s>gb, 3); /* intra dc vlc threshold */ 
415  415 
//FIXME don't just ignore everything 
416 
if(s>pict_type == FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE){


416 
if(s>pict_type == AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE){


417  417 
mpeg4_decode_sprite_trajectory(s, &s>gb); 
418  418 
av_log(s>avctx, AV_LOG_ERROR, "untested\n"); 
419  419 
} 
420  420  
421  421 
//FIXME reduced res stuff here 
422  422  
423 
if (s>pict_type != FF_I_TYPE) {


423 
if (s>pict_type != AV_PICTURE_TYPE_I) {


424  424 
int f_code = get_bits(&s>gb, 3); /* fcode_for */ 
425  425 
if(f_code==0){ 
426  426 
av_log(s>avctx, AV_LOG_ERROR, "Error, video packet header damaged (f_code=0)\n"); 
427  427 
} 
428  428 
} 
429 
if (s>pict_type == FF_B_TYPE) {


429 
if (s>pict_type == AV_PICTURE_TYPE_B) {


430  430 
int b_code = get_bits(&s>gb, 3); 
431  431 
if(b_code==0){ 
432  432 
av_log(s>avctx, AV_LOG_ERROR, "Error, video packet header damaged (b_code=0)\n"); 
...  ...  
555  555 
if(s>mb_x == s>resync_mb_x && s>mb_y == s>resync_mb_y+1) 
556  556 
s>first_slice_line=0; 
557  557  
558 
if(s>pict_type==FF_I_TYPE){


558 
if(s>pict_type==AV_PICTURE_TYPE_I){


559  559 
int i; 
560  560  
561  561 
do{ 
...  ...  
604  604 
skip_bits1(&s>gb); 
605  605 
if(bits&0x10000){ 
606  606 
/* skip mb */ 
607 
if(s>pict_type==FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE){


607 
if(s>pict_type==AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE){


608  608 
s>current_picture.mb_type[xy]= MB_TYPE_SKIP  MB_TYPE_16x16  MB_TYPE_GMC  MB_TYPE_L0; 
609  609 
mx= get_amv(s, 0); 
610  610 
my= get_amv(s, 1); 
...  ...  
645  645 
if(s>mbintra_table[xy]) 
646  646 
ff_clean_intra_table_entries(s); 
647  647  
648 
if(s>pict_type==FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)


648 
if(s>pict_type==AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)


649  649 
s>mcsel= get_bits1(&s>gb); 
650  650 
else s>mcsel= 0; 
651  651  
...  ...  
717  717 
if(s>mb_x == s>resync_mb_x && s>mb_y == s>resync_mb_y+1) 
718  718 
s>first_slice_line=0; 
719  719  
720 
if(s>pict_type==FF_I_TYPE){


720 
if(s>pict_type==AV_PICTURE_TYPE_I){


721  721 
int ac_pred= get_bits1(&s>gb); 
722  722 
int cbpy = get_vlc2(&s>gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); 
723  723 
if(cbpy<0){ 
...  ...  
791  791 
int ff_mpeg4_decode_partitions(MpegEncContext *s) 
792  792 
{ 
793  793 
int mb_num; 
794 
const int part_a_error= s>pict_type==FF_I_TYPE ? (DC_ERRORMV_ERROR) : MV_ERROR;


795 
const int part_a_end = s>pict_type==FF_I_TYPE ? (DC_END MV_END) : MV_END;


794 
const int part_a_error= s>pict_type==AV_PICTURE_TYPE_I ? (DC_ERRORMV_ERROR) : MV_ERROR;


795 
const int part_a_end = s>pict_type==AV_PICTURE_TYPE_I ? (DC_END MV_END) : MV_END;


796  796  
797  797 
mb_num= mpeg4_decode_partition_a(s); 
798  798 
if(mb_num<0){ 
...  ...  
808  808  
809  809 
s>mb_num_left= mb_num; 
810  810  
811 
if(s>pict_type==FF_I_TYPE){


811 
if(s>pict_type==AV_PICTURE_TYPE_I){


812  812 
while(show_bits(&s>gb, 9) == 1) 
813  813 
skip_bits(&s>gb, 9); 
814  814 
if(get_bits_long(&s>gb, 19)!=DC_MARKER){ 
...  ...  
826  826 
ff_er_add_slice(s, s>resync_mb_x, s>resync_mb_y, s>mb_x1, s>mb_y, part_a_end); 
827  827  
828  828 
if( mpeg4_decode_partition_b(s, mb_num) < 0){ 
829 
if(s>pict_type==FF_P_TYPE)


829 
if(s>pict_type==AV_PICTURE_TYPE_P)


830  830 
ff_er_add_slice(s, s>resync_mb_x, s>resync_mb_y, s>mb_x, s>mb_y, DC_ERROR); 
831  831 
return 1; 
832  832 
}else{ 
833 
if(s>pict_type==FF_P_TYPE)


833 
if(s>pict_type==AV_PICTURE_TYPE_P)


834  834 
ff_er_add_slice(s, s>resync_mb_x, s>resync_mb_y, s>mb_x1, s>mb_y, DC_END); 
835  835 
} 
836  836  
...  ...  
1101  1101 
ff_set_qscale(s, s>current_picture.qscale_table[xy] ); 
1102  1102 
} 
1103  1103  
1104 
if (s>pict_type == FF_P_TYPE  s>pict_type==FF_S_TYPE) {


1104 
if (s>pict_type == AV_PICTURE_TYPE_P  s>pict_type==AV_PICTURE_TYPE_S) {


1105  1105 
int i; 
1106  1106 
for(i=0; i<4; i++){ 
1107  1107 
s>mv[0][i][0] = s>current_picture.motion_val[0][ s>block_index[i] ][0]; 
...  ...  
1115  1115 
s>block_last_index[i] = 1; 
1116  1116 
s>mv_dir = MV_DIR_FORWARD; 
1117  1117 
s>mv_type = MV_TYPE_16X16; 
1118 
if(s>pict_type==FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE){


1118 
if(s>pict_type==AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE){


1119  1119 
s>mcsel=1; 
1120  1120 
s>mb_skipped = 0; 
1121  1121 
}else{ 
...  ...  
1179  1179  
1180  1180 
assert(s>h263_pred); 
1181  1181  
1182 
if (s>pict_type == FF_P_TYPE  s>pict_type==FF_S_TYPE) {


1182 
if (s>pict_type == AV_PICTURE_TYPE_P  s>pict_type==AV_PICTURE_TYPE_S) {


1183  1183 
do{ 
1184  1184 
if (get_bits1(&s>gb)) { 
1185  1185 
/* skip mb */ 
...  ...  
1188  1188 
s>block_last_index[i] = 1; 
1189  1189 
s>mv_dir = MV_DIR_FORWARD; 
1190  1190 
s>mv_type = MV_TYPE_16X16; 
1191 
if(s>pict_type==FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE){


1191 
if(s>pict_type==AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE){


1192  1192 
s>current_picture.mb_type[xy]= MB_TYPE_SKIP  MB_TYPE_GMC  MB_TYPE_16x16  MB_TYPE_L0; 
1193  1193 
s>mcsel=1; 
1194  1194 
s>mv[0][0][0]= get_amv(s, 0); 
...  ...  
1216  1216 
s>mb_intra = ((cbpc & 4) != 0); 
1217  1217 
if (s>mb_intra) goto intra; 
1218  1218  
1219 
if(s>pict_type==FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)


1219 
if(s>pict_type==AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)


1220  1220 
s>mcsel= get_bits1(&s>gb); 
1221  1221 
else s>mcsel= 0; 
1222  1222 
cbpy = get_vlc2(&s>gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1) ^ 0x0F; 
...  ...  
1295  1295 
mot_val[1] = my; 
1296  1296 
} 
1297  1297 
} 
1298 
} else if(s>pict_type==FF_B_TYPE) {


1298 
} else if(s>pict_type==AV_PICTURE_TYPE_B) {


1299  1299 
int modb1; // first bit of modb 
1300  1300 
int modb2; // second bit of modb 
1301  1301 
int mb_type; 
...  ...  
1492  1492 
if(mpeg4_is_resync(s)){ 
1493  1493 
const int delta= s>mb_x + 1 == s>mb_width ? 2 : 1; 
1494  1494  
1495 
if(s>pict_type==FF_B_TYPE){


1495 
if(s>pict_type==AV_PICTURE_TYPE_B){


1496  1496 
ff_thread_await_progress((AVFrame*)s>next_picture_ptr, 
1497  1497 
(s>mb_x + delta >= s>mb_width) ? FFMIN(s>mb_y+1, s>mb_height1) : s>mb_y, 0); 
1498  1498 
} 
1499  1499  
1500 
if(s>pict_type==FF_B_TYPE && s>next_picture.mbskip_table[xy + delta])


1500 
if(s>pict_type==AV_PICTURE_TYPE_B && s>next_picture.mbskip_table[xy + delta])


1501  1501 
return SLICE_OK; 
1502  1502 
return SLICE_END; 
1503  1503 
} 
...  ...  
1897  1897 
static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ 
1898  1898 
int time_incr, time_increment; 
1899  1899  
1900 
s>pict_type = get_bits(gb, 2) + FF_I_TYPE; /* pict type: I = 0 , P = 1 */


1901 
if(s>pict_type==FF_B_TYPE && s>low_delay && s>vol_control_parameters==0 && !(s>flags & CODEC_FLAG_LOW_DELAY)){


1900 
s>pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I; /* pict type: I = 0 , P = 1 */


1901 
if(s>pict_type==AV_PICTURE_TYPE_B && s>low_delay && s>vol_control_parameters==0 && !(s>flags & CODEC_FLAG_LOW_DELAY)){


1902  1902 
av_log(s>avctx, AV_LOG_ERROR, "low_delay flag incorrectly, clearing it\n"); 
1903  1903 
s>low_delay=0; 
1904  1904 
} 
1905  1905  
1906 
s>partitioned_frame= s>data_partitioning && s>pict_type!=FF_B_TYPE;


1906 
s>partitioned_frame= s>data_partitioning && s>pict_type!=AV_PICTURE_TYPE_B;


1907  1907 
if(s>partitioned_frame) 
1908  1908 
s>decode_mb= mpeg4_decode_partitioned_mb; 
1909  1909 
else 
...  ...  
1919  1919 
av_log(s>avctx, AV_LOG_ERROR, "hmm, seems the headers are not complete, trying to guess time_increment_bits\n"); 
1920  1920  
1921  1921 
for(s>time_increment_bits=1 ;s>time_increment_bits<16; s>time_increment_bits++){ 
1922 
if ( s>pict_type == FF_P_TYPE


1923 
 (s>pict_type == FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE)) {


1922 
if ( s>pict_type == AV_PICTURE_TYPE_P


1923 
 (s>pict_type == AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE)) {


1924  1924 
if((show_bits(gb, s>time_increment_bits+6)&0x37) == 0x30) break; 
1925  1925 
}else 
1926  1926 
if((show_bits(gb, s>time_increment_bits+5)&0x1F) == 0x18) break; 
...  ...  
1932  1932 
if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further 
1933  1933 
else time_increment= get_bits(gb, s>time_increment_bits); 
1934  1934  
1935 
if(s>pict_type!=FF_B_TYPE){


1935 
if(s>pict_type!=AV_PICTURE_TYPE_B){


1936  1936 
s>last_time_base= s>time_base; 
1937  1937 
s>time_base+= time_incr; 
1938  1938 
s>time= s>time_base*s>avctx>time_base.den + time_increment; 
...  ...  
1982  1982 
av_log(s>avctx, AV_LOG_ERROR, "vop not coded\n"); 
1983  1983 
return FRAME_SKIPPED; 
1984  1984 
} 
1985 
if (s>shape != BIN_ONLY_SHAPE && ( s>pict_type == FF_P_TYPE


1986 
 (s>pict_type == FF_S_TYPE && s>vol_sprite_usage==GMC_SPRITE))) {


1985 
if (s>shape != BIN_ONLY_SHAPE && ( s>pict_type == AV_PICTURE_TYPE_P


1986 
 (s>pict_type == AV_PICTURE_TYPE_S && s>vol_sprite_usage==GMC_SPRITE))) {


1987  1987 
/* rounding type for motion estimation */ 
1988  1988 
s>no_rounding = get_bits1(gb); 
1989  1989 
} else { 
...  ...  
1992  1992 
//FIXME reduced res stuff 
1993  1993  
1994  1994 
if (s>shape != RECT_SHAPE) { 
1995 
if (s>vol_sprite_usage != 1  s>pict_type != FF_I_TYPE) {


1995 
if (s>vol_sprite_usage != 1  s>pict_type != AV_PICTURE_TYPE_I) {


1996  1996 
int width, height, hor_spat_ref, ver_spat_ref; 
1997  1997  
1998  1998 
width = get_bits(gb, 13); 
...  ...  
2013  2013  
2014  2014 
if (s>shape != BIN_ONLY_SHAPE) { 
2015  2015 
skip_bits_long(gb, s>cplx_estimation_trash_i); 
2016 
if(s>pict_type != FF_I_TYPE)


2016 
if(s>pict_type != AV_PICTURE_TYPE_I)


2017  2017 
skip_bits_long(gb, s>cplx_estimation_trash_p); 
2018 
if(s>pict_type == FF_B_TYPE)


2018 
if(s>pict_type == AV_PICTURE_TYPE_B)


2019  2019 
skip_bits_long(gb, s>cplx_estimation_trash_b); 
2020  2020  
2021  2021 
s>intra_dc_threshold= mpeg4_dc_threshold[ get_bits(gb, 3) ]; 
...  ...  
2038  2038 
ff_init_scantable(s>dsp.idct_permutation, &s>intra_v_scantable, ff_alternate_vertical_scan); 
2039  2039 
} 
2040  2040  
2041 
if(s>pict_type == FF_S_TYPE && (s>vol_sprite_usage==STATIC_SPRITE  s>vol_sprite_usage==GMC_SPRITE)){


2041 
if(s>pict_type == AV_PICTURE_TYPE_S && (s>vol_sprite_usage==STATIC_SPRITE  s>vol_sprite_usage==GMC_SPRITE)){


2042  2042 
mpeg4_decode_sprite_trajectory(s, gb); 
2043  2043 
if(s>sprite_brightness_change) av_log(s>avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n"); 
2044  2044 
if(s>vol_sprite_usage==STATIC_SPRITE) av_log(s>avctx, AV_LOG_ERROR, "static sprite not supported\n"); 
...  ...  
2051  2051 
return 1; // makes no sense to continue, as there is nothing left from the image then 
2052  2052 
} 
2053  2053  
2054 
if (s>pict_type != FF_I_TYPE) {


2054 
if (s>pict_type != AV_PICTURE_TYPE_I) {


2055  2055 
s>f_code = get_bits(gb, 3); /* fcode_for */ 
2056  2056 
if(s>f_code==0){ 
2057  2057 
av_log(s>avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (f_code=0)\n"); 
...  ...  
2060  2060 
}else 
2061  2061 
s>f_code=1; 
2062  2062  
2063 
if (s>pict_type == FF_B_TYPE) {


2063 
if (s>pict_type == AV_PICTURE_TYPE_B) {


2064  2064 
s>b_code = get_bits(gb, 3); 
2065  2065 
}else 
2066  2066 
s>b_code=1; 
...  ...  
2068  2068 
if(s>avctx>debug&FF_DEBUG_PICT_INFO){ 
2069  2069 
av_log(s>avctx, AV_LOG_DEBUG, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d\n", 
2070  2070 
s>qscale, s>f_code, s>b_code, 
2071 
s>pict_type == FF_I_TYPE ? "I" : (s>pict_type == FF_P_TYPE ? "P" : (s>pict_type == FF_B_TYPE ? "B" : "S")),


2071 
s>pict_type == AV_PICTURE_TYPE_I ? "I" : (s>pict_type == AV_PICTURE_TYPE_P ? "P" : (s>pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),


2072  2072 
gb>size_in_bits,s>progressive_sequence, s>alternate_scan, s>top_field_first, 
2073  2073 
s>quarter_sample ? "q" : "h", s>data_partitioning, s>resync_marker, s>num_sprite_warping_points, 
2074  2074 
s>sprite_warping_accuracy, 1s>no_rounding, s>vo_type, s>vol_control_parameters ? " VOLC" : " ", s>intra_dc_threshold, s>cplx_estimation_trash_i, s>cplx_estimation_trash_p, s>cplx_estimation_trash_b); 
2075  2075 
} 
2076  2076  
2077  2077 
if(!s>scalability){ 
2078 
if (s>shape!=RECT_SHAPE && s>pict_type!=FF_I_TYPE) {


2078 
if (s>shape!=RECT_SHAPE && s>pict_type!=AV_PICTURE_TYPE_I) {


2079  2079 
skip_bits1(gb); // vop shape coding type 
2080  2080 
} 
2081  2081 
}else{ 
Also available in: Unified diff