In that patch:

- avctx and gb elements were removed from VC9Context, hence a larger diff
- some code was added to h263dec.c regarding CODEC_ID_WMV3 (should apply to CODEC_ID_VC9 too)
- VLC tables and other related tables were made global whenever this seemed necessary; appropriate changes were therefore made to other parts of the code using those tables
- the change for the bitplane management to a struct (some of them should eventually be mapped to MpegEncContext arrays) wasn't associated with the proper frees; should be fixed now
patch by anonymous

better names for globalized tables by me

Originally committed as revision 3905 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
anonymous 20 years ago committed by Michael Niedermayer
parent 093c6e50c9
commit 0d33db8a4d
  1. 5
      libavcodec/h263dec.c
  2. 37
      libavcodec/msmpeg4.c
  3. 2
      libavcodec/msmpeg4data.h
  4. 737
      libavcodec/vc9.c
  5. 19
      libavcodec/vc9data.h
  6. 4
      libavcodec/wmv2.c

@ -85,6 +85,11 @@ int ff_h263_decode_init(AVCodecContext *avctx)
s->h263_pred = 1; s->h263_pred = 1;
s->msmpeg4_version=5; s->msmpeg4_version=5;
break; break;
case CODEC_ID_WMV3:
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->msmpeg4_version=6;
break;
case CODEC_ID_H263I: case CODEC_ID_H263I:
break; break;
case CODEC_ID_FLV1: case CODEC_ID_FLV1:

@ -75,6 +75,8 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
/* vc9 externs */
extern uint8_t wmv3_dc_scale_table[32];
#ifdef DEBUG #ifdef DEBUG
int intra_count = 0; int intra_count = 0;
@ -175,6 +177,11 @@ static void common_init(MpegEncContext * s)
s->y_dc_scale_table= wmv1_y_dc_scale_table; s->y_dc_scale_table= wmv1_y_dc_scale_table;
s->c_dc_scale_table= wmv1_c_dc_scale_table; s->c_dc_scale_table= wmv1_c_dc_scale_table;
break; break;
case 6:
s->y_dc_scale_table= wmv3_dc_scale_table;
s->c_dc_scale_table= wmv3_dc_scale_table;
break;
} }
@ -629,7 +636,7 @@ void msmpeg4_encode_mb(MpegEncContext * s,
if (s->pict_type == I_TYPE) { if (s->pict_type == I_TYPE) {
set_stat(ST_INTRA_MB); set_stat(ST_INTRA_MB);
put_bits(&s->pb, put_bits(&s->pb,
table_mb_intra[coded_cbp][1], table_mb_intra[coded_cbp][0]); ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
} else { } else {
if (s->use_skip_mb_code) if (s->use_skip_mb_code)
put_bits(&s->pb, 1, 0); /* mb coded */ put_bits(&s->pb, 1, 0); /* mb coded */
@ -1030,9 +1037,9 @@ else
/* decoding stuff */ /* decoding stuff */
static VLC mb_non_intra_vlc[4]; static VLC mb_non_intra_vlc[4];
static VLC mb_intra_vlc; VLC ff_msmp4_mb_i_vlc;
static VLC dc_lum_vlc[2]; VLC ff_msmp4_dc_luma_vlc[2];
static VLC dc_chroma_vlc[2]; VLC ff_msmp4_dc_chroma_vlc[2];
static VLC v2_dc_lum_vlc; static VLC v2_dc_lum_vlc;
static VLC v2_dc_chroma_vlc; static VLC v2_dc_chroma_vlc;
static VLC cbpy_vlc; static VLC cbpy_vlc;
@ -1121,16 +1128,16 @@ int ff_msmpeg4_decode_init(MpegEncContext *s)
mv->table_mv_code, 2, 2, 1); mv->table_mv_code, 2, 2, 1);
} }
init_vlc(&dc_lum_vlc[0], DC_VLC_BITS, 120, init_vlc(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
&ff_table0_dc_lum[0][1], 8, 4, &ff_table0_dc_lum[0][1], 8, 4,
&ff_table0_dc_lum[0][0], 8, 4, 1); &ff_table0_dc_lum[0][0], 8, 4, 1);
init_vlc(&dc_chroma_vlc[0], DC_VLC_BITS, 120, init_vlc(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
&ff_table0_dc_chroma[0][1], 8, 4, &ff_table0_dc_chroma[0][1], 8, 4,
&ff_table0_dc_chroma[0][0], 8, 4, 1); &ff_table0_dc_chroma[0][0], 8, 4, 1);
init_vlc(&dc_lum_vlc[1], DC_VLC_BITS, 120, init_vlc(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
&ff_table1_dc_lum[0][1], 8, 4, &ff_table1_dc_lum[0][1], 8, 4,
&ff_table1_dc_lum[0][0], 8, 4, 1); &ff_table1_dc_lum[0][0], 8, 4, 1);
init_vlc(&dc_chroma_vlc[1], DC_VLC_BITS, 120, init_vlc(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
&ff_table1_dc_chroma[0][1], 8, 4, &ff_table1_dc_chroma[0][1], 8, 4,
&ff_table1_dc_chroma[0][0], 8, 4, 1); &ff_table1_dc_chroma[0][0], 8, 4, 1);
@ -1160,9 +1167,9 @@ int ff_msmpeg4_decode_init(MpegEncContext *s)
&wmv2_inter_table[i][0][0], 8, 4, 1); //FIXME name? &wmv2_inter_table[i][0][0], 8, 4, 1); //FIXME name?
} }
init_vlc(&mb_intra_vlc, MB_INTRA_VLC_BITS, 64, init_vlc(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
&table_mb_intra[0][1], 4, 2, &ff_msmp4_mb_i_table[0][1], 4, 2,
&table_mb_intra[0][0], 4, 2, 1); &ff_msmp4_mb_i_table[0][0], 4, 2, 1);
init_vlc(&v1_intra_cbpc_vlc, V1_INTRA_CBPC_VLC_BITS, 8, init_vlc(&v1_intra_cbpc_vlc, V1_INTRA_CBPC_VLC_BITS, 8,
intra_MCBPC_bits, 1, 1, intra_MCBPC_bits, 1, 1,
@ -1187,6 +1194,8 @@ int ff_msmpeg4_decode_init(MpegEncContext *s)
break; break;
case 5: case 5:
s->decode_mb= wmv2_decode_mb; s->decode_mb= wmv2_decode_mb;
case 6:
//FIXME + TODO VC9 decode mb
break; break;
} }
@ -1588,7 +1597,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
} else { } else {
set_stat(ST_INTRA_MB); set_stat(ST_INTRA_MB);
s->mb_intra = 1; s->mb_intra = 1;
code = get_vlc2(&s->gb, mb_intra_vlc.table, MB_INTRA_VLC_BITS, 2); code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
if (code < 0) if (code < 0)
return -1; return -1;
/* predict coded block pattern */ /* predict coded block pattern */
@ -1911,9 +1920,9 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
level-=256; level-=256;
}else{ //FIXME optimize use unified tables & index }else{ //FIXME optimize use unified tables & index
if (n < 4) { if (n < 4) {
level = get_vlc2(&s->gb, dc_lum_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); level = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else { } else {
level = get_vlc2(&s->gb, dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} }
if (level < 0){ if (level < 0){
av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n"); av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");

@ -4,7 +4,7 @@
*/ */
/* intra picture macro block coded block pattern */ /* intra picture macro block coded block pattern */
static const uint16_t table_mb_intra[64][2] = { const uint16_t ff_msmp4_mb_i_table[64][2] = {
{ 0x1, 1 },{ 0x17, 6 },{ 0x9, 5 },{ 0x5, 5 }, { 0x1, 1 },{ 0x17, 6 },{ 0x9, 5 },{ 0x5, 5 },
{ 0x6, 5 },{ 0x47, 9 },{ 0x20, 7 },{ 0x10, 7 }, { 0x6, 5 },{ 0x47, 9 },{ 0x20, 7 },{ 0x10, 7 },
{ 0x2, 5 },{ 0x7c, 9 },{ 0x3a, 7 },{ 0x1d, 7 }, { 0x2, 5 },{ 0x7c, 9 },{ 0x3a, 7 },{ 0x1d, 7 },

File diff suppressed because it is too large Load Diff

@ -167,23 +167,8 @@ static const uint8_t vc9_4mv_block_pattern_bits[4][16] = {
{ 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4} { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
}; };
/* I-Picture CBPCY VLC tables */ const uint8_t wmv3_dc_scale_table[32]={
//same as msmpeg4 table_mb_intra 0, 4, 6, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
static const uint16_t vc9_cbpcy_i_codes[64] = {
1, 23, 9, 5, 6, 71, 32, 16,
2, 124, 58, 29, 2, 236, 119, 0,
3, 183, 44, 19, 1, 360, 70, 63,
30, 1810, 181, 66, 34, 453, 286, 135,
6, 3, 30, 28, 18, 904, 68, 112,
31, 574, 57, 142, 1, 454, 182, 69,
20, 575, 125, 24, 7, 455, 134, 25,
21, 475, 2, 70, 13, 1811, 474, 361
};
static const uint8_t vc9_cbpcy_i_bits[64] = {
1, 6, 5, 5, 5, 9, 7, 7, 5, 9, 7, 7, 6, 9, 8, 8,
5, 9, 7, 7, 6, 10, 8, 8, 6, 13, 9, 8, 7, 11, 10, 9,
4, 9, 7, 6, 7, 12, 9, 9, 6, 11, 8, 9, 7, 11, 9, 9,
6, 11, 9, 9, 7, 11, 9, 9, 6, 10, 9, 9, 8, 13, 10, 10
}; };
/* P-Picture CBPCY VLC tables */ /* P-Picture CBPCY VLC tables */

@ -244,7 +244,7 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
if (s->pict_type == I_TYPE) { if (s->pict_type == I_TYPE) {
set_stat(ST_INTRA_MB); set_stat(ST_INTRA_MB);
put_bits(&s->pb, put_bits(&s->pb,
table_mb_intra[coded_cbp][1], table_mb_intra[coded_cbp][0]); ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
} else { } else {
put_bits(&s->pb, put_bits(&s->pb,
wmv2_inter_table[w->cbp_table_index][cbp][1], wmv2_inter_table[w->cbp_table_index][cbp][1],
@ -734,7 +734,7 @@ static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
cbp = code & 0x3f; cbp = code & 0x3f;
} else { } else {
s->mb_intra = 1; s->mb_intra = 1;
code = get_vlc2(&s->gb, mb_intra_vlc.table, MB_INTRA_VLC_BITS, 2); code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
if (code < 0){ if (code < 0){
av_log(s->avctx, AV_LOG_ERROR, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y); av_log(s->avctx, AV_LOG_ERROR, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
return -1; return -1;

Loading…
Cancel
Save