#include "vpar_synchro.h"
#include "video_parser.h"
+
/*
* Local prototypes
*/
/* Get macroblock_type. */
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;
-
-//fprintf( stderr, "MB type : %d\n", p_mb->i_mb_type );
/* SCALABILITY : warning, we don't know if spatial_temporal_weight_code
* has to be dropped, take care if you use scalable streams. */
yuv_data_t * p_data2;
/************* DEBUG *************/
- static int i_count = 0;
int i_inc;
- boolean_t b_stop = 0;
+ static int i_count;
+i_count++;
i_inc = MacroblockAddressIncrement( p_vpar );
-
*pi_mb_address += i_inc;
-
//*pi_mb_address += MacroblockAddressIncrement( p_vpar );
- b_stop = i_inc > 1;
-// fprintf( stderr, "inc : %d (%d)\n", *pi_mb_address, i_inc );
-if( 0 )//i_count > 8 )
-{
- exit(0);
-}
-i_count++;
-
-if( 0 )
- //i_count == 249)
- // i_count != *pi_mb_address)
- //b_stop )
-{
- fprintf( stderr, "i_count = %d (%d)\n", i_count, i_inc );
- fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x ", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x\n", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x ", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
- fprintf( stderr, "%x\n", GetBits( &p_vpar->bit_stream, 16 ) );
- exit(0);
-}
for( i_mb = i_mb_previous + 1; i_mb < *pi_mb_address; i_mb++ )
{
static f_motion_t pf_motion_skipped[4] = {NULL, vdec_MotionField,
vdec_MotionField, vdec_MotionFrame};
-fprintf(stderr, "Skipped macroblock !\n");
/* Reset DC predictors (7.2.1). */
p_vpar->slice.pi_dc_dct_pred[0] = p_vpar->slice.pi_dc_dct_pred[1]
= p_vpar->slice.pi_dc_dct_pred[2]
if( p_vpar->mb.i_mb_type & MB_MOTION_FORWARD )
{
-fprintf( stderr, "motion !\n" );
+//fprintf( stderr, "motion !\n" );
(*p_vpar->sequence.pf_decode_mv)( p_vpar, p_mb, 0 );
}
if( p_vpar->mb.i_mb_type & MB_MOTION_BACKWARD )
{
-fprintf( stderr, "motion2 !\n" );
+//fprintf( stderr, "motion2 !\n" );
(*p_vpar->sequence.pf_decode_mv)( p_vpar, p_mb, 1 );
}
{
RemoveBits( &p_vpar->bit_stream, 1 );
}
+if( 0 )
+ //i_count == 1231 &&
+ // i_count != *pi_mb_address)
+ //p_vpar->picture.i_coding_type == P_CODING_TYPE )
+{
+ fprintf( stderr, "i_count = %d (%d)\n", i_count, p_vpar->mb.i_mb_type );
+ fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x ", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x\n", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x ", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x", GetBits( &p_vpar->bit_stream, 16 ) );
+ fprintf( stderr, "%x\n", GetBits( &p_vpar->bit_stream, 16 ) );
+ exit(0);
+}
if( p_vpar->mb.i_mb_type & MB_PATTERN )
{
- (*p_vpar->sequence.pf_decode_pattern)( p_vpar );
+ p_vpar->mb.i_coded_block_pattern = (*p_vpar->sequence.pf_decode_pattern)( p_vpar );
+//fprintf( stderr, "pattern : %d\n", p_vpar->mb.i_coded_block_pattern );
}
else
{
p_vpar->mb.i_coded_block_pattern = pi_coded_block_pattern
[p_vpar->mb.i_mb_type & MB_INTRA];
}
-
pf_addb = ppf_addb_intra[p_vpar->mb.i_mb_type & MB_INTRA];
/*
/* Testing on 6 bits */
int i_type = ShowBits( &p_vpar->bit_stream, 6 );
+#if 0
+/* Table B-3, macroblock_type in P-pictures, codes 001..1xx */
+static lookup_t PMBtab0[8] = {
+ {-1,0},
+ {MB_MOTION_FORWARD,3},
+ {MB_PATTERN,2}, {MB_PATTERN,2},
+ {MB_MOTION_FORWARD|MB_PATTERN,1},
+ {MB_MOTION_FORWARD|MB_PATTERN,1},
+ {MB_MOTION_FORWARD|MB_PATTERN,1},
+ {MB_MOTION_FORWARD|MB_PATTERN,1}
+};
+
+/* Table B-3, macroblock_type in P-pictures, codes 000001..00011x */
+static lookup_t PMBtab1[8] = {
+ {-1,0},
+ {MB_QUANT|MB_INTRA,6},
+ {MB_QUANT|MB_PATTERN,5}, {MB_QUANT|MB_PATTERN,5},
+ {MB_QUANT|MB_MOTION_FORWARD|MB_PATTERN,5}, {MB_QUANT|MB_MOTION_FORWARD|MB_PATTERN,5},
+ {MB_INTRA,5}, {MB_INTRA,5}
+};
+
+
+ if(i_type >= 8)
+ {
+ i_type >>= 3;
+ RemoveBits( &p_vpar->bit_stream,PMBtab0[i_type].i_length );
+ return PMBtab0[i_type].i_value;
+ }
+
+ if (i_type==0)
+ {
+ printf("Invalid P macroblock_type code\n");
+ return -1;
+ }
+ RemoveBits( &p_vpar->bit_stream,PMBtab1[i_type].i_length );
+ return PMBtab1[i_type].i_value;
+#endif
/* Dump the good number of bits */
RemoveBits( &p_vpar->bit_stream, p_vpar->ppl_mb_type[0][i_type].i_length );
-
/* return the value from the lookup table for P type */
return p_vpar->ppl_mb_type[0][i_type].i_value;
}
/* Lookup Table for the chromatic component */
static int pi_cc_index[12] = { 0, 0, 0, 0, 1, 2, 1, 2, 1, 2 };
-
+
i_cc = pi_cc_index[i_b];
/* Determine whether it is luminance or not (chrominance) */
i_length = pl_DCT_tab_ac[(i_code>>12)-4].i_length;
}
}
+ else if( i_code >= 1024 )
+ {
+ i_run = pl_DCT_tab0[(i_code>>8)-4].i_run;
+ i_length = pl_DCT_tab0[(i_code>>8)-4].i_length;
+ i_level = pl_DCT_tab0[(i_code>>8)-4].i_level;
+ }
else
{
i_run = ppl_dct_coef[0][i_code].i_run;
i_coef = i_parse;
i_parse += i_run;
i_nc ++;
-
+
+if( i_parse >= 64 )
+{
+ break;
+}
+
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;
+ p_mb->ppi_blocks[i_b][i_pos] = b_sign ? -i_level : i_level;
}
-fprintf( stderr, "MPEG2 end (%d)\n", i_b );
+fprintf( stderr, "Non intra MPEG2 end (%d)\n", i_b );
exit(0);
-
+//p_vpar->picture.b_error = 1;
}
/*****************************************************************************
/* Lookup Table for the chromatic component */
static int pi_cc_index[12] = { 0, 0, 0, 0, 1, 2, 1, 2, 1, 2 };
-
i_cc = pi_cc_index[i_b];
/* Determine whether it is luminance or not (chrominance) */
// i_run, i_level, i_parse, ShowBits( &p_vpar->bit_stream, 16 ) );
//fprintf( stderr, "- %4x\n",ShowBits( &p_vpar->bit_stream, 16 ) );
-
+if( i_parse >= 64 )
+{
+ fprintf( stderr, "Beuhh dans l'intra decode (%d)\n", i_b );
+ break;
+}
i_coef = i_parse;
i_parse += i_run;
i_nc ++;
fprintf( stderr, "MPEG2 end (%d)\n", i_b );
exit(0);
+//p_vpar->b_error = 1;
}
#include "video_parser.h"
#include "vpar_motion.h"
-/* mv_format */
-#define MV_FIELD 0
-#define MV_FRAME 1
+
/*
* Local prototypes
static __inline__ int vpar_MotionCode( vpar_thread_t * p_vpar )
{
int i_code;
- static mv_tab_t p_mv_tab0[8] =
+ static lookup_t pl_mv_tab0[8] =
{ {-1,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1} };
/* Table B-10, motion_code, codes 0000011 ... 000011x */
- static mv_tab_t p_mv_tab1[8] =
+ static lookup_t pl_mv_tab1[8] =
{ {-1,0}, {-1,0}, {-1,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5} };
/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
- static mv_tab_t p_mv_tab2[12] = {
+ static lookup_t pl_mv_tab2[12] = {
{16,9}, {15,9}, {14,9}, {13,9},
{12,9}, {11,9}, {10,8}, {10,8},
{9,8}, {9,8}, {8,8}, {8,8} };
- if( GetBits(&p_vpar->bit_stream, 1) )
- {
- return 0;
- }
-
- if( (i_code = ShowBits(&p_vpar->bit_stream, 9)) >= 64 )
- {
- i_code >>= 6;
- RemoveBits( &p_vpar->bit_stream, p_mv_tab0[0].i_len );
- return( GetBits(&p_vpar->bit_stream, 1) ? -p_mv_tab0[i_code].i_val : p_mv_tab0[i_code].i_val );
- }
-
- if( i_code >= 24 )
- {
- i_code >>= 3;
- RemoveBits( &p_vpar->bit_stream, p_mv_tab1[0].i_len );
- return( GetBits(&p_vpar->bit_stream, 1) ? -p_mv_tab1[i_code].i_val : p_mv_tab1[i_code].i_val );
- }
-
- if( (i_code -= 12) < 0 )
- {
- p_vpar->picture.b_error = 1;
- intf_DbgMsg( "vpar debug: Invalid motion_vector code\n" );
- return 0;
- }
-
- RemoveBits( &p_vpar->bit_stream, p_mv_tab2[0].i_len );
- return( GetBits(&p_vpar->bit_stream, 1) ? -p_mv_tab2[i_code].i_val : p_mv_tab2[i_code].i_val );
+ if( GetBits(&p_vpar->bit_stream, 1) )
+ {
+ return 0;
+ }
+ if( (i_code = ShowBits(&p_vpar->bit_stream, 9)) >= 64 )
+ {
+ i_code >>= 6;
+ RemoveBits( &p_vpar->bit_stream, pl_mv_tab0[i_code].i_length );
+ return( GetBits(&p_vpar->bit_stream, 1) ? -pl_mv_tab0[i_code].i_value : pl_mv_tab0[i_code].i_value );
+ }
+
+ if( i_code >= 24 )
+ {
+ i_code >>= 3;
+ RemoveBits( &p_vpar->bit_stream, pl_mv_tab1[i_code].i_length );
+ return( GetBits(&p_vpar->bit_stream, 1) ? -pl_mv_tab1[i_code].i_value : pl_mv_tab1[i_code].i_value );
+ }
+
+ if( (i_code -= 12) < 0 )
+ {
+ p_vpar->picture.b_error = 1;
+ intf_DbgMsg( "vpar debug: Invalid motion_vector code\n" );
+ return 0;
+ }
+
+ RemoveBits( &p_vpar->bit_stream, pl_mv_tab2[i_code].i_length );
+ return( GetBits(&p_vpar->bit_stream, 1) ? -pl_mv_tab2[i_code].i_value : pl_mv_tab2[i_code].i_value );
}
/****************************************************************************
void vpar_MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_r,
int i_s, int i_full_pel )
{
-
int i_motion_code, i_motion_residual;
int i_r_size;
{
if( p_vpar->mb.i_mv_count == 1 )
{
- if( p_vpar->mb.i_mv_format == MV_FIELD && !p_vpar->mb.b_dmv )
+ if( p_vpar->mb.i_mv_format == MOTION_FIELD && !p_vpar->mb.b_dmv )
{
p_mb->ppi_field_select[0][i_s] = p_mb->ppi_field_select[1][i_s]
= GetBits( &p_vpar->bit_stream, 1 );