Commit 81b0f175 authored by Gaël Hendryckx's avatar Gaël Hendryckx

  Et le petit toast qui va avec...
parent 4d8747f7
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
* General compilation options * General compilation options
*******************************************************************************/ *******************************************************************************/
#define FRAMEBUFFER
/* Define for DVB support - Note that some extensions or restrictions may be /* Define for DVB support - Note that some extensions or restrictions may be
* incompatible with native MPEG2 streams */ * incompatible with native MPEG2 streams */
//#define DVB_EXTENSIONS //#define DVB_EXTENSIONS
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
/***************************************************************************** /*****************************************************************************
* Common declarations * Common declarations
*****************************************************************************/ *****************************************************************************/
#ifndef VDEC_DFT #ifndef VDEC_DFT
typedef short elem_t; typedef short elem_t;
#else #else
...@@ -21,6 +22,122 @@ typedef int elem_t; ...@@ -21,6 +22,122 @@ typedef int elem_t;
struct vdec_thread_s; struct vdec_thread_s;
#define SPARSE_SCALE_FACTOR 8
#define DCTSIZE 8 /* 8*8 DCT */
/*****************************************************************************
* Macros
*****************************************************************************/
/* We assume that right shift corresponds to signed division by 2 with
* rounding towards minus infinity. This is correct for typical "arithmetic
* shift" instructions that shift in copies of the sign bit. But some
* C compilers implement >> with an unsigned shift. For these machines you
* must define RIGHT_SHIFT_IS_UNSIGNED.
* RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
* It is only applied with constant shift counts. SHIFT_TEMPS must be
* included in the variables of any routine using RIGHT_SHIFT.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define SHIFT_TEMPS INT32 shift_temp;
#define RIGHT_SHIFT(x,shft) \
((shift_temp = (x)) < 0 ? \
(shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
(shift_temp >> (shft)))
#else
#define SHIFT_TEMPS
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
/*
* A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT
* on each column. Direct algorithms are also available, but they are
* much more complex and seem not to be any faster when reduced to code.
*
* The poop on this scaling stuff is as follows:
*
* Each 1-D IDCT step produces outputs which are a factor of sqrt(N)
* larger than the true IDCT outputs. The final outputs are therefore
* a factor of N larger than desired; since N=8 this can be cured by
* a simple right shift at the end of the algorithm. The advantage of
* this arrangement is that we save two multiplications per 1-D IDCT,
* because the y0 and y4 inputs need not be divided by sqrt(N).
*
* We have to do addition and subtraction of the integer inputs, which
* is no problem, and multiplication by fractional constants, which is
* a problem to do in integer arithmetic. We multiply all the constants
* by CONST_SCALE and convert them to integer constants (thus retaining
* CONST_BITS bits of precision in the constants). After doing a
* multiplication we have to divide the product by CONST_SCALE, with proper
* rounding, to produce the correct output. This division can be done
* cheaply as a right shift of CONST_BITS bits. We postpone shifting
* as long as possible so that partial sums can be added together with
* full fractional precision.
*
* The outputs of the first pass are scaled up by PASS1_BITS bits so that
* they are represented to better-than-integral precision. These outputs
* require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
* with the recommended scaling. (To scale up 12-bit sample data further, an
* intermediate INT32 array would be needed.)
*
* To avoid overflow of the 32-bit intermediate results in pass 2, we must
* have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
* shows that the values given below are the most effective.
*/
#ifdef EIGHT_BIT_SAMPLES
#define PASS1_BITS 2
#else
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
#define ONE ((INT32) 1)
#define CONST_SCALE (ONE << CONST_BITS)
/* Convert a positive real constant to an integer scaled by CONST_SCALE.
* IMPORTANT: if your compiler doesn't do this arithmetic at compile time,
* you will pay a significant penalty in run time. In that case, figure
* the correct integer constant values and insert them by hand.
*/
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
/* When adding two opposite-signed fixes, the 0.5 cancels */
#define FIX2(x) ((INT32) ((x) * CONST_SCALE))
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
* 16x16->32 bit multiply can be used instead of a full 32x32 multiply;
* this provides a useful speedup on many machines.
* There is no way to specify a 16x16->32 multiply in portable C, but
* some C compilers will do the right thing if you provide the correct
* combination of casts.
* NB: for 12-bit samples, a full 32-bit multiplication will be needed.
*/
#ifdef EIGHT_BIT_SAMPLES
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const)))
#endif
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT32) (const)))
#endif
#endif
#ifndef MULTIPLY /* default definition */
#define MULTIPLY(var,const) ((var) * (const))
#endif
/***************************************************************************** /*****************************************************************************
* Function pointers * Function pointers
*****************************************************************************/ *****************************************************************************/
...@@ -30,5 +147,6 @@ typedef void (*f_idct_t)( struct vdec_thread_s *, elem_t*, int ); ...@@ -30,5 +147,6 @@ typedef void (*f_idct_t)( struct vdec_thread_s *, elem_t*, int );
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
void vdec_DummyIDCT( struct vdec_thread_s *, elem_t*, int ); void vdec_DummyIDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_InitIDCT (struct vdec_thread_s * p_vdec)
void vdec_SparseIDCT( struct vdec_thread_s *, elem_t*, int ); void vdec_SparseIDCT( struct vdec_thread_s *, elem_t*, int );
void vdec_IDCT( struct vdec_thread_s *, elem_t*, int ); void vdec_IDCT( struct vdec_thread_s *, elem_t*, int );
/******************************************************************************* /*****************************************************************************
* video_decoder.h : video decoder thread * video_decoder.h : video decoder thread
* (c)1999 VideoLAN * (c)1999 VideoLAN
******************************************************************************* *****************************************************************************
******************************************************************************* *****************************************************************************
* Requires: * Requires:
* "config.h" * "config.h"
* "common.h" * "common.h"
...@@ -12,21 +12,21 @@ ...@@ -12,21 +12,21 @@
* "video.h" * "video.h"
* "video_output.h" * "video_output.h"
* "decoder_fifo.h" * "decoder_fifo.h"
*******************************************************************************/ *****************************************************************************/
/******************************************************************************* /*****************************************************************************
* vdec_thread_t: video decoder thread descriptor * vdec_thread_t: video decoder thread descriptor
******************************************************************************* *****************************************************************************
* ?? * ??
*******************************************************************************/ *****************************************************************************/
typedef struct vdec_thread_s typedef struct vdec_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 */
/* ?? */ /* ?? */
...@@ -35,39 +35,27 @@ typedef struct vdec_thread_s ...@@ -35,39 +35,27 @@ typedef struct vdec_thread_s
/* Input properties */ /* Input properties */
decoder_fifo_t fifo; /* PES input fifo */ video_parser_t * p_vpar; /* video_parser thread */
short int p_pre_idct[64*64]; /* initialization of sparse idct routines */
/* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream;
/* Output properties */
vout_thread_t * p_vout; /* video output thread */
int i_stream; /* video stream id */
#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_pictures; /* number of pictures read */ count_t c_decoded_pictures; /* number of pictures decoded */
count_t c_i_pictures; /* number of I pictures read */ count_t c_decoded_i_pictures; /* number of I pictures decoded */
count_t c_p_pictures; /* number of P pictures read */ count_t c_decoded_p_pictures; /* number of P pictures decoded */
count_t c_b_pictures; /* number of B pictures read */ count_t c_decoded_b_pictures; /* number of B 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_p_pictures; /* number of P pictures decoded */
count_t c_decoded_b_pictures; /* number of B pictures decoded */
#endif #endif
} vdec_thread_t; } vdec_thread_t;
/******************************************************************************* /*****************************************************************************
* Prototypes * Prototypes
*******************************************************************************/ *****************************************************************************/
/* Thread management functions */ /* Thread management functions */
vdec_thread_t * vdec_CreateThread ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*, vdec_thread_t * vdec_CreateThread ( vpar_thread_t *p_vpar /*, int *pi_status */ );
vout_thread_t *p_vout, int *pi_status */ ); void vdec_DestroyThread ( vdec_thread_t *p_vdec /*, int *pi_status */ );
void vdec_DestroyThread ( vdec_thread_t *p_vdec /*, int *pi_status */ );
/* Time management functions */ /* Time management functions */
/* ?? */ /* ?? */
......
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