Commit cf9e7c61 authored by Jean-Marc Dressler's avatar Jean-Marc Dressler

Le debuggage du parser avance ... lentement.
parent e95de90d
...@@ -68,11 +68,11 @@ typedef struct vpar_thread_s ...@@ -68,11 +68,11 @@ typedef struct vpar_thread_s
/* tables for macroblock types 0=P 1=B */ /* tables for macroblock types 0=P 1=B */
lookup_t ppl_mb_type[2][64]; lookup_t ppl_mb_type[2][64];
/* table for coded_block_pattern */ /* table for coded_block_pattern */
lookup_t pl_coded_pattern[512]; lookup_t * pl_coded_pattern;
/* variable length codes for the structure dct_dc_size for intra blocks */ /* variable length codes for the structure dct_dc_size for intra blocks */
lookup_t pppl_dct_dc_size[2][2][32]; lookup_t * pppl_dct_dc_size[2][2];
/* structure to store the tables B14 & B15 */ /* structure to store the tables B14 & B15 */
dct_lookup_t * pppl_dct_coef[2][65536]; dct_lookup_t * pppl_dct_coef[2][65536];
#ifdef STATS #ifdef STATS
/* Statistics */ /* Statistics */
......
...@@ -116,15 +116,15 @@ typedef struct slice_parsing_s ...@@ -116,15 +116,15 @@ typedef struct slice_parsing_s
/***************************************************************************** /*****************************************************************************
* Standard codes * Standard codes
*****************************************************************************/ *****************************************************************************/
#define PICTURE_START_CODE 0x100 #define PICTURE_START_CODE 0x100L
#define SLICE_START_CODE_MIN 0x101 #define SLICE_START_CODE_MIN 0x101L
#define SLICE_START_CODE_MAX 0x1AF #define SLICE_START_CODE_MAX 0x1AFL
#define USER_DATA_START_CODE 0x1B2 #define USER_DATA_START_CODE 0x1B2L
#define SEQUENCE_HEADER_CODE 0x1B3 #define SEQUENCE_HEADER_CODE 0x1B3L
#define SEQUENCE_ERROR_CODE 0x1B4 #define SEQUENCE_ERROR_CODE 0x1B4L
#define EXTENSION_START_CODE 0x1B5 #define EXTENSION_START_CODE 0x1B5L
#define SEQUENCE_END_CODE 0x1B7 #define SEQUENCE_END_CODE 0x1B7L
#define GROUP_START_CODE 0x1B8 #define GROUP_START_CODE 0x1B8L
/* extension start code IDs */ /* extension start code IDs */
#define SEQUENCE_EXTENSION_ID 1 #define SEQUENCE_EXTENSION_ID 1
......
...@@ -58,6 +58,9 @@ static void EndThread ( vpar_thread_t *p_vpar ); ...@@ -58,6 +58,9 @@ static void EndThread ( vpar_thread_t *p_vpar );
* Following configuration properties are used: * Following configuration properties are used:
* ?? * ??
*******************************************************************************/ *******************************************************************************/
#include "main.h"
#include "interface.h"
extern main_t* p_main;
vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*, vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*,
vout_thread_t *p_vout, int *pi_status */ ) vout_thread_t *p_vout, int *pi_status */ )
{ {
...@@ -93,6 +96,9 @@ vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i ...@@ -93,6 +96,9 @@ vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
p_vpar->bit_stream.fifo.buffer = 0; p_vpar->bit_stream.fifo.buffer = 0;
p_vpar->bit_stream.fifo.i_available = 0; p_vpar->bit_stream.fifo.i_available = 0;
/* FIXME !!!! */
p_vpar->p_vout = p_main->p_intf->p_vout;
/* Spawn the video parser thread */ /* Spawn the video parser thread */
if ( vlc_thread_create(&p_vpar->thread_id, "video parser", (vlc_thread_func_t)RunThread, (void *)p_vpar) ) if ( vlc_thread_create(&p_vpar->thread_id, "video parser", (vlc_thread_func_t)RunThread, (void *)p_vpar) )
{ {
......
...@@ -394,7 +394,7 @@ void __inline__ FillMbAddrIncTable( vpar_thread_t * p_vpar, ...@@ -394,7 +394,7 @@ void __inline__ FillMbAddrIncTable( vpar_thread_t * p_vpar,
p_vpar->pl_mb_addr_inc[i_dummy + i_dummy2].i_value = * pi_value; p_vpar->pl_mb_addr_inc[i_dummy + i_dummy2].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_dummy + i_dummy2].i_length = i_length;
} }
(*pi_value)--; (*pi_value)--;
} }
} }
...@@ -403,6 +403,7 @@ void InitMbAddrInc( vpar_thread_t * p_vpar ) ...@@ -403,6 +403,7 @@ void InitMbAddrInc( vpar_thread_t * p_vpar )
{ {
int i_dummy; int i_dummy;
int i_value; int i_value;
for( i_dummy = 0 ; i_dummy < 8 ; i_dummy++ ) for( i_dummy = 0 ; i_dummy < 8 ; i_dummy++ )
{ {
p_vpar->pl_mb_addr_inc[i_dummy].i_value = MB_ERROR; p_vpar->pl_mb_addr_inc[i_dummy].i_value = MB_ERROR;
...@@ -426,15 +427,17 @@ void InitMbAddrInc( vpar_thread_t * p_vpar ) ...@@ -426,15 +427,17 @@ void InitMbAddrInc( vpar_thread_t * p_vpar )
p_vpar->pl_mb_addr_inc[i_dummy].i_value = MB_ERROR; p_vpar->pl_mb_addr_inc[i_dummy].i_value = MB_ERROR;
p_vpar->pl_mb_addr_inc[i_dummy].i_length = 0; p_vpar->pl_mb_addr_inc[i_dummy].i_length = 0;
} }
i_value = 33; i_value = 33;
FillMbAddrIncTable( p_vpar, 1024, 2048, 1024, &i_value, 1 );
FillMbAddrIncTable( p_vpar, 512, 1024, 256, &i_value, 3 );
FillMbAddrIncTable( p_vpar, 256, 512, 128, &i_value, 4 );
FillMbAddrIncTable( p_vpar, 128, 256, 64, &i_value, 5 );
FillMbAddrIncTable( p_vpar, 96, 128, 16, &i_value, 7 );
FillMbAddrIncTable( p_vpar, 48, 96, 8, &i_value, 8 );
FillMbAddrIncTable( p_vpar, 36, 48, 2, &i_value, 10 );
FillMbAddrIncTable( p_vpar, 24, 36, 1, &i_value, 11 ); FillMbAddrIncTable( p_vpar, 24, 36, 1, &i_value, 11 );
FillMbAddrIncTable( p_vpar, 36, 48, 2, &i_value, 10 );
FillMbAddrIncTable( p_vpar, 48, 96, 8, &i_value, 8 );
FillMbAddrIncTable( p_vpar, 96, 128, 16, &i_value, 7 );
FillMbAddrIncTable( p_vpar, 128, 256, 64, &i_value, 5 );
FillMbAddrIncTable( p_vpar, 256, 512, 128, &i_value, 4 );
FillMbAddrIncTable( p_vpar, 512, 1024, 256, &i_value, 3 );
FillMbAddrIncTable( p_vpar, 1024, 2048, 1024, &i_value, 1 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -502,7 +505,7 @@ void InitBMBType( vpar_thread_t * p_vpar ) ...@@ -502,7 +505,7 @@ void InitBMBType( vpar_thread_t * p_vpar )
*****************************************************************************/ *****************************************************************************/
void InitCodedPattern( vpar_thread_t * p_vpar ) void InitCodedPattern( vpar_thread_t * p_vpar )
{ {
p_vpar->pl_coded_pattern = pl_coded_pattern_init_table; p_vpar->pl_coded_pattern = (lookup_t*) pl_coded_pattern_init_table;
} }
/***************************************************************************** /*****************************************************************************
...@@ -513,11 +516,12 @@ void InitCodedPattern( vpar_thread_t * p_vpar ) ...@@ -513,11 +516,12 @@ void InitCodedPattern( vpar_thread_t * p_vpar )
/* First fonction for filling the table */ /* First fonction for filling the table */
static void __inline__ FillDCTTable( vpar_thread_t * p_vpar, static void __inline__ FillDCTTable( vpar_thread_t * p_vpar,
dct_lookup_t * pl_DCT_tab, dct_lookup_t * pl_DCT_tab,
int i_intra, int i_dec, int i_off ) int i_size, int i_intra, int i_dec, int i_off )
{ {
int i_dummy, i_dummy2; int i_dummy, i_dummy2;
int i_end; int i_end;
i_end = sizeof(pl_DCT_tab) / sizeof(dct_lookup_t);
i_end = i_size / sizeof(dct_lookup_t);
for( i_dummy = 0; i_dummy < i_end; i_dummy++ ) for( i_dummy = 0; i_dummy < i_end; i_dummy++ )
{ {
for( i_dummy2 = 0; i_dummy2 < ( 1 << i_dec ); i_dummy2++ ) for( i_dummy2 = 0; i_dummy2 < ( 1 << i_dec ); i_dummy2++ )
...@@ -543,25 +547,24 @@ void InitDCTTables( vpar_thread_t * p_vpar ) ...@@ -543,25 +547,24 @@ void InitDCTTables( vpar_thread_t * p_vpar )
/* For table B14 & B15, we have a pointer to tables */ /* For table B14 & B15, we have a pointer to tables */
/* We fill the table thanks to the fonction defined above */ /* We fill the table thanks to the fonction defined above */
FillDCTTable( p_vpar, pl_DCT_tab_dc, 0, 12, 4 ); FillDCTTable( p_vpar, pl_DCT_tab_dc, sizeof(pl_DCT_tab_dc),0, 12, 4 );
FillDCTTable( p_vpar, pl_DCT_tab_ac, 0, 12, 4 ); FillDCTTable( p_vpar, pl_DCT_tab_ac, sizeof(pl_DCT_tab_ac), 0, 12, 4 );
FillDCTTable( p_vpar, pl_DCT_tab0, 0, 8, 4 ); FillDCTTable( p_vpar, pl_DCT_tab0, sizeof(pl_DCT_tab0), 0, 8, 4 );
FillDCTTable( p_vpar, pl_DCT_tab1, 0, 6, 8 ); FillDCTTable( p_vpar, pl_DCT_tab1, sizeof(pl_DCT_tab1), 0, 6, 8 );
FillDCTTable( p_vpar, pl_DCT_tab2, 0, 4, 16 ); FillDCTTable( p_vpar, pl_DCT_tab2, sizeof(pl_DCT_tab2), 0, 4, 16 );
FillDCTTable( p_vpar, pl_DCT_tab3, 0, 3, 16 ); FillDCTTable( p_vpar, pl_DCT_tab3, sizeof(pl_DCT_tab3), 0, 3, 16 );
FillDCTTable( p_vpar, pl_DCT_tab4, 0, 2, 16 ); FillDCTTable( p_vpar, pl_DCT_tab4, sizeof(pl_DCT_tab4), 0, 2, 16 );
FillDCTTable( p_vpar, pl_DCT_tab5, 0, 1, 16 ); FillDCTTable( p_vpar, pl_DCT_tab5, sizeof(pl_DCT_tab5), 0, 1, 16 );
FillDCTTable( p_vpar, pl_DCT_tab6, 0, 0, 16 ); FillDCTTable( p_vpar, pl_DCT_tab6, sizeof(pl_DCT_tab6), 0, 0, 16 );
FillDCTTable( p_vpar, pl_DCT_tab_dc, 1, 12, 4 ); FillDCTTable( p_vpar, pl_DCT_tab_dc, sizeof(pl_DCT_tab_dc), 1, 12, 4 );
FillDCTTable( p_vpar, pl_DCT_tab_ac, 1, 12, 4 ); FillDCTTable( p_vpar, pl_DCT_tab_ac, sizeof(pl_DCT_tab_ac), 1, 12, 4 );
FillDCTTable( p_vpar, pl_DCT_tab0a, 1, 8, 4 ); FillDCTTable( p_vpar, pl_DCT_tab0a, sizeof(pl_DCT_tab0a), 1, 8, 4 );
FillDCTTable( p_vpar, pl_DCT_tab1a, 1, 6, 8); FillDCTTable( p_vpar, pl_DCT_tab1a, sizeof(pl_DCT_tab1a), 1, 6, 8);
FillDCTTable( p_vpar, pl_DCT_tab2, 1, 4, 16 ); FillDCTTable( p_vpar, pl_DCT_tab2, sizeof(pl_DCT_tab2), 1, 4, 16 );
FillDCTTable( p_vpar, pl_DCT_tab3, 1, 3, 16 ); FillDCTTable( p_vpar, pl_DCT_tab3, sizeof(pl_DCT_tab3), 1, 3, 16 );
FillDCTTable( p_vpar, pl_DCT_tab4, 1, 2, 16 ); FillDCTTable( p_vpar, pl_DCT_tab4, sizeof(pl_DCT_tab4), 1, 2, 16 );
FillDCTTable( p_vpar, pl_DCT_tab5, 1, 1, 16 ); FillDCTTable( p_vpar, pl_DCT_tab5, sizeof(pl_DCT_tab5), 1, 1, 16 );
FillDCTTable( p_vpar, pl_DCT_tab6, 1, 0, 16 ); FillDCTTable( p_vpar, pl_DCT_tab6, sizeof(pl_DCT_tab6), 1, 0, 16 );
} }
/* /*
...@@ -590,8 +593,22 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -590,8 +593,22 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
elem_t * p_data1; elem_t * p_data1;
elem_t * p_data2; elem_t * p_data2;
*pi_mb_address += MacroblockAddressIncrement( p_vpar ); /************* DEBUG *************/
static i_count = 0;
int i_inc;
i_inc = MacroblockAddressIncrement( p_vpar );
*pi_mb_address += i_inc;
//*pi_mb_address += MacroblockAddressIncrement( p_vpar );
fprintf( stderr, "inc : %d (%d)\n", *pi_mb_address, i_inc );
/*
if( i_count > 4 )
{
while(1);
}
i_count++;
*/
for( i_mb = i_mb_previous; i_mb < *pi_mb_address; i_mb++ ) for( i_mb = i_mb_previous; i_mb < *pi_mb_address; i_mb++ )
{ {
/* Skipped macroblock (ISO/IEC 13818-2 7.6.6). */ /* Skipped macroblock (ISO/IEC 13818-2 7.6.6). */
...@@ -633,11 +650,8 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -633,11 +650,8 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
/* Set the field we use for motion compensation */ /* Set the field we use for motion compensation */
p_mb->ppi_field_select[0][0] = p_mb->ppi_field_select[0][1] p_mb->ppi_field_select[0][0] = p_mb->ppi_field_select[0][1]
= ( p_vpar->picture.i_current_structure == BOTTOM_FIELD ); = ( p_vpar->picture.i_current_structure == BOTTOM_FIELD );
/* Predict from field of same parity. */
/* ??? */
} }
fprintf(stderr, "MB1\n");
/* Get a macroblock structure. */ /* Get a macroblock structure. */
if( (p_mb = p_vpar->picture.pp_mb[i_mb_base + *pi_mb_address] = if( (p_mb = p_vpar->picture.pp_mb[i_mb_base + *pi_mb_address] =
vpar_NewMacroblock( &p_vpar->vfifo )) == NULL ) vpar_NewMacroblock( &p_vpar->vfifo )) == NULL )
...@@ -659,11 +673,13 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -659,11 +673,13 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
if( p_vpar->mb.i_mb_type & MB_MOTION_FORWARD ) if( p_vpar->mb.i_mb_type & MB_MOTION_FORWARD )
{ {
fprintf( stderr, "motion !\n" );
(*p_vpar->sequence.pf_decode_mv)( p_vpar, p_mb, 0 ); (*p_vpar->sequence.pf_decode_mv)( p_vpar, p_mb, 0 );
} }
if( p_vpar->mb.i_mb_type & MB_MOTION_BACKWARD ) if( p_vpar->mb.i_mb_type & MB_MOTION_BACKWARD )
{ {
fprintf( stderr, "motion2 !\n" );
(*p_vpar->sequence.pf_decode_mv)( p_vpar, p_mb, 1 ); (*p_vpar->sequence.pf_decode_mv)( p_vpar, p_mb, 1 );
} }
...@@ -689,7 +705,7 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -689,7 +705,7 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
/* /*
* Effectively decode blocks. * Effectively decode blocks.
*/ */
fprintf(stderr, "MB2\n");
i_mask = 1 << (3 + 2*p_vpar->sequence.i_chroma_nb_blocks); i_mask = 1 << (3 + 2*p_vpar->sequence.i_chroma_nb_blocks);
/* luminance */ /* luminance */
...@@ -730,14 +746,15 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -730,14 +746,15 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
+ (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);
for( i_b = 4; i_b < 4 + 2*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}; elem_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 )
{ {
fprintf( stderr, "Merde !!!!\n" );
memset( p_mb->ppi_blocks[i_b], 0, 64*sizeof(elem_t) ); memset( p_mb->ppi_blocks[i_b], 0, 64*sizeof(elem_t) );
(*pppf_decode_block[p_vpar->sequence.b_mpeg2] (*pppf_decode_block[p_vpar->sequence.b_mpeg2]
[p_vpar->mb.i_mb_type & MB_INTRA]) [p_vpar->mb.i_mb_type & MB_INTRA])
...@@ -819,11 +836,10 @@ static __inline__ void InitMacroblock( vpar_thread_t * p_vpar, ...@@ -819,11 +836,10 @@ static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
*****************************************************************************/ *****************************************************************************/
static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar ) static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar )
{ {
int i_addr_inc = 0;
/* Index in the lookup table mb_addr_inc */ /* Index in the lookup table mb_addr_inc */
int i_index = ShowBits( &p_vpar->bit_stream, 11 ); int i_index = ShowBits( &p_vpar->bit_stream, 11 );
int i_addr_inc = 0;
/* Test the presence of the escape character */ /* Test the presence of the escape character */
while( i_index == 8 ) while( i_index == 8 )
{ {
...@@ -856,11 +872,32 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar, ...@@ -856,11 +872,32 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
/* Get macroblock_type. */ /* Get macroblock_type. */
p_vpar->mb.i_mb_type = (p_vpar->picture.pf_macroblock_type)( p_vpar ); p_vpar->mb.i_mb_type = (p_vpar->picture.pf_macroblock_type)( p_vpar );
p_mb->i_mb_type = p_vpar->mb.i_mb_type; p_mb->i_mb_type = p_vpar->mb.i_mb_type;
fprintf( stderr, "MB type : %d\n", p_mb->i_mb_type );
/* SCALABILITY : warning, we don't know if spatial_temporal_weight_code /* SCALABILITY : warning, we don't know if spatial_temporal_weight_code
* has to be dropped, take care if you use scalable streams. */ * has to be dropped, take care if you use scalable streams. */
/* DumpBits( &p_vpar->bit_stream, 2 ); */ /* DumpBits( &p_vpar->bit_stream, 2 ); */
if( !(p_vpar->mb.i_mb_type & (MB_MOTION_FORWARD | MB_MOTION_BACKWARD)) )
{
/* If mb_type has neither MOTION_FORWARD nor MOTION_BACKWARD, this
* is useless, but also harmless. */
p_vpar->mb.i_motion_type = MOTION_FRAME;
}
else
{
if( p_vpar->picture.i_structure == FRAME_STRUCTURE
&& p_vpar->picture.b_frame_pred_frame_dct )
{
p_vpar->mb.i_motion_type = MOTION_FRAME;
}
else
{
p_vpar->mb.i_motion_type = GetBits( &p_vpar->bit_stream, 2 );
}
}
if( p_mb->b_P_coding_type && !(p_vpar->mb.i_mb_type & (MB_MOTION_FORWARD|MB_INTRA)) ) if( p_mb->b_P_coding_type && !(p_vpar->mb.i_mb_type & (MB_MOTION_FORWARD|MB_INTRA)) )
{ {
/* Special No-MC macroblock in P pictures (7.6.3.5). */ /* Special No-MC macroblock in P pictures (7.6.3.5). */
...@@ -870,17 +907,6 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar, ...@@ -870,17 +907,6 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
p_vpar->mb.i_motion_type = MOTION_FRAME; p_vpar->mb.i_motion_type = MOTION_FRAME;
p_mb->ppi_field_select[0][0] = ( p_vpar->picture.i_current_structure == BOTTOM_FIELD ); p_mb->ppi_field_select[0][0] = ( p_vpar->picture.i_current_structure == BOTTOM_FIELD );
} }
else if( !(p_vpar->mb.i_mb_type & (MB_MOTION_FORWARD | MB_MOTION_BACKWARD))
|| p_vpar->picture.b_frame_pred_frame_dct )
{
/* If mb_type has neither MOTION_FORWARD nor MOTION_BACKWARD, this
* is useless, but also harmless. */
p_vpar->mb.i_motion_type = MOTION_FRAME;
}
else
{
p_vpar->mb.i_motion_type = GetBits( &p_vpar->bit_stream, 2 );
}
if( p_vpar->mb.i_mb_type & MB_INTRA ) if( p_vpar->mb.i_mb_type & MB_INTRA )
{ {
...@@ -903,17 +929,17 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar, ...@@ -903,17 +929,17 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
(!p_vpar->picture.b_frame_pred_frame_dct) && (!p_vpar->picture.b_frame_pred_frame_dct) &&
(p_vpar->mb.i_mb_type & (MB_PATTERN|MB_INTRA)) ) (p_vpar->mb.i_mb_type & (MB_PATTERN|MB_INTRA)) )
{ {
if( p_vpar->mb.b_dct_type = GetBits( &p_vpar->bit_stream, 1 ) ) if( (p_vpar->mb.b_dct_type = GetBits( &p_vpar->bit_stream, 1 )) )
{ {
/* The DCT is coded on fields. Jump one line between each /* The DCT is coded on fields. Jump one line between each
* sample. */ * sample. */
p_mb->i_addb_l_stride <<= 1; p_mb->i_addb_l_stride <<= 1;
p_mb->i_addb_l_stride += 8; p_mb->i_addb_l_stride += 8;
/* With CHROMA_420, the DCT is necessarily frame-coded. */ /* With CHROMA_420, the DCT is necessarily frame-coded. */
if( p_vpar->sequence.i_chroma_format != CHROMA_420 ) if( p_vpar->sequence.i_chroma_format != CHROMA_420 )
{ {
p_mb->i_addb_c_stride <<= 1; p_mb->i_addb_c_stride <<= 1;
p_mb->i_addb_c_stride += 8; p_mb->i_addb_c_stride += 8;
} }
} }
} }
...@@ -934,7 +960,7 @@ int vpar_IMBType( vpar_thread_t * p_vpar ) ...@@ -934,7 +960,7 @@ int vpar_IMBType( vpar_thread_t * p_vpar )
{MB_QUANT|MB_INTRA, 2}, {MB_QUANT|MB_INTRA, 2},
{MB_INTRA, 1}, {MB_INTRA, 1},
{MB_INTRA, 1} }; {MB_INTRA, 1} };
fprintf( stderr, "i_type : %d\n", i_type );
/* Dump the good number of bits */ /* Dump the good number of bits */
DumpBits( &p_vpar->bit_stream, pl_mb_Itype[i_type].i_length ); DumpBits( &p_vpar->bit_stream, pl_mb_Itype[i_type].i_length );
return pl_mb_Itype[i_type].i_value; return pl_mb_Itype[i_type].i_value;
...@@ -1152,12 +1178,14 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1152,12 +1178,14 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
/* 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 };
fprintf( stderr, "%x\n", ShowBits( &p_vpar->bit_stream, 32 ) );
i_cc = pi_cc_index[i_b]; i_cc = pi_cc_index[i_b];
/* 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;
//fprintf( stderr, "MPEG2\n" );
/* 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 );
...@@ -1167,7 +1195,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1167,7 +1195,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
i_code5 = i_code >> 4; i_code5 = i_code >> 4;
/* Shall we lookup in the first or in the second table ? */ /* Shall we lookup in the first or in the second table ? */
i_select = ( i_code5 - 1 ) / 31; i_select = ( i_code5 == 31 );
/* Offset value for looking in the second table */ /* Offset value for looking in the second table */
i_offset = 0x1f0 + ( i_type * 0x1f0 ); i_offset = 0x1f0 + ( i_type * 0x1f0 );
i_pos = ( i_code5 * ( ! i_select ) ) + ( ( i_code - i_offset ) * i_select ); i_pos = ( i_code5 * ( ! i_select ) ) + ( ( i_code - i_offset ) * i_select );
...@@ -1190,7 +1218,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1190,7 +1218,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
( 11 - p_vpar->picture.i_intra_dc_precision ) ); ( 11 - p_vpar->picture.i_intra_dc_precision ) );
i_nc = ( p_vpar->slice.pi_dc_dct_pred[i_cc] != 0 ); i_nc = ( p_vpar->slice.pi_dc_dct_pred[i_cc] != 0 );
#endif #endif
//fprintf( stderr, "coucou\n" );
/* Decoding of the AC coefficients */ /* Decoding of the AC coefficients */
i_coef = 0; i_coef = 0;
...@@ -1198,9 +1226,11 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1198,9 +1226,11 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
for( i_dummy = 1; i_dummy < 64; i_dummy++ ) for( i_dummy = 1; i_dummy < 64; i_dummy++ )
{ {
i_code = ShowBits( &p_vpar->bit_stream, 16 ); i_code = ShowBits( &p_vpar->bit_stream, 16 );
fprintf( stderr, "b_intra : %d\ni_code : %d\n", b_intra, i_code );
i_run = (*p_vpar->pppl_dct_coef[b_intra][i_code]).i_run; i_run = (*p_vpar->pppl_dct_coef[b_intra][i_code]).i_run;
DumpBits( &p_vpar->bit_stream, DumpBits( &p_vpar->bit_stream,
(*p_vpar->pppl_dct_coef[b_intra][i_code]).i_length ); (*p_vpar->pppl_dct_coef[b_intra][i_code]).i_length );
//fprintf( stderr, "glop\n" );
switch( i_run ) switch( i_run )
{ {
case DCT_ESCAPE: case DCT_ESCAPE:
...@@ -1234,4 +1264,5 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, ...@@ -1234,4 +1264,5 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
{ {
p_mb->pf_idct[i_b] = vdec_IDCT; p_mb->pf_idct[i_b] = vdec_IDCT;
} }
//fprintf( stderr, "MPEG2 end\n" );
} }
...@@ -164,11 +164,10 @@ static __inline__ void NextStartCode( vpar_thread_t * p_vpar ) ...@@ -164,11 +164,10 @@ static __inline__ void NextStartCode( vpar_thread_t * p_vpar )
/* Re-align the buffer on an 8-bit boundary */ /* Re-align the buffer on an 8-bit boundary */
RealignBits( &p_vpar->bit_stream ); RealignBits( &p_vpar->bit_stream );
while( ShowBits( &p_vpar->bit_stream, 16 ) != 0 && !p_vpar->b_die ) while( ShowBits( &p_vpar->bit_stream, 24 ) != 0x01L && !p_vpar->b_die )
{ {
DumpBits( &p_vpar->bit_stream, 8 ); DumpBits( &p_vpar->bit_stream, 8 );
} }
DumpBits( &p_vpar->bit_stream, 16 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -263,8 +262,9 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar ) ...@@ -263,8 +262,9 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar )
while( !p_vpar->b_die ) while( !p_vpar->b_die )
{ {
NextStartCode( p_vpar ); NextStartCode( p_vpar );
if( ShowBits( &p_vpar->bit_stream, 16 ) == SEQUENCE_HEADER_CODE ) if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_HEADER_CODE )
return 0; return 0;
DumpBits( &p_vpar->bit_stream, 8 );
} }
return 1; return 1;
} }
...@@ -294,9 +294,7 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar ) ...@@ -294,9 +294,7 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar )
break; break;
case PICTURE_START_CODE: case PICTURE_START_CODE:
fprintf( stderr, "begin picture\n" );
PictureHeader( p_vpar ); PictureHeader( p_vpar );
fprintf( stderr, "end picture\n" );
return 0; return 0;
break; break;
...@@ -513,8 +511,8 @@ static void GroupHeader( vpar_thread_t * p_vpar ) ...@@ -513,8 +511,8 @@ static void GroupHeader( vpar_thread_t * p_vpar )
*****************************************************************************/ *****************************************************************************/
static void PictureHeader( vpar_thread_t * p_vpar ) static void PictureHeader( vpar_thread_t * p_vpar )
{ {
static f_macroblock_type_t ppf_macroblock_type[4] = static f_macroblock_type_t ppf_macroblock_type[5] = {NULL,
{vpar_IMBType, vpar_PMBType, vpar_IMBType, vpar_PMBType,
vpar_BMBType, vpar_DMBType}; vpar_BMBType, vpar_DMBType};
int i_structure; int i_structure;
...@@ -544,7 +542,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -544,7 +542,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
/* /*
* Picture Coding Extension * Picture Coding Extension
*/ */
fprintf( stderr, "picture1\n" );
NextStartCode( p_vpar ); NextStartCode( p_vpar );
if( ShowBits( &p_vpar->bit_stream, 16 ) == EXTENSION_START_CODE ) if( ShowBits( &p_vpar->bit_stream, 16 ) == EXTENSION_START_CODE )
{ {
...@@ -616,7 +614,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -616,7 +614,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->picture.i_current_structure = 0; p_vpar->picture.i_current_structure = 0;
intf_DbgMsg("vpar debug: odd number of field picture."); intf_DbgMsg("vpar debug: odd number of field picture.\n");
} }
if( p_vpar->picture.i_current_structure ) if( p_vpar->picture.i_current_structure )
...@@ -657,6 +655,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -657,6 +655,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
return; return;
} }
fprintf(stderr, "begin picture\n");
/* OK, now we are sure we will decode the picture. */ /* OK, now we are sure we will decode the picture. */
#define P_picture p_vpar->picture.p_picture #define P_picture p_vpar->picture.p_picture
...@@ -722,9 +721,9 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -722,9 +721,9 @@ static void PictureHeader( vpar_thread_t * p_vpar )
DumpBits32( &p_vpar->bit_stream ); DumpBits32( &p_vpar->bit_stream );
/* Decode slice data. */ /* Decode slice data. */
SliceHeader( p_vpar, &i_mb_address, i_mb_base, i_dummy & 255 ); p_vpar->sequence.pf_slice_header( p_vpar, &i_mb_address, i_mb_base, i_dummy & 255 );
} }
/* Link referenced pictures for the decoder /* Link referenced pictures for the decoder
* They are unlinked in vpar_ReleaseMacroblock() & vpar_DestroyMacroblock() */ * They are unlinked in vpar_ReleaseMacroblock() & vpar_DestroyMacroblock() */
if( p_vpar->sequence.p_forward != NULL ) if( p_vpar->sequence.p_forward != NULL )
...@@ -739,6 +738,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -739,6 +738,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
if( p_vpar->picture.b_error ) if( p_vpar->picture.b_error )
{ {
/* Trash picture. */ /* Trash picture. */
fprintf(stderr, "Image trashee\n");
for( i_mb = 0; p_vpar->picture.pp_mb[i_mb]; i_mb++ ) for( i_mb = 0; p_vpar->picture.pp_mb[i_mb]; i_mb++ )
{ {
vpar_DestroyMacroblock( &p_vpar->vfifo, p_vpar->picture.pp_mb[i_mb] ); vpar_DestroyMacroblock( &p_vpar->vfifo, p_vpar->picture.pp_mb[i_mb] );
...@@ -759,9 +759,12 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -759,9 +759,12 @@ static void PictureHeader( vpar_thread_t * p_vpar )
/* Prepare context for the next picture. */ /* Prepare context for the next picture. */
P_picture = NULL; P_picture = NULL;
if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE )
p_vpar->picture.i_current_structure = 0;
} }
else if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE ) else if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE )
{ {
fprintf(stderr, "Image decodee\n");
/* Frame completely parsed. */ /* Frame completely parsed. */
P_picture->i_deccount = p_vpar->sequence.i_mb_size; P_picture->i_deccount = p_vpar->sequence.i_mb_size;
for( i_mb = 0; i_mb < p_vpar->sequence.i_mb_size; i_mb++ ) for( i_mb = 0; i_mb < p_vpar->sequence.i_mb_size; i_mb++ )
...@@ -771,6 +774,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -771,6 +774,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
/* Prepare context for the next picture. */ /* Prepare context for the next picture. */
P_picture = NULL; P_picture = NULL;
p_vpar->picture.i_current_structure = 0;
} }
#undef P_picture #undef P_picture
} }
...@@ -786,7 +790,7 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar, ...@@ -786,7 +790,7 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
static int pi_dc_dct_reinit[4] = {128,256,512,1024}; static int pi_dc_dct_reinit[4] = {128,256,512,1024};
int i_mb_address_save = *pi_mb_address; int i_mb_address_save = *pi_mb_address;
/* slice_vertical_position_extension and priority_breakpoint already done */ /* slice_vertical_position_extension and priority_breakpoint already done */
LoadQuantizerScale( p_vpar ); LoadQuantizerScale( p_vpar );
...@@ -818,7 +822,8 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar, ...@@ -818,7 +822,8 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
i_mb_base ); i_mb_base );
i_mb_address_save = *pi_mb_address; i_mb_address_save = *pi_mb_address;
} }
while( !ShowBits( &p_vpar->bit_stream, 23 ) ); while( ShowBits( &p_vpar->bit_stream, 23 ) );
NextStartCode( p_vpar );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type, boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure ) int i_structure )
{ {
return( i_coding_type == I_CODING_TYPE );
} }
/***************************************************************************** /*****************************************************************************
......
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