annotate libmpdemux/demux_ogg.c @ 5327:674793ca4225

100l :(
author arpi
date Mon, 25 Mar 2002 03:19:06 +0000
parents 9841a86d66f9
children a43b00b28081
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5133
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
1
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
2 #include "config.h"
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
3
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
4
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
5 #include <stdlib.h>
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
6 #include <stdio.h>
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
7
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
8 #include "../mp_msg.h"
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
9 #include "../help_mp.h"
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
10 #include "stream.h"
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
11 #include "demuxer.h"
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
12 #include "stheader.h"
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
13
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
14 #ifndef HAVE_OGGVORBIS
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
15 /// Some dummy function to use when no Ogg and Vorbis lib are avaible
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
16 int demux_ogg_open(demuxer_t* demuxer) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
17 return 0;
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
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
20 int demux_ogg_fill_buffer(demuxer_t *d) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
21 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
22 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
23
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
24 demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
25 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_NoOggVorbis);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
26 // disable audio
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
27 demuxer->audio->id = -2;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
28 return demuxer;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
29 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
30 #else
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
31
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
32 #include <ogg/ogg.h>
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
33 #include <vorbis/codec.h>
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
34
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
35 #define BLOCK_SIZE 1024
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
36
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
37 /// Vorbis decoder context : we need the vorbis_info for vorbis timestamping
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
38 /// Shall we put this struct def in a common header ?
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
39 typedef struct ov_struct_st {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
40 vorbis_info vi; /* struct that stores all the static vorbis bitstream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
41 settings */
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
42 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
43 vorbis_block vb; /* local working space for packet->PCM decode */
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
44 } ov_struct_t;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
45
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
46 //// OggDS headers
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
47 // Header for the new header format
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
48 typedef struct stream_header_video
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
49 {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
50 ogg_int32_t width;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
51 ogg_int32_t height;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
52 } stream_header_video;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
53
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
54 typedef struct stream_header_audio
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
55 {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
56 ogg_int16_t channels;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
57 ogg_int16_t blockalign;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
58 ogg_int32_t avgbytespersec;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
59 } stream_header_audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
60
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
61 typedef struct stream_header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
62 {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
63 char streamtype[8];
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
64 char subtype[4];
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
65
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
66 ogg_int32_t size; // size of the structure
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
67
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
68 ogg_int64_t time_unit; // in reference time
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
69 ogg_int64_t samples_per_unit;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
70 ogg_int32_t default_len; // in media time
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
71
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
72 ogg_int32_t buffersize;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
73 ogg_int16_t bits_per_sample;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
74
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
75 union
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
76 {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
77 // Video specific
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
78 stream_header_video video;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
79 // Audio specific
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
80 stream_header_audio audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
81 } sh;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
82 } stream_header;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
83
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
84 /// Our private datas
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
85
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
86 /// A logical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
87 typedef struct ogg_stream {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
88 /// Timestamping stuff
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
89 float samplerate; /// granulpos 2 time
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
90 int64_t lastpos;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
91 int32_t lastsize;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
92
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
93 // Logical stream state
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
94 ogg_stream_state stream;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
95 } ogg_stream_t;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
96
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
97 typedef struct ogg_demuxer {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
98 /// Physical stream state
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
99 ogg_sync_state sync;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
100 /// Current page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
101 ogg_page page;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
102 /// Logical streams
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
103 ogg_stream_t *subs;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
104 int num_sub;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
105 } ogg_demuxer_t;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
106
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
107 /// Some defines from OggDS
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
108 #define PACKET_TYPE_HEADER 0x01
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
109 #define PACKET_TYPE_BITS 0x07
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
110 #define PACKET_LEN_BITS01 0xc0
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
111 #define PACKET_LEN_BITS2 0x02
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
112 #define PACKET_IS_SYNCPOINT 0x08
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
113
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
114
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
115 // 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
116 // fill os if non NULL and return the stream id
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
117 static int demux_ogg_get_page_stream(ogg_demuxer_t* ogg_d,ogg_stream_state** os) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
118 int id,s_no;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
119 ogg_page* page = &ogg_d->page;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
120
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
121 s_no = ogg_page_serialno(page);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
122
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
123 for(id= 0; id < ogg_d->num_sub ; id++) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
124 if(s_no == ogg_d->subs[id].stream.serialno)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
125 break;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
126 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
127
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
128 if(id == ogg_d->num_sub)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
129 return -1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
130
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
131 if(os)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
132 *os = &ogg_d->subs[id].stream;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
133
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
134 return id;
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 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
137
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
138 /// 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
139 // return 1 if the packet was added, 0 otherwise
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
140 static int demux_ogg_add_packet(demux_stream_t* ds,ogg_stream_t* os,ogg_packet* pack) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
141 demuxer_t* d = ds->demuxer;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
142 demux_packet_t* dp;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
143 unsigned char* data;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
144 float pts = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
145 int flags = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
146
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
147 // If packet is an header we jump it except for vorbis
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
148 if((*pack->packet & PACKET_TYPE_HEADER) &&
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
149 (ds == d->video || (ds == d->audio && ((sh_audio_t*)ds->sh)->format != 0xFFFE )))
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
150 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
151
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
152 // For vorbis packet the packet is the data, for other codec we must jump the header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
153 if(ds == d->audio && ((sh_audio_t*)ds->sh)->format == 0xFFFE) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
154 data = pack->packet;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
155 if(*pack->packet & PACKET_TYPE_HEADER)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
156 pts = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
157 else {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
158 vorbis_info* vi = &((ov_struct_t*)((sh_audio_t*)ds->sh)->context)->vi;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
159 // When we dump the audio, there is no vi, but we dont care of timestamp in this case
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
160 if(vi) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
161 int32_t blocksize = vorbis_packet_blocksize(vi,pack) / vi->channels;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
162 // Calculate the timestamp if the packet don't have any
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
163 if(pack->granulepos == -1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
164 pack->granulepos = os->lastpos;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
165 if(os->lastsize > 0)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
166 pack->granulepos += os->lastsize;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
167 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
168 pts = pack->granulepos / (float)vi->rate;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
169 os->lastsize = blocksize;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
170 os->lastpos = pack->granulepos;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
171 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
172 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
173 } else {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
174 // Find data start
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
175 int16_t hdrlen = (*pack->packet & PACKET_LEN_BITS01)>>6;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
176 hdrlen |= (*pack->packet & PACKET_LEN_BITS2) <<1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
177 data = pack->packet + 1 + hdrlen;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
178 // Calculate the timestamp
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
179 if(pack->granulepos == -1)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
180 pack->granulepos = os->lastpos + os->lastsize;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
181 // If we alredy have a timestamp it can be a syncpoint
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
182 else if(*pack->packet & PACKET_IS_SYNCPOINT)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
183 flags = 1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
184 pts = pack->granulepos/os->samplerate;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
185 // Save the packet length and timestamp
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
186 os->lastsize = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
187 while(hdrlen) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
188 os->lastsize <<= 8;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
189 os->lastsize |= pack->packet[hdrlen];
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
190 hdrlen--;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
191 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
192 os->lastpos = pack->granulepos;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
193 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
194
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
195 /// Send the packet
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
196 dp = new_demux_packet(pack->bytes-(data-pack->packet));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
197 memcpy(dp->buffer,data,pack->bytes-(data-pack->packet));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
198 ds->pts = pts;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
199 ds->flags = flags;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
200 ds_add_packet(ds,dp);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
201 return 1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
202 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
203
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
204 /// Open an ogg physical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
205 int demux_ogg_open(demuxer_t* demuxer) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
206 ogg_demuxer_t* ogg_d;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
207 stream_t *s;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
208 char* buf;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
209 int np,s_no, n_audio = 0, n_video = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
210 ogg_sync_state* sync;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
211 ogg_page* page;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
212 ogg_packet pack;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
213 sh_audio_t* sh_a;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
214 sh_video_t* sh_v;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
215
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
216 s = demuxer->stream;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
217
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
218 ogg_d = (ogg_demuxer_t*)calloc(1,sizeof(ogg_demuxer_t));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
219 sync = &ogg_d->sync;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
220 page = &ogg_d->page;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
221
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
222 ogg_sync_init(&ogg_d->sync);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
223
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
224 while(1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
225 /// Try to get a page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
226 np = ogg_sync_pageout(sync,page);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
227 /// Error
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
228 if(np < 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
229 mp_msg(MSGT_DEMUX,MSGL_DBG2,"OGG demuxer : Bad page sync\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
230 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
231 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
232 /// Need some more data
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
233 if(np <= 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
234 int len;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
235 buf = ogg_sync_buffer(sync,BLOCK_SIZE);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
236 len = stream_read(s,buf,BLOCK_SIZE);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
237 if(len == 0 && s->eof) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
238 free(ogg_d);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
239 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
240 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
241 ogg_sync_wrote(sync,len);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
242 continue;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
243 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
244
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
245 // We got one page now
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
246
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
247 if( ! ogg_page_bos(page) ) { // It's not a begining page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
248 // Header parsing end here, we need to get the page otherwise it will be lost
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
249 int id = demux_ogg_get_page_stream(ogg_d,NULL);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
250 if(id >= 0)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
251 ogg_stream_pagein(&ogg_d->subs[id].stream,page);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
252 else
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
253 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG : Warning found none bos page from unknow stream %d\n",ogg_page_serialno(page));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
254 break;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
255 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
256
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
257 /// Init the data structure needed for a logical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
258 ogg_d->subs = (ogg_stream_t*)realloc(ogg_d->subs,(ogg_d->num_sub+1)*sizeof(ogg_stream_t));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
259 memset(&ogg_d->subs[ogg_d->num_sub],0,sizeof(ogg_stream_t));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
260 /// Get the stream serial number
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
261 s_no = ogg_page_serialno(page);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
262 ogg_stream_init(&ogg_d->subs[ogg_d->num_sub].stream,s_no);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
263 mp_msg(MSGT_DEMUX,MSGL_DBG2,"OGG : Found a stream with serial=%d\n",s_no);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
264 // Take the first page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
265 ogg_stream_pagein(&ogg_d->subs[ogg_d->num_sub].stream,page);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
266 // Get first packet of the page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
267 ogg_stream_packetout(&ogg_d->subs[ogg_d->num_sub].stream,&pack);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
268
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
269 // Reset our vars
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
270 sh_a = NULL;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
271 sh_v = NULL;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
272
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
273 // Check for Vorbis
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
274 if(pack.bytes >= 7 && ! strncmp(&pack.packet[1],"vorbis", 6) ) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
275 sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
276 sh_a->format = 0xFFFE;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
277 n_audio++;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
278 mp_msg(MSGT_DEMUX,MSGL_V,"OGG : stream %d is vorbis\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
279
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
280 /// Check for old header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
281 } else if(pack.bytes >= 142 && ! strncmp(&pack.packet[1],"Direct Show Samples embedded in Ogg",35) ) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
282
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
283 // Old video header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
284 if(*(int32_t*)(pack.packet+96) == 0x05589f80 && pack.bytes >= 184) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
285 sh_v = new_sh_video(demuxer,ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
286 sh_v->bih = (BITMAPINFOHEADER*)calloc(1,sizeof(BITMAPINFOHEADER));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
287 sh_v->format = mmioFOURCC(pack.packet[68],pack.packet[69],
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
288 pack.packet[70],pack.packet[71]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
289 sh_v->frametime = (*(int64_t*)(pack.packet+164))*0.0000001;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
290 sh_v->fps = 1/sh_v->frametime;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
291 sh_v->disp_w = sh_v->bih->biWidth = *(int32_t*)(pack.packet+176);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
292 sh_v->disp_h = sh_v->bih->biHeight = *(int32_t*)(pack.packet+180);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
293 sh_v->bih->biBitCount = *(int16_t*)(pack.packet+182);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
294
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
295 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
296 n_video++;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
297 mp_msg(MSGT_DEMUX,MSGL_V,"OGG stream %d is video\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
298
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
299 // Old audio header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
300 } else if(*(int32_t*)pack.packet+96 == 0x05589F81) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
301 unsigned int extra_size;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
302 sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
303 extra_size = *(int16_t*)(pack.packet+140);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
304 sh_a->wf = (WAVEFORMATEX*)calloc(1,sizeof(WAVEFORMATEX)+extra_size);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
305 sh_a->format = sh_a->wf->wFormatTag = *(int16_t*)(pack.packet+124);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
306 sh_a->channels = sh_a->wf->nChannels = *(int16_t*)(pack.packet+126);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
307 sh_a->samplerate = sh_a->wf->nSamplesPerSec = *(int32_t*)(pack.packet+128);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
308 sh_a->wf->nAvgBytesPerSec = *(int32_t*)(pack.packet+132);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
309 sh_a->wf->nBlockAlign = *(int16_t*)(pack.packet+136);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
310 sh_a->wf->wBitsPerSample = *(int16_t*)(pack.packet+138);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
311 sh_a->samplesize = (sh_a->wf->wBitsPerSample+7)/8;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
312 sh_a->wf->cbSize = extra_size;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
313 if(extra_size > 0)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
314 memcpy(sh_a->wf+sizeof(WAVEFORMATEX),pack.packet+142,extra_size);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
315
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
316 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate * sh_a->channels;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
317 n_audio++;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
318 mp_msg(MSGT_DEMUX,MSGL_V,"OGG stream %d is audio\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
319 } else
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
320 mp_msg(MSGT_DEMUX,MSGL_WARN,"OGG stream %d contain an old header but the header type is unknow\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
321
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
322 // Check new header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
323 } else if ( (*pack.packet & PACKET_TYPE_BITS ) == PACKET_TYPE_HEADER &&
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
324 pack.bytes >= (int)sizeof(stream_header)+1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
325 stream_header *st = (stream_header*)(pack.packet+1);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
326 /// New video header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
327 if(strncmp(st->streamtype,"video",5) == 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
328 sh_v = new_sh_video(demuxer,ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
329 sh_v->bih = (BITMAPINFOHEADER*)calloc(1,sizeof(BITMAPINFOHEADER));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
330 sh_v->format = mmioFOURCC(st->subtype[0],st->subtype[1],
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
331 st->subtype[2],st->subtype[3]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
332 sh_v->frametime = st->time_unit*0.0000001;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
333 sh_v->fps = 1/sh_v->frametime;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
334 sh_v->bih->biSize = st->buffersize;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
335 sh_v->bih->biBitCount = st->bits_per_sample;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
336 sh_v->disp_w = sh_v->bih->biWidth = st->sh.video.width;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
337 sh_v->disp_h = sh_v->bih->biHeight = st->sh.video.height;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
338
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
339 ogg_d->subs[ogg_d->num_sub].samplerate= sh_v->fps;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
340 n_video++;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
341 mp_msg(MSGT_DEMUX,MSGL_V,"OGG stream %d is video\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
342 /// New audio header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
343 } else if(strncmp(st->streamtype,"audio",5) == 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
344 char buffer[5];
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
345 unsigned int extra_size = st->size - sizeof(stream_header);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
346 memcpy(buffer,st->subtype,4);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
347 buffer[4] = '\0';
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
348 sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
349 sh_a->wf = (WAVEFORMATEX*)calloc(1,sizeof(WAVEFORMATEX)+extra_size);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
350 sh_a->format = sh_a->wf->wFormatTag = atoi(buffer);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
351 sh_a->channels = sh_a->wf->nChannels = st->sh.audio.channels;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
352 sh_a->samplerate = sh_a->wf->nSamplesPerSec = st->samples_per_unit;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
353 sh_a->wf->nAvgBytesPerSec = st->sh.audio.avgbytespersec;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
354 sh_a->wf->nBlockAlign = st->sh.audio.blockalign;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
355 sh_a->wf->wBitsPerSample = st->bits_per_sample;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
356 sh_a->samplesize = (sh_a->wf->wBitsPerSample+7)/8;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
357 sh_a->wf->cbSize = extra_size;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
358 if(extra_size)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
359 memcpy(sh_a->wf+sizeof(WAVEFORMATEX),st+1,extra_size);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
360
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
361 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate * sh_a->channels;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
362 n_audio++;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
363 mp_msg(MSGT_DEMUX,MSGL_V,"OGG stream %d is audio\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
364
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
365 /// Check for text (subtitles) header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
366 } else if(strncmp(st->streamtype,"text",4) == 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
367 mp_msg(MSGT_DEMUX,MSGL_WARN,"OGG text stream are not supported\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
368 //// Unknow header type
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
369 } else
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
370 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG stream %d has a header marker but is of an unknow type\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
371 /// Unknow (invalid ?) header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
372 } else
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
373 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG stream %d is of an unknow type\n",ogg_d->num_sub);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
374
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
375 if(sh_a || sh_v) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
376 demux_stream_t* ds = NULL;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
377 if(sh_a) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
378 // If the audio stream is not defined we took the first one
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
379 if(demuxer->audio->id == -1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
380 demuxer->audio->id = ogg_d->num_sub;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
381 demuxer->audio->sh = sh_a;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
382 sh_a->ds = demuxer->audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
383 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
384 /// Is it the stream we want
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
385 if(demuxer->audio->id == ogg_d->num_sub)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
386 ds = demuxer->audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
387 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
388 if(sh_v) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
389 /// Also for video
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
390 if(demuxer->video->id == -1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
391 demuxer->video->id = ogg_d->num_sub;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
392 demuxer->video->sh = sh_v;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
393 sh_v->ds = demuxer->video;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
394 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
395 if(demuxer->video->id == ogg_d->num_sub)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
396 ds = demuxer->video;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
397 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
398 /// Add the packet contained in this page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
399 if(ds) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
400 /// Finish the page, otherwise packets will be lost
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
401 do {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
402 demux_ogg_add_packet(ds,&ogg_d->subs[ogg_d->num_sub],&pack);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
403 } while(ogg_stream_packetout(&ogg_d->subs[ogg_d->num_sub].stream,&pack) == 1);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
404
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
405 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
406 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
407 ogg_d->num_sub++;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
408 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
409
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
410 /// Finish to setup the demuxer
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
411 demuxer->priv = ogg_d;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
412 /// We can't seek :(
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
413 demuxer->seekable = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
414
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
415 if(!n_video)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
416 demuxer->video->id = -2;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
417 if(!n_audio)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
418 demuxer->audio->id = -2;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
419
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
420 mp_msg(MSGT_DEMUX,MSGL_V,"OGG demuxer : found %d audio stream and %d video stream\n",n_audio,n_video);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
421
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
422 return 1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
423 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
424
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
425
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
426 int demux_ogg_fill_buffer(demuxer_t *d) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
427 ogg_demuxer_t* ogg_d;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
428 stream_t *s;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
429 demux_stream_t *ds;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
430 ogg_sync_state* sync;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
431 ogg_stream_state* os;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
432 ogg_page* page;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
433 ogg_packet pack;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
434 int np = 0, id=0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
435
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
436 s = d->stream;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
437 ogg_d = d->priv;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
438 sync = &ogg_d->sync;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
439 page = &ogg_d->page;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
440
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
441 /// Find the stream we are working on
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
442 if ( (id = demux_ogg_get_page_stream(ogg_d,&os)) < 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
443 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG demuxer : can't get current stream\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
444 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
445 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
446
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
447 while(1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
448 np = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
449 ds = NULL;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
450 /// Try to get some packet from the current page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
451 while( (np = ogg_stream_packetout(os,&pack)) != 1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
452 /// No packet we go the next page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
453 if(np == 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
454 while(1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
455 int pa,len;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
456 char *buf;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
457 /// Get the next page from the physical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
458 while( (pa = ogg_sync_pageout(sync,page)) != 1) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
459 /// Error : we skip some bytes
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
460 if(pa < 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
461 mp_msg(MSGT_DEMUX,MSGL_WARN,"OGG : Page out not synced, we skip some bytes\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
462 continue;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
463 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
464 /// We need more data
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
465 buf = ogg_sync_buffer(sync,BLOCK_SIZE);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
466 len = stream_read(s,buf,BLOCK_SIZE);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
467 if(len == 0 && s->eof) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
468 mp_msg(MSGT_DEMUX,MSGL_DBG2,"OGG : Stream EOF !!!!\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
469 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
470 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
471 ogg_sync_wrote(sync,len);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
472 } /// Page loop
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
473
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
474 /// Find the page's logical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
475 if( (id = demux_ogg_get_page_stream(ogg_d,&os)) < 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
476 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG demuxer error : we met an unknow stream\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
477 return 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
478 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
479 /// Take the page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
480 if(ogg_stream_pagein(os,page) == 0)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
481 break;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
482 /// Page was invalid => retry
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
483 mp_msg(MSGT_DEMUX,MSGL_WARN,"OGG demuxer : got invalid page !!!!!\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
484 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
485 } else /// Packet was corrupted
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
486 mp_msg(MSGT_DEMUX,MSGL_WARN,"OGG : bad packet in stream %d\n",id);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
487 } /// Packet loop
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
488
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
489 /// Is the actual logical stream in use ?
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
490 if(id == d->audio->id)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
491 ds = d->audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
492 else if(id == d->video->id)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
493 ds = d->video;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
494
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
495 if(ds) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
496 if(!demux_ogg_add_packet(ds,&ogg_d->subs[id],&pack))
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
497 continue; /// Unuseful packet, get another
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
498 return 1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
499 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
500
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
501 } /// while(1)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
502
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
503 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
504
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
505 /// 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
506 // stream, then we join the avi and ogg demuxer with a demuxers demuxer
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
507 demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
508 demuxer_t *od;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
509 ogg_demuxer_t *ogg_d;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
510 stream_t* s;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
511 uint32_t hdrsizes[3];
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
512 demux_packet_t *dp;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
513 sh_audio_t *sh_audio = demuxer->audio->sh;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
514 int np;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
515 unsigned char *p = NULL,*buf;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
516 int plen;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
517
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
518 /// Check that the cbSize is enouth big for the following reads
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
519 if(sh_audio->wf->cbSize < 3*sizeof(uint32_t)) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
520 mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI OGG : Initial audio header is too small !!!!!\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
521 goto fallback;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
522 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
523 /// Get the size of the 3 header packet
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
524 memcpy(hdrsizes, ((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX), 3*sizeof(uint32_t));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
525
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
526 /// Check the size
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
527 if(sh_audio->wf->cbSize < 3*sizeof(uint32_t) + sizeof(uint32_t)+hdrsizes[0]+hdrsizes[1] + hdrsizes[2]) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
528 mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI OGG : Audio header is too small !!!!!\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
529 goto fallback;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
530 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
531
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
532 // Build the ogg demuxer private datas
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
533 ogg_d = (ogg_demuxer_t*)calloc(1,sizeof(ogg_demuxer_t));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
534 ogg_d->num_sub = 1;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
535 ogg_d->subs = (ogg_stream_t*)malloc(sizeof(ogg_stream_t));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
536
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
537 // Init the ogg physical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
538 ogg_sync_init(&ogg_d->sync);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
539
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
540 // Get the first page of the stream : we assume there only 1 logical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
541 while((np = ogg_sync_pageout(&ogg_d->sync,&ogg_d->page)) <= 0 ) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
542 if(np < 0) {
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
543 mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI OGG error : Can't init using first stream packets\n");
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
544 free(ogg_d);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
545 goto fallback;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
546 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
547 // Add some data
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
548 plen = ds_get_packet(demuxer->audio,&p);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
549 buf = ogg_sync_buffer(&ogg_d->sync,plen);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
550 memcpy(buf,p,plen);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
551 ogg_sync_wrote(&ogg_d->sync,plen);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
552 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
553 // Init the logical stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
554 mp_msg(MSGT_DEMUX,MSGL_DBG2,"AVI OGG found page with serial %d\n",ogg_page_serialno(&ogg_d->page));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
555 ogg_stream_init(&ogg_d->subs[0].stream,ogg_page_serialno(&ogg_d->page));
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
556 // Write the page
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
557 ogg_stream_pagein(&ogg_d->subs[0].stream,&ogg_d->page);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
558
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
559 // Create the ds_stream and the ogg demuxer
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
560 s = new_ds_stream(demuxer->audio);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
561 od = new_demuxer(s,DEMUXER_TYPE_OGG,0,-2,-2);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
562
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
563 /// Add the header packets in the ogg demuxer audio stream
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
564 // Initial header
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
565 dp = new_demux_packet(hdrsizes[0]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
566 memcpy(dp->buffer,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t),hdrsizes[0]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
567 ds_add_packet(od->audio,dp);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
568 /// Comments
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
569 dp = new_demux_packet(hdrsizes[1]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
570 memcpy(dp->buffer,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0],hdrsizes[1]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
571 ds_add_packet(od->audio,dp);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
572 /// Code book
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
573 dp = new_demux_packet(hdrsizes[2]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
574 memcpy(dp->buffer,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0]+hdrsizes[1],hdrsizes[2]);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
575 ds_add_packet(od->audio,dp);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
576
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
577 // Finish setting up the ogg demuxer
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
578 od->priv = ogg_d;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
579 sh_audio = new_sh_audio(od,0);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
580 od->audio->id = 0;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
581 od->video->id = -2;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
582 od->audio->sh = sh_audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
583 sh_audio->ds = od->audio;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
584 sh_audio->format = 0xFFFE;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
585
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
586 /// Return the joined demuxers
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
587 return new_demuxers_demuxer(demuxer,od,demuxer);
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
588
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
589 fallback:
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
590 demuxer->audio->id = -2;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
591 return demuxer;
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
592
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
593 }
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
594
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
595 /// TODO : Seeking 8-)
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
596
9841a86d66f9 Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
diff changeset
597 #endif