Commit ea23960c authored by Christophe Massiot's avatar Christophe Massiot

video_fifo.c et vpar_headers.c compilent � peu pr�s. Correction d'environ

4212 fautes de frappe.
parent 56bb1291
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
***************************************************************************** *****************************************************************************
* This rotative FIFO contains undecoded macroblocks that are to be decoded * This rotative FIFO contains undecoded macroblocks that are to be decoded
*****************************************************************************/ *****************************************************************************/
struct video_parser_s; struct vpar_thread_s;
typedef struct video_fifo_s typedef struct video_fifo_s
{ {
...@@ -43,7 +43,7 @@ typedef struct video_fifo_s ...@@ -43,7 +43,7 @@ typedef struct video_fifo_s
int i_start; int i_start;
int i_end; int i_end;
struct video_parser_s * p_vpar; struct vpar_thread_s * p_vpar;
} video_fifo_t; } video_fifo_t;
/***************************************************************************** /*****************************************************************************
......
...@@ -77,3 +77,15 @@ typedef struct ...@@ -77,3 +77,15 @@ typedef struct
#define MOTION_FRAME 2 #define MOTION_FRAME 2
#define MOTION_16X8 2 #define MOTION_16X8 2
#define MOTION_DMV 3 #define MOTION_DMV 3
/*****************************************************************************
* Prototypes
*****************************************************************************/
void vpar_CodedPattern420( struct vpar_thread_s* p_vpar );
void vpar_CodedPattern422( struct vpar_thread_s* p_vpar );
void 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 );
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
*****************************************************************************/ *****************************************************************************/
struct vpar_thread_s; struct vpar_thread_s;
typedef void (*f_slice_header_t)( struct vpar_thread_s*, int*, int, elem_t*, u32); typedef void (*f_slice_header_t)( struct vpar_thread_s*, int*, int, u32);
typedef void (*f_chroma_pattern_t)( struct vpar_thread_s* );
typedef int (*f_macroblock_type_t)( struct vpar_thread_s* );
/***************************************************************************** /*****************************************************************************
* quant_matrix_t : Quantization Matrix * quant_matrix_t : Quantization Matrix
...@@ -53,7 +55,7 @@ typedef struct sequence_s ...@@ -53,7 +55,7 @@ typedef struct sequence_s
quant_matrix_t intra_quant, nonintra_quant; quant_matrix_t intra_quant, nonintra_quant;
quant_matrix_t chroma_intra_quant, chroma_nonintra_quant; quant_matrix_t chroma_intra_quant, chroma_nonintra_quant;
void (*pf_decode_mv)( struct vpar_thread_s *, int ); void (*pf_decode_mv)( struct vpar_thread_s *, int );
void (*pf_decode_pattern)( struct vpar_thread_s * ); f_chroma_pattern_t pf_decode_pattern;
/* Parser context */ /* Parser context */
picture_t * p_forward; picture_t * p_forward;
...@@ -79,6 +81,7 @@ typedef struct picture_parsing_s ...@@ -79,6 +81,7 @@ typedef struct picture_parsing_s
int ppi_f_code[2][2]; int ppi_f_code[2][2];
int i_intra_dc_precision; int i_intra_dc_precision;
boolean_t b_frame_pred_frame_dct, b_q_scale_type; boolean_t b_frame_pred_frame_dct, b_q_scale_type;
boolean_t b_intra_vlc_format;
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;
...@@ -93,7 +96,7 @@ typedef struct picture_parsing_s ...@@ -93,7 +96,7 @@ typedef struct picture_parsing_s
/* Relative to the current field */ /* Relative to the current field */
int i_coding_type, i_structure; int i_coding_type, i_structure;
boolean_t b_frame_structure; boolean_t b_frame_structure;
int (*pf_macroblock_type)( struct vpar_thread_s * ); f_macroblock_type_t pf_macroblock_type;
boolean_t b_error; boolean_t b_error;
} picture_parsing_t; } picture_parsing_t;
......
...@@ -28,11 +28,15 @@ ...@@ -28,11 +28,15 @@
#include "decoder_fifo.h" #include "decoder_fifo.h"
#include "video.h" #include "video.h"
#include "video_output.h" #include "video_output.h"
#include "video_parser.h"
#include "macroblock.h" #include "vdec_idct.h"
#include "video_fifo.h"
#include "video_decoder.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 * vpar_InitFIFO : initialize the video FIFO
...@@ -42,19 +46,20 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar ) ...@@ -42,19 +46,20 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar )
int i_dummy; int i_dummy;
/* Initialize mutex and cond */ /* Initialize mutex and cond */
vlc_mutex_init( p_vpar->vfifo.lock ); vlc_mutex_init( &p_vpar->vfifo.lock );
vlc_cond_init( p_vpar->vfifo.wait ); vlc_cond_init( &p_vpar->vfifo.wait );
vlc_mutex_init( p_vpar->vbuffer.lock ); vlc_mutex_init( &p_vpar->vbuffer.lock );
/* Initialize FIFO properties */ /* Initialize FIFO properties */
p_vpar->vfifo.i_start = p_vpar->vfifo.i_end = 0; p_vpar->vfifo.i_start = p_vpar->vfifo.i_end = 0;
p_vpar->vfifo.p_vpar = p_vpar; p_vpar->vfifo.p_vpar = p_vpar;
/* Initialize buffer properties */ /* 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++ ) 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;
} }
} }
...@@ -91,18 +96,18 @@ macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo ) ...@@ -91,18 +96,18 @@ macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
{ {
macroblock_t * p_mb; macroblock_t * p_mb;
#define P_buffer p_fifo->p_vpar.vbuffer #define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock( &P_buffer->lock ); vlc_mutex_lock( &P_buffer.lock );
if( P_buffer.i_index == -1 ) if( P_buffer.i_index == -1 )
{ {
/* No more structures available. This should not happen ! */ /* No more structures available. This should not happen ! */
return NULL; return NULL;
} }
p_mb = P_buffer->pp_undec_free[ P_buffer->i_index-- ]; p_mb = P_buffer.pp_mb_free[ P_buffer.i_index-- ];
#undef P_buffer
vlc_mutex_unlock( &P_buffer->lock ); vlc_mutex_unlock( &P_buffer.lock );
#undef P_buffer
return( p_mb ); return( p_mb );
} }
...@@ -117,7 +122,7 @@ void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb ) ...@@ -117,7 +122,7 @@ void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
/* By construction, the video FIFO cannot be full */ /* By construction, the video FIFO cannot be full */
VIDEO_FIFO_END( *p_fifo ) = p_mb; VIDEO_FIFO_END( *p_fifo ) = p_mb;
VIDEO_FIFO_INCEND( *p_fifo ); VIDEO_FIFO_INCEND( *p_fifo );
vlc_mutex_unlock( &p_fifo->lock ); vlc_mutex_unlock( &p_fifo->lock );
} }
...@@ -130,19 +135,19 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb ) ...@@ -130,19 +135,19 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
/* Unlink referenced pictures */ /* Unlink referenced pictures */
if( p_mb->p_forw_top != NULL ) 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 ) 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 ) 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 ) 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 */ /* Unlink picture buffer */
...@@ -151,7 +156,7 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb ) ...@@ -151,7 +156,7 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
if( p_mb->p_picture->i_deccount == 0 ) if( p_mb->p_picture->i_deccount == 0 )
{ {
/* Mark the picture to be displayed */ /* 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. */ /* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar ); vpar_SynchroEnd( p_fifo->p_vpar );
...@@ -159,10 +164,10 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb ) ...@@ -159,10 +164,10 @@ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
vlc_mutex_unlock( & p_mb->p_picture->lock_deccount ); vlc_mutex_unlock( & p_mb->p_picture->lock_deccount );
/* Release the macroblock_t structure */ /* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar.vbuffer #define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock( &P_buffer->lock ); vlc_mutex_lock( &P_buffer.lock );
P_buffer->pp_mb_free[ ++P_buffer->i_index ] = p_mb; P_buffer.pp_mb_free[ ++P_buffer.i_index ] = p_mb;
vlc_mutex_unlock( &P_buffer->lock ); vlc_mutex_unlock( &P_buffer.lock );
#undef P_buffer #undef P_buffer
} }
...@@ -174,25 +179,25 @@ void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb ) ...@@ -174,25 +179,25 @@ void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
/* Unlink referenced pictures */ /* Unlink referenced pictures */
if( p_mb->p_forw_top != NULL ) 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 ) 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 ) 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 ) 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 */ /* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar.vbuffer #define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock( &P_buffer->lock ); vlc_mutex_lock( &P_buffer.lock );
P_buffer->pp_mb_free[ ++P_buffer->i_index ] = p_mb; P_buffer.pp_mb_free[ ++P_buffer.i_index ] = p_mb;
vlc_mutex_unlock( &P_buffer->lock ); vlc_mutex_unlock( &P_buffer.lock );
#undef P_buffer #undef P_buffer
} }
...@@ -28,41 +28,54 @@ ...@@ -28,41 +28,54 @@
#include "decoder_fifo.h" #include "decoder_fifo.h"
#include "video.h" #include "video.h"
#include "video_output.h" #include "video_output.h"
#include "vpar_blocks.h"
#include "video_parser.h"
#include "macroblock.h" #include "vdec_idct.h"
#include "video_fifo.h"
#include "video_decoder.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 * Local prototypes
*/ */
static __inline__ void NextStartCode( vpar_thread_t * p_vpar ); static __inline__ void NextStartCode( vpar_thread_t * p_vpar );
static void GroupHeader( vpar_thread_t * p_vpar ) static void SequenceHeader( vpar_thread_t * p_vpar );
static void PictureHeader( 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, static void __inline__ ReferenceUpdate( vpar_thread_t * p_vpar,
int i_coding_type, int i_coding_type,
picture_t * p_newref ) picture_t * p_newref );
static void __inline__ ReferenceReplace( vpar_thread_t * p_vpar, static void __inline__ ReferenceReplace( vpar_thread_t * p_vpar,
int i_coding_type, int i_coding_type,
picture_t * p_newref ) picture_t * p_newref );
static void SliceHeader00( vpar_thread_t * p_vpar, static void SliceHeader00( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base, 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, static void SliceHeader01( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base, 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, static void SliceHeader10( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base, 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, static void SliceHeader11( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base, 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, static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
int * pi_mb_address, int i_mb_base, 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 ExtensionAndUserData( vpar_thread_t * p_vpar ) 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 * vpar_NextSequenceHeader : Find the next sequence header
...@@ -72,7 +85,7 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar ) ...@@ -72,7 +85,7 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar )
while( !p_vpar->b_die ) while( !p_vpar->b_die )
{ {
NextStartCode( p_vpar ); 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 0;
} }
return 1; return 1;
...@@ -158,20 +171,20 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -158,20 +171,20 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
i_height_save = p_vpar->sequence.i_height; i_height_save = p_vpar->sequence.i_height;
i_width_save = p_vpar->sequence.i_width; i_width_save = p_vpar->sequence.i_width;
p_vpar->sequence.i_height = GetBits( p_vpar->bit_stream, 12 ); 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_width = GetBits( &p_vpar->bit_stream, 12 );
p_vpar->sequence.i_ratio = GetBits( p_vpar->bit_stream, 4 ); p_vpar->sequence.i_aspect_ratio = GetBits( &p_vpar->bit_stream, 4 );
p_vpar->sequence.d_frame_rate = 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, /* We don't need bit_rate_value, marker_bit, vbv_buffer_size,
* constrained_parameters_flag */ * constrained_parameters_flag */
DumpBits( p_vpar->bit_stream, 30 ); DumpBits( &p_vpar->bit_stream, 30 );
/* /*
* Quantization matrices * 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 ); LoadMatrix( p_vpar, &p_vpar->sequence.intra_quant );
} }
...@@ -181,7 +194,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -181,7 +194,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
LinkMatrix( &p_vpar->sequence.intra_quant, pi_default_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 ); LoadMatrix( p_vpar, &p_vpar->sequence.nonintra_quant );
} }
...@@ -204,9 +217,9 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -204,9 +217,9 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
NextStartCode( p_vpar ); NextStartCode( 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 int pi_chroma_nb_blocks[4] = {0, 1, 2, 4};
static (void *) ppf_chroma_pattern[4]( vpar_thread_t * ) = static f_chroma_pattern_t ppf_chroma_pattern[4] =
{NULL, vpar_CodedPattern420, {NULL, vpar_CodedPattern420,
vpar_CodedPattern422, vpar_CodedPattern444}; vpar_CodedPattern422, vpar_CodedPattern444};
...@@ -239,7 +252,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -239,7 +252,7 @@ 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_width = p_vpar->sequence.i_width >> 2;
p_vpar->sequence.i_chroma_nb_blocks = 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;
...@@ -282,10 +295,9 @@ static void SequenceHeader( vpar_thread_t * p_vpar ) ...@@ -282,10 +295,9 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
} }
if( p_vpar->sequence.i_width != i_width_save if( p_vpar->sequence.i_width != i_width_save
|| p_vpar->sequence.i_height != i_height_save || p_vpar->sequence.i_height != i_height_save )
|| p_vpar->sequence.p_frame_lum_lookup == NULL )
{ {
/* What do we do in case of a size change ??? */
} }
/* Extension and User data */ /* Extension and User data */
...@@ -307,7 +319,8 @@ static void GroupHeader( vpar_thread_t * p_vpar ) ...@@ -307,7 +319,8 @@ static void GroupHeader( vpar_thread_t * p_vpar )
*****************************************************************************/ *****************************************************************************/
static void PictureHeader( vpar_thread_t * p_vpar ) 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}; vpar_BMBType, vpar_DMBType};
int i_structure; int i_structure;
...@@ -358,7 +371,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -358,7 +371,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->picture.b_q_scale_type = GetBits( &p_vpar->bit_stream, 1 ); 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_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_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 /* repeat_first_field (ISO/IEC 13818-2 6.3.10 is necessary to know
* the length of the picture_display_extension structure. * the length of the picture_display_extension structure.
* chroma_420_type (obsolete) */ * chroma_420_type (obsolete) */
...@@ -376,15 +389,15 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -376,15 +389,15 @@ static void PictureHeader( vpar_thread_t * p_vpar )
else else
{ {
/* MPEG-1 compatibility flags */ /* 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; 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_concealment_mv = 0;
p_vpar->picture.b_q_scale_type = 0; p_vpar->picture.b_q_scale_type = 0;
p_vpar->picture.b_intra_vlc_format = 0; p_vpar->picture.b_intra_vlc_format = 0;
p_vpar->picture.b_alternate_scan = 0; /* zigzag */ p_vpar->picture.b_alternate_scan = 0; /* zigzag */
b_repeat_first_field = FALSE; p_vpar->picture.b_repeat_first_field = 0;
p_vpar->picture.b_progressive_frame = TRUE; p_vpar->picture.b_progressive_frame = 1;
} }
if( p_vpar->picture.i_current_structure && if( p_vpar->picture.i_current_structure &&
...@@ -392,10 +405,10 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -392,10 +405,10 @@ static void PictureHeader( vpar_thread_t * p_vpar )
i_structure == 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. */ /* 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, ReferenceReplace( p_vpar,
p_vpar->picture.p_second_field_buffer->i_coding_type, p_vpar->picture.i_coding_type,
NULL ); NULL );
for( i_mb = 0; i_mb < p_vpar->sequence.i_mb_size >> 1; i_mb++ ) for( i_mb = 0; i_mb < p_vpar->sequence.i_mb_size >> 1; i_mb++ )
...@@ -406,7 +419,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -406,7 +419,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
vout_DestroyPicture( p_vpar->p_vout, p_vpar->picture.p_picture ); 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."); intf_DbgMsg("vpar debug: odd number of field picture.");
} }
...@@ -415,28 +428,32 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -415,28 +428,32 @@ static void PictureHeader( vpar_thread_t * p_vpar )
{ {
/* Second field of a frame. We will decode it if, and only if we /* Second field of a frame. We will decode it if, and only if we
* have decoded the first frame. */ * have decoded the first frame. */
b_parsable = (p_vpar->picture.p_second_field_buffer != NULL); b_parsable = (p_vpar->picture.p_picture != NULL);
} }
else else
{ {
/* Do we have the reference pictures ? */ /* 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)) || (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_forward == NULL ||
p_vpar->sequence.p_backward == NULL)); p_vpar->sequence.p_backward == NULL));
/* Does synchro say we have enough time to decode it ? */ if( b_parsable )
b_parsable &&= vpar_SynchroChoose( p_vpar, i_coding_type, i_structure ); {
/* 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 ) if( !b_parsable )
{ {
/* Update the reference pointers. */ /* 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. */ /* 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. */ /* Update context. */
if( i_structure != FRAME_STRUCTURE ) if( i_structure != FRAME_STRUCTURE )
...@@ -448,7 +465,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -448,7 +465,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
/* OK, now we are sure we will decode the picture. */ /* OK, now we are sure we will decode the picture. */
#define P_picture p_vpar->picture.p_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 ) if( !p_vpar->picture.i_current_structure )
{ {
...@@ -460,7 +477,8 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -460,7 +477,8 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->sequence.i_chroma_format ); p_vpar->sequence.i_chroma_format );
/* Initialize values. */ /* 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 ); i_structure );
p_vpar->picture.i_lum_incr = - 8 + ( p_vpar->sequence.i_width p_vpar->picture.i_lum_incr = - 8 + ( p_vpar->sequence.i_width
<< ( i_structure != FRAME_STRUCTURE ) ); << ( i_structure != FRAME_STRUCTURE ) );
...@@ -469,7 +487,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -469,7 +487,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
( 3 - p_vpar->sequence.i_chroma_format )) ); ( 3 - p_vpar->sequence.i_chroma_format )) );
/* Update the reference pointers. */ /* 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_current_structure |= i_structure;
p_vpar->picture.i_structure = i_structure; p_vpar->picture.i_structure = i_structure;
...@@ -499,7 +517,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -499,7 +517,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
(i_dummy > SLICE_START_CODE_MAX) ) (i_dummy > SLICE_START_CODE_MAX) )
{ {
intf_DbgMsg("vpar debug: premature end of picture"); intf_DbgMsg("vpar debug: premature end of picture");
p_vpar->picture.b_error = TRUE; p_vpar->picture.b_error = 1;
break; break;
} }
DumpBits32( &p_vpar->bit_stream ); DumpBits32( &p_vpar->bit_stream );
...@@ -520,7 +538,7 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -520,7 +538,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
vout_DestroyPicture( p_vpar->p_vout, P_picture ); vout_DestroyPicture( p_vpar->p_vout, P_picture );
/* Prepare context for the next picture. */ /* Prepare context for the next picture. */
P_picture = NULL: P_picture = NULL;
} }
else if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE ) else if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE )
{ {
...@@ -640,8 +658,8 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar, ...@@ -640,8 +658,8 @@ static __inline__ void SliceHeader( vpar_thread_t * p_vpar,
/* Reset DC coefficients predictors (ISO/IEC 13818-2 7.2.1). Why /* Reset DC coefficients predictors (ISO/IEC 13818-2 7.2.1). Why
* does the reference decoder put 0 instead of the normative values ? */ * 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_dc_dct_pred[0] = p_vpar->slice.pi_dc_dct_pred[1]
= p_vpar->slice.pi_dct_pred[2] = p_vpar->slice.pi_dc_dct_pred[2]
= pi_dc_dct_reinit[p_vpar->picture.i_intra_dc_precision]; = pi_dc_dct_reinit[p_vpar->picture.i_intra_dc_precision];
/* Reset motion vector predictors (ISO/IEC 13818-2 7.6.3.4). */ /* Reset motion vector predictors (ISO/IEC 13818-2 7.6.3.4). */
...@@ -747,7 +765,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar ) ...@@ -747,7 +765,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar )
if( GetBits( &p_vpar->bit_stream, 1 ) ) if( GetBits( &p_vpar->bit_stream, 1 ) )
{ {
/* Load non_intra_quantiser_matrix for luminance. */ /* 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 else
{ {
...@@ -764,7 +782,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar ) ...@@ -764,7 +782,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar )
{ {
/* Link the chrominance intra matrix to the luminance one. */ /* Link the chrominance intra matrix to the luminance one. */
LinkMatrix( &p_vpar->sequence.chroma_intra_quant, 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 ) ) if( GetBits( &p_vpar->bit_stream, 1 ) )
{ {
...@@ -775,7 +793,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar ) ...@@ -775,7 +793,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar )
{ {
/* Link the chrominance intra matrix to the luminance one. */ /* Link the chrominance intra matrix to the luminance one. */
LinkMatrix( &p_vpar->sequence.chroma_intra_quant, 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 ) ) if( GetBits( &p_vpar->bit_stream, 1 ) )
{ {
...@@ -786,7 +804,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar ) ...@@ -786,7 +804,7 @@ static void QuantMatrixExtension( vpar_thread_t * p_vpar )
{ {
/* Link the chrominance nonintra matrix to the luminance one. */ /* Link the chrominance nonintra matrix to the luminance one. */
LinkMatrix( &p_vpar->sequence.chroma_nonintra_quant, LinkMatrix( &p_vpar->sequence.chroma_nonintra_quant,
&p_vpar->sequence.nonintra_quant ); p_vpar->sequence.nonintra_quant.pi_matrix );
} }
} }
...@@ -860,7 +878,7 @@ static void PictureTemporalScalableExtension( vpar_thread_t * p_vpar ) ...@@ -860,7 +878,7 @@ static void PictureTemporalScalableExtension( vpar_thread_t * p_vpar )
* CopyrightExtension : Keeps some legal informations * * 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 */ u32 i_copyright_nb_1, i_copyright_nb_2; /* local integers */
p_vpar->sequence.b_copyright_flag = GetBits( &p_vpar->bit_stream, 1 ); p_vpar->sequence.b_copyright_flag = GetBits( &p_vpar->bit_stream, 1 );
...@@ -878,16 +896,16 @@ static void CopytrightExtension( vpar_thread_t * p_vpar ) ...@@ -878,16 +896,16 @@ static void CopytrightExtension( vpar_thread_t * p_vpar )
i_copyright_nb_2 = GetBits( &p_vpar->bit_stream, 22 ); i_copyright_nb_2 = GetBits( &p_vpar->bit_stream, 22 );
DumpBits( &p_vpar->bit_stream, 1 ); DumpBits( &p_vpar->bit_stream, 1 );
/* third part and sum */ /* third part and sum */
p_vpar->sequence.i_copyright_nb = ( i_copyright_nb_1 << 44 ) + p_vpar->sequence.i_copyright_nb = ( (u64)i_copyright_nb_1 << 44 ) +
( i_copyright_nb_2 << 22 ) + ( (u64)i_copyright_nb_2 << 22 ) +
( GetBits( &p_vpar->bit_stream, 22 ) ); ( (u64)GetBits( &p_vpar->bit_stream, 22 ) );
} }
/***************************************************************************** /*****************************************************************************
* LoadMatrix : Load a quantization matrix * 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; int i_dummy;
...@@ -895,13 +913,13 @@ static void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix ) ...@@ -895,13 +913,13 @@ static void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix )
{ {
/* Allocate a piece of memory to load the matrix. */ /* Allocate a piece of memory to load the matrix. */
p_matrix->pi_matrix = (int *)malloc( 64*sizeof(int) ); 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++ ) for( i_dummy = 0; i_dummy < 64; i_dummy++ )
{ {
p_matrix->pi_matrix[pi_scan[SCAN_ZIGZAG][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 #ifdef FOURIER_IDCT
...@@ -914,7 +932,7 @@ static void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix ) ...@@ -914,7 +932,7 @@ static void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix )
/***************************************************************************** /*****************************************************************************
* LinkMatrix : Link a quantization matrix to another * 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; int i_dummy;
...@@ -922,7 +940,7 @@ static void LinkMatrix( quant_matrix_t * p_matrix, int * pi_array ) ...@@ -922,7 +940,7 @@ static void LinkMatrix( quant_matrix_t * p_matrix, int * pi_array )
{ {
/* Deallocate the piece of memory. */ /* Deallocate the piece of memory. */
free( p_matrix->pi_matrix ); free( p_matrix->pi_matrix );
p_matrix->b_allocated = FALSE; p_matrix->b_allocated = 0;
} }
p_matrix->pi_matrix = pi_array; p_matrix->pi_matrix = pi_array;
......
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