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

Le parser fonctionne maintenant avec les I, les P et les B.
Reste a implementer la synchro et finir le decodeur.
parent 66c97236
......@@ -3,11 +3,6 @@
* (c)1999 VideoLAN
*****************************************************************************/
typedef struct
{
char i_val, i_len;
} mv_tab_t;
/*
* Prototypes
*/
......
......@@ -39,6 +39,7 @@
#include "vpar_synchro.h"
#include "video_parser.h"
/*
* Local prototypes
*/
......@@ -646,8 +647,6 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
/* 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. */
......@@ -741,39 +740,13 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
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++ )
{
......@@ -782,7 +755,6 @@ if( 0 )
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]
......@@ -840,13 +812,13 @@ fprintf(stderr, "Skipped macroblock !\n");
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 );
}
......@@ -854,10 +826,27 @@ fprintf( stderr, "motion2 !\n" );
{
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
{
......@@ -866,7 +855,6 @@ fprintf( stderr, "motion2 !\n" );
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];
/*
......@@ -1002,9 +990,45 @@ int vpar_PMBType( vpar_thread_t * p_vpar )
/* 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;
}
......@@ -1134,7 +1158,7 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in
/* 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) */
......@@ -1166,6 +1190,12 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in
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;
......@@ -1203,16 +1233,21 @@ static void vpar_DecodeMPEG2Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, in
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;
}
/*****************************************************************************
......@@ -1238,7 +1273,6 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
/* 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) */
......@@ -1436,7 +1470,11 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
// 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 ++;
......@@ -1450,4 +1488,5 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
fprintf( stderr, "MPEG2 end (%d)\n", i_b );
exit(0);
//p_vpar->b_error = 1;
}
......@@ -40,9 +40,7 @@
#include "video_parser.h"
#include "vpar_motion.h"
/* mv_format */
#define MV_FIELD 0
#define MV_FRAME 1
/*
* Local prototypes
......@@ -54,45 +52,44 @@
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 );
}
/****************************************************************************
......@@ -129,7 +126,6 @@ static __inline__ void vpar_DecodeMotionVector( int * pi_prediction, int i_r_siz
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;
......@@ -189,7 +185,7 @@ void vpar_MPEG2MotionVector( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_
{
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 );
......
......@@ -49,7 +49,9 @@
boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
return( i_coding_type == I_CODING_TYPE );
return( 1 );
return( i_coding_type == I_CODING_TYPE || i_coding_type == P_CODING_TYPE );
//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