annotate oggdec.c @ 5595:0980c09b05c1 libavformat

Fix BSD compile (PF_UNSPEC is not a standard define, AF_UNSPEC is).
author rbultje
date Wed, 27 Jan 2010 22:31:13 +0000
parents 52c7b29eca31
children 37e2c3e635b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
1 /*
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
2 * Ogg bitstream support
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
3 * Luca Barbato <lu_zero@gentoo.org>
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
4 * Based on tcvp implementation
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 877
diff changeset
5 *
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
6 */
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
7
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
8 /**
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
9 Copyright (C) 2005 Michael Ahlberg, Måns Rullgård
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
10
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
11 Permission is hereby granted, free of charge, to any person
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
12 obtaining a copy of this software and associated documentation
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
13 files (the "Software"), to deal in the Software without
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
14 restriction, including without limitation the rights to use, copy,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
15 modify, merge, publish, distribute, sublicense, and/or sell copies
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
16 of the Software, and to permit persons to whom the Software is
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
17 furnished to do so, subject to the following conditions:
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
18
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
19 The above copyright notice and this permission notice shall be
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
20 included in all copies or substantial portions of the Software.
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
21
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
26 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
27 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
29 DEALINGS IN THE SOFTWARE.
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
30 **/
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
31
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
32
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
33 #include <stdio.h>
2714
b22ba392ac21 Rename ogg2.[ch] to oggdec.[ch].
diego
parents: 2713
diff changeset
34 #include "oggdec.h"
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
35 #include "avformat.h"
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
36
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
37 #define MAX_PAGE_SIZE 65307
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
38 #define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
39
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
40 static const struct ogg_codec * const ogg_codecs[] = {
5512
60671fac35ad Add support for dirac in ogg
conrad
parents: 5434
diff changeset
41 &ff_dirac_codec,
3770
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
42 &ff_speex_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
43 &ff_vorbis_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
44 &ff_theora_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
45 &ff_flac_codec,
5512
60671fac35ad Add support for dirac in ogg
conrad
parents: 5434
diff changeset
46 &ff_old_dirac_codec,
3770
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
47 &ff_old_flac_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
48 &ff_ogm_video_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
49 &ff_ogm_audio_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
50 &ff_ogm_text_codec,
6c71b789c69e Add ff_ prefix to ogg_codec_t structs
reimar
parents: 3767
diff changeset
51 &ff_ogm_old_codec,
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
52 NULL
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
53 };
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
54
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
55 //FIXME We could avoid some structure duplication
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
56 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
57 ogg_save (AVFormatContext * s)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
58 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
59 struct ogg *ogg = s->priv_data;
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
60 struct ogg_state *ost =
727
a827309802b5 pre-c99 compatibility
mru
parents: 726
diff changeset
61 av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
62 int i;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2732
diff changeset
63 ost->pos = url_ftell (s->pb);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
64 ost->curidx = ogg->curidx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
65 ost->next = ogg->state;
1657
a472266b5d39 save/restore number of streams
mru
parents: 1397
diff changeset
66 ost->nstreams = ogg->nstreams;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
67 memcpy(ost->streams, ogg->streams, ogg->nstreams * sizeof(*ogg->streams));
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
68
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
69 for (i = 0; i < ogg->nstreams; i++){
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
70 struct ogg_stream *os = ogg->streams + i;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
71 os->buf = av_malloc (os->bufsize);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
72 memset (os->buf, 0, os->bufsize);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
73 memcpy (os->buf, ost->streams[i].buf, os->bufpos);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
74 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
75
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
76 ogg->state = ost;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
77
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
78 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
79 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
80
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
81 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
82 ogg_restore (AVFormatContext * s, int discard)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
83 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
84 struct ogg *ogg = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2732
diff changeset
85 ByteIOContext *bc = s->pb;
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
86 struct ogg_state *ost = ogg->state;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
87 int i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
88
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
89 if (!ost)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
90 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
91
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
92 ogg->state = ost->next;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
93
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
94 if (!discard){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
95 for (i = 0; i < ogg->nstreams; i++)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
96 av_free (ogg->streams[i].buf);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
97
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
98 url_fseek (bc, ost->pos, SEEK_SET);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
99 ogg->curidx = ost->curidx;
1657
a472266b5d39 save/restore number of streams
mru
parents: 1397
diff changeset
100 ogg->nstreams = ost->nstreams;
a472266b5d39 save/restore number of streams
mru
parents: 1397
diff changeset
101 memcpy(ogg->streams, ost->streams,
a472266b5d39 save/restore number of streams
mru
parents: 1397
diff changeset
102 ost->nstreams * sizeof(*ogg->streams));
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
103 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
104
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
105 av_free (ost);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
106
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
107 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
108 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
109
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
110 static int
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
111 ogg_reset (struct ogg * ogg)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
112 {
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
113 int i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
114
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
115 for (i = 0; i < ogg->nstreams; i++){
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
116 struct ogg_stream *os = ogg->streams + i;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
117 os->bufpos = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
118 os->pstart = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
119 os->psize = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
120 os->granule = -1;
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
121 os->lastpts = AV_NOPTS_VALUE;
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
122 os->lastdts = AV_NOPTS_VALUE;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
123 os->nsegs = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
124 os->segp = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
125 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
126
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
127 ogg->curidx = -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
128
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
129 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
130 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
131
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
132 static const struct ogg_codec *
728
db6846a618bd s/u_char/uint8_t/
mru
parents: 727
diff changeset
133 ogg_find_codec (uint8_t * buf, int size)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
134 {
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
135 int i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
136
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
137 for (i = 0; ogg_codecs[i]; i++)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
138 if (size >= ogg_codecs[i]->magicsize &&
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
139 !memcmp (buf, ogg_codecs[i]->magic, ogg_codecs[i]->magicsize))
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
140 return ogg_codecs[i];
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
141
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
142 return NULL;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
143 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
144
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
145 static int
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
146 ogg_find_stream (struct ogg * ogg, int serial)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
147 {
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
148 int i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
149
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
150 for (i = 0; i < ogg->nstreams; i++)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
151 if (ogg->streams[i].serial == serial)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
152 return i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
153
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
154 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
155 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
156
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
157 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
158 ogg_new_stream (AVFormatContext * s, uint32_t serial)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
159 {
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
160
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
161 struct ogg *ogg = s->priv_data;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
162 int idx = ogg->nstreams++;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
163 AVStream *st;
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
164 struct ogg_stream *os;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
165
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
166 ogg->streams = av_realloc (ogg->streams,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
167 ogg->nstreams * sizeof (*ogg->streams));
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
168 memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
169 os = ogg->streams + idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
170 os->serial = serial;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
171 os->bufsize = DECODER_BUFFER_SIZE;
1133
554cc16341da 10l: don't allocate a new buffer quite so often
mru
parents: 1132
diff changeset
172 os->buf = av_malloc(os->bufsize);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
173 os->header = -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
174
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
175 st = av_new_stream (s, idx);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
176 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2001
diff changeset
177 return AVERROR(ENOMEM);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
178
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
179 av_set_pts_info(st, 64, 1, 1000000);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
180
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
181 return idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
182 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
183
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
184 static int
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
185 ogg_new_buf(struct ogg *ogg, int idx)
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
186 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
187 struct ogg_stream *os = ogg->streams + idx;
1134
19ceddeafe2e s/u_char/uint8_t/ accidentally copied from tcvp
mru
parents: 1133
diff changeset
188 uint8_t *nb = av_malloc(os->bufsize);
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
189 int size = os->bufpos - os->pstart;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
190 if(os->buf){
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
191 memcpy(nb, os->buf + os->pstart, size);
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
192 av_free(os->buf);
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
193 }
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
194 os->buf = nb;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
195 os->bufpos = size;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
196 os->pstart = 0;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
197
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
198 return 0;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
199 }
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
200
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
201 static int
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
202 ogg_read_page (AVFormatContext * s, int *str)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
203 {
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2732
diff changeset
204 ByteIOContext *bc = s->pb;
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
205 struct ogg *ogg = s->priv_data;
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
206 struct ogg_stream *os;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
207 int i = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
208 int flags, nsegs;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
209 uint64_t gp;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
210 uint32_t serial;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
211 uint32_t seq;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
212 uint32_t crc;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
213 int size, idx;
1332
7474cc6383d4 fix some signedness warnings
mru
parents: 1331
diff changeset
214 uint8_t sync[4];
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
215 int sp = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
216
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
217 if (get_buffer (bc, sync, 4) < 4)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
218 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
219
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
220 do{
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
221 int c;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
222
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
223 if (sync[sp & 3] == 'O' &&
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
224 sync[(sp + 1) & 3] == 'g' &&
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
225 sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S')
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
226 break;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
227
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
228 c = url_fgetc (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
229 if (c < 0)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
230 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
231 sync[sp++ & 3] = c;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
232 }while (i++ < MAX_PAGE_SIZE);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
233
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
234 if (i >= MAX_PAGE_SIZE){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
235 av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n");
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
236 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
237 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
238
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
239 if (url_fgetc (bc) != 0) /* version */
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
240 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
241
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
242 flags = url_fgetc (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
243 gp = get_le64 (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
244 serial = get_le32 (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
245 seq = get_le32 (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
246 crc = get_le32 (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
247 nsegs = url_fgetc (bc);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
248
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
249 idx = ogg_find_stream (ogg, serial);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
250 if (idx < 0){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
251 idx = ogg_new_stream (s, serial);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
252 if (idx < 0)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
253 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
254 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
255
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
256 os = ogg->streams + idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
257
1133
554cc16341da 10l: don't allocate a new buffer quite so often
mru
parents: 1132
diff changeset
258 if(os->psize > 0)
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
259 ogg_new_buf(ogg, idx);
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
260
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
261 if (get_buffer (bc, os->segments, nsegs) < nsegs)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
262 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
263
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
264 os->nsegs = nsegs;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
265 os->segp = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
266
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
267 size = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
268 for (i = 0; i < nsegs; i++)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
269 size += os->segments[i];
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
270
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
271 if (flags & OGG_FLAG_CONT){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
272 if (!os->psize){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
273 while (os->segp < os->nsegs){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
274 int seg = os->segments[os->segp++];
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
275 os->pstart += seg;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
276 if (seg < 255)
4483
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
277 break;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
278 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
279 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
280 }else{
4483
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
281 os->psize = 0;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
282 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
283
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
284 if (os->bufsize - os->bufpos < size){
728
db6846a618bd s/u_char/uint8_t/
mru
parents: 727
diff changeset
285 uint8_t *nb = av_malloc (os->bufsize *= 2);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
286 memcpy (nb, os->buf, os->bufpos);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
287 av_free (os->buf);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
288 os->buf = nb;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
289 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
290
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
291 if (get_buffer (bc, os->buf + os->bufpos, size) < size)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
292 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
293
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
294 os->bufpos += size;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
295 os->granule = gp;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
296 os->flags = flags;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
297
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
298 if (str)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
299 *str = idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
300
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
301 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
302 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
303
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
304 static int
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
305 ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
306 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
307 struct ogg *ogg = s->priv_data;
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
308 int idx, i;
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
309 struct ogg_stream *os;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
310 int complete = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
311 int segp = 0, psize = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
312
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
313 #if 0
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
314 av_log (s, AV_LOG_DEBUG, "ogg_packet: curidx=%i\n", ogg->curidx);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
315 #endif
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
316
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
317 do{
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
318 idx = ogg->curidx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
319
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
320 while (idx < 0){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
321 if (ogg_read_page (s, &idx) < 0)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
322 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
323 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
324
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
325 os = ogg->streams + idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
326
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
327 #if 0
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
328 av_log (s, AV_LOG_DEBUG,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
329 "ogg_packet: idx=%d pstart=%d psize=%d segp=%d nsegs=%d\n",
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
330 idx, os->pstart, os->psize, os->segp, os->nsegs);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
331 #endif
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
332
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
333 if (!os->codec){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
334 if (os->header < 0){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
335 os->codec = ogg_find_codec (os->buf, os->bufpos);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
336 if (!os->codec){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
337 os->header = 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
338 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
339 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
340 }else{
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
341 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
342 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
343 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
344
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
345 segp = os->segp;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
346 psize = os->psize;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
347
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
348 while (os->segp < os->nsegs){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
349 int ss = os->segments[os->segp++];
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
350 os->psize += ss;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
351 if (ss < 255){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
352 complete = 1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
353 break;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
354 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
355 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
356
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
357 if (!complete && os->segp == os->nsegs){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
358 ogg->curidx = -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
359 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
360 }while (!complete);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
361
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
362 #if 0
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
363 av_log (s, AV_LOG_DEBUG,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
364 "ogg_packet: idx %i, frame size %i, start %i\n",
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
365 idx, os->psize, os->pstart);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
366 #endif
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
367
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
368 ogg->curidx = idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
369
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
370 if (os->header < 0){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
371 int hdr = os->codec->header (s, idx);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
372 if (!hdr){
4483
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
373 os->header = os->seq;
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
374 os->segp = segp;
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
375 os->psize = psize;
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
376 ogg->headers = 1;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
377 }else{
4483
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
378 os->pstart += os->psize;
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
379 os->psize = 0;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
380 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
381 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
382
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
383 if (os->header > -1 && os->seq > os->header){
2732
2b101e9d25c0 set PKT_FLAG_KEY for Theora and OGM streams
mru
parents: 2714
diff changeset
384 os->pflags = 0;
5276
5de92e352cf9 Calculate correct packet durations when demuxing Ogg/Speex. This involves
jbr
parents: 5240
diff changeset
385 os->pduration = 0;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
386 if (os->codec && os->codec->packet)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
387 os->codec->packet (s, idx);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
388 if (str)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
389 *str = idx;
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
390 if (dstart)
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
391 *dstart = os->pstart;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
392 if (dsize)
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
393 *dsize = os->psize;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
394 os->pstart += os->psize;
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
395 os->psize = 0;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
396 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
397
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
398 // determine whether there are more complete packets in this page
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
399 // if not, the page's granule will apply to this packet
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
400 os->page_end = 1;
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
401 for (i = os->segp; i < os->nsegs; i++)
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
402 if (os->segments[i] < 255) {
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
403 os->page_end = 0;
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
404 break;
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
405 }
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
406
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
407 os->seq++;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
408 if (os->segp == os->nsegs)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
409 ogg->curidx = -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
410
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
411 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
412 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
413
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
414 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
415 ogg_get_headers (AVFormatContext * s)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
416 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
417 struct ogg *ogg = s->priv_data;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
418
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
419 do{
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
420 if (ogg_packet (s, NULL, NULL, NULL) < 0)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
421 return -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
422 }while (!ogg->headers);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
423
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
424 #if 0
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
425 av_log (s, AV_LOG_DEBUG, "found headers\n");
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
426 #endif
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
427
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
428 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
429 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
430
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
431 static uint64_t
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
432 ogg_gptopts (AVFormatContext * s, int i, uint64_t gp, int64_t *dts)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
433 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
434 struct ogg *ogg = s->priv_data;
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
435 struct ogg_stream *os = ogg->streams + i;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
436 uint64_t pts = AV_NOPTS_VALUE;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
437
755
27449ee55201 support theora in ogg, plus required ogg core changes
mru
parents: 730
diff changeset
438 if(os->codec->gptopts){
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
439 pts = os->codec->gptopts(s, i, gp, dts);
1077
91677ac6fb19 set stream time_base properly
mru
parents: 1076
diff changeset
440 } else {
755
27449ee55201 support theora in ogg, plus required ogg core changes
mru
parents: 730
diff changeset
441 pts = gp;
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
442 if (dts)
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
443 *dts = pts;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
444 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
445
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
446 return pts;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
447 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
448
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
449
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
450 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
451 ogg_get_length (AVFormatContext * s)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
452 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
453 struct ogg *ogg = s->priv_data;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
454 int idx = -1, i;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3770
diff changeset
455 int64_t size, end;
766
ed249b9caa2f don't try to find file length if streaming
mru
parents: 764
diff changeset
456
2841
a41a1ec2213c use proper url_is_streamed() API
aurel
parents: 2771
diff changeset
457 if(url_is_streamed(s->pb))
766
ed249b9caa2f don't try to find file length if streaming
mru
parents: 764
diff changeset
458 return 0;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
459
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
460 // already set
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
461 if (s->duration != AV_NOPTS_VALUE)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
462 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
463
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2732
diff changeset
464 size = url_fsize(s->pb);
1104
2a31a69400f3 fix seek related bugs
mru
parents: 1077
diff changeset
465 if(size < 0)
2a31a69400f3 fix seek related bugs
mru
parents: 1077
diff changeset
466 return 0;
4876
3a1ffb822e81 Ensure that there's pages to read for duration calculation in the ogg demuxer
conrad
parents: 4483
diff changeset
467 end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: 0;
1104
2a31a69400f3 fix seek related bugs
mru
parents: 1077
diff changeset
468
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
469 ogg_save (s);
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2732
diff changeset
470 url_fseek (s->pb, end, SEEK_SET);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
471
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
472 while (!ogg_read_page (s, &i)){
1658
2400a22af998 check for sane values in ogg_get_length(), fix lol-ffplay.ogm fuzz test
mru
parents: 1657
diff changeset
473 if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
2400a22af998 check for sane values in ogg_get_length(), fix lol-ffplay.ogm fuzz test
mru
parents: 1657
diff changeset
474 ogg->streams[i].codec)
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
475 idx = i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
476 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
477
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
478 if (idx != -1){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
479 s->streams[idx]->duration =
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
480 ogg_gptopts (s, idx, ogg->streams[idx].granule, NULL);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
481 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
482
1104
2a31a69400f3 fix seek related bugs
mru
parents: 1077
diff changeset
483 ogg->size = size;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
484 ogg_restore (s, 0);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
485
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
486 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
487 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
488
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
489
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
490 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
491 ogg_read_header (AVFormatContext * s, AVFormatParameters * ap)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
492 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
493 struct ogg *ogg = s->priv_data;
5240
432736854b4c Disable parsing for ogg streams where no ogg header was found,
reimar
parents: 5032
diff changeset
494 int i;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
495 ogg->curidx = -1;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
496 //linear headers seek from start
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
497 if (ogg_get_headers (s) < 0){
4483
187c981dfcb0 Use consistent indent style in oggdec.
pross
parents: 4016
diff changeset
498 return -1;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
499 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
500
5240
432736854b4c Disable parsing for ogg streams where no ogg header was found,
reimar
parents: 5032
diff changeset
501 for (i = 0; i < ogg->nstreams; i++)
432736854b4c Disable parsing for ogg streams where no ogg header was found,
reimar
parents: 5032
diff changeset
502 if (ogg->streams[i].header < 0)
432736854b4c Disable parsing for ogg streams where no ogg header was found,
reimar
parents: 5032
diff changeset
503 ogg->streams[i].codec = NULL;
432736854b4c Disable parsing for ogg streams where no ogg header was found,
reimar
parents: 5032
diff changeset
504
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
505 //linear granulepos seek from end
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
506 ogg_get_length (s);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
507
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
508 //fill the extradata in the per codec callbacks
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
509 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
510 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
511
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
512
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
513 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
514 ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
515 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
516 struct ogg *ogg;
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
517 struct ogg_stream *os;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
518 int idx = -1;
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
519 int pstart, psize;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
520
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 877
diff changeset
521 //Get an ogg packet
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
522 do{
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
523 if (ogg_packet (s, &idx, &pstart, &psize) < 0)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
524 return AVERROR(EIO);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
525 }while (idx < 0 || !s->streams[idx]);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
526
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
527 ogg = s->priv_data;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
528 os = ogg->streams + idx;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
529
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
530 //Alloc a pkt
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
531 if (av_new_packet (pkt, psize) < 0)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
532 return AVERROR(EIO);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
533 pkt->stream_index = idx;
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
534 memcpy (pkt->data, os->buf + pstart, psize);
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
535
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
536 if (os->lastpts != AV_NOPTS_VALUE) {
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
537 pkt->pts = os->lastpts;
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
538 os->lastpts = AV_NOPTS_VALUE;
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
539 }
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
540 if (os->lastdts != AV_NOPTS_VALUE) {
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
541 pkt->dts = os->lastdts;
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
542 os->lastdts = AV_NOPTS_VALUE;
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
543 }
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
544 if (os->page_end) {
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
545 if (os->granule != -1LL) {
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
546 if (os->codec && os->codec->granule_is_start)
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
547 pkt->pts = ogg_gptopts(s, idx, os->granule, &pkt->dts);
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
548 else
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
549 os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts);
5434
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
550 os->granule = -1LL;
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
551 } else
68c8e7affd44 Fix PTS for OGM codecs.
conrad
parents: 5276
diff changeset
552 av_log(s, AV_LOG_WARNING, "Packet is missing granule\n");
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
553 }
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
554
2732
2b101e9d25c0 set PKT_FLAG_KEY for Theora and OGM streams
mru
parents: 2714
diff changeset
555 pkt->flags = os->pflags;
5276
5de92e352cf9 Calculate correct packet durations when demuxing Ogg/Speex. This involves
jbr
parents: 5240
diff changeset
556 pkt->duration = os->pduration;
2732
2b101e9d25c0 set PKT_FLAG_KEY for Theora and OGM streams
mru
parents: 2714
diff changeset
557
1132
a5487f44bbfa cleaned up buffer management
mru
parents: 1120
diff changeset
558 return psize;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
559 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
560
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
561
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
562 static int
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
563 ogg_read_close (AVFormatContext * s)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
564 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
565 struct ogg *ogg = s->priv_data;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
566 int i;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
567
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
568 for (i = 0; i < ogg->nstreams; i++){
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
569 av_free (ogg->streams[i].buf);
755
27449ee55201 support theora in ogg, plus required ogg core changes
mru
parents: 730
diff changeset
570 av_free (ogg->streams[i].private);
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
571 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
572 av_free (ogg->streams);
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
573 return 0;
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
574 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
575
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
576
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
577 static int64_t
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
578 ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
579 int64_t pos_limit)
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
580 {
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
581 struct ogg *ogg = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2732
diff changeset
582 ByteIOContext *bc = s->pb;
2592
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
583 int64_t pts = AV_NOPTS_VALUE;
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
584 int i;
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
585 url_fseek(bc, *pos_arg, SEEK_SET);
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
586 while (url_ftell(bc) < pos_limit && !ogg_read_page (s, &i)) {
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
587 if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
588 ogg->streams[i].codec && i == stream_index) {
5514
52c7b29eca31 oggdec: Set dts when known
conrad
parents: 5512
diff changeset
589 pts = ogg_gptopts(s, i, ogg->streams[i].granule, NULL);
2592
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
590 // FIXME: this is the position of the packet after the one with above
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
591 // pts.
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
592 *pos_arg = url_ftell(bc);
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
593 break;
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
594 }
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
595 }
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
596 ogg_reset(ogg);
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
597 return pts;
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
598 }
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
599
877
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
600 static int ogg_probe(AVProbeData *p)
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
601 {
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
602 if (p->buf[0] == 'O' && p->buf[1] == 'g' &&
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
603 p->buf[2] == 'g' && p->buf[3] == 'S' &&
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
604 p->buf[4] == 0x0 && p->buf[5] <= 0x7 )
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
605 return AVPROBE_SCORE_MAX;
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
606 else
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
607 return 0;
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
608 }
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
609
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
610 AVInputFormat ogg_demuxer = {
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
611 "ogg",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3023
diff changeset
612 NULL_IF_CONFIG_SMALL("Ogg"),
4016
6cd006bc2de9 OGG: untypedef demuxer structs
mru
parents: 3973
diff changeset
613 sizeof (struct ogg),
877
7e42b4e47dfc ogg format probe function by Ivo <ivop at euronet nl>
mru
parents: 858
diff changeset
614 ogg_probe,
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
615 ogg_read_header,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
616 ogg_read_packet,
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
617 ogg_read_close,
2593
16aa09b0f20f Remove ogg seek function, instead use generic seek via read_timestamp function
reimar
parents: 2592
diff changeset
618 NULL,
2592
c2f4fba2c234 Add a read_timestamp function to ogg demuxer
reimar
parents: 2378
diff changeset
619 ogg_read_timestamp,
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
620 .extensions = "ogg",
5032
3aabdadf9d5f Add a VorbisComment metadata conversion table and use it in the FLAC and
jbr
parents: 4876
diff changeset
621 .metadata_conv = ff_vorbiscomment_metadata_conv,
726
17178af951b4 Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff changeset
622 };