Commit 8204a960 authored by Jean-Marc Dressler's avatar Jean-Marc Dressler

Les I marchent !!!!!!!!!!!!!!!!!!!!!!!!
Le gros bug est mort.
parent 2faf5103
......@@ -267,7 +267,7 @@
#define VOUT_DISPLAY_DELAY 100000
/* Delay (in microseconds) between increments in idle levels */
#define VOUT_IDLE_DELAY 5000000
#define VOUT_IDLE_DELAY 5000000000
/* Number of pictures required to computes the FPS rate */
#define VOUT_FPS_SAMPLES 5
......
......@@ -86,7 +86,7 @@ struct vdec_thread_s;
* shows that the values given below are the most effective.
*/
#define CONST_BITS 13 /* Jimmy chose this constant :) */
#define CONST_BITS 8 /* Jimmy chose this constant :) */
#ifdef EIGHT_BIT_SAMPLES
#define PASS1_BITS 2
......
......@@ -40,10 +40,10 @@ typedef struct vdec_thread_s
struct vpar_thread_s * p_vpar; /* video_parser thread */
/* Lookup tables */
#ifdef MPEG2_COMPLIANT
//#ifdef MPEG2_COMPLIANT
u8 pi_crop_buf[VDEC_CROPRANGE];
u8 * pi_crop,
#endif
u8 * pi_crop;
//#endif
#ifdef STATS
/* Statistics */
......@@ -59,7 +59,7 @@ typedef struct vdec_thread_s
/*****************************************************************************
* Function pointers
*****************************************************************************/
typedef void (*f_addb_t)( elem_t*, yuv_data_t*, int );
typedef void (*f_addb_t)( vdec_thread_t *, elem_t*, yuv_data_t*, int );
/*****************************************************************************
* Prototypes
......@@ -69,6 +69,6 @@ struct vpar_thread_s;
/* Thread management functions */
vdec_thread_t * vdec_CreateThread ( struct vpar_thread_s *p_vpar /*, int *pi_status */ );
void vdec_DestroyThread ( vdec_thread_t *p_vdec /*, int *pi_status */ );
void vdec_AddBlock( elem_t*, yuv_data_t*, int );
void vdec_CopyBlock( elem_t*, yuv_data_t*, int );
void vdec_DummyBlock( elem_t*, yuv_data_t*, int );
void vdec_AddBlock( vdec_thread_t *, elem_t*, yuv_data_t*, int );
void vdec_CopyBlock( vdec_thread_t *, elem_t*, yuv_data_t*, int );
void vdec_DummyBlock( vdec_thread_t *, elem_t*, yuv_data_t*, int );
......@@ -44,6 +44,8 @@
* Local prototypes
*/
//extern IDCT_mmx(elem_t*);
/* Our current implementation is a fast DCT, we might move to a fast DFT or
* an MMX DCT in the future. */
......@@ -85,7 +87,6 @@ void vdec_SparseIDCT (vdec_thread_t * p_vdec, elem_t * p_block,
int coeff, rr;
/* If DC Coefficient. */
if ( i_sparse_pos == 0 )
{
dp=(int *)p_block;
......@@ -136,6 +137,8 @@ void vdec_SparseIDCT (vdec_thread_t * p_vdec, elem_t * p_block,
*****************************************************************************/
void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
{
//IDCT_mmx(p_block);
#if 1
s32 tmp0, tmp1, tmp2, tmp3;
s32 tmp10, tmp11, tmp12, tmp13;
s32 z1, z2, z3, z4, z5;
......@@ -1310,4 +1313,5 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
dataptr++; /* advance pointer to next column */
}
#endif
}
......@@ -128,9 +128,9 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
*******************************************************************************/
static int InitThread( vdec_thread_t *p_vdec )
{
#ifdef MPEG2_COMPLIANT
//#ifdef MPEG2_COMPLIANT
int i_dummy;
#endif
//#endif
intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec);
......@@ -144,12 +144,12 @@ static int InitThread( vdec_thread_t *p_vdec )
p_vdec->c_decoded_b_pictures = 0;
#endif
#ifdef MPEG2_COMPLIANT
//#ifdef MPEG2_COMPLIANT
/* Init crop table */
p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1);
for( i_dummy = -VDEC_CROPRANGE; i_dummy < -256; i_dummy ++ )
for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
{
p_vdec->pi_crop[i_dummy] = -256;
p_vdec->pi_crop[i_dummy] = 0;
}
for( ; i_dummy < 255; i_dummy ++ )
{
......@@ -159,7 +159,7 @@ static int InitThread( vdec_thread_t *p_vdec )
{
p_vdec->pi_crop[i_dummy] = 255;
}
#endif
//#endif
/* Mark thread as running and return */
intf_DbgMsg("vdec debug: InitThread(%p) succeeded\n", p_vdec);
......@@ -255,9 +255,9 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
* Motion Compensation (ISO/IEC 13818-2 section 7.6)
*/
(*p_mb->pf_motion)( p_mb );
//#if 0
/* luminance */
for( i_b = 0; i_b < 4; i_b++ )
for( i_b = 0; i_b <4; i_b++ )
{
/*
* Inverse DCT (ISO/IEC 13818-2 section Annex A)
......@@ -265,13 +265,29 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
(p_mb->pf_idct[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->pi_sparse_pos[i_b] );
// if( (i_b & 2) )
/* {
int i, j;
elem_t meuh[64];
for( i = 0; i < 8; i++ )
{
for( j = 0; j < 8; j++ )
{
meuh[8*j + (7-i)] = p_mb->ppi_blocks[i_b][j + 8*i];
}
}
memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
}
*/
/*
* 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->p_data[i_b], p_mb->i_l_stride );
(p_mb->pf_addb[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_addb_l_stride );
}
//#endif
//#if 0
/* chrominance */
for( i_b = 4; i_b < 4 + p_mb->i_chroma_nb_blocks; i_b++ )
{
......@@ -280,14 +296,29 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
*/
(p_mb->pf_idct[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->pi_sparse_pos[i_b] );
/*
{
int i, j;
elem_t meuh[64];
for( i = 0; i < 8; i++ )
{
for( j = 0; j < 8; j++ )
{
meuh[8*j + (7-i)] = p_mb->ppi_blocks[i_b][j + 8*i];
}
}
memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
}
*/
/*
* Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
*/
(p_mb->pf_addb[i_b])( (elem_t*)p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_c_stride );
(p_mb->pf_addb[i_b])( p_vdec, p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_addb_c_stride );
}
//#endif
/*
* Decoding is finished, release the macroblock and free
* unneeded memory.
......@@ -298,7 +329,7 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
/*******************************************************************************
* vdec_AddBlock : add a block
*******************************************************************************/
void vdec_AddBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_data, int i_incr )
{
int i_x, i_y;
......@@ -307,7 +338,7 @@ void vdec_AddBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
for( i_x = 0; i_x < 8; i_x++ )
{
#ifdef MPEG2_COMPLIANT
*p_data = p_vdec->pi_clip[*p_data + *p_block++];
*p_data = p_vdec->pi_crop[*p_data + *p_block++];
p_data++;
#else
*p_data++ += *p_block++;
......@@ -320,13 +351,14 @@ void vdec_AddBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
/*******************************************************************************
* vdec_CopyBlock : copy a block
*******************************************************************************/
void vdec_CopyBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_data, int i_incr )
{
int i_y;
//fprintf(stderr, "%d ", i_incr );
for( i_y = 0; i_y < 8; i_y++ )
{
#ifndef VDEC_DFT
#if 0
/* elem_t and yuv_data_t are the same */
memcpy( p_data, p_block, 8*sizeof(yuv_data_t) );
p_data += i_incr+8;
......@@ -338,7 +370,7 @@ void vdec_CopyBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
{
/* ??? Need clip to be MPEG-2 compliant */
/* ??? Why does the reference decoder add 128 ??? */
*p_data++ = *p_block++;
*p_data++ = p_vdec->pi_crop[*p_block++];
}
p_data += i_incr;
#endif
......@@ -348,6 +380,6 @@ void vdec_CopyBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
/*******************************************************************************
* vdec_DummyBlock : dummy function that does nothing
*******************************************************************************/
void vdec_DummyBlock( elem_t * p_block, yuv_data_t * p_data, int i_incr )
void vdec_DummyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_data, int i_incr )
{
}
......@@ -102,7 +102,9 @@ macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
if( P_buffer.i_index == -1 )
{
/* No more structures available. This should not happen ! */
return NULL;
msleep(VPAR_IDLE_SLEEP);
return vpar_NewMacroblock( p_fifo );
// return NULL;
}
p_mb = P_buffer.pp_mb_free[ P_buffer.i_index-- ];
......@@ -136,10 +138,11 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
/* Unlink picture buffer */
vlc_mutex_lock( &p_mb->p_picture->lock_deccount );
p_mb->p_picture->i_deccount--;
//fprintf(stderr, "%d ", p_mb->p_picture->i_deccount);
/* Test if it was the last block of the picture */
if( p_mb->p_picture->i_deccount == 0 )
if( p_mb->p_picture->i_deccount == 1 )
{
fprintf(stderr, "Image decodee\n");
/* Mark the picture to be displayed */
vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
......@@ -147,16 +150,16 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
vpar_SynchroEnd( p_fifo->p_vpar );
/* Unlink referenced pictures */
if( p_mb->p_forward != NULL )
/* if( p_mb->p_forward != NULL )
{
vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forward );
}
if( p_mb->p_backward != NULL )
{
vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backward );
}
}
vlc_mutex_unlock( & p_mb->p_picture->lock_deccount );
}*/
}
vlc_mutex_unlock( &p_mb->p_picture->lock_deccount );
/* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar->vbuffer
......
......@@ -574,6 +574,7 @@ void vpar_InitDCTTables( vpar_thread_t * p_vpar )
* Macroblock parsing functions
*/
/*****************************************************************************
* vpar_ParseMacroblock : Parse the next macroblock
*****************************************************************************/
......@@ -587,8 +588,6 @@ void vpar_ParseMacroblock( vpar_thread_t * p_vpar, int * pi_mb_address,
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;
macroblock_t * p_mb;
......@@ -631,13 +630,14 @@ if( 0 )
exit(0);
}
for( i_mb = i_mb_previous; i_mb < *pi_mb_address; i_mb++ )
for( i_mb = i_mb_previous + 1; i_mb < *pi_mb_address; i_mb++ )
{
/* Skipped macroblock (ISO/IEC 13818-2 7.6.6). */
static int pi_dc_dct_reinit[4] = {128,256,512,1024};
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]
......@@ -749,7 +749,8 @@ fprintf( stderr, "motion2 !\n" );
/* Calculate block coordinates. */
p_mb->p_data[i_b] = p_data1
+ pi_y[p_vpar->mb.b_dct_type][i_b]
* p_vpar->sequence.i_width;
* p_vpar->sequence.i_width
+ pi_x[i_b];
}
else
{
......@@ -757,44 +758,20 @@ fprintf( stderr, "motion2 !\n" );
p_mb->pf_addb[i_b] = vdec_DummyBlock;
p_mb->pf_idct[i_b] = vdec_DummyIDCT;
}
if( 0 )
//i_count == 482 && i_b == 2 )
// i_count != *pi_mb_address)
//b_stop )
{
fprintf( stderr, "i_count = %d (%d)\n", i_count, i_inc );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x ", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x\n", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x ", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x\n", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x ", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x\n", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x ", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x\n", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x ", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x", GetBits( &p_vpar->bit_stream, 16 ) );
fprintf( stderr, "%4x\n", GetBits( &p_vpar->bit_stream, 16 ) );
exit(0);
}
}
/* chrominance */
//fprintf(stderr, "%d ", p_mb->i_c_x
// + p_mb->i_c_y
// * (p_vpar->sequence.i_chroma_width));
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_mb->i_c_x
+ p_mb->i_c_y
* (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_mb->i_c_x
+ p_mb->i_c_y
* (p_vpar->sequence.i_chroma_width);
for( i_b = 4; i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks;
......@@ -815,7 +792,8 @@ fprintf( stderr, "motion2 !\n" );
/* Calculate block coordinates. */
p_mb->p_data[i_b] = pp_data[i_b & 1]
+ pi_y[p_vpar->mb.b_dct_type][i_b]
* p_vpar->sequence.i_chroma_width;
* p_vpar->sequence.i_chroma_width
+ pi_x[i_b];
}
else
{
......@@ -1260,7 +1238,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
int i_nc;
int i_cc;
int i_coef;
int i_type;
int i_type, i_quant_type;
int i_code;
int i_length;
int i_pos;
......@@ -1274,11 +1252,12 @@ 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) */
i_type = ( i_cc + 1 ) >> 1;
i_quant_type = i_type | (p_vpar->sequence.i_chroma_format == CHROMA_420);
/* Give a pointer to the quantization matrices for intra blocks */
ppi_quant[0] = p_vpar->sequence.intra_quant.pi_matrix;
......@@ -1451,7 +1430,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
: i_level;
break;
case DCT_EOB:
if( i_nc <= 1 )
if( i_nc <= 0 )
{
p_mb->pf_idct[i_b] = vdec_SparseIDCT;
p_mb->pi_sparse_pos[i_b] = i_coef;
......@@ -1479,8 +1458,8 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
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] ) >> 4;
p_mb->ppi_blocks[i_b][i_parse] = b_sign ? -i_level : i_level;
ppi_quant[i_quant_type][i_pos] ) >> 4;
p_mb->ppi_blocks[i_b][i_pos] = b_sign ? -i_level : i_level;
}
fprintf( stderr, "MPEG2 end (%d)\n", i_b );
......
......@@ -443,7 +443,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
{
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->sequence.i_chroma_width = p_vpar->sequence.i_width >> 1;
p_vpar->sequence.i_chroma_mb_width = 8;
p_vpar->sequence.i_chroma_mb_height = 8;
break;
......@@ -679,16 +679,15 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->b_error = 1;
return;
}
bzero( P_picture->p_data, 940032 );
/* Initialize values. */
P_picture->date = vpar_SynchroDecode( p_vpar,
p_vpar->picture.i_coding_type,
i_structure );
p_vpar->picture.i_l_stride = - 8 + ( p_vpar->sequence.i_width
<< ( 1 - p_vpar->picture.b_frame_structure ) );
p_vpar->picture.i_c_stride = -8 + ( p_vpar->sequence.i_width
<< (( 1 - p_vpar->picture.b_frame_structure ) +
( 3 - p_vpar->sequence.i_chroma_format )) );
p_vpar->picture.i_c_stride = - 8 + ( p_vpar->sequence.i_chroma_width
<< ( 1 - p_vpar->picture.b_frame_structure ));
/* Update the reference pointers. */
ReferenceUpdate( p_vpar, p_vpar->picture.i_coding_type, P_picture );
......@@ -701,8 +700,8 @@ static void PictureHeader( vpar_thread_t * p_vpar )
if( i_structure == BOTTOM_FIELD )
{
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;
p_vpar->mb.i_l_y = 1;
p_vpar->mb.i_c_y = 1;
}
else
{
......
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