]> git.sesse.net Git - vlc/blob - src/video_decoder/vpar_headers.h
* Borrowed LiViD's MMX and MMX EXT IDCT.
[vlc] / src / video_decoder / vpar_headers.h
1 /*****************************************************************************
2  * vpar_headers.h : video parser : headers parsing
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: vpar_headers.h,v 1.4 2001/01/17 18:17:30 massiot Exp $
6  *
7  * Authors: Christophe Massiot <massiot@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  * quant_matrix_t : Quantization Matrix
40  *****************************************************************************/
41 typedef struct quant_matrix_s
42 {
43     u8 *        pi_matrix;
44     boolean_t   b_allocated;
45                           /* Has the matrix been allocated by vpar_headers ? */
46 } quant_matrix_t;
47
48 /*****************************************************************************
49  * sequence_t : sequence descriptor
50  *****************************************************************************
51  * This structure should only be changed when reading the sequence header,
52  * or exceptionnally some extension structures (like quant_matrix).
53  *****************************************************************************/
54 typedef struct sequence_s
55 {
56     u32                 i_height, i_width;      /* height and width of the lum
57                                                  * comp of the picture       */
58     u32                 i_size;       /* total number of pel of the lum comp */
59     u32                 i_mb_height, i_mb_width, i_mb_size;
60                                             /* the same, in macroblock units */
61     unsigned int        i_aspect_ratio;        /* height/width display ratio */
62     unsigned int        i_matrix_coefficients;/* coeffs of the YUV transform */
63     int                 i_frame_rate;  /* theoritical frame rate in fps*1001 */
64     boolean_t           b_mpeg2;                                    /* guess */
65     boolean_t           b_progressive;              /* progressive (ie.
66                                                      * non-interlaced) frame */
67     unsigned int        i_scalable_mode; /* scalability ; unsupported, but
68                                           * modifies the syntax of the binary
69                                           * stream.                          */
70     quant_matrix_t      intra_quant, nonintra_quant;
71     quant_matrix_t      chroma_intra_quant, chroma_nonintra_quant;
72                                             /* current quantization matrices */
73
74     /* Chromatic information */
75     unsigned int        i_chroma_format;               /* see CHROMA_* below */
76     int                 i_chroma_nb_blocks;       /* number of chroma blocks */
77     u32                 i_chroma_width;/* width of a line of the chroma comp */
78     u32                 i_chroma_mb_width, i_chroma_mb_height;
79                                  /* size of a macroblock in the chroma buffer
80                                   * (eg. 8x8 or 8x16 or 16x16)               */
81
82     /* Parser context */
83     picture_t *         p_forward;        /* current forward reference frame */
84     picture_t *         p_backward;      /* current backward reference frame */
85     mtime_t             next_pts, next_dts;
86
87     /* Copyright extension */
88     boolean_t           b_copyright_flag;     /* Whether the following
89                                                  information is significant
90                                                  or not. */
91     u8                  i_copyright_id;
92     boolean_t           b_original;
93     u64                 i_copyright_nb;
94 } sequence_t;
95
96 /*****************************************************************************
97  * picture_parsing_t : parser context descriptor
98  *****************************************************************************
99  * This structure should only be changed when reading the picture header.
100  *****************************************************************************/
101 typedef struct picture_parsing_s
102 {
103     /* ISO/CEI 11172-2 backward compatibility */
104     boolean_t           pb_full_pel_vector[2];
105     int                 i_forward_f_code, i_backward_f_code;
106
107     /* Values from the picture_coding_extension. Please refer to ISO/IEC
108      * 13818-2. */
109     int                 ppi_f_code[2][2];
110     int                 i_intra_dc_precision;
111     boolean_t           b_frame_pred_frame_dct, b_q_scale_type;
112     boolean_t           b_intra_vlc_format;
113     boolean_t           b_alternate_scan, b_progressive;
114     boolean_t           b_top_field_first, b_concealment_mv;
115     boolean_t           b_repeat_first_field;
116     /* Relative to the current field */
117     int                 i_coding_type, i_structure;
118     boolean_t           b_frame_structure; /* i_structure == FRAME_STRUCTURE */
119
120     picture_t *         p_picture;               /* picture buffer from vout */
121     int                 i_current_structure;   /* current parsed structure of
122                                                 * p_picture (second field ?) */
123 #ifdef VDEC_SMP
124     macroblock_t *      pp_mb[MAX_MB];         /* macroblock buffer to
125                                                 * send to the vdec thread(s) */
126 #endif
127     boolean_t           b_error;            /* parsing error, try to recover */
128
129     int                 i_l_stride, i_c_stride;
130                                     /* number of coeffs to jump when changing
131                                      * lines (different with field pictures) */
132 } picture_parsing_t;
133
134 /*****************************************************************************
135  * Standard codes
136  *****************************************************************************/
137 #define PICTURE_START_CODE      0x100L
138 #define SLICE_START_CODE_MIN    0x101L
139 #define SLICE_START_CODE_MAX    0x1AFL
140 #define USER_DATA_START_CODE    0x1B2L
141 #define SEQUENCE_HEADER_CODE    0x1B3L
142 #define SEQUENCE_ERROR_CODE     0x1B4L
143 #define EXTENSION_START_CODE    0x1B5L
144 #define SEQUENCE_END_CODE       0x1B7L
145 #define GROUP_START_CODE        0x1B8L
146
147 /* extension start code IDs */
148 #define SEQUENCE_EXTENSION_ID                    1
149 #define SEQUENCE_DISPLAY_EXTENSION_ID            2
150 #define QUANT_MATRIX_EXTENSION_ID                3
151 #define COPYRIGHT_EXTENSION_ID                   4
152 #define SEQUENCE_SCALABLE_EXTENSION_ID           5
153 #define PICTURE_DISPLAY_EXTENSION_ID             7
154 #define PICTURE_CODING_EXTENSION_ID              8
155 #define PICTURE_SPATIAL_SCALABLE_EXTENSION_ID    9
156 #define PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID  10
157
158 /* scalable modes */
159 #define SC_NONE     0
160 #define SC_DP       1
161 #define SC_SPAT     2
162 #define SC_SNR      3
163 #define SC_TEMP     4
164
165 /* Chroma types */
166 #define CHROMA_420 1
167 #define CHROMA_422 2
168 #define CHROMA_444 3
169
170 /* Pictures types */
171 #define I_CODING_TYPE           1
172 #define P_CODING_TYPE           2
173 #define B_CODING_TYPE           3
174 #define D_CODING_TYPE           4 /* MPEG-1 ONLY */
175 /* other values are reserved */
176
177 /* Structures */
178 #define TOP_FIELD               1
179 #define BOTTOM_FIELD            2
180 #define FRAME_STRUCTURE         3
181
182 /*****************************************************************************
183  * Prototypes
184  *****************************************************************************/
185 int vpar_NextSequenceHeader( struct vpar_thread_s * p_vpar );
186 int vpar_ParseHeader( struct vpar_thread_s * p_vpar );