1 /**
2 * Copyright (C) 2005 Matthieu CASTET, Alex Beregszaszi
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 **/
24
25 #include <stdlib.h>
31
37
39 {
45 int err;
46 uint8_t *cdp;
47
49 return 0;
50
51 if (!thp) {
53 if (!thp)
56 }
57
59 case 0x80: {
62
64
65 /* 0x80"theora" */
67
71 "Too old or unsupported Theora (%x)\n", thp->
version);
73 }
74
77
80
88 }
89
91 }
92
95 if (!(timebase.
num > 0 && timebase.
den > 0)) {
99 }
101
104
109
112
116 }
117 break;
118 case 0x81:
120 case 0x82:
123 break;
124 default:
127 }
128
132 return err;
133 }
135
137 *cdp++ = os->
psize >> 8;
138 *cdp++ = os->
psize & 0xff;
141
142 return 1;
143 }
144
146 int64_t *dts)
147 {
151 uint64_t iframe, pframe;
152
153 if (!thp)
155
158
160 iframe++;
161
162 if (!pframe)
164
165 if (dts)
166 *dts = iframe + pframe;
167
168 return iframe + pframe;
169 }
170
172 {
173 struct ogg *
ogg =
s->priv_data;
176
177 /* first packet handling
178 here we parse the duration of each packet in the first page and compare
179 the total duration to the page granule to find the encoder delay and
180 set the first timestamp */
181
183 int seg;
185
187 for (seg = os->
segp; seg < os->
nsegs; seg++) {
190 }
191
197 s->streams[idx]->start_time = os->
lastpts;
198 if (
s->streams[idx]->duration > 0)
199 s->streams[idx]->duration -=
s->streams[idx]->start_time;
200 }
201 }
202
203 /* parse packet duration */
206 }
207
208 return 0;
209 }
210
212 .
magic =
"200円theora",
213 .magicsize = 7,
217 .nb_header = 3,
218 };