1 /*****************************************************************************
2 * vpar_headers.c : headers parsing
4 *****************************************************************************/
6 /* ?? passer en terminate/destroy avec les signaux supplémentaires */
8 /*****************************************************************************
10 *****************************************************************************/
18 #include <X11/extensions/XShm.h>
23 #include "vlc_thread.h"
26 #include "debug.h" /* ?? temporaire, requis par netlist.h */
29 #include "input_netlist.h"
30 #include "decoder_fifo.h"
32 #include "video_output.h"
33 #include "video_parser.h"
35 #include "undec_picture.h"
36 #include "video_fifo.h"
37 #include "video_decoder.h"
43 /*****************************************************************************
44 * vpar_NextSequenceHeader : Find the next sequence header
45 *****************************************************************************/
46 void vpar_NextSequenceHeader( vpar_thread_t * p_vpar )
48 while( !p_vpar->b_die )
50 NextStartCode( p_vpar );
51 if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_START_CODE )
56 /*****************************************************************************
57 * vpar_ParseHeader : Parse the next header
58 *****************************************************************************/
59 int vpar_ParseHeader( vpar_thread_t * p_vpar )
61 while( !p_vpar->b_die )
63 NextStartCode( p_vpar );
64 switch( GetBits32( &p_vpar->bit_stream ) )
66 case SEQUENCE_HEADER_CODE:
67 SequenceHeader( p_vpar );
71 case GROUP_START_CODE:
72 GroupHeader( p_vpar );
76 case PICTURE_START_CODE:
77 PictureHeader( p_vpar );
81 case SEQUENCE_END_CODE:
93 * Following functions are local
96 /*****************************************************************************
97 * NextStartCode : Find the next start code
98 *****************************************************************************/
99 static __inline__ void NextStartCode( vpar_thread_t * p_vpar )
101 /* Re-align the buffer to an 8-bit boundary */
102 DumpBits( &p_vpar->bit_stream, p_vpar->bit_stream.fifo.i_available & 7 );
104 while( ShowBits( &p_vpar->bit_stream, 24 ) != 0x01L && !p_vpar->b_die )
106 DumpBits( &p_vpar->bit_stream, 8 );
110 /*****************************************************************************
111 * SequenceHeader : Parse the next sequence header
112 *****************************************************************************/
113 static void SequenceHeader( vpar_thread_t * p_vpar )
115 int i_frame_rate_code;
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 );
122 /* We don't need bit_rate_value, marker_bit, vbv_buffer_size,
123 * constrained_parameters_flag */
124 DumpBits( p_vpar->bits_stream, 30 );
127 /*****************************************************************************
128 * GroupHeader : Parse the next group of pictures header
129 *****************************************************************************/
130 static void GroupHeader( vpar_thread_t * p_vpar )
134 /*****************************************************************************
135 * PictureHeader : Parse the next picture header
136 *****************************************************************************/
137 static void PictureHeader( vpar_thread_t * p_vpar )