]> git.sesse.net Git - vlc/blob - include/vpar_blocks.h
Suite du video_parser et du video_decoder.
[vlc] / include / vpar_blocks.h
1 /*****************************************************************************
2  * vpar_blocks.h : video parser blocks management
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  * macroblock_t : information on a macroblock
20  *****************************************************************************/
21 typedef struct macroblock_s
22 {
23     picture_t *             p_picture;
24     int                     i_mb_x, i_mb_y;
25     int                     i_structure;
26     int                     i_l_x, i_l_y;    /* position of macroblock (lum) */
27     int                     i_c_x, i_c_y; /* position of macroblock (chroma) */
28     int                     i_structure;
29     int                     i_chroma_nb_blocks;  /* nb of bks for a chr comp */
30
31     /* IDCT information */
32     elem_t                  ppi_blocks[12][64];                    /* blocks */
33     f_idct_t                pf_idct[12];             /* sparse IDCT or not ? */
34     int                     pi_sparse_pos[12];
35
36     /* Motion compensation information */
37     f_motion_t              pf_motion;    /* function to use for motion comp */
38     f_chroma_motion_t       pf_chroma_motion;
39     picture_t *             p_backw_top, p_backw_bot;
40     picture_t *             p_forw_top, p_forw_bot;
41     int                     i_field_select_backw_top, i_field_select_backw_bot;
42     int                     i_field_select_forw_top, i_field_select_forw_bot;
43     int                     pi_motion_vectors_backw_top[2];
44     int                     pi_motion_vectors_backw_bot[2];
45     int                     pi_motion_vectors_forw_top[2];
46     int                     pi_motion_vectors_forw_bot[2];
47
48     /* AddBlock information */
49     f_addb_t                pf_addb[12];
50     data_t *                p_data[12];    /* positions of blocks in picture */
51     int                     i_lum_incr, i_chroma_incr;
52 } macroblock_t;
53
54 /*****************************************************************************
55  * macroblock_parsing_t : parser context descriptor #3
56  *****************************************************************************/
57 typedef struct
58 {
59     int                     i_mb_type, i_motion_type, i_mv_count, i_mv_format;
60     int                     i_coded_block_pattern;
61     boolean_t               b_dct_type;
62 } macroblock_parsing_t;
63
64 /*****************************************************************************
65  * LoadQuantizerScale
66  *****************************************************************************
67  * Quantizer scale factor (ISO/IEC 13818-2 7.4.2.2)
68  *****************************************************************************/
69 static __inline__ void LoadQuantizerScale( vpar_thread_t * p_vpar )
70 {
71     /* Quantization coefficient table */
72     static unsigned char    ppi_quantizer_scale[3][32] =
73     {
74         /* MPEG-2 */
75         {
76             /* q_scale_type */
77             /* linear */
78             0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,
79             32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
80         },
81         {
82             /* non-linear */
83             0, 1, 2, 3, 4, 5, 6, 7, 8, 10,12,14,16,18,20, 22,
84             24,28,32,36,40,44,48,52,56,64,72,80,88,96,104,112
85         },
86         /* MPEG-1 */
87         {
88             0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
89             16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
90         }
91     };
92
93     p_vpar->slice.i_quantizer_scale = ppi_quantizer_scale
94            [(!p_vpar->sequence.b_mpeg2 << 1) | p_vpar->picture.b_q_scale_type]
95            [GetBits( &p_vpar->bit_stream, 5 )];
96 }
97
98 /*****************************************************************************
99  * Standard codes
100  *****************************************************************************/
101 /* Macroblock types */
102 #define MB_INTRA                        1
103 #define MB_PATTERN                      2
104 #define MB_MOTION_BACKWARD              4
105 #define MB_MOTION_FORWARD               8
106 #define MB_QUANT                        16
107
108 /* Motion types */
109 #define MOTION_FIELD                    1
110 #define MOTION_FRAME                    2
111 #define MOTION_16X8                     2
112 #define MOTION_DMV                      3