]> git.sesse.net Git - vlc/blob - include/vpar_headers.h
5036f0b94be3a1a0bb20a65b23c8df4563e01d18
[vlc] / include / vpar_headers.h
1 /*****************************************************************************
2  * vpar_headers.h : video parser : headers parsing
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  *****************************************************************************/
17  
18 /*****************************************************************************
19  * Function pointers
20  *****************************************************************************/
21 struct vpar_thread_s;
22
23 typedef void    (*f_slice_header_t)( struct vpar_thread_s*, int*, int, u32);
24 typedef void    (*f_chroma_pattern_t)( struct vpar_thread_s* );
25 typedef int     (*f_macroblock_type_t)( struct vpar_thread_s* );
26
27 /*****************************************************************************
28  * quant_matrix_t : Quantization Matrix
29  *****************************************************************************/
30 typedef struct quant_matrix_s
31 {
32     int *       pi_matrix;
33     boolean_t   b_allocated;
34                           /* Has the matrix been allocated by vpar_headers ? */
35 } quant_matrix_t;
36
37 /*****************************************************************************
38  * sequence_t : sequence descriptor
39  *****************************************************************************/
40 typedef struct sequence_s
41 {
42     u32                 i_height, i_width, i_size;
43     u32                 i_mb_height, i_mb_width, i_mb_size;
44     unsigned int        i_aspect_ratio;
45     double              d_frame_rate;
46     boolean_t           b_mpeg2;
47     boolean_t           b_progressive;
48     unsigned int        i_scalable_mode;
49     f_slice_header_t    pf_slice_header;
50     quant_matrix_t      intra_quant, nonintra_quant;
51     quant_matrix_t      chroma_intra_quant, chroma_nonintra_quant;
52     void                (*pf_decode_mv)( struct vpar_thread_s *, int );
53     f_chroma_pattern_t  pf_decode_pattern;
54
55     /* Chromatic information */
56     unsigned int        i_chroma_format;
57     int                 i_chroma_nb_blocks;
58     u32                 i_chroma_width;
59     u32                 i_chroma_mb_width, i_chroma_mb_height;
60
61     /* Parser context */
62     picture_t *         p_forward;
63     picture_t *         p_backward;
64
65     /* Copyright extension */
66     boolean_t               b_copyright_flag;     /* Whether the following
67                                                      information is significant
68                                                      or not. */
69     u8                      i_copyright_id;
70     boolean_t               b_original;
71     u64                     i_copyright_nb;
72 } sequence_t;
73
74 /*****************************************************************************
75  * picture_parsing_t : parser context descriptor
76  *****************************************************************************/
77 typedef struct picture_parsing_s
78 {
79     boolean_t           pb_full_pel_vector[2];
80     int                 i_forward_f_code, i_backward_f_code;
81
82     int                 ppi_f_code[2][2];
83     int                 i_intra_dc_precision;
84     boolean_t           b_frame_pred_frame_dct, b_q_scale_type;
85     boolean_t           b_intra_vlc_format;
86     boolean_t           b_alternate_scan, b_progressive_frame;
87     boolean_t           b_top_field_first, b_concealment_mv;
88     boolean_t           b_repeat_first_field;
89     int                 i_l_stride, i_c_stride;
90
91     /* Used for second field management */
92     int                 i_current_structure;
93
94     picture_t *         p_picture;
95     macroblock_t *      pp_mb[MAX_MB];
96
97     /* Relative to the current field */
98     int                 i_coding_type, i_structure;
99     boolean_t           b_frame_structure;
100     f_macroblock_type_t pf_macroblock_type;
101
102     /* Scalability variables */
103     int                 i_spatial_temporal_weight_code_table_index;
104     
105     boolean_t           b_error;
106 } picture_parsing_t;
107
108 /*****************************************************************************
109  * slice_parsing_t : parser context descriptor #2
110  *****************************************************************************/
111 typedef struct slice_parsing_s
112 {
113     unsigned char       i_quantizer_scale;
114     int                 pi_dc_dct_pred[3];          /* ISO/IEC 13818-2 7.2.1 */
115     int                 pppi_pmv[2][2][2];  /* Motion vect predictors, 7.6.3 */
116 } slice_parsing_t;
117
118 /*****************************************************************************
119  * Standard codes
120  *****************************************************************************/
121 #define PICTURE_START_CODE      0x100
122 #define SLICE_START_CODE_MIN    0x101
123 #define SLICE_START_CODE_MAX    0x1AF
124 #define USER_DATA_START_CODE    0x1B2
125 #define SEQUENCE_HEADER_CODE    0x1B3
126 #define SEQUENCE_ERROR_CODE     0x1B4
127 #define EXTENSION_START_CODE    0x1B5
128 #define SEQUENCE_END_CODE       0x1B7
129 #define GROUP_START_CODE        0x1B8
130
131 /* extension start code IDs */
132 #define SEQUENCE_EXTENSION_ID                    1
133 #define SEQUENCE_DISPLAY_EXTENSION_ID            2
134 #define QUANT_MATRIX_EXTENSION_ID                3
135 #define COPYRIGHT_EXTENSION_ID                   4
136 #define SEQUENCE_SCALABLE_EXTENSION_ID           5
137 #define PICTURE_DISPLAY_EXTENSION_ID             7
138 #define PICTURE_CODING_EXTENSION_ID              8
139 #define PICTURE_SPATIAL_SCALABLE_EXTENSION_ID    9
140 #define PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID  10
141
142 /* scalable modes */
143 #define SC_NONE     0
144 #define SC_DP       1
145 #define SC_SPAT     2
146 #define SC_SNR      3
147 #define SC_TEMP     4
148
149 /* Pictures types */
150 #define I_CODING_TYPE           1
151 #define P_CODING_TYPE           2
152 #define B_CODING_TYPE           3
153 #define D_CODING_TYPE           4 /* MPEG-1 ONLY */
154 /* other values are reserved */
155
156 /* Structures */
157 #define TOP_FIELD               1
158 #define BOTTOM_FIELD            2
159 #define FRAME_STRUCTURE         3
160
161
162 /*****************************************************************************
163  * Prototypes
164  *****************************************************************************/
165 int vpar_NextSequenceHeader( struct vpar_thread_s * p_vpar );
166 int vpar_ParseHeader( struct vpar_thread_s * p_vpar );