]> git.sesse.net Git - vlc/blob - include/video_parser.h
Encore du debuggage.
[vlc] / include / video_parser.h
1 /*****************************************************************************
2  * video_parser.h : video parser thread
3  * (c)1999 VideoLAN
4  *****************************************************************************
5  *****************************************************************************
6  * Requires:
7  *  "config.h"
8  *  "common.h"
9  *  "mtime.h"
10  *  "vlc_thread.h"
11  *  "input.h"
12  *  "video.h"
13  *  "video_output.h"
14  *  "decoder_fifo.h"
15  *  "video_fifo.h"
16  *  "vpar_headers.h"
17  *****************************************************************************/
18
19 /*****************************************************************************
20  * vpar_thread_t: video parser thread descriptor
21  *****************************************************************************
22  * ??
23  *****************************************************************************/
24 typedef struct vpar_thread_s
25 {
26     /* Thread properties and locks */
27     boolean_t           b_die;                                 /* `die' flag */
28     boolean_t           b_run;                                 /* `run' flag */
29     boolean_t           b_error;                             /* `error' flag */
30     boolean_t           b_active;                           /* `active' flag */
31     vlc_thread_t        thread_id;                /* id for thread functions */
32
33     /* Thread configuration */
34     /* ?? */
35  /*??*/
36 //    int *pi_status;
37     
38
39     /* Input properties */
40     decoder_fifo_t      fifo;                              /* PES input fifo */
41
42     /* The bit stream structure handles the PES stream at the bit level */
43     bit_stream_t        bit_stream;
44
45     /* Output properties */
46     vout_thread_t *     p_vout;                       /* video output thread */
47     int                 i_stream;                         /* video stream id */
48     
49     /* Decoder properties */
50     struct vdec_thread_s *      p_vdec[NB_VDEC];
51     video_fifo_t                vfifo;
52     video_buffer_t              vbuffer;
53
54     /* Parser properties */
55     sequence_t              sequence;
56     picture_parsing_t       picture;
57     slice_parsing_t         slice;
58     macroblock_parsing_t    mb;
59     video_synchro_t         synchro;
60
61     /* Lookup tables */
62 #ifdef MPEG2_COMPLIANT
63     s16                     pi_crop_buf[65536];
64     s16 *                   pi_crop;
65 #endif
66     lookup_t                pl_mb_addr_inc[2048];    /* for macroblock
67                                                         address increment */
68     /* variable length codes for the structure dct_dc_size */
69     lookup_t                pppl_dct_dc_size[2][2][32];  
70     /* tables for macroblock types 0=P 1=B */
71     lookup_t                pl_mb_type[2][64];
72     /* table for coded_block_pattern */
73     lookup_t                pl_coded_pattern[512];
74
75 #ifdef STATS
76     /* Statistics */
77     count_t         c_loops;                              /* number of loops */
78     count_t         c_idle_loops;                    /* number of idle loops */
79     count_t         c_sequences;                      /* number of sequences */
80     count_t         c_pictures;                   /* number of pictures read */
81     count_t         c_i_pictures;               /* number of I pictures read */
82     count_t         c_p_pictures;               /* number of P pictures read */
83     count_t         c_b_pictures;               /* number of B pictures read */
84     count_t         c_decoded_pictures;        /* number of pictures decoded */
85     count_t         c_decoded_i_pictures;    /* number of I pictures decoded */
86     count_t         c_decoded_p_pictures;    /* number of P pictures decoded */
87     count_t         c_decoded_b_pictures;    /* number of B pictures decoded */
88 #endif
89 } vpar_thread_t;
90
91 /* Chroma types */
92 #define CHROMA_420 1
93 #define CHROMA_422 2
94 #define CHROMA_444 3
95
96 /*****************************************************************************
97  * Prototypes
98  *****************************************************************************/
99
100 /* Thread management functions */
101 vpar_thread_t * vpar_CreateThread       ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*,
102                                           vout_thread_t *p_vout, int *pi_status */ );
103 void            vpar_DestroyThread      ( vpar_thread_t *p_vpar /*, int *pi_status */ );
104
105 /* Time management functions */
106 /* ?? */
107
108 /* Dynamic thread settings */
109 /* ?? */
110
111 /*****************************************************************************
112  * LoadQuantizerScale
113  *****************************************************************************
114  * Quantizer scale factor (ISO/IEC 13818-2 7.4.2.2)
115  *****************************************************************************/
116 static __inline__ void LoadQuantizerScale( struct vpar_thread_s * p_vpar )
117 {
118     /* Quantization coefficient table */
119     static u8   ppi_quantizer_scale[3][32] =
120     {
121         /* MPEG-2 */
122         {
123             /* q_scale_type */
124             /* linear */
125             0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,
126             32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
127         },
128         {
129             /* non-linear */
130             0, 1, 2, 3, 4, 5, 6, 7, 8, 10,12,14,16,18,20, 22,
131             24,28,32,36,40,44,48,52,56,64,72,80,88,96,104,112
132         },
133         /* MPEG-1 */
134         {
135             0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
136             16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
137         }
138     };
139
140     p_vpar->slice.i_quantizer_scale = ppi_quantizer_scale
141            [(!p_vpar->sequence.b_mpeg2 << 1) | p_vpar->picture.b_q_scale_type]
142            [GetBits( &p_vpar->bit_stream, 5 )];
143 }
144