comparison mpeg12.c @ 1853:9de89f579086 libavcodec

add vlc for cbp=0 that is valid in 422,444
author iive
date Tue, 02 Mar 2004 18:39:25 +0000
parents 9ecbf5d23cdc
children ea2a4058441c
comparison
equal deleted inserted replaced
1852:9ecbf5d23cdc 1853:9de89f579086
594 s->last_mv[0][i][1]= 2*s->mv[0][i][1]; 594 s->last_mv[0][i][1]= 2*s->mv[0][i][1];
595 } 595 }
596 s->mv_bits+= get_bits_diff(s); 596 s->mv_bits+= get_bits_diff(s);
597 } 597 }
598 if(cbp) 598 if(cbp)
599 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); 599 put_bits(&s->pb, mbPatTable[cbp][1], mbPatTable[cbp][0]);
600 s->f_count++; 600 s->f_count++;
601 } else{ 601 } else{
602 static const int mb_type_len[4]={0,3,4,2}; //bak,for,bi 602 static const int mb_type_len[4]={0,3,4,2}; //bak,for,bi
603 603
604 if(s->mv_type == MV_TYPE_16X16){ 604 if(s->mv_type == MV_TYPE_16X16){
673 s->b_count++; 673 s->b_count++;
674 } 674 }
675 } 675 }
676 s->mv_bits += get_bits_diff(s); 676 s->mv_bits += get_bits_diff(s);
677 if(cbp) 677 if(cbp)
678 put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]); 678 put_bits(&s->pb, mbPatTable[cbp][1], mbPatTable[cbp][0]);
679 } 679 }
680 for(i=0;i<6;i++) { 680 for(i=0;i<6;i++) {
681 if (cbp & (1 << (5 - i))) { 681 if (cbp & (1 << (5 - i))) {
682 mpeg1_encode_block(s, block[i], i); 682 mpeg1_encode_block(s, block[i], i);
683 } 683 }
965 &mbMotionVectorTable[0][1], 2, 1, 965 &mbMotionVectorTable[0][1], 2, 1,
966 &mbMotionVectorTable[0][0], 2, 1); 966 &mbMotionVectorTable[0][0], 2, 1);
967 init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36, 967 init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36,
968 &mbAddrIncrTable[0][1], 2, 1, 968 &mbAddrIncrTable[0][1], 2, 1,
969 &mbAddrIncrTable[0][0], 2, 1); 969 &mbAddrIncrTable[0][0], 2, 1);
970 init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 63, 970 init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64,
971 &mbPatTable[0][1], 2, 1, 971 &mbPatTable[0][1], 2, 1,
972 &mbPatTable[0][0], 2, 1); 972 &mbPatTable[0][0], 2, 1);
973 973
974 init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, 974 init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
975 &table_mb_ptype[0][1], 2, 1, 975 &table_mb_ptype[0][1], 2, 1,
1304 1304
1305 s->mb_intra = 0; 1305 s->mb_intra = 0;
1306 1306
1307 if (HAS_CBP(mb_type)) { 1307 if (HAS_CBP(mb_type)) {
1308 cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1); 1308 cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
1309 if (cbp < 0){ 1309 if (cbp < 0 || (cbp == 0) && (s->chroma_format < 2) ){
1310 av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y); 1310 av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
1311 return -1; 1311 return -1;
1312 } 1312 }
1313 cbp++;
1314 if(s->chroma_format == 2){//CHROMA422 1313 if(s->chroma_format == 2){//CHROMA422
1315 cbp|= ( get_bits(&s->gb,2) ) << 6; 1314 cbp|= ( get_bits(&s->gb,2) ) << 6;
1316 }else 1315 }else
1317 if(s->chroma_format > 2){//CHROMA444 1316 if(s->chroma_format > 2){//CHROMA444
1318 cbp|= ( get_bits(&s->gb,6) ) << 6; 1317 cbp|= ( get_bits(&s->gb,6) ) << 6;