]> git.sesse.net Git - vlc/blob - modules/demux/ogg.h
Qt: ExtensionItemDelegate: remove unused members
[vlc] / modules / demux / ogg.h
1 /*****************************************************************************
2  * ogg.h : ogg stream demux module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001-2010 VLC authors and VideoLAN
5  *
6  * Authors: Gildas Bazin <gbazin@netcourrier.com>
7  *          Andre Pang <Andre.Pang@csiro.au> (Annodex support)
8  *          Gabriel Finch <salsaman@gmail.com> (moved from ogg.c to ogg.h)
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Definitions of structures and functions used by this plugin
27  *****************************************************************************/
28
29 //#define OGG_DEMUX_DEBUG 1
30 #ifdef OGG_DEMUX_DEBUG
31   #define DemuxDebug(code) code
32 #else
33   #define DemuxDebug(code)
34 #endif
35
36 /* Some defines from OggDS http://svn.xiph.org/trunk/oggds/ */
37 #define PACKET_TYPE_HEADER   0x01
38 #define PACKET_TYPE_BITS     0x07
39 #define PACKET_LEN_BITS01    0xc0
40 #define PACKET_LEN_BITS2     0x02
41 #define PACKET_IS_SYNCPOINT  0x08
42
43 typedef struct oggseek_index_entry demux_index_entry_t;
44 typedef struct ogg_skeleton_t ogg_skeleton_t;
45
46 typedef struct logical_stream_s
47 {
48     ogg_stream_state os;                        /* logical stream of packets */
49
50     es_format_t      fmt;
51     es_format_t      fmt_old;                  /* format of old ES is reused */
52     es_out_id_t      *p_es;
53     double           f_rate;
54
55     int              i_serial_no;
56
57     /* the header of some logical streams (eg vorbis) contain essential
58      * data for the decoder. We back them up here in case we need to re-feed
59      * them to the decoder. */
60     bool             b_force_backup;
61     int              i_packets_backup;
62     int32_t          i_extra_headers_packets;
63     void             *p_headers;
64     int              i_headers;
65     ogg_int64_t      i_previous_granulepos;
66
67     /* program clock reference (in units of 90kHz) derived from the previous
68      * granulepos */
69     mtime_t          i_pcr;
70     mtime_t          i_interpolated_pcr;
71     mtime_t          i_previous_pcr;
72
73     /* Misc */
74     bool b_initializing;
75     bool b_finished;
76     bool b_reinit;
77     bool b_oggds;
78     int i_granule_shift;
79
80     /* Opus has a starting offset in the headers. */
81     int i_pre_skip;
82     /* Vorbis and Opus can trim the end of a stream using granule positions. */
83     int i_end_trim;
84
85     /* offset of first keyframe for theora; can be 0 or 1 depending on version number */
86     int8_t i_keyframe_offset;
87
88     /* keyframe index for seeking, created as we discover keyframes */
89     demux_index_entry_t *idx;
90
91     /* Skeleton data */
92     ogg_skeleton_t *p_skel;
93
94     /* skip some frames after a seek */
95     int i_skip_frames;
96
97     /* data start offset (absolute) in bytes */
98     int64_t i_data_start;
99
100     /* kate streams have the number of headers in the ID header */
101     int i_kate_num_headers;
102
103     /* for Annodex logical bitstreams */
104     int i_secondary_header_packets;
105
106     block_t *p_preparse_block;
107 } logical_stream_t;
108
109 struct ogg_skeleton_t
110 {
111     int            i_messages;
112     char         **ppsz_messages;
113     unsigned char *p_index;
114     uint64_t       i_index;
115     uint64_t       i_index_size;
116     int64_t        i_indexstampden;/* time denominator */
117     int64_t        i_indexfirstnum;/* first sample time numerator */
118     int64_t        i_indexlastnum;
119 };
120
121 struct demux_sys_t
122 {
123     ogg_sync_state oy;        /* sync and verify incoming physical bitstream */
124
125     int i_streams;                           /* number of logical bitstreams */
126     logical_stream_t **pp_stream;  /* pointer to an array of logical streams */
127     logical_stream_t *p_skelstream; /* pointer to skeleton stream if any */
128
129     logical_stream_t *p_old_stream; /* pointer to a old logical stream to avoid recreating it */
130
131     /* program clock reference (in units of 90kHz) derived from the pcr of
132      * the sub-streams */
133     mtime_t i_pcr;
134     mtime_t i_pcr_offset;
135     /* informative only */
136     mtime_t i_pcr_jitter;
137     int64_t i_access_delay;
138
139     /* new stream or starting from a chain */
140     bool b_chained_boundary;
141
142     /* bitrate */
143     int     i_bitrate;
144     bool    b_partial_bitrate;
145
146     /* after reading all headers, the first data page is stuffed into the relevant stream, ready to use */
147     bool    b_page_waiting;
148
149     /* count of total frames in video stream */
150     int64_t i_total_frames;
151
152     /* length of file in bytes */
153     int64_t i_total_length;
154
155     /* offset position in file (for reading) */
156     int64_t i_input_position;
157
158     /* current page being parsed */
159     ogg_page current_page;
160
161     /* */
162     vlc_meta_t          *p_meta;
163     int                 i_seekpoints;
164     seekpoint_t         **pp_seekpoints;
165
166     /* skeleton */
167     struct
168     {
169         uint16_t major;
170         uint16_t minor;
171     } skeleton;
172
173     /* */
174     int                 i_attachments;
175     input_attachment_t  **attachments;
176
177     /* preparsing info */
178     bool b_preparsing_done;
179     bool b_es_created;
180
181     /* Length, if available. */
182     int64_t i_length;
183
184     DemuxDebug( bool b_seeked; )
185 };
186
187
188 unsigned const char * Read7BitsVariableLE( unsigned const char *,
189                                            unsigned const char *,
190                                            uint64_t * );
191 bool Ogg_GetBoundsUsingSkeletonIndex( logical_stream_t *p_stream, int64_t i_time,
192                                       int64_t *pi_lower, int64_t *pi_upper );