Commit 7190bee5 authored by Christophe Massiot's avatar Christophe Massiot

J'en ai chi� mais j'ai enfin pondu le AddBlock du video_decoder.

parent c3a438c7
...@@ -13,16 +13,22 @@ ...@@ -13,16 +13,22 @@
/***************************************************************************** /*****************************************************************************
* Common declarations * Common declarations
*****************************************************************************/ *****************************************************************************/
#define elem_t short #ifndef VDEC_DFT
typedef short elem_t;
#else
typedef int elem_t;
#endif
struct vdec_thread_s;
/***************************************************************************** /*****************************************************************************
* Function pointers * Function pointers
*****************************************************************************/ *****************************************************************************/
typedef void (*f_idct_t)( elem_t*, int ); typedef void (*f_idct_t)( struct vdec_thread_s *, elem_t*, int );
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
void vdec_DummyIDCT( elem_t*, int ); void vdec_DummyIDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_SparseIDCT( elem_t*, int ); void vdec_SparseIDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_IDCT( elem_t*, int ); void vdec_IDCT( struct vdec_thread_s *, elem_t*, int );
...@@ -21,11 +21,13 @@ ...@@ -21,11 +21,13 @@
typedef struct macroblock_s typedef struct macroblock_s
{ {
picture_t * p_picture; picture_t * p_picture;
int i_mb_x, i_mb_y;
int i_structure; int i_structure;
int i_l_x, i_l_y; /* position of macroblock (lum) */ int i_l_x, i_l_y; /* position of macroblock (lum) */
int i_c_x, i_c_y; /* position of macroblock (chroma) */ int i_c_x, i_c_y; /* position of macroblock (chroma) */
int i_chroma_nb_blocks; /* nb of bks for a chr comp */ int i_chroma_nb_blocks; /* nb of bks for a chr comp */
int i_l_stride; /* number of data_t to ignore
* when changing lines */
int i_c_stride; /* idem, for chroma */
/* IDCT information */ /* IDCT information */
elem_t ppi_blocks[12][64]; /* blocks */ elem_t ppi_blocks[12][64]; /* blocks */
...@@ -47,9 +49,9 @@ typedef struct macroblock_s ...@@ -47,9 +49,9 @@ typedef struct macroblock_s
int pi_motion_vectors_forw_bot[2]; int pi_motion_vectors_forw_bot[2];
/* AddBlock information */ /* AddBlock information */
f_addb_t pf_addb[12]; f_addb_t pf_addb[12]; /* pointer to the Add function */
data_t * p_data[12]; /* positions of blocks in picture */ data_t * p_data[12]; /* pointer to the position
int i_lum_incr, i_chroma_incr; * in the final picture */
} macroblock_t; } macroblock_t;
/***************************************************************************** /*****************************************************************************
...@@ -60,6 +62,8 @@ typedef struct ...@@ -60,6 +62,8 @@ typedef struct
int i_mb_type, i_motion_type, i_mv_count, i_mv_format; int i_mb_type, i_motion_type, i_mv_count, i_mv_format;
int i_coded_block_pattern; int i_coded_block_pattern;
boolean_t b_dct_type; boolean_t b_dct_type;
int i_l_x, i_l_y, i_c_x, i_c_y;
} macroblock_parsing_t; } macroblock_parsing_t;
/***************************************************************************** /*****************************************************************************
......
...@@ -42,12 +42,10 @@ extern int * pi_default_nonintra_quant; ...@@ -42,12 +42,10 @@ extern int * pi_default_nonintra_quant;
*****************************************************************************/ *****************************************************************************/
typedef struct sequence_s typedef struct sequence_s
{ {
u32 i_height, i_width, i_chroma_width, i_size; u32 i_height, i_width, i_size;
u32 i_mb_height, i_mb_width, i_mb_size; u32 i_mb_height, i_mb_width, i_mb_size;
unsigned int i_aspect_ratio; unsigned int i_aspect_ratio;
double d_frame_rate; double d_frame_rate;
unsigned int i_chroma_format;
int i_chroma_nb_blocks;
boolean_t b_mpeg2; boolean_t b_mpeg2;
boolean_t b_progressive; boolean_t b_progressive;
unsigned int i_scalable_mode; unsigned int i_scalable_mode;
...@@ -57,6 +55,12 @@ typedef struct sequence_s ...@@ -57,6 +55,12 @@ typedef struct sequence_s
void (*pf_decode_mv)( struct vpar_thread_s *, int ); void (*pf_decode_mv)( struct vpar_thread_s *, int );
f_chroma_pattern_t pf_decode_pattern; f_chroma_pattern_t pf_decode_pattern;
/* Chromatic information */
unsigned int i_chroma_format;
int i_chroma_nb_blocks;
u32 i_chroma_width;
u32 i_chroma_mb_width, i_chroma_mb_height;
/* Parser context */ /* Parser context */
picture_t * p_forward; picture_t * p_forward;
picture_t * p_backward; picture_t * p_backward;
...@@ -85,7 +89,7 @@ typedef struct picture_parsing_s ...@@ -85,7 +89,7 @@ typedef struct picture_parsing_s
boolean_t b_alternate_scan, b_progressive_frame; boolean_t b_alternate_scan, b_progressive_frame;
boolean_t b_top_field_first, b_concealment_mv; boolean_t b_top_field_first, b_concealment_mv;
boolean_t b_repeat_first_field; boolean_t b_repeat_first_field;
int i_lum_incr, i_chroma_incr; int i_l_stride, i_c_stride;
/* Used for second field management */ /* Used for second field management */
int i_current_structure; int i_current_structure;
......
...@@ -242,13 +242,14 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb ) ...@@ -242,13 +242,14 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
/* /*
* Inverse DCT (ISO/IEC 13818-2 section Annex A) * Inverse DCT (ISO/IEC 13818-2 section Annex A)
*/ */
(p_mb->pf_idct[i_b])( p_mb->ppi_blocks[i_b], p_mb->pi_sparse_pos[i_b] ); (p_mb->pf_idct[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->pi_sparse_pos[i_b] );
/* /*
* Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8) * Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
*/ */
(p_mb->pf_addb[i_b])( p_mb->ppi_blocks[i_b], (p_mb->pf_addb[i_b])( p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_lum_incr ); p_mb->p_data[i_b], p_mb->i_l_stride );
} }
/* chrominance */ /* chrominance */
...@@ -257,13 +258,14 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb ) ...@@ -257,13 +258,14 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
/* /*
* Inverse DCT (ISO/IEC 13818-2 section Annex A) * Inverse DCT (ISO/IEC 13818-2 section Annex A)
*/ */
(p_mb->pf_idct[i_b])( p_mb->ppi_blocks[i_b], p_mb->pi_sparse_pos[i_b] ); (p_mb->pf_idct[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->pi_sparse_pos[i_b] );
/* /*
* Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8) * Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
*/ */
(p_mb->pf_addb[i_b])( p_mb->ppi_blocks[i_b], (p_mb->pf_addb[i_b])( p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_chroma_incr ); p_mb->p_data[i_b], p_mb->i_c_stride );
} }
/* /*
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* Local prototypes * Local prototypes
*/ */
static __inline__ void InitMacroblock( vpar_thread_t * p_vpar, static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
macroblock_t * p_mb, int i_mb_address ); macroblock_t * p_mb );
static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar ); static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar );
static __inline__ void MacroblockModes( vpar_thread_t * p_vpar, static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
macroblock_t * p_mb ); macroblock_t * p_mb );
...@@ -61,10 +61,20 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -61,10 +61,20 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
int i_mb_previous, int i_mb_base ) int i_mb_previous, int i_mb_base )
{ {
static f_addb_t ppf_addb_intra[2] = {vdec_AddBlock, vdec_CopyBlock}; static f_addb_t ppf_addb_intra[2] = {vdec_AddBlock, vdec_CopyBlock};
static f_decode_block_t pppf_decode_block[2][2] =
{ {vpar_DecodeMPEG1Non, vpar_DecodeMPEG1Intra},
{vpar_DecodeMPEG2Non, vpar_DecodeMPEG2Intra} };
static int pi_x[12] = {0,8,0,8,0,0,0,0,8,8,8,8};
static int pi_y[2][12] = { {0,0,8,8,0,0,8,8,0,0,8,8},
{0,0,1,1,0,0,1,1,0,0,1,1} };
static int pi_chroma_hor[4] = { 0, 1, 1, 0 };
static int pi_chroma_ver[4] = { 0, 1, 0, 0 };
int i_mb, i_b, i_mask, i_x, i_y, pi_pos[3], pi_width[3]; 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;
elem_t * p_data2;
*pi_mb_address += MacroblockAddressIncrement( p_vpar ); *pi_mb_address += MacroblockAddressIncrement( p_vpar );
...@@ -94,7 +104,7 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -94,7 +104,7 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
return; return;
} }
InitMacroblock( p_vpar, p_mb, i_mb ); InitMacroblock( p_vpar, p_mb );
/* No IDCT nor AddBlock. */ /* No IDCT nor AddBlock. */
for( i_b = 0; i_b < 12; i_b++ ) for( i_b = 0; i_b < 12; i_b++ )
...@@ -119,7 +129,7 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -119,7 +129,7 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
return; return;
} }
InitMacroblock( p_vpar, p_mb, *pi_mb_address ); InitMacroblock( p_vpar, p_mb );
/* Parse off macroblock_modes structure. */ /* Parse off macroblock_modes structure. */
MacroblockModes( p_vpar, p_mb ); MacroblockModes( p_vpar, p_mb );
...@@ -158,44 +168,59 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -158,44 +168,59 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
pf_addb = ppf_addb_intra[p_vpar->mb.i_mb_type & MB_INTRA]; pf_addb = ppf_addb_intra[p_vpar->mb.i_mb_type & MB_INTRA];
/* C'est de la merde, il faut recommencer */ /*
* Effectively decode blocks.
i_x = p_mb->i_mb_x << 4; */
i_y = p_mb->i_mb_y << 4;
i_mask = 1 << (3 + 2*p_vpar->sequence.i_chroma_nb_blocks);
pi_pos[0] = i_y*(p_vpar->sequence.i_width
<< (!p_vpar->picture.b_frame_structure)) /* luminance */
+ (p_mb->i_structure == BOTTOM_FIELD)*p_vpar->sequence.i_width p_data1 = p_mb->p_picture->p_y
+ i_x; + p_mb->i_l_x + p_mb->i_l_y*(p_vpar->sequence.i_width);
pi_pos[1] = pi_pos[2] = i_y*(p_vpar->sequence.i_chroma_width
<< (!p_vpar->picture.b_frame_structure)) for( i_b = 0; i_b < 4; i_b++, i_mask >>= 1 )
+ (p_mb->i_structure == BOTTOM_FIELD)*p_vpar->sequence.i_chroma_width
+ (i_x >> (3-p_vpar->sequence.i_chroma_format));
pi_width[0] = p_vpar->sequence.i_width << (!p_vpar->picture.b_frame_structure
|| p_vpar->mb.b_dct_type);
pi_width[1] = pi_width[2] = p_vpar->sequence.i_chroma_width
<< (!p_vpar->picture.b_frame_structure || p_vpar->mb.b_dct_type);
/* Effectively decode blocks. */
for( i_b = 0, i_mask = 1 << (3 + 2*p_vpar->sequence.i_chroma_nb_blocks);
i_b < 4 + 2*p_vpar->sequence.i_chroma_nb_blocks; i_b++, i_mask >>= 1 )
{ {
if( p_vpar->mb.i_coded_block_pattern & i_mask ) if( p_vpar->mb.i_coded_block_pattern & i_mask )
{ {
static f_decode_block_t pppf_decode_block[2][2] = memset( p_mb->ppi_blocks[i_b], 0, 64*sizeof(elem_t) );
{ {vpar_DecodeMPEG1Non, vpar_DecodeMPEG1Intra}, (*pppf_decode_block[p_vpar->sequence.b_mpeg2]
{vpar_DecodeMPEG2Non, vpar_DecodeMPEG2Intra} }; [p_vpar->mb.i_mb_type & MB_INTRA])
static int pi_x[12] = {0,8,0,8,0,0,0,0,8,8,8,8}; ( p_vpar, p_mb, i_b );
static int pi_y[12] = {0,0,8,8,0,0,8,8,0,0,8,8};
data_t pi_data[12] = /* decode_block has already set pf_idct and pi_sparse_pos. */
{p_mb->p_picture->p_y, p_mb->p_picture->p_y, p_mb->pf_addb[i_b] = pf_addb;
p_mb->p_picture->p_y, p_mb->p_picture->p_y,
p_mb->p_picture->p_u, p_mb->p_picture->p_v, /* Calculate block coordinates. */
p_mb->p_picture->p_u, p_mb->p_picture->p_v, p_mb->p_data[i_b] = p_data1
p_mb->p_picture->p_u, p_mb->p_picture->p_v, + pi_y[p_vpar->mb.b_dct_type][i_b]
p_mb->p_picture->p_u, p_mb->p_picture->p_v}; * p_vpar->sequence.i_chroma_width;
}
bzero( p_mb->ppi_blocks[i_b], 64*sizeof(elem_t) ); else
{
/* Block not coded, so no IDCT, nor AddBlock */
p_mb->pf_addb[i_b] = vdec_DummyBlock;
p_mb->pf_idct[i_b] = vdec_DummyIDCT;
}
}
/* chrominance 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_y >> pi_chroma_ver[p_vpar->sequence.i_chroma_format])
* (p_vpar->sequence.i_chroma_width);
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_y >> pi_chroma_ver[p_vpar->sequence.i_chroma_format])
* (p_vpar->sequence.i_chroma_width);
for( i_b = 4; i_b < 4 + 2*p_vpar->sequence.i_chroma_nb_blocks;
i_b++, i_mask >>= 1 )
{
elem_t * pp_data[2] = {p_data1, p_data2};
if( p_vpar->mb.i_coded_block_pattern & i_mask )
{
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])
( p_vpar, p_mb, i_b ); ( p_vpar, p_mb, i_b );
...@@ -204,10 +229,9 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -204,10 +229,9 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
p_mb->pf_addb[i_b] = pf_addb; p_mb->pf_addb[i_b] = pf_addb;
/* Calculate block coordinates. */ /* Calculate block coordinates. */
p_mb->p_data[i_b] = pi_data[i_b] + pi_pos[i_b >> 2] p_mb->p_data[i_b] = pp_data[i_b & 1]
+ pi_y[i_b]*pi_width[i_b >> 2] + pi_y[p_vpar->mb.b_dct_type][i_b]
+ (p_vpar->mb.b_dct_type & ((i_b & 2) >> 1)); * p_vpar->sequence.i_chroma_width;
/* INACHEV parce que trop pourri ! */
} }
else else
{ {
...@@ -248,16 +272,30 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address, ...@@ -248,16 +272,30 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
* InitMacroblock : Initialize macroblock values * InitMacroblock : Initialize macroblock values
*****************************************************************************/ *****************************************************************************/
static __inline__ void InitMacroblock( vpar_thread_t * p_vpar, static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
macroblock_t * p_mb, int i_mb_address ) macroblock_t * p_mb )
{ {
p_mb->p_picture = p_vpar->picture.p_picture; p_mb->p_picture = p_vpar->picture.p_picture;
p_mb->i_structure = p_vpar->picture.i_structure; p_mb->i_structure = p_vpar->picture.i_structure;
p_mb->i_mb_x = i_mb_address % p_vpar->sequence.i_mb_width; p_mb->i_l_x = p_vpar->mb.i_l_x;
p_mb->i_mb_y = i_mb_address / p_vpar->sequence.i_mb_width; p_mb->i_l_y = p_vpar->mb.i_l_y;
p_mb->i_c_x = p_vpar->mb.i_c_x;
p_mb->i_c_y = p_vpar->mb.i_c_y;
p_mb->i_chroma_nb_blocks = p_vpar->sequence.i_chroma_nb_blocks; p_mb->i_chroma_nb_blocks = p_vpar->sequence.i_chroma_nb_blocks;
p_mb->i_lum_incr = p_vpar->picture.i_lum_incr; p_mb->i_l_stride = p_vpar->picture.i_l_stride;
p_mb->i_chroma_incr = p_vpar->picture.i_chroma_incr; p_mb->i_c_stride = p_vpar->picture.i_c_stride;
/* Update macroblock real position. */
p_vpar->mb.i_l_x += 16;
p_vpar->mb.i_l_y += (p_vpar->mb.i_l_x / p_vpar->sequence.i_width)
* (2 - p_vpar->picture.b_frame_structure) * 16;
p_vpar->mb.i_l_x %= p_vpar->sequence.i_width;
p_vpar->mb.i_c_x += p_vpar->sequence.i_chroma_mb_width;
p_vpar->mb.i_c_y += (p_vpar->mb.i_c_x / p_vpar->sequence.i_chroma_width)
* (2 - p_vpar->picture.b_frame_structure)
* p_vpar->sequence.i_chroma_mb_height;
p_vpar->mb.i_c_x %= p_vpar->sequence.i_chroma_width;
} }
/***************************************************************************** /*****************************************************************************
...@@ -288,7 +326,7 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar, ...@@ -288,7 +326,7 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
* 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( !(p_vpar->mb.i_mb_type & (MB_MOTION_FORWARD | MB_MOTION_BACKWARD))
|| p_vpar->picture.b_frame_pred_frame_dct ) || p_vpar->picture.b_frame_pred_frame_dct )
{ {
/* If mb_type has neither MOTION_FORWARD nor MOTION_BACKWARD, this /* If mb_type has neither MOTION_FORWARD nor MOTION_BACKWARD, this
...@@ -307,15 +345,18 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar, ...@@ -307,15 +345,18 @@ static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
p_vpar->mb.i_mv_format = ppi_mv_format[p_vpar->picture.b_frame_structure] p_vpar->mb.i_mv_format = ppi_mv_format[p_vpar->picture.b_frame_structure]
[p_vpar->mb.i_motion_type]; [p_vpar->mb.i_motion_type];
p_vpar->mb.b_dct_type = 0;
if( (p_vpar->picture.i_structure == FRAME_STRUCTURE) && if( (p_vpar->picture.i_structure == FRAME_STRUCTURE) &&
(!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)) )
{ {
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 ) )
} {
else p_mb->i_l_stride <<= 1;
{ p_mb->i_l_stride += 8;
p_vpar->mb.b_dct_type = 0; p_mb->i_c_stride <<= 1;
p_mb->i_c_stride += 8;
}
} }
} }
......
...@@ -219,7 +219,6 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -219,7 +219,6 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
if( ShowBits( &p_vpar->bit_stream, 32 ) == EXTENSION_START_CODE ) if( ShowBits( &p_vpar->bit_stream, 32 ) == EXTENSION_START_CODE )
{ {
int i_dummy; int i_dummy;
static int pi_chroma_nb_blocks[4] = {0, 1, 2, 4};
static f_chroma_pattern_t ppf_chroma_pattern[4] = static f_chroma_pattern_t ppf_chroma_pattern[4] =
{NULL, vpar_CodedPattern420, {NULL, vpar_CodedPattern420,
vpar_CodedPattern422, vpar_CodedPattern444}; vpar_CodedPattern422, vpar_CodedPattern444};
...@@ -230,10 +229,6 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -230,10 +229,6 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
DumpBits( &p_vpar->bit_stream, 12 ); DumpBits( &p_vpar->bit_stream, 12 );
p_vpar->sequence.b_progressive = GetBits( &p_vpar->bit_stream, 1 ); p_vpar->sequence.b_progressive = GetBits( &p_vpar->bit_stream, 1 );
p_vpar->sequence.i_chroma_format = GetBits( &p_vpar->bit_stream, 2 ); p_vpar->sequence.i_chroma_format = GetBits( &p_vpar->bit_stream, 2 );
p_vpar->sequence.i_chroma_width = p_vpar->sequence.i_width
>> (3-p_vpar->sequence.i_chroma_format);
p_vpar->sequence.i_chroma_nb_blocks = pi_chroma_nb_blocks
[p_vpar->sequence.i_chroma_format];
p_vpar->sequence.pf_decode_pattern = ppf_chroma_pattern p_vpar->sequence.pf_decode_pattern = ppf_chroma_pattern
[p_vpar->sequence.i_chroma_format]; [p_vpar->sequence.i_chroma_format];
p_vpar->sequence.i_width |= GetBits( &p_vpar->bit_stream, 2 ) << 12; p_vpar->sequence.i_width |= GetBits( &p_vpar->bit_stream, 2 ) << 12;
...@@ -253,13 +248,12 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -253,13 +248,12 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
/* It's an MPEG-1 stream. Put adequate parameters. */ /* It's an MPEG-1 stream. Put adequate parameters. */
p_vpar->sequence.b_progressive = 1; p_vpar->sequence.b_progressive = 1;
p_vpar->sequence.i_chroma_format = CHROMA_420; p_vpar->sequence.i_chroma_format = CHROMA_420;
p_vpar->sequence.i_chroma_width = p_vpar->sequence.i_width >> 2;
p_vpar->sequence.i_chroma_nb_blocks = 2;
p_vpar->sequence.pf_decode_pattern = vpar_CodedPattern420; p_vpar->sequence.pf_decode_pattern = vpar_CodedPattern420;
p_vpar->sequence.pf_decode_mv = vpar_MPEG1MotionVector; p_vpar->sequence.pf_decode_mv = vpar_MPEG1MotionVector;
} }
/* Update sizes */
p_vpar->sequence.i_mb_width = (p_vpar->sequence.i_width + 15) / 16; p_vpar->sequence.i_mb_width = (p_vpar->sequence.i_width + 15) / 16;
p_vpar->sequence.i_mb_height = (p_vpar->sequence.b_progressive) ? p_vpar->sequence.i_mb_height = (p_vpar->sequence.b_progressive) ?
(p_vpar->sequence.i_height + 15) / 16 : (p_vpar->sequence.i_height + 15) / 16 :
...@@ -271,6 +265,30 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -271,6 +265,30 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
p_vpar->sequence.i_size = p_vpar->sequence.i_width p_vpar->sequence.i_size = p_vpar->sequence.i_width
* p_vpar->sequence.i_height; * p_vpar->sequence.i_height;
/* Update chromatic information */
switch( p_vpar->sequence.i_chroma_format )
{
case CHROMA_420:
p_vpar->sequence.i_chroma_nb_blocks = 2;
p_vpar->sequence.i_chroma_width = p_vpar->sequence.i_width >> 2;
p_vpar->i_chroma_mb_width = 8;
p_vpar->i_chroma_mb_height = 8;
break;
case CHROMA_422:
p_vpar->sequence.i_chroma_nb_blocks = 4;
p_vpar->sequence.i_chroma_width = p_vpar->sequence.i_width >> 1;
p_vpar->i_chroma_mb_width = 8;
p_vpar->i_chroma_mb_height = 16;
break;
case CHROMA_444:
p_vpar->sequence.i_chroma_nb_blocks = 8;
p_vpar->sequence.i_chroma_width = p_vpar->sequence.i_width;
p_vpar->i_chroma_mb_width = 16;
p_vpar->i_chroma_mb_height = 16;
}
/* Slice Header functions */ /* Slice Header functions */
if( p_vpar->sequence.i_height <= 2800 ) if( p_vpar->sequence.i_height <= 2800 )
{ {
...@@ -481,10 +499,10 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -481,10 +499,10 @@ static void PictureHeader( vpar_thread_t * p_vpar )
P_picture->date = vpar_SynchroDecode( p_vpar, P_picture->date = vpar_SynchroDecode( p_vpar,
p_vpar->picture.i_coding_type, p_vpar->picture.i_coding_type,
i_structure ); i_structure );
p_vpar->picture.i_lum_incr = - 8 + ( p_vpar->sequence.i_width p_vpar->picture.i_l_stride = - 8 + ( p_vpar->sequence.i_width
<< ( i_structure != FRAME_STRUCTURE ) ); << ( 1 - p_vpar->picture.b_frame_structure ) );
p_vpar->picture.i_chroma_incr = -8 + ( p_vpar->sequence.i_width p_vpar->picture.i_c_stride = -8 + ( p_vpar->sequence.i_width
<< (( i_structure != FRAME_STRUCTURE ) + << (( 1 - p_vpar->picture.b_frame_structure ) +
( 3 - p_vpar->sequence.i_chroma_format )) ); ( 3 - p_vpar->sequence.i_chroma_format )) );
/* Update the reference pointers. */ /* Update the reference pointers. */
...@@ -498,12 +516,16 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -498,12 +516,16 @@ static void PictureHeader( vpar_thread_t * p_vpar )
if( i_structure == BOTTOM_FIELD ) if( i_structure == BOTTOM_FIELD )
{ {
i_mb_base = p_vpar->sequence.i_mb_size >> 1; i_mb_base = p_vpar->sequence.i_mb_size >> 1;
p_vpar->mb.i_l_y = 16;
p_vpar->mb.i_c_y = p_vpar->sequence.i_chroma_mb_height;
} }
else else
{ {
i_mb_base = 0; i_mb_base = 0;
p_vpar->mb.i_l_y = p_vpar->mb.i_c_y = 0;
} }
i_mb_address = 0; i_mb_address = 0;
p_vpar->mb.i_l_x = p_vpar->mb.i_c_x = 0;
/* Extension and User data. */ /* Extension and User data. */
ExtensionAndUserData( p_vpar ); ExtensionAndUserData( p_vpar );
...@@ -924,7 +946,7 @@ static __inline__ void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_ma ...@@ -924,7 +946,7 @@ static __inline__ void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_ma
= GetBits( &p_vpar->bit_stream, 8 ); = GetBits( &p_vpar->bit_stream, 8 );
} }
#ifdef FOURIER_IDCT #ifdef VDEC_DFT
/* Discrete Fourier Transform requires the quantization matrices to /* Discrete Fourier Transform requires the quantization matrices to
* be normalized before using them. */ * be normalized before using them. */
vdec_NormQuantMatrix( p_matrix->pi_matrix ); vdec_NormQuantMatrix( p_matrix->pi_matrix );
......
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