]> git.sesse.net Git - vlc/blob - include/vpar_blocks.h
Oubli� d'en committer un bout...
[vlc] / include / vpar_blocks.h
1 /*****************************************************************************
2  * vpar_blocks.h : video parser blocks management
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Authors: Christophe Massiot <massiot@via.ecp.fr>
7  *          Jean-Marc Dressler <polux@via.ecp.fr>
8  *          Stéphane Borel <stef@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Requires:
27  *  "config.h"
28  *  "common.h"
29  *  "mtime.h"
30  *  "threads.h"
31  *  "input.h"
32  *  "video.h"
33  *  "video_output.h"
34  *  "decoder_fifo.h"
35  *  "video_fifo.h"
36  *****************************************************************************/
37
38 /*****************************************************************************
39  * macroblock_t : information on a macroblock passed to the video_decoder
40  *                thread
41  *****************************************************************************/
42 typedef struct macroblock_s
43 {
44     picture_t *             p_picture;          /* current frame in progress */
45
46     int                     i_mb_type;                    /* macroblock type */
47     int                     i_coded_block_pattern;
48                                                  /* which blocks are coded ? */
49     int                     i_chroma_nb_blocks;         /* number of blocks for
50                                                          * chroma components */
51
52     /* IDCT information */
53     dctelem_t               ppi_blocks[12][64];                    /* blocks */
54     f_idct_t                pf_idct[12];             /* sparse IDCT or not ? */
55     int                     pi_sparse_pos[12];             /* position of the
56                                                             * non-NULL coeff */
57
58     /* Motion compensation information */
59     f_motion_t              pf_motion;    /* function to use for motion comp */
60     picture_t *             p_backward;          /* backward reference frame */
61     picture_t *             p_forward;            /* forward reference frame */
62     int                     ppi_field_select[2][2];      /* field to use to
63                                                           * form predictions */
64     int                     pppi_motion_vectors[2][2][2];  /* motion vectors */
65     int                     ppi_dmv[2][2];    /* differential motion vectors */
66                             /* coordinates of the block in the picture */
67     int                     i_l_x, i_c_x;
68     int                     i_motion_l_y;
69     int                     i_motion_c_y;
70     int                     i_l_stride;         /* number of yuv_data_t to
71                                                  * ignore when changing line */
72     int                     i_c_stride;                  /* idem, for chroma */
73     boolean_t               b_P_second;  /* Second field of a P picture ?
74                                           * (used to determine the predicting
75                                           * frame)                           */
76     boolean_t               b_motion_field;  /* Field we are predicting
77                                               * (top field or bottom field) */
78
79     /* AddBlock information */
80     yuv_data_t *            p_data[12];              /* pointer to the position
81                                                       * in the final picture */
82     int                     i_addb_l_stride, i_addb_c_stride;
83                                  /* nb of coeffs to jump when changing lines */
84 } macroblock_t;
85
86 /*****************************************************************************
87  * macroblock_parsing_t : macroblock context & predictors
88  *****************************************************************************/
89 typedef struct
90 {
91     unsigned char       i_quantizer_scale;        /* scale of the quantization
92                                                    * matrices                */
93     int                 pi_dc_dct_pred[3];          /* ISO/IEC 13818-2 7.2.1 */
94     int                 pppi_pmv[2][2][2];  /* Motion vect predictors, 7.6.3 */
95     int                 i_motion_dir;/* Used for the next skipped macroblock */
96
97     /* Context used to optimize block parsing */
98     int                 i_motion_type, i_mv_count, i_mv_format;
99     boolean_t           b_dmv, b_dct_type;
100
101     /* Coordinates of the upper-left pixel of the macroblock, in lum and
102      * chroma */
103     int                 i_l_x, i_l_y, i_c_x, i_c_y;
104 } macroblock_parsing_t;
105
106 /*****************************************************************************
107  * lookup_t : entry type for lookup tables                                   *
108  *****************************************************************************/
109 typedef struct lookup_s
110 {
111     int    i_value;
112     int    i_length;
113 } lookup_t;
114
115 /*****************************************************************************
116  * ac_lookup_t : special entry type for lookup tables about ac coefficients
117  *****************************************************************************/
118 typedef struct dct_lookup_s
119 {
120     char   i_run;
121     char   i_level;
122     char   i_length;
123 } dct_lookup_t;
124
125 /*****************************************************************************
126  * Standard codes
127  *****************************************************************************/
128 /* Macroblock types */
129 #define MB_INTRA                        1
130 #define MB_PATTERN                      2
131 #define MB_MOTION_BACKWARD              4
132 #define MB_MOTION_FORWARD               8
133 #define MB_QUANT                        16
134
135 /* Motion types */
136 #define MOTION_FIELD                    1
137 #define MOTION_FRAME                    2
138 #define MOTION_16X8                     2
139 #define MOTION_DMV                      3
140
141 /* Macroblock Address Increment types */
142 #define MB_ADDRINC_ESCAPE               8
143 #define MB_ADDRINC_STUFFING             15
144
145 /* Error constant for lookup tables */
146 #define MB_ERROR                        (-1)
147
148 /* Scan */
149 #define SCAN_ZIGZAG                     0
150 #define SCAN_ALT                        1
151
152 /* Constant for block decoding */
153 #define DCT_EOB                         64
154 #define DCT_ESCAPE                      65
155
156 /*****************************************************************************
157  * Constants
158  *****************************************************************************/
159 extern int      pi_default_intra_quant[];
160 extern int      pi_default_nonintra_quant[];
161 extern u8       pi_scan[2][64];
162
163 /*****************************************************************************
164  * Prototypes
165  *****************************************************************************/
166 void vpar_InitCrop( struct vpar_thread_s* p_vpar );
167 void vpar_InitMbAddrInc( struct vpar_thread_s * p_vpar );
168 void vpar_InitPMBType( struct vpar_thread_s * p_vpar );
169 void vpar_InitBMBType( struct vpar_thread_s * p_vpar );
170 void vpar_InitCodedPattern( struct vpar_thread_s * p_vpar );
171 void vpar_InitDCTTables( struct vpar_thread_s * p_vpar );
172 void vpar_PictureData( struct vpar_thread_s * p_vpar, int i_mb_base );