Le gros bug est mort.
#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
* 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
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 */
/*****************************************************************************
* 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
/* 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 );
* 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. */
int coeff, rr;
/* If DC Coefficient. */
-
if ( i_sparse_pos == 0 )
{
dp=(int *)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;
dataptr++; /* advance pointer to next column */
}
+#endif
}
*******************************************************************************/
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);
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 ++ )
{
{
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);
* 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)
(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++ )
{
*/
(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.
/*******************************************************************************
* 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;
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++;
/*******************************************************************************
* 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;
{
/* ??? 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
/*******************************************************************************
* 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 )
{
}
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-- ];
/* 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 );
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
* Macroblock parsing functions
*/
+
/*****************************************************************************
* vpar_ParseMacroblock : Parse the next macroblock
*****************************************************************************/
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;
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]
/* 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
{
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;
/* 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
{
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;
/* 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;
: 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;
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 );
{
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;
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 );
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
{