Commit ecc98c96 authored by Stéphane Borel's avatar Stéphane Borel

Rajout de la quantification ,�limination de plusieurs warning,
plus decodage des blocks non intra.
parent dd545857
...@@ -215,77 +215,8 @@ dct_lookup_t pl_DCT_tab0[60] = ...@@ -215,77 +215,8 @@ dct_lookup_t pl_DCT_tab0[60] =
/* Table B-15, DCT coefficients table one, /* Table B-15, DCT coefficients table one,
* codes 000001xx ... 11111111 * codes 000001xx ... 11111111
*/ */
#if 0
dct_lookup_t pl_DCT_tab0a[252] = dct_lookup_t pl_DCT_tab0a[252] =
{ {
{DCT_ESCAPE,0,6}, {DCT_ESCAPE,0,6}, {DCT_ESCAPE,0,6}, {DCT_ESCAPE,0,6},
/* Escape */
{7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
{6,1,7}, {6,1,7}, {2,2,7}, {2,2,7},
{0,7,6}, {0,7,6}, {0,7,6}, {0,7,6},
{0,6,6}, {0,6,6}, {0,6,6}, {0,6,6},
{4,1,6}, {4,1,6}, {4,1,6}, {4,1,6},
{5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
{1,5,8}, {11,1,8}, {0,11,8}, {0,10,8},
{13,1,8}, {12,1,8}, {3,2,8}, {1,4,8},
{2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
{2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
{1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
{1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
{3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
{3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
{DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4}, /* EOB */
{DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4},
{DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4},
{DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4}, {DCT_EOB,0,4},
{0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
{0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
{0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
{0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
{0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
{0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
{0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
{0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
{9,1,7}, {9,1,7}, {1,3,7}, {1,3,7},
{10,1,7}, {10,1,7}, {0,8,7}, {0,8,7},
{0,9,7}, {0,9,7}, {0,12,8}, {0,13,8},
{2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}
};
#endif
dct_lookup_t pl_DCT_tab0a[252] =
{
{65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */ {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
{7,1,7}, {7,1,7}, {8,1,7}, {8,1,7}, {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
{6,1,7}, {6,1,7}, {2,2,7}, {2,2,7}, {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7},
...@@ -349,7 +280,7 @@ dct_lookup_t pl_DCT_tab0a[252] = ...@@ -349,7 +280,7 @@ dct_lookup_t pl_DCT_tab0a[252] =
{10,1,7}, {10,1,7}, {0,8,7}, {0,8,7}, {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7},
{0,9,7}, {0,9,7}, {0,12,8}, {0,13,8}, {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8},
{2,3,8}, {4,2,8}, {0,14,8}, {0,15,8} {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}
}; };
...@@ -465,13 +396,13 @@ void __inline__ FillMbAddrIncTable( vpar_thread_t * p_vpar, ...@@ -465,13 +396,13 @@ void __inline__ FillMbAddrIncTable( vpar_thread_t * p_vpar,
int i_start, int i_end, int i_step, int i_start, int i_end, int i_step,
int * pi_value, int i_length ) int * pi_value, int i_length )
{ {
int i_dummy, i_dummy2; int i_pos, i_offset;
for( i_dummy = i_start ; i_dummy < i_end ; i_dummy += i_step ) for( i_pos = i_start ; i_pos < i_end ; i_pos += i_step )
{ {
for( i_dummy2 = 0 ; i_dummy2 < i_step ; i_dummy2 ++ ) for( i_offset = 0 ; i_offset < i_step ; i_offset ++ )
{ {
p_vpar->pl_mb_addr_inc[i_dummy + i_dummy2].i_value = * pi_value; p_vpar->pl_mb_addr_inc[i_pos + i_offset].i_value = * pi_value;
p_vpar->pl_mb_addr_inc[i_dummy + i_dummy2].i_length = i_length; p_vpar->pl_mb_addr_inc[i_pos + i_offset].i_length = i_length;
} }
(*pi_value)--; (*pi_value)--;
} }
...@@ -662,11 +593,11 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -662,11 +593,11 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
int i_mb, i_b, i_mask; int i_mb, i_b, i_mask;
macroblock_t * p_mb; macroblock_t * p_mb;
f_addb_t pf_addb; f_addb_t pf_addb;
elem_t * p_data1; yuv_data_t * p_data1;
elem_t * p_data2; yuv_data_t * p_data2;
/************* DEBUG *************/ /************* DEBUG *************/
static i_count = 0; static int i_count = 0;
int i_inc; int i_inc;
boolean_t b_stop = 0; boolean_t b_stop = 0;
...@@ -786,7 +717,7 @@ fprintf( stderr, "motion2 !\n" ); ...@@ -786,7 +717,7 @@ fprintf( stderr, "motion2 !\n" );
else else
{ {
int pi_coded_block_pattern[2] = {0, int pi_coded_block_pattern[2] = {0,
(1 << 4+p_vpar->sequence.i_chroma_nb_blocks) - 1}; (1 << (4+p_vpar->sequence.i_chroma_nb_blocks)) - 1};
p_vpar->mb.i_coded_block_pattern = pi_coded_block_pattern p_vpar->mb.i_coded_block_pattern = pi_coded_block_pattern
[p_vpar->mb.i_mb_type & MB_INTRA]; [p_vpar->mb.i_mb_type & MB_INTRA];
} }
...@@ -800,7 +731,7 @@ fprintf( stderr, "motion2 !\n" ); ...@@ -800,7 +731,7 @@ fprintf( stderr, "motion2 !\n" );
i_mask = 1 << (3 + p_vpar->sequence.i_chroma_nb_blocks); i_mask = 1 << (3 + p_vpar->sequence.i_chroma_nb_blocks);
/* luminance */ /* luminance */
p_data1 = (elem_t*) p_mb->p_picture->p_y; p_data1 = p_mb->p_picture->p_y
+ p_mb->i_l_x + p_mb->i_l_y*(p_vpar->sequence.i_width); + p_mb->i_l_x + p_mb->i_l_y*(p_vpar->sequence.i_width);
for( i_b = 0 ; i_b < 4 ; i_b++, i_mask >>= 1 ) for( i_b = 0 ; i_b < 4 ; i_b++, i_mask >>= 1 )
...@@ -857,11 +788,11 @@ fprintf( stderr, "motion2 !\n" ); ...@@ -857,11 +788,11 @@ fprintf( stderr, "motion2 !\n" );
} }
/* chrominance */ /* chrominance */
p_data1 = (elem_t*) p_mb->p_picture->p_u p_data1 = p_mb->p_picture->p_u
+ (p_mb->i_c_x >> pi_chroma_hor[p_vpar->sequence.i_chroma_format]) + (p_mb->i_c_x >> pi_chroma_hor[p_vpar->sequence.i_chroma_format])
+ (p_mb->i_c_y >> pi_chroma_ver[p_vpar->sequence.i_chroma_format]) + (p_mb->i_c_y >> pi_chroma_ver[p_vpar->sequence.i_chroma_format])
* (p_vpar->sequence.i_chroma_width); * (p_vpar->sequence.i_chroma_width);
p_data2 = (elem_t*) p_mb->p_picture->p_v p_data2 = p_mb->p_picture->p_v
+ (p_mb->i_c_x >> pi_chroma_hor[p_vpar->sequence.i_chroma_format]) + (p_mb->i_c_x >> pi_chroma_hor[p_vpar->sequence.i_chroma_format])
+ (p_mb->i_c_y >> pi_chroma_ver[p_vpar->sequence.i_chroma_format]) + (p_mb->i_c_y >> pi_chroma_ver[p_vpar->sequence.i_chroma_format])
* (p_vpar->sequence.i_chroma_width); * (p_vpar->sequence.i_chroma_width);
...@@ -869,7 +800,7 @@ fprintf( stderr, "motion2 !\n" ); ...@@ -869,7 +800,7 @@ fprintf( stderr, "motion2 !\n" );
for( i_b = 4; i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks; for( i_b = 4; i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks;
i_b++, i_mask >>= 1 ) i_b++, i_mask >>= 1 )
{ {
elem_t * pp_data[2] = {p_data1, p_data2}; yuv_data_t * pp_data[2] = {p_data1, p_data2};
if( p_vpar->mb.i_coded_block_pattern & i_mask ) if( p_vpar->mb.i_coded_block_pattern & i_mask )
{ {
...@@ -1224,55 +1155,73 @@ static void vpar_DecodeMPEG1Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1224,55 +1155,73 @@ static void vpar_DecodeMPEG1Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
*****************************************************************************/ *****************************************************************************/
static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b ) static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b )
{ {
#if 0 int i_parse;
int i_dummy;
int i_code;
int i_nc; int i_nc;
int i_cc;
int i_coef; int i_coef;
int i_type;
int i_code;
int i_length;
int i_pos;
int i_run; int i_run;
int i_level; int i_level;
boolean_t b_intra;
boolean_t b_sign; boolean_t b_sign;
int * ppi_quant[2];
/* Lookup Table for the chromatic component */
static int pi_cc_index[12] = { 0, 0, 0, 0, 1, 2, 1, 2, 1, 2 };
/* There is no special decodding for DC coefficient in non intra blocs i_cc = pi_cc_index[i_b];
* except that we won't use exactly the same table B.14 note 3 & 4 */
/* Decoding of the coefficients */ /* Determine whether it is luminance or not (chrominance) */
i_type = ( i_cc + 1 ) >> 1;
/* Give a pointer to the quantization matrices for intra blocks */
ppi_quant[0] = p_vpar->sequence.nonintra_quant.pi_matrix;
ppi_quant[1] = p_vpar->sequence.chroma_nonintra_quant.pi_matrix;
/* Decoding of the AC coefficients */
i_nc = 0; i_nc = 0;
i_coef = 0; i_coef = 0;
for( i_parse = 0; ; i_parse++ )
b_intra = p_vpar->picture.b_intra_vlc_format;
for( i_dummy = 0; i_dummy < 64; i_dummy++ )
{ {
i_code = ShowBits( &p_vpar->bit_stream, 16 ); i_code = ShowBits( &p_vpar->bit_stream, 16 );
i_run = (*p_vpar->pppl_dct_coef[b_intra][i_code]).i_run; if( i_code >= 16384 )
RemoveBits( &p_vpar->bit_stream, {
(*p_vpar->pppl_dct_coef[b_intra][i_code]).i_length ); if( i_parse == 0 )
{
i_run = pl_DCT_tab_dc[(i_code>>12)-4].i_run;
i_level = pl_DCT_tab_dc[(i_code>>12)-4].i_level;
i_length = pl_DCT_tab_dc[(i_code>>12)-4].i_length;
}
else
{
i_run = pl_DCT_tab_ac[(i_code>>12)-4].i_run;
i_level = pl_DCT_tab_ac[(i_code>>12)-4].i_level;
i_length = pl_DCT_tab_ac[(i_code>>12)-4].i_length;
}
}
else
{
i_run = ppl_dct_coef[0][i_code].i_run;
i_length = ppl_dct_coef[0][i_code].i_length;
i_level = ppl_dct_coef[0][i_code].i_level;
}
RemoveBits( &p_vpar->bit_stream, i_length );
switch( i_run ) switch( i_run )
{ {
case DCT_ESCAPE: case DCT_ESCAPE:
i_run = GetBits( &p_vpar->bit_stream, 6 ); i_run = GetBits( &p_vpar->bit_stream, 6 );
i_level = GetBits( &p_vpar->bit_stream, 12 ); i_level = GetBits( &p_vpar->bit_stream, 12 );
p_mb->ppi_blocks[i_b][i_dummy] = ( b_sign = ( i_level > 2047 ) ) i_level = (b_sign = ( i_level > 2047 )) ? 4096 - i_level
? ( -4096 + i_level )
: i_level; : i_level;
i_coef = i_dummy;
i_dummy += i_run;
i_nc ++;
break; break;
case DCT_EOB: case DCT_EOB:
i_dummy = 64; if( i_nc <= 1 )
break;
default:
i_level = (*p_vpar->pppl_dct_coef[b_intra][i_code]).i_level;
b_sign = GetBits( &p_vpar->bit_stream, 1 );
p_mb->ppi_blocks[i_b][i_dummy] = b_sign ? -i_level : i_level;
i_coef = i_dummy;
i_dummy += i_run;
i_nc ++;
}
}
if( i_nc == 1 )
{ {
p_mb->pf_idct[i_b] = vdec_SparseIDCT; p_mb->pf_idct[i_b] = vdec_SparseIDCT;
p_mb->pi_sparse_pos[i_b] = i_coef; p_mb->pi_sparse_pos[i_b] = i_coef;
...@@ -1281,7 +1230,25 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in ...@@ -1281,7 +1230,25 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in
{ {
p_mb->pf_idct[i_b] = vdec_IDCT; p_mb->pf_idct[i_b] = vdec_IDCT;
} }
#endif return;
break;
default:
b_sign = GetBits( &p_vpar->bit_stream, 1 );
}
i_coef = i_parse;
i_parse += i_run;
i_nc ++;
i_pos = pi_scan[p_vpar->picture.b_alternate_scan][i_parse];
i_level = ( i_level *
p_vpar->slice.i_quantizer_scale *
ppi_quant[i_type][i_pos] ) >> 5;
p_mb->ppi_blocks[i_b][i_parse] = b_sign ? -i_level : i_level;
}
fprintf( stderr, "MPEG2 end (%d)\n", i_b );
exit(0);
} }
/***************************************************************************** /*****************************************************************************
...@@ -1289,16 +1256,13 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in ...@@ -1289,16 +1256,13 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in
*****************************************************************************/ *****************************************************************************/
static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b ) static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b )
{ {
int i_dummy; int i_parse;
int i_nc; int i_nc;
int i_cc; int i_cc;
int i_coef; int i_coef;
int i_type; int i_type;
int i_code; int i_code;
int i_length; int i_length;
int i_code5;
int i_select;
int i_offset;
int i_pos; int i_pos;
int i_dct_dc_size; int i_dct_dc_size;
int i_dct_dc_diff; int i_dct_dc_diff;
...@@ -1306,14 +1270,21 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1306,14 +1270,21 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
int i_level; int i_level;
boolean_t b_vlc_intra; boolean_t b_vlc_intra;
boolean_t b_sign; boolean_t b_sign;
int * ppi_quant[2];
/* Lookup Table for the chromatic component */ /* Lookup Table for the chromatic component */
static int pi_cc_index[12] = { 0, 0, 0, 0, 1, 2, 1, 2, 1, 2 }; static int pi_cc_index[12] = { 0, 0, 0, 0, 1, 2, 1, 2, 1, 2 };
i_cc = pi_cc_index[i_b]; i_cc = pi_cc_index[i_b];
#if 0
/* Determine whether it is luminance or not (chrominance) */ /* Determine whether it is luminance or not (chrominance) */
i_type = ( i_cc + 1 ) >> 1; i_type = ( i_cc + 1 ) >> 1;
/* Give a pointer to the quantization matrices for intra blocks */
ppi_quant[0] = p_vpar->sequence.intra_quant.pi_matrix;
ppi_quant[1] = p_vpar->sequence.chroma_intra_quant.pi_matrix;
#if 0
/* Decoding of the DC intra coefficient */ /* Decoding of the DC intra coefficient */
/* The nb of bits to parse depends on i_type */ /* The nb of bits to parse depends on i_type */
i_code = ShowBits( &p_vpar->bit_stream, 9 + i_type ); i_code = ShowBits( &p_vpar->bit_stream, 9 + i_type );
...@@ -1329,68 +1300,51 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1329,68 +1300,51 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
i_pos = ( i_code5 * ( ! i_select ) ) + ( ( i_code - i_offset ) * i_select ); i_pos = ( i_code5 * ( ! i_select ) ) + ( ( i_code - i_offset ) * i_select );
i_dct_dc_size = p_vpar->pppl_dct_dc_size[i_type][i_select][i_pos].i_value; i_dct_dc_size = p_vpar->pppl_dct_dc_size[i_type][i_select][i_pos].i_value;
#endif #endif
if( i_b < 4 )
{
int code, size, length, dct_diff;
/* decode length */ if( !i_type/*i_b < 4*/ )
code = ShowBits(&p_vpar->bit_stream, 5);
if (code<31)
{ {
size = pl_dct_dc_lum_init_table_1[code].i_value; /* decode length */
length = pl_dct_dc_lum_init_table_1[code].i_length; i_code = ShowBits(&p_vpar->bit_stream, 5);
RemoveBits(&p_vpar->bit_stream, length); if (i_code<31)
}
else
{ {
code = ShowBits(&p_vpar->bit_stream, 9) - 0x1f0; i_dct_dc_size = pl_dct_dc_lum_init_table_1[i_code].i_value;
size = pl_dct_dc_lum_init_table_2[code].i_value; i_length = pl_dct_dc_lum_init_table_1[i_code].i_length;
length = pl_dct_dc_lum_init_table_2[code].i_length; RemoveBits( &p_vpar->bit_stream, i_length);
RemoveBits( &p_vpar->bit_stream, length);
} }
if (size==0)
dct_diff = 0;
else else
{ {
dct_diff = GetBits( &p_vpar->bit_stream, size); i_code = ShowBits(&p_vpar->bit_stream, 9) - 0x1f0;
if ((dct_diff & (1<<(size-1)))==0) i_dct_dc_size = pl_dct_dc_lum_init_table_2[i_code].i_value;
dct_diff-= (1<<size) - 1; i_length = pl_dct_dc_lum_init_table_2[i_code].i_length;
RemoveBits( &p_vpar->bit_stream, i_length);
} }
i_dct_dc_diff = dct_diff;
} }
else else
{ {
int code, size, length, dct_diff;
/* decode length */ /* decode length */
code = ShowBits(&p_vpar->bit_stream, 5); i_code = ShowBits(&p_vpar->bit_stream, 5);
if (code<31) if (i_code<31)
{ {
size = pl_dct_dc_chrom_init_table_1[code].i_value; i_dct_dc_size = pl_dct_dc_chrom_init_table_1[i_code].i_value;
length = pl_dct_dc_chrom_init_table_1[code].i_length; i_length = pl_dct_dc_chrom_init_table_1[i_code].i_length;
RemoveBits(&p_vpar->bit_stream, length); RemoveBits(&p_vpar->bit_stream, i_length);
} }
else else
{ {
code = ShowBits(&p_vpar->bit_stream, 10) - 0x3e0; i_code = ShowBits(&p_vpar->bit_stream, 10) - 0x3e0;
size = pl_dct_dc_chrom_init_table_2[code].i_value; i_dct_dc_size = pl_dct_dc_chrom_init_table_2[i_code].i_value;
length = pl_dct_dc_chrom_init_table_2[code].i_length; i_length = pl_dct_dc_chrom_init_table_2[i_code].i_length;
RemoveBits( &p_vpar->bit_stream, length); RemoveBits( &p_vpar->bit_stream, i_length);
} }
}
if (size==0) if (i_dct_dc_size==0)
dct_diff = 0; i_dct_dc_diff = 0;
else else
{ {
dct_diff = GetBits( &p_vpar->bit_stream, size); i_dct_dc_diff = GetBits( &p_vpar->bit_stream, i_dct_dc_size);
if ((dct_diff & (1<<(size-1)))==0) if ((i_dct_dc_diff & (1<<(i_dct_dc_size-1)))==0)
dct_diff-= (1<<size) - 1; i_dct_dc_diff-= (1<<i_dct_dc_size) - 1;
}
i_dct_dc_diff = dct_diff;
} }
/* Dump the variable length code */ /* Dump the variable length code */
...@@ -1409,7 +1363,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1409,7 +1363,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
i_coef = 0; i_coef = 0;
b_vlc_intra = p_vpar->picture.b_intra_vlc_format; b_vlc_intra = p_vpar->picture.b_intra_vlc_format;
for( i_dummy = 1; /*i_dummy < 64*/; i_dummy++ ) for( i_parse = 1; /*i_parse < 64*/; i_parse++ )
{ {
i_code = ShowBits( &p_vpar->bit_stream, 16 ); i_code = ShowBits( &p_vpar->bit_stream, 16 );
if( i_code >= 16384 ) if( i_code >= 16384 )
...@@ -1435,6 +1389,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1435,6 +1389,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
i_level = ppl_dct_coef[b_vlc_intra][i_code].i_level; i_level = ppl_dct_coef[b_vlc_intra][i_code].i_level;
} }
#if 0
{ {
int code = i_code; int code = i_code;
int intra_vlc_format = b_vlc_intra; int intra_vlc_format = b_vlc_intra;
...@@ -1477,7 +1432,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1477,7 +1432,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
exit(0); exit(0);
} }
} }
#endif
...@@ -1489,12 +1444,11 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1489,12 +1444,11 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
case DCT_ESCAPE: case DCT_ESCAPE:
i_run = GetBits( &p_vpar->bit_stream, 6 ); i_run = GetBits( &p_vpar->bit_stream, 6 );
i_level = GetBits( &p_vpar->bit_stream, 12 ); i_level = GetBits( &p_vpar->bit_stream, 12 );
p_mb->ppi_blocks[i_b][i_dummy] = ( b_sign = ( i_level > 2047 ) ) /*p_mb->ppi_blocks[i_b][i_parse] = ( b_sign = ( i_level > 2047 ) )
? ( -4096 + i_level ) ? ( -4096 + i_level )
: i_level;*/
i_level = (b_sign = ( i_level > 2047 )) ? 4096 - i_level
: i_level; : i_level;
i_coef = i_dummy;
i_dummy += i_run;
i_nc ++;
break; break;
case DCT_EOB: case DCT_EOB:
if( i_nc <= 1 ) if( i_nc <= 1 )
...@@ -1511,26 +1465,24 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1511,26 +1465,24 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
break; break;
default: default:
b_sign = GetBits( &p_vpar->bit_stream, 1 ); b_sign = GetBits( &p_vpar->bit_stream, 1 );
p_mb->ppi_blocks[i_b][i_dummy] = b_sign ? -i_level : i_level; //p_mb->ppi_blocks[i_b][i_parse] = b_sign ? -i_level : i_level;
i_coef = i_dummy;
i_dummy += i_run;
i_nc ++;
} }
// fprintf( stderr, "i_code : %d (%d), run : %d, %d, %d (%4x) ", i_code , b_vlc_intra, // fprintf( stderr, "i_code : %d (%d), run : %d, %d, %d (%4x) ", i_code , b_vlc_intra,
// i_run, i_level, i_dummy, ShowBits( &p_vpar->bit_stream, 16 ) ); // i_run, i_level, i_parse, ShowBits( &p_vpar->bit_stream, 16 ) );
//fprintf( stderr, "- %4x\n",ShowBits( &p_vpar->bit_stream, 16 ) ); //fprintf( stderr, "- %4x\n",ShowBits( &p_vpar->bit_stream, 16 ) );
}
if( i_nc <= 1 ) i_coef = i_parse;
{ i_parse += i_run;
p_mb->pf_idct[i_b] = vdec_SparseIDCT; i_nc ++;
p_mb->pi_sparse_pos[i_b] = i_coef;
} i_pos = pi_scan[p_vpar->picture.b_alternate_scan][i_parse];
else i_level = ( i_level *
{ p_vpar->slice.i_quantizer_scale *
p_mb->pf_idct[i_b] = vdec_IDCT; ppi_quant[i_type][i_pos] ) >> 4;
p_mb->ppi_blocks[i_b][i_parse] = b_sign ? -i_level : i_level;
} }
fprintf( stderr, "MPEG2 end (%d)\n", i_b ); fprintf( stderr, "MPEG2 end (%d)\n", i_b );
exit(0); exit(0);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment