]> git.sesse.net Git - vlc/blob - modules/demux/ogg.h
ogg: Fix theora length computing.
[vlc] / modules / demux / ogg.h
1 /*****************************************************************************
2  * ogg.h : ogg stream demux module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001-2010 the VideoLAN team
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
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 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 General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28
29
30
31
32 /*****************************************************************************
33  * Definitions of structures and functions used by this plugins
34  *****************************************************************************/
35
36
37 typedef struct oggseek_index_entry demux_index_entry_t;
38
39
40 typedef struct logical_stream_s
41 {
42     ogg_stream_state os;                        /* logical stream of packets */
43
44     es_format_t      fmt;
45     es_format_t      fmt_old;                  /* format of old ES is reused */
46     es_out_id_t      *p_es;
47     double           f_rate;
48
49     int              i_serial_no;
50
51     /* the header of some logical streams (eg vorbis) contain essential
52      * data for the decoder. We back them up here in case we need to re-feed
53      * them to the decoder. */
54     int              b_force_backup;
55     int              i_packets_backup;
56     void             *p_headers;
57     int              i_headers;
58
59     /* program clock reference (in units of 90kHz) derived from the previous
60      * granulepos */
61     mtime_t          i_pcr;
62     mtime_t          i_interpolated_pcr;
63     mtime_t          i_previous_pcr;
64
65     /* Misc */
66     bool b_reinit;
67     int i_granule_shift;
68     /* Opus has a starting offset in the headers. */
69     int i_pre_skip;
70
71     /* offset of first keyframe for theora; can be 0 or 1 depending on version number */
72     int64_t i_keyframe_offset;
73
74     /* keyframe index for seeking, created as we discover keyframes */
75     demux_index_entry_t *idx;
76
77     /* skip some frames after a seek */
78     int i_skip_frames;
79
80     /* data start offset (absolute) in bytes */
81     int64_t i_data_start;
82
83     /* kate streams have the number of headers in the ID header */
84     int i_kate_num_headers;
85
86     /* for Annodex logical bitstreams */
87     int i_secondary_header_packets;
88
89 } logical_stream_t;
90
91
92
93
94
95
96 struct demux_sys_t
97 {
98     ogg_sync_state oy;        /* sync and verify incoming physical bitstream */
99
100     int i_streams;                           /* number of logical bitstreams */
101     logical_stream_t **pp_stream;  /* pointer to an array of logical streams */
102
103     logical_stream_t *p_old_stream; /* pointer to a old logical stream to avoid recreating it */
104
105     /* program clock reference (in units of 90kHz) derived from the pcr of
106      * the sub-streams */
107     mtime_t i_pcr;
108
109     /* stream state */
110     int     i_bos;
111     int     i_eos;
112
113     /* bitrate */
114     int     i_bitrate;
115
116     /* after reading all headers, the first data page is stuffed into the relevant stream, ready to use */
117     bool    b_page_waiting;
118
119     /* count of total frames in video stream */
120     int64_t i_total_frames;
121
122     /* length of file in bytes */
123     int64_t i_total_length;
124
125     /* offset position in file (for reading) */
126     int64_t i_input_position;
127
128     /* current page being parsed */
129     ogg_page current_page;
130
131     mtime_t i_st_pts;
132
133
134     /* */
135     vlc_meta_t *p_meta;
136
137     /* */
138     int                i_attachments;
139     input_attachment_t **attachments;
140
141     /* Length, if available. */
142     int64_t i_length;
143 };