Mercurial > mplayer.hg
annotate libmpdemux/demux_ogg.c @ 31436:bc52a219f741
Move mpae_toolame_ctx structure to ae_toolame.c.
The structure is not used anywhere else.
author | diego |
---|---|
date | Mon, 21 Jun 2010 09:42:01 +0000 |
parents | 21516121610a |
children | cd81fce1f010 |
rev | line source |
---|---|
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
1 /* |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
2 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
3 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
7 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
8 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
12 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
13 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28051
diff
changeset
|
17 */ |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
18 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
19 #include "config.h" |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
20 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
21 #include <stdlib.h> |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
22 #include <stdio.h> |
7845
86420d5d7283
endianess independency (using get int 16/32/64 func instead of typecasting pointer)
arpi
parents:
7760
diff
changeset
|
23 #include <string.h> |
10092 | 24 #include <assert.h> |
25 #include <math.h> | |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18468
diff
changeset
|
26 #include <inttypes.h> |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
27 |
17012 | 28 #include "mp_msg.h" |
29 #include "help_mp.h" | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
21828
diff
changeset
|
30 #include "stream/stream.h" |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
31 #include "demuxer.h" |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
32 #include "stheader.h" |
23312
f625b826ec32
Reuse AV_RL macros in ogg demuxer instead of its own overcomplicated implementations of it.
reimar
parents:
23262
diff
changeset
|
33 #include "libavutil/intreadwrite.h" |
30589
df6c41f16b40
Add header for AVI print functions; avoids many forward declarations.
diego
parents:
30585
diff
changeset
|
34 #include "aviprint.h" |
30580
a25d16882312
Add header file for store_ughvlc(); avoids forward declarations.
diego
parents:
30570
diff
changeset
|
35 #include "demux_mov.h" |
30585
2ed1972eb23b
Add header for demux_ogg_open, init_avi_with_ogg; avoids forward declarations.
diego
parents:
30583
diff
changeset
|
36 #include "demux_ogg.h" |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
37 |
14843 | 38 #define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's') |
16915
6b1d1e4adaea
Speex support. Seeking and pts generation does not work.
reimar
parents:
16884
diff
changeset
|
39 #define FOURCC_SPEEX mmioFOURCC('s', 'p', 'x', ' ') |
14843 | 40 #define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o') |
41 | |
27397
d47744b95b78
Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents:
27393
diff
changeset
|
42 #ifdef CONFIG_TREMOR |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8123
diff
changeset
|
43 #include <tremor/ogg.h> |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8123
diff
changeset
|
44 #include <tremor/ivorbiscodec.h> |
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8123
diff
changeset
|
45 #else |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
46 #include <ogg/ogg.h> |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
47 #include <vorbis/codec.h> |
8342
86835828d5b5
Add Tremor (an integer-only Vorbis decoder) support.
rguyom
parents:
8123
diff
changeset
|
48 #endif |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
49 |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27359
diff
changeset
|
50 #ifdef CONFIG_OGGTHEORA |
10092 | 51 #include <theora/theora.h> |
28051 | 52 int _ilog (unsigned int); /* defined in many places in theora/lib/ */ |
10092 | 53 #endif |
54 | |
5809
4b24942acdbb
Add seeking without index (still not perfect). Use -forceidx for the
albeu
parents:
5732
diff
changeset
|
55 #define BLOCK_SIZE 4096 |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
56 |
10092 | 57 /* Theora decoder context : we won't be able to interpret granule positions |
58 * without using theora_granule_time with the theora_state of the stream. | |
59 * This is duplicated in `vd_theora.c'; put this in a common header? | |
60 */ | |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27359
diff
changeset
|
61 #ifdef CONFIG_OGGTHEORA |
10092 | 62 typedef struct theora_struct_st { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
63 theora_state st; |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10608
diff
changeset
|
64 theora_comment cc; |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
65 theora_info inf; |
10092 | 66 } theora_struct_t; |
67 #endif | |
68 | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
69 //// OggDS headers |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
70 // Header for the new header format |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
71 typedef struct stream_header_video { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
72 ogg_int32_t width; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
73 ogg_int32_t height; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
74 } stream_header_video; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
75 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
76 typedef struct stream_header_audio { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
77 ogg_int16_t channels; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
78 ogg_int16_t blockalign; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
79 ogg_int32_t avgbytespersec; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
80 } stream_header_audio; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
81 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
82 typedef struct __attribute__((__packed__)) stream_header { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
83 char streamtype[8]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
84 char subtype[4]; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
85 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
86 ogg_int32_t size; // size of the structure |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
87 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
88 ogg_int64_t time_unit; // in reference time |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
89 ogg_int64_t samples_per_unit; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
90 ogg_int32_t default_len; // in media time |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
91 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
92 ogg_int32_t buffersize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
93 ogg_int16_t bits_per_sample; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
94 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
95 ogg_int16_t padding; |
13881 | 96 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
97 union { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
98 // Video specific |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
99 stream_header_video video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
100 // Audio specific |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
101 stream_header_audio audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
102 } sh; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
103 } stream_header; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
104 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
105 /// Our private datas |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
106 |
5732 | 107 typedef struct ogg_syncpoint { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
108 int64_t granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
109 off_t page_pos; |
5732 | 110 } ogg_syncpoint_t; |
111 | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
112 /// A logical stream |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
113 typedef struct ogg_stream { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
114 /// Timestamping stuff |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
115 float samplerate; /// granulpos 2 time |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
116 int64_t lastpos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
117 int32_t lastsize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
118 int keyframe_frequency_force; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
119 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
120 // Logical stream state |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
121 ogg_stream_state stream; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
122 int hdr_packets; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
123 int vorbis; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
124 int speex; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
125 int theora; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
126 int flac; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
127 int text; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
128 int id; |
18430
9300d63e235c
unbind demux_ogg from ad_libvorbis; this permits to use -ac ffvorbis without crashes
nicodvb
parents:
18237
diff
changeset
|
129 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
130 vorbis_info vi; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
131 int vi_initialized; |
21519
5924b2b9f5de
made vorbis_info a member of ogg_stream rather than ogg_demuxer;
nicodvb
parents:
21509
diff
changeset
|
132 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
133 void *ogg_d; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
134 } ogg_stream_t; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
135 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
136 typedef struct ogg_demuxer { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
137 /// Physical stream state |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
138 ogg_sync_state sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
139 /// Current page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
140 ogg_page page; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
141 /// Logical streams |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
142 ogg_stream_t *subs; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
143 int num_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
144 ogg_syncpoint_t *syncpoints; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
145 int num_syncpoint; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
146 off_t pos, last_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
147 int64_t initial_granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
148 int64_t final_granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
149 int64_t duration; |
13127
957fc21fc10a
Do not use globals. Put the variables into the appropriate demuxer struct instead.
mosu
parents:
13089
diff
changeset
|
150 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
151 /* Used for subtitle switching. */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
152 int n_text; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
153 int *text_ids; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
154 char **text_langs; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
155 } ogg_demuxer_t; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
156 |
5732 | 157 #define NUM_VORBIS_HDR_PACKETS 3 |
158 | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
159 /// Some defines from OggDS |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
160 #define PACKET_TYPE_HEADER 0x01 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
161 #define PACKET_TYPE_BITS 0x07 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
162 #define PACKET_LEN_BITS01 0xc0 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
163 #define PACKET_LEN_BITS2 0x02 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
164 #define PACKET_IS_SYNCPOINT 0x08 |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
165 |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
166 extern char *dvdsub_lang, *audio_lang; |
13501
a5004eb92a79
fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents:
13127
diff
changeset
|
167 extern int dvdsub_id; |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
168 |
7010 | 169 //-------- subtitle support - should be moved to decoder layer, and queue |
170 // - subtitles up in demuxer buffer... | |
171 | |
17012 | 172 #include "subreader.h" |
173 #include "libvo/sub.h" | |
7010 | 174 #define OGG_SUB_MAX_LINE 128 |
175 | |
176 static subtitle ogg_sub; | |
177 //FILE* subout; | |
178 | |
30570
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29734
diff
changeset
|
179 static void demux_ogg_add_sub(ogg_stream_t *os, ogg_packet *pack) |
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29734
diff
changeset
|
180 { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
181 int lcv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
182 char *packet = pack->packet; |
7010 | 183 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
184 if (pack->bytes < 4) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
185 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
186 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\ndemux_ogg_add_sub %02X %02X %02X '%s'\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
187 (unsigned char)packet[0], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
188 (unsigned char)packet[1], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
189 (unsigned char)packet[2], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
190 &packet[3]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
191 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
192 if (((unsigned char)packet[0]) == 0x88) { // some subtitle text |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
193 // Find data start |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
194 double endpts = MP_NOPTS_VALUE; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
195 int32_t duration = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
196 int16_t hdrlen = (*packet & PACKET_LEN_BITS01) >> 6, i; |
7010 | 197 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
198 hdrlen |= (*packet & PACKET_LEN_BITS2) << 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
199 lcv = 1 + hdrlen; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
200 if (pack->bytes < lcv) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
201 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
202 for (i = hdrlen; i > 0; i--) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
203 duration <<= 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
204 duration |= (unsigned char)packet[i]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
205 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
206 if (hdrlen > 0 && duration > 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
207 float pts; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
208 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
209 if (pack->granulepos == -1) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
210 pack->granulepos = os->lastpos + os->lastsize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
211 pts = (float)pack->granulepos / (float)os->samplerate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
212 endpts = 1.0 + pts + (float)duration / 1000.0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
213 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
214 sub_clear_text(&ogg_sub, MP_NOPTS_VALUE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
215 sub_add_text(&ogg_sub, &packet[lcv], pack->bytes - lcv, endpts); |
8788
ee443da1cef3
mosu: subtitles will be cleared after their life time as given in the packet's header has expired and after seeking
mosu
parents:
8655
diff
changeset
|
216 } |
7010 | 217 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
218 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Ogg sub lines: %d first: '%s'\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
219 ogg_sub.lines, ogg_sub.text[0]); |
27393 | 220 #ifdef CONFIG_ICONV |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
221 subcp_recode(&ogg_sub); |
8618
a879b231b7e3
This patch adds a call to subcp_recode1(), so this subtitles too are
arpi
parents:
8375
diff
changeset
|
222 #endif |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
223 vo_sub = &ogg_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
224 vo_osd_changed(OSDTYPE_SUBTITLE); |
7010 | 225 } |
226 | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
227 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
228 // get the logical stream of the current page |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
229 // fill os if non NULL and return the stream id |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
230 static int demux_ogg_get_page_stream(ogg_demuxer_t *ogg_d, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
231 ogg_stream_state **os) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
232 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
233 int id, s_no; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
234 ogg_page *page = &ogg_d->page; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
235 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
236 s_no = ogg_page_serialno(page); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
237 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
238 for (id = 0; id < ogg_d->num_sub; id++) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
239 if (s_no == ogg_d->subs[id].stream.serialno) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
240 break; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
241 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
242 if (id == ogg_d->num_sub) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
243 // If we have only one vorbis stream allow the stream id to change |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
244 // it's normal on radio stream (each song have an different id). |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
245 // But we (or the codec?) should check that the samplerate, etc |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
246 // doesn't change (for radio stream it's ok) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
247 if (ogg_d->num_sub == 1 && ogg_d->subs[0].vorbis) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
248 ogg_stream_reset(&ogg_d->subs[0].stream); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
249 ogg_stream_init(&ogg_d->subs[0].stream, s_no); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
250 id = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
251 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
252 return -1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
253 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
254 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
255 if (os) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
256 *os = &ogg_d->subs[id].stream; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
257 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
258 return id; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
259 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
260 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
261 static unsigned char *demux_ogg_read_packet(ogg_stream_t *os, ogg_packet *pack, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
262 float *pts, int *flags, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
263 int samplesize) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
264 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
265 unsigned char *data = pack->packet; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
266 int size = pack->bytes; |
5732 | 267 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
268 *pts = MP_NOPTS_VALUE; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
269 *flags = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
270 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
271 if (os->vorbis) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
272 if (*pack->packet & PACKET_TYPE_HEADER) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
273 os->hdr_packets++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
274 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
275 vorbis_info *vi; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
276 int32_t blocksize = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
277 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
278 // When we dump the audio, there is no vi, but we don't care of timestamp in this case |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
279 vi = os->vi_initialized ? &os->vi : NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
280 if (vi) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
281 blocksize = vorbis_packet_blocksize(vi, pack) / samplesize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
282 // Calculate the timestamp if the packet don't have any |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
283 if (pack->granulepos == -1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
284 pack->granulepos = os->lastpos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
285 if (os->lastsize > 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
286 pack->granulepos += os->lastsize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
287 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
288 *flags = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
289 if (vi) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
290 *pts = pack->granulepos / (float)vi->rate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
291 os->lastsize = blocksize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
292 os->lastpos = pack->granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
293 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
294 } else if (os->speex) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
295 // whole packet (default) |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27359
diff
changeset
|
296 # ifdef CONFIG_OGGTHEORA |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
297 } else if (os->theora) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
298 /* we pass complete packets to theora, mustn't strip the header! */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
299 os->lastsize = 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
300 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
301 /* header packets begin on 1-bit: thus check (*data&0x80). We don't |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
302 have theora_state st, until all header packets were passed to the |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
303 decoder. */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
304 if (!size || !(*data&0x80)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
305 int keyframe_granule_shift = _ilog(os->keyframe_frequency_force - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
306 int64_t iframemask = (1 << keyframe_granule_shift) - 1; |
10092 | 307 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
308 if (pack->granulepos >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
309 os->lastpos = pack->granulepos >> keyframe_granule_shift; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
310 os->lastpos += pack->granulepos & iframemask; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
311 *flags = (pack->granulepos & iframemask) == 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
312 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
313 os->lastpos++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
314 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
315 pack->granulepos = os->lastpos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
316 *pts = (double)os->lastpos / (double)os->samplerate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
317 } |
27363
40057010b1fa
Change a bunch of codec-specific preprocessor directives from a HAVE_
diego
parents:
27359
diff
changeset
|
318 #endif /* CONFIG_OGGTHEORA */ |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
319 } else if (os->flac) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
320 /* we pass complete packets to flac, mustn't strip the header! */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
321 if (os->flac == 2 && pack->packet[0] != 0xff) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
322 return NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
323 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
324 if (*pack->packet & PACKET_TYPE_HEADER) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
325 os->hdr_packets++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
326 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
327 // Find data start |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
328 int16_t hdrlen = (*pack->packet & PACKET_LEN_BITS01) >> 6; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
329 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
330 hdrlen |= (*pack->packet & PACKET_LEN_BITS2) << 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
331 data = pack->packet + 1 + hdrlen; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
332 // Calculate the timestamp |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
333 if (pack->granulepos == -1) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
334 pack->granulepos = os->lastpos + (os->lastsize ? os->lastsize : 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
335 // If we already have a timestamp it can be a syncpoint |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
336 if (*pack->packet & PACKET_IS_SYNCPOINT) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
337 *flags = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
338 *pts = pack->granulepos / os->samplerate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
339 // Save the packet length and timestamp |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
340 os->lastsize = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
341 while (hdrlen) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
342 os->lastsize <<= 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
343 os->lastsize |= pack->packet[hdrlen]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
344 hdrlen--; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
345 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
346 os->lastpos = pack->granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
347 } |
5732 | 348 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
349 return data; |
5732 | 350 } |
351 | |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
352 // check if clang has substring from comma separated langlist |
25495 | 353 static int demux_ogg_check_lang(const char *clang, const char *langlist) |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
354 { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
355 const char *c; |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
356 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
357 if (!langlist || !*langlist) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
358 return 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
359 while ((c = strchr(langlist, ','))) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
360 if (!strncasecmp(clang, langlist, c - langlist)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
361 return 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
362 langlist = &c[1]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
363 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
364 if (!strncasecmp(clang, langlist, strlen(langlist))) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
365 return 1; |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
366 return 0; |
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
367 } |
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
368 |
30582
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
369 /** \brief Change the current subtitle stream and return its ID. |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
370 |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
371 \param demuxer The demuxer whose subtitle stream will be changed. |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
372 \param new_num The number of the new subtitle track. The number must be |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
373 between 0 and ogg_d->n_text - 1. |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
374 |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
375 \returns The Ogg stream number ( = page serial number) of the newly selected |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
376 track. |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
377 */ |
30583
c8b12c3fc5a5
Mark demux_ogg_sub_id() as static; it is not used outside of the file.
diego
parents:
30582
diff
changeset
|
378 static int demux_ogg_sub_id(demuxer_t *demuxer, int index) |
c8b12c3fc5a5
Mark demux_ogg_sub_id() as static; it is not used outside of the file.
diego
parents:
30582
diff
changeset
|
379 { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
380 ogg_demuxer_t *ogg_d = demuxer->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
381 return (index < 0) ? index : (index >= ogg_d->n_text) ? -1 : ogg_d->text_ids[index]; |
30582
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
382 } |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
383 |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
384 /** \brief Translate the ogg track number into the subtitle number. |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
385 * \param demuxer The demuxer about whose subtitles we are inquiring. |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
386 * \param id The ogg track number of the subtitle track. |
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
387 */ |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
388 static int demux_ogg_sub_reverse_id(demuxer_t *demuxer, int id) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
389 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
390 ogg_demuxer_t *ogg_d = demuxer->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
391 int i; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
392 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
393 for (i = 0; i < ogg_d->n_text; i++) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
394 if (ogg_d->text_ids[i] == id) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
395 return i; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
396 return -1; |
30582
85aaf16401b5
Move up demux_ogg_sub_id, demux_ogg_sub_reverse_id; avoids forward declarations.
diego
parents:
30580
diff
changeset
|
397 } |
13803
0bd7ccf63c54
Declare a prototype for the function before it is used. Otherwise some compiler versions will "optimize" them away, and linking will fail.
mosu
parents:
13641
diff
changeset
|
398 |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
399 /// Try to print out comments and also check for LANGUAGE= tag |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
400 static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
401 int id, vorbis_comment *vc) |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
402 { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
403 const char *hdr, *val; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
404 char **cmt = vc->user_comments; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
405 int index, i; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
406 ogg_demuxer_t *ogg_d = d->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
407 static const struct table { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
408 const char *ogg; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
409 const char *mp; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
410 } table[] = { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
411 { "ENCODED_USING", "Software" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
412 { "ENCODER_URL", "Encoder URL" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
413 { "TITLE", "Title" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
414 { "ARTIST", "Artist" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
415 { "COMMENT", "Comments" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
416 { "DATE", "Creation Date" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
417 { "GENRE", "Genre" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
418 { "ALBUM", "Album" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
419 { "TRACKNUMBER", "Track" }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
420 { NULL, NULL }, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
421 }; |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
422 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
423 while (*cmt) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
424 hdr = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
425 if (!strncasecmp(*cmt, "LANGUAGE=", 9)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
426 val = *cmt + 9; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
427 if (ogg_d->subs[id].text) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
428 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
429 ogg_d->subs[id].id, val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
430 else if (id != d->video->id) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
431 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
432 ogg_d->subs[id].id, val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
433 if (ogg_d->subs[id].text) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
434 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
435 "[Ogg] Language for -sid %d is '-slang \"%s\"'\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
436 ogg_d->subs[id].id, val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
437 // copy this language name into the array |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
438 index = demux_ogg_sub_reverse_id(d, id); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
439 if (index >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
440 sh_sub_t *sh; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
441 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
442 // in case of malicious files with more than one lang per track: |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
443 if (ogg_d->text_langs[index]) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
444 free(ogg_d->text_langs[index]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
445 ogg_d->text_langs[index] = strdup(val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
446 sh = d->s_streams[index]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
447 if (sh && sh->lang) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
448 free(sh->lang); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
449 if (sh) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
450 sh->lang = strdup(val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
451 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
452 // check for -slang if subs are uninitialized yet |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
453 if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
454 d->sub->id = index; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
455 dvdsub_id = index; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
456 mp_msg(MSGT_DEMUX, MSGL_V, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
457 "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
458 id, val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
459 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
460 else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
461 hdr = "Language"; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
462 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
463 else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
464 for (i = 0; table[i].ogg; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
465 if (!strncasecmp(*cmt, table[i].ogg, strlen(table[i].ogg)) && |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
466 (*cmt)[strlen(table[i].ogg)] == '=') { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
467 hdr = table[i].mp; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
468 val = *cmt + strlen(table[i].ogg) + 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
469 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
470 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
471 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
472 if (hdr) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
473 demux_info_add(d, hdr, val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
474 mp_dbg(MSGT_DEMUX, MSGL_DBG2, " %s: %s\n", hdr, val); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
475 cmt++; |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
476 } |
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
477 } |
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
478 |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
479 /// Calculate the timestamp and add the packet to the demux stream |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
480 // return 1 if the packet was added, 0 otherwise |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
481 static int demux_ogg_add_packet(demux_stream_t *ds, ogg_stream_t *os, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
482 int id, ogg_packet *pack) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
483 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
484 demuxer_t *d = ds->demuxer; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
485 demux_packet_t *dp; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
486 unsigned char *data; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
487 float pts = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
488 int flags = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
489 int samplesize = 1; |
12104
fdce1dd97638
Support for selecting subtitles with -slang. Patch by Andriy N Gritsenko <andrej at lucky onedot net>
mosu
parents:
11898
diff
changeset
|
490 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
491 // If packet is an comment header then we try to get comments at first |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
492 if (pack->bytes >= 7 && !memcmp(pack->packet, "\003vorbis", 7)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
493 vorbis_info vi; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
494 vorbis_comment vc; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
495 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
496 vorbis_info_init(&vi); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
497 vorbis_comment_init(&vc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
498 vi.rate = 1L; // it's checked by vorbis_synthesis_headerin() |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
499 if (vorbis_synthesis_headerin(&vi, &vc, pack) == 0) // if no errors |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
500 demux_ogg_check_comments(d, os, id, &vc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
501 vorbis_comment_clear(&vc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
502 vorbis_info_clear(&vi); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
503 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
504 if (os->text) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
505 if (id == demux_ogg_sub_id(d, d->sub->id)) // don't want to add subtitles to the demuxer for now |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
506 demux_ogg_add_sub(os, pack); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
507 return 0; |
16915
6b1d1e4adaea
Speex support. Seeking and pts generation does not work.
reimar
parents:
16884
diff
changeset
|
508 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
509 if (os->speex) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
510 // discard first two packets, they contain the header and comment |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
511 if (os->hdr_packets < 2) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
512 os->hdr_packets++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
513 return 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
514 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
515 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
516 // If packet is an header we jump it except for vorbis and theora |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
517 // (PACKET_TYPE_HEADER bit doesn't even exist for theora ?!) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
518 // We jump nothing for FLAC. Ain't this great? Packet contents have to be |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
519 // handled differently for each and every stream type. The joy! The joy! |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
520 if (!os->flac && (*pack->packet & PACKET_TYPE_HEADER) && |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
521 (ds != d->audio || ((sh_audio_t*)ds->sh)->format != FOURCC_VORBIS || os->hdr_packets >= NUM_VORBIS_HDR_PACKETS ) && |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
522 (ds != d->video || (((sh_video_t*)ds->sh)->format != FOURCC_THEORA))) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
523 return 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
524 } |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
525 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
526 // For vorbis packet the packet is the data, for other codec we must jump |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
527 // the header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
528 if (ds == d->audio && ((sh_audio_t*)ds->sh)->format == FOURCC_VORBIS) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
529 samplesize = ((sh_audio_t *)ds->sh)->samplesize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
530 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
531 data = demux_ogg_read_packet(os, pack, &pts, &flags, samplesize); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
532 if (!data) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
533 return 0; |
5732 | 534 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
535 /// Clear subtitles if necessary (for broken files) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
536 if (sub_clear_text(&ogg_sub, pts)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
537 vo_sub = &ogg_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
538 vo_osd_changed(OSDTYPE_SUBTITLE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
539 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
540 /// Send the packet |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
541 dp = new_demux_packet(pack->bytes - (data - pack->packet)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
542 memcpy(dp->buffer, data, pack->bytes - (data - pack->packet)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
543 dp->pts = pts; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
544 dp->flags = flags; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
545 ds_add_packet(ds, dp); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
546 mp_msg(MSGT_DEMUX, MSGL_DBG2, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
547 "New dp: %p ds=%p pts=%5.3f len=%d flag=%d \n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
548 dp, ds, pts, dp->len, flags); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
549 return 1; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
550 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
551 |
12263
26be0fd618b5
Much improved seeking. Patch by Michael Behrich <behrisch at informatik adot hu-berlin anotherdot de>
mosu
parents:
12135
diff
changeset
|
552 /// if -forceidx build a table of all syncpoints to make seeking easier |
26be0fd618b5
Much improved seeking. Patch by Michael Behrich <behrisch at informatik adot hu-berlin anotherdot de>
mosu
parents:
12135
diff
changeset
|
553 /// otherwise try to get at least the final_granulepos |
30570
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29734
diff
changeset
|
554 static void demux_ogg_scan_stream(demuxer_t *demuxer) |
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29734
diff
changeset
|
555 { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
556 ogg_demuxer_t *ogg_d = demuxer->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
557 stream_t *s = demuxer->stream; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
558 ogg_sync_state *sync = &ogg_d->sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
559 ogg_page *page = &ogg_d->page; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
560 ogg_stream_state *oss; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
561 ogg_stream_t *os; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
562 ogg_packet op; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
563 int np, sid, p, samplesize = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
564 off_t pos, last_pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
565 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
566 pos = last_pos = demuxer->movi_start; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
567 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
568 // Reset the stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
569 stream_seek(s, demuxer->movi_start); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
570 ogg_sync_reset(sync); |
5732 | 571 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
572 // Get the serial number of the stream we use |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
573 if (demuxer->video->id >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
574 sid = demuxer->video->id; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
575 } else if (demuxer->audio->id >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
576 sid = demuxer->audio->id; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
577 if (((sh_audio_t*)demuxer->audio->sh)->format == FOURCC_VORBIS) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
578 samplesize = ((sh_audio_t*)demuxer->audio->sh)->samplesize; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
579 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
580 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
581 os = &ogg_d->subs[sid]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
582 oss = &os->stream; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
583 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
584 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
585 np = ogg_sync_pageseek(sync, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
586 if (np < 0) { // We had to skip some bytes |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
587 if (index_mode == 2) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
588 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
589 "Bad page sync while building syncpoints table (%d)\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
590 -np); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
591 pos += -np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
592 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
593 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
594 if (np <= 0) { // We need more data |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
595 char *buf = ogg_sync_buffer(sync, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
596 int len = stream_read(s, buf, BLOCK_SIZE); |
5732 | 597 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
598 if (len == 0 && s->eof) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
599 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
600 ogg_sync_wrote(sync, len); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
601 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
602 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
603 // The page is ready |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
604 //ogg_sync_pageout(sync, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
605 if (ogg_page_serialno(page) != os->stream.serialno) { // It isn't a page from the stream we want |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
606 pos += np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
607 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
608 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
609 if (ogg_stream_pagein(oss, page) != 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
610 mp_msg(MSGT_DEMUX, MSGL_ERR, "Pagein error ????\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
611 pos += np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
612 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
613 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
614 p = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
615 while (ogg_stream_packetout(oss, &op) == 1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
616 float pts; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
617 int flags; |
5732 | 618 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
619 demux_ogg_read_packet(os, &op, &pts, &flags, samplesize); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
620 if (op.granulepos >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
621 ogg_d->final_granulepos = op.granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
622 if (ogg_d->initial_granulepos == MP_NOPTS_VALUE && (flags & 1)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
623 ogg_d->initial_granulepos = op.granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
624 if (index_mode != 2 && ogg_d->pos < demuxer->movi_end - 2 * 270000) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
625 //the 270000 are just a wild guess |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
626 stream_seek(s, FFMAX(ogg_d->pos, demuxer->movi_end - 270000)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
627 ogg_sync_reset(sync); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
628 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
629 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
630 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
631 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
632 if (index_mode == 2 && (flags || (os->vorbis && op.granulepos >= 0))) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
633 if (ogg_d->num_syncpoint > SIZE_MAX / sizeof(ogg_syncpoint_t) - 1) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
634 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
635 ogg_d->syncpoints = realloc_struct(ogg_d->syncpoints, (ogg_d->num_syncpoint + 1), sizeof(ogg_syncpoint_t)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
636 ogg_d->syncpoints[ogg_d->num_syncpoint].granulepos = op.granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
637 ogg_d->syncpoints[ogg_d->num_syncpoint].page_pos = (ogg_page_continued(page) && p == 0) ? last_pos : pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
638 ogg_d->num_syncpoint++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
639 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
640 p++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
641 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
642 if (p > 1 || (p == 1 && !ogg_page_continued(page))) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
643 last_pos = pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
644 pos += np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
645 if (index_mode == 2) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
646 mp_msg(MSGT_DEMUX, MSGL_INFO, "Building syncpoint table %d%%\r", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
647 (int)(pos * 100 / s->end_pos)); |
5732 | 648 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
649 |
31000
21516121610a
Merge two redundant if checks, patch by ubitux, ubitux gmail com.
diego
parents:
30999
diff
changeset
|
650 if (index_mode == 2) { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
651 mp_msg(MSGT_DEMUX, MSGL_INFO, "\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
652 mp_msg(MSGT_DEMUX, MSGL_V, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
653 "Ogg syncpoints table builed: %d syncpoints\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
654 ogg_d->num_syncpoint); |
31000
21516121610a
Merge two redundant if checks, patch by ubitux, ubitux gmail com.
diego
parents:
30999
diff
changeset
|
655 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
656 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
657 mp_msg(MSGT_DEMUX, MSGL_V, "Ogg stream length (granulepos): %"PRId64"\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
658 ogg_d->final_granulepos); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
659 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
660 stream_reset(s); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
661 stream_seek(s, demuxer->movi_start); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
662 ogg_sync_reset(sync); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
663 for (np = 0; np < ogg_d->num_sub; np++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
664 ogg_stream_reset(&ogg_d->subs[np].stream); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
665 ogg_d->subs[np].lastpos = ogg_d->subs[np].lastsize = ogg_d->subs[np].hdr_packets = 0; |
5732 | 666 } |
667 | |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
668 // Get the first page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
669 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
670 np = ogg_sync_pageout(sync, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
671 if (np <= 0) { // We need more data |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
672 char *buf = ogg_sync_buffer(sync, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
673 int len = stream_read(s, buf, BLOCK_SIZE); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
674 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
675 if (len == 0 && s->eof) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
676 mp_msg(MSGT_DEMUX, MSGL_ERR, "EOF while trying to get the first page !!!!\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
677 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
678 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
679 ogg_sync_wrote(sync, len); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
680 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
681 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
682 demux_ogg_get_page_stream(ogg_d, &oss); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
683 ogg_stream_pagein(oss, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
684 break; |
5732 | 685 } |
686 } | |
687 | |
18430
9300d63e235c
unbind demux_ogg from ad_libvorbis; this permits to use -ac ffvorbis without crashes
nicodvb
parents:
18237
diff
changeset
|
688 static void fixup_vorbis_wf(sh_audio_t *sh, ogg_demuxer_t *od) |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
689 { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
690 int i, offset; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
691 int ris, init_error = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
692 ogg_packet op[3]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
693 unsigned char *buf[3]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
694 unsigned char *ptr; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
695 unsigned int len; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
696 ogg_stream_t *os = &od->subs[sh->ds->id]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
697 vorbis_comment vc; |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
698 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
699 vorbis_info_init(&os->vi); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
700 vorbis_comment_init(&vc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
701 for (i = 0; i < 3; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
702 op[i].bytes = ds_get_packet(sh->ds, &(op[i].packet)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
703 mp_msg(MSGT_DEMUX, MSGL_V, "fixup_vorbis_wf: i=%d, size=%ld\n", i, op[i].bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
704 if (op[i].bytes < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
705 mp_msg(MSGT_DEMUX, MSGL_ERR, "Ogg demuxer error!, fixup_vorbis_wf: bad packet n. %d\n", i); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
706 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
707 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
708 buf[i] = malloc(op[i].bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
709 if (!buf[i]) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
710 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
711 memcpy(buf[i], op[i].packet, op[i].bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
712 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
713 op[i].b_o_s = (i == 0); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
714 ris = vorbis_synthesis_headerin(&os->vi, &vc, &op[i]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
715 if (ris < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
716 init_error = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
717 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DEMUX_OGG: header n. %d broken! len=%ld, code: %d\n", i, op[i].bytes, ris); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
718 } |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
719 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
720 vorbis_comment_clear(&vc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
721 if (!init_error) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
722 os->vi_initialized = 1; |
18430
9300d63e235c
unbind demux_ogg from ad_libvorbis; this permits to use -ac ffvorbis without crashes
nicodvb
parents:
18237
diff
changeset
|
723 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
724 len = op[0].bytes + op[1].bytes + op[2].bytes; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
725 sh->wf = calloc(1, sizeof(WAVEFORMATEX) + len + len / 255 + 64); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
726 ptr = (unsigned char*)(sh->wf + 1); |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
727 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
728 ptr[0] = 2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
729 offset = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
730 offset += store_ughvlc(&ptr[offset], op[0].bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
731 mp_msg(MSGT_DEMUX, MSGL_V, "demux_ogg, offset after 1st len = %u\n", offset); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
732 offset += store_ughvlc(&ptr[offset], op[1].bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
733 mp_msg(MSGT_DEMUX, MSGL_V, "demux_ogg, offset after 2nd len = %u\n", offset); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
734 for (i = 0; i < 3; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
735 mp_msg(MSGT_DEMUX, MSGL_V, "demux_ogg, i=%d, bytes: %ld, offset: %u\n", i, op[i].bytes, offset); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
736 memcpy(&ptr[offset], buf[i], op[i].bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
737 offset += op[i].bytes; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
738 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
739 sh->wf->cbSize = offset; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
740 mp_msg(MSGT_DEMUX, MSGL_V, "demux_ogg, extradata size: %d\n", sh->wf->cbSize); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
741 sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX) + sh->wf->cbSize); |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
742 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
743 if (op[0].bytes >= 29) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
744 unsigned int br; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
745 int nombr, minbr, maxbr; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
746 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
747 ptr = buf[0]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
748 sh->channels = ptr[11]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
749 sh->samplerate = sh->wf->nSamplesPerSec = AV_RL32(&ptr[12]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
750 maxbr = AV_RL32(&ptr[16]); //max |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
751 nombr = AV_RL32(&ptr[20]); //nominal |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
752 minbr = AV_RL32(&ptr[24]); //minimum |
19694
d32f43ae7f5b
in fixup_vorbis_wf() set to 0 bitrates indicated as -1 (unspecified, according to the specs); patch by Andrew Savchenko - Bircoph list ru
nicodvb
parents:
19540
diff
changeset
|
753 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
754 if (maxbr == -1) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
755 maxbr = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
756 if (nombr == -1) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
757 nombr = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
758 if (minbr == -1) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
759 minbr = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
760 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
761 br = maxbr / 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
762 if (!br) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
763 br = nombr / 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
764 if (!br) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
765 br = minbr / 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
766 sh->wf->nAvgBytesPerSec = br; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
767 sh->wf->wBitsPerSample = 16; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
768 sh->samplesize = (sh->wf->wBitsPerSample + 7) / 8; |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
769 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
770 mp_msg(MSGT_DEMUX, MSGL_V, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
771 "demux_ogg, vorbis stream features are: channels: %d, srate: %d, bitrate: %d, max: %u, nominal: %u, min: %u\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
772 sh->channels, sh->samplerate, sh->wf->nAvgBytesPerSec, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
773 maxbr, nombr, minbr); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
774 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
775 free(buf[2]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
776 free(buf[1]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
777 free(buf[0]); |
15420
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
778 } |
f3cf481bbcda
vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents:
15321
diff
changeset
|
779 |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
780 /// Open an ogg physical stream |
16175 | 781 // Not static because it's used also in demuxer_avi.c |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
782 int demux_ogg_open(demuxer_t *demuxer) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
783 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
784 ogg_demuxer_t *ogg_d; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
785 stream_t *s; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
786 char *buf; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
787 int np, s_no, n_audio = 0, n_video = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
788 int audio_id = -1, video_id = -1, text_id = -1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
789 ogg_sync_state *sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
790 ogg_page *page; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
791 ogg_packet pack; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
792 sh_audio_t *sh_a; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
793 sh_video_t *sh_v; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
794 |
27393 | 795 #ifdef CONFIG_ICONV |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
796 subcp_open(NULL); |
8618
a879b231b7e3
This patch adds a call to subcp_recode1(), so this subtitles too are
arpi
parents:
8375
diff
changeset
|
797 #endif |
a879b231b7e3
This patch adds a call to subcp_recode1(), so this subtitles too are
arpi
parents:
8375
diff
changeset
|
798 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
799 s = demuxer->stream; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
800 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
801 demuxer->priv = ogg_d = calloc(1, sizeof(*ogg_d)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
802 sync = &ogg_d->sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
803 page = &ogg_d->page; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
804 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
805 ogg_sync_init(sync); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
806 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
807 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
808 /// Try to get a page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
809 ogg_d->pos += ogg_d->last_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
810 np = ogg_sync_pageseek(sync, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
811 /// Error |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
812 if (np < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
813 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Ogg demuxer : Bad page sync\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
814 goto err_out; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
815 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
816 /// Need some more data |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
817 if (np == 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
818 int len; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
819 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
820 buf = ogg_sync_buffer(sync, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
821 len = stream_read(s, buf, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
822 if (len == 0 && s->eof) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
823 goto err_out; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
824 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
825 ogg_sync_wrote(sync, len); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
826 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
827 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
828 ogg_d->last_size = np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
829 // We got one page now |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
830 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
831 if (!ogg_page_bos(page)) { // It's not a beginning page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
832 // Header parsing end here, we need to get the page otherwise it will be lost |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
833 int id = demux_ogg_get_page_stream(ogg_d, NULL); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
834 if (id >= 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
835 ogg_stream_pagein(&ogg_d->subs[id].stream, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
836 else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
837 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
838 "Ogg : Warning found none bos page from unknown stream %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
839 ogg_page_serialno(page)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
840 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
841 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
842 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
843 /// Init the data structure needed for a logical stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
844 ogg_d->subs = realloc_struct(ogg_d->subs, ogg_d->num_sub+1, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
845 sizeof(ogg_stream_t)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
846 memset(&ogg_d->subs[ogg_d->num_sub], 0, sizeof(ogg_stream_t)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
847 /// Get the stream serial number |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
848 s_no = ogg_page_serialno(page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
849 ogg_stream_init(&ogg_d->subs[ogg_d->num_sub].stream, s_no); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
850 mp_msg(MSGT_DEMUX, MSGL_DBG2, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
851 "Ogg : Found a stream with serial=%d\n", s_no); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
852 // Take the first page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
853 ogg_stream_pagein(&ogg_d->subs[ogg_d->num_sub].stream, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
854 // Get first packet of the page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
855 ogg_stream_packetout(&ogg_d->subs[ogg_d->num_sub].stream, &pack); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
856 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
857 // Reset our vars |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
858 sh_a = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
859 sh_v = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
860 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
861 ogg_d->subs[ogg_d->num_sub].ogg_d = ogg_d; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
862 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
863 // Check for Vorbis |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
864 if (pack.bytes >= 7 && !strncmp(&pack.packet[1], "vorbis", 6)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
865 sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
866 sh_a->format = FOURCC_VORBIS; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
867 ogg_d->subs[ogg_d->num_sub].vorbis = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
868 ogg_d->subs[ogg_d->num_sub].id = n_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
869 n_audio++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
870 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
871 "[Ogg] stream %d: audio (Vorbis), -aid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
872 ogg_d->num_sub, n_audio - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
873 } else if (pack.bytes >= 80 && !strncmp(pack.packet, "Speex", 5)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
874 sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
875 sh_a->wf = calloc(1, sizeof(WAVEFORMATEX) + pack.bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
876 sh_a->format = FOURCC_SPEEX; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
877 sh_a->samplerate = sh_a->wf->nSamplesPerSec = AV_RL32(&pack.packet[36]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
878 sh_a->channels = sh_a->wf->nChannels = AV_RL32(&pack.packet[48]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
879 sh_a->wf->wFormatTag = sh_a->format; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
880 sh_a->wf->nAvgBytesPerSec = AV_RL32(&pack.packet[52]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
881 sh_a->wf->nBlockAlign = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
882 sh_a->wf->wBitsPerSample = 16; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
883 sh_a->samplesize = 2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
884 sh_a->wf->cbSize = pack.bytes; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
885 memcpy(&sh_a->wf[1], pack.packet, pack.bytes); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
886 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
887 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
888 ogg_d->subs[ogg_d->num_sub].speex = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
889 ogg_d->subs[ogg_d->num_sub].id = n_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
890 n_audio++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
891 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
892 "[Ogg] stream %d: audio (Speex), -aid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
893 ogg_d->num_sub, n_audio - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
894 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
895 // check for Theora |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
896 #ifdef CONFIG_OGGTHEORA |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
897 } else if (pack.bytes >= 7 && !strncmp (&pack.packet[1], "theora", 6)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
898 int errorCode = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
899 theora_info inf; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
900 theora_comment cc; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
901 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
902 theora_info_init (&inf); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
903 theora_comment_init (&cc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
904 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
905 errorCode = theora_decode_header (&inf, &cc, &pack); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
906 if (errorCode) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
907 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
908 "Theora header parsing failed: %i \n", errorCode); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
909 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
910 sh_v = new_sh_video_vid(demuxer, ogg_d->num_sub, n_video); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
911 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
912 sh_v->bih = calloc(1, sizeof(BITMAPINFOHEADER)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
913 sh_v->bih->biSize = sizeof(BITMAPINFOHEADER); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
914 sh_v->bih->biCompression = sh_v->format = FOURCC_THEORA; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
915 sh_v->fps = ((double)inf.fps_numerator) / (double)inf.fps_denominator; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
916 sh_v->frametime = ((double)inf.fps_denominator) / (double)inf.fps_numerator; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
917 sh_v->disp_w = sh_v->bih->biWidth = inf.frame_width; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
918 sh_v->disp_h = sh_v->bih->biHeight = inf.frame_height; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
919 sh_v->bih->biBitCount = 24; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
920 sh_v->bih->biPlanes = 3; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
921 sh_v->bih->biSizeImage = ((sh_v->bih->biBitCount / 8) * sh_v->bih->biWidth * sh_v->bih->biHeight); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
922 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
923 ogg_d->subs[ogg_d->num_sub].theora = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
924 ogg_d->subs[ogg_d->num_sub].keyframe_frequency_force = inf.keyframe_frequency_force; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
925 ogg_d->subs[ogg_d->num_sub].id = n_video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
926 n_video++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
927 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
928 "[Ogg] stream %d: video (Theora v%d.%d.%d), -vid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
929 ogg_d->num_sub, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
930 (int)inf.version_major, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
931 (int)inf.version_minor, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
932 (int)inf.version_subminor, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
933 n_video - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
934 if (mp_msg_test(MSGT_HEADER, MSGL_V)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
935 print_video_header(sh_v->bih, MSGL_V); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
936 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
937 theora_comment_clear(&cc); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
938 theora_info_clear(&inf); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
939 #endif /* CONFIG_OGGTHEORA */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
940 } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
941 sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
942 sh_a->format = mmioFOURCC('f', 'L', 'a', 'C'); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
943 ogg_d->subs[ogg_d->num_sub].id = n_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
944 n_audio++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
945 ogg_d->subs[ogg_d->num_sub].flac = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
946 sh_a->wf = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
947 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
948 "[Ogg] stream %d: audio (FLAC), -aid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
949 ogg_d->num_sub, n_audio - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
950 } else if (pack.bytes >= 51 && !strncmp(&pack.packet[1], "FLAC", 4)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
951 sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
952 sh_a->format = mmioFOURCC('f', 'L', 'a', 'C'); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
953 ogg_d->subs[ogg_d->num_sub].id = n_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
954 n_audio++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
955 ogg_d->subs[ogg_d->num_sub].flac = 2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
956 sh_a->wf = calloc(1, sizeof(WAVEFORMATEX) + 34); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
957 sh_a->wf->wFormatTag = sh_a->format; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
958 sh_a->wf->cbSize = 34; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
959 memcpy(&sh_a->wf[1], &pack.packet[17], 34); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
960 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
961 "[Ogg] stream %d: audio (FLAC, try 2), -aid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
962 ogg_d->num_sub, n_audio - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
963 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
964 /// Check for old header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
965 } else if (pack.bytes >= 142 && |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
966 !strncmp(&pack.packet[1], "Direct Show Samples embedded in Ogg", 35)) { |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
967 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
968 // Old video header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
969 if (AV_RL32(pack.packet + 96) == 0x05589f80 && pack.bytes >= 184) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
970 sh_v = new_sh_video_vid(demuxer, ogg_d->num_sub, n_video); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
971 sh_v->bih = calloc(1, sizeof(BITMAPINFOHEADER)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
972 sh_v->bih->biSize = sizeof(BITMAPINFOHEADER); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
973 sh_v->bih->biCompression = sh_v->format = mmioFOURCC(pack.packet[68], pack.packet[69], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
974 pack.packet[70], pack.packet[71]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
975 sh_v->frametime = AV_RL64(pack.packet + 164) * 0.0000001; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
976 sh_v->fps = 1 / sh_v->frametime; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
977 sh_v->disp_w = sh_v->bih->biWidth = AV_RL32(pack.packet + 176); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
978 sh_v->disp_h = sh_v->bih->biHeight = AV_RL32(pack.packet + 180); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
979 sh_v->bih->biBitCount = AV_RL16(pack.packet + 182); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
980 if (!sh_v->bih->biBitCount) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
981 sh_v->bih->biBitCount = 24; // hack, FIXME |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
982 sh_v->bih->biPlanes = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
983 sh_v->bih->biSizeImage = (sh_v->bih->biBitCount >> 3) * sh_v->bih->biWidth * sh_v->bih->biHeight; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
984 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
985 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
986 ogg_d->subs[ogg_d->num_sub].id = n_video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
987 n_video++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
988 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
989 "[Ogg] stream %d: video (FOURCC %c%c%c%c), -vid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
990 ogg_d->num_sub, pack.packet[68], pack.packet[69], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
991 pack.packet[70], pack.packet[71], n_video - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
992 if (mp_msg_test(MSGT_HEADER, MSGL_V)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
993 print_video_header(sh_v->bih, MSGL_V); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
994 // Old audio header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
995 } else if (AV_RL32(pack.packet + 96) == 0x05589F81) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
996 unsigned int extra_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
997 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
998 sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
999 extra_size = AV_RL16(pack.packet + 140); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1000 sh_a->wf = calloc(1, sizeof(WAVEFORMATEX) + extra_size); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1001 sh_a->format = sh_a->wf->wFormatTag = AV_RL16(pack.packet + 124); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1002 sh_a->channels = sh_a->wf->nChannels = AV_RL16(pack.packet + 126); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1003 sh_a->samplerate = sh_a->wf->nSamplesPerSec = AV_RL32(pack.packet + 128); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1004 sh_a->wf->nAvgBytesPerSec = AV_RL32(pack.packet + 132); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1005 sh_a->wf->nBlockAlign = AV_RL16(pack.packet + 136); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1006 sh_a->wf->wBitsPerSample = AV_RL16(pack.packet + 138); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1007 sh_a->samplesize = (sh_a->wf->wBitsPerSample + 7) / 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1008 sh_a->wf->cbSize = extra_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1009 if (extra_size > 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1010 memcpy(((char *)sh_a->wf) + sizeof(WAVEFORMATEX), |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1011 pack.packet + 142, extra_size); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1012 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1013 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1014 ogg_d->subs[ogg_d->num_sub].id = n_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1015 n_audio++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1016 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1017 "[Ogg] stream %d: audio (format 0x%04x), -aid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1018 ogg_d->num_sub, sh_a->format, n_audio - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1019 if (mp_msg_test(MSGT_HEADER, MSGL_V)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1020 print_wave_header(sh_a->wf, MSGL_V); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1021 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1022 mp_msg(MSGT_DEMUX, MSGL_WARN, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1023 "Ogg stream %d contains an old header but the header type is unknown\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1024 ogg_d->num_sub); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1025 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1026 // Check new header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1027 } else if ((*pack.packet & PACKET_TYPE_BITS ) == PACKET_TYPE_HEADER && |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1028 pack.bytes >= (int)sizeof(stream_header) + 1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1029 stream_header *st = (stream_header*)(pack.packet + 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1030 /// New video header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1031 if (strncmp(st->streamtype, "video", 5) == 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1032 sh_v = new_sh_video_vid(demuxer, ogg_d->num_sub, n_video); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1033 sh_v->bih = calloc(1, sizeof(BITMAPINFOHEADER)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1034 sh_v->bih->biSize = sizeof(BITMAPINFOHEADER); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1035 sh_v->bih->biCompression = sh_v->format = mmioFOURCC(st->subtype[0], st->subtype[1], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1036 st->subtype[2], st->subtype[3]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1037 sh_v->frametime = AV_RL64(&st->time_unit) * 0.0000001; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1038 sh_v->fps = 1.0 / sh_v->frametime; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1039 sh_v->bih->biBitCount = AV_RL16(&st->bits_per_sample); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1040 sh_v->disp_w = sh_v->bih->biWidth = AV_RL32(&st->sh.video.width); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1041 sh_v->disp_h = sh_v->bih->biHeight = AV_RL32(&st->sh.video.height); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1042 if (!sh_v->bih->biBitCount) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1043 sh_v->bih->biBitCount = 24; // hack, FIXME |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1044 sh_v->bih->biPlanes = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1045 sh_v->bih->biSizeImage = (sh_v->bih->biBitCount >> 3) * sh_v->bih->biWidth * sh_v->bih->biHeight; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1046 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1047 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1048 ogg_d->subs[ogg_d->num_sub].id = n_video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1049 n_video++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1050 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1051 "[Ogg] stream %d: video (FOURCC %c%c%c%c), -vid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1052 ogg_d->num_sub, st->subtype[0], st->subtype[1], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1053 st->subtype[2], st->subtype[3], n_video - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1054 if (mp_msg_test(MSGT_HEADER, MSGL_V)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1055 print_video_header(sh_v->bih, MSGL_V); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1056 /// New audio header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1057 } else if (strncmp(st->streamtype, "audio", 5) == 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1058 char buffer[5]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1059 unsigned int extra_size = AV_RL32(&st->size) - sizeof(stream_header); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1060 unsigned int extra_offset = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1061 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1062 memcpy(buffer, st->subtype, 4); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1063 buffer[4] = '\0'; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1064 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1065 /* Nasty workaround. stream_header.size seems not to contain the real |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1066 size in all cases. There are four extra bytes that are unaccounted |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1067 for in front of the real codec initialization data _at least_ for |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1068 AAC. So far I've only seen those bytes being all 0, so we can |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1069 just skip them here. */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1070 if ((strtol(buffer, NULL, 16) == 0xff) && (extra_size >= 4)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1071 extra_size -= 4; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1072 extra_offset = 4; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1073 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1074 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1075 sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1076 sh_a->wf = calloc(1, sizeof(WAVEFORMATEX) + extra_size); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1077 sh_a->format = sh_a->wf->wFormatTag = strtol(buffer, NULL, 16); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1078 sh_a->channels = sh_a->wf->nChannels = AV_RL16(&st->sh.audio.channels); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1079 sh_a->samplerate = sh_a->wf->nSamplesPerSec = AV_RL64(&st->samples_per_unit); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1080 sh_a->wf->nAvgBytesPerSec = AV_RL32(&st->sh.audio.avgbytespersec); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1081 sh_a->wf->nBlockAlign = AV_RL16(&st->sh.audio.blockalign); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1082 sh_a->wf->wBitsPerSample = AV_RL16(&st->bits_per_sample); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1083 sh_a->samplesize = (sh_a->wf->wBitsPerSample + 7) / 8; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1084 sh_a->wf->cbSize = extra_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1085 if (extra_size) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1086 memcpy(((char *)sh_a->wf)+sizeof(WAVEFORMATEX), |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1087 ((char *)(st+1))+extra_offset, extra_size); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1088 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1089 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1090 ogg_d->subs[ogg_d->num_sub].id = n_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1091 n_audio++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1092 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1093 "[Ogg] stream %d: audio (format 0x%04x), -aid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1094 ogg_d->num_sub, sh_a->format, n_audio - 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1095 if (mp_msg_test(MSGT_HEADER, MSGL_V)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1096 print_wave_header(sh_a->wf, MSGL_V); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1097 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1098 /// Check for text (subtitles) header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1099 } else if (strncmp(st->streamtype, "text", 4) == 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1100 mp_msg(MSGT_DEMUX, MSGL_INFO, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1101 "[Ogg] stream %d: subtitles (SRT-like text subtitles), -sid %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1102 ogg_d->num_sub, ogg_d->n_text); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1103 ogg_d->subs[ogg_d->num_sub].samplerate = AV_RL64(&st->time_unit) / 10; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1104 ogg_d->subs[ogg_d->num_sub].text = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1105 ogg_d->subs[ogg_d->num_sub].id = ogg_d->n_text; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1106 if (demuxer->sub->id == ogg_d->n_text) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1107 text_id = ogg_d->num_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1108 new_sh_sub(demuxer, ogg_d->n_text); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1109 ogg_d->n_text++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1110 ogg_d->text_ids = realloc_struct(ogg_d->text_ids, ogg_d->n_text, sizeof(*ogg_d->text_ids)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1111 ogg_d->text_ids[ogg_d->n_text - 1] = ogg_d->num_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1112 ogg_d->text_langs = realloc_struct(ogg_d->text_langs, ogg_d->n_text, sizeof(*ogg_d->text_langs)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1113 ogg_d->text_langs[ogg_d->n_text - 1] = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1114 //// Unknown header type |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1115 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1116 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1117 "Ogg stream %d has a header marker but is of an unknown type\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1118 ogg_d->num_sub); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1119 /// Unknown (invalid ?) header |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1120 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1121 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1122 "Ogg stream %d is of an unknown type\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1123 ogg_d->num_sub); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1124 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1125 if (sh_a || sh_v) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1126 demux_stream_t *ds = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1127 if (sh_a) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1128 // If the audio stream is not defined we took the first one |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1129 if (demuxer->audio->id == -1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1130 demuxer->audio->id = n_audio - 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1131 //if (sh_a->wf) print_wave_header(sh_a->wf, MSGL_INFO); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1132 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1133 /// Is it the stream we want |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1134 if (demuxer->audio->id == n_audio - 1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1135 demuxer->audio->sh = sh_a; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1136 sh_a->ds = demuxer->audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1137 ds = demuxer->audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1138 audio_id = ogg_d->num_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1139 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1140 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1141 if (sh_v) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1142 /// Also for video |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1143 if (demuxer->video->id == -1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1144 demuxer->video->id = n_video - 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1145 //if (sh_v->bih) print_video_header(sh_v->bih, MSGL_INFO); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1146 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1147 if (demuxer->video->id == n_video - 1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1148 demuxer->video->sh = sh_v; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1149 sh_v->ds = demuxer->video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1150 ds = demuxer->video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1151 video_id = ogg_d->num_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1152 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1153 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1154 /// Add the header packets if the stream isn't seekable |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1155 if (ds && !s->end_pos) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1156 /// Finish the page, otherwise packets will be lost |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1157 do { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1158 demux_ogg_add_packet(ds, &ogg_d->subs[ogg_d->num_sub], |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1159 ogg_d->num_sub, &pack); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1160 } while (ogg_stream_packetout(&ogg_d->subs[ogg_d->num_sub].stream, &pack) == 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1161 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1162 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1163 ogg_d->num_sub++; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1164 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1165 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1166 if (!n_video && !n_audio) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1167 goto err_out; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1168 } |
10092 | 1169 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1170 if (!n_video || video_id < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1171 demuxer->video->id = -2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1172 else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1173 demuxer->video->id = video_id; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1174 if (!n_audio || audio_id < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1175 demuxer->audio->id = -2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1176 else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1177 demuxer->audio->id = audio_id; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1178 /* Disable the subs only if there are no text streams at all. |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1179 Otherwise the stream to display might be chosen later when the comment |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1180 packet is encountered and the user used -slang instead of -sid. */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1181 if (!ogg_d->n_text) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1182 demuxer->sub->id = -2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1183 else if (text_id >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1184 demuxer->sub->id = text_id; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1185 mp_msg(MSGT_DEMUX, MSGL_V, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1186 "Ogg demuxer: Displaying subtitle stream id %d\n", text_id); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1187 } |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1188 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1189 ogg_d->final_granulepos = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1190 ogg_d->initial_granulepos = MP_NOPTS_VALUE; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1191 if (!s->end_pos) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1192 demuxer->seekable = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1193 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1194 demuxer->movi_start = s->start_pos; // Needed for XCD (Ogg written in MODE2) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1195 demuxer->movi_end = s->end_pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1196 demuxer->seekable = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1197 demux_ogg_scan_stream(demuxer); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1198 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1199 if (ogg_d->initial_granulepos == MP_NOPTS_VALUE) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1200 ogg_d->initial_granulepos = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1201 ogg_d->duration = ogg_d->final_granulepos - ogg_d->initial_granulepos; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1202 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1203 mp_msg(MSGT_DEMUX, MSGL_V, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1204 "Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1205 n_audio, n_audio > 1 ? "s" : "", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1206 n_video, n_video > 1 ? "s" : "", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1207 ogg_d->n_text, ogg_d->n_text > 1 ? "s" : ""); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1208 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1209 sh_a = demuxer->audio->sh; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1210 if (sh_a && sh_a->format == FOURCC_VORBIS) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1211 fixup_vorbis_wf(sh_a, ogg_d); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1212 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1213 return DEMUXER_TYPE_OGG; |
14666
91bbfcb66883
Memleak fixes. Based on patch by Timothy Lee (timothy lee at siriushk com).
reimar
parents:
14574
diff
changeset
|
1214 |
91bbfcb66883
Memleak fixes. Based on patch by Timothy Lee (timothy lee at siriushk com).
reimar
parents:
14574
diff
changeset
|
1215 err_out: |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1216 return 0; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1217 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1218 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1219 static int demux_ogg_fill_buffer(demuxer_t *d, demux_stream_t *dsds) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1220 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1221 ogg_demuxer_t *ogg_d; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1222 stream_t *s; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1223 demux_stream_t *ds; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1224 ogg_sync_state *sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1225 ogg_stream_state *os; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1226 ogg_page *page; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1227 ogg_packet pack; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1228 int np = 0, id=0; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1229 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1230 s = d->stream; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1231 ogg_d = d->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1232 sync = &ogg_d->sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1233 page = &ogg_d->page; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1234 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1235 /// Find the stream we are working on |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1236 if ((id = demux_ogg_get_page_stream(ogg_d, &os)) < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1237 mp_msg(MSGT_DEMUX, MSGL_ERR, "Ogg demuxer : can't get current stream\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1238 return 0; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1239 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1240 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1241 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1242 np = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1243 ds = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1244 /// Try to get some packet from the current page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1245 while ((np = ogg_stream_packetout(os, &pack)) != 1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1246 /// No packet we go the next page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1247 if (np == 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1248 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1249 int pa, len; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1250 char *buf; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1251 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1252 ogg_d->pos += ogg_d->last_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1253 /// Get the next page from the physical stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1254 while ((pa = ogg_sync_pageseek(sync, page)) <= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1255 /// Error : we skip some bytes |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1256 if (pa < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1257 mp_msg(MSGT_DEMUX, MSGL_WARN, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1258 "Ogg : Page out not synced, we skip some bytes\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1259 ogg_d->pos -= pa; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1260 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1261 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1262 /// We need more data |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1263 buf = ogg_sync_buffer(sync, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1264 len = stream_read(s, buf, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1265 if (len == 0 && s->eof) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1266 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Ogg : Stream EOF !!!!\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1267 return 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1268 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1269 ogg_sync_wrote(sync, len); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1270 } /// Page loop |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1271 ogg_d->last_size = pa; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1272 /// Find the page's logical stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1273 if ((id = demux_ogg_get_page_stream(ogg_d, &os)) < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1274 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1275 "Ogg demuxer error : we met an unknown stream\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1276 return 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1277 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1278 /// Take the page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1279 if (ogg_stream_pagein(os, page) == 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1280 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1281 /// Page was invalid => retry |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1282 mp_msg(MSGT_DEMUX, MSGL_WARN, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1283 "Ogg demuxer : got invalid page !!!!!\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1284 ogg_d->pos += ogg_d->last_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1285 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1286 } else /// Packet was corrupted |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1287 mp_msg(MSGT_DEMUX, MSGL_WARN, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1288 "Ogg : bad packet in stream %d\n", id); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1289 } /// Packet loop |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1290 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1291 /// Is the actual logical stream in use ? |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1292 if (id == d->audio->id) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1293 ds = d->audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1294 else if (id == d->video->id) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1295 ds = d->video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1296 else if (ogg_d->subs[id].text) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1297 ds = d->sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1298 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1299 if (ds) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1300 if (!demux_ogg_add_packet(ds, &ogg_d->subs[id], id, &pack)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1301 continue; /// Unuseful packet, get another |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1302 d->filepos = ogg_d->pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1303 return 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1304 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1305 } /// while (1) |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1306 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1307 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1308 /// For avi with Ogg audio stream we have to create an ogg demuxer for this |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1309 // stream, then we join the avi and ogg demuxer with a demuxers demuxer |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1310 demuxer_t *init_avi_with_ogg(demuxer_t *demuxer) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1311 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1312 demuxer_t *od; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1313 ogg_demuxer_t *ogg_d; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1314 stream_t *s; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1315 uint32_t hdrsizes[3]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1316 demux_packet_t *dp; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1317 sh_audio_t *sh_audio = demuxer->audio->sh; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1318 int np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1319 uint8_t *extradata = (uint8_t *)(sh_audio->wf + 1); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1320 int i; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1321 unsigned char *p = NULL, *buf; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1322 int plen; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1323 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1324 /// Check that the cbSize is big enough for the following reads |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1325 if (sh_audio->wf->cbSize < 22 + 3 * 4) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1326 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1327 "AVI Ogg : Initial audio header is too small !!!!!\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1328 goto fallback; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1329 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1330 /// Get the size of the 3 header packet |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1331 extradata += 22; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1332 for (i = 0; i < 3; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1333 hdrsizes[i] = AV_RL32(extradata); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1334 extradata += 4; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1335 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1336 // printf("\n!!!!!! hdr sizes: %d %d %d \n", hdrsizes[0], hdrsizes[1], hdrsizes[2]); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1337 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1338 /// Check the size |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1339 if (sh_audio->wf->cbSize < 22 + 3 * 4 + hdrsizes[0] + hdrsizes[1] + hdrsizes[2]) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1340 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1341 "AVI Ogg : Audio header is too small !!!!!\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1342 goto fallback; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1343 } |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1344 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1345 // Build the ogg demuxer private datas |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1346 ogg_d = calloc(1, sizeof(*ogg_d)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1347 ogg_d->num_sub = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1348 ogg_d->subs = malloc(sizeof(*ogg_d->subs)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1349 ogg_d->subs[0].vorbis = 1; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1350 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1351 // Init the ogg physical stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1352 ogg_sync_init(&ogg_d->sync); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1353 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1354 // Get the first page of the stream : we assume there only 1 logical stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1355 while ((np = ogg_sync_pageout(&ogg_d->sync, &ogg_d->page)) <= 0 ) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1356 if (np < 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1357 mp_msg(MSGT_DEMUX, MSGL_ERR, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1358 "AVI Ogg error : Can't init using first stream packets\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1359 free(ogg_d); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1360 goto fallback; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1361 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1362 // Add some data |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1363 plen = ds_get_packet(demuxer->audio, &p); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1364 buf = ogg_sync_buffer(&ogg_d->sync, plen); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1365 memcpy(buf, p, plen); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1366 ogg_sync_wrote(&ogg_d->sync, plen); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1367 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1368 // Init the logical stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1369 mp_msg(MSGT_DEMUX, MSGL_DBG2, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1370 "AVI Ogg found page with serial %d\n", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1371 ogg_page_serialno(&ogg_d->page)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1372 ogg_stream_init(&ogg_d->subs[0].stream, ogg_page_serialno(&ogg_d->page)); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1373 // Write the page |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1374 ogg_stream_pagein(&ogg_d->subs[0].stream, &ogg_d->page); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1375 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1376 // Create the ds_stream and the ogg demuxer |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1377 s = new_ds_stream(demuxer->audio); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1378 od = new_demuxer(s, DEMUXER_TYPE_OGG, 0, -2, -2, NULL); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1379 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1380 /// Add the header packets in the ogg demuxer audio stream |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1381 for (i = 0; i < 3; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1382 dp = new_demux_packet(hdrsizes[i]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1383 memcpy(dp->buffer, extradata, hdrsizes[i]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1384 ds_add_packet(od->audio, dp); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1385 extradata += hdrsizes[i]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1386 } |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1387 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1388 // Finish setting up the ogg demuxer |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1389 od->priv = ogg_d; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1390 sh_audio = new_sh_audio(od, 0); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1391 od->audio->id = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1392 od->video->id = -2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1393 od->audio->sh = sh_audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1394 sh_audio->ds = od->audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1395 sh_audio->format = FOURCC_VORBIS; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1396 fixup_vorbis_wf(sh_audio, ogg_d); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1397 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1398 /// Return the joined demuxers |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1399 return new_demuxers_demuxer(demuxer, od, demuxer); |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1400 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1401 fallback: |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1402 demuxer->audio->id = -2; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1403 return demuxer; |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1404 |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1405 } |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff
changeset
|
1406 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1407 static void demux_ogg_seek(demuxer_t *demuxer, float rel_seek_secs, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1408 float audio_delay, int flags) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1409 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1410 ogg_demuxer_t *ogg_d = demuxer->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1411 ogg_sync_state *sync = &ogg_d->sync; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1412 ogg_page* page= &ogg_d->page; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1413 ogg_stream_state *oss; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1414 ogg_stream_t *os; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1415 demux_stream_t *ds; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1416 ogg_packet op; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1417 float rate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1418 int i, sp, first, precision = 1, do_seek = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1419 vorbis_info *vi = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1420 int64_t gp = 0, old_gp; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1421 off_t pos, old_pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1422 int np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1423 int is_gp_valid; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1424 float pts; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1425 int is_keyframe; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1426 int samplesize = 1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1427 ogg_int64_t granulepos_orig; |
5732 | 1428 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1429 if (demuxer->video->id >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1430 ds = demuxer->video; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1431 rate = ogg_d->subs[ds->id].samplerate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1432 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1433 ds = demuxer->audio; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1434 os = &ogg_d->subs[ds->id]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1435 vi = &(os->vi); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1436 rate = (float)vi->rate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1437 samplesize = ((sh_audio_t*)ds->sh)->samplesize; |
5809
4b24942acdbb
Add seeking without index (still not perfect). Use -forceidx for the
albeu
parents:
5732
diff
changeset
|
1438 } |
4b24942acdbb
Add seeking without index (still not perfect). Use -forceidx for the
albeu
parents:
5732
diff
changeset
|
1439 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1440 os = &ogg_d->subs[ds->id]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1441 oss = &os->stream; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1442 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1443 old_gp = os->lastpos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1444 old_pos = ogg_d->pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1445 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1446 //calculate the granulepos to seek to |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1447 gp = flags & SEEK_ABSOLUTE ? ogg_d->initial_granulepos : os->lastpos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1448 if (flags & SEEK_FACTOR) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1449 if (ogg_d->duration > 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1450 gp += ogg_d->duration * rel_seek_secs; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1451 else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1452 gp += rel_seek_secs * (demuxer->movi_end - demuxer->movi_start) * os->lastpos / ogg_d->pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1453 } else |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1454 gp += rel_seek_secs * rate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1455 if (gp < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1456 gp = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1457 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1458 //calculate the filepos to seek to |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1459 if (ogg_d->syncpoints) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1460 for (sp = 0; sp < ogg_d->num_syncpoint; sp++) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1461 if (ogg_d->syncpoints[sp].granulepos >= gp) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1462 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1463 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1464 if (sp >= ogg_d->num_syncpoint) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1465 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1466 if (sp > 0 && ogg_d->syncpoints[sp].granulepos - gp > gp - ogg_d->syncpoints[sp - 1].granulepos) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1467 sp--; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1468 if (ogg_d->syncpoints[sp].granulepos == os->lastpos) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1469 if (sp > 0 && gp < os->lastpos) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1470 sp--; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1471 if (sp < ogg_d->num_syncpoint - 1 && gp > os->lastpos) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1472 sp++; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1473 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1474 pos = ogg_d->syncpoints[sp].page_pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1475 precision = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1476 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1477 pos = flags & SEEK_ABSOLUTE ? 0 : ogg_d->pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1478 if (flags & SEEK_FACTOR) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1479 pos += (demuxer->movi_end - demuxer->movi_start) * rel_seek_secs; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1480 else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1481 if (ogg_d->duration > 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1482 pos += rel_seek_secs * (demuxer->movi_end - demuxer->movi_start) / (ogg_d->duration / rate); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1483 } else if (os->lastpos > 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1484 pos += rel_seek_secs * ogg_d->pos / (os->lastpos / rate); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1485 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1486 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1487 if (pos < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1488 pos = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1489 if (pos > (demuxer->movi_end - demuxer->movi_start)) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1490 pos = demuxer->movi_end - demuxer->movi_start; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1491 } // if (ogg_d->syncpoints) |
5732 | 1492 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1493 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1494 if (do_seek) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1495 stream_seek(demuxer->stream, pos+demuxer->movi_start); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1496 ogg_sync_reset(sync); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1497 for (i = 0; i < ogg_d->num_sub; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1498 ogg_stream_reset(&ogg_d->subs[i].stream); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1499 ogg_d->subs[i].lastpos = ogg_d->subs[i].lastsize = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1500 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1501 ogg_d->pos = pos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1502 ogg_d->last_size = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1503 /* we just guess that we reached correct granulepos, in case a |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1504 subsequent search occurs before we read a valid granulepos */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1505 os->lastpos = gp; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1506 first = !(ogg_d->syncpoints); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1507 do_seek=0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1508 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1509 ogg_d->pos += ogg_d->last_size; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1510 ogg_d->last_size = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1511 np = ogg_sync_pageseek(sync, page); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1512 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1513 if (np < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1514 ogg_d->pos -= np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1515 if (np <= 0) { // We need more data |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1516 char *buf = ogg_sync_buffer(sync, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1517 int len = stream_read(demuxer->stream, buf, BLOCK_SIZE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1518 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1519 if (len == 0 && demuxer->stream->eof) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1520 mp_msg(MSGT_DEMUX, MSGL_V, "EOF while trying to seek !!!!\n"); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1521 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1522 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1523 ogg_sync_wrote(sync, len); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1524 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1525 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1526 ogg_d->last_size = np; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1527 if (ogg_page_serialno(page) != oss->serialno) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1528 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1529 |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1530 if (ogg_stream_pagein(oss, page) != 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1531 continue; |
5809
4b24942acdbb
Add seeking without index (still not perfect). Use -forceidx for the
albeu
parents:
5732
diff
changeset
|
1532 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1533 while (1) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1534 np = ogg_stream_packetout(oss, &op); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1535 if (np < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1536 continue; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1537 else if (np == 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1538 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1539 if (first) { /* Discard the first packet as it's probably broken, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1540 and we don't have any other means to decide whether it is |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1541 complete or not. */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1542 first = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1543 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1544 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1545 is_gp_valid = (op.granulepos >= 0); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1546 granulepos_orig=op.granulepos; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1547 demux_ogg_read_packet(os, &op, &pts, &is_keyframe, samplesize); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1548 if (precision && is_gp_valid) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1549 precision--; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1550 if (abs(gp - op.granulepos) > rate && (op.granulepos != old_gp)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1551 //prepare another seek because we are off by more than 1s |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1552 pos += (gp - op.granulepos) * (pos - old_pos) / (op.granulepos - old_gp); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1553 if (pos < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1554 pos = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1555 if (pos < demuxer->movi_end - demuxer->movi_start) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1556 do_seek=1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1557 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1558 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1559 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1560 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1561 if (is_gp_valid && pos > 0 && old_gp > gp |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1562 && 2 * (old_gp - op.granulepos) < old_gp - gp) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1563 /* prepare another seek because looking for a syncpoint |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1564 destroyed the backward search */ |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1565 pos = old_pos - 1.5 * (old_pos - pos); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1566 if (pos < 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1567 pos = 0; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1568 if (pos < demuxer->movi_end - demuxer->movi_start) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1569 do_seek=1; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1570 break; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1571 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1572 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1573 if (!precision && (is_keyframe || os->vorbis || os->speex)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1574 if (sub_clear_text(&ogg_sub, MP_NOPTS_VALUE)) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1575 vo_sub = &ogg_sub; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1576 vo_osd_changed(OSDTYPE_SUBTITLE); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1577 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1578 op.granulepos=granulepos_orig; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1579 demux_ogg_add_packet(ds, os, ds->id, &op); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1580 return; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1581 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1582 } |
5732 | 1583 } |
1584 | |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1585 mp_msg(MSGT_DEMUX, MSGL_ERR, "Can't find the good packet :(\n"); |
5732 | 1586 } |
1587 | |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1588 static void demux_close_ogg(demuxer_t *demuxer) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1589 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1590 ogg_demuxer_t *ogg_d = demuxer->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1591 ogg_stream_t *os = NULL; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1592 int i; |
5812 | 1593 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1594 if (!ogg_d) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1595 return; |
5812 | 1596 |
27393 | 1597 #ifdef CONFIG_ICONV |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1598 subcp_close(); |
8618
a879b231b7e3
This patch adds a call to subcp_recode1(), so this subtitles too are
arpi
parents:
8375
diff
changeset
|
1599 #endif |
a879b231b7e3
This patch adds a call to subcp_recode1(), so this subtitles too are
arpi
parents:
8375
diff
changeset
|
1600 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1601 ogg_sync_clear(&ogg_d->sync); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1602 if (ogg_d->subs) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1603 for (i = 0; i < ogg_d->num_sub; i++) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1604 os = &ogg_d->subs[i]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1605 ogg_stream_clear(&os->stream); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1606 if (os->vi_initialized) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1607 vorbis_info_clear(&os->vi); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1608 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1609 free(ogg_d->subs); |
21811 | 1610 } |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1611 if (ogg_d->syncpoints) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1612 free(ogg_d->syncpoints); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1613 if (ogg_d->text_ids) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1614 free(ogg_d->text_ids); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1615 if (ogg_d->text_langs) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1616 for (i = 0; i < ogg_d->n_text; i++) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1617 if (ogg_d->text_langs[i]) free(ogg_d->text_langs[i]); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1618 free(ogg_d->text_langs); |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1619 } |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1620 free(ogg_d); |
5812 | 1621 } |
1622 | |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1623 static int demux_ogg_control(demuxer_t *demuxer, int cmd, void *arg) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1624 { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1625 ogg_demuxer_t *ogg_d = demuxer->priv; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1626 ogg_stream_t *os; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1627 float rate; |
11577 | 1628 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1629 if (demuxer->video->id >= 0) { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1630 os = &ogg_d->subs[demuxer->video->id]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1631 rate = os->samplerate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1632 } else { |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1633 os = &ogg_d->subs[demuxer->audio->id]; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1634 rate = os->vi.rate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1635 } |
11575
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1636 |
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1637 switch(cmd) { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1638 case DEMUXER_CTRL_GET_TIME_LENGTH: |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1639 if (ogg_d->duration <= 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1640 return DEMUXER_CTRL_DONTKNOW; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1641 *(double *)arg = (double)(ogg_d->duration) / rate; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1642 return DEMUXER_CTRL_GUESS; |
11575
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1643 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1644 case DEMUXER_CTRL_GET_PERCENT_POS: |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1645 if (ogg_d->duration <= 0) |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1646 return DEMUXER_CTRL_DONTKNOW; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1647 *(int *)arg = ((os->lastpos - ogg_d->initial_granulepos) * 100) / ogg_d->duration; |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1648 return DEMUXER_CTRL_OK; |
11575
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1649 |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1650 default: |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1651 return DEMUXER_CTRL_NOTIMPL; |
11575
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1652 } |
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1653 } |
0ac7fe8f3af8
Get the total length for Ogg files. Patch by Michael Behrisch <behrisch@informatik.hu-berlin.de>.
mosu
parents:
11467
diff
changeset
|
1654 |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25495
diff
changeset
|
1655 const demuxer_desc_t demuxer_desc_ogg = { |
30999
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1656 "Ogg demuxer", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1657 "ogg", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1658 "Ogg", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1659 "?", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1660 "", |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1661 DEMUXER_TYPE_OGG, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1662 1, // safe autodetect |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1663 demux_ogg_open, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1664 demux_ogg_fill_buffer, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1665 NULL, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1666 demux_close_ogg, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1667 demux_ogg_seek, |
abb0b5990ec8
cosmetics: reindent demux_ogg.c to K&R style plus some prettyprinting
diego
parents:
30837
diff
changeset
|
1668 demux_ogg_control |
16175 | 1669 }; |