Commit e229f269 authored by Christophe Massiot's avatar Christophe Massiot

Suite du video_parser et du video_decoder.

parent ce68167e
/*****************************************************************************
* video_decoder.h : video decoder thread
* (c)1999 VideoLAN
*****************************************************************************
*****************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
* "vlc_thread.h"
* "input.h"
* "video.h"
* "video_output.h"
* "decoder_fifo.h"
*****************************************************************************/
/*****************************************************************************
* vdec_thread_t: video decoder thread descriptor
*****************************************************************************
* ??
*****************************************************************************/
typedef struct vdec_thread_s
{
/* Thread properties and locks */
boolean_t b_die; /* `die' flag */
boolean_t b_run; /* `run' flag */
boolean_t b_error; /* `error' flag */
boolean_t b_active; /* `active' flag */
vlc_thread_t thread_id; /* id for thread functions */
/* Thread configuration */
/* ?? */
/*??*/
// int *pi_status;
/* Input properties */
video_parser_t * p_vpar; /* video_parser thread */
#ifdef STATS
/* Statistics */
count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_decoded_pictures; /* number of pictures decoded */
count_t c_decoded_i_pictures; /* number of I pictures decoded */
count_t c_decoded_p_pictures; /* number of P pictures decoded */
count_t c_decoded_b_pictures; /* number of B pictures decoded */
#endif
} vdec_thread_t;
/*****************************************************************************
* Prototypes
*****************************************************************************/
/* Thread management functions */
vdec_thread_t * vdec_CreateThread ( vpar_thread_t *p_vpar /*, int *pi_status */ );
void vdec_DestroyThread ( vdec_thread_t *p_vdec /*, int *pi_status */ );
/* Time management functions */
/* ?? */
/* Dynamic thread settings */
/* ?? */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/***************************************************************************** /*****************************************************************************
* video_fifo_t * video_fifo_t
***************************************************************************** *****************************************************************************
* This rotative FIFO contains undecoded pictures that are to be decoded * This rotative FIFO contains undecoded macroblocks that are to be decoded
*****************************************************************************/ *****************************************************************************/
typedef struct video_fifo_s typedef struct video_fifo_s
{ {
...@@ -37,7 +37,7 @@ typedef struct video_fifo_s ...@@ -37,7 +37,7 @@ typedef struct video_fifo_s
vlc_cond_t wait; /* fifo data conditional variable */ vlc_cond_t wait; /* fifo data conditional variable */
/* buffer is an array of undec_picture_t pointers */ /* buffer is an array of undec_picture_t pointers */
undec_picture_t * buffer[VFIFO_SIZE + 1]; macroblock_t * buffer[VFIFO_SIZE + 1];
int i_start; int i_start;
int i_end; int i_end;
...@@ -48,22 +48,22 @@ typedef struct video_fifo_s ...@@ -48,22 +48,22 @@ typedef struct video_fifo_s
* video_buffer_t * video_buffer_t
***************************************************************************** *****************************************************************************
* This structure enables the parser to maintain a list of free * This structure enables the parser to maintain a list of free
* undec_picture_t structures * macroblock_t structures
*****************************************************************************/ *****************************************************************************/
typedef struct video_buffer_s typedef struct video_buffer_s
{ {
vlc_mutex_t lock; /* buffer data lock */ vlc_mutex_t lock; /* buffer data lock */
undec_picture_t p_undec_p[VFIFO_SIZE + 1]; macroblock_t p_macroblocks[VFIFO_SIZE + 1];
undec_picture_t * pp_undec_free[VFIFO_SIZE+1]; /* this is a LIFO */ macroblock_t * pp_mb_free[VFIFO_SIZE+1]; /* this is a LIFO */
int i_index; int i_index;
} video_buffer_t; } video_buffer_t;
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
undec_picture_t * vpar_GetPicture( video_fifo_t * p_fifo ); macroblock_t * vpar_GetMacroblock( video_fifo_t * p_fifo );
undec_picture_t * vpar_NewPicture( video_fifo_t * p_fifo ); macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo );
void vpar_DecodePicture( video_fifo_t * p_fifo, undec_picture_t * p_undec_p ); void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb );
void vpar_ReleasePicture( video_fifo_t * p_fifo, undec_picture_t * p_undec_p ); void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb );
void vpar_DestroyPicture( video_fifo_t * p_fifo, undec_picture_t * p_undec_p ); void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb );
/******************************************************************************* /*****************************************************************************
* video_parser.h : video parser thread * video_parser.h : video parser thread
* (c)1999 VideoLAN * (c)1999 VideoLAN
******************************************************************************* *****************************************************************************
******************************************************************************* *****************************************************************************
* Requires: * Requires:
* "config.h" * "config.h"
* "common.h" * "common.h"
...@@ -13,44 +13,22 @@ ...@@ -13,44 +13,22 @@
* "video_output.h" * "video_output.h"
* "decoder_fifo.h" * "decoder_fifo.h"
* "video_fifo.h" * "video_fifo.h"
*******************************************************************************/ * "vpar_headers.h"
*****************************************************************************/
/******************************************************************************* /*****************************************************************************
* sequence_t : sequence descriptor
*******************************************************************************
* ??
*******************************************************************************/
typedef struct sequence_s
{
u16 i_height, i_width;
u16 i_mb_height, i_mb_width;
unsigned int i_aspect_ratio;
double d_frame_rate;
unsigned int i_chroma_format;
boolean_t b_mpeg2;
boolean_t b_progressive;
/* Parser context */
picture_t * p_forward, p_backward;
pel_lookup_table_t * p_frame_lum_lookup, p_field_lum_lookup;
pel_lookup_table_t * p_frame_chroma_lookup, p_field_chroma_lookup;
quant_matrix_t intra_quant, nonintra_quant;
quant_matrix_t chroma_intra_quant, chroma_nonintra_quant;
} sequence_t;
/*******************************************************************************
* vpar_thread_t: video parser thread descriptor * vpar_thread_t: video parser thread descriptor
******************************************************************************* *****************************************************************************
* ?? * ??
*******************************************************************************/ *****************************************************************************/
typedef struct vpar_thread_s typedef struct vpar_thread_s
{ {
/* Thread properties and locks */ /* Thread properties and locks */
boolean_t b_die; /* `die' flag */ boolean_t b_die; /* `die' flag */
boolean_t b_run; /* `run' flag */ boolean_t b_run; /* `run' flag */
boolean_t b_error; /* `error' flag */ boolean_t b_error; /* `error' flag */
boolean_t b_active; /* `active' flag */ boolean_t b_active; /* `active' flag */
vlc_thread_t thread_id; /* id for thread functions */ vlc_thread_t thread_id; /* id for thread functions */
/* Thread configuration */ /* Thread configuration */
/* ?? */ /* ?? */
...@@ -59,67 +37,45 @@ typedef struct vpar_thread_s ...@@ -59,67 +37,45 @@ typedef struct vpar_thread_s
/* Input properties */ /* Input properties */
decoder_fifo_t fifo; /* PES input fifo */ decoder_fifo_t fifo; /* PES input fifo */
/* The bit stream structure handles the PES stream at the bit level */ /* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream; bit_stream_t bit_stream;
/* Output properties */ /* Output properties */
vout_thread_t * p_vout; /* video output thread */ vout_thread_t * p_vout; /* video output thread */
int i_stream; /* video stream id */ int i_stream; /* video stream id */
/* Decoder properties */ /* Decoder properties */
struct vdec_thread_s * p_vdec[MAX_VDEC]; struct vdec_thread_s * p_vdec[NB_VDEC];
video_fifo_t vfifo; video_fifo_t vfifo;
video_buffer_t vbuffer; video_buffer_t vbuffer;
/* Parser properties */ /* Parser properties */
sequence_t sequence; sequence_t sequence;
picture_parsing_t picture;
slice_parsing_t slice;
macroblock_parsing_t mb;
#ifdef STATS #ifdef STATS
/* Statistics */ /* Statistics */
count_t c_loops; /* number of loops */ count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */ count_t c_idle_loops; /* number of idle loops */
count_t c_sequences; /* number of sequences */ count_t c_sequences; /* number of sequences */
count_t c_pictures; /* number of pictures read */ count_t c_pictures; /* number of pictures read */
count_t c_i_pictures; /* number of I pictures read */ count_t c_i_pictures; /* number of I pictures read */
count_t c_p_pictures; /* number of P pictures read */ count_t c_p_pictures; /* number of P pictures read */
count_t c_b_pictures; /* number of B pictures read */ count_t c_b_pictures; /* number of B pictures read */
count_t c_decoded_pictures; /* number of pictures decoded */ count_t c_decoded_pictures; /* number of pictures decoded */
count_t c_decoded_i_pictures; /* number of I pictures decoded */ count_t c_decoded_i_pictures; /* number of I pictures decoded */
count_t c_decoded_p_pictures; /* number of P pictures decoded */ count_t c_decoded_p_pictures; /* number of P pictures decoded */
count_t c_decoded_b_pictures; /* number of B pictures decoded */ count_t c_decoded_b_pictures; /* number of B pictures decoded */
#endif #endif
} vpar_thread_t; } vpar_thread_t;
/******************************************************************************* /*****************************************************************************
* Standard start codes
*******************************************************************************/
#define PICTURE_START_CODE 0x100
#define SLICE_START_CODE_MIN 0x101
#define SLICE_START_CODE_MAX 0x1AF
#define USER_DATA_START_CODE 0x1B2
#define SEQUENCE_HEADER_CODE 0x1B3
#define SEQUENCE_ERROR_CODE 0x1B4
#define EXTENSION_START_CODE 0x1B5
#define SEQUENCE_END_CODE 0x1B7
#define GROUP_START_CODE 0x1B8
/* extension start code IDs */
#define SEQUENCE_EXTENSION_ID 1
#define SEQUENCE_DISPLAY_EXTENSION_ID 2
#define QUANT_MATRIX_EXTENSION_ID 3
#define COPYRIGHT_EXTENSION_ID 4
#define SEQUENCE_SCALABLE_EXTENSION_ID 5
#define PICTURE_DISPLAY_EXTENSION_ID 7
#define PICTURE_CODING_EXTENSION_ID 8
#define PICTURE_SPATIAL_SCALABLE_EXTENSION_ID 9
#define PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID 10
/*******************************************************************************
* Prototypes * Prototypes
*******************************************************************************/ *****************************************************************************/
/* Thread management functions */ /* Thread management functions */
vpar_thread_t * vpar_CreateThread ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*, vpar_thread_t * vpar_CreateThread ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*,
......
...@@ -16,16 +16,97 @@ ...@@ -16,16 +16,97 @@
*****************************************************************************/ *****************************************************************************/
/***************************************************************************** /*****************************************************************************
* quant_matrix_t : Quantization Matrix * macroblock_t : information on a macroblock
*****************************************************************************/
typedef struct macroblock_s
{
picture_t * p_picture;
int i_mb_x, i_mb_y;
int i_structure;
int i_l_x, i_l_y; /* position of macroblock (lum) */
int i_c_x, i_c_y; /* position of macroblock (chroma) */
int i_structure;
int i_chroma_nb_blocks; /* nb of bks for a chr comp */
/* IDCT information */
elem_t ppi_blocks[12][64]; /* blocks */
f_idct_t pf_idct[12]; /* sparse IDCT or not ? */
int pi_sparse_pos[12];
/* Motion compensation information */
f_motion_t pf_motion; /* function to use for motion comp */
f_chroma_motion_t pf_chroma_motion;
picture_t * p_backw_top, p_backw_bot;
picture_t * p_forw_top, p_forw_bot;
int i_field_select_backw_top, i_field_select_backw_bot;
int i_field_select_forw_top, i_field_select_forw_bot;
int pi_motion_vectors_backw_top[2];
int pi_motion_vectors_backw_bot[2];
int pi_motion_vectors_forw_top[2];
int pi_motion_vectors_forw_bot[2];
/* AddBlock information */
f_addb_t pf_addb[12];
data_t * p_data[12]; /* positions of blocks in picture */
int i_lum_incr, i_chroma_incr;
} macroblock_t;
/*****************************************************************************
* macroblock_parsing_t : parser context descriptor #3
*****************************************************************************/
typedef struct
{
int i_mb_type, i_motion_type, i_mv_count, i_mv_format;
int i_coded_block_pattern;
boolean_t b_dct_type;
} macroblock_parsing_t;
/*****************************************************************************
* LoadQuantizerScale
***************************************************************************** *****************************************************************************
* ?? * Quantizer scale factor (ISO/IEC 13818-2 7.4.2.2)
*****************************************************************************/ *****************************************************************************/
typedef struct quant_matrix_s static __inline__ void LoadQuantizerScale( vpar_thread_t * p_vpar )
{ {
int pi_matrix[64]; /* Quantization coefficient table */
boolean_t b_allocated; static unsigned char ppi_quantizer_scale[3][32] =
/* Has the matrix been allocated by vpar_headers ? */ {
} quant_matrix_t; /* MPEG-2 */
{
/* q_scale_type */
/* linear */
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,
32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
},
{
/* non-linear */
0, 1, 2, 3, 4, 5, 6, 7, 8, 10,12,14,16,18,20, 22,
24,28,32,36,40,44,48,52,56,64,72,80,88,96,104,112
},
/* MPEG-1 */
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
}
};
p_vpar->slice.i_quantizer_scale = ppi_quantizer_scale
[(!p_vpar->sequence.b_mpeg2 << 1) | p_vpar->picture.b_q_scale_type]
[GetBits( &p_vpar->bit_stream, 5 )];
}
/*****************************************************************************
* Standard codes
*****************************************************************************/
/* Macroblock types */
#define MB_INTRA 1
#define MB_PATTERN 2
#define MB_MOTION_BACKWARD 4
#define MB_MOTION_FORWARD 8
#define MB_QUANT 16
extern int * pi_default_intra_quant; /* Motion types */
extern int * pi_default_nonintra_quant; #define MOTION_FIELD 1
#define MOTION_FRAME 2
#define MOTION_16X8 2
#define MOTION_DMV 3
/*****************************************************************************
* vpar_headers.h : video parser : headers parsing
* (c)1999 VideoLAN
*****************************************************************************
*****************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
* "vlc_thread.h"
* "input.h"
* "video.h"
* "video_output.h"
* "decoder_fifo.h"
* "video_fifo.h"
*****************************************************************************/
/*****************************************************************************
* Function pointers
*****************************************************************************/
typedef (void *) f_slice_header_t( vpar_thread_t*, int*, int, elem_t*, u32);
/*****************************************************************************
* quant_matrix_t : Quantization Matrix
*****************************************************************************/
typedef struct quant_matrix_s
{
int pi_matrix[64];
boolean_t b_allocated;
/* Has the matrix been allocated by vpar_headers ? */
} quant_matrix_t;
extern int * pi_default_intra_quant;
extern int * pi_default_nonintra_quant;
/*****************************************************************************
* sequence_t : sequence descriptor
*****************************************************************************/
typedef struct sequence_s
{
u32 i_height, i_width, i_chroma_width, i_size;
u32 i_mb_height, i_mb_width, i_mb_size;
unsigned int i_aspect_ratio;
double d_frame_rate;
unsigned int i_chroma_format;
int i_chroma_nb_blocks;
boolean_t b_mpeg2;
boolean_t b_progressive;
unsigned int i_scalable_mode;
f_slice_header_t pf_slice_header;
quant_matrix_t intra_quant, nonintra_quant;
quant_matrix_t chroma_intra_quant, chroma_nonintra_quant;
(void *) pf_decode_mv( vpar_thread_t *, int );
(void *) pf_decode_pattern( vpar_thread_t * );
/* Parser context */
picture_t * p_forward, p_backward;
} sequence_t;
/*****************************************************************************
* picture_parsing_t : parser context descriptor
*****************************************************************************/
typedef struct picture_parsing_s
{
boolean_t b_full_pel_forward_vector, b_full_pel_backward_vector;
int i_forward_f_code, i_backward_f_code;
int ppi_f_code[2][2];
int i_intra_dc_precision;
boolean_t b_frame_pred_frame_dct, b_q_scale_type;
boolean_t b_alternate_scan, b_progressive_frame;
boolean_t b_top_field_first, b_concealment_mv;
int i_lum_incr, i_chroma_incr;
/* Used for second field management */
int i_current_structure;
picture_t * p_picture;
macroblock_t * pp_mb[MAX_MB];
/* Relative to the current field */
int i_coding_type, i_structure;
boolean_t b_frame_structure;
(int *) pf_macroblock_type( vpar_thread_t * );
boolean_t b_error;
} picture_parsing_t;
/*****************************************************************************
* slice_parsing_t : parser context descriptor #2
*****************************************************************************/
typedef struct slice_parsing_s
{
unsigned char i_quantizer_scale;
int pi_dc_dct_pred[3]; /* ISO/IEC 13818-2 7.2.1 */
int pppi_pmv[2][2][2]; /* Motion vect predictors, 7.6.3 */
} slice_parsing_t;
/*****************************************************************************
* Standard codes
*****************************************************************************/
#define PICTURE_START_CODE 0x100
#define SLICE_START_CODE_MIN 0x101
#define SLICE_START_CODE_MAX 0x1AF
#define USER_DATA_START_CODE 0x1B2
#define SEQUENCE_HEADER_CODE 0x1B3
#define SEQUENCE_ERROR_CODE 0x1B4
#define EXTENSION_START_CODE 0x1B5
#define SEQUENCE_END_CODE 0x1B7
#define GROUP_START_CODE 0x1B8
/* extension start code IDs */
#define SEQUENCE_EXTENSION_ID 1
#define SEQUENCE_DISPLAY_EXTENSION_ID 2
#define QUANT_MATRIX_EXTENSION_ID 3
#define COPYRIGHT_EXTENSION_ID 4
#define SEQUENCE_SCALABLE_EXTENSION_ID 5
#define PICTURE_DISPLAY_EXTENSION_ID 7
#define PICTURE_CODING_EXTENSION_ID 8
#define PICTURE_SPATIAL_SCALABLE_EXTENSION_ID 9
#define PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID 10
/* scalable modes */
#define SC_NONE 0
#define SC_DP 1
#define SC_SPAT 2
#define SC_SNR 3
#define SC_TEMP 4
/* Pictures types */
#define I_CODING_TYPE 1
#define P_CODING_TYPE 2
#define B_CODING_TYPE 3
#define D_CODING_TYPE 4 /* MPEG-1 ONLY */
/* other values are reserved */
/* Structures */
#define TOP_FIELD 1
#define BOTTOM_FIELD 2
#define FRAME_STRUCTURE 3
/*****************************************************************************
* vdec_idct.c : IDCT functions
* (c)1999 VideoLAN
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
#include "video_parser.h"
#include "undec_picture.h"
#include "video_fifo.h"
#include "video_decoder.h"
/*
* Local prototypes
*/
/* Our current implementation is a fast DCT, we might move to a fast DFT or
* an MMX DCT in the future. */
/*****************************************************************************
* vdec_DummyIDCT : dummy function that does nothing
*****************************************************************************/
void vdec_DummyIDCT( elem_t * p_block, int i_idontcare )
{
}
/*****************************************************************************
* vdec_SparseIDCT : IDCT function for sparse matrices
*****************************************************************************/
void vdec_SparseIDCT( elem_t * p_block, int i_sparse_pos )
{
/* Copy from mpeg_play */
}
/*****************************************************************************
* vdec_IDCT : IDCT function for normal matrices
*****************************************************************************/
void vdec_IDCT( elem_t * p_block, int i_idontcare )
{
}
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
* (c)1999 VideoLAN * (c)1999 VideoLAN
*****************************************************************************/ *****************************************************************************/
/* ?? passer en terminate/destroy avec les signaux supplmentaires */
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
...@@ -40,52 +38,46 @@ ...@@ -40,52 +38,46 @@
* Local prototypes * Local prototypes
*/ */
typedef (void *) f_motion_c_t( coeff_t *, pel_lookup_table_t *,
int, coeff_t *, int, int,
int, int, int, int, int );
/***************************************************************************** /*****************************************************************************
* vdec_MotionCompensation : motion compensation * vdec_DummyRecon : motion compensation for an intra macroblock
*****************************************************************************/ *****************************************************************************/
void vdec_MotionFrame( vdec_thread_t * p_vdec, void vdec_DummyRecon( macroblock_t * p_mb )
undec_picture_t * p_undec_p, int i_mb,
f_motion_mb_t pf_mb_motion )
{ {
static int p_chroma_nb_blocks[4] = {1, 2, 4}; }
static int p_chroma_nb_elems[4] = {0, 64, 128, 256};
int i_mb_x, i_mb_y; /* Position of our macroblock in the final picture */ /*****************************************************************************
elem_t * p_y, p_u, p_v; /* Pointers to our picture's data */ * vdec_ForwardRecon : motion compensation for a forward predicted macroblock
*****************************************************************************/
void vdec_ForwardRecon( macroblock_t * p_mb )
{
}
/*****************************************************************************
* vdec_BackwardRecon : motion compensation for a backward predicted macroblock
*****************************************************************************/
void vdec_BackwardRecon( macroblock_t * p_mb )
{
#define P_mb_info p_undec_p->p_mb_info[i_mb]
i_mb_x = (i_mb << 5) % p_undec_p->p_picture->i_width;
i_mb_y = (i_mb << 5) / p_undec_p->p_picture->i_width;
p_y = &p_undec_p->p_picture->p_y[256*i_mb];
p_u = &p_undec_p->p_picture->p_u[p_chroma_nb_elems[p_undec_p->p_picture->i_chroma_type]*i_mb];
p_v = &p_undec_p->p_picture->p_v[p_chroma_nb_elems[p_undec_p->p_picture->i_chroma_type]*i_mb];
if( (p_undec_p->i_coding_type == P_CODING_TYPE) ||
(P_mb_info->i_mb_type & MB_MOTION_FORWARD) )
{
if( (P_mb_info->i_motion_type == MOTION_FRAME) ||
!(P_mb_info->i_mb_type & MB_INTRA) )
{
MotionBlock( p_undec_p->p_forward->p_u,
p_undec_p->p_forward->p_lookup_lum,
p_undec_p->p_picture->i_width,
p_u, i_mb_x, i_mb_y,
p_undec_p->p_picture->i_width,
p_undec_p->ppp_motion_vectors[0][0][0],
p_undec_p->ppp_motion_vectors[0][0][1] );
}
}
} }
/***************************************************************************** /*****************************************************************************
* MotionMacroblock : motion compensation for a macroblock * vdec_BidirectionalRecon : motion compensation for a bidirectionally
* predicted macroblock
*****************************************************************************/ *****************************************************************************/
void vdec_MotionMacroblock420( coeff_t * p_src, pel_lookup_table_t * p_lookup, void vdec_BidirectionalRecon( macroblock_t * p_mb )
int i_width_line, {
coeff_t * p_dest, int i_dest_x, i_dest_y,
int i_stride_line, }
i_mv1_x, i_mv1_y, i_mv2_x, i_mv2_y )
/*****************************************************************************
* vdec_MotionMacroblock420 : motion compensation for a 4:2:0 macroblock
*****************************************************************************/
void vdec_MotionMacroblock420( macroblock_t * p_mb )
{ {
/* Luminance */ /* Luminance */
MotionBlock( p_undec_p->p_forward->p_u, p_undec_p->p_forward->p_lookup_lum, MotionBlock( p_undec_p->p_forward->p_u, p_undec_p->p_forward->p_lookup_lum,
...@@ -105,12 +97,9 @@ void __inline__ MotionBlock( coeff_t * p_src, pel_lookup_table_t * p_lookup, ...@@ -105,12 +97,9 @@ void __inline__ MotionBlock( coeff_t * p_src, pel_lookup_table_t * p_lookup,
int i_stride_line, int i_stride_line,
i_mv1_x, i_mv1_y, i_mv2_x, i_mv2_y ) i_mv1_x, i_mv1_y, i_mv2_x, i_mv2_y )
{ {
static (void *) ComponentMode( coeff_t * p_src, static f_motion_c_t ComponentMode[4]
pel_lookup_table_t * p_lookup, = { &ComponentNN, &ComponentNH, &ComponentHN,
coeff_t * p_dest, int i_dest_x, i_dest_y, &ComponentHH };
int i_stride_line, i_mv_x, i_mv_y )[4]
= { ComponentNN, ComponentNH, ComponentHN,
ComponentHH };
int i_mode; int i_mode;
...@@ -118,7 +107,8 @@ void __inline__ MotionBlock( coeff_t * p_src, pel_lookup_table_t * p_lookup, ...@@ -118,7 +107,8 @@ void __inline__ MotionBlock( coeff_t * p_src, pel_lookup_table_t * p_lookup,
ComponentMode[i_mode]( p_src, p_lookup, i_width_line, ComponentMode[i_mode]( p_src, p_lookup, i_width_line,
p_dest, i_dest_x, i_dest_y, p_dest, i_dest_x, i_dest_y,
i_stride_line, i_mv_x >> 1, i_mv_y >> 1 ); i_stride_line, i_mv1_x >> 1, i_mv1_y >> 1,
i_mv2_x >> 1, i_mv2_y >> 1 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -132,9 +122,22 @@ void ComponentNN( coeff_t * p_src, pel_lookup_table_t * p_lookup, ...@@ -132,9 +122,22 @@ void ComponentNN( coeff_t * p_src, pel_lookup_table_t * p_lookup,
int i_vpos; int i_vpos;
register int i_hpos, i_src_loc; register int i_hpos, i_src_loc;
i_src_loc = (i_dest_y + i_mv_y)*i_width_line + i_dest_x + i_mv_x; i_src_loc = (i_dest_y + i_mv1_y)*i_width_line + i_dest_x + i_mv1_x;
for( i_vpos = 0; i_vpos < 8; i_vpos++ ) for( i_vpos = 0; i_vpos < 4; i_vpos++ )
{
for( i_hpos = 0; i_hpos < 8; i_hpos++ )
{
p_dest[i_hpos] += p_src[p_lookup->pi_pel[i_src_loc + i_hpos]];
}
p_dest += 8;
i_src_loc += i_stride_line;
}
i_src_loc = (i_dest_y + i_mv2_y)*i_width_line + i_dest_x + i_mv2_x;
for( i_vpos = 4; i_vpos < 8; i_vpos++ )
{ {
for( i_hpos = 0; i_hpos < 8; i_hpos++ ) for( i_hpos = 0; i_hpos < 8; i_hpos++ )
{ {
......
...@@ -43,8 +43,8 @@ static int InitThread ( vdec_thread_t *p_vdec ); ...@@ -43,8 +43,8 @@ static int InitThread ( vdec_thread_t *p_vdec );
static void RunThread ( vdec_thread_t *p_vdec ); static void RunThread ( vdec_thread_t *p_vdec );
static void ErrorThread ( vdec_thread_t *p_vdec ); static void ErrorThread ( vdec_thread_t *p_vdec );
static void EndThread ( vdec_thread_t *p_vdec ); static void EndThread ( vdec_thread_t *p_vdec );
static void DecodePicture ( vdec_thread_t *p_vdec, static void DecodeMacroblock ( vdec_thread_t *p_vdec,
undec_picture_t * p_undec_p ); macroblock_t * p_mb );
/******************************************************************************* /*******************************************************************************
* vdec_CreateThread: create a video decoder thread * vdec_CreateThread: create a video decoder thread
...@@ -165,11 +165,11 @@ static void RunThread( vdec_thread_t *p_vdec ) ...@@ -165,11 +165,11 @@ static void RunThread( vdec_thread_t *p_vdec )
*/ */
while( (!p_vdec->b_die) && (!p_vdec->b_error) ) while( (!p_vdec->b_die) && (!p_vdec->b_error) )
{ {
undec_picture_t * p_undec_p; macroblock_t * p_mb;
if( (p_undec_p = GetPicture( p_vdec->p_vpar->p_fifo )) != NULL ) if( (p_mb = GetMacroblock( &p_vdec->p_vpar.vfifo )) != NULL )
{ {
DecodePicture( p_vdec, p_undec_p ); DecodeMacroblock( p_vdec, p_mb );
} }
} }
...@@ -220,92 +220,101 @@ static void EndThread( vdec_thread_t *p_vdec ) ...@@ -220,92 +220,101 @@ static void EndThread( vdec_thread_t *p_vdec )
} }
/******************************************************************************* /*******************************************************************************
* DecodePicture : decode a picture * DecodeMacroblock : decode a macroblock of a picture
*******************************************************************************/ *******************************************************************************/
static void DecodePicture( vdec_thread_t *p_vdec, undec_picture_t * p_undec_p ) static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
{ {
static int pi_chroma_nb_blocks[4] = {0, 1, 2, 4}; int i_b;
static int pi_chroma_nb_coeffs[4] = {0, 64, 128, 256};
static f_motion_mb_t ppf_chroma_motion[4] = { NULL,
&vdec_MotionMacroBlock420,
&vdec_MotionMacroBlock422,
&vdec_MotionMacroBlock444 };
static f_motion_t pppf_motion_forward[4][2] = {
{NULL, NULL} /* I picture */
{&vdec_MotionForward, &vdec_MotionForward} /* P */
{NULL, &vdec_MotionForward} /* B */
{NULL, NULL} /* D */ };
static f_motion_t pppf_motion_backward[4][2] = {
{NULL, NULL} /* I picture */
{NULL, NULL} /* P */
{NULL, &vdec_MotionBackward} /* B */
{NULL, NULL} /* D */ };
static f_motion_t ppf_motion[4] = { NULL,
&vdec_MotionTopFirst,
&vdec_MotionBottomFirst,
&vdec_MotionFrame };
int i_mb, i_b, i_totb;
coeff_t * p_y, p_u, p_v;
f_motion_mb_t pf_chroma_motion;
f_motion_t pf_motion_forward, pf_motion_backward;
int i_chroma_nb_blocks, i_chroma_nb_coeffs;
p_y = (coeff_t *)p_undec_p->p_picture->p_y;
p_u = (coeff_t *)p_undec_p->p_picture->p_u;
p_v = (coeff_t *)p_undec_p->p_picture->p_v;
#define I_chroma_format p_undec_p->p_picture->i_chroma_format
pf_chroma_motion = ppf_chroma_motion[I_chroma_format];
pf_motion_forward
pf_motion = ppf_motion[p_undec_p->i_structure];
i_chroma_nb_blocks = pi_chroma_nb_blocks[I_chroma_format]; /*
i_chroma_nb_coeffs = pi_chroma_nb_coeffs[I_chroma_format]; * Motion Compensation (ISO/IEC 13818-2 section 7.6)
#undef I_chroma_format */
(*p_mb->pf_motion)( p_mb );
for( i_mb = 0; i_mb < p_undec_p->i_mb_height*p_undec_p->i_mb_width; i_mb++ ) /* luminance */
for( i_b = 0; i_b < 4; i_b++ )
{ {
#define P_mb_info p_undec_p->p_mb_info[i_ref]
/* /*
* Inverse DCT (ISO/IEC 13818-2 section Annex A) * Inverse DCT (ISO/IEC 13818-2 section Annex A)
*/ */
(*p_mb->pf_idct[i_b])( p_mb, p_mb->ppi_blocks[i_b], p_mb->pi_sparse_pos[i_b] );
/* Luminance : always 4 blocks */
for( i_b = 0; i_b < 4; i_b++ ) /*
{ * Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
(*P_mb_info.p_idct_function[i_b])( p_y + i_b*64 ); */
} (*p_mb->pf_addb[i_b])( p_mb->ppi_blocks[i_b],
i_totb = 4; p_mb->p_data[i_b], p_mb->i_lum_incr );
}
/* Chrominance Cr */
for( i_b = 0; i_b < i_chroma_nb_blocks; i_b++ )
{
(*P_mb_info.p_idct_function[i_totb + i_b])( p_u + i_b*64 );
}
i_totb += i_chroma_nb_blocks;
/* Chrominance Cb */
for( i_b = 0; i_b < i_chroma_nb_blocks; i_b++ )
{
(*P_mb_info.p_idct_function[i_totb + i_b])( p_v + i_b*64 );
}
/* chrominance */
for( i_b = 4; i_b < 4 + 2*p_mb->i_chroma_nb_blocks; i_b++ )
{
/* /*
* Motion Compensation (ISO/IEC 13818-2 section 7.6) * Inverse DCT (ISO/IEC 13818-2 section Annex A)
*/ */
(*pf_motion)( p_vdec, p_undec_p, i_mb, pf_chroma_motion ); (*p_mb->pf_idct[i_b])( p_mb, p_mb->ppi_blocks[i_b], p_mb->pi_sparse_pos[i_b] );
p_y += 256; /*
p_u += i_chroma_nb_coeffs; * Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
p_v += i_chroma_nb_coeffs; */
#undef P_mb_info (*p_mb->pf_addb[i_b])( p_mb->ppi_blocks[i_b],
p_mb->p_data[i_b], p_mb->i_chroma_incr );
} }
/* /*
* Decoding is finished, mark the picture ready for displaying and free * Decoding is finished, release the macroblock and free
* unneeded memory * unneeded memory.
*/ */
vpar_ReleasePicture( p_vdec->p_vpar->p_fifo, p_undec_p ); vpar_ReleaseMacroblock( &p_vdec->p_vpar.vfifo, p_mb );
}
/*******************************************************************************
* vdec_AddBlock : add a block
*******************************************************************************/
void vdec_AddBlock( elem_t * p_block, data_t * p_data, int i_incr )
{
int i_x, i_y;
for( i_y = 0; i_y < 8; i_y++ )
{
for( i_x = 0; i_x < 8; i_x++ )
{
/* ??? Need clip to be MPEG-2 compliant */
*p_data++ += *p_block++;
}
p_data += i_incr;
}
}
/*******************************************************************************
* vdec_CopyBlock : copy a block
*******************************************************************************/
void vdec_CopyBlock( elem_t * p_block, data_t * p_data, int i_incr )
{
int i_x, i_y;
for( i_y = 0; i_y < 8; i_y++ )
{
#ifndef VDEC_DFT
/* elem_t and data_t are the same */
memcopy( p_data, p_block, 8*sizeof(data_t) );
p_data += i_incr+8;
p_block += 8;
#else
for( i_x = 0; i_x < 8; i_x++ )
{
/* ??? Need clip to be MPEG-2 compliant */
/* ??? Why does the reference decoder add 128 ??? */
*p_data++ = *p_block++;
}
p_data += i_incr;
#endif
}
}
/*******************************************************************************
* vdec_DummyBlock : dummy function that does nothing
*******************************************************************************/
void vdec_DummyBlock( elem_t * p_block, data_t * p_data, int i_incr )
{
} }
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "video_output.h" #include "video_output.h"
#include "video_parser.h" #include "video_parser.h"
#include "undec_picture.h" #include "macroblock.h"
#include "video_fifo.h" #include "video_fifo.h"
#include "video_decoder.h" #include "video_decoder.h"
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
*****************************************************************************/ *****************************************************************************/
void vpar_InitFIFO( vpar_thread_t * p_vpar ) 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 );
...@@ -54,17 +54,16 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar ) ...@@ -54,17 +54,16 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar )
i_index = VFIFO_SIZE; /* all structures are available */ 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_undec_free[i_dummy] = p_vpar->vfifo.p_undec_p + i; p_vpar->vfifo.pp_mb_free[i_dummy] = p_vpar->vfifo.p_macroblocks + i;
p_vpar->vfifo.p_undec_p[i].p_mb_info = NULL;
} }
} }
/***************************************************************************** /*****************************************************************************
* vpar_GetPicture : return a picture to be decoded * vpar_GetMacroblock : return a macroblock to be decoded
*****************************************************************************/ *****************************************************************************/
undec_picture_t * vpar_GetPicture( video_fifo_t * p_fifo ) macroblock_t * vpar_GetMacroblock( video_fifo_t * p_fifo )
{ {
undec_picture_t * p_undec_p; macroblock_t * p_mb;
vlc_mutex_lock( &p_fifo->lock ); vlc_mutex_lock( &p_fifo->lock );
while( VIDEO_FIFO_ISEMPTY( *p_fifo ) ) while( VIDEO_FIFO_ISEMPTY( *p_fifo ) )
...@@ -77,20 +76,20 @@ undec_picture_t * vpar_GetPicture( video_fifo_t * p_fifo ) ...@@ -77,20 +76,20 @@ undec_picture_t * vpar_GetPicture( video_fifo_t * p_fifo )
} }
} }
p_undec_p = VIDEO_FIFO_START( *p_fifo ); p_mb = VIDEO_FIFO_START( *p_fifo );
VIDEO_FIFO_INCSTART( *p_fifo ); VIDEO_FIFO_INCSTART( *p_fifo );
vlc_mutex_unlock( &p_fifo->lock ); vlc_mutex_unlock( &p_fifo->lock );
return( p_undec_p ); return( p_mb );
} }
/***************************************************************************** /*****************************************************************************
* vpar_NewPicture : return a buffer for the parser * vpar_NewMacroblock : return a buffer for the parser
*****************************************************************************/ *****************************************************************************/
undec_picture_t * vpar_NewPicture( video_fifo_t * p_fifo ) macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
{ {
undec_picture_t * p_undec_p; 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 );
...@@ -100,128 +99,100 @@ undec_picture_t * vpar_NewPicture( video_fifo_t * p_fifo ) ...@@ -100,128 +99,100 @@ undec_picture_t * vpar_NewPicture( video_fifo_t * p_fifo )
return NULL; return NULL;
} }
p_undec_p = P_buffer->pp_undec_free[ P_buffer->i_index-- ]; p_mb = P_buffer->pp_undec_free[ P_buffer->i_index-- ];
#undef P_buffer #undef P_buffer
vlc_mutex_unlock( &P_buffer->lock ); vlc_mutex_unlock( &P_buffer->lock );
return( p_undec_p ); return( p_mb );
} }
/***************************************************************************** /*****************************************************************************
* vpar_DecodePicture : put a picture in the video fifo, if it is decodable * vpar_DecodeMacroblock : put a macroblock in the video fifo
*****************************************************************************/ *****************************************************************************/
void vpar_DecodePicture( video_fifo_t * p_fifo, undec_picture_t * p_undec_p ) void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
{ {
boolean_t b_decodable; /* Place picture in the video FIFO */
vlc_mutex_lock( &p_fifo->lock );
switch( p_undec_p )
{
case B_CODING_TYPE:
b_decodable = ((p_undec_p->p_backward_p != NULL) &&
(p_undec_p->p_forward_p != NULL));
break;
case P_CODING_TYPE:
b_decodable = (p_undec_p->p_backward_p != NULL);
break;
case I_CODING_TYPE:
case D_CODING_TYPE:
b_decodable = TRUE;
break;
default:
/* That should not happen */
}
if( b_decodable )
{
/* Place picture in the video FIFO */
vlc_mutex_lock( &p_fifo->lock );
/* By construction, the video FIFO cannot be full */ /* By construction, the video FIFO cannot be full */
VIDEO_FIFO_END( *p_fifo ) = p_undec_p; 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 );
}
} }
/***************************************************************************** /*****************************************************************************
* vpar_ReleasePicture : put a picture in the video_output fifo, and update * vpar_ReleaseMacroblock : release a macroblock and put the picture in the
* links and buffers * video output heap, if it is finished
*****************************************************************************/ *****************************************************************************/
void vpar_ReleasePicture( video_fifo_t * p_fifo, undec_picture_t * p_undec_p ) void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
{ {
int i_ref; /* Unlink referenced pictures */
if( p_mb->p_forw_top != NULL )
/* Tell referencing pictures so that they can be decoded */
for( i_ref = 0; p_undec_p->pp_referencing_undec[i_ref].p_undec != NULL
&& i_ref < MAX_REFERENCING_UNDEC; i_ref++ )
{ {
*p_undec_p->pp_referencing_undec[i_ref].pp_frame = p_undec_p->p_picture; vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_top );
vout_LinkPicture( p_fifo->p_vpar.p_vout, p_picture ); }
if( p_mb->p_backw_top != NULL )
/* Try to put the referencing picture in the video FIFO */ {
vpar_DecodePicture( p_fifo, p_undec_p->pp_referencing_undec[i_ref].p_undec ); 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 );
}
if( p_mb->p_backw_bot != NULL )
{
vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_backw_bot );
} }
/* Unlink referenced pictures */ /* Unlink picture buffer */
if( p_undec_p->p_forward_ref != NULL ) vlc_mutex_lock( &p_mb->p_picture->lock_deccount );
p_mb->p_picture->i_deccount--;
if( p_mb->p_picture->i_deccount == 0 )
{ {
vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_undec_p->p_forward_ref ); /* Mark the picture to be displayed */
if( p_undec_p->p_backward_ref != NULL ) vout_DisplayPicture( p_fifo->p_vpar.p_vout, p_mb->p_picture );
{
vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_undec_p->p_backward_ref ); /* Warn Synchro for its records. */
} vpar_SynchroEnd( p_fifo->p_vpar );
} }
vlc_mutex_unlock( & p_mb->p_picture->lock_deccount );
/* Mark the picture to be displayed */
vout_DisplayPicture( p_fifo->p_vpar.p_vout, p_undec_p->p_picture );
/* Release the undec_picture_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_undec_free[ ++P_buffer->i_index ] = p_undec_p;
vlc_mutex_unlock( &P_buffer->lock ); vlc_mutex_unlock( &P_buffer->lock );
#undef P_buffer #undef P_buffer
}
} }
/***************************************************************************** /*****************************************************************************
* vpar_DestroyPicture : destroy a picture in case of error * vpar_DestroyMacroblock : destroy a macroblock in case of error
*****************************************************************************/ *****************************************************************************/
void vpar_DestroyPicture( video_fifo_t * p_fifo, undec_picture_t * p_undec_p ) void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
{ {
int i_ref; /* Unlink referenced pictures */
if( p_mb->p_forw_top != NULL )
/* Destroy referencing pictures */
for( i_ref = 0; p_undec_p->pp_referencing_undec[i_ref].p_undec != NULL
&& i_ref < MAX_REFERENCING_UNDEC; i_ref++ )
{ {
/* Try to put the referencing picture in the video FIFO */ vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_top );
vpar_DestroyPicture( p_fifo, p_undec_p->pp_referencing_undec[i_ref].p_undec );
} }
if( p_mb->p_backw_top != NULL )
/* Unlink referenced pictures */
if( p_undec_p->p_forward_ref != NULL )
{ {
vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_undec_p->p_forward_ref ); vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_backw_top );
if( p_undec_p->p_backward_ref != NULL )
{
vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_undec_p->p_backward_ref );
}
} }
if( p_mb->p_forw_bot != NULL )
/* Release the picture buffer */ {
vout_DestroyPicture( p_fifo->p_vpar.p_vout, p_undec_p->p_picture ); vout_UnlinkPicture( p_fifo->p_vpar.p_vout, p_mb->p_forw_bot );
}
/* Release the undec_picture_t structure */ if( p_mb->p_backw_bot != NULL )
{
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 #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_undec_free[ ++P_buffer->i_index ] = p_undec_p;
vlc_mutex_unlock( &P_buffer->lock ); vlc_mutex_unlock( &P_buffer->lock );
#undef P_buffer #undef P_buffer
}
} }
...@@ -146,6 +146,7 @@ static int CheckConfiguration( video_cfg_t *p_cfg ) ...@@ -146,6 +146,7 @@ static int CheckConfiguration( video_cfg_t *p_cfg )
*******************************************************************************/ *******************************************************************************/
static int InitThread( vpar_thread_t *p_vpar ) static int InitThread( vpar_thread_t *p_vpar )
{ {
int i_dummy;
intf_DbgMsg("vpar debug: initializing video parser thread %p\n", p_vpar); intf_DbgMsg("vpar debug: initializing video parser thread %p\n", p_vpar);
...@@ -181,6 +182,7 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -181,6 +182,7 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar->sequence.nonintra_quant.b_allocated = FALSE; p_vpar->sequence.nonintra_quant.b_allocated = FALSE;
p_vpar->sequence.chroma_intra_quant.b_allocated = FALSE; p_vpar->sequence.chroma_intra_quant.b_allocated = FALSE;
p_vpar->sequence.chroma_nonintra_quant.b_allocated = FALSE; p_vpar->sequence.chroma_nonintra_quant.b_allocated = FALSE;
p_vpar->sequence.i_frame_number = 0;
/* Initialize other properties */ /* Initialize other properties */
#ifdef STATS #ifdef STATS
...@@ -201,16 +203,19 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -201,16 +203,19 @@ static int InitThread( vpar_thread_t *p_vpar )
bzero( p_vpar->p_vdec, MAX_VDEC*sizeof(vdec_thread_t *) ); bzero( p_vpar->p_vdec, MAX_VDEC*sizeof(vdec_thread_t *) );
/* Spawn a video_decoder thread */ /* Spawn video_decoder threads */
/* ??? add the possibility to launch multiple vdec threads */ /* ??? modify the number of vdecs at runtime ? */
if( (p_vpar->p_vdec[0] = vdec_CreateThread( p_vpar )) == NULL ) for( i_dummy = 0; i_dummy < NB_VDEC; i_dummy++ )
{ {
return( 1 ); if( (p_vpar->p_vdec[i_dummy] = vdec_CreateThread( p_vpar )) == NULL )
{
return( 1 );
}
} }
/* Mark thread as running and return */ /* Mark thread as running and return */
intf_DbgMsg("vpar debug: InitThread(%p) succeeded\n", p_vpar); intf_DbgMsg("vpar debug: InitThread(%p) succeeded\n", p_vpar);
return( 0 ); return( 0 );
} }
/******************************************************************************* /*******************************************************************************
...@@ -289,15 +294,16 @@ static void ErrorThread( vpar_thread_t *p_vpar ) ...@@ -289,15 +294,16 @@ static void ErrorThread( vpar_thread_t *p_vpar )
vlc_mutex_lock( &p_vpar->fifo.data_lock ); vlc_mutex_lock( &p_vpar->fifo.data_lock );
/* ?? trash all trashable PES packets */ /* ?? trash all trashable PES packets */
while( !PARSER_FIFO_ISEMPTY(p_vpar->fifo) ) while( !DECODER_FIFO_ISEMPTY(p_vpar->fifo) )
{ {
input_NetlistFreePES( p_vpar->bit_stream.p_input, PARSER_FIFO_START(p_vpar->fifo) ); input_NetlistFreePES( p_vpar->bit_stream.p_input,
PARSER_FIFO_INCSTART( p_vpar->fifo ); DECODER_FIFO_START(p_vpar->fifo) );
DECODER_FIFO_INCSTART( p_vpar->fifo );
} }
vlc_mutex_unlock( &p_vpar->fifo.data_lock ); vlc_mutex_unlock( &p_vpar->fifo.data_lock );
/* Sleep a while */ /* Sleep a while */
msleep( VPAR_IDLE_SLEEP ); msleep( VPAR_IDLE_SLEEP );
} }
} }
...@@ -323,7 +329,7 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -323,7 +329,7 @@ static void EndThread( vpar_thread_t *p_vpar )
/* ?? */ /* ?? */
/* Destroy vdec threads */ /* Destroy vdec threads */
for( i_dummy = 0; i_dummy < MAX_VDEC; i_dummy++ ) for( i_dummy = 0; i_dummy < NB_VDEC; i_dummy++ )
{ {
if( p_vpar->p_vdec[i_dummy] != NULL ) if( p_vpar->p_vdec[i_dummy] != NULL )
vdec_DestroyThread( p_vpar->p_vdec[i_dummy] ); vdec_DestroyThread( p_vpar->p_vdec[i_dummy] );
......
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
* vpar_motion.c : motion vectors parsing
* (c)1999 VideoLAN
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
#include "video_parser.h"
#include "video_fifo.h"
#include "video_decoder.h"
/*
* Local prototypes
*/
/*****************************************************************************
* vpar_MPEG1MotionVector : Parse the next MPEG-1 motion vector
*****************************************************************************/
void vpar_MPEG1MotionVector( vpar_thread_t * p_vpar, int i_mv )
{
}
/*****************************************************************************
* vpar_MPEG2MotionVector : Parse the next MPEG-2 motion vector
*****************************************************************************/
void vpar_MPEG2MotionVector( vpar_thread_t * p_vpar, int i_mv )
{
}
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