]> git.sesse.net Git - vlc/blob - include/vpar_headers.h
Encore un commit venu tout droit des abysses de l'enfer, d�sol� pour
[vlc] / include / vpar_headers.h
1 /*****************************************************************************
2  * vpar_headers.h : video parser : headers parsing
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this program; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Requires:
26  *  "config.h"
27  *  "common.h"
28  *  "mtime.h"
29  *  "threads.h"
30  *  "input.h"
31  *  "video.h"
32  *  "video_output.h"
33  *  "decoder_fifo.h"
34  *  "video_fifo.h"
35  *****************************************************************************/
36
37 /*****************************************************************************
38  * quant_matrix_t : Quantization Matrix
39  *****************************************************************************/
40 typedef struct quant_matrix_s
41 {
42     int *       pi_matrix;
43     boolean_t   b_allocated;
44                           /* Has the matrix been allocated by vpar_headers ? */
45 } quant_matrix_t;
46
47 /*****************************************************************************
48  * sequence_t : sequence descriptor
49  *****************************************************************************
50  * This structure should only be changed when reading the sequence header,
51  * or exceptionnally some extension structures (like quant_matrix).
52  *****************************************************************************/
53 typedef struct sequence_s
54 {
55     u32                 i_height, i_width;      /* height and width of the lum
56                                                  * comp of the picture       */
57     u32                 i_size;       /* total number of pel of the lum comp */
58     u32                 i_mb_height, i_mb_width, i_mb_size;
59                                             /* the same, in macroblock units */
60     unsigned int        i_aspect_ratio;        /* height/width display ratio */
61     unsigned int        i_matrix_coefficients;/* coeffs of the YUV transform */
62     float               r_frame_rate;       /* theoritical frame rate in fps */
63     boolean_t           b_mpeg2;                                    /* guess */
64     boolean_t           b_progressive;              /* progressive (ie.
65                                                      * non-interlaced) frame */
66     unsigned int        i_scalable_mode; /* scalability ; unsupported, but
67                                           * modifies the syntax of the binary
68                                           * stream.                          */
69     quant_matrix_t      intra_quant, nonintra_quant;
70     quant_matrix_t      chroma_intra_quant, chroma_nonintra_quant;
71                                             /* current quantization matrices */
72
73     /* Chromatic information */
74     unsigned int        i_chroma_format;               /* see CHROMA_* below */
75     int                 i_chroma_nb_blocks;       /* number of chroma blocks */
76     u32                 i_chroma_width;/* width of a line of the chroma comp */
77     u32                 i_chroma_mb_width, i_chroma_mb_height;
78                                  /* size of a macroblock in the chroma buffer
79                                   * (eg. 8x8 or 8x16 or 16x16)               */
80
81     /* Parser context */
82     picture_t *         p_forward;        /* current forward reference frame */
83     picture_t *         p_backward;      /* current backward reference frame */
84
85     /* Copyright extension */
86     boolean_t           b_copyright_flag;     /* Whether the following
87                                                  information is significant
88                                                  or not. */
89     u8                  i_copyright_id;
90     boolean_t           b_original;
91     u64                 i_copyright_nb;
92 } sequence_t;
93
94 /*****************************************************************************
95  * picture_parsing_t : parser context descriptor
96  *****************************************************************************
97  * This structure should only be changed when reading the picture header.
98  *****************************************************************************/
99 typedef struct picture_parsing_s
100 {
101     /* ISO/CEI 11172-2 backward compatibility */
102     boolean_t           pb_full_pel_vector[2];
103     int                 i_forward_f_code, i_backward_f_code;
104
105     /* Values from the picture_coding_extension. Please refer to ISO/IEC
106      * 13818-2. */
107     int                 ppi_f_code[2][2];
108     int                 i_intra_dc_precision;
109     boolean_t           b_frame_pred_frame_dct, b_q_scale_type;
110     boolean_t           b_intra_vlc_format;
111     boolean_t           b_alternate_scan, b_progressive_frame;
112     boolean_t           b_top_field_first, b_concealment_mv;
113     boolean_t           b_repeat_first_field;
114     /* Relative to the current field */
115     int                 i_coding_type, i_structure;
116     boolean_t           b_frame_structure; /* i_structure == FRAME_STRUCTURE */
117
118     picture_t *         p_picture;               /* picture buffer from vout */
119     int                 i_current_structure;   /* current parsed structure of
120                                                 * p_picture (second field ?) */
121 #ifdef VDEC_SMP
122     macroblock_t *      pp_mb[MAX_MB];         /* macroblock buffer to
123                                                 * send to the vdec thread(s) */
124 #endif
125     boolean_t           b_error;            /* parsing error, try to recover */
126
127     int                 i_l_stride, i_c_stride;
128                                     /* number of coeffs to jump when changing
129                                      * lines (different with field pictures) */
130 } picture_parsing_t;
131
132 /*****************************************************************************
133  * Standard codes
134  *****************************************************************************/
135 #define PICTURE_START_CODE      0x100L
136 #define SLICE_START_CODE_MIN    0x101L
137 #define SLICE_START_CODE_MAX    0x1AFL
138 #define USER_DATA_START_CODE    0x1B2L
139 #define SEQUENCE_HEADER_CODE    0x1B3L
140 #define SEQUENCE_ERROR_CODE     0x1B4L
141 #define EXTENSION_START_CODE    0x1B5L
142 #define SEQUENCE_END_CODE       0x1B7L
143 #define GROUP_START_CODE        0x1B8L
144
145 /* extension start code IDs */
146 #define SEQUENCE_EXTENSION_ID                    1
147 #define SEQUENCE_DISPLAY_EXTENSION_ID            2
148 #define QUANT_MATRIX_EXTENSION_ID                3
149 #define COPYRIGHT_EXTENSION_ID                   4
150 #define SEQUENCE_SCALABLE_EXTENSION_ID           5
151 #define PICTURE_DISPLAY_EXTENSION_ID             7
152 #define PICTURE_CODING_EXTENSION_ID              8
153 #define PICTURE_SPATIAL_SCALABLE_EXTENSION_ID    9
154 #define PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID  10
155
156 /* scalable modes */
157 #define SC_NONE     0
158 #define SC_DP       1
159 #define SC_SPAT     2
160 #define SC_SNR      3
161 #define SC_TEMP     4
162
163 /* Chroma types */
164 #define CHROMA_420 1
165 #define CHROMA_422 2
166 #define CHROMA_444 3
167
168 /* Pictures types */
169 #define I_CODING_TYPE           1
170 #define P_CODING_TYPE           2
171 #define B_CODING_TYPE           3
172 #define D_CODING_TYPE           4 /* MPEG-1 ONLY */
173 /* other values are reserved */
174
175 /* Structures */
176 #define TOP_FIELD               1
177 #define BOTTOM_FIELD            2
178 #define FRAME_STRUCTURE         3
179
180 /*****************************************************************************
181  * Prototypes
182  *****************************************************************************/
183 int vpar_NextSequenceHeader( struct vpar_thread_s * p_vpar );
184 int vpar_ParseHeader( struct vpar_thread_s * p_vpar );