#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
-#include "video_parser.h"
-#include "macroblock.h"
-#include "video_fifo.h"
+#include "vdec_idct.h"
#include "video_decoder.h"
+#include "vdec_motion.h"
+
+#include "vpar_blocks.h"
+#include "vpar_headers.h"
+#include "video_fifo.h"
+#include "video_parser.h"
/*****************************************************************************
* vpar_InitFIFO : initialize the video FIFO
int i_dummy;
/* Initialize mutex and cond */
- vlc_mutex_init( p_vpar->vfifo.lock );
- vlc_cond_init( p_vpar->vfifo.wait );
- vlc_mutex_init( p_vpar->vbuffer.lock );
+ vlc_mutex_init( &p_vpar->vfifo.lock );
+ vlc_cond_init( &p_vpar->vfifo.wait );
+ vlc_mutex_init( &p_vpar->vbuffer.lock );
/* Initialize FIFO properties */
p_vpar->vfifo.i_start = p_vpar->vfifo.i_end = 0;
p_vpar->vfifo.p_vpar = p_vpar;
/* Initialize buffer properties */
- i_index = VFIFO_SIZE; /* all structures are available */
+ p_vpar->vbuffer.i_index = VFIFO_SIZE; /* all structures are available */
for( i_dummy = 0; i_dummy < VFIFO_SIZE + 1; i_dummy++ )
{
- p_vpar->vfifo.pp_mb_free[i_dummy] = p_vpar->vfifo.p_macroblocks + i;
+ p_vpar->vbuffer.pp_mb_free[i_dummy] = p_vpar->vbuffer.p_macroblocks
+ + i_dummy;
}
}
{
macroblock_t * p_mb;
-#define P_buffer p_fifo->p_vpar.vbuffer
- vlc_mutex_lock( &P_buffer->lock );
+#define P_buffer p_fifo->p_vpar->vbuffer
+ vlc_mutex_lock( &P_buffer.lock );
if( P_buffer.i_index == -1 )
{
/* No more structures available. This should not happen ! */
return NULL;
}
- p_mb = P_buffer->pp_undec_free[ P_buffer->i_index-- ];
-#undef P_buffer
+ p_mb = P_buffer.pp_mb_free[ P_buffer.i_index-- ];
- vlc_mutex_unlock( &P_buffer->lock );
+ vlc_mutex_unlock( &P_buffer.lock );
+#undef P_buffer
return( p_mb );
}
/* By construction, the video FIFO cannot be full */
VIDEO_FIFO_END( *p_fifo ) = p_mb;
VIDEO_FIFO_INCEND( *p_fifo );
-
+
vlc_mutex_unlock( &p_fifo->lock );
}
/* Unlink referenced pictures */
if( p_mb->p_forw_top != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_top );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forw_top );
}
if( p_mb->p_backw_top != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_backw_top );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backw_top );
}
if( p_mb->p_forw_bot != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_bot );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forw_bot );
}
if( p_mb->p_backw_bot != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_backw_bot );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backw_bot );
}
/* Unlink picture buffer */
if( p_mb->p_picture->i_deccount == 0 )
{
/* Mark the picture to be displayed */
- vout_DisplayPicture( p_fifo->p_vpar.p_vout, p_mb->p_picture );
+ vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
/* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar );
vlc_mutex_unlock( & p_mb->p_picture->lock_deccount );
/* Release the macroblock_t structure */
-#define P_buffer p_fifo->p_vpar.vbuffer
- vlc_mutex_lock( &P_buffer->lock );
- P_buffer->pp_mb_free[ ++P_buffer->i_index ] = p_mb;
- vlc_mutex_unlock( &P_buffer->lock );
+#define P_buffer p_fifo->p_vpar->vbuffer
+ vlc_mutex_lock( &P_buffer.lock );
+ P_buffer.pp_mb_free[ ++P_buffer.i_index ] = p_mb;
+ vlc_mutex_unlock( &P_buffer.lock );
#undef P_buffer
}
/* Unlink referenced pictures */
if( p_mb->p_forw_top != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_top );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forw_top );
}
if( p_mb->p_backw_top != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_backw_top );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backw_top );
}
if( p_mb->p_forw_bot != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_bot );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forw_bot );
}
if( p_mb->p_backw_bot != NULL )
{
- vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_backw_bot );
+ vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backw_bot );
}
/* Release the macroblock_t structure */
-#define P_buffer p_fifo->p_vpar.vbuffer
- vlc_mutex_lock( &P_buffer->lock );
- P_buffer->pp_mb_free[ ++P_buffer->i_index ] = p_mb;
- vlc_mutex_unlock( &P_buffer->lock );
+#define P_buffer p_fifo->p_vpar->vbuffer
+ vlc_mutex_lock( &P_buffer.lock );
+ P_buffer.pp_mb_free[ ++P_buffer.i_index ] = p_mb;
+ vlc_mutex_unlock( &P_buffer.lock );
#undef P_buffer
}
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
-#include "vpar_blocks.h"
-#include "video_parser.h"
-#include "macroblock.h"
-#include "video_fifo.h"
+#include "vdec_idct.h"
#include "video_decoder.h"
+#include "vdec_motion.h"
+
+#include "vpar_blocks.h"
+#include "vpar_headers.h"
+#include "video_fifo.h"
+#include "video_parser.h"
/*
* Local prototypes
*/
static __inline__ void NextStartCode( vpar_thread_t * p_vpar );
-static void GroupHeader( vpar_thread_t * p_vpar )
-static void PictureHeader( vpar_thread_t * p_vpar )
+static void SequenceHeader( vpar_thread_t * p_vpar );
+static void GroupHeader( vpar_thread_t * p_vpar );
+static void PictureHeader( vpar_thread_t * p_vpar );
static void __inline__ ReferenceUpdate( vpar_thread_t * p_vpar,
int i_coding_type,
- picture_t * p_newref )
+ picture_t * p_newref );
static void __inline__ ReferenceReplace( vpar_thread_t * p_vpar,
int i_coding_type,
- picture_t * p_newref )
+ picture_t * p_newref );
static void SliceHeader00( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base,
- elem_t * p_y, p_u, p_v, u32 i_vert_code )
+ u32 i_vert_code );
static void SliceHeader01( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base,
- elem_t * p_y, p_u, p_v, u32 i_vert_code )
+ u32 i_vert_code );
static void SliceHeader10( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base,
- elem_t * p_y, p_u, p_v, u32 i_vert_code )
+ u32 i_vert_code );
static void SliceHeader11( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base,
- elem_t * p_y, p_u, p_v, u32 i_vert_code )
+ u32 i_vert_code );
static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base,
- elem_t * p_y, p_u, p_v, u32 i_vert_code )
-static void ExtensionAndUserData( vpar_thread_t * p_vpar )
+ u32 i_vert_code );
+static void ExtensionAndUserData( vpar_thread_t * p_vpar );
+static void QuantMatrixExtension( vpar_thread_t * p_vpar );
+static void SequenceScalableExtension( vpar_thread_t * p_vpar );
+static void SequenceDisplayExtension( vpar_thread_t * p_vpar );
+static void PictureDisplayExtension( vpar_thread_t * p_vpar );
+static void PictureSpatialScalableExtension( vpar_thread_t * p_vpar );
+static void PictureTemporalScalableExtension( vpar_thread_t * p_vpar );
+static void CopyrightExtension( vpar_thread_t * p_vpar );
+static __inline__ void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix );
+static __inline__ void LinkMatrix( quant_matrix_t * p_matrix, int * pi_array );
/*****************************************************************************
* vpar_NextSequenceHeader : Find the next sequence header
while( !p_vpar->b_die )
{
NextStartCode( p_vpar );
- if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_START_CODE )
+ if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_HEADER_CODE )
return 0;
}
return 1;
i_height_save = p_vpar->sequence.i_height;
i_width_save = p_vpar->sequence.i_width;
- p_vpar->sequence.i_height = GetBits( p_vpar->bit_stream, 12 );
- p_vpar->sequence.i_width = GetBits( p_vpar->bit_stream, 12 );
- p_vpar->sequence.i_ratio = GetBits( p_vpar->bit_stream, 4 );
+ p_vpar->sequence.i_height = GetBits( &p_vpar->bit_stream, 12 );
+ p_vpar->sequence.i_width = GetBits( &p_vpar->bit_stream, 12 );
+ p_vpar->sequence.i_aspect_ratio = GetBits( &p_vpar->bit_stream, 4 );
p_vpar->sequence.d_frame_rate =
- d_frame_rate_table( GetBits( p_vpar->bit_stream, 4 ) );
+ d_frame_rate_table[ GetBits( &p_vpar->bit_stream, 4 ) ];
/* We don't need bit_rate_value, marker_bit, vbv_buffer_size,
* constrained_parameters_flag */
- DumpBits( p_vpar->bit_stream, 30 );
+ DumpBits( &p_vpar->bit_stream, 30 );
/*
* Quantization matrices
*/
- if( GetBits( p_vpar->bit_stream, 1 ) ) /* load_intra_quantizer_matrix */
+ if( GetBits( &p_vpar->bit_stream, 1 ) ) /* load_intra_quantizer_matrix */
{
LoadMatrix( p_vpar, &p_vpar->sequence.intra_quant );
}
LinkMatrix( &p_vpar->sequence.intra_quant, pi_default_intra_quant );
}
- if( GetBits( p_vpar->bit_stream, 1 ) ) /* load_non_intra_quantizer_matrix */
+ if( GetBits( &p_vpar->bit_stream, 1 ) ) /* load_non_intra_quantizer_matrix */
{
LoadMatrix( p_vpar, &p_vpar->sequence.nonintra_quant );
}
NextStartCode( p_vpar );
if( ShowBits( &p_vpar->bit_stream, 32 ) == EXTENSION_START_CODE )
{
- int i_dummy;
- static int pi_chroma_nb_blocks[4] = {0, 1, 2, 4};
- static (void *) ppf_chroma_pattern[4]( vpar_thread_t * ) =
+ int i_dummy;
+ static int pi_chroma_nb_blocks[4] = {0, 1, 2, 4};
+ static f_chroma_pattern_t ppf_chroma_pattern[4] =
{NULL, vpar_CodedPattern420,
vpar_CodedPattern422, vpar_CodedPattern444};
/* It's an MPEG-1 stream. Put adequate parameters. */
p_vpar->sequence.b_progressive = 1;
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_width = p_vpar->sequence.i_width >> 2;
p_vpar->sequence.i_chroma_nb_blocks = 2;
p_vpar->sequence.pf_decode_pattern = vpar_CodedPattern420;
}
if( p_vpar->sequence.i_width != i_width_save
- || p_vpar->sequence.i_height != i_height_save
- || p_vpar->sequence.p_frame_lum_lookup == NULL )
+ || p_vpar->sequence.i_height != i_height_save )
{
-
+ /* What do we do in case of a size change ??? */
}
/* Extension and User data */
*****************************************************************************/
static void PictureHeader( vpar_thread_t * p_vpar )
{
- static (int *) ppf_macroblock_type[4] = {vpar_IMBType, vpar_PMBType,
+ static f_macroblock_type_t ppf_macroblock_type[4] =
+ {vpar_IMBType, vpar_PMBType,
vpar_BMBType, vpar_DMBType};
int i_structure;
p_vpar->picture.b_q_scale_type = GetBits( &p_vpar->bit_stream, 1 );
p_vpar->picture.b_intra_vlc_format = GetBits( &p_vpar->bit_stream, 1 );
p_vpar->picture.b_alternate_scan = GetBits( &p_vpar->bit_stream, 1 );
- p_vpar->picture.b_repeat_first_field = GetBits( &vpar->bit_stream, 1 );
+ p_vpar->picture.b_repeat_first_field = GetBits( &p_vpar->bit_stream, 1 );
/* repeat_first_field (ISO/IEC 13818-2 6.3.10 is necessary to know
* the length of the picture_display_extension structure.
* chroma_420_type (obsolete) */
else
{
/* MPEG-1 compatibility flags */
- p_vpar->i_intra_dc_precision = 0; /* 8 bits */
+ p_vpar->picture.i_intra_dc_precision = 0; /* 8 bits */
i_structure = FRAME_STRUCTURE;
- p_vpar->b_frame_pred_frame_dct = TRUE;
+ p_vpar->picture.b_frame_pred_frame_dct = 1;
p_vpar->picture.b_concealment_mv = 0;
p_vpar->picture.b_q_scale_type = 0;
p_vpar->picture.b_intra_vlc_format = 0;
p_vpar->picture.b_alternate_scan = 0; /* zigzag */
- b_repeat_first_field = FALSE;
- p_vpar->picture.b_progressive_frame = TRUE;
+ p_vpar->picture.b_repeat_first_field = 0;
+ p_vpar->picture.b_progressive_frame = 1;
}
if( p_vpar->picture.i_current_structure &&
i_structure == p_vpar->picture.i_current_structure) )
{
/* We don't have the second field of the buffered frame. */
- if( p_pvar->picture.p_picture != NULL )
+ if( p_vpar->picture.p_picture != NULL )
{
ReferenceReplace( p_vpar,
- p_vpar->picture.p_second_field_buffer->i_coding_type,
+ p_vpar->picture.i_coding_type,
NULL );
for( i_mb = 0; i_mb < p_vpar->sequence.i_mb_size >> 1; i_mb++ )
vout_DestroyPicture( p_vpar->p_vout, p_vpar->picture.p_picture );
}
- p_pvar->picture.i_current_structure = 0;
+ p_vpar->picture.i_current_structure = 0;
intf_DbgMsg("vpar debug: odd number of field picture.");
}
{
/* Second field of a frame. We will decode it if, and only if we
* have decoded the first frame. */
- b_parsable = (p_vpar->picture.p_second_field_buffer != NULL);
+ b_parsable = (p_vpar->picture.p_picture != NULL);
}
else
{
/* Do we have the reference pictures ? */
- b_parsable = !((i_coding_type == P_CODING_TYPE) &&
+ b_parsable = !((p_vpar->picture.i_coding_type == P_CODING_TYPE) &&
(p_vpar->sequence.p_forward == NULL)) ||
- ((i_coding_type == B_CODING_TYPE) &&
+ ((p_vpar->picture.i_coding_type == B_CODING_TYPE) &&
(p_vpar->sequence.p_forward == NULL ||
p_vpar->sequence.p_backward == NULL));
- /* Does synchro say we have enough time to decode it ? */
- b_parsable &&= vpar_SynchroChoose( p_vpar, i_coding_type, i_structure );
+ if( b_parsable )
+ {
+ /* Does synchro say we have enough time to decode it ? */
+ b_parsable = vpar_SynchroChoose( p_vpar,
+ p_vpar->picture.i_coding_type, i_structure );
+ }
}
if( !b_parsable )
{
/* Update the reference pointers. */
- ReferenceUpdate( p_vpar, i_coding_type, NULL );
+ ReferenceUpdate( p_vpar, p_vpar->picture.i_coding_type, NULL );
/* Warn Synchro we have trashed a picture. */
- vpar_SynchroTrash( p_vpar, i_coding_type, i_structure );
+ vpar_SynchroTrash( p_vpar, p_vpar->picture.i_coding_type, i_structure );
/* Update context. */
if( i_structure != FRAME_STRUCTURE )
/* OK, now we are sure we will decode the picture. */
#define P_picture p_vpar->picture.p_picture
- p_vpar->picture.b_error = FALSE;
+ p_vpar->picture.b_error = 0;
if( !p_vpar->picture.i_current_structure )
{
p_vpar->sequence.i_chroma_format );
/* Initialize values. */
- P_picture->date = vpar_SynchroDecode( p_vpar, i_coding_type,
+ P_picture->date = vpar_SynchroDecode( p_vpar,
+ p_vpar->picture.i_coding_type,
i_structure );
p_vpar->picture.i_lum_incr = - 8 + ( p_vpar->sequence.i_width
<< ( i_structure != FRAME_STRUCTURE ) );
( 3 - p_vpar->sequence.i_chroma_format )) );
/* Update the reference pointers. */
- ReferenceUpdate( p_vpar, i_coding_type, p_picture );
+ ReferenceUpdate( p_vpar, p_vpar->picture.i_coding_type, P_picture );
}
p_vpar->picture.i_current_structure |= i_structure;
p_vpar->picture.i_structure = i_structure;
(i_dummy > SLICE_START_CODE_MAX) )
{
intf_DbgMsg("vpar debug: premature end of picture");
- p_vpar->picture.b_error = TRUE;
+ p_vpar->picture.b_error = 1;
break;
}
DumpBits32( &p_vpar->bit_stream );
vout_DestroyPicture( p_vpar->p_vout, P_picture );
/* Prepare context for the next picture. */
- P_picture = NULL:
+ P_picture = NULL;
}
else if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE )
{
/* Reset DC coefficients predictors (ISO/IEC 13818-2 7.2.1). Why
* does the reference decoder put 0 instead of the normative values ? */
- p_vpar->slice.pi_dct_pred[0] = p_vpar->slice.pi_dct_pred[1]
- = p_vpar->slice.pi_dct_pred[2]
+ p_vpar->slice.pi_dc_dct_pred[0] = p_vpar->slice.pi_dc_dct_pred[1]
+ = p_vpar->slice.pi_dc_dct_pred[2]
= pi_dc_dct_reinit[p_vpar->picture.i_intra_dc_precision];
/* Reset motion vector predictors (ISO/IEC 13818-2 7.6.3.4). */
if( GetBits( &p_vpar->bit_stream, 1 ) )
{
/* Load non_intra_quantiser_matrix for luminance. */
- LoadMatrix( p_vpar, &p_vpar->sequence.non_intra_quant );
+ LoadMatrix( p_vpar, &p_vpar->sequence.nonintra_quant );
}
else
{
{
/* Link the chrominance intra matrix to the luminance one. */
LinkMatrix( &p_vpar->sequence.chroma_intra_quant,
- &p_vpar->sequence.intra_quant );
+ p_vpar->sequence.intra_quant.pi_matrix );
}
if( GetBits( &p_vpar->bit_stream, 1 ) )
{
{
/* Link the chrominance intra matrix to the luminance one. */
LinkMatrix( &p_vpar->sequence.chroma_intra_quant,
- &p_vpar->sequence.intra_quant );
+ p_vpar->sequence.intra_quant.pi_matrix );
}
if( GetBits( &p_vpar->bit_stream, 1 ) )
{
{
/* Link the chrominance nonintra matrix to the luminance one. */
LinkMatrix( &p_vpar->sequence.chroma_nonintra_quant,
- &p_vpar->sequence.nonintra_quant );
+ p_vpar->sequence.nonintra_quant.pi_matrix );
}
}
* CopyrightExtension : Keeps some legal informations *
*****************************************************************************/
-static void CopytrightExtension( vpar_thread_t * p_vpar )
+static void CopyrightExtension( vpar_thread_t * p_vpar )
{
u32 i_copyright_nb_1, i_copyright_nb_2; /* local integers */
p_vpar->sequence.b_copyright_flag = GetBits( &p_vpar->bit_stream, 1 );
i_copyright_nb_2 = GetBits( &p_vpar->bit_stream, 22 );
DumpBits( &p_vpar->bit_stream, 1 );
/* third part and sum */
- p_vpar->sequence.i_copyright_nb = ( i_copyright_nb_1 << 44 ) +
- ( i_copyright_nb_2 << 22 ) +
- ( GetBits( &p_vpar->bit_stream, 22 ) );
+ p_vpar->sequence.i_copyright_nb = ( (u64)i_copyright_nb_1 << 44 ) +
+ ( (u64)i_copyright_nb_2 << 22 ) +
+ ( (u64)GetBits( &p_vpar->bit_stream, 22 ) );
}
/*****************************************************************************
* LoadMatrix : Load a quantization matrix
*****************************************************************************/
-static void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix )
+static __inline__ void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix )
{
int i_dummy;
{
/* Allocate a piece of memory to load the matrix. */
p_matrix->pi_matrix = (int *)malloc( 64*sizeof(int) );
- p_matrix->b_allocated = TRUE;
+ p_matrix->b_allocated = 1;
}
for( i_dummy = 0; i_dummy < 64; i_dummy++ )
{
p_matrix->pi_matrix[pi_scan[SCAN_ZIGZAG][i_dummy]]
- = GetBits( p_vpar->bit_stream, 8 );
+ = GetBits( &p_vpar->bit_stream, 8 );
}
#ifdef FOURIER_IDCT
/*****************************************************************************
* LinkMatrix : Link a quantization matrix to another
*****************************************************************************/
-static void LinkMatrix( quant_matrix_t * p_matrix, int * pi_array )
+static __inline__ void LinkMatrix( quant_matrix_t * p_matrix, int * pi_array )
{
int i_dummy;
{
/* Deallocate the piece of memory. */
free( p_matrix->pi_matrix );
- p_matrix->b_allocated = FALSE;
+ p_matrix->b_allocated = 0;
}
p_matrix->pi_matrix = pi_array;