]> git.sesse.net Git - vlc/blob - src/video_parser/vpar_headers.c
D�but du d�codeur + d�but du parseur.
[vlc] / src / video_parser / vpar_headers.c
1 /*****************************************************************************
2  * vpar_headers.c : headers parsing
3  * (c)1999 VideoLAN
4  *****************************************************************************/
5
6 /* ?? passer en terminate/destroy avec les signaux supplémentaires */
7
8 /*****************************************************************************
9  * Preamble
10  *****************************************************************************/
11 #include <errno.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <unistd.h>
15 #include <string.h>
16 #include <sys/uio.h>
17 #include <X11/Xlib.h>
18 #include <X11/extensions/XShm.h>
19
20 #include "config.h"
21 #include "common.h"
22 #include "mtime.h"
23 #include "vlc_thread.h"
24
25 #include "intf_msg.h"
26 #include "debug.h"                    /* ?? temporaire, requis par netlist.h */
27
28 #include "input.h"
29 #include "input_netlist.h"
30 #include "decoder_fifo.h"
31 #include "video.h"
32 #include "video_output.h"
33 #include "video_parser.h"
34
35 #include "undec_picture.h"
36 #include "video_fifo.h"
37 #include "video_decoder.h"
38
39 /*
40  * Local prototypes
41  */
42
43 /*****************************************************************************
44  * vpar_NextSequenceHeader : Find the next sequence header
45  *****************************************************************************/
46 void vpar_NextSequenceHeader( vpar_thread_t * p_vpar )
47 {
48     while( !p_vpar->b_die )
49     {
50         NextStartCode( p_vpar );
51         if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_START_CODE )
52             return;
53     }
54 }
55
56 /*****************************************************************************
57  * vpar_ParseHeader : Parse the next header
58  *****************************************************************************/
59 int vpar_ParseHeader( vpar_thread_t * p_vpar )
60 {
61     while( !p_vpar->b_die )
62     {
63         NextStartCode( p_vpar );
64         switch( GetBits32( &p_vpar->bit_stream ) )
65         {
66         case SEQUENCE_HEADER_CODE:
67             SequenceHeader( p_vpar );
68             return 0;
69             break;
70
71         case GROUP_START_CODE:
72             GroupHeader( p_vpar );
73             return 0;
74             break;
75
76         case PICTURE_START_CODE:
77             PictureHeader( p_vpar );
78             return 0;
79             break;
80
81         case SEQUENCE_END_CODE:
82             return 1;
83             break;
84
85         default:
86         }
87     }
88
89     return 0;
90 }
91
92 /*
93  * Following functions are local
94  */
95
96 /*****************************************************************************
97  * NextStartCode : Find the next start code
98  *****************************************************************************/
99 static __inline__ void NextStartCode( vpar_thread_t * p_vpar )
100 {
101     /* Re-align the buffer to an 8-bit boundary */
102     DumpBits( &p_vpar->bit_stream, p_vpar->bit_stream.fifo.i_available & 7 );
103
104     while( ShowBits( &p_vpar->bit_stream, 24 ) != 0x01L && !p_vpar->b_die )
105     {
106         DumpBits( &p_vpar->bit_stream, 8 );
107     }
108 }
109
110 /*****************************************************************************
111  * SequenceHeader : Parse the next sequence header
112  *****************************************************************************/
113 static void SequenceHeader( vpar_thread_t * p_vpar )
114 {
115     int         i_frame_rate_code;
116
117     p_vpar->sequence.i_height = ntohl( GetBits( p_vpar->bit_stream, 12 ) );
118     p_vpar->sequence.i_width = ntohl( GetBits( p_vpar->bit_stream, 12 ) );
119     p_vpar->sequence.i_ratio = GetBits( p_vpar->bit_stream, 4 );
120     i_frame_rate_code = GetBits( p_vpar->bit_stream, 4 );
121
122     /* We don't need bit_rate_value, marker_bit, vbv_buffer_size,
123      * constrained_parameters_flag */
124     DumpBits( p_vpar->bits_stream, 30 );
125 }
126
127 /*****************************************************************************
128  * GroupHeader : Parse the next group of pictures header
129  *****************************************************************************/
130 static void GroupHeader( vpar_thread_t * p_vpar )
131 {
132
133 }
134 /*****************************************************************************
135  * PictureHeader : Parse the next picture header
136  *****************************************************************************/
137 static void PictureHeader( vpar_thread_t * p_vpar )
138 {
139
140 }