annotate libmpdemux/demux_real.c @ 3905:91e5c563fce5

SSE added
author arpi
date Sun, 30 Dec 2001 20:26:19 +0000
parents c5cefeb78c40
children 701d18898835
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
1 /*
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
2 Real parser & demuxer
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
3
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
4 (C) Alex Beregszaszi <alex@naxine.org>
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
5
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
6 Based on FFmpeg's libav/rm.c.
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
7 */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
8
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
9 /*
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
10 Some codecs for Real (from Mike Melanson):
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
11
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
12 RV10: As has been mentioned, H.263-based; not an unreasonable guess
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
13 RV20: RealVideo 2.0, nothing known
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
14 RV30: RealVideo 3.0,nothing known, but I don't believe I've ever seen any
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
15 media encoded with it
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
16 DNET: apparently one of their original audio codecs, to be used with music
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
17 SIPR: SiprNet, based on ACELP, and is great for compressing voice
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
18 COKR(?): Cooker, the fabled G2 audio codec
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
19
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
20 New infos:
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
21
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
22 Audio codecs: (supported by RealPlayer8 for Linux)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
23 ATRC - RealAudio 8 (ATRAC3)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
24 COOK - RealAudio G2
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
25 DNET - RealAudio 3.0
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
26 SIPR - SiproLab's audio codec
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
27
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
28 Video codecs: (supported by RealPlayer8 for Linux)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
29 RV10
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
30 RV20
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
31 RV30
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
32 */
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
33
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
34 #include <stdio.h>
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
35 #include <stdlib.h>
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
36 #include <unistd.h>
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
37
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
38 #include "config.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
39 #include "mp_msg.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
40 #include "help_mp.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
41
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
42 #include "stream.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
43 #include "demuxer.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
44 #include "stheader.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
45 #include "bswap.h"
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
46
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
47 #define MKTAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24))
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
48
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
49 #define MAX_STREAMS 10
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
50
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
51 typedef struct {
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
52 /* for seeking */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
53 int index_chunk_offset;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
54 int *index_table[MAX_STREAMS];
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
55 int index_table_size[MAX_STREAMS];
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
56 int data_chunk_offset;
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
57 int num_of_packets;
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
58 int current_packet;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
59
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
60 /* stream id table */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
61 int last_a_stream;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
62 int a_streams[MAX_STREAMS];
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
63 int last_v_stream;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
64 int v_streams[MAX_STREAMS];
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
65 } real_priv_t;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
66
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
67 static void get_str(int isbyte, demuxer_t *demuxer, char *buf, int buf_size)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
68 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
69 int len, i;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
70 char *q;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
71
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
72 if (isbyte)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
73 len = stream_read_char(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
74 else
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
75 len = stream_read_word(demuxer->stream);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
76
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
77 stream_read(demuxer->stream, buf, (len > buf_size) ? buf_size : len);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
78 if (len > buf_size)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
79 stream_skip(demuxer->stream, len-buf_size);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
80
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
81 printf("read_str: %d bytes read\n", len);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
82 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
83
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
84 static void skip_str(int isbyte, demuxer_t *demuxer)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
85 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
86 int len;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
87
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
88 if (isbyte)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
89 len = stream_read_char(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
90 else
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
91 len = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
92
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
93 stream_skip(demuxer->stream, len);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
94
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
95 printf("skip_str: %d bytes skipped\n", len);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
96 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
97
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
98 static void parse_index_chunk(demuxer_t *demuxer)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
99 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
100 real_priv_t *priv = demuxer->priv;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
101 int origpos = stream_tell(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
102 int i, entries;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
103 int stream_id = 0;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
104
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
105 printf("Building index table from index chunk (%d)\n",
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
106 priv->index_chunk_offset);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
107
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
108 stream_seek(demuxer->stream, priv->index_chunk_offset);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
109
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
110 stream_skip(demuxer->stream, 4); /* INDX */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
111
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
112 read_index:
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
113 if (stream_id > MAX_STREAMS)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
114 goto end;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
115
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
116 stream_skip(demuxer->stream, 8); /* unknown */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
117 entries = stream_read_word(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
118 printf("entries: %d\n", entries);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
119 if (entries <= 0)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
120 goto end;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
121 stream_skip(demuxer->stream, 12); /* unknown */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
122
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
123 // stream_skip(demuxer->stream, 22); /* unknown bytes */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
124
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
125 priv->index_table_size[stream_id] = entries;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
126 priv->index_table[stream_id] = malloc(priv->index_table_size[stream_id] * sizeof(int));
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
127
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
128 for (i = 0; i < entries; i++)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
129 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
130 priv->index_table[stream_id][i] = stream_read_dword(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
131 stream_skip(demuxer->stream, 10); /* unknown bytes */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
132 /* [position(dword)][unk1(word)][unused(dword)][unk2(word)] */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
133 printf("Index table: Stream#%d: entry: %d: pos: %d\n",
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
134 stream_id, i, priv->index_table[stream_id][i]);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
135 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
136 demuxer->seekable = 1; /* got index, we're able to seek */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
137
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
138 // stream_seek(demuxer->stream, stream_tell(demuxer->stream)-7);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
139 /* search next index table for other stream */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
140 i = stream_read_word(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
141 printf("pos: %d, next tag: %.4s\n", stream_tell(demuxer->stream), &i);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
142 if (i == MKTAG('I', 'N', 'D', 'X'))
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
143 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
144 stream_id++;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
145 goto read_index;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
146 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
147
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
148 end:
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
149 if (entries == -256)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
150 stream_reset(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
151 stream_seek(demuxer->stream, origpos);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
152 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
153
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
154 int real_check_file(demuxer_t* demuxer)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
155 {
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
156 real_priv_t *priv;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
157 int c;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
158
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
159 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for REAL\n");
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
160
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
161 c = stream_read_dword_le(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
162 if (c == -256)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
163 return 0; /* EOF */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
164 if (c != MKTAG('.', 'R', 'M', 'F'))
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
165 return 0; /* bad magic */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
166
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
167 priv = malloc(sizeof(real_priv_t));
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
168 memset(priv, 0, sizeof(real_priv_t));
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
169 demuxer->priv = priv;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
170
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
171 return 1;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
172 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
173
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
174 // return value:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
175 // 0 = EOF or no stream found
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
176 // 1 = successfully read a packet
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
177 int demux_real_fill_buffer(demuxer_t *demuxer)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
178 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
179 real_priv_t *priv = demuxer->priv;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
180 demux_stream_t *ds = NULL;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
181 int len;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
182 int timestamp;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
183 int stream_id;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
184 int i;
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
185 int flags;
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
186
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
187 // printf("num_of_packets: %d\n", priv->num_of_packets);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
188
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
189 loop:
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
190 if ((priv->num_of_packets == 0) && (priv->num_of_packets != -10))
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
191 return 0; /* EOF */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
192 if (priv->current_packet > priv->num_of_packets)
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
193 return 0; /* EOF */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
194 stream_skip(demuxer->stream, 2); /* version */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
195 len = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
196 if (len == -256) /* EOF */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
197 return 0;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
198 if (len < 12)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
199 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
200 printf("bad packet len (%d)\n", len);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
201 stream_skip(demuxer->stream, len);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
202 goto loop;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
203 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
204 stream_id = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
205 timestamp = stream_read_dword(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
206
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
207 stream_skip(demuxer->stream, 1); /* reserved */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
208 flags = stream_read_char(demuxer->stream);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
209 /* flags: */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
210 /* 0x2 - keyframe */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
211
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
212 // printf("packet#%d: pos: %d, len: %d, stream_id: %d, timestamp: %d, flags: %x\n",
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
213 // priv->current_packet, stream_tell(demuxer->stream)-12, len, stream_id, timestamp, flags);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
214
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
215 // if (priv->num_of_packets != -10)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
216 // priv->num_of_packets--;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
217 priv->current_packet++;
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
218 len -= 12;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
219
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
220 /* check if stream_id is audio stream */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
221 for (i = 0; i < priv->last_a_stream; i++)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
222 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
223 if (priv->a_streams[i] == stream_id)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
224 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
225 // printf("packet is audio (id: %d)\n", stream_id);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
226 ds = demuxer->audio; /* FIXME */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
227 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
228 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
229 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
230 /* check if stream_id is video stream */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
231 for (i = 0; i < priv->last_v_stream; i++)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
232 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
233 if (priv->v_streams[i] == stream_id)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
234 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
235 // printf("packet is video (id: %d)\n", stream_id);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
236 ds = demuxer->video; /* FIXME */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
237 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
238 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
239 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
240
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
241 /* id not found */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
242 if (ds == NULL)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
243 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
244 printf("unknown stream id (%d)\n", stream_id);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
245 stream_skip(demuxer->stream, len);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
246 goto loop;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
247 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
248
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
249 demuxer->filepos = stream_tell(demuxer->stream);
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
250 ds_read_packet(ds, demuxer->stream, len, timestamp/90000.0f,
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
251 demuxer->filepos, (flags & 0x2) ? 0x10 : 0);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
252
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
253 return 1;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
254 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
255
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
256 void demux_open_real(demuxer_t* demuxer)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
257 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
258 real_priv_t* priv = demuxer->priv;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
259 int num_of_headers;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
260 int i;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
261
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
262 stream_skip(demuxer->stream, 4); /* header size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
263 stream_skip(demuxer->stream, 2);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
264 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
265 num_of_headers = stream_read_dword(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
266 // stream_skip(demuxer->stream, 4); /* number of headers */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
267
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
268 /* parse chunks */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
269 for (i = 1; i < num_of_headers; i++)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
270 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
271 int chunk, chunk_size;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
272
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
273 chunk = stream_read_dword_le(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
274 chunk_size = stream_read_dword(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
275
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
276 stream_skip(demuxer->stream, 2);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
277
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
278 if (chunk_size < 10)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
279 goto fail;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
280
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
281 printf("Chunk: %.4s (size: %d)\n",
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
282 (char *)&chunk, chunk_size);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
283
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
284 switch(chunk)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
285 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
286 case MKTAG('P', 'R', 'O', 'P'):
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
287 // printf("Properties chunk\n");
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
288 stream_skip(demuxer->stream, 4); /* max bitrate */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
289 stream_skip(demuxer->stream, 4); /* avg bitrate */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
290 stream_skip(demuxer->stream, 4); /* max packet size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
291 stream_skip(demuxer->stream, 4); /* avg packet size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
292 stream_skip(demuxer->stream, 4); /* nb packets */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
293 stream_skip(demuxer->stream, 4); /* duration */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
294 stream_skip(demuxer->stream, 4); /* preroll */
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
295 // stream_skip(demuxer->stream, 4); /* index offset */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
296 priv->index_chunk_offset = stream_read_dword(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
297 printf("Index chunk offset: 0x%x\n", priv->index_chunk_offset);
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
298 // stream_skip(demuxer->stream, 4); /* data offset */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
299 priv->data_chunk_offset = stream_read_dword(demuxer->stream)+10;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
300 printf("Data chunk offset: 0x%x\n", priv->data_chunk_offset);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
301 stream_skip(demuxer->stream, 2); /* nb streams */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
302 #if 0
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
303 stream_skip(demuxer->stream, 2); /* flags */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
304 #else
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
305 {
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
306 int flags = stream_read_word(demuxer->stream);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
307 printf("Flags (%x): ", flags);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
308 if (flags & 0x1)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
309 printf("[save allowed] ");
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
310 if (flags & 0x2)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
311 printf("[perfect play (?)] ");
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
312 if (flags & 0x4)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
313 printf("[live broadcast] ");
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
314 printf("\n");
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
315 }
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
316 #endif
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
317 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
318 case MKTAG('C', 'O', 'N', 'T'):
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
319 {
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
320 char *buf;
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
321 int len;
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
322
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
323 // printf("Broadcasting informations (title, author, copyright, comment)\n");
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
324
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
325 len = stream_read_word(demuxer->stream);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
326 if (len > 0)
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
327 {
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
328 buf = malloc(len+1);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
329 stream_read(demuxer->stream, buf, len);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
330 demux_info_add(demuxer, "name", buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
331 free(buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
332 }
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
333
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
334 len = stream_read_word(demuxer->stream);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
335 if (len > 0)
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
336 {
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
337 buf = malloc(len+1);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
338 stream_read(demuxer->stream, buf, len);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
339 buf[len] = 0;
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
340 demux_info_add(demuxer, "author", buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
341 free(buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
342 }
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
343
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
344 len = stream_read_word(demuxer->stream);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
345 if (len > 0)
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
346 {
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
347 buf = malloc(len+1);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
348 stream_read(demuxer->stream, buf, len);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
349 buf[len] = 0;
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
350 demux_info_add(demuxer, "copyright", buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
351 free(buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
352 }
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
353
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
354 len = stream_read_word(demuxer->stream);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
355 if (len > 0)
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
356 {
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
357 buf = malloc(len+1);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
358 stream_read(demuxer->stream, buf, len);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
359 buf[len] = 0;
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
360 demux_info_add(demuxer, "comment", buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
361 free(buf);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
362 }
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
363
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
364 // skip_str(0, demuxer); /* title */
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
365 // skip_str(0, demuxer); /* author */
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
366 // skip_str(0, demuxer); /* copyright */
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
367 // skip_str(0, demuxer); /* comment */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
368 break;
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
369 }
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
370 case MKTAG('M', 'D', 'P', 'R'):
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
371 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
372 /* new stream */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
373 int stream_id;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
374 int bitrate;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
375 int codec_data_size;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
376 int codec_pos;
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
377 int tmp;
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
378
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
379 stream_id = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
380 printf("Found new stream (id: %d)\n", stream_id);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
381
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
382 stream_skip(demuxer->stream, 4); /* max bitrate */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
383 bitrate = stream_read_dword(demuxer->stream); /* bitrate */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
384 stream_skip(demuxer->stream, 4); /* max packet size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
385 stream_skip(demuxer->stream, 4); /* avg packet size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
386 stream_skip(demuxer->stream, 4); /* start time */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
387 stream_skip(demuxer->stream, 4); /* preroll */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
388 stream_skip(demuxer->stream, 4); /* duration */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
389
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
390 skip_str(1, demuxer); /* stream description */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
391 skip_str(1, demuxer); /* mimetype */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
392
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
393 codec_data_size = stream_read_dword(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
394 codec_pos = stream_tell(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
395
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
396 tmp = stream_read_dword(demuxer->stream);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
397 if (tmp == MKTAG(0xfd, 'a', 'r', '.')) /* audio header */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
398 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
399 sh_audio_t *sh = new_sh_audio(demuxer, stream_id);
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
400 char buf[128]; /* for codec name */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
401 int frame_size;
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
402 int version;
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
403
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
404 printf("Found audio stream!\n");
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
405 version = stream_read_word(demuxer->stream);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
406 printf("version: %d\n", version);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
407 // stream_skip(demuxer->stream, 2); /* version (4 or 5) */
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
408 stream_skip(demuxer->stream, 2);
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
409 stream_skip(demuxer->stream, 4); /* .ra4 or .ra5 */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
410 stream_skip(demuxer->stream, 4);
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
411 stream_skip(demuxer->stream, 2); /* version (4 or 5) */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
412 stream_skip(demuxer->stream, 4); /* header size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
413 stream_skip(demuxer->stream, 2); /* add codec info */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
414 stream_skip(demuxer->stream, 4); /* coded frame size */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
415 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
416 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
417 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
418 stream_skip(demuxer->stream, 2); /* 1 */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
419 // stream_skip(demuxer->stream, 2); /* coded frame size */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
420 frame_size = stream_read_word(demuxer->stream);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
421 printf("frame_size: %d\n", frame_size);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
422 stream_skip(demuxer->stream, 4);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
423
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
424 if (version == 5)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
425 stream_skip(demuxer->stream, 6);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
426
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
427 sh->samplerate = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
428 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
429 sh->channels = stream_read_word(demuxer->stream);
3877
a3c73266f81f fixed rv10 with subid=3
alex
parents: 3795
diff changeset
430 printf("samplerate: %d, channels: %d\n",
a3c73266f81f fixed rv10 with subid=3
alex
parents: 3795
diff changeset
431 sh->samplerate, sh->channels);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
432
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
433 if (version == 5)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
434 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
435 stream_skip(demuxer->stream, 4);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
436 stream_read(demuxer->stream, buf, 4);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
437 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
438 else
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
439 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
440 /* Desc #1 */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
441 skip_str(1, demuxer);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
442 /* Desc #2 */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
443 get_str(1, demuxer, buf, sizeof(buf));
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
444 }
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
445
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
446 tmp = 1; /* supported audio codec */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
447 switch (MKTAG(buf[0], buf[1], buf[2], buf[3]))
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
448 {
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
449 case MKTAG('d', 'n', 'e', 't'):
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
450 printf("Audio: DNET -> AC3\n");
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
451 sh->format = 0x2000;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
452 break;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
453 case MKTAG('s', 'i', 'p', 'r'):
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
454 printf("Audio: SiproLab's ACELP.net\n");
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
455 sh->format = 0x130;
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
456 break;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
457 case MKTAG('c', 'o', 'o', 'k'):
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
458 printf("Audio: Real's GeneralCooker (unsupported)\n");
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
459 tmp = 0;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
460 break;
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
461 case MKTAG('a', 't', 'r', 'c'):
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
462 default:
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
463 printf("Audio: Unknown (%s)\n", buf);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
464 tmp = 0;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
465 sh->format = MKTAG(buf[0], buf[1], buf[2], buf[3]);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
466 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
467
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
468 if (tmp)
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
469 {
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
470 /* Emulate WAVEFORMATEX struct: */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
471 sh->wf = malloc(sizeof(WAVEFORMATEX));
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
472 memset(sh->wf, 0, sizeof(WAVEFORMATEX));
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
473 sh->wf->wFormatTag = sh->format;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
474 sh->wf->nChannels = sh->channels;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
475 sh->wf->wBitsPerSample = 16;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
476 sh->wf->nSamplesPerSec = sh->samplerate;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
477 sh->wf->nAvgBytesPerSec = bitrate;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
478 sh->wf->nBlockAlign = frame_size; /* 19 for acelp, pff */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
479 sh->wf->cbSize = 0;
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
480
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
481 /* insert as stream */
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
482 demuxer->audio->sh = sh;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
483 sh->ds = demuxer->audio;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
484 demuxer->audio->id = stream_id;
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
485
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
486 if (priv->last_a_stream+1 < MAX_STREAMS)
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
487 {
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
488 priv->a_streams[priv->last_a_stream] = stream_id;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
489 priv->last_a_stream++;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
490 }
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
491 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
492 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
493 else
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
494 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
495 /* video header */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
496 sh_video_t *sh = new_sh_video(demuxer, stream_id);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
497
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
498 tmp = stream_read_dword_le(demuxer->stream);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
499 printf("video: %.4s (%x)\n", (char *)&tmp, tmp);
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
500 if (tmp != MKTAG('V', 'I', 'D', 'O'))
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
501 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
502 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported video codec\n");
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
503 goto skip_this_chunk;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
504 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
505
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
506 sh->format = stream_read_dword_le(demuxer->stream); /* fourcc */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
507 printf("video fourcc: %.4s (%x)\n", (char *)&sh->format, sh->format);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
508
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
509 /* emulate BITMAPINFOHEADER */
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
510 sh->bih = malloc(sizeof(BITMAPINFOHEADER));
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
511 memset(sh->bih, 0, sizeof(BITMAPINFOHEADER));
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
512 sh->bih->biSize = 40;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
513 sh->disp_w = sh->bih->biWidth = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
514 sh->disp_h = sh->bih->biHeight = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
515 sh->bih->biPlanes = 1;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
516 sh->bih->biBitCount = 24;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
517 sh->bih->biCompression = sh->format;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
518 sh->bih->biSizeImage= sh->bih->biWidth*sh->bih->biHeight*3;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
519
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
520 sh->fps = stream_read_word(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
521 sh->frametime = 1.0f/sh->fps;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
522
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
523 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
524 stream_skip(demuxer->stream, 2);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
525 stream_skip(demuxer->stream, 4);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
526 stream_skip(demuxer->stream, 2);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
527
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
528 /* h263 hack */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
529 tmp = stream_read_dword(demuxer->stream);
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
530 printf("H.263 ID: %x\n", tmp);
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
531 switch (tmp)
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
532 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
533 case 0x10000000:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
534 /* sub id: 0 */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
535 /* codec id: rv10 */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
536 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
537 case 0x10003000:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
538 case 0x10003001:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
539 /* sub id: 3 */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
540 /* codec id: rv10 */
3877
a3c73266f81f fixed rv10 with subid=3
alex
parents: 3795
diff changeset
541 sh->bih->biCompression = sh->format = mmioFOURCC('R', 'V', '1', '3');
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
542 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
543 case 0x20001000:
3788
d554b5b33d76 improved audio codec detection
alex
parents: 3777
diff changeset
544 case 0x20100001:
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
545 /* codec id: rv20 */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
546 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
547 default:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
548 /* codec id: none */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
549 printf("unknown id: %x\n", tmp);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
550 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
551
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
552 /* insert as stream */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
553 demuxer->video->sh = sh;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
554 sh->ds = demuxer->video;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
555 demuxer->video->id = stream_id;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
556 if (priv->last_v_stream+1 < MAX_STREAMS)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
557 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
558 priv->v_streams[priv->last_v_stream] = stream_id;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
559 priv->last_v_stream++;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
560 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
561 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
562
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
563 skip_this_chunk:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
564 /* skip codec info */
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
565 tmp = stream_tell(demuxer->stream) - codec_pos;
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
566 stream_skip(demuxer->stream, codec_data_size - tmp);
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
567 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
568 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
569 case MKTAG('D', 'A', 'T', 'A'):
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
570 goto header_end;
3795
15745f11e717 fixed audio detection code and improved ;)
alex
parents: 3788
diff changeset
571 case MKTAG('I', 'N', 'D', 'X'):
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
572 default:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
573 printf("Unknown chunk: %x\n", chunk);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
574 stream_skip(demuxer->stream, chunk_size - 10);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
575 break;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
576 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
577 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
578
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
579 header_end:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
580 priv->num_of_packets = stream_read_dword(demuxer->stream);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
581 // stream_skip(demuxer->stream, 4); /* number of packets */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
582 stream_skip(demuxer->stream, 4); /* next data header */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
583
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
584 printf("Packets in file: %d\n", priv->num_of_packets);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
585
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
586 if (priv->num_of_packets == 0)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
587 priv->num_of_packets = -10;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
588
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
589 /* disable seeking */
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
590 demuxer->seekable = 0;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
591
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
592 if (priv->index_chunk_offset && (index_mode == 1) || (index_mode == 2))
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
593 parse_index_chunk(demuxer);
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
594
3777
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
595 fail:
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
596 return;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
597 }
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
598
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
599 void demux_close_real(demuxer_t *demuxer)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
600 {
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
601 real_priv_t* priv = demuxer->priv;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
602
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
603 if (priv)
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
604 free(priv);
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
605
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
606 return;
026ccd3dc489 added real demuxer
alex
parents:
diff changeset
607 }
3882
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
608
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
609 #if 0
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
610 /* will complete it later - please upload RV10 samples WITH INDEX CHUNK */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
611 int demux_seek_real(demuxer_t *demuxer, float rel_seek_secs, int flags)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
612 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
613 real_priv_t *priv = demuxer->priv;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
614 demux_stream_t *d_audio = demuxer->audio;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
615 demux_stream_t *d_video = demuxer->video;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
616 sh_audio_t *sh_audio = d_audio->sh;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
617 sh_video_t *sh_video = d_video->sh;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
618 int rel_seek_frames = sh->fps*rel_seek_secs;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
619 int video_chunk_pos = d_video->pos;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
620 int stream_id = 0;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
621
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
622 #if 0
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
623 if (flags & 1)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
624 /* seek absolute */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
625 video_chunk_pos = 0;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
626
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
627 if (flags & 2)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
628 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
629 int total = sh_video->video.dwLength;
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
630
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
631 rel_seek_frames
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
632 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
633 #endif
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
634
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
635 if (rel_seek_frames > 0)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
636 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
637 /* seek forward */
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
638 for (i = 0; i < index_table_size[stream_id]; i++)
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
639 {
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
640 if (index_table[stream_id][i]
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
641 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
642 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
643 }
c5cefeb78c40 added read_index_chunk, fixed audio_header parser for version5
alex
parents: 3877
diff changeset
644 #endif