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