Mercurial > mplayer.hg
annotate libmpdemux/demux_real.c @ 7533:abc3b12165b7
another dga v1 fix by Fredrik Noring <noring@nocrew.org>
author | arpi |
---|---|
date | Sat, 28 Sep 2002 18:50:45 +0000 |
parents | c4434bdf6e51 |
children | 30e1c1f77737 |
rev | line source |
---|---|
3777 | 1 /* |
2 Real parser & demuxer | |
3 | |
4 (C) Alex Beregszaszi <alex@naxine.org> | |
5 | |
6 Based on FFmpeg's libav/rm.c. | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
7 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
8 TODO: fix the whole syncing mechanism |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
9 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
10 $Log$ |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7105
diff
changeset
|
11 Revision 1.26 2002/09/22 02:33:26 arpi |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7105
diff
changeset
|
12 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7105
diff
changeset
|
13 |
7105 | 14 Revision 1.25 2002/08/27 23:01:54 arpi |
15 - added matrix cracking/debugging code - disabled | |
16 - use real codec headers for sipr | |
17 | |
7085
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
18 Revision 1.24 2002/08/25 00:07:15 arpi |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
19 some files has some shit before teh audio/video headers... |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
20 |
7084 | 21 Revision 1.23 2002/08/24 23:07:34 arpi |
22 10l - fixed chunktab size calculation | |
23 | |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
24 Revision 1.22 2002/08/24 22:39:27 arpi |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
25 - changed re-muxed packet structure (see struct dp_hdr_t) |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
26 now the packets can be encapsulated into avi or other file formats |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
27 - skip redundant/resent fragments (bit 0x20 set of first byte of frag) |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
28 |
6995
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
29 Revision 1.21 2002/08/14 09:15:31 arpi |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
30 RV20 A-V desync fixed - use timestamp hack only for RV30 |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
31 |
6982 | 32 Revision 1.20 2002/08/12 00:04:37 arpi |
33 RV40 support | |
34 | |
6916 | 35 Revision 1.19 2002/08/05 03:13:45 arpi |
36 fixed 'eof at 66s' bug | |
37 | |
6423 | 38 Revision 1.18 2002/06/14 00:49:56 arpi |
39 fixed playback speed and a-v sync issues | |
40 | |
6414
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
41 Revision 1.17 2002/06/13 13:31:45 arpi |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
42 fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net> |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
43 |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
44 Revision 1.16 2002/06/13 00:14:28 atmos4 |
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
45 Implement Nilmoni's and Bernd Ernesti's patches for: |
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
46 Better real codec dir detection and NetBSD real support. |
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
47 Fix Nilmonis code, so it's working like expected. |
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
48 Move a debug printf to mp_msg and some fixes in demux_real.c. |
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
49 Some cosmetics :) -> RealPlayer 8 to RealPlayer, as RealOne (aka RealPlayer 9 works, too) |
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
50 |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
51 Revision 1.15 2002/06/10 13:55:56 arpi |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
52 export subpacket-size and matrix w*h to the codec (cook) |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
53 |
6369 | 54 Revision 1.14 2002/06/10 02:27:31 arpi |
55 export extra data for cook codec, some debug stuff | |
56 | |
6344 | 57 Revision 1.13 2002/06/09 01:07:22 arpi |
58 - multiple audio/video stream support fixed | |
59 - aid/vid autodetection (asf style - use id of first packet received) | |
60 - rv20 sub-packets support | |
61 - exporting codec id and sub-id to the codec, in bitmapinfoheader | |
62 | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
63 Revision 1.12 2002/06/08 20:46:14 arpi |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
64 sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net> |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
65 (little cleanup and fprintf->mp_msg by me) |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
66 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
67 Revision 1.11 2002/04/30 23:29:38 alex |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
68 completed real seeking - working very well with audio only files |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
69 |
5810 | 70 Revision 1.10 2002/04/24 15:36:06 albeu |
71 Added demuxer uninit | |
72 | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
73 Revision 1.9 2002/03/15 15:51:37 alex |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
74 added PRE-ALPHA seeking ability and index table generator (like avi's one) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
75 |
4328
2936f5445e0c
fixed num_of_packets and current_packet handling, bug found by Mike Melanson
alex
parents:
4235
diff
changeset
|
76 Revision 1.8 2002/01/23 19:41:01 alex |
2936f5445e0c
fixed num_of_packets and current_packet handling, bug found by Mike Melanson
alex
parents:
4235
diff
changeset
|
77 fixed num_of_packets and current_packet handling, bug found by Mike Melanson |
2936f5445e0c
fixed num_of_packets and current_packet handling, bug found by Mike Melanson
alex
parents:
4235
diff
changeset
|
78 |
4235 | 79 Revision 1.7 2002/01/18 11:02:52 alex |
80 fix dnet support | |
81 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
82 Revision 1.6 2002/01/04 19:32:58 alex |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
83 updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes) |
3788 | 84 |
3795 | 85 |
86 Audio codecs: (supported by RealPlayer8 for Linux) | |
4235 | 87 DNET - RealAudio 3.0, really it's AC3 in swapped-byteorder |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
88 SIPR - SiproLab's audio codec, ACELP decoder working with MPlayer, |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
89 needs fine-tuning too :) |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
90 ATRC - RealAudio 8 (ATRAC3) - www.minidisc.org/atrac3_article.pdf, |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
91 ACM decoder uploaded, needs some fine-tuning to work |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
92 -> RealAudio 8 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
93 COOK/COKR - Real Cooker -> RealAudio G2 |
3795 | 94 |
95 Video codecs: (supported by RealPlayer8 for Linux) | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
96 RV10 - H.263 based, working with libavcodec's decoder |
3795 | 97 RV20 |
98 RV30 | |
3788 | 99 */ |
100 | |
3777 | 101 #include <stdio.h> |
102 #include <stdlib.h> | |
103 #include <unistd.h> | |
104 | |
105 #include "config.h" | |
106 #include "mp_msg.h" | |
107 #include "help_mp.h" | |
108 | |
109 #include "stream.h" | |
110 #include "demuxer.h" | |
111 #include "stheader.h" | |
112 #include "bswap.h" | |
113 | |
6369 | 114 //#define mp_dbg(mod,lev, args... ) mp_msg_c((mod<<8)|lev, ## args ) |
115 | |
3777 | 116 #define MKTAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) |
117 | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
118 #define MAX_STREAMS 32 |
3777 | 119 |
120 typedef struct { | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
121 int timestamp; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
122 int offset; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
123 int packetno; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
124 int len; /* only filled by our index generator */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
125 int flags; /* only filled by our index generator */ |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
126 } real_index_table_t; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
127 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
128 typedef struct { |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
129 /* for seeking */ |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
130 int index_chunk_offset; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
131 real_index_table_t *index_table[MAX_STREAMS]; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
132 // int *index_table[MAX_STREAMS]; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
133 int index_table_size[MAX_STREAMS]; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
134 int data_chunk_offset; |
3777 | 135 int num_of_packets; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
136 int current_packet; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
137 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
138 int current_apacket; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
139 int current_vpacket; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
140 |
6423 | 141 // timestamp correction: |
142 int kf_pts; // timestamp of next video keyframe | |
143 int a_pts; // previous audio timestamp | |
144 float v_pts; // previous video timestamp | |
145 | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
146 /* stream id table */ |
3777 | 147 int last_a_stream; |
148 int a_streams[MAX_STREAMS]; | |
149 int last_v_stream; | |
150 int v_streams[MAX_STREAMS]; | |
151 } real_priv_t; | |
152 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
153 /* originally from FFmpeg */ |
3777 | 154 static void get_str(int isbyte, demuxer_t *demuxer, char *buf, int buf_size) |
155 { | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
156 int len; |
3777 | 157 |
158 if (isbyte) | |
159 len = stream_read_char(demuxer->stream); | |
160 else | |
161 len = stream_read_word(demuxer->stream); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
162 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
163 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
|
164 if (len > buf_size) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
165 stream_skip(demuxer->stream, len-buf_size); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
166 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
167 printf("read_str: %d bytes read\n", len); |
3777 | 168 } |
169 | |
170 static void skip_str(int isbyte, demuxer_t *demuxer) | |
171 { | |
172 int len; | |
173 | |
174 if (isbyte) | |
175 len = stream_read_char(demuxer->stream); | |
176 else | |
177 len = stream_read_word(demuxer->stream); | |
178 | |
179 stream_skip(demuxer->stream, len); | |
180 | |
181 printf("skip_str: %d bytes skipped\n", len); | |
182 } | |
183 | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
184 static void dump_index(demuxer_t *demuxer, int stream_id) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
185 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
186 real_priv_t *priv = demuxer->priv; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
187 real_index_table_t *index; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
188 int i, entries; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
189 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
190 if (!verbose) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
191 return; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
192 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
193 if (stream_id > MAX_STREAMS) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
194 return; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
195 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
196 index = priv->index_table[stream_id]; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
197 entries = priv->index_table_size[stream_id]; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
198 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
199 printf("Index table for stream %d\n", stream_id); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
200 for (i = 0; i < entries; i++) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
201 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
202 printf("packetno: %x pos: %x len: %x timestamp: %x flags: %x\n", |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
203 index[i].packetno, index[i].offset, index[i].len, index[i].timestamp, |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
204 index[i].flags); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
205 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
206 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
207 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
208 static int parse_index_chunk(demuxer_t *demuxer) |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
209 { |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
210 real_priv_t *priv = demuxer->priv; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
211 int origpos = stream_tell(demuxer->stream); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
212 int next_header_pos = priv->index_chunk_offset; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
213 int i, entries, stream_id; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
214 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
215 read_index: |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
216 stream_seek(demuxer->stream, next_header_pos); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
217 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
218 i = stream_read_dword_le(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
219 if ((i == -256) || (i != MKTAG('I', 'N', 'D', 'X'))) |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
220 { |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
221 printf("Something went wrong, no index chunk found on given address (%d)\n", |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
222 next_header_pos); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
223 goto end; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
224 } |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
225 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
226 printf("Reading index table from index chunk (%d)\n", |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
227 next_header_pos); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
228 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
229 i = stream_read_dword(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
230 printf("size: %d bytes\n", i); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
231 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
232 i = stream_read_word(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
233 if (i != 0) |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
234 printf("Hmm, index table with unknown version (%d), please report it to MPlayer developers!\n", i); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
235 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
236 entries = stream_read_dword(demuxer->stream); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
237 printf("entries: %d\n", entries); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
238 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
239 stream_id = stream_read_word(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
240 printf("stream_id: %d\n", stream_id); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
241 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
242 next_header_pos = stream_read_dword(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
243 printf("next_header_pos: %d\n", next_header_pos); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
244 if (entries <= 0) |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
245 { |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
246 if (next_header_pos) |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
247 goto read_index; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
248 i = entries; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
249 goto end; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
250 } |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
251 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
252 priv->index_table_size[stream_id] = entries; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
253 priv->index_table[stream_id] = malloc(priv->index_table_size[stream_id] * sizeof(real_index_table_t)); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
254 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
255 for (i = 0; i < entries; i++) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
256 { |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
257 stream_skip(demuxer->stream, 2); /* version */ |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
258 priv->index_table[stream_id][i].timestamp = stream_read_dword(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
259 priv->index_table[stream_id][i].offset = stream_read_dword(demuxer->stream); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
260 priv->index_table[stream_id][i].packetno = stream_read_dword(demuxer->stream); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
261 // printf("Index table: Stream#%d: entry: %d: pos: %d\n", |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
262 // stream_id, i, priv->index_table[stream_id][i].offset); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
263 } |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
264 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
265 dump_index(demuxer, stream_id); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
266 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
267 if (next_header_pos > 0) |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
268 goto read_index; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
269 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
270 end: |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
271 demuxer->seekable = 1; /* got index, we're able to seek */ |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
272 if (i == -256) |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
273 stream_reset(demuxer->stream); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
274 stream_seek(demuxer->stream, origpos); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
275 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
276 return 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
277 else |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
278 return 1; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
279 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
280 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
281 static int generate_index(demuxer_t *demuxer) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
282 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
283 real_priv_t *priv = demuxer->priv; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
284 int origpos = stream_tell(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
285 int data_pos = priv->data_chunk_offset-10; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
286 int num_of_packets = 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
287 int i, entries = 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
288 int len, stream_id = 0, timestamp, flags; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
289 int tab_pos = 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
290 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
291 read_index: |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
292 stream_seek(demuxer->stream, data_pos); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
293 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
294 i = stream_read_dword_le(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
295 if ((i == -256) || (i != MKTAG('D', 'A', 'T', 'A'))) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
296 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
297 printf("Something went wrong, no data chunk found on given address (%d)\n", |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
298 data_pos); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
299 goto end; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
300 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
301 stream_skip(demuxer->stream, 4); /* chunk size */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
302 stream_skip(demuxer->stream, 2); /* version */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
303 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
304 num_of_packets = stream_read_dword(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
305 printf("Generating index table from raw data (pos: 0x%x) for %d packets\n", |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
306 data_pos, num_of_packets); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
307 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
308 data_pos = stream_read_dword_le(demuxer->stream)-10; /* next data chunk */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
309 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
310 for (i = 0; i < MAX_STREAMS; i++) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
311 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
312 priv->index_table_size[i] = num_of_packets; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
313 priv->index_table[i] = malloc(priv->index_table_size[i] * sizeof(real_index_table_t)); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
314 // priv->index_table[stream_id] = realloc(priv->index_table[stream_id], |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
315 // priv->index_table_size[stream_id] * sizeof(real_index_table_t)); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
316 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
317 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
318 tab_pos = 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
319 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
320 // memset(priv->index_table_size, 0, sizeof(int)*MAX_STREAMS); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
321 // memset(priv->index_table, 0, sizeof(real_index_table_t)*MAX_STREAMS); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
322 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
323 while (tab_pos < num_of_packets) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
324 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
325 i = stream_read_char(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
326 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
327 goto end; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
328 stream_skip(demuxer->stream, 1); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
329 // stream_skip(demuxer->stream, 2); /* version */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
330 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
331 len = stream_read_word(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
332 stream_id = stream_read_word(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
333 timestamp = stream_read_dword(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
334 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
335 stream_skip(demuxer->stream, 1); /* reserved */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
336 flags = stream_read_char(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
337 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
338 i = tab_pos; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
339 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
340 // priv->index_table_size[stream_id] = i; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
341 // if (priv->index_table[stream_id] == NULL) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
342 // priv->index_table[stream_id] = malloc(priv->index_table_size[stream_id] * sizeof(real_index_table_t)); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
343 // else |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
344 // priv->index_table[stream_id] = realloc(priv->index_table[stream_id], |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
345 // priv->index_table_size[stream_id] * sizeof(real_index_table_t)); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
346 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
347 priv->index_table[stream_id][i].timestamp = timestamp; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
348 priv->index_table[stream_id][i].offset = stream_tell(demuxer->stream)-12; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
349 priv->index_table[stream_id][i].len = len; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
350 priv->index_table[stream_id][i].packetno = entries; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
351 priv->index_table[stream_id][i].flags = flags; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
352 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
353 tab_pos++; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
354 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
355 /* skip data */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
356 stream_skip(demuxer->stream, len-12); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
357 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
358 dump_index(demuxer, stream_id); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
359 if (data_pos) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
360 goto read_index; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
361 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
362 end: |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
363 demuxer->seekable = 1; /* got index, we're able to seek */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
364 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
365 stream_reset(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
366 stream_seek(demuxer->stream, origpos); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
367 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
368 return 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
369 else |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
370 return 1; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
371 } |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
372 |
3795 | 373 int real_check_file(demuxer_t* demuxer) |
374 { | |
3777 | 375 real_priv_t *priv; |
376 int c; | |
377 | |
378 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for REAL\n"); | |
379 | |
380 c = stream_read_dword_le(demuxer->stream); | |
381 if (c == -256) | |
382 return 0; /* EOF */ | |
383 if (c != MKTAG('.', 'R', 'M', 'F')) | |
384 return 0; /* bad magic */ | |
385 | |
386 priv = malloc(sizeof(real_priv_t)); | |
387 memset(priv, 0, sizeof(real_priv_t)); | |
388 demuxer->priv = priv; | |
389 | |
390 return 1; | |
391 } | |
392 | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
393 void hexdump(char *, unsigned long); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
394 |
6995
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
395 static float real_fix_timestamp(real_priv_t* priv, unsigned char* s, int timestamp, float frametime, unsigned int format){ |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
396 float v_pts; |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
397 int kf=timestamp; |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
398 if(format==0x30335652){ // RV30 timestamps: |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
399 kf=2*(((s[1]&15)<<8)+s[2]); // 12-bit timestamp from frame header |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
400 //kf=((s[1]<<8)+s[2])>>3; // 12-bit timestamp from frame header |
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
401 printf("\nTS: %08X (%04X) %02X %02X %02X %02X\n",timestamp,kf,s[0],s[1],s[2],s[3]); |
6423 | 402 kf|=timestamp&(~0x1fff); // combine with packet timestamp |
403 if(kf<timestamp-4096) kf+=8192; else // workaround wrap-around problems | |
404 if(kf>timestamp+4096) kf-=8192; | |
405 if(!(s[0]&0x8) || !(s[0]&0x10)){ // P || I frame -> swap timestamps | |
406 int tmp=kf; | |
407 kf=priv->kf_pts; | |
408 priv->kf_pts=tmp; | |
409 // if(kf<=tmp) kf=0; | |
410 } | |
6995
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
411 } |
6423 | 412 v_pts=kf*0.001f; |
413 if(v_pts<priv->v_pts || !kf) v_pts=priv->v_pts+frametime; | |
414 priv->v_pts=v_pts; | |
415 // printf("\n#T# %5d/%5d (%5.3f) %5.3f \n",kf,timestamp,frametime,v_pts); | |
416 return v_pts; | |
417 } | |
418 | |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
419 typedef struct dp_hdr_s { |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
420 uint32_t chunks; // number of chunks |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
421 uint32_t timestamp; // timestamp from packet header |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
422 uint32_t len; // length of actual data |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
423 uint32_t chunktab; // offset to chunk offset array |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
424 } dp_hdr_t; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
425 |
3777 | 426 // return value: |
427 // 0 = EOF or no stream found | |
428 // 1 = successfully read a packet | |
429 int demux_real_fill_buffer(demuxer_t *demuxer) | |
430 { | |
431 real_priv_t *priv = demuxer->priv; | |
432 demux_stream_t *ds = NULL; | |
4235 | 433 sh_audio_t *sh_audio = NULL; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
434 sh_video_t *sh_video = NULL; |
3777 | 435 int len; |
436 int timestamp; | |
437 int stream_id; | |
438 int i; | |
3795 | 439 int flags; |
6916 | 440 int version; |
441 int reserved; | |
3777 | 442 |
443 loop: | |
4328
2936f5445e0c
fixed num_of_packets and current_packet handling, bug found by Mike Melanson
alex
parents:
4235
diff
changeset
|
444 /* also don't check if no num_of_packets was defined in header */ |
2936f5445e0c
fixed num_of_packets and current_packet handling, bug found by Mike Melanson
alex
parents:
4235
diff
changeset
|
445 if ((priv->current_packet > priv->num_of_packets) && |
6916 | 446 (priv->num_of_packets != -10)){ |
447 printf("num_of_packets reached!\n"); | |
3777 | 448 return 0; /* EOF */ |
6916 | 449 } |
450 demuxer->filepos = stream_tell(demuxer->stream); | |
451 version = stream_read_word(demuxer->stream); /* version */ | |
3777 | 452 len = stream_read_word(demuxer->stream); |
6916 | 453 |
454 if (len == -256){ /* EOF */ | |
455 printf("len==-256!\n"); | |
3777 | 456 return 0; |
6916 | 457 } |
3777 | 458 if (len < 12) |
459 { | |
6916 | 460 printf("%08X: packet v%d len=%d \n",(int)demuxer->filepos,(int)version,(int)len); |
3777 | 461 printf("bad packet len (%d)\n", len); |
462 stream_skip(demuxer->stream, len); | |
463 goto loop; | |
464 } | |
465 stream_id = stream_read_word(demuxer->stream); | |
466 timestamp = stream_read_dword(demuxer->stream); | |
467 | |
6916 | 468 reserved = stream_read_char(demuxer->stream); |
3795 | 469 flags = stream_read_char(demuxer->stream); |
470 /* flags: */ | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
471 /* 0x1 - reliable */ |
3795 | 472 /* 0x2 - keyframe */ |
473 | |
6916 | 474 // printf("%08X: packet v%d len=%4d id=%d pts=%6d rvd=%d flags=%d \n", |
475 // (int)demuxer->filepos,(int)version,(int)len, stream_id, | |
476 // (int) timestamp, reserved, flags); | |
477 | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
478 // debug re-enabled (FS) |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
479 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "len:%d\n", len); |
6916 | 480 mp_dbg(MSGT_DEMUX,MSGL_V, "\npacket#%d: pos: 0x%0x, len: %d, id: %d, pts: %d, flags: %x rvd:%d\n", |
481 priv->current_packet, (int)demuxer->filepos, len, stream_id, timestamp, flags, reserved); | |
3777 | 482 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
483 priv->current_packet++; |
3777 | 484 len -= 12; |
485 | |
6344 | 486 // printf("s_id=%d aid=%d vid=%d \n",stream_id,demuxer->audio->id,demuxer->video->id); |
487 | |
3777 | 488 /* check if stream_id is audio stream */ |
6344 | 489 if(demuxer->audio->id==-1 || demuxer->audio->id==stream_id) |
3777 | 490 for (i = 0; i < priv->last_a_stream; i++) |
491 { | |
492 if (priv->a_streams[i] == stream_id) | |
493 { | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
494 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "packet is audio (id: %d)\n", stream_id); |
3777 | 495 ds = demuxer->audio; /* FIXME */ |
4235 | 496 sh_audio = ds->sh; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
497 priv->current_apacket++; |
6344 | 498 demuxer->audio->id=stream_id; |
3777 | 499 break; |
500 } | |
501 } | |
502 /* check if stream_id is video stream */ | |
6344 | 503 if(demuxer->video->id==-1 || demuxer->video->id==stream_id) |
3777 | 504 for (i = 0; i < priv->last_v_stream; i++) |
505 { | |
506 if (priv->v_streams[i] == stream_id) | |
507 { | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
508 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "packet is video (id: %d)\n", stream_id); |
3777 | 509 ds = demuxer->video; /* FIXME */ |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
510 sh_video = ds->sh; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
511 priv->current_vpacket++; |
6344 | 512 demuxer->video->id=stream_id; |
3777 | 513 break; |
514 } | |
515 } | |
516 | |
517 /* id not found */ | |
518 if (ds == NULL) | |
519 { | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
520 mp_msg(MSGT_DEMUX,MSGL_DBG2, "unknown stream id (%d)\n", stream_id); |
3777 | 521 stream_skip(demuxer->stream, len); |
522 goto loop; | |
523 } | |
524 | |
4235 | 525 #if 0 |
3795 | 526 ds_read_packet(ds, demuxer->stream, len, timestamp/90000.0f, |
527 demuxer->filepos, (flags & 0x2) ? 0x10 : 0); | |
4235 | 528 #else |
529 { | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
530 demux_packet_t *dp=NULL; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
531 // = new_demux_packet(len); |
4235 | 532 |
533 /* if DNET, swap bytes! */ | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
534 if (sh_audio != NULL) { |
7105 | 535 #ifdef CRACK_MATRIX |
536 int spos=stream_tell(demuxer->stream); | |
537 static int cnt=0; | |
538 static int cnt2=CRACK_MATRIX; | |
539 #endif | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
540 dp = new_demux_packet(len); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
541 stream_read(demuxer->stream, dp->buffer, len); |
7105 | 542 #ifdef CRACK_MATRIX |
543 printf("*** audio block len=%d\n",len); | |
544 { // HACK - used for reverse engineering the descrambling matrix | |
545 FILE* f=fopen("test.rm","r+"); | |
546 fseek(f,spos,SEEK_SET); | |
547 ++cnt; | |
548 // for(i=0;i<len;i++) dp->buffer[i]=i/0x12; | |
549 // for(i=0;i<len;i++) dp->buffer[i]=i; | |
550 // for(i=0;i<len;i++) dp->buffer[i]=cnt; | |
551 // for(i=0;i<len;i++) dp->buffer[i]=cnt<<4; | |
552 for(i=0;i<len;i++) dp->buffer[i]=(i==cnt2) ? (cnt+16*(8+cnt)) : 0; | |
553 if(cnt==6){ cnt=0; ++cnt2; } | |
554 fwrite(dp->buffer, len, 1, f); | |
555 fclose(f); | |
556 if(cnt2>0x150) *((int*)NULL)=1; // sig11 :) | |
557 } | |
558 #endif | |
4235 | 559 if (sh_audio->format == 0x2000) |
560 { | |
561 char *ptr = dp->buffer; | |
562 | |
563 for (i = 0; i < len; i += 2) | |
564 { | |
565 const char tmp = ptr[0]; | |
566 ptr[0] = ptr[1]; | |
567 ptr[1] = tmp; | |
568 ptr += 2; | |
569 } | |
570 } | |
6423 | 571 dp->pts = (priv->a_pts==timestamp) ? 0 : (timestamp/1000.0f); |
572 priv->a_pts=timestamp; | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
573 dp->pos = demuxer->filepos; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
574 dp->flags = (flags & 0x2) ? 0x10 : 0; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
575 ds_add_packet(ds, dp); |
6369 | 576 } else |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
577 if (sh_video != NULL) { |
6982 | 578 if (sh_video->format==0x30345652 || |
579 sh_video->format==0x30335652 || | |
6344 | 580 sh_video->format==0x30325652 ) { |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
581 // we need a more complicated demuxing |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
582 // a block may contain multiple packets |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
583 // as well as a packet may be contained in multiple blocks |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7105
diff
changeset
|
584 int vpkg_header, vpkg_length, vpkg_offset; |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7105
diff
changeset
|
585 int vpkg_seqnum=-1; |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
586 int vpkg_subseq=0; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
587 |
6916 | 588 while(len>2){ |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
589 dp_hdr_t* dp_hdr; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
590 unsigned char* dp_data; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
591 uint32_t* extra; |
6916 | 592 |
593 // printf("xxx len=%d \n",len); | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
594 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
595 // read packet header |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
596 // bit 7: 1=last block in block chain |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
597 // bit 6: 1=short header (only one block?) |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
598 vpkg_header=stream_read_char(demuxer->stream); --len; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
599 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "hdr: %0.2X (len=%d) ",vpkg_header,len); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
600 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
601 if (0x40==(vpkg_header&0xc0)) { |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
602 // seems to be a very short header |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
603 // 2 bytes, purpose of the second byte yet unknown |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
604 int bummer; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
605 bummer=stream_read_char(demuxer->stream); --len; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
606 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "%0.2X",bummer); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
607 vpkg_offset=0; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
608 vpkg_length=len; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
609 } else { |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
610 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
611 if (0==(vpkg_header&0x40)) { |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
612 // sub-seqnum (bits 0-6: number of fragment. bit 7: ???) |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
613 vpkg_subseq=stream_read_char(demuxer->stream); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
614 --len; |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
615 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "subseq: %0.2X ",vpkg_subseq); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
616 vpkg_subseq&=0x7f; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
617 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
618 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
619 // size of the complete packet |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
620 // bit 14 is always one (same applies to the offset) |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
621 vpkg_length=stream_read_word(demuxer->stream); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
622 len-=2; |
6344 | 623 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "l: %0.2X %0.2X ",vpkg_length>>8,vpkg_length&0xff); |
6916 | 624 if (!(vpkg_length&0xC000)) { |
625 vpkg_length<<=16; | |
626 vpkg_length|=stream_read_word(demuxer->stream); | |
627 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "l+: %0.2X %0.2X ",(vpkg_length>>8)&0xff,vpkg_length&0xff); | |
6344 | 628 len-=2; |
629 } else | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
630 vpkg_length&=0x3fff; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
631 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
632 // offset of the following data inside the complete packet |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
633 // Note: if (hdr&0xC0)==0x80 then offset is relative to the |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
634 // _end_ of the packet, so it's equal to fragment size!!! |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
635 vpkg_offset=stream_read_word(demuxer->stream); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
636 len-=2; |
6344 | 637 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "o: %0.2X %0.2X ",vpkg_offset>>8,vpkg_offset&0xff); |
6916 | 638 if (!(vpkg_offset&0xC000)) { |
639 vpkg_offset<<=16; | |
640 vpkg_offset|=stream_read_word(demuxer->stream); | |
641 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "o+: %0.2X %0.2X ",(vpkg_offset>>8)&0xff,vpkg_offset&0xff); | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
642 len-=2; |
6344 | 643 } else |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
644 vpkg_offset&=0x3fff; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
645 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
646 vpkg_seqnum=stream_read_char(demuxer->stream); --len; |
6344 | 647 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "seq: %0.2X ",vpkg_seqnum); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
648 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
649 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "\n"); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
650 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "blklen=%d\n", len); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
651 mp_msg(MSGT_DEMUX,MSGL_DBG2, "block: hdr=0x%0x, len=%d, offset=%d, seqnum=%d\n", |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
652 vpkg_header, vpkg_length, vpkg_offset, vpkg_seqnum); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
653 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
654 if(ds->asf_packet){ |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
655 dp=ds->asf_packet; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
656 dp_hdr=(dp_hdr_t*)dp->buffer; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
657 dp_data=dp->buffer+sizeof(dp_hdr_t); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
658 extra=(uint32_t*)(dp->buffer+dp_hdr->chunktab); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
659 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "we have an incomplete packet (oldseq=%d new=%d)\n",ds->asf_seq,vpkg_seqnum); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
660 // we have an incomplete packet: |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
661 if(ds->asf_seq!=vpkg_seqnum){ |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
662 // this fragment is for new packet, close the old one |
6423 | 663 mp_msg(MSGT_DEMUX,MSGL_DBG2, "closing probably incomplete packet, len: %d \n",dp->len); |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
664 dp->pts=(dp_hdr->len<3)?0: |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
665 real_fix_timestamp(priv,dp_data,dp_hdr->timestamp,sh_video->frametime,sh_video->format); |
6423 | 666 ds_add_packet(ds,dp); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
667 ds->asf_packet=NULL; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
668 } else { |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
669 // append data to it! |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
670 ++dp_hdr->chunks; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
671 mp_msg(MSGT_DEMUX,MSGL_DBG2,"[chunks=%d subseq=%d]\n",dp_hdr->chunks,vpkg_subseq); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
672 if(dp_hdr->chunktab+8*(1+dp_hdr->chunks)>dp->len){ |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
673 // increase buffer size, this should not happen! |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
674 mp_msg(MSGT_DEMUX,MSGL_WARN, "chunktab buffer too small!!!!!\n"); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
675 dp->len=dp_hdr->chunktab+8*(4+dp_hdr->chunks); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
676 dp->buffer=realloc(dp->buffer,dp->len); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
677 // re-calc pointers: |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
678 dp_hdr=(dp_hdr_t*)dp->buffer; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
679 dp_data=dp->buffer+sizeof(dp_hdr_t); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
680 extra=(uint32_t*)(dp->buffer+dp_hdr->chunktab); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
681 } |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
682 extra[2*dp_hdr->chunks+0]=1; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
683 extra[2*dp_hdr->chunks+1]=dp_hdr->len; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
684 if(0x80==(vpkg_header&0xc0)){ |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
685 // last fragment! |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
686 if(dp_hdr->len!=vpkg_length-vpkg_offset) |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
687 mp_msg(MSGT_DEMUX,MSGL_V,"warning! assembled.len=%d frag.len=%d total.len=%d \n",dp->len,vpkg_offset,vpkg_length-vpkg_offset); |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
688 stream_read(demuxer->stream, dp_data+dp_hdr->len, vpkg_offset); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
689 if(dp_data[dp_hdr->len]&0x20) --dp_hdr->chunks; else |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
690 dp_hdr->len+=vpkg_offset; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
691 len-=vpkg_offset; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
692 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "fragment (%d bytes) appended, %d bytes left\n",vpkg_offset,len); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
693 // we know that this is the last fragment -> we can close the packet! |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
694 dp->pts=(dp_hdr->len<3)?0: |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
695 real_fix_timestamp(priv,dp_data,dp_hdr->timestamp,sh_video->frametime,sh_video->format); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
696 ds_add_packet(ds,dp); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
697 ds->asf_packet=NULL; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
698 // continue parsing |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
699 continue; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
700 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
701 // non-last fragment: |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
702 if(dp_hdr->len!=vpkg_offset) |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
703 mp_msg(MSGT_DEMUX,MSGL_V,"warning! assembled.len=%d offset=%d frag.len=%d total.len=%d \n",dp->len,vpkg_offset,len,vpkg_length); |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
704 stream_read(demuxer->stream, dp_data+dp_hdr->len, len); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
705 if(dp_data[dp_hdr->len]&0x20) --dp_hdr->chunks; else |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
706 dp_hdr->len+=len; |
6916 | 707 len=0; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
708 break; // no more fragments in this chunk! |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
709 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
710 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
711 // create new packet! |
7084 | 712 dp = new_demux_packet(sizeof(dp_hdr_t)+vpkg_length+8*(1+2*(vpkg_header&0x3F))); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
713 // the timestamp seems to be in milliseconds |
6423 | 714 dp->pts = 0; // timestamp/1000.0f; //timestamp=0; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
715 dp->pos = demuxer->filepos; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
716 dp->flags = (flags & 0x2) ? 0x10 : 0; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
717 ds->asf_seq = vpkg_seqnum; |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
718 dp_hdr=(dp_hdr_t*)dp->buffer; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
719 dp_hdr->chunks=0; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
720 dp_hdr->timestamp=timestamp; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
721 dp_hdr->chunktab=sizeof(dp_hdr_t)+vpkg_length; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
722 dp_data=dp->buffer+sizeof(dp_hdr_t); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
723 extra=(uint32_t*)(dp->buffer+dp_hdr->chunktab); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
724 extra[0]=1; extra[1]=0; // offset of the first chunk |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
725 if(0x00==(vpkg_header&0xc0)){ |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
726 // first fragment: |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
727 dp_hdr->len=len; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
728 stream_read(demuxer->stream, dp_data, len); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
729 ds->asf_packet=dp; |
6916 | 730 len=0; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
731 break; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
732 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
733 // whole packet (not fragmented): |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
734 dp_hdr->len=vpkg_length; len-=vpkg_length; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
735 stream_read(demuxer->stream, dp_data, vpkg_length); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
736 dp->pts=(dp_hdr->len<3)?0: |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
737 real_fix_timestamp(priv,dp_data,dp_hdr->timestamp,sh_video->frametime,sh_video->format); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
738 ds_add_packet(ds,dp); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
739 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
740 } // while(len>0) |
6916 | 741 |
742 if(len){ | |
743 printf("\n******** !!!!!!!! BUG!! len=%d !!!!!!!!!!! ********\n",len); | |
744 if(len>0) stream_skip(demuxer->stream, len); | |
745 } | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
746 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
747 } else { |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
748 // old video stream type |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
749 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
750 dp = new_demux_packet(len); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
751 stream_read(demuxer->stream, dp->buffer, len); |
6344 | 752 #if 0 |
753 { unsigned char* p=dp->buffer; | |
754 int i; | |
755 printf("\n#HDR# %04X",len); | |
756 for(i=0;i<20;i++) printf(" %02X",p[i]); | |
757 printf("\n"); | |
758 if((p[0]&0x80)) printf("#HDR#\n"); | |
759 } | |
760 #endif | |
761 | |
762 dp->pts = timestamp/1000.0f; | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
763 dp->pos = demuxer->filepos; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
764 dp->flags = (flags & 0x2) ? 0x10 : 0; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
765 ds_add_packet(ds, dp); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
766 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
767 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
768 } |
4235 | 769 } |
770 #endif | |
3777 | 771 |
772 return 1; | |
773 } | |
774 | |
775 void demux_open_real(demuxer_t* demuxer) | |
776 { | |
777 real_priv_t* priv = demuxer->priv; | |
778 int num_of_headers; | |
779 int i; | |
780 | |
781 stream_skip(demuxer->stream, 4); /* header size */ | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
782 stream_skip(demuxer->stream, 2); /* version */ |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
783 // stream_skip(demuxer->stream, 4); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
784 i = stream_read_dword(demuxer->stream); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
785 mp_msg(MSGT_DEMUX,MSGL_V, "real: File version: %d\n", i); |
3777 | 786 num_of_headers = stream_read_dword(demuxer->stream); |
787 // stream_skip(demuxer->stream, 4); /* number of headers */ | |
788 | |
789 /* parse chunks */ | |
790 for (i = 1; i < num_of_headers; i++) | |
791 { | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
792 int chunk_id, chunk_pos, chunk_size; |
3777 | 793 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
794 chunk_pos = stream_tell(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
795 chunk_id = stream_read_dword_le(demuxer->stream); |
3777 | 796 chunk_size = stream_read_dword(demuxer->stream); |
797 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
798 stream_skip(demuxer->stream, 2); /* version */ |
3777 | 799 |
800 if (chunk_size < 10) | |
801 goto fail; | |
802 | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
803 mp_msg(MSGT_DEMUX,MSGL_V, "Chunk: %.4s (%x) (size: 0x%x, offset: 0x%x)\n", |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
804 (char *)&chunk_id, chunk_id, chunk_size, chunk_pos); |
3777 | 805 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
806 switch(chunk_id) |
3777 | 807 { |
808 case MKTAG('P', 'R', 'O', 'P'): | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
809 /* Properties header */ |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
810 |
3777 | 811 stream_skip(demuxer->stream, 4); /* max bitrate */ |
812 stream_skip(demuxer->stream, 4); /* avg bitrate */ | |
813 stream_skip(demuxer->stream, 4); /* max packet size */ | |
814 stream_skip(demuxer->stream, 4); /* avg packet size */ | |
815 stream_skip(demuxer->stream, 4); /* nb packets */ | |
816 stream_skip(demuxer->stream, 4); /* duration */ | |
817 stream_skip(demuxer->stream, 4); /* preroll */ | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
818 priv->index_chunk_offset = stream_read_dword(demuxer->stream); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
819 mp_msg(MSGT_DEMUX,MSGL_V,"First index chunk offset: 0x%x\n", priv->index_chunk_offset); |
3795 | 820 priv->data_chunk_offset = stream_read_dword(demuxer->stream)+10; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
821 mp_msg(MSGT_DEMUX,MSGL_V,"First data chunk offset: 0x%x\n", priv->data_chunk_offset); |
3777 | 822 stream_skip(demuxer->stream, 2); /* nb streams */ |
3795 | 823 #if 0 |
3777 | 824 stream_skip(demuxer->stream, 2); /* flags */ |
3795 | 825 #else |
826 { | |
827 int flags = stream_read_word(demuxer->stream); | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
828 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
829 if (flags) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
830 { |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
831 mp_msg(MSGT_DEMUX,MSGL_V,"Flags (%x): ", flags); |
3795 | 832 if (flags & 0x1) |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
833 mp_msg(MSGT_DEMUX,MSGL_V,"[save allowed] "); |
3795 | 834 if (flags & 0x2) |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
835 mp_msg(MSGT_DEMUX,MSGL_V,"[perfect play (more buffers)] "); |
3795 | 836 if (flags & 0x4) |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
837 mp_msg(MSGT_DEMUX,MSGL_V,"[live broadcast] "); |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
838 mp_msg(MSGT_DEMUX,MSGL_V,"\n"); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
839 } |
3795 | 840 } |
841 #endif | |
3777 | 842 break; |
843 case MKTAG('C', 'O', 'N', 'T'): | |
3788 | 844 { |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
845 /* Content description header */ |
3788 | 846 char *buf; |
847 int len; | |
848 | |
849 len = stream_read_word(demuxer->stream); | |
850 if (len > 0) | |
851 { | |
852 buf = malloc(len+1); | |
853 stream_read(demuxer->stream, buf, len); | |
5810 | 854 buf[len] = 0; |
3788 | 855 demux_info_add(demuxer, "name", buf); |
856 free(buf); | |
857 } | |
858 | |
859 len = stream_read_word(demuxer->stream); | |
860 if (len > 0) | |
861 { | |
862 buf = malloc(len+1); | |
863 stream_read(demuxer->stream, buf, len); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
864 buf[len] = 0; |
3788 | 865 demux_info_add(demuxer, "author", buf); |
866 free(buf); | |
867 } | |
868 | |
869 len = stream_read_word(demuxer->stream); | |
870 if (len > 0) | |
871 { | |
872 buf = malloc(len+1); | |
873 stream_read(demuxer->stream, buf, len); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
874 buf[len] = 0; |
3788 | 875 demux_info_add(demuxer, "copyright", buf); |
876 free(buf); | |
877 } | |
878 | |
879 len = stream_read_word(demuxer->stream); | |
880 if (len > 0) | |
881 { | |
882 buf = malloc(len+1); | |
883 stream_read(demuxer->stream, buf, len); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
884 buf[len] = 0; |
3788 | 885 demux_info_add(demuxer, "comment", buf); |
886 free(buf); | |
887 } | |
3777 | 888 break; |
3788 | 889 } |
3777 | 890 case MKTAG('M', 'D', 'P', 'R'): |
891 { | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
892 /* Media properties header */ |
3777 | 893 int stream_id; |
894 int bitrate; | |
895 int codec_data_size; | |
896 int codec_pos; | |
3795 | 897 int tmp; |
3777 | 898 |
899 stream_id = stream_read_word(demuxer->stream); | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
900 mp_msg(MSGT_DEMUX,MSGL_V,"Found new stream (id: %d)\n", stream_id); |
3777 | 901 |
902 stream_skip(demuxer->stream, 4); /* max bitrate */ | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
903 bitrate = stream_read_dword(demuxer->stream); /* avg bitrate */ |
3777 | 904 stream_skip(demuxer->stream, 4); /* max packet size */ |
905 stream_skip(demuxer->stream, 4); /* avg packet size */ | |
906 stream_skip(demuxer->stream, 4); /* start time */ | |
907 stream_skip(demuxer->stream, 4); /* preroll */ | |
908 stream_skip(demuxer->stream, 4); /* duration */ | |
909 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
910 skip_str(1, demuxer); /* stream description (name) */ |
3777 | 911 skip_str(1, demuxer); /* mimetype */ |
912 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
913 /* Type specific header */ |
3777 | 914 codec_data_size = stream_read_dword(demuxer->stream); |
915 codec_pos = stream_tell(demuxer->stream); | |
916 | |
3795 | 917 tmp = stream_read_dword(demuxer->stream); |
7085
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
918 |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
919 mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_real: type_spec: len=%d fpos=0x%X first_dword=0x%X (%.4s) \n", |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
920 (int)codec_data_size,(int)codec_pos,tmp,&tmp); |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
921 |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
922 #if 1 |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
923 // skip unknown shit - FIXME: find a better/cleaner way! |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
924 { int len=codec_data_size; |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
925 while(--len>=8){ |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
926 if(tmp==MKTAG(0xfd, 'a', 'r', '.')) break; // audio |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
927 if(tmp==MKTAG('O', 'D', 'I', 'V')) break; // video |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
928 tmp=(tmp<<8)|stream_read_char(demuxer->stream); |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
929 } |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
930 } |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
931 #endif |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
932 |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
933 #define stream_skip(st,siz) { int i; for(i=0;i<siz;i++) mp_msg(MSGT_DEMUX,MSGL_V," %02X",stream_read_char(st)); mp_msg(MSGT_DEMUX,MSGL_V,"\n");} |
7085
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
934 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
935 if (tmp == MKTAG(0xfd, 'a', 'r', '.')) |
3777 | 936 { |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
937 /* audio header */ |
3777 | 938 sh_audio_t *sh = new_sh_audio(demuxer, stream_id); |
3795 | 939 char buf[128]; /* for codec name */ |
940 int frame_size; | |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
941 int sub_packet_size; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
942 int sub_packet_h; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
943 int version; |
6369 | 944 int flavor; |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
945 |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
946 mp_msg(MSGT_DEMUX,MSGL_V,"Found audio stream!\n"); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
947 version = stream_read_word(demuxer->stream); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
948 mp_msg(MSGT_DEMUX,MSGL_V,"version: %d\n", version); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
949 // stream_skip(demuxer->stream, 2); /* version (4 or 5) */ |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
950 stream_skip(demuxer->stream, 2); // 00 00 |
3788 | 951 stream_skip(demuxer->stream, 4); /* .ra4 or .ra5 */ |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
952 stream_skip(demuxer->stream, 4); // ??? |
3788 | 953 stream_skip(demuxer->stream, 2); /* version (4 or 5) */ |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
954 stream_skip(demuxer->stream, 4); // header size == 0x4E |
6369 | 955 flavor = stream_read_word(demuxer->stream);/* codec flavor id */ |
3777 | 956 stream_skip(demuxer->stream, 4); /* coded frame size */ |
6369 | 957 stream_skip(demuxer->stream, 4); // big number |
958 stream_skip(demuxer->stream, 4); // bigger number | |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
959 stream_skip(demuxer->stream, 4); // 2 || -''- |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
960 // stream_skip(demuxer->stream, 2); // 0x10 |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
961 sub_packet_h = stream_read_word(demuxer->stream); |
3795 | 962 // stream_skip(demuxer->stream, 2); /* coded frame size */ |
963 frame_size = stream_read_word(demuxer->stream); | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
964 mp_msg(MSGT_DEMUX,MSGL_V,"frame_size: %d\n", frame_size); |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
965 sub_packet_size = stream_read_word(demuxer->stream); |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
966 mp_msg(MSGT_DEMUX,MSGL_V,"sub_packet_size: %d\n", sub_packet_size); |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
967 stream_skip(demuxer->stream, 2); // 0 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
968 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
969 if (version == 5) |
6369 | 970 stream_skip(demuxer->stream, 6); //0,srate,0 |
3777 | 971 |
972 sh->samplerate = stream_read_word(demuxer->stream); | |
6369 | 973 stream_skip(demuxer->stream, 2); // 0 |
974 sh->samplesize = stream_read_word(demuxer->stream)/8; | |
3777 | 975 sh->channels = stream_read_word(demuxer->stream); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
976 mp_msg(MSGT_DEMUX,MSGL_V,"samplerate: %d, channels: %d\n", |
3877 | 977 sh->samplerate, sh->channels); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
978 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
979 if (version == 5) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
980 { |
6369 | 981 stream_skip(demuxer->stream, 4); // "genr" |
982 stream_read(demuxer->stream, buf, 4); // fourcc | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
983 buf[4] = 0; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
984 } |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
985 else |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
986 { |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
987 /* Desc #1 */ |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
988 skip_str(1, demuxer); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
989 /* Desc #2 */ |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
990 get_str(1, demuxer, buf, sizeof(buf)); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
991 } |
3777 | 992 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
993 /* Emulate WAVEFORMATEX struct: */ |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
994 sh->wf = malloc(sizeof(WAVEFORMATEX)); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
995 memset(sh->wf, 0, sizeof(WAVEFORMATEX)); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
996 sh->wf->nChannels = sh->channels; |
6369 | 997 sh->wf->wBitsPerSample = sh->samplesize*8; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
998 sh->wf->nSamplesPerSec = sh->samplerate; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
999 sh->wf->nAvgBytesPerSec = bitrate; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1000 sh->wf->nBlockAlign = frame_size; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1001 sh->wf->cbSize = 0; |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1002 sh->format = MKTAG(buf[0], buf[1], buf[2], buf[3]); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1003 |
3795 | 1004 tmp = 1; /* supported audio codec */ |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1005 switch (sh->format) |
3795 | 1006 { |
1007 case MKTAG('d', 'n', 'e', 't'): | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1008 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: DNET -> AC3\n"); |
3795 | 1009 sh->format = 0x2000; |
1010 break; | |
1011 case MKTAG('s', 'i', 'p', 'r'): | |
7105 | 1012 #if 0 |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1013 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: SiproLab's ACELP.net\n"); |
3788 | 1014 sh->format = 0x130; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1015 /* for buggy directshow loader */ |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1016 sh->wf->cbSize = 4; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1017 sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX)+sh->wf->cbSize); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1018 sh->wf->wBitsPerSample = 0; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1019 sh->wf->nAvgBytesPerSec = 1055; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1020 sh->wf->nBlockAlign = 19; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1021 // sh->wf->nBlockAlign = frame_size / 288; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1022 buf[0] = 30; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1023 buf[1] = 1; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1024 buf[2] = 1; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1025 buf[3] = 0; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1026 memcpy((sh->wf+18), (char *)&buf[0], 4); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1027 // sh->wf[sizeof(WAVEFORMATEX)+1] = 30; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1028 // sh->wf[sizeof(WAVEFORMATEX)+2] = 1; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1029 // sh->wf[sizeof(WAVEFORMATEX)+3] = 1; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1030 // sh->wf[sizeof(WAVEFORMATEX)+4] = 0; |
3795 | 1031 break; |
7105 | 1032 #endif |
3795 | 1033 case MKTAG('c', 'o', 'o', 'k'): |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1034 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: Real's GeneralCooker (?) (RealAudio G2?) (unsupported)\n"); |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1035 sh->wf->cbSize = 4+2+24; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1036 sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX)+sh->wf->cbSize); |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1037 ((short*)(sh->wf+1))[0]=sub_packet_size; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1038 ((short*)(sh->wf+1))[1]=sub_packet_h; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1039 ((short*)(sh->wf+1))[2]=flavor; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1040 stream_read(demuxer->stream, ((char*)(sh->wf+1))+6, 24); // extras |
3795 | 1041 break; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1042 case MKTAG('a', 't', 'r', 'c'): |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1043 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: Sony ATRAC3 (RealAudio 8) (unsupported)\n"); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1044 sh->format = 0x270; |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1045 /* 14 bytes extra header needed ! */ |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1046 sh->wf->cbSize = 14; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1047 sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX)+sh->wf->cbSize); |
4235 | 1048 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1049 sh->wf->nAvgBytesPerSec = 16537; // 8268 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1050 sh->wf->nBlockAlign = 384; // 192 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1051 sh->wf->wBitsPerSample = 0; /* from AVI created by VirtualDub */ |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1052 break; |
3795 | 1053 default: |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1054 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: Unknown (%s)\n", buf); |
3795 | 1055 tmp = 0; |
3777 | 1056 } |
1057 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1058 sh->wf->wFormatTag = sh->format; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1059 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1060 print_wave_header(sh->wf); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1061 |
3795 | 1062 if (tmp) |
3777 | 1063 { |
3795 | 1064 /* insert as stream */ |
1065 demuxer->audio->sh = sh; | |
1066 sh->ds = demuxer->audio; | |
6344 | 1067 // demuxer->audio->id = -1;//stream_id; |
3788 | 1068 |
3795 | 1069 if (priv->last_a_stream+1 < MAX_STREAMS) |
1070 { | |
1071 priv->a_streams[priv->last_a_stream] = stream_id; | |
1072 priv->last_a_stream++; | |
1073 } | |
6344 | 1074 // priv->current_aid = stream_id; |
3777 | 1075 } |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1076 else |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1077 free(sh->wf); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1078 // break; |
6369 | 1079 |
1080 #undef stream_skip | |
1081 | |
3777 | 1082 } |
1083 else | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1084 // case MKTAG('V', 'I', 'D', 'O'): |
7085
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
1085 if(tmp == MKTAG('O', 'D', 'I', 'V')) |
3777 | 1086 { |
1087 /* video header */ | |
1088 sh_video_t *sh = new_sh_video(demuxer, stream_id); | |
1089 | |
1090 sh->format = stream_read_dword_le(demuxer->stream); /* fourcc */ | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1091 mp_msg(MSGT_DEMUX,MSGL_V,"video fourcc: %.4s (%x)\n", (char *)&sh->format, sh->format); |
3777 | 1092 |
3795 | 1093 /* emulate BITMAPINFOHEADER */ |
6344 | 1094 sh->bih = malloc(sizeof(BITMAPINFOHEADER)+8); |
1095 memset(sh->bih, 0, sizeof(BITMAPINFOHEADER)+8); | |
1096 sh->bih->biSize = 48; | |
3777 | 1097 sh->disp_w = sh->bih->biWidth = stream_read_word(demuxer->stream); |
1098 sh->disp_h = sh->bih->biHeight = stream_read_word(demuxer->stream); | |
1099 sh->bih->biPlanes = 1; | |
1100 sh->bih->biBitCount = 24; | |
1101 sh->bih->biCompression = sh->format; | |
1102 sh->bih->biSizeImage= sh->bih->biWidth*sh->bih->biHeight*3; | |
1103 | |
1104 sh->fps = stream_read_word(demuxer->stream); | |
1105 sh->frametime = 1.0f/sh->fps; | |
1106 | |
6344 | 1107 #if 1 |
6414
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1108 stream_skip(demuxer->stream, 4); |
6344 | 1109 #else |
1110 printf("unknown1: 0x%X \n",stream_read_dword(demuxer->stream)); | |
1111 printf("unknown2: 0x%X \n",stream_read_word(demuxer->stream)); | |
1112 printf("unknown3: 0x%X \n",stream_read_word(demuxer->stream)); | |
1113 #endif | |
6414
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1114 if (sh->format==0x30335652 || |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1115 sh->format==0x30325652 ) { |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1116 sh->fps = stream_read_word(demuxer->stream); |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1117 sh->frametime = 1.0f/sh->fps; |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1118 } else { |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1119 stream_skip(demuxer->stream, 2); |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1120 } |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1121 stream_skip(demuxer->stream, 2); |
6344 | 1122 |
1123 // read codec sub-format (to make difference between low and high rate codec) | |
1124 ((unsigned int*)(sh->bih+1))[0]=stream_read_dword(demuxer->stream); | |
3777 | 1125 |
1126 /* h263 hack */ | |
3795 | 1127 tmp = stream_read_dword(demuxer->stream); |
6344 | 1128 ((unsigned int*)(sh->bih+1))[1]=tmp; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1129 mp_msg(MSGT_DEMUX,MSGL_V,"H.263 ID: %x\n", tmp); |
3795 | 1130 switch (tmp) |
3777 | 1131 { |
1132 case 0x10000000: | |
1133 /* sub id: 0 */ | |
1134 /* codec id: rv10 */ | |
1135 break; | |
1136 case 0x10003000: | |
1137 case 0x10003001: | |
1138 /* sub id: 3 */ | |
1139 /* codec id: rv10 */ | |
3877 | 1140 sh->bih->biCompression = sh->format = mmioFOURCC('R', 'V', '1', '3'); |
3777 | 1141 break; |
1142 case 0x20001000: | |
3788 | 1143 case 0x20100001: |
7084 | 1144 case 0x20200002: |
3777 | 1145 /* codec id: rv20 */ |
1146 break; | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1147 case 0x30202002: |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1148 /* codec id: rv30 */ |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1149 break; |
6982 | 1150 case 0x40000000: |
1151 /* codec id: rv40 */ | |
1152 break; | |
3777 | 1153 default: |
1154 /* codec id: none */ | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1155 mp_msg(MSGT_DEMUX,MSGL_V,"unknown id: %x\n", tmp); |
3777 | 1156 } |
1157 | |
1158 /* insert as stream */ | |
1159 demuxer->video->sh = sh; | |
1160 sh->ds = demuxer->video; | |
6344 | 1161 // demuxer->video->id = -1; //stream_id; |
3777 | 1162 if (priv->last_v_stream+1 < MAX_STREAMS) |
1163 { | |
1164 priv->v_streams[priv->last_v_stream] = stream_id; | |
1165 priv->last_v_stream++; | |
1166 } | |
6344 | 1167 // priv->current_vid = stream_id; |
3777 | 1168 } |
7085
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
1169 else { |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
1170 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not audio/video stream or unsupported!\n"); |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
1171 } |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1172 // break; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1173 // default: |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7105
diff
changeset
|
1174 //skip_this_chunk: |
3777 | 1175 /* skip codec info */ |
3795 | 1176 tmp = stream_tell(demuxer->stream) - codec_pos; |
6344 | 1177 mp_msg(MSGT_DEMUX,MSGL_V,"### skipping %d bytes of codec info\n", codec_data_size - tmp); |
1178 #if 0 | |
1179 { int i; | |
1180 for(i=0;i<codec_data_size - tmp;i++) | |
1181 printf(" %02X",stream_read_char(demuxer->stream)); | |
1182 printf("\n"); | |
1183 } | |
1184 #else | |
3795 | 1185 stream_skip(demuxer->stream, codec_data_size - tmp); |
6344 | 1186 #endif |
3777 | 1187 break; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1188 // } |
3777 | 1189 } |
1190 case MKTAG('D', 'A', 'T', 'A'): | |
1191 goto header_end; | |
3795 | 1192 case MKTAG('I', 'N', 'D', 'X'): |
3777 | 1193 default: |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1194 mp_msg(MSGT_DEMUX,MSGL_V,"Unknown chunk: %x\n", chunk_id); |
3777 | 1195 stream_skip(demuxer->stream, chunk_size - 10); |
1196 break; | |
1197 } | |
1198 } | |
1199 | |
1200 header_end: | |
1201 priv->num_of_packets = stream_read_dword(demuxer->stream); | |
1202 // stream_skip(demuxer->stream, 4); /* number of packets */ | |
1203 stream_skip(demuxer->stream, 4); /* next data header */ | |
1204 | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1205 mp_msg(MSGT_DEMUX,MSGL_V,"Packets in file: %d\n", priv->num_of_packets); |
3777 | 1206 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1207 if (priv->num_of_packets == 0) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1208 priv->num_of_packets = -10; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1209 |
3777 | 1210 /* disable seeking */ |
1211 demuxer->seekable = 0; | |
1212 | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1213 if (index_mode == 2) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1214 generate_index(demuxer); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1215 else if (priv->index_chunk_offset && ((index_mode == 1) || (index_mode == 2))) |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1216 parse_index_chunk(demuxer); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1217 |
3777 | 1218 fail: |
1219 return; | |
1220 } | |
1221 | |
1222 void demux_close_real(demuxer_t *demuxer) | |
1223 { | |
1224 real_priv_t* priv = demuxer->priv; | |
1225 | |
1226 if (priv) | |
1227 free(priv); | |
1228 | |
1229 return; | |
1230 } | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1231 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1232 /* please upload RV10 samples WITH INDEX CHUNK */ |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1233 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
|
1234 { |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1235 real_priv_t *priv = demuxer->priv; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1236 demux_stream_t *d_audio = demuxer->audio; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1237 demux_stream_t *d_video = demuxer->video; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1238 sh_audio_t *sh_audio = d_audio->sh; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1239 sh_video_t *sh_video = d_video->sh; |
6344 | 1240 int vid = d_video->id, aid = d_audio->id; |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
1241 int next_offset = 0; |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1242 int rel_seek_frames = 0; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1243 int streams = 0; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1244 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1245 if ((index_mode != 1) && (index_mode != 2)) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1246 return 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1247 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1248 if (sh_video) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1249 streams |= 1; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1250 if (sh_audio) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1251 streams |= 2; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1252 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1253 // printf("streams: %d\n", streams); |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1254 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1255 if (!streams) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1256 return 0; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1257 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1258 if (flags & 1) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1259 /* seek absolute */ |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1260 priv->current_apacket = priv->current_vpacket = 0; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1261 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1262 /* flags & 2 ? */ |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1263 if (streams & 1) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1264 rel_seek_frames = (int)(sh_video->fps*rel_seek_secs); |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1265 else if (streams & 2) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1266 rel_seek_frames = (int)(rel_seek_secs); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1267 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1268 // printf("rel_seek_frames: %d\n", rel_seek_frames); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1269 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1270 if (streams & 2) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1271 priv->current_apacket += rel_seek_frames; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1272 if (streams & 1) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1273 priv->current_vpacket += rel_seek_frames; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1274 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1275 if ( |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1276 ((streams & 2) && (priv->current_apacket > priv->index_table_size[aid])) || |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1277 ((streams & 1) && (priv->current_vpacket > priv->index_table_size[vid])) ) |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1278 return 0; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1279 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1280 /* both video and audio stream */ |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1281 if (streams == 3) |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1282 { |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1283 // if (priv->current_apacket > priv->current_vpacket) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1284 // { |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1285 /* search keyframe */ |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1286 while (!(priv->index_table[vid][priv->current_vpacket].flags & 0x2)) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1287 priv->current_vpacket++; |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1288 next_offset = priv->index_table[vid][priv->current_vpacket].offset; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1289 // } |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1290 // else |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1291 // { |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1292 // next_offset = priv->index_table[aid][priv->current_apacket].offset; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1293 // } |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1294 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1295 else |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1296 { |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1297 if (streams & 1) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1298 { |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1299 /* search keyframe */ |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1300 while (!(priv->index_table[vid][priv->current_vpacket].flags & 0x2)) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1301 priv->current_vpacket++; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1302 next_offset = priv->index_table[vid][priv->current_vpacket].offset; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1303 } |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1304 else if (streams & 2) |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1305 { |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1306 next_offset = priv->index_table[aid][priv->current_apacket].offset; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1307 } |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1308 } |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1309 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1310 // printf("seek: pos: %d, current packets: a: %d, v: %d\n", |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1311 // next_offset, priv->current_apacket, priv->current_vpacket); |
6404
83b3315c679b
Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents:
6374
diff
changeset
|
1312 return stream_seek(demuxer->stream, next_offset); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1313 } |