Commit b9dc0c52 authored by Christophe Massiot's avatar Christophe Massiot

Nettoyage global. Le vlc se ferme proprement, elem_t devient dctelem_t, le

macroblock perdu a �t� retrouv�, et bien plus...
parent f0be4ee4
......@@ -45,7 +45,7 @@
/* Program version and copyright message */
#define PROGRAM_VERSION "1.0-dev"
#define COPYRIGHT_MESSAGE "VideoLAN Client v" PROGRAM_VERSION " (" __DATE__ ") - " \
PROGRAM_OPTIONS " - (c)1999 VideoLAN"
PROGRAM_OPTIONS " - (c)1999-2000 VideoLAN"
/*******************************************************************************
* General compilation options
......
......@@ -15,9 +15,9 @@
*****************************************************************************/
#ifndef VDEC_DFT
typedef short elem_t;
typedef short dctelem_t;
#else
typedef int elem_t;
typedef int dctelem_t;
#endif
struct vdec_thread_s;
......@@ -143,12 +143,12 @@ struct vdec_thread_s;
/*****************************************************************************
* Function pointers
*****************************************************************************/
typedef void (*f_idct_t)( struct vdec_thread_s *, elem_t*, int );
typedef void (*f_idct_t)( struct vdec_thread_s *, dctelem_t*, int );
/*****************************************************************************
* Prototypes
*****************************************************************************/
void vdec_DummyIDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_DummyIDCT( struct vdec_thread_s *, dctelem_t*, int );
void vdec_InitIDCT (struct vdec_thread_s * p_vdec);
void vdec_SparseIDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_IDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_SparseIDCT( struct vdec_thread_s *, dctelem_t*, int );
void vdec_IDCT( struct vdec_thread_s *, dctelem_t*, int );
......@@ -34,7 +34,7 @@ typedef struct vdec_thread_s
// int *pi_status;
/* idct iformations */
elem_t p_pre_idct[64*64];
dctelem_t p_pre_idct[64*64];
/* Input properties */
struct vpar_thread_s * p_vpar; /* video_parser thread */
......@@ -59,7 +59,7 @@ typedef struct vdec_thread_s
/*****************************************************************************
* Function pointers
*****************************************************************************/
typedef void (*f_addb_t)( vdec_thread_t *, elem_t*, yuv_data_t*, int );
typedef void (*f_addb_t)( vdec_thread_t *, dctelem_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( 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 );
void vdec_AddBlock( vdec_thread_t *, dctelem_t*, yuv_data_t*, int );
void vdec_CopyBlock( vdec_thread_t *, dctelem_t*, yuv_data_t*, int );
void vdec_DummyBlock( vdec_thread_t *, dctelem_t*, yuv_data_t*, int );
......@@ -33,7 +33,7 @@ typedef struct macroblock_s
int i_c_stride; /* idem, for chroma */
/* IDCT information */
elem_t ppi_blocks[12][64]; /* blocks */
dctelem_t ppi_blocks[12][64]; /* blocks */
f_idct_t pf_idct[12]; /* sparse IDCT or not ? */
int pi_sparse_pos[12];
......@@ -131,10 +131,17 @@ extern u8 pi_scan[2][64];
* Prototypes
*****************************************************************************/
void vpar_InitCrop( struct vpar_thread_s* p_vpar );
void vpar_InitMbAddrInc( struct vpar_thread_s * p_vpar );
void vpar_InitPMBType( struct vpar_thread_s * p_vpar );
void vpar_InitBMBType( struct vpar_thread_s * p_vpar );
void vpar_InitCodedPattern( struct vpar_thread_s * p_vpar );
void vpar_InitDCTTables( struct vpar_thread_s * p_vpar );
void vpar_ParseMacroblock( struct vpar_thread_s * p_vpar, int * pi_mb_address,
int i_mb_previous, int i_mb_base );
int vpar_CodedPattern420( struct vpar_thread_s* p_vpar );
int vpar_CodedPattern422( struct vpar_thread_s* p_vpar );
int vpar_CodedPattern444( struct vpar_thread_s* p_vpar );
int vpar_IMBType( struct vpar_thread_s* p_vpar );
int vpar_PMBType( struct vpar_thread_s* p_vpar );
int vpar_BMBType( struct vpar_thread_s* p_vpar );
int vpar_DMBType( struct vpar_thread_s* p_vpar );
int vpar_IMBType( struct vpar_thread_s* p_vpar );
int vpar_PMBType( struct vpar_thread_s* p_vpar );
int vpar_BMBType( struct vpar_thread_s* p_vpar );
int vpar_DMBType( struct vpar_thread_s* p_vpar );
......@@ -32,4 +32,4 @@ void vpar_SynchroTrash( struct vpar_thread_s * p_vpar, int i_coding_type,
int i_structure );
mtime_t vpar_SynchroDecode( struct vpar_thread_s * p_vpar, int i_coding_type,
int i_structure );
void vpar_SynchroEnd( struct vpar_thread_s * p_vpar );
......@@ -341,7 +341,7 @@ static void EndThread( input_thread_t * p_input )
{
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
vdec_DestroyThread( (vdec_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ );
vpar_DestroyThread( (vpar_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ );
break;
case MPEG1_AUDIO_ES:
......
......@@ -44,7 +44,7 @@
* Local prototypes
*/
//extern IDCT_mmx(elem_t*);
//extern IDCT_mmx(dctelem_t*);
/* Our current implementation is a fast DCT, we might move to a fast DFT or
* an MMX DCT in the future. */
......@@ -52,7 +52,7 @@
/*****************************************************************************
* vdec_DummyIDCT : dummy function that does nothing
*****************************************************************************/
void vdec_DummyIDCT( vdec_thread_t * p_vdec, elem_t * p_block,
void vdec_DummyIDCT( vdec_thread_t * p_vdec, dctelem_t * p_block,
int i_idontcare )
{
}
......@@ -66,8 +66,8 @@ void vdec_InitIDCT (vdec_thread_t * p_vdec)
{
int i;
elem_t * p_pre = p_vdec->p_pre_idct;
memset( p_pre, 0, 64*64*sizeof(elem_t) );
dctelem_t * p_pre = p_vdec->p_pre_idct;
memset( p_pre, 0, 64*64*sizeof(dctelem_t) );
for( i=0 ; i < 64 ; i++ )
{
......@@ -76,7 +76,7 @@ void vdec_InitIDCT (vdec_thread_t * p_vdec)
}
}
void vdec_SparseIDCT (vdec_thread_t * p_vdec, elem_t * p_block,
void vdec_SparseIDCT (vdec_thread_t * p_vdec, dctelem_t * p_block,
int i_sparse_pos)
{
short int val;
......@@ -135,7 +135,7 @@ void vdec_SparseIDCT (vdec_thread_t * p_vdec, elem_t * p_block,
/*****************************************************************************
* vdec_IDCT : IDCT function for normal matrices
*****************************************************************************/
void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
void vdec_IDCT( vdec_thread_t * p_vdec, dctelem_t * p_block, int i_idontcare )
{
//IDCT_mmx(p_block);
#if 1
......@@ -143,7 +143,7 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
s32 tmp10, tmp11, tmp12, tmp13;
s32 z1, z2, z3, z4, z5;
s32 d0, d1, d2, d3, d4, d5, d6, d7;
elem_t * dataptr;
dctelem_t * dataptr;
int rowctr;
SHIFT_TEMPS
......@@ -174,7 +174,7 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
if (d0)
{
/* Compute a 32 bit value to assign. */
elem_t dcval = (elem_t) (d0 << PASS1_BITS);
dctelem_t dcval = (dctelem_t) (d0 << PASS1_BITS);
register int v = (dcval & 0xffff) | (dcval << 16);
idataptr[0] = v;
......@@ -727,14 +727,14 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr[0] = (elem_t) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
dataptr[7] = (elem_t) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
dataptr[1] = (elem_t) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
dataptr[6] = (elem_t) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
dataptr[2] = (elem_t) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
dataptr[5] = (elem_t) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
dataptr[3] = (elem_t) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
dataptr[4] = (elem_t) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
dataptr[0] = (dctelem_t) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
dataptr[7] = (dctelem_t) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
dataptr[1] = (dctelem_t) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
dataptr[6] = (dctelem_t) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
dataptr[2] = (dctelem_t) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
dataptr[5] = (dctelem_t) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
dataptr[3] = (dctelem_t) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
dataptr[4] = (dctelem_t) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
dataptr += DCTSIZE; /* advance pointer to next row */
}
......@@ -1294,21 +1294,21 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr[DCTSIZE*0] = (elem_t) DESCALE(tmp10 + tmp3,
dataptr[DCTSIZE*0] = (dctelem_t) DESCALE(tmp10 + tmp3,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*7] = (elem_t) DESCALE(tmp10 - tmp3,
dataptr[DCTSIZE*7] = (dctelem_t) DESCALE(tmp10 - tmp3,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*1] = (elem_t) DESCALE(tmp11 + tmp2,
dataptr[DCTSIZE*1] = (dctelem_t) DESCALE(tmp11 + tmp2,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*6] = (elem_t) DESCALE(tmp11 - tmp2,
dataptr[DCTSIZE*6] = (dctelem_t) DESCALE(tmp11 - tmp2,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*2] = (elem_t) DESCALE(tmp12 + tmp1,
dataptr[DCTSIZE*2] = (dctelem_t) DESCALE(tmp12 + tmp1,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*5] = (elem_t) DESCALE(tmp12 - tmp1,
dataptr[DCTSIZE*5] = (dctelem_t) DESCALE(tmp12 - tmp1,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*3] = (elem_t) DESCALE(tmp13 + tmp0,
dataptr[DCTSIZE*3] = (dctelem_t) DESCALE(tmp13 + tmp0,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*4] = (elem_t) DESCALE(tmp13 - tmp0,
dataptr[DCTSIZE*4] = (dctelem_t) DESCALE(tmp13 - tmp0,
CONST_BITS+PASS1_BITS+3);
dataptr++; /* advance pointer to next column */
......
......@@ -111,6 +111,11 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
/* Ask thread to kill itself */
p_vdec->b_die = 1;
/* Make sure the parser thread leaves the GetByte() function */
vlc_mutex_lock( &(p_vdec->p_vpar->vfifo.lock) );
vlc_cond_signal( &(p_vdec->p_vpar->vfifo.wait) );
vlc_mutex_unlock( &(p_vdec->p_vpar->vfifo.lock) );
/* Waiting for the decoder thread to exit */
/* Remove this as soon as the "status" flag is implemented */
......@@ -128,9 +133,7 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
*******************************************************************************/
static int InitThread( vdec_thread_t *p_vdec )
{
//#ifdef MPEG2_COMPLIANT
int i_dummy;
//#endif
intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec);
......@@ -144,7 +147,6 @@ static int InitThread( vdec_thread_t *p_vdec )
p_vdec->c_decoded_b_pictures = 0;
#endif
//#ifdef MPEG2_COMPLIANT
/* Init crop table */
p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1);
for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
......@@ -159,7 +161,6 @@ static int InitThread( vdec_thread_t *p_vdec )
{
p_vdec->pi_crop[i_dummy] = 255;
}
//#endif
/* Mark thread as running and return */
intf_DbgMsg("vdec debug: InitThread(%p) succeeded\n", p_vdec);
......@@ -194,7 +195,7 @@ static void RunThread( vdec_thread_t *p_vdec )
while( (!p_vdec->b_die) && (!p_vdec->b_error) )
{
macroblock_t * p_mb;
if( (p_mb = vpar_GetMacroblock( &p_vdec->p_vpar->vfifo )) != NULL )
{
DecodeMacroblock( p_vdec, p_mb );
......@@ -255,9 +256,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,29 +266,13 @@ 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_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++ )
{
......@@ -296,21 +281,6 @@ memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
*/
(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)
......@@ -318,7 +288,7 @@ memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
(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.
......@@ -329,7 +299,7 @@ memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
/*******************************************************************************
* vdec_AddBlock : add a block
*******************************************************************************/
void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_data, int i_incr )
void vdec_AddBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, yuv_data_t * p_data, int i_incr )
{
int i_x, i_y;
......@@ -337,12 +307,8 @@ void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_dat
{
for( i_x = 0; i_x < 8; i_x++ )
{
#ifdef MPEG2_COMPLIANT
*p_data = p_vdec->pi_crop[*p_data + *p_block++];
p_data++;
#else
*p_data++ += *p_block++;
#endif
}
p_data += i_incr;
}
......@@ -351,7 +317,7 @@ void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_dat
/*******************************************************************************
* vdec_CopyBlock : copy a block
*******************************************************************************/
void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_data, int i_incr )
void vdec_CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, yuv_data_t * p_data, int i_incr )
{
int i_y;
//fprintf(stderr, "%d ", i_incr );
......@@ -359,7 +325,7 @@ void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_da
for( i_y = 0; i_y < 8; i_y++ )
{
#if 0
/* elem_t and yuv_data_t are the same */
/* dctelem_t and yuv_data_t are the same */
memcpy( p_data, p_block, 8*sizeof(yuv_data_t) );
p_data += i_incr+8;
p_block += 8;
......@@ -380,6 +346,6 @@ void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_da
/*******************************************************************************
* vdec_DummyBlock : dummy function that does nothing
*******************************************************************************/
void vdec_DummyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_data, int i_incr )
void vdec_DummyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, yuv_data_t * p_data, int i_incr )
{
}
......@@ -84,7 +84,7 @@ macroblock_t * vpar_GetMacroblock( video_fifo_t * p_fifo )
p_mb = VIDEO_FIFO_START( *p_fifo );
VIDEO_FIFO_INCSTART( *p_fifo );
vlc_mutex_unlock( &p_fifo->lock );
return( p_mb );
......@@ -99,12 +99,13 @@ macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
#define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock( &P_buffer.lock );
if( P_buffer.i_index == -1 )
while( P_buffer.i_index == -1 )
{
/* No more structures available. This should not happen ! */
msleep(VPAR_IDLE_SLEEP);
return vpar_NewMacroblock( p_fifo );
// return NULL;
intf_DbgMsg("vpar debug: macroblock list is empty, delaying\n");
vlc_mutex_unlock( &P_buffer.lock );
msleep(VPAR_IDLE_SLEEP);
vlc_mutex_lock( &P_buffer.lock );
}
p_mb = P_buffer.pp_mb_free[ P_buffer.i_index-- ];
......@@ -135,12 +136,16 @@ void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
*****************************************************************************/
void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
{
boolean_t b_finished;
/* Unlink picture buffer */
vlc_mutex_lock( &p_mb->p_picture->lock_deccount );
p_mb->p_picture->i_deccount--;
b_finished = (p_mb->p_picture->i_deccount == 1);
vlc_mutex_unlock( &p_mb->p_picture->lock_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 == 1 )
if( b_finished )
{
fprintf(stderr, "Image decodee\n");
/* Mark the picture to be displayed */
......@@ -159,7 +164,6 @@ fprintf(stderr, "Image decodee\n");
vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backward );
}*/
}
vlc_mutex_unlock( &p_mb->p_picture->lock_deccount );
/* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar->vbuffer
......@@ -174,6 +178,35 @@ fprintf(stderr, "Image decodee\n");
*****************************************************************************/
void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
{
boolean_t b_finished;
/* Unlink picture buffer */
vlc_mutex_lock( &p_mb->p_picture->lock_deccount );
p_mb->p_picture->i_deccount--;
b_finished = (p_mb->p_picture->i_deccount == 1);
vlc_mutex_unlock( &p_mb->p_picture->lock_deccount );
/* Test if it was the last block of the picture */
if( b_finished )
{
fprintf(stderr, "Image trashee\n");
/* Mark the picture to be displayed */
vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
/* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar );
/* Unlink referenced pictures */
/* 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 );
}*/
}
/* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock( &P_buffer.lock );
......
......@@ -175,16 +175,6 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar->bit_stream.i_byte = p_vpar->bit_stream.p_ts->i_payload_start;
vlc_mutex_unlock( &p_vpar->fifo.data_lock );
#if 0
/* ?? */
/* Create video stream */
p_vpar->i_stream = vout_CreateStream( p_vpar->p_vout );
if( p_vpar->i_stream < 0 ) /* error */
{
return( 1 );
}
#endif
/* Initialize parsing data */
p_vpar->sequence.p_forward = NULL;
p_vpar->sequence.p_backward = NULL;
......@@ -198,6 +188,9 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar->sequence.i_copyright_id = 0;
p_vpar->sequence.i_copyright_nb = 0;
p_vpar->picture.p_picture = NULL;
p_vpar->picture.i_current_structure = 0;
/* Initialize other properties */
#ifdef STATS
p_vpar->c_loops = 0;
......@@ -214,7 +207,7 @@ static int InitThread( vpar_thread_t *p_vpar )
/* Initialize video FIFO */
vpar_InitFIFO( p_vpar );
bzero( p_vpar->p_vdec, NB_VDEC*sizeof(vdec_thread_t *) );
/* Spawn video_decoder threads */
......
......@@ -42,11 +42,6 @@
/*
* Local prototypes
*/
static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
macroblock_t * p_mb );
static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar );
static __inline__ void MacroblockModes( vpar_thread_t * p_vpar,
macroblock_t * p_mb );
typedef void (*f_decode_block_t)( vpar_thread_t *, macroblock_t *, int );
static void vpar_DecodeMPEG1Non( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b );
static void vpar_DecodeMPEG1Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b );
......@@ -57,7 +52,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
* Initialisation tables
*/
/* Table for coded_block_pattern resolution */
lookup_t pl_coded_pattern_init_table[512] =
static lookup_t pl_coded_pattern_init_table[512] =
{ {MB_ERROR, 0}, {0, 9}, {39, 9}, {27, 9}, {59, 9}, {55, 9}, {47, 9}, {31, 9},
{58, 8}, {58, 8}, {54, 8}, {54, 8}, {46, 8}, {46, 8}, {30, 8}, {30, 8},
{57, 8}, {57, 8}, {53, 8}, {53, 8}, {45, 8}, {45, 8}, {29, 8}, {29, 8},
......@@ -128,7 +123,7 @@ lookup_t pl_coded_pattern_init_table[512] =
*/
/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
lookup_t pl_dct_dc_lum_init_table_1[32] =
static lookup_t pl_dct_dc_lum_init_table_1[32] =
{ {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
{0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
......@@ -136,7 +131,7 @@ lookup_t pl_dct_dc_lum_init_table_1[32] =
};
/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
lookup_t pl_dct_dc_lum_init_table_2[32] =
static lookup_t pl_dct_dc_lum_init_table_2[32] =
{ {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
{8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10,9}, {11,9},
{MB_ERROR, 0}, {MB_ERROR, 0}, {MB_ERROR, 0}, {MB_ERROR, 0},
......@@ -146,7 +141,7 @@ lookup_t pl_dct_dc_lum_init_table_2[32] =
};
/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
lookup_t pl_dct_dc_chrom_init_table_1[32] =
static lookup_t pl_dct_dc_chrom_init_table_1[32] =
{ {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
......@@ -154,7 +149,7 @@ lookup_t pl_dct_dc_chrom_init_table_1[32] =
};
/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
lookup_t pl_dct_dc_chrom_init_table_2[32] =
static lookup_t pl_dct_dc_chrom_init_table_2[32] =
{ {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
{6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
{7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
......@@ -172,7 +167,7 @@ lookup_t pl_dct_dc_chrom_init_table_2[32] =
/* Table B-14, DCT coefficients table zero,
* codes 0100 ... 1xxx (used for first (DC) coefficient)
*/
dct_lookup_t pl_DCT_tab_dc[12] =
static dct_lookup_t pl_DCT_tab_dc[12] =
{
{0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
{0,1,1}, {0,1,1}, {0,1,1}, {0,1,1},
......@@ -182,7 +177,7 @@ dct_lookup_t pl_DCT_tab_dc[12] =
/* Table B-14, DCT coefficients table zero,
* codes 0100 ... 1xxx (used for all other coefficients)
*/
dct_lookup_t pl_DCT_tab_ac[12] =
static dct_lookup_t pl_DCT_tab_ac[12] =
{
{0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
{DCT_EOB,0,2}, {DCT_EOB,0,2}, {DCT_EOB,0,2}, {DCT_EOB,0,2}, /* EOB */
......@@ -192,7 +187,7 @@ dct_lookup_t pl_DCT_tab_ac[12] =
/* Table B-14, DCT coefficients table zero,
* codes 000001xx ... 00111xxx
*/
dct_lookup_t pl_DCT_tab0[60] =
static dct_lookup_t pl_DCT_tab0[60] =
{
{DCT_ESCAPE,0,6}, {DCT_ESCAPE,0,6}, {DCT_ESCAPE,0,6}, {DCT_ESCAPE,0,6},
/* Escape */
......@@ -215,7 +210,7 @@ dct_lookup_t pl_DCT_tab0[60] =
/* Table B-15, DCT coefficients table one,
* codes 000001xx ... 11111111
*/
dct_lookup_t pl_DCT_tab0a[252] =
static dct_lookup_t pl_DCT_tab0a[252] =
{
{65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
{7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
......@@ -282,13 +277,10 @@ dct_lookup_t pl_DCT_tab0a[252] =
{2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}
};
/* Table B-14, DCT coefficients table zero,
* codes 0000001000 ... 0000001111
*/
dct_lookup_t pl_DCT_tab1[8] =
static dct_lookup_t pl_DCT_tab1[8] =
{
{16,1,10}, {5,2,10}, {0,7,10}, {2,3,10},
{1,4,10}, {15,1,10}, {14,1,10}, {4,2,10}
......@@ -297,7 +289,7 @@ dct_lookup_t pl_DCT_tab1[8] =
/* Table B-15, DCT coefficients table one,
* codes 000000100x ... 000000111x
*/
dct_lookup_t pl_DCT_tab1a[8] =
static dct_lookup_t pl_DCT_tab1a[8] =
{
{5,2,9}, {5,2,9}, {14,1,9}, {14,1,9},
{2,4,10}, {16,1,10}, {15,1,9}, {15,1,9}
......@@ -306,7 +298,7 @@ dct_lookup_t pl_DCT_tab1a[8] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 000000010000 ... 000000011111
*/
dct_lookup_t pl_DCT_tab2[16] =
static dct_lookup_t pl_DCT_tab2[16] =
{
{0,11,12}, {8,2,12}, {4,3,12}, {0,10,12},
{2,4,12}, {7,2,12}, {21,1,12}, {20,1,12},
......@@ -317,7 +309,7 @@ dct_lookup_t pl_DCT_tab2[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 0000000010000 ... 0000000011111
*/
dct_lookup_t pl_DCT_tab3[16] =
static dct_lookup_t pl_DCT_tab3[16] =
{
{10,2,13}, {9,2,13}, {5,3,13}, {3,4,13},
{2,5,13}, {1,7,13}, {1,6,13}, {0,15,13},
......@@ -328,7 +320,7 @@ dct_lookup_t pl_DCT_tab3[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 00000000010000 ... 00000000011111
*/
dct_lookup_t pl_DCT_tab4[16] =
static dct_lookup_t pl_DCT_tab4[16] =
{
{0,31,14}, {0,30,14}, {0,29,14}, {0,28,14},
{0,27,14}, {0,26,14}, {0,25,14}, {0,24,14},
......@@ -339,7 +331,7 @@ dct_lookup_t pl_DCT_tab4[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 000000000010000 ... 000000000011111
*/
dct_lookup_t pl_DCT_tab5[16] =
static dct_lookup_t pl_DCT_tab5[16] =
{
{0,40,15}, {0,39,15}, {0,38,15}, {0,37,15},
{0,36,15}, {0,35,15}, {0,34,15}, {0,33,15},
......@@ -350,7 +342,7 @@ dct_lookup_t pl_DCT_tab5[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 0000000000010000 ... 0000000000011111
*/
dct_lookup_t pl_DCT_tab6[16] =
static dct_lookup_t pl_DCT_tab6[16] =
{
{1,18,16}, {1,17,16}, {1,16,16}, {1,15,16},
{6,3,16}, {16,2,16}, {15,2,16}, {14,2,16},
......@@ -392,7 +384,7 @@ void vpar_InitCrop( vpar_thread_t * p_vpar )
*****************************************************************************/
/* Function for filling up the lookup table for mb_addr_inc */
void __inline__ FillMbAddrIncTable( vpar_thread_t * p_vpar,
static void __inline__ FillMbAddrIncTable( vpar_thread_t * p_vpar,
int i_start, int i_end, int i_step,
int * pi_value, int i_length )
{
......@@ -574,6 +566,159 @@ void vpar_InitDCTTables( vpar_thread_t * p_vpar )
* Macroblock parsing functions
*/
/*****************************************************************************
* InitMacroblock : Initialize macroblock values
*****************************************************************************/
static __inline__ void InitMacroblock( vpar_thread_t * p_vpar,
macroblock_t * p_mb )
{
static f_chroma_motion_t pf_chroma_motion[4] =
{ NULL, vdec_Motion420, vdec_Motion422, vdec_Motion444 };
p_mb->p_picture = p_vpar->picture.p_picture;
p_mb->i_structure = p_vpar->picture.i_structure;
p_mb->i_current_structure = p_vpar->picture.i_current_structure;
p_mb->i_l_x = p_vpar->mb.i_l_x;
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->pf_chroma_motion = pf_chroma_motion[p_vpar->sequence.i_chroma_format];
p_mb->b_P_coding_type = ( p_vpar->picture.i_coding_type == P_CODING_TYPE );
p_mb->p_forward = p_vpar->sequence.p_forward;
p_mb->p_backward = p_vpar->sequence.p_backward;
p_mb->i_addb_l_stride = p_mb->i_l_stride = p_vpar->picture.i_l_stride;
p_mb->i_addb_c_stride = 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;
}