Mercurial > mplayer.hg
annotate libmpdemux/demux_real.c @ 32418:71a04d45357c
Make af_reinit "public", to allow using it in future patches.
author | reimar |
---|---|
date | Sun, 17 Oct 2010 15:52:18 +0000 |
parents | 1fb9fff0eb39 |
children | 8fa2f43cb760 |
rev | line source |
---|---|
3777 | 1 /* |
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
2 * Real parser & demuxer |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
3 * copyright (C) 2001 Alex Beregszaszi |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
4 * copyright (C) 2005, 2006 Roberto Togni |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
5 * based on FFmpeg's libav/rm.c |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
6 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
7 * audio codecs: (supported by RealPlayer8 for Linux) |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
8 * DNET - RealAudio 3.0, really it's AC3 in swapped-byteorder |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
9 * SIPR - SiproLab's audio codec, ACELP decoder working with MPlayer, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
10 * needs fine-tuning too :) |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
11 * ATRC - RealAudio 8 (ATRAC3) - www.minidisc.org/atrac3_article.pdf, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
12 * ACM decoder uploaded, needs some fine-tuning to work |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
13 * -> RealAudio 8 |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
14 * COOK/COKR - Real Cooker -> RealAudio G2 |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
15 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
16 * video codecs: (supported by RealPlayer8 for Linux) |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
17 * RV10 - H.263 based, working with libavcodec's decoder |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
18 * RV20-RV40 - using RealPlayer's codec plugins |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
19 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
20 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
21 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
22 * MPlayer is free software; you can redistribute it and/or modify |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
23 * it under the terms of the GNU General Public License as published by |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
24 * the Free Software Foundation; either version 2 of the License, or |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
25 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
26 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
27 * MPlayer is distributed in the hope that it will be useful, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
30 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
31 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
32 * You should have received a copy of the GNU General Public License along |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
33 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
34 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
28630
diff
changeset
|
35 */ |
3788 | 36 |
3777 | 37 #include <stdio.h> |
38 #include <stdlib.h> | |
39 #include <unistd.h> | |
23632 | 40 #include <inttypes.h> |
3777 | 41 |
42 #include "config.h" | |
43 #include "mp_msg.h" | |
44 #include "help_mp.h" | |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
45 #include "mpbswap.h" |
31465
65a4a8ddb552
Remove duplicated MKTAG macro definition, #include libavutil/common.h instead.
diego
parents:
31269
diff
changeset
|
46 #include "libavutil/common.h" |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22018
diff
changeset
|
47 #include "stream/stream.h" |
30589
df6c41f16b40
Add header for AVI print functions; avoids many forward declarations.
diego
parents:
30578
diff
changeset
|
48 #include "aviprint.h" |
3777 | 49 #include "demuxer.h" |
50 #include "stheader.h" | |
30573
02420b32391b
Add separate header for real_fix_timestamp(); avoids forward declarations.
diego
parents:
29288
diff
changeset
|
51 #include "demux_real.h" |
3777 | 52 |
6369 | 53 //#define mp_dbg(mod,lev, args... ) mp_msg_c((mod<<8)|lev, ## args ) |
54 | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
55 #define MAX_STREAMS 32 |
3777 | 56 |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
57 static unsigned char sipr_swaps[38][2]={ |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
58 {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68}, |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
59 {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46}, |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
60 {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56}, |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
61 {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83}, |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
62 {77,80} }; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
63 |
3777 | 64 typedef struct { |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
65 unsigned int timestamp; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
66 int offset; |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
67 // int packetno; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
68 // int len; /* only filled by our index generator */ |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
69 // 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
|
70 } real_index_table_t; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
71 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
72 typedef struct { |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
73 /* for seeking */ |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
74 int index_chunk_offset; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
75 real_index_table_t *index_table[MAX_STREAMS]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
76 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
77 // int *index_table[MAX_STREAMS]; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
78 int index_table_size[MAX_STREAMS]; |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
79 int index_malloc_size[MAX_STREAMS]; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
80 int data_chunk_offset; |
3777 | 81 int num_of_packets; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
82 int current_packet; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
83 |
11441 | 84 // need for seek |
85 int audio_need_keyframe; | |
86 int video_after_seek; | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
87 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
88 int current_apacket; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
89 int current_vpacket; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
90 |
6423 | 91 // timestamp correction: |
20229
cd827d62fb71
Fix timestamps for streams where kf_base gets negative
rtogni
parents:
20198
diff
changeset
|
92 int64_t kf_base;// timestamp of the prev. video keyframe |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
93 unsigned int kf_pts; // timestamp of next video keyframe |
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
94 unsigned int a_pts; // previous audio timestamp |
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
95 double v_pts; // previous video timestamp |
11441 | 96 unsigned long duration; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
97 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
98 /* stream id table */ |
7710 | 99 // int last_a_stream; |
100 // int a_streams[MAX_STREAMS]; | |
101 // int last_v_stream; | |
102 // int v_streams[MAX_STREAMS]; | |
14402 | 103 |
104 /** | |
105 * Used to demux multirate files | |
106 */ | |
107 int is_multirate; ///< != 0 for multirate files | |
108 int str_data_offset[MAX_STREAMS]; ///< Data chunk offset for every audio/video stream | |
109 int audio_curpos; ///< Current file position for audio demuxing | |
110 int video_curpos; ///< Current file position for video demuxing | |
111 int a_num_of_packets; ///< Number of audio packets | |
112 int v_num_of_packets; ///< Number of video packets | |
113 int a_bitrate; ///< Audio bitrate | |
114 int v_bitrate; ///< Video bitrate | |
115 int stream_switch; ///< Flag used to switch audio/video demuxing | |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
116 |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
117 /** |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
118 * Used to reorder audio data |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
119 */ |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
120 unsigned int intl_id[MAX_STREAMS]; ///< interleaver id, per stream |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
121 int sub_packet_size[MAX_STREAMS]; ///< sub packet size, per stream |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
122 int sub_packet_h[MAX_STREAMS]; ///< number of coded frames per block |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
123 int coded_framesize[MAX_STREAMS]; ///< coded frame size, per stream |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
124 int audiopk_size[MAX_STREAMS]; ///< audio packet size |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
125 unsigned char *audio_buf; ///< place to store reordered audio data |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
126 double *audio_timestamp; ///< timestamp for each audio packet |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
127 int sub_packet_cnt; ///< number of subpacket already received |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
128 int audio_filepos; ///< file position of first audio packet in block |
3777 | 129 } real_priv_t; |
130 | |
18444
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
131 //! use at most 200 MB of memory for index, corresponds to around 25 million entries |
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
132 #define MAX_INDEX_ENTRIES (200*1024*1024 / sizeof(real_index_table_t)) |
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
133 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
134 /* originally from FFmpeg */ |
3777 | 135 static void get_str(int isbyte, demuxer_t *demuxer, char *buf, int buf_size) |
136 { | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
137 int len; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
138 |
3777 | 139 if (isbyte) |
140 len = stream_read_char(demuxer->stream); | |
141 else | |
142 len = stream_read_word(demuxer->stream); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
143 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
144 stream_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
|
145 if (len > buf_size) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
146 stream_skip(demuxer->stream, len-buf_size); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
147 |
11870 | 148 mp_msg(MSGT_DEMUX, MSGL_V, "read_str: %d bytes read\n", len); |
3777 | 149 } |
150 | |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
151 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
|
152 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
153 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
|
154 real_index_table_t *index; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
155 int i, entries; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
156 |
28550
6832bb1e1e3a
Fix a regression caused by r17933; RealMedia index tables could never be printed.
zuxy
parents:
28549
diff
changeset
|
157 if (!mp_msg_test(MSGT_DEMUX,MSGL_V)) |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
158 return; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
159 |
18106
3a34a728fa1b
always cast stream IDs to unsigned before comparing to MAX_STREAMS.
reimar
parents:
17977
diff
changeset
|
160 if ((unsigned)stream_id >= MAX_STREAMS) |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
161 return; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
162 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
163 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
|
164 entries = priv->index_table_size[stream_id]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
165 |
11870 | 166 mp_msg(MSGT_DEMUX, MSGL_V, "Index table for stream %d\n", stream_id); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
167 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
|
168 { |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
169 #if 1 |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
170 mp_msg(MSGT_DEMUX, MSGL_V,"i: %d, pos: %d, timestamp: %u\n", i, index[i].offset, index[i].timestamp); |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
171 #else |
11870 | 172 mp_msg(MSGT_DEMUX, MSGL_V,"packetno: %x pos: %x len: %x timestamp: %x flags: %x\n", |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
173 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
|
174 index[i].flags); |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
175 #endif |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
176 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
177 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
178 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
179 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
|
180 { |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
181 real_priv_t *priv = demuxer->priv; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
182 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
|
183 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
|
184 int i, entries, stream_id; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
185 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
186 read_index: |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
187 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
|
188 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
189 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
|
190 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
|
191 { |
11870 | 192 mp_msg(MSGT_DEMUX, MSGL_WARN,"Something went wrong, no index chunk found on given address (%d)\n", |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
193 next_header_pos); |
11441 | 194 index_mode = -1; |
195 if (i == -256) | |
196 stream_reset(demuxer->stream); | |
197 stream_seek(demuxer->stream, origpos); | |
198 return 0; | |
199 //goto end; | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
200 } |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
201 |
11870 | 202 mp_msg(MSGT_DEMUX, MSGL_V,"Reading index table from index chunk (%d)\n", |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
203 next_header_pos); |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
204 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
205 i = stream_read_dword(demuxer->stream); |
11870 | 206 mp_msg(MSGT_DEMUX, MSGL_V,"size: %d bytes\n", i); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
207 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
208 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
|
209 if (i != 0) |
11870 | 210 mp_msg(MSGT_DEMUX, MSGL_WARN,"Hmm, index table with unknown version (%d), please report it to MPlayer developers!\n", i); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
211 |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
212 entries = stream_read_dword(demuxer->stream); |
11870 | 213 mp_msg(MSGT_DEMUX, MSGL_V,"entries: %d\n", entries); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
214 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
215 stream_id = stream_read_word(demuxer->stream); |
11870 | 216 mp_msg(MSGT_DEMUX, MSGL_V,"stream_id: %d\n", stream_id); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
217 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
218 next_header_pos = stream_read_dword(demuxer->stream); |
11870 | 219 mp_msg(MSGT_DEMUX, MSGL_V,"next_header_pos: %d\n", next_header_pos); |
18444
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
220 if (entries <= 0 || entries > MAX_INDEX_ENTRIES) |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
221 { |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
222 if (next_header_pos) |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
223 goto read_index; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
224 i = entries; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
225 goto end; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
226 } |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
227 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
228 priv->index_table_size[stream_id] = entries; |
18444
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
229 priv->index_table[stream_id] = calloc(priv->index_table_size[stream_id], sizeof(real_index_table_t)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
230 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
231 for (i = 0; i < entries; i++) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
232 { |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
233 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
|
234 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
|
235 priv->index_table[stream_id][i].offset = stream_read_dword(demuxer->stream); |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
236 stream_skip(demuxer->stream, 4); /* packetno */ |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
237 // 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
|
238 // 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
|
239 // 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
|
240 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
241 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
242 dump_index(demuxer, stream_id); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
243 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
244 if (next_header_pos > 0) |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
245 goto read_index; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
246 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
247 end: |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
248 if (i == -256) |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
249 stream_reset(demuxer->stream); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
250 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
|
251 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
252 return 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
253 else |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
254 return 1; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
255 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
256 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
257 #if 1 |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
258 |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
259 static void add_index_item(demuxer_t *demuxer, int stream_id, unsigned int timestamp, int offset) |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
260 { |
12665
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
261 if ((unsigned)stream_id < MAX_STREAMS) |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
262 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
263 real_priv_t *priv = demuxer->priv; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
264 real_index_table_t *index; |
18444
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
265 if (priv->index_table_size[stream_id] >= MAX_INDEX_ENTRIES) { |
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
266 mp_msg(MSGT_DEMUXER, MSGL_WARN, "Index too large during building\n"); |
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
267 return; |
fa603193eccf
Fix potential integer overflows in memory allocation. Patch by Reimar and me, SIZE_MAX by Rich
rtognimp
parents:
18176
diff
changeset
|
268 } |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
269 if (priv->index_table_size[stream_id] >= priv->index_malloc_size[stream_id]) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
270 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
271 if (priv->index_malloc_size[stream_id] == 0) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
272 priv->index_malloc_size[stream_id] = 2048; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
273 else |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
274 priv->index_malloc_size[stream_id] += priv->index_malloc_size[stream_id] / 2; |
14897 | 275 // in case we have a really large chunk... |
276 if (priv->index_table_size[stream_id] >= | |
277 priv->index_malloc_size[stream_id]) | |
278 priv->index_malloc_size[stream_id] = | |
279 priv->index_table_size[stream_id] + 1; | |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
280 priv->index_table[stream_id] = realloc(priv->index_table[stream_id], priv->index_malloc_size[stream_id]*sizeof(priv->index_table[0][0])); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
281 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
282 if (priv->index_table_size[stream_id] > 0) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
283 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
284 index = &priv->index_table[stream_id][priv->index_table_size[stream_id] - 1]; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
285 if (index->timestamp >= timestamp || index->offset >= offset) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
286 return; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
287 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
288 index = &priv->index_table[stream_id][priv->index_table_size[stream_id]++]; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
289 index->timestamp = timestamp; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
290 index->offset = offset; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
291 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
292 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
293 |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
294 static void add_index_segment(demuxer_t *demuxer, int seek_stream_id, int64_t seek_timestamp) |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
295 { |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
296 int tag, len, stream_id, flags; |
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
297 unsigned int timestamp; |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
298 if (seek_timestamp != -1 && (unsigned)seek_stream_id >= MAX_STREAMS) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
299 return; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
300 while (1) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
301 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
302 demuxer->filepos = stream_tell(demuxer->stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
303 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
304 tag = stream_read_dword(demuxer->stream); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
305 if (tag == MKTAG('A', 'T', 'A', 'D')) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
306 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
307 stream_skip(demuxer->stream, 14); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
308 continue; /* skip to next loop */ |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
309 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
310 len = tag & 0xffff; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
311 if (tag == -256 || len < 12) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
312 break; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
313 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
314 stream_id = stream_read_word(demuxer->stream); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
315 timestamp = stream_read_dword(demuxer->stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
316 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
317 stream_skip(demuxer->stream, 1); /* reserved */ |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
318 flags = stream_read_char(demuxer->stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
319 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
320 if (flags == -256) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
321 break; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
322 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
323 if (flags & 2) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
324 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
325 add_index_item(demuxer, stream_id, timestamp, demuxer->filepos); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
326 if (stream_id == seek_stream_id && timestamp >= seek_timestamp) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
327 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
328 stream_seek(demuxer->stream, demuxer->filepos); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
329 return; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
330 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
331 } |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
332 // printf("Index: stream=%d packet=%d timestamp=%u len=%d flags=0x%x datapos=0x%x\n", stream_id, entries, timestamp, len, flags, index->offset); |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
333 /* skip data */ |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
334 stream_skip(demuxer->stream, len-12); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
335 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
336 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
337 |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
338 static int generate_index(demuxer_t *demuxer) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
339 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
340 real_priv_t *priv = demuxer->priv; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
341 int origpos = stream_tell(demuxer->stream); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
342 int data_pos = priv->data_chunk_offset-10; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
343 int i; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
344 int tag; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
345 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
346 stream_seek(demuxer->stream, data_pos); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
347 tag = stream_read_dword(demuxer->stream); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
348 if (tag != MKTAG('A', 'T', 'A', 'D')) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
349 { |
11870 | 350 mp_msg(MSGT_DEMUX, MSGL_WARN,"Something went wrong, no data chunk found on given address (%d)\n", data_pos); |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
351 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
352 else |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
353 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
354 stream_skip(demuxer->stream, 14); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
355 add_index_segment(demuxer, -1, -1); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
356 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
357 for (i = 0; i < MAX_STREAMS; i++) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
358 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
359 if (priv->index_table_size[i] > 0) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
360 { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
361 dump_index(demuxer, i); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
362 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
363 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
364 stream_reset(demuxer->stream); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
365 stream_seek(demuxer->stream, origpos); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
366 return 0; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
367 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
368 |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
369 #else |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
370 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
371 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
|
372 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
373 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
|
374 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
|
375 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
|
376 int num_of_packets = 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
377 int i, entries = 0; |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
378 int len, stream_id = 0, flags; |
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
379 unsigned int timestamp; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
380 int tab_pos = 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
381 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
382 read_index: |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
383 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
|
384 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
385 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
|
386 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
|
387 { |
11870 | 388 mp_msg(MSGT_DEMUX, MSGL_WARN,"Something went wrong, no data chunk found on given address (%d)\n", |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
389 data_pos); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
390 goto end; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
391 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
392 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
|
393 stream_skip(demuxer->stream, 2); /* version */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
394 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
395 num_of_packets = stream_read_dword(demuxer->stream); |
11870 | 396 mp_msg(MSGT_DEMUX, MSGL_V,"Generating index table from raw data (pos: 0x%x) for %d packets\n", |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
397 data_pos, num_of_packets); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
398 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
399 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
|
400 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
401 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
|
402 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
403 priv->index_table_size[i] = num_of_packets; |
18505
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
404 priv->index_table[i] = calloc(priv->index_table_size[i], sizeof(real_index_table_t)); |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
405 // 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
|
406 // 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
|
407 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
408 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
409 tab_pos = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
410 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
411 // 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
|
412 // memset(priv->index_table, 0, sizeof(real_index_table_t)*MAX_STREAMS); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
413 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
414 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
|
415 { |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
416 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
|
417 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
418 goto end; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
419 stream_skip(demuxer->stream, 1); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
420 // 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
|
421 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
422 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
|
423 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
|
424 timestamp = stream_read_dword(demuxer->stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
425 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
426 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
|
427 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
|
428 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
429 i = tab_pos; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
430 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
431 // 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
|
432 // 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
|
433 // 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
|
434 // else |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
435 // 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
|
436 // priv->index_table_size[stream_id] * sizeof(real_index_table_t)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
437 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
444 tab_pos++; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
445 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
446 /* skip data */ |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
447 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
|
448 } |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
449 dump_index(demuxer, stream_id); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
450 if (data_pos) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
451 goto read_index; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
452 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
453 end: |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
454 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
455 stream_reset(demuxer->stream); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
456 stream_seek(demuxer->stream, origpos); |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
457 if (i == -256) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
458 return 0; |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
459 else |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
460 return 1; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
461 } |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
462 #endif |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
463 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
464 |
16175 | 465 static int real_check_file(demuxer_t* demuxer) |
3795 | 466 { |
3777 | 467 real_priv_t *priv; |
468 int c; | |
469 | |
470 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for REAL\n"); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
471 |
3777 | 472 c = stream_read_dword_le(demuxer->stream); |
473 if (c == -256) | |
474 return 0; /* EOF */ | |
475 if (c != MKTAG('.', 'R', 'M', 'F')) | |
476 return 0; /* bad magic */ | |
477 | |
32108 | 478 priv = calloc(1, sizeof(real_priv_t)); |
3777 | 479 demuxer->priv = priv; |
480 | |
16175 | 481 return DEMUXER_TYPE_REAL; |
3777 | 482 } |
483 | |
9543 | 484 #define SKIP_BITS(n) buffer<<=n |
485 #define SHOW_BITS(n) ((buffer)>>(32-(n))) | |
486 | |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
487 double real_fix_timestamp(unsigned char *buf, unsigned int timestamp, unsigned int format, int64_t *kf_base, int *kf_pts, double *pts){ |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
488 double v_pts; |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
489 unsigned char *s = buf + 1 + (*buf+1)*8; |
9543 | 490 uint32_t buffer= (s[0]<<24) + (s[1]<<16) + (s[2]<<8) + s[3]; |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
491 unsigned int kf=timestamp; |
9543 | 492 int pict_type; |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
493 unsigned int orig_kf; |
9555 | 494 |
9543 | 495 if(format==mmioFOURCC('R','V','3','0') || format==mmioFOURCC('R','V','4','0')){ |
496 if(format==mmioFOURCC('R','V','3','0')){ | |
497 SKIP_BITS(3); | |
498 pict_type= SHOW_BITS(2); | |
499 SKIP_BITS(2 + 7); | |
500 }else{ | |
501 SKIP_BITS(1); | |
502 pict_type= SHOW_BITS(2); | |
9555 | 503 SKIP_BITS(2 + 7 + 3); |
9543 | 504 } |
9555 | 505 orig_kf= |
506 kf= SHOW_BITS(13); // kf= 2*SHOW_BITS(12); | |
507 // if(pict_type==0) | |
508 if(pict_type<=1){ | |
509 // I frame, sync timestamps: | |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
510 *kf_base=(int64_t)timestamp-kf; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
511 mp_msg(MSGT_DEMUX, MSGL_DBG2,"\nTS: base=%08"PRIX64"\n",*kf_base); |
9555 | 512 kf=timestamp; |
513 } else { | |
514 // P/B frame, merge timestamps: | |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
515 int64_t tmp=(int64_t)timestamp-*kf_base; |
9555 | 516 kf|=tmp&(~0x1fff); // combine with packet timestamp |
517 if(kf<tmp-4096) kf+=8192; else // workaround wrap-around problems | |
518 if(kf>tmp+4096) kf-=8192; | |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
519 kf+=*kf_base; |
9555 | 520 } |
9543 | 521 if(pict_type != 3){ // P || I frame -> swap timestamps |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
522 unsigned int tmp=kf; |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
523 kf=*kf_pts; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
524 *kf_pts=tmp; |
6423 | 525 // if(kf<=tmp) kf=0; |
526 } | |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
527 mp_msg(MSGT_DEMUX, MSGL_DBG2,"\nTS: %08X -> %08X (%04X) %d %02X %02X %02X %02X %5u\n",timestamp,kf,orig_kf,pict_type,s[0],s[1],s[2],s[3],pts?kf-(unsigned int)(*pts*1000.0):0); |
6995
8f92313a0cd5
RV20 A-V desync fixed - use timestamp hack only for RV30
arpi
parents:
6982
diff
changeset
|
528 } |
6423 | 529 v_pts=kf*0.001f; |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
530 // if(pts && (v_pts<*pts || !kf)) v_pts=*pts+frametime; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
531 if(pts) *pts=v_pts; |
6423 | 532 return v_pts; |
533 } | |
534 | |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
535 typedef struct dp_hdr_s { |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
536 uint32_t chunks; // number of chunks |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
537 uint32_t timestamp; // timestamp from packet header |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
538 uint32_t len; // length of actual data |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
539 uint32_t chunktab; // offset to chunk offset array |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
540 } dp_hdr_t; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
541 |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
542 static void queue_video_packet(real_priv_t *priv, demux_stream_t *ds, demux_packet_t *dp) |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
543 { |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
544 dp_hdr_t hdr = *(dp_hdr_t*)dp->buffer; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
545 unsigned char *tmp = malloc(8*(1+hdr.chunks)); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
546 memcpy(tmp, dp->buffer+hdr.chunktab, 8*(1+hdr.chunks)); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
547 memmove(dp->buffer+1+8*(1+hdr.chunks), dp->buffer+sizeof(dp_hdr_t), hdr.len); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
548 memcpy(dp->buffer+1, tmp, 8*(1+hdr.chunks)); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
549 *dp->buffer = (uint8_t)hdr.chunks; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
550 free(tmp); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
551 |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
552 if(priv->video_after_seek){ |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
553 priv->kf_base = 0; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
554 priv->kf_pts = hdr.timestamp; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
555 priv->video_after_seek = 0; |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
556 } |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
557 if(hdr.len >= 3) /* this check may be useless */ |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
558 dp->pts = real_fix_timestamp(dp->buffer, hdr.timestamp, |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
559 ((sh_video_t *)ds->sh)->format, |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
560 &priv->kf_base, &priv->kf_pts, |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
561 &priv->v_pts); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
562 ds_add_packet(ds, dp); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
563 } |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
564 |
3777 | 565 // return value: |
566 // 0 = EOF or no stream found | |
567 // 1 = successfully read a packet | |
16175 | 568 static int demux_real_fill_buffer(demuxer_t *demuxer, demux_stream_t *dsds) |
3777 | 569 { |
570 real_priv_t *priv = demuxer->priv; | |
571 demux_stream_t *ds = NULL; | |
572 int len; | |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
573 unsigned int timestamp; |
3777 | 574 int stream_id; |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8123
diff
changeset
|
575 #ifdef CRACK_MATRIX |
3777 | 576 int i; |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8123
diff
changeset
|
577 #endif |
3795 | 578 int flags; |
6916 | 579 int version; |
580 int reserved; | |
11886 | 581 demux_packet_t *dp; |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
582 int x, sps, cfs, sph, spc, w; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
583 int audioreorder_getnextpk = 0; |
3777 | 584 |
20499 | 585 // Don't demux video if video codec init failed |
586 if (demuxer->video->id >= 0 && !demuxer->video->sh) | |
587 demuxer->video->id = -2; | |
588 | |
19960
5928bd5c7f0b
Make fill_buffer function check for stream eof, fixes hang at eof (bug #580)
reimar
parents:
19954
diff
changeset
|
589 while(!stream_eof(demuxer->stream)){ |
7710 | 590 |
14402 | 591 /* Handle audio/video demxing switch for multirate files (non-interleaved) */ |
592 if (priv->is_multirate && priv->stream_switch) { | |
28549 | 593 if (priv->current_apacket >= priv->index_table_size[demuxer->audio->id]) |
14402 | 594 demuxer->audio->eof = 1; |
28549 | 595 if (priv->current_vpacket >= priv->index_table_size[demuxer->video->id]) |
14402 | 596 demuxer->video->eof = 1; |
597 if (demuxer->audio->eof && demuxer->video->eof) | |
598 return 0; | |
599 else if (!demuxer->audio->eof && demuxer->video->eof) | |
600 stream_seek(demuxer->stream, priv->audio_curpos); // Get audio | |
601 else if (demuxer->audio->eof && !demuxer->video->eof) | |
602 stream_seek(demuxer->stream, priv->video_curpos); // Get video | |
28549 | 603 else if (priv->index_table[demuxer->audio->id][priv->current_apacket].timestamp < |
604 priv->index_table[demuxer->video->id][priv->current_vpacket].timestamp) | |
14402 | 605 stream_seek(demuxer->stream, priv->audio_curpos); // Get audio |
606 else | |
607 stream_seek(demuxer->stream, priv->video_curpos); // Get video | |
608 priv->stream_switch = 0; | |
609 } | |
610 | |
6916 | 611 demuxer->filepos = stream_tell(demuxer->stream); |
612 version = stream_read_word(demuxer->stream); /* version */ | |
3777 | 613 len = stream_read_word(demuxer->stream); |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
614 if ((version==0x4441) && (len==0x5441)) { // new data chunk |
10342 | 615 mp_msg(MSGT_DEMUX,MSGL_INFO,"demux_real: New data chunk is coming!!!\n"); |
14402 | 616 if (priv->is_multirate) |
617 return 0; // EOF | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
618 stream_skip(demuxer->stream,14); |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
619 demuxer->filepos = stream_tell(demuxer->stream); |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
620 version = stream_read_word(demuxer->stream); /* version */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
621 len = stream_read_word(demuxer->stream); |
12076
1309695bcdf4
Stop reading the file if an INDX chunk is found instead of a data packet.
mosu
parents:
11989
diff
changeset
|
622 } else if ((version == 0x494e) && (len == 0x4458)) { |
1309695bcdf4
Stop reading the file if an INDX chunk is found instead of a data packet.
mosu
parents:
11989
diff
changeset
|
623 mp_msg(MSGT_DEMUX,MSGL_V,"demux_real: Found INDX chunk. EOF.\n"); |
14586
77e2eaf833c5
Do not read any more data at eof: if got eof in the middle of an audio
rtognimp
parents:
14585
diff
changeset
|
624 demuxer->stream->eof=1; |
12076
1309695bcdf4
Stop reading the file if an INDX chunk is found instead of a data packet.
mosu
parents:
11989
diff
changeset
|
625 return 0; |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
626 } |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
627 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
628 |
6916 | 629 if (len == -256){ /* EOF */ |
7710 | 630 // printf("len==-256!\n"); |
3777 | 631 return 0; |
6916 | 632 } |
7710 | 633 if (len < 12){ |
11870 | 634 mp_msg(MSGT_DEMUX, MSGL_V,"%08X: packet v%d len=%d \n",(int)demuxer->filepos,(int)version,(int)len); |
635 mp_msg(MSGT_DEMUX, MSGL_WARN,"bad packet len (%d)\n", len); | |
28630
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
636 if ((unsigned)demuxer->video->id < MAX_STREAMS) { |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
637 if (priv->current_vpacket + 1 < priv->index_table_size[demuxer->video->id]) { |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
638 stream_seek(demuxer->stream, priv->index_table[demuxer->video->id][++priv->current_vpacket].offset); |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
639 } |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
640 } else if ((unsigned)demuxer->audio->id < MAX_STREAMS) { |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
641 if (priv->current_apacket + 1 < priv->index_table_size[demuxer->audio->id]) { |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
642 stream_seek(demuxer->stream, priv->index_table[demuxer->audio->id][++priv->current_apacket].offset); |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
643 } |
acadba04afaf
Be more robust against corrupted RM files that contain invalid packet length
zuxy
parents:
28550
diff
changeset
|
644 } |
7710 | 645 continue; //goto loop; |
3777 | 646 } |
7710 | 647 |
3777 | 648 stream_id = stream_read_word(demuxer->stream); |
649 timestamp = stream_read_dword(demuxer->stream); | |
6916 | 650 reserved = stream_read_char(demuxer->stream); |
3795 | 651 flags = stream_read_char(demuxer->stream); |
652 /* flags: */ | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
653 /* 0x1 - reliable */ |
3795 | 654 /* 0x2 - keyframe */ |
655 | |
14402 | 656 if (version == 1) { |
657 int tmp; | |
658 tmp = stream_read_char(demuxer->stream); | |
659 mp_msg(MSGT_DEMUX, MSGL_DBG2,"Version: %d, skipped byte is %d\n", version, tmp); | |
660 len--; | |
661 } | |
662 | |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
663 if (flags & 2) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
664 add_index_item(demuxer, stream_id, timestamp, demuxer->filepos); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
665 |
6916 | 666 // printf("%08X: packet v%d len=%4d id=%d pts=%6d rvd=%d flags=%d \n", |
667 // (int)demuxer->filepos,(int)version,(int)len, stream_id, | |
668 // (int) timestamp, reserved, flags); | |
669 | |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
670 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "\npacket#%d: pos: 0x%0x, len: %d, id: %d, pts: %u, flags: %x rvd:%d\n", |
6916 | 671 priv->current_packet, (int)demuxer->filepos, len, stream_id, timestamp, flags, reserved); |
3777 | 672 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
673 priv->current_packet++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
674 len -= 12; |
3777 | 675 |
6344 | 676 // printf("s_id=%d aid=%d vid=%d \n",stream_id,demuxer->audio->id,demuxer->video->id); |
677 | |
7710 | 678 /* check stream_id: */ |
679 | |
680 if(demuxer->audio->id==stream_id){ | |
11441 | 681 if (priv->audio_need_keyframe == 1&& flags != 0x2) |
682 goto discard; | |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
683 got_audio: |
7710 | 684 ds=demuxer->audio; |
685 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "packet is audio (id: %d)\n", stream_id); | |
686 | |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
687 if (flags & 2) { |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
688 priv->sub_packet_cnt = 0; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
689 audioreorder_getnextpk = 0; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
690 } |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
691 |
7710 | 692 // parse audio chunk: |
3777 | 693 { |
7105 | 694 #ifdef CRACK_MATRIX |
695 int spos=stream_tell(demuxer->stream); | |
696 static int cnt=0; | |
697 static int cnt2=CRACK_MATRIX; | |
698 #endif | |
11877 | 699 if (((sh_audio_t *)ds->sh)->format == mmioFOURCC('M', 'P', '4', 'A')) { |
25599
a836d1288d59
Don't dynamically allocate sub_packet_lengths[] in raac demuxing.
rtogni
parents:
25027
diff
changeset
|
700 uint16_t sub_packet_lengths[16], sub_packets, i; |
25600 | 701 int totlen = 0; |
11877 | 702 /* AAC in Real: several AAC frames in one Real packet. */ |
703 /* Second byte, upper four bits: number of AAC frames */ | |
704 /* next n * 2 bytes: length of the AAC frames in bytes, BE */ | |
25600 | 705 if (len < 2) |
706 goto discard; | |
11877 | 707 sub_packets = (stream_read_word(demuxer->stream) & 0xf0) >> 4; |
25600 | 708 if (len < 2 * sub_packets) |
709 goto discard; | |
11877 | 710 for (i = 0; i < sub_packets; i++) |
25600 | 711 totlen += sub_packet_lengths[i] = stream_read_word(demuxer->stream); |
712 if (len < totlen ) | |
713 goto discard; | |
11877 | 714 for (i = 0; i < sub_packets; i++) { |
715 demux_packet_t *dp = new_demux_packet(sub_packet_lengths[i]); | |
716 stream_read(demuxer->stream, dp->buffer, sub_packet_lengths[i]); | |
20794
cc6e090f9a75
Changed code that used pts=0 in demux packets to indicate "not known".
uau
parents:
20499
diff
changeset
|
717 if (priv->a_pts != timestamp) |
20795
047887057875
Change some constants in pts arithmetic from float to double.
uau
parents:
20794
diff
changeset
|
718 dp->pts = timestamp / 1000.0; |
11877 | 719 priv->a_pts = timestamp; |
720 dp->pos = demuxer->filepos; | |
721 ds_add_packet(ds, dp); | |
722 } | |
723 return 1; | |
724 } | |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
725 if ((priv->intl_id[stream_id] == mmioFOURCC('I', 'n', 't', '4')) || |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
726 (priv->intl_id[stream_id] == mmioFOURCC('g', 'e', 'n', 'r')) || |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
727 (priv->intl_id[stream_id] == mmioFOURCC('s', 'i', 'p', 'r'))) { |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
728 sps = priv->sub_packet_size[stream_id]; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
729 sph = priv->sub_packet_h[stream_id]; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
730 cfs = priv->coded_framesize[stream_id]; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
731 w = priv->audiopk_size[stream_id]; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
732 spc = priv->sub_packet_cnt; |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
733 switch (priv->intl_id[stream_id]) { |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
734 case mmioFOURCC('I', 'n', 't', '4'): |
25600 | 735 if (len < cfs * sph/2) |
736 goto discard; | |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
737 for (x = 0; x < sph / 2; x++) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
738 stream_read(demuxer->stream, priv->audio_buf + x * 2 * w + spc * cfs, cfs); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
739 break; |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
740 case mmioFOURCC('g', 'e', 'n', 'r'): |
25600 | 741 if (len < w) |
742 goto discard; | |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
743 for (x = 0; x < w / sps; x++) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
744 stream_read(demuxer->stream, priv->audio_buf + sps * (sph * x + ((sph + 1) / 2) * (spc & 1) + |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
745 (spc >> 1)), sps); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
746 break; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
747 case mmioFOURCC('s', 'i', 'p', 'r'): |
25600 | 748 if (len < w) |
749 goto discard; | |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
750 stream_read(demuxer->stream, priv->audio_buf + spc * w, w); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
751 if (spc == sph - 1) { |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
752 int n; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
753 int bs = sph * w * 2 / 96; // nibbles per subpacket |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
754 // Perform reordering |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
755 for(n=0; n < 38; n++) { |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
756 int j; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
757 int i = bs * sipr_swaps[n][0]; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
758 int o = bs * sipr_swaps[n][1]; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
759 // swap nibbles of block 'i' with 'o' TODO: optimize |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
760 for(j = 0;j < bs; j++) { |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
761 int x = (i & 1) ? (priv->audio_buf[i >> 1] >> 4) : (priv->audio_buf[i >> 1] & 0x0F); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
762 int y = (o & 1) ? (priv->audio_buf[o >> 1] >> 4) : (priv->audio_buf[o >> 1] & 0x0F); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
763 if(o & 1) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
764 priv->audio_buf[o >> 1] = (priv->audio_buf[o >> 1] & 0x0F) | (x << 4); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
765 else |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
766 priv->audio_buf[o >> 1] = (priv->audio_buf[o >> 1] & 0xF0) | x; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
767 if(i & 1) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
768 priv->audio_buf[i >> 1] = (priv->audio_buf[i >> 1] & 0x0F) | (y << 4); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
769 else |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
770 priv->audio_buf[i >> 1] = (priv->audio_buf[i >> 1] & 0xF0) | y; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
771 ++i; ++o; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
772 } |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
773 } |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
774 } |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
775 break; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
776 } |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
777 priv->audio_need_keyframe = 0; |
26381
4617c374f752
demux_real.c: Always use MP_NOPTS_VALUE for unknown pts
uau
parents:
26069
diff
changeset
|
778 priv->audio_timestamp[priv->sub_packet_cnt] = (priv->a_pts==timestamp) ? MP_NOPTS_VALUE : (timestamp/1000.0); |
17317
69fe94dded9a
Remove assumption that all audio packets in a block have the same
rtognimp
parents:
17316
diff
changeset
|
779 priv->a_pts = timestamp; |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
780 if (priv->sub_packet_cnt == 0) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
781 priv->audio_filepos = demuxer->filepos; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
782 if (++(priv->sub_packet_cnt) < sph) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
783 audioreorder_getnextpk = 1; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
784 else { |
32110 | 785 int apk_usize = ((sh_audio_t*)ds->sh)->wf->nBlockAlign; |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
786 audioreorder_getnextpk = 0; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
787 priv->sub_packet_cnt = 0; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
788 // Release all the audio packets |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
789 for (x = 0; x < sph*w/apk_usize; x++) { |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
790 dp = new_demux_packet(apk_usize); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
791 memcpy(dp->buffer, priv->audio_buf + x * apk_usize, apk_usize); |
17317
69fe94dded9a
Remove assumption that all audio packets in a block have the same
rtognimp
parents:
17316
diff
changeset
|
792 /* Put timestamp only on packets that correspond to original audio packets in file */ |
20794
cc6e090f9a75
Changed code that used pts=0 in demux packets to indicate "not known".
uau
parents:
20499
diff
changeset
|
793 if (x * apk_usize % w == 0) |
cc6e090f9a75
Changed code that used pts=0 in demux packets to indicate "not known".
uau
parents:
20499
diff
changeset
|
794 dp->pts = priv->audio_timestamp[x * apk_usize / w]; |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
795 dp->pos = priv->audio_filepos; // all equal |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
796 dp->flags = x ? 0 : 0x10; // Mark first packet as keyframe |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
797 ds_add_packet(ds, dp); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
798 } |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
799 } |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
800 } else { // No interleaving |
11886 | 801 dp = new_demux_packet(len); |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
802 stream_read(demuxer->stream, dp->buffer, len); |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
803 |
7105 | 804 #ifdef CRACK_MATRIX |
11870 | 805 mp_msg(MSGT_DEMUX, MSGL_V,"*** audio block len=%d\n",len); |
7105 | 806 { // HACK - used for reverse engineering the descrambling matrix |
807 FILE* f=fopen("test.rm","r+"); | |
808 fseek(f,spos,SEEK_SET); | |
809 ++cnt; | |
810 // for(i=0;i<len;i++) dp->buffer[i]=i/0x12; | |
811 // for(i=0;i<len;i++) dp->buffer[i]=i; | |
812 // for(i=0;i<len;i++) dp->buffer[i]=cnt; | |
813 // for(i=0;i<len;i++) dp->buffer[i]=cnt<<4; | |
814 for(i=0;i<len;i++) dp->buffer[i]=(i==cnt2) ? (cnt+16*(8+cnt)) : 0; | |
815 if(cnt==6){ cnt=0; ++cnt2; } | |
816 fwrite(dp->buffer, len, 1, f); | |
817 fclose(f); | |
818 if(cnt2>0x150) *((int*)NULL)=1; // sig11 :) | |
819 } | |
820 #endif | |
10118 | 821 #if 0 |
7710 | 822 if( ((sh_audio_t *)ds->sh)->format == 0x2000) { |
823 // if DNET, swap bytes, as DNET is byte-swapped AC3: | |
4235 | 824 char *ptr = dp->buffer; |
7710 | 825 int i; |
4235 | 826 for (i = 0; i < len; i += 2) |
827 { | |
828 const char tmp = ptr[0]; | |
829 ptr[0] = ptr[1]; | |
830 ptr[1] = tmp; | |
831 ptr += 2; | |
832 } | |
833 } | |
10118 | 834 #endif |
11441 | 835 if (priv->audio_need_keyframe == 1) { |
836 priv->audio_need_keyframe = 0; | |
20794
cc6e090f9a75
Changed code that used pts=0 in demux packets to indicate "not known".
uau
parents:
20499
diff
changeset
|
837 } else if(priv->a_pts != timestamp) |
cc6e090f9a75
Changed code that used pts=0 in demux packets to indicate "not known".
uau
parents:
20499
diff
changeset
|
838 dp->pts = timestamp/1000.0; |
6423 | 839 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
|
840 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
|
841 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
|
842 ds_add_packet(ds, dp); |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
843 |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
844 } // codec_id check, codec default case |
7710 | 845 } |
11441 | 846 // we will not use audio index if we use -idx and have a video |
28549 | 847 if(((!demuxer->video->sh && index_mode == 2) || priv->is_multirate) && (unsigned)demuxer->audio->id < MAX_STREAMS) { |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
848 while (priv->current_apacket + 1 < priv->index_table_size[demuxer->audio->id] && |
28549 | 849 timestamp > priv->index_table[demuxer->audio->id][priv->current_apacket].timestamp) { |
11441 | 850 priv->current_apacket += 1; |
14402 | 851 priv->stream_switch = 1; |
852 } | |
28549 | 853 if (priv->stream_switch) |
854 priv->audio_curpos = stream_tell(demuxer->stream); | |
855 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
856 |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
857 // If we're reordering audio packets and we need more data get it |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
858 if (audioreorder_getnextpk) |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
859 continue; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
860 |
7710 | 861 return 1; |
862 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
863 |
7710 | 864 if(demuxer->video->id==stream_id){ |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
865 got_video: |
7710 | 866 ds=demuxer->video; |
867 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "packet is video (id: %d)\n", stream_id); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
868 |
7710 | 869 // parse video chunk: |
870 { | |
871 // we need a more complicated, 2nd level demuxing, as the video | |
872 // frames are stored fragmented in the video chunks :( | |
873 sh_video_t *sh_video = ds->sh; | |
874 demux_packet_t *dp; | |
19952
9f95bc4b361a
int->unsigned to avoid crash to sign extension, partially fixes bug #580
reimar
parents:
18505
diff
changeset
|
875 unsigned vpkg_header, vpkg_length, vpkg_offset; |
7710 | 876 int vpkg_seqnum=-1; |
877 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
|
878 |
6916 | 879 while(len>2){ |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
880 dp_hdr_t* dp_hdr; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
881 unsigned char* dp_data; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
882 uint32_t* extra; |
6916 | 883 |
884 // 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
|
885 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
886 // read packet header |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
887 // 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
|
888 // 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
|
889 vpkg_header=stream_read_char(demuxer->stream); --len; |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
890 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "hdr: %02X (len=%d) ",vpkg_header,len); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
891 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
892 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
|
893 // 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
|
894 // 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
|
895 int bummer; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
896 bummer=stream_read_char(demuxer->stream); --len; |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
897 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "%02X",bummer); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
898 vpkg_offset=0; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
899 vpkg_length=len; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
900 } else { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
901 |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
902 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
|
903 // 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
|
904 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
|
905 --len; |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
906 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "subseq: %02X ",vpkg_subseq); |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
907 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
|
908 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
909 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
910 // 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
|
911 // 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
|
912 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
|
913 len-=2; |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
914 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "l: %02X %02X ",vpkg_length>>8,vpkg_length&0xff); |
6916 | 915 if (!(vpkg_length&0xC000)) { |
916 vpkg_length<<=16; | |
19954
f3f751f50ccf
Missing part of previous patch to demux_real.c (revision 19958)
reimar
parents:
19952
diff
changeset
|
917 vpkg_length|=(uint16_t)stream_read_word(demuxer->stream); |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
918 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "l+: %02X %02X ",(vpkg_length>>8)&0xff,vpkg_length&0xff); |
6344 | 919 len-=2; |
920 } else | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
921 vpkg_length&=0x3fff; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
922 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
923 // 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
|
924 // 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
|
925 // _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
|
926 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
|
927 len-=2; |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
928 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "o: %02X %02X ",vpkg_offset>>8,vpkg_offset&0xff); |
6916 | 929 if (!(vpkg_offset&0xC000)) { |
930 vpkg_offset<<=16; | |
19954
f3f751f50ccf
Missing part of previous patch to demux_real.c (revision 19958)
reimar
parents:
19952
diff
changeset
|
931 vpkg_offset|=(uint16_t)stream_read_word(demuxer->stream); |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
932 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "o+: %02X %02X ",(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
|
933 len-=2; |
6344 | 934 } else |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
935 vpkg_offset&=0x3fff; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
936 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
937 vpkg_seqnum=stream_read_char(demuxer->stream); --len; |
10735
8a10d5d0ce86
serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents:
10508
diff
changeset
|
938 mp_dbg(MSGT_DEMUX,MSGL_DBG2, "seq: %02X ",vpkg_seqnum); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
939 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
940 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
|
941 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
|
942 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
|
943 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
|
944 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
945 if(ds->asf_packet){ |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
946 dp=ds->asf_packet; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
947 dp_hdr=(dp_hdr_t*)dp->buffer; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
948 dp_data=dp->buffer+sizeof(dp_hdr_t); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
949 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
|
950 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
|
951 // 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
|
952 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
|
953 // this fragment is for new packet, close the old one |
6423 | 954 mp_msg(MSGT_DEMUX,MSGL_DBG2, "closing probably incomplete packet, len: %d \n",dp->len); |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
955 queue_video_packet(priv, ds, dp); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
956 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
|
957 } else { |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
958 // append data to it! |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
959 ++dp_hdr->chunks; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
960 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
|
961 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
|
962 // increase buffer size, this should not happen! |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
963 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
|
964 dp->len=dp_hdr->chunktab+8*(4+dp_hdr->chunks); |
27282
16beae919ff1
Avoid including avcodec.h in demuxer.h (and thus many other files) just to get
reimar
parents:
27269
diff
changeset
|
965 dp->buffer=realloc(dp->buffer,dp->len+MP_INPUT_BUFFER_PADDING_SIZE); |
16beae919ff1
Avoid including avcodec.h in demuxer.h (and thus many other files) just to get
reimar
parents:
27269
diff
changeset
|
966 memset(dp->buffer + dp->len, 0, MP_INPUT_BUFFER_PADDING_SIZE); |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
967 // re-calc pointers: |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
968 dp_hdr=(dp_hdr_t*)dp->buffer; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
969 dp_data=dp->buffer+sizeof(dp_hdr_t); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
970 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
|
971 } |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
972 extra[2*dp_hdr->chunks+0]=le2me_32(1); |
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
973 extra[2*dp_hdr->chunks+1]=le2me_32(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
|
974 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
|
975 // last fragment! |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
976 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
|
977 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); |
27643 | 978 if (vpkg_offset > dp->len - sizeof(dp_hdr_t) - dp_hdr->len) vpkg_offset = dp->len - sizeof(dp_hdr_t) - dp_hdr->len; |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
979 stream_read(demuxer->stream, dp_data+dp_hdr->len, vpkg_offset); |
9553
6886b16ac5d1
Redundant packet ignoring is RV30-only (at least frame-header flag 0x20 is)
arpi
parents:
9543
diff
changeset
|
980 if((dp_data[dp_hdr->len]&0x20) && (sh_video->format==0x30335652)) --dp_hdr->chunks; else |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
981 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
|
982 len-=vpkg_offset; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
983 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
|
984 // we know that this is the last fragment -> we can close the packet! |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
985 queue_video_packet(priv, ds, dp); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
986 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
|
987 // continue parsing |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
988 continue; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
989 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
990 // non-last fragment: |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
991 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
|
992 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); |
27643 | 993 if (len > dp->len - sizeof(dp_hdr_t) - dp_hdr->len) len = dp->len - sizeof(dp_hdr_t) - dp_hdr->len; |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
994 stream_read(demuxer->stream, dp_data+dp_hdr->len, len); |
9553
6886b16ac5d1
Redundant packet ignoring is RV30-only (at least frame-header flag 0x20 is)
arpi
parents:
9543
diff
changeset
|
995 if((dp_data[dp_hdr->len]&0x20) && (sh_video->format==0x30335652)) --dp_hdr->chunks; else |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
996 dp_hdr->len+=len; |
6916 | 997 len=0; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
998 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
|
999 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1000 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1001 // create new packet! |
7084 | 1002 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
|
1003 // the timestamp seems to be in milliseconds |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1004 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
|
1005 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
|
1006 ds->asf_seq = vpkg_seqnum; |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1007 dp_hdr=(dp_hdr_t*)dp->buffer; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1008 dp_hdr->chunks=0; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1009 dp_hdr->timestamp=timestamp; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1010 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
|
1011 dp_data=dp->buffer+sizeof(dp_hdr_t); |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1012 extra=(uint32_t*)(dp->buffer+dp_hdr->chunktab); |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
1013 extra[0]=le2me_32(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
|
1014 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
|
1015 // first fragment: |
27643 | 1016 if (len > dp->len - sizeof(dp_hdr_t)) len = dp->len - sizeof(dp_hdr_t); |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1017 dp_hdr->len=len; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1018 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
|
1019 ds->asf_packet=dp; |
6916 | 1020 len=0; |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1021 break; |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1022 } |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1023 // whole packet (not fragmented): |
11870 | 1024 if (vpkg_length > len) { |
1025 mp_msg(MSGT_DEMUX, MSGL_WARN,"\n******** WARNING: vpkg_length=%i > len=%i ********\n", vpkg_length, len); | |
1026 /* | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1027 * To keep the video stream rolling, we need to break |
11870 | 1028 * here. We shouldn't touch len to make sure rest of the |
1029 * broken packet is skipped. | |
1030 */ | |
1031 break; | |
1032 } | |
7081
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1033 dp_hdr->len=vpkg_length; len-=vpkg_length; |
66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
arpi
parents:
6995
diff
changeset
|
1034 stream_read(demuxer->stream, dp_data, vpkg_length); |
28468
b9da026ee222
change internal real video packetizing format to the more straight forward one
aurel
parents:
28051
diff
changeset
|
1035 queue_video_packet(priv, ds, dp); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1036 |
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1037 } // while(len>0) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1038 |
6916 | 1039 if(len){ |
11870 | 1040 mp_msg(MSGT_DEMUX, MSGL_WARN,"\n******** !!!!!!!! BUG!! len=%d !!!!!!!!!!! ********\n",len); |
6916 | 1041 if(len>0) stream_skip(demuxer->stream, len); |
1042 } | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1043 } |
28549 | 1044 if ((unsigned)demuxer->video->id < MAX_STREAMS) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1045 while (priv->current_vpacket + 1 < priv->index_table_size[demuxer->video->id] && |
28549 | 1046 timestamp > priv->index_table[demuxer->video->id][priv->current_vpacket + 1].timestamp) { |
11441 | 1047 priv->current_vpacket += 1; |
14402 | 1048 priv->stream_switch = 1; |
1049 } | |
28549 | 1050 if (priv->stream_switch) |
1051 priv->video_curpos = stream_tell(demuxer->stream); | |
1052 } | |
1053 | |
7710 | 1054 return 1; |
4235 | 1055 } |
3777 | 1056 |
18106
3a34a728fa1b
always cast stream IDs to unsigned before comparing to MAX_STREAMS.
reimar
parents:
17977
diff
changeset
|
1057 if((unsigned)stream_id<MAX_STREAMS){ |
8927 | 1058 |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1059 if(demuxer->audio->id==-1 && demuxer->a_streams[stream_id]){ |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1060 sh_audio_t *sh = demuxer->a_streams[stream_id]; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1061 demuxer->audio->id=stream_id; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1062 sh->ds=demuxer->audio; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1063 demuxer->audio->sh=sh; |
18505
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1064 priv->audio_buf = calloc(priv->sub_packet_h[demuxer->audio->id], priv->audiopk_size[demuxer->audio->id]); |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
1065 priv->audio_timestamp = calloc(priv->sub_packet_h[demuxer->audio->id], sizeof(double)); |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1066 mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected RM audio ID = %d\n",stream_id); |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1067 goto got_audio; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1068 } |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1069 |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1070 if(demuxer->video->id==-1 && demuxer->v_streams[stream_id]){ |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1071 sh_video_t *sh = demuxer->v_streams[stream_id]; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1072 demuxer->video->id=stream_id; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1073 sh->ds=demuxer->video; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1074 demuxer->video->sh=sh; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1075 mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected RM video ID = %d\n",stream_id); |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1076 goto got_video; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1077 } |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1078 |
8927 | 1079 } |
1080 | |
7710 | 1081 mp_msg(MSGT_DEMUX,MSGL_DBG2, "unknown stream id (%d)\n", stream_id); |
11441 | 1082 discard: |
7710 | 1083 stream_skip(demuxer->stream, len); |
1084 }// goto loop; | |
19960
5928bd5c7f0b
Make fill_buffer function check for stream eof, fixes hang at eof (bug #580)
reimar
parents:
19954
diff
changeset
|
1085 return 0; |
3777 | 1086 } |
1087 | |
16175 | 1088 static demuxer_t* demux_open_real(demuxer_t* demuxer) |
3777 | 1089 { |
1090 real_priv_t* priv = demuxer->priv; | |
1091 int num_of_headers; | |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1092 int a_streams=0; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1093 int v_streams=0; |
3777 | 1094 int i; |
11797
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1095 int header_size; |
3777 | 1096 |
11797
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1097 header_size = stream_read_dword(demuxer->stream); /* header size */ |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1098 mp_msg(MSGT_DEMUX,MSGL_V, "real: Header size: %d\n", header_size); |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1099 i = stream_read_word(demuxer->stream); /* version */ |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1100 mp_msg(MSGT_DEMUX,MSGL_V, "real: Header object version: %d\n", i); |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1101 if (header_size == 0x10) |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1102 i = stream_read_word(demuxer->stream); |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1103 else /* we should test header_size here too. */ |
571295c177d2
Fix for Real files with header size == 0x10 (normally is 0x12)
rtognimp
parents:
11606
diff
changeset
|
1104 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
|
1105 mp_msg(MSGT_DEMUX,MSGL_V, "real: File version: %d\n", i); |
3777 | 1106 num_of_headers = stream_read_dword(demuxer->stream); |
1107 | |
1108 /* parse chunks */ | |
10508
e2a88f1d47f6
BBC .rm fix, based on patch by Balatoni Denes <pnis@coder.hu>
arpi
parents:
10368
diff
changeset
|
1109 for (i = 1; i <= num_of_headers; i++) |
e2a88f1d47f6
BBC .rm fix, based on patch by Balatoni Denes <pnis@coder.hu>
arpi
parents:
10368
diff
changeset
|
1110 // for (i = 1; ; i++) |
3777 | 1111 { |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1112 int chunk_id, chunk_pos, chunk_size; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1113 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1114 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
|
1115 chunk_id = stream_read_dword_le(demuxer->stream); |
3777 | 1116 chunk_size = stream_read_dword(demuxer->stream); |
1117 | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1118 stream_skip(demuxer->stream, 2); /* version */ |
7710 | 1119 |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1120 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
|
1121 (char *)&chunk_id, chunk_id, chunk_size, chunk_pos); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1122 |
29247
fe871e69b1b3
chunk size = 0 is valid for DATA chunks (used in live streams), don't
rtogni
parents:
29238
diff
changeset
|
1123 if (chunk_id != MKTAG('D', 'A', 'T', 'A') && chunk_size < 10){ |
7710 | 1124 mp_msg(MSGT_DEMUX,MSGL_ERR,"demux_real: invalid chunksize! (%d)\n",chunk_size); |
8569 | 1125 break; //return; |
7710 | 1126 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1127 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1128 switch(chunk_id) |
3777 | 1129 { |
1130 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
|
1131 /* Properties header */ |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1132 |
3777 | 1133 stream_skip(demuxer->stream, 4); /* max bitrate */ |
1134 stream_skip(demuxer->stream, 4); /* avg bitrate */ | |
1135 stream_skip(demuxer->stream, 4); /* max packet size */ | |
1136 stream_skip(demuxer->stream, 4); /* avg packet size */ | |
1137 stream_skip(demuxer->stream, 4); /* nb packets */ | |
11441 | 1138 priv->duration = stream_read_dword(demuxer->stream)/1000; /* duration */ |
3777 | 1139 stream_skip(demuxer->stream, 4); /* preroll */ |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1140 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
|
1141 mp_msg(MSGT_DEMUX,MSGL_V,"First index chunk offset: 0x%x\n", priv->index_chunk_offset); |
3795 | 1142 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
|
1143 mp_msg(MSGT_DEMUX,MSGL_V,"First data chunk offset: 0x%x\n", priv->data_chunk_offset); |
3777 | 1144 stream_skip(demuxer->stream, 2); /* nb streams */ |
3795 | 1145 #if 0 |
3777 | 1146 stream_skip(demuxer->stream, 2); /* flags */ |
3795 | 1147 #else |
1148 { | |
1149 int flags = stream_read_word(demuxer->stream); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1150 |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1151 if (flags) |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1152 { |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1153 mp_msg(MSGT_DEMUX,MSGL_V,"Flags (%x): ", flags); |
3795 | 1154 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
|
1155 mp_msg(MSGT_DEMUX,MSGL_V,"[save allowed] "); |
3795 | 1156 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
|
1157 mp_msg(MSGT_DEMUX,MSGL_V,"[perfect play (more buffers)] "); |
3795 | 1158 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
|
1159 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
|
1160 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
|
1161 } |
3795 | 1162 } |
1163 #endif | |
3777 | 1164 break; |
1165 case MKTAG('C', 'O', 'N', 'T'): | |
3788 | 1166 { |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1167 /* Content description header */ |
3788 | 1168 char *buf; |
1169 int len; | |
1170 | |
1171 len = stream_read_word(demuxer->stream); | |
1172 if (len > 0) | |
1173 { | |
1174 buf = malloc(len+1); | |
1175 stream_read(demuxer->stream, buf, len); | |
5810 | 1176 buf[len] = 0; |
29288
4a1c217a844b
In all demux_info_add calls change "name" to "title".
reimar
parents:
29263
diff
changeset
|
1177 demux_info_add(demuxer, "title", buf); |
3788 | 1178 free(buf); |
1179 } | |
1180 | |
1181 len = stream_read_word(demuxer->stream); | |
1182 if (len > 0) | |
1183 { | |
1184 buf = malloc(len+1); | |
1185 stream_read(demuxer->stream, buf, len); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1186 buf[len] = 0; |
3788 | 1187 demux_info_add(demuxer, "author", buf); |
1188 free(buf); | |
1189 } | |
1190 | |
1191 len = stream_read_word(demuxer->stream); | |
1192 if (len > 0) | |
1193 { | |
1194 buf = malloc(len+1); | |
1195 stream_read(demuxer->stream, buf, len); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1196 buf[len] = 0; |
3788 | 1197 demux_info_add(demuxer, "copyright", buf); |
1198 free(buf); | |
1199 } | |
1200 | |
1201 len = stream_read_word(demuxer->stream); | |
1202 if (len > 0) | |
1203 { | |
1204 buf = malloc(len+1); | |
1205 stream_read(demuxer->stream, buf, len); | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1206 buf[len] = 0; |
3788 | 1207 demux_info_add(demuxer, "comment", buf); |
1208 free(buf); | |
1209 } | |
3777 | 1210 break; |
3788 | 1211 } |
3777 | 1212 case MKTAG('M', 'D', 'P', 'R'): |
1213 { | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1214 /* Media properties header */ |
3777 | 1215 int stream_id; |
1216 int bitrate; | |
1217 int codec_data_size; | |
1218 int codec_pos; | |
3795 | 1219 int tmp; |
14402 | 1220 int len; |
17788
2fe769b4b30b
Fix potential read from an unitialized pointer (CID: 236)
rtognimp
parents:
17776
diff
changeset
|
1221 char *descr, *mimet = NULL; |
3777 | 1222 |
1223 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
|
1224 mp_msg(MSGT_DEMUX,MSGL_V,"Found new stream (id: %d)\n", stream_id); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1225 |
3777 | 1226 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
|
1227 bitrate = stream_read_dword(demuxer->stream); /* avg bitrate */ |
3777 | 1228 stream_skip(demuxer->stream, 4); /* max packet size */ |
1229 stream_skip(demuxer->stream, 4); /* avg packet size */ | |
1230 stream_skip(demuxer->stream, 4); /* start time */ | |
1231 stream_skip(demuxer->stream, 4); /* preroll */ | |
1232 stream_skip(demuxer->stream, 4); /* duration */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1233 |
14402 | 1234 if ((len = stream_read_char(demuxer->stream)) > 0) { |
1235 descr = malloc(len+1); | |
1236 stream_read(demuxer->stream, descr, len); | |
1237 descr[len] = 0; | |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
18106
diff
changeset
|
1238 mp_msg(MSGT_DEMUX, MSGL_INFO,"Stream description: %s\n", descr); |
14402 | 1239 free(descr); |
1240 } | |
1241 if ((len = stream_read_char(demuxer->stream)) > 0) { | |
1242 mimet = malloc(len+1); | |
1243 stream_read(demuxer->stream, mimet, len); | |
1244 mimet[len] = 0; | |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
18106
diff
changeset
|
1245 mp_msg(MSGT_DEMUX, MSGL_INFO,"Stream mimetype: %s\n", mimet); |
14402 | 1246 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1247 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1248 /* Type specific header */ |
3777 | 1249 codec_data_size = stream_read_dword(demuxer->stream); |
1250 codec_pos = stream_tell(demuxer->stream); | |
1251 | |
7710 | 1252 #ifdef MP_DEBUG |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1253 #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");} |
7710 | 1254 #endif |
1255 | |
14402 | 1256 if (!strncmp(mimet,"audio/",6)) { |
1257 if (strstr(mimet,"x-pn-realaudio") || strstr(mimet,"x-pn-multirate-realaudio")) { | |
1258 tmp = stream_read_dword(demuxer->stream); | |
1259 if (tmp != MKTAG(0xfd, 'a', 'r', '.')) | |
3777 | 1260 { |
14402 | 1261 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: can't find .ra in codec data\n"); |
1262 } else { | |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1263 /* audio header */ |
31609
cd81fce1f010
Make the stream language an argument to the stream creation function
reimar
parents:
31465
diff
changeset
|
1264 sh_audio_t *sh = new_sh_audio(demuxer, stream_id, NULL); |
3795 | 1265 char buf[128]; /* for codec name */ |
1266 int frame_size; | |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1267 int sub_packet_size; |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1268 int sub_packet_h; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1269 int version; |
6369 | 1270 int flavor; |
8094 | 1271 int coded_frame_size; |
1272 int codecdata_length; | |
11989
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1273 int i; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1274 char *buft; |
12327
fac1637c2c37
Fix for 28_8 in rm files and header length != 0x4e
rtognimp
parents:
12076
diff
changeset
|
1275 int hdr_size; |
23089 | 1276 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "real", stream_id); |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1277 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
|
1278 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
|
1279 mp_msg(MSGT_DEMUX,MSGL_V,"version: %d\n", version); |
11989
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1280 if (version == 3) { |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1281 stream_skip(demuxer->stream, 2); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1282 stream_skip(demuxer->stream, 10); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1283 stream_skip(demuxer->stream, 4); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1284 // Name, author, (c) are also in CONT tag |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1285 if ((i = stream_read_char(demuxer->stream)) != 0) { |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1286 buft = malloc(i+1); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1287 stream_read(demuxer->stream, buft, i); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1288 buft[i] = 0; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1289 demux_info_add(demuxer, "Name", buft); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1290 free(buft); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1291 } |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1292 if ((i = stream_read_char(demuxer->stream)) != 0) { |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1293 buft = malloc(i+1); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1294 stream_read(demuxer->stream, buft, i); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1295 buft[i] = 0; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1296 demux_info_add(demuxer, "Author", buft); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1297 free(buft); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1298 } |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1299 if ((i = stream_read_char(demuxer->stream)) != 0) { |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1300 buft = malloc(i+1); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1301 stream_read(demuxer->stream, buft, i); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1302 buft[i] = 0; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1303 demux_info_add(demuxer, "Copyright", buft); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1304 free(buft); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1305 } |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1306 if ((i = stream_read_char(demuxer->stream)) != 0) |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1307 mp_msg(MSGT_DEMUX,MSGL_WARN,"Last header byte is not zero!\n"); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1308 stream_skip(demuxer->stream, 1); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1309 i = stream_read_char(demuxer->stream); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1310 sh->format = stream_read_dword_le(demuxer->stream); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1311 if (i != 4) { |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1312 mp_msg(MSGT_DEMUX,MSGL_WARN,"Audio FourCC size is not 4 (%d), please report to " |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1313 "MPlayer developers\n", i); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1314 stream_skip(demuxer->stream, i - 4); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1315 } |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1316 if (sh->format != mmioFOURCC('l','p','c','J')) { |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1317 mp_msg(MSGT_DEMUX,MSGL_WARN,"Version 3 audio with FourCC %8x, please report to " |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1318 "MPlayer developers\n", sh->format); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1319 } |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1320 sh->channels = 1; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1321 sh->samplesize = 16; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1322 sh->samplerate = 8000; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1323 frame_size = 240; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1324 strcpy(buf, "14_4"); |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1325 } else { |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1326 stream_skip(demuxer->stream, 2); // 00 00 |
3788 | 1327 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
|
1328 stream_skip(demuxer->stream, 4); // ??? |
3788 | 1329 stream_skip(demuxer->stream, 2); /* version (4 or 5) */ |
12327
fac1637c2c37
Fix for 28_8 in rm files and header length != 0x4e
rtognimp
parents:
12076
diff
changeset
|
1330 hdr_size = stream_read_dword(demuxer->stream); // header size |
fac1637c2c37
Fix for 28_8 in rm files and header length != 0x4e
rtognimp
parents:
12076
diff
changeset
|
1331 mp_msg(MSGT_DEMUX,MSGL_V,"header size: %d\n", hdr_size); |
6369 | 1332 flavor = stream_read_word(demuxer->stream);/* codec flavor id */ |
8094 | 1333 coded_frame_size = stream_read_dword(demuxer->stream);/* needed by codec */ |
17401
d624a0a191f3
Print some more useful data from header in verbose mode
rtognimp
parents:
17394
diff
changeset
|
1334 mp_msg(MSGT_DEMUX,MSGL_V,"coded_frame_size: %d\n", coded_frame_size); |
6369 | 1335 stream_skip(demuxer->stream, 4); // big number |
1336 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
|
1337 stream_skip(demuxer->stream, 4); // 2 || -''- |
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1338 sub_packet_h = stream_read_word(demuxer->stream); |
17401
d624a0a191f3
Print some more useful data from header in verbose mode
rtognimp
parents:
17394
diff
changeset
|
1339 mp_msg(MSGT_DEMUX,MSGL_V,"sub_packet_h: %d\n", sub_packet_h); |
3795 | 1340 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
|
1341 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
|
1342 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
|
1343 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
|
1344 stream_skip(demuxer->stream, 2); // 0 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1345 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1346 if (version == 5) |
6369 | 1347 stream_skip(demuxer->stream, 6); //0,srate,0 |
3777 | 1348 |
1349 sh->samplerate = stream_read_word(demuxer->stream); | |
6369 | 1350 stream_skip(demuxer->stream, 2); // 0 |
1351 sh->samplesize = stream_read_word(demuxer->stream)/8; | |
3777 | 1352 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
|
1353 mp_msg(MSGT_DEMUX,MSGL_V,"samplerate: %d, channels: %d\n", |
3877 | 1354 sh->samplerate, sh->channels); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1355 |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1356 if (version == 5) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1357 { |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1358 stream_read(demuxer->stream, buf, 4); // interleaver id |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1359 priv->intl_id[stream_id] = MKTAG(buf[0], buf[1], buf[2], buf[3]); |
6369 | 1360 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
|
1361 buf[4] = 0; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1362 } |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1363 else |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1364 { |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1365 /* Interleaver id */ |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1366 get_str(1, demuxer, buf, sizeof(buf)); |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1367 priv->intl_id[stream_id] = MKTAG(buf[0], buf[1], buf[2], buf[3]); |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1368 /* Codec FourCC */ |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1369 get_str(1, demuxer, buf, sizeof(buf)); |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1370 } |
11989
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1371 } |
3777 | 1372 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1373 /* Emulate WAVEFORMATEX struct: */ |
32109 | 1374 sh->wf = calloc(1, sizeof(*sh->wf)); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1375 sh->wf->nChannels = sh->channels; |
6369 | 1376 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
|
1377 sh->wf->nSamplesPerSec = sh->samplerate; |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1378 sh->wf->nAvgBytesPerSec = bitrate/8; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1379 sh->wf->nBlockAlign = frame_size; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1380 sh->wf->cbSize = 0; |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1381 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
|
1382 |
6374
b2d5aeb72f95
export subpacket-size and matrix w*h to the codec (cook)
arpi
parents:
6369
diff
changeset
|
1383 switch (sh->format) |
3795 | 1384 { |
1385 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
|
1386 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: DNET -> AC3\n"); |
10118 | 1387 // sh->format = 0x2000; |
3795 | 1388 break; |
10032 | 1389 case MKTAG('1', '4', '_', '4'): |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1390 sh->wf->nBlockAlign = 0x14; |
11989
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1391 break; |
644d59147048
Support for v3 audio section (used with 14_4 codec) in real files
rtognimp
parents:
11886
diff
changeset
|
1392 |
10032 | 1393 case MKTAG('2', '8', '_', '8'): |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1394 sh->wf->nBlockAlign = coded_frame_size; |
12327
fac1637c2c37
Fix for 28_8 in rm files and header length != 0x4e
rtognimp
parents:
12076
diff
changeset
|
1395 break; |
fac1637c2c37
Fix for 28_8 in rm files and header length != 0x4e
rtognimp
parents:
12076
diff
changeset
|
1396 |
3795 | 1397 case MKTAG('s', 'i', 'p', 'r'): |
8094 | 1398 case MKTAG('a', 't', 'r', 'c'): |
3795 | 1399 case MKTAG('c', 'o', 'o', 'k'): |
8094 | 1400 // realaudio codec plugins - common: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1401 stream_skip(demuxer->stream,3); // Skip 3 unknown bytes |
8094 | 1402 if (version==5) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1403 stream_skip(demuxer->stream,1); // Skip 1 additional unknown byte |
8094 | 1404 codecdata_length=stream_read_dword(demuxer->stream); |
18505
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1405 // Check extradata len, we can't store bigger values in cbSize anyway |
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1406 if ((unsigned)codecdata_length > 0xffff) { |
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1407 mp_msg(MSGT_DEMUX,MSGL_ERR,"Extradata too big (%d)\n", codecdata_length); |
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1408 goto skip_this_chunk; |
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1409 } |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1410 sh->wf->cbSize = codecdata_length; |
32109 | 1411 sh->wf = realloc(sh->wf, sizeof(*sh->wf)+sh->wf->cbSize); |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1412 stream_read(demuxer->stream, ((char*)(sh->wf+1)), codecdata_length); // extras |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1413 if (priv->intl_id[stream_id] == MKTAG('g', 'e', 'n', 'r')) |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1414 sh->wf->nBlockAlign = sub_packet_size; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1415 else |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1416 sh->wf->nBlockAlign = coded_frame_size; |
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1417 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1418 break; |
17149
9a0a376a54b1
Move audio packets reordering from codec interface to demuxers for real
rtognimp
parents:
16877
diff
changeset
|
1419 |
11877 | 1420 case MKTAG('r', 'a', 'a', 'c'): |
1421 case MKTAG('r', 'a', 'c', 'p'): | |
1422 /* This is just AAC. The two or five bytes of */ | |
1423 /* config data needed for libfaad are stored */ | |
1424 /* after the audio headers. */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1425 stream_skip(demuxer->stream,3); // Skip 3 unknown bytes |
11877 | 1426 if (version==5) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1427 stream_skip(demuxer->stream,1); // Skip 1 additional unknown byte |
11877 | 1428 codecdata_length=stream_read_dword(demuxer->stream); |
1429 if (codecdata_length>=1) { | |
1430 sh->codecdata_len = codecdata_length - 1; | |
1431 sh->codecdata = calloc(sh->codecdata_len, 1); | |
1432 stream_skip(demuxer->stream, 1); | |
1433 stream_read(demuxer->stream, sh->codecdata, sh->codecdata_len); | |
1434 } | |
1435 sh->format = mmioFOURCC('M', 'P', '4', 'A'); | |
1436 break; | |
3795 | 1437 default: |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1438 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: Unknown (%s)\n", buf); |
3777 | 1439 } |
1440 | |
21989
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1441 // Interleaver setup |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1442 priv->sub_packet_size[stream_id] = sub_packet_size; |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1443 priv->sub_packet_h[stream_id] = sub_packet_h; |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1444 priv->coded_framesize[stream_id] = coded_frame_size; |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1445 priv->audiopk_size[stream_id] = frame_size; |
c3dc45e16aa3
Use interleaver id to select the correct interleaver instead of guessing
rtogni
parents:
21421
diff
changeset
|
1446 |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1447 sh->wf->wFormatTag = sh->format; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1448 |
17388
002e4923d5ab
Print audio 4cc for every stream, print 4cc of selected audio track
rtognimp
parents:
17366
diff
changeset
|
1449 mp_msg(MSGT_DEMUX,MSGL_V,"audio fourcc: %.4s (%x)\n", (char *)&sh->format, sh->format); |
17932 | 1450 if ( mp_msg_test(MSGT_DEMUX,MSGL_V) ) |
17977
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
17932
diff
changeset
|
1451 print_wave_header(sh->wf, MSGL_V); |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1452 |
14402 | 1453 /* Select audio stream with highest bitrate if multirate file*/ |
1454 if (priv->is_multirate && ((demuxer->audio->id == -1) || | |
1455 ((demuxer->audio->id >= 0) && priv->a_bitrate && (bitrate > priv->a_bitrate)))) { | |
1456 demuxer->audio->id = stream_id; | |
1457 priv->a_bitrate = bitrate; | |
1458 mp_msg(MSGT_DEMUX,MSGL_DBG2,"Multirate autoselected audio id %d with bitrate %d\n", stream_id, bitrate); | |
1459 } | |
1460 | |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1461 if(demuxer->audio->id==stream_id){ |
7710 | 1462 sh->ds=demuxer->audio; |
1463 demuxer->audio->sh=sh; | |
18505
01b9f29c2fb5
Fix some potential integer overflow in memory allocation (mot of these
rtognimp
parents:
18444
diff
changeset
|
1464 priv->audio_buf = calloc(priv->sub_packet_h[demuxer->audio->id], priv->audiopk_size[demuxer->audio->id]); |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
1465 priv->audio_timestamp = calloc(priv->sub_packet_h[demuxer->audio->id], sizeof(double)); |
3777 | 1466 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1467 |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1468 ++a_streams; |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1469 |
7710 | 1470 #ifdef stream_skip |
6369 | 1471 #undef stream_skip |
7710 | 1472 #endif |
3777 | 1473 } |
14498 | 1474 } else if (strstr(mimet,"X-MP3-draft-00")) { |
31609
cd81fce1f010
Make the stream language an argument to the stream creation function
reimar
parents:
31465
diff
changeset
|
1475 sh_audio_t *sh = new_sh_audio(demuxer, stream_id, NULL); |
23010
74efb0fa8a0b
with -identify show audio and video id; patch by Andrew Savchenko (Bircoph list ru)
nicodvb
parents:
22605
diff
changeset
|
1476 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "real", stream_id); |
14402 | 1477 |
1478 /* Emulate WAVEFORMATEX struct: */ | |
32109 | 1479 sh->wf = calloc(1, sizeof(*sh->wf)); |
14402 | 1480 sh->wf->nChannels = 0;//sh->channels; |
1481 sh->wf->wBitsPerSample = 16; | |
1482 sh->wf->nSamplesPerSec = 0;//sh->samplerate; | |
1483 sh->wf->nAvgBytesPerSec = 0;//bitrate; | |
1484 sh->wf->nBlockAlign = 0;//frame_size; | |
1485 sh->wf->cbSize = 0; | |
14498 | 1486 sh->wf->wFormatTag = sh->format = mmioFOURCC('a','d','u',0x55); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1487 |
14402 | 1488 if(demuxer->audio->id==stream_id){ |
1489 sh->ds=demuxer->audio; | |
1490 demuxer->audio->sh=sh; | |
1491 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1492 |
14402 | 1493 ++a_streams; |
1494 } else if (strstr(mimet,"x-ralf-mpeg4")) { | |
1495 mp_msg(MSGT_DEMUX,MSGL_ERR,"Real lossless audio not supported yet\n"); | |
25027 | 1496 } else if (strstr(mimet,"x-pn-encrypted-ra")) { |
1497 mp_msg(MSGT_DEMUX,MSGL_ERR,"Encrypted audio is not supported\n"); | |
14402 | 1498 } else { |
1499 mp_msg(MSGT_DEMUX,MSGL_V,"Unknown audio stream format\n"); | |
1500 } | |
1501 } else if (!strncmp(mimet,"video/",6)) { | |
1502 if (strstr(mimet,"x-pn-realvideo") || strstr(mimet,"x-pn-multirate-realvideo")) { | |
20159
5bb2619601f2
Remove old hack to search for .ar and VIDO, we know where they are
rtogni
parents:
20144
diff
changeset
|
1503 stream_skip(demuxer->stream, 4); // VIDO length, same as codec_data_size |
14402 | 1504 tmp = stream_read_dword(demuxer->stream); |
1505 if(tmp != MKTAG('O', 'D', 'I', 'V')) | |
3777 | 1506 { |
14402 | 1507 mp_msg(MSGT_DEMUX,MSGL_V,"Video: can't find VIDO in codec data\n"); |
1508 } else { | |
3777 | 1509 /* video header */ |
1510 sh_video_t *sh = new_sh_video(demuxer, stream_id); | |
23010
74efb0fa8a0b
with -identify show audio and video id; patch by Andrew Savchenko (Bircoph list ru)
nicodvb
parents:
22605
diff
changeset
|
1511 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "real", stream_id); |
3777 | 1512 |
1513 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
|
1514 mp_msg(MSGT_DEMUX,MSGL_V,"video fourcc: %.4s (%x)\n", (char *)&sh->format, sh->format); |
3777 | 1515 |
3795 | 1516 /* emulate BITMAPINFOHEADER */ |
32109 | 1517 sh->bih = calloc(1, sizeof(*sh->bih)); |
1518 sh->bih->biSize = sizeof(*sh->bih); | |
3777 | 1519 sh->disp_w = sh->bih->biWidth = stream_read_word(demuxer->stream); |
1520 sh->disp_h = sh->bih->biHeight = stream_read_word(demuxer->stream); | |
1521 sh->bih->biPlanes = 1; | |
1522 sh->bih->biBitCount = 24; | |
1523 sh->bih->biCompression = sh->format; | |
1524 sh->bih->biSizeImage= sh->bih->biWidth*sh->bih->biHeight*3; | |
1525 | |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1526 sh->fps = (float) stream_read_word(demuxer->stream); |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1527 if (sh->fps<=0) sh->fps=24; // we probably won't even care about fps |
3777 | 1528 sh->frametime = 1.0f/sh->fps; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1529 |
6344 | 1530 #if 1 |
6414
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1531 stream_skip(demuxer->stream, 4); |
6344 | 1532 #else |
11870 | 1533 mp_msg(MSGT_DEMUX, MSGL_V,"unknown1: 0x%X \n",stream_read_dword(demuxer->stream)); |
1534 mp_msg(MSGT_DEMUX, MSGL_V,"unknown2: 0x%X \n",stream_read_word(demuxer->stream)); | |
1535 mp_msg(MSGT_DEMUX, MSGL_V,"unknown3: 0x%X \n",stream_read_word(demuxer->stream)); | |
6344 | 1536 #endif |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1537 // if(sh->format==0x30335652 || sh->format==0x30325652 ) |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1538 if(1) |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1539 { |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1540 int tmp=stream_read_word(demuxer->stream); |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1541 if(tmp>0){ |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1542 sh->fps=tmp; sh->frametime = 1.0f/sh->fps; |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1543 } |
6414
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1544 } else { |
7710 | 1545 int fps=stream_read_word(demuxer->stream); |
11870 | 1546 mp_msg(MSGT_DEMUX, MSGL_WARN,"realvid: ignoring FPS = %d\n",fps); |
6414
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1547 } |
67c1050a8718
fix fps/frametime parsing - patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6404
diff
changeset
|
1548 stream_skip(demuxer->stream, 2); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1549 |
3777 | 1550 { |
20920 | 1551 // read and store codec extradata |
14568 | 1552 unsigned int cnt = codec_data_size - (stream_tell(demuxer->stream) - codec_pos); |
32109 | 1553 if (cnt > 0x7fffffff - sizeof(*sh->bih)) { |
20920 | 1554 mp_msg(MSGT_DEMUX, MSGL_ERR,"Extradata too big (%u)\n", cnt); |
14568 | 1555 } else { |
32109 | 1556 sh->bih = realloc(sh->bih, sizeof(*sh->bih) + cnt); |
20143 | 1557 sh->bih->biSize += cnt; |
20920 | 1558 stream_read(demuxer->stream, ((unsigned char*)(sh->bih+1)), cnt); |
14568 | 1559 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1560 } |
20920 | 1561 if(sh->format == 0x30315652 && ((unsigned char*)(sh->bih+1))[6] == 0x30) |
1562 sh->bih->biCompression = sh->format = mmioFOURCC('R', 'V', '1', '3'); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1563 |
14402 | 1564 /* Select video stream with highest bitrate if multirate file*/ |
1565 if (priv->is_multirate && ((demuxer->video->id == -1) || | |
1566 ((demuxer->video->id >= 0) && priv->v_bitrate && (bitrate > priv->v_bitrate)))) { | |
1567 demuxer->video->id = stream_id; | |
1568 priv->v_bitrate = bitrate; | |
1569 mp_msg(MSGT_DEMUX,MSGL_DBG2,"Multirate autoselected video id %d with bitrate %d\n", stream_id, bitrate); | |
1570 } | |
1571 | |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1572 if(demuxer->video->id==stream_id){ |
7710 | 1573 sh->ds=demuxer->video; |
1574 demuxer->video->sh=sh; | |
3777 | 1575 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1576 |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1577 ++v_streams; |
7710 | 1578 |
3777 | 1579 } |
14402 | 1580 } else { |
1581 mp_msg(MSGT_DEMUX,MSGL_V,"Unknown video stream format\n"); | |
1582 } | |
1583 } else if (strstr(mimet,"logical-")) { | |
1584 if (strstr(mimet,"fileinfo")) { | |
1585 mp_msg(MSGT_DEMUX,MSGL_V,"Got a logical-fileinfo chunk\n"); | |
1586 } else if (strstr(mimet,"-audio") || strstr(mimet,"-video")) { | |
1587 int i, stream_cnt; | |
1588 int stream_list[MAX_STREAMS]; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1589 |
14402 | 1590 priv->is_multirate = 1; |
1591 stream_skip(demuxer->stream, 4); // Length of codec data (repeated) | |
1592 stream_cnt = stream_read_dword(demuxer->stream); // Get number of audio or video streams | |
18106
3a34a728fa1b
always cast stream IDs to unsigned before comparing to MAX_STREAMS.
reimar
parents:
17977
diff
changeset
|
1593 if ((unsigned)stream_cnt >= MAX_STREAMS) { |
14402 | 1594 mp_msg(MSGT_DEMUX,MSGL_ERR,"Too many streams in %s. Big troubles ahead.\n", mimet); |
1595 goto skip_this_chunk; | |
1596 } | |
1597 for (i = 0; i < stream_cnt; i++) | |
1598 stream_list[i] = stream_read_word(demuxer->stream); | |
1599 for (i = 0; i < stream_cnt; i++) | |
18106
3a34a728fa1b
always cast stream IDs to unsigned before comparing to MAX_STREAMS.
reimar
parents:
17977
diff
changeset
|
1600 if ((unsigned)stream_list[i] >= MAX_STREAMS) { |
14402 | 1601 mp_msg(MSGT_DEMUX,MSGL_ERR,"Stream id out of range: %d. Ignored.\n", stream_list[i]); |
1602 stream_skip(demuxer->stream, 4); // Skip DATA offset for broken stream | |
1603 } else { | |
1604 priv->str_data_offset[stream_list[i]] = stream_read_dword(demuxer->stream); | |
1605 mp_msg(MSGT_DEMUX,MSGL_V,"Stream %d with DATA offset 0x%08x\n", stream_list[i], priv->str_data_offset[stream_list[i]]); | |
1606 } | |
1607 // Skip the rest of this chunk | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1608 } else |
14402 | 1609 mp_msg(MSGT_DEMUX,MSGL_V,"Unknown logical stream\n"); |
1610 } | |
7085
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
1611 else { |
02aa64b49b70
some files has some shit before teh audio/video headers...
arpi
parents:
7084
diff
changeset
|
1612 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
|
1613 } |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1614 // break; |
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1615 // default: |
14402 | 1616 skip_this_chunk: |
3777 | 1617 /* skip codec info */ |
3795 | 1618 tmp = stream_tell(demuxer->stream) - codec_pos; |
6344 | 1619 mp_msg(MSGT_DEMUX,MSGL_V,"### skipping %d bytes of codec info\n", codec_data_size - tmp); |
1620 #if 0 | |
1621 { int i; | |
1622 for(i=0;i<codec_data_size - tmp;i++) | |
11870 | 1623 mp_msg(MSGT_DEMUX, MSGL_V," %02X",stream_read_char(demuxer->stream)); |
1624 mp_msg(MSGT_DEMUX, MSGL_V,"\n"); | |
6344 | 1625 } |
1626 #else | |
3795 | 1627 stream_skip(demuxer->stream, codec_data_size - tmp); |
6344 | 1628 #endif |
14402 | 1629 if (mimet) |
1630 free (mimet); | |
3777 | 1631 break; |
3985
701d18898835
updated/extended some parts, based on RMFF (also initial ATRAC3 hackings and notes)
alex
parents:
3882
diff
changeset
|
1632 // } |
3777 | 1633 } |
1634 case MKTAG('D', 'A', 'T', 'A'): | |
1635 goto header_end; | |
3795 | 1636 case MKTAG('I', 'N', 'D', 'X'): |
3777 | 1637 default: |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1638 mp_msg(MSGT_DEMUX,MSGL_V,"Unknown chunk: %x\n", chunk_id); |
3777 | 1639 stream_skip(demuxer->stream, chunk_size - 10); |
1640 break; | |
1641 } | |
1642 } | |
1643 | |
1644 header_end: | |
14402 | 1645 if(priv->is_multirate) { |
1646 mp_msg(MSGT_DEMUX,MSGL_V,"Selected video id %d audio id %d\n", demuxer->video->id, demuxer->audio->id); | |
1647 /* Perform some sanity checks to avoid checking streams id all over the code*/ | |
1648 if (demuxer->audio->id >= MAX_STREAMS) { | |
1649 mp_msg(MSGT_DEMUX,MSGL_ERR,"Invalid audio stream %d. No sound will be played.\n", demuxer->audio->id); | |
1650 demuxer->audio->id = -2; | |
1651 } else if ((demuxer->audio->id >= 0) && (priv->str_data_offset[demuxer->audio->id] == 0)) { | |
1652 mp_msg(MSGT_DEMUX,MSGL_ERR,"Audio stream %d not found. No sound will be played.\n", demuxer->audio->id); | |
1653 demuxer->audio->id = -2; | |
1654 } | |
1655 if (demuxer->video->id >= MAX_STREAMS) { | |
1656 mp_msg(MSGT_DEMUX,MSGL_ERR,"Invalid video stream %d. No video will be played.\n", demuxer->video->id); | |
1657 demuxer->video->id = -2; | |
1658 } else if ((demuxer->video->id >= 0) && (priv->str_data_offset[demuxer->video->id] == 0)) { | |
1659 mp_msg(MSGT_DEMUX,MSGL_ERR,"Video stream %d not found. No video will be played.\n", demuxer->video->id); | |
1660 demuxer->video->id = -2; | |
1661 } | |
1662 } | |
1663 | |
1664 if(priv->is_multirate && ((demuxer->video->id >= 0) || (demuxer->audio->id >=0))) { | |
1665 /* If audio or video only, seek to right place and behave like standard file */ | |
1666 if (demuxer->video->id < 0) { | |
1667 // Stream is audio only, or -novideo | |
1668 stream_seek(demuxer->stream, priv->data_chunk_offset = priv->str_data_offset[demuxer->audio->id]+10); | |
1669 priv->is_multirate = 0; | |
1670 } | |
1671 if (demuxer->audio->id < 0) { | |
1672 // Stream is video only, or -nosound | |
1673 stream_seek(demuxer->stream, priv->data_chunk_offset = priv->str_data_offset[demuxer->video->id]+10); | |
1674 priv->is_multirate = 0; | |
1675 } | |
1676 } | |
1677 | |
1678 if(!priv->is_multirate) { | |
10508
e2a88f1d47f6
BBC .rm fix, based on patch by Balatoni Denes <pnis@coder.hu>
arpi
parents:
10368
diff
changeset
|
1679 // printf("i=%d num_of_headers=%d \n",i,num_of_headers); |
3777 | 1680 priv->num_of_packets = stream_read_dword(demuxer->stream); |
1681 stream_skip(demuxer->stream, 4); /* next data header */ | |
1682 | |
6340
7f612cf06ba5
sub-packet demuxer for rv20/rv30, patch by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
5918
diff
changeset
|
1683 mp_msg(MSGT_DEMUX,MSGL_V,"Packets in file: %d\n", priv->num_of_packets); |
3777 | 1684 |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1685 if (priv->num_of_packets == 0) |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1686 priv->num_of_packets = -10; |
14402 | 1687 } else { |
1688 priv->audio_curpos = priv->str_data_offset[demuxer->audio->id] + 18; | |
1689 stream_seek(demuxer->stream, priv->str_data_offset[demuxer->audio->id]+10); | |
1690 priv->a_num_of_packets=priv->a_num_of_packets = stream_read_dword(demuxer->stream); | |
1691 priv->video_curpos = priv->str_data_offset[demuxer->video->id] + 18; | |
1692 stream_seek(demuxer->stream, priv->str_data_offset[demuxer->video->id]+10); | |
1693 priv->v_num_of_packets = stream_read_dword(demuxer->stream); | |
1694 priv->stream_switch = 1; | |
1695 /* Index required for multirate playback, force building if it's not there */ | |
1696 /* but respect user request to force index regeneration */ | |
1697 if (index_mode == -1) | |
1698 index_mode = 1; | |
1699 } | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1700 |
3777 | 1701 |
11441 | 1702 priv->audio_need_keyframe = 0; |
1703 priv->video_after_seek = 0; | |
1704 | |
12665
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1705 switch (index_mode){ |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1706 case -1: // untouched |
31269
5eec425fdee2
Disable index reading in real demuxer if stream is not seekable.
reimar
parents:
30589
diff
changeset
|
1707 if ((demuxer->stream->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK && |
5eec425fdee2
Disable index reading in real demuxer if stream is not seekable.
reimar
parents:
30589
diff
changeset
|
1708 priv->index_chunk_offset && parse_index_chunk(demuxer)) |
12665
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1709 { |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1710 demuxer->seekable = 1; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1711 } |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1712 break; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1713 case 1: // use (generate index) |
17394
d44f30816921
Always try to parse index chunk, no reason to check for movi_end
reimar
parents:
17391
diff
changeset
|
1714 if (priv->index_chunk_offset && parse_index_chunk(demuxer)) |
12665
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1715 { |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1716 demuxer->seekable = 1; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1717 } else { |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1718 generate_index(demuxer); |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1719 demuxer->seekable = 1; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1720 } |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1721 break; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1722 case 2: // force generating index |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1723 generate_index(demuxer); |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1724 demuxer->seekable = 1; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1725 break; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1726 default: // do nothing |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1727 break; |
751a27fc8895
index creation/reading behaviour just like the avi demuxer, patch based on work by Reza Jelveh, Moritz Bunkus und myself
alex
parents:
12367
diff
changeset
|
1728 } |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1729 |
8109
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1730 // detect streams: |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1731 if(demuxer->video->id==-1 && v_streams>0){ |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1732 // find the valid video stream: |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1733 if(!ds_fill_buffer(demuxer->video)){ |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1734 mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingVideoStream); |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1735 } |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1736 } |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1737 if(demuxer->audio->id==-1 && a_streams>0){ |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1738 // find the valid audio stream: |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1739 if(!ds_fill_buffer(demuxer->audio)){ |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1740 mp_msg(MSGT_DEMUXER,MSGL_INFO,"RM: " MSGTR_MissingAudioStream); |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1741 } |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1742 } |
cb4c507c69aa
ASF-style stream auto-selection, to fix files with fake a/v streams (only
arpi
parents:
8094
diff
changeset
|
1743 |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1744 if(demuxer->video->sh){ |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1745 sh_video_t *sh=demuxer->video->sh; |
14578 | 1746 mp_msg(MSGT_DEMUX,MSGL_V,"VIDEO: %.4s [%08X,%08X] %dx%d (aspect %4.2f) %4.2f fps\n", |
17366 | 1747 (char *)&sh->format,((unsigned int*)(sh->bih+1))[1],((unsigned int*)(sh->bih+1))[0], |
9561
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1748 sh->disp_w,sh->disp_h,sh->aspect,sh->fps); |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1749 } |
05c462fd6bff
- fixed playback of files with bad WxH in header (tricky! we can always read the
arpi
parents:
9555
diff
changeset
|
1750 |
17388
002e4923d5ab
Print audio 4cc for every stream, print 4cc of selected audio track
rtognimp
parents:
17366
diff
changeset
|
1751 if(demuxer->audio->sh){ |
002e4923d5ab
Print audio 4cc for every stream, print 4cc of selected audio track
rtognimp
parents:
17366
diff
changeset
|
1752 sh_audio_t *sh=demuxer->audio->sh; |
002e4923d5ab
Print audio 4cc for every stream, print 4cc of selected audio track
rtognimp
parents:
17366
diff
changeset
|
1753 mp_msg(MSGT_DEMUX,MSGL_V,"AUDIO: %.4s [%08X]\n", |
17391 | 1754 (char *)&sh->format,sh->format); |
17388
002e4923d5ab
Print audio 4cc for every stream, print 4cc of selected audio track
rtognimp
parents:
17366
diff
changeset
|
1755 } |
002e4923d5ab
Print audio 4cc for every stream, print 4cc of selected audio track
rtognimp
parents:
17366
diff
changeset
|
1756 |
16175 | 1757 return demuxer; |
3777 | 1758 } |
1759 | |
16175 | 1760 static void demux_close_real(demuxer_t *demuxer) |
3777 | 1761 { |
13837 | 1762 int i; |
3777 | 1763 real_priv_t* priv = demuxer->priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1764 |
13837 | 1765 if (priv){ |
1766 for(i=0; i<MAX_STREAMS; i++) | |
1767 if(priv->index_table[i]) | |
1768 free(priv->index_table[i]); | |
17318
184a3683834a
Don't leak memory (free audio reordering buffers)
rtognimp
parents:
17317
diff
changeset
|
1769 if (priv->audio_buf) |
184a3683834a
Don't leak memory (free audio reordering buffers)
rtognimp
parents:
17317
diff
changeset
|
1770 free(priv->audio_buf); |
184a3683834a
Don't leak memory (free audio reordering buffers)
rtognimp
parents:
17317
diff
changeset
|
1771 if (priv->audio_timestamp) |
184a3683834a
Don't leak memory (free audio reordering buffers)
rtognimp
parents:
17317
diff
changeset
|
1772 free(priv->audio_timestamp); |
3777 | 1773 free(priv); |
13837 | 1774 } |
3777 | 1775 |
1776 return; | |
1777 } | |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1778 |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1779 /* please upload RV10 samples WITH INDEX CHUNK */ |
17636 | 1780 static void demux_seek_real(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1781 { |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1782 real_priv_t *priv = demuxer->priv; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1783 demux_stream_t *d_audio = demuxer->audio; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1784 demux_stream_t *d_video = demuxer->video; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1785 sh_audio_t *sh_audio = d_audio->sh; |
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1786 sh_video_t *sh_video = d_video->sh; |
6344 | 1787 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
|
1788 int next_offset = 0; |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
1789 int64_t cur_timestamp = 0; |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1790 int streams = 0; |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1791 int retried = 0; |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1792 |
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1793 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1794 if (sh_video && (unsigned)vid < MAX_STREAMS && priv->index_table_size[vid]) |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1795 streams |= 1; |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1796 if (sh_audio && (unsigned)aid < MAX_STREAMS && priv->index_table_size[aid]) |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1797 streams |= 2; |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1798 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1799 // printf("streams: %d\n", streams); |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1800 |
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1801 if (!streams) |
17174
83a8c738be89
make demuxer seek and close functions return void, patch by Dominik Mierzejewski
wanderer
parents:
17149
diff
changeset
|
1802 return; |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1803 |
25883
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
1804 if (flags & SEEK_ABSOLUTE) |
5083
ce6952225939
added PRE-ALPHA seeking ability and index table generator (like avi's one)
alex
parents:
4328
diff
changeset
|
1805 priv->current_apacket = priv->current_vpacket = 0; |
25883
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
1806 if (flags & SEEK_FACTOR) |
20492
0b563edd9b3a
Quick hack to implement percent-based seeking, also fixes seeking with gmplayer
reimar
parents:
20229
diff
changeset
|
1807 rel_seek_secs *= priv->duration; |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1808 |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1809 if ((streams & 1) && priv->current_vpacket >= priv->index_table_size[vid]) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1810 priv->current_vpacket = priv->index_table_size[vid] - 1; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1811 if ((streams & 2) && priv->current_apacket >= priv->index_table_size[aid]) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1812 priv->current_apacket = priv->index_table_size[aid] - 1; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1813 |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1814 // if (index_mode == 1 || index_mode == 2) { |
11441 | 1815 if (streams & 1) {// use the video index if we have one |
1816 cur_timestamp = priv->index_table[vid][priv->current_vpacket].timestamp; | |
1817 if (rel_seek_secs > 0) | |
1818 while ((priv->index_table[vid][priv->current_vpacket].timestamp - cur_timestamp) < rel_seek_secs * 1000){ | |
1819 priv->current_vpacket += 1; | |
1820 if (priv->current_vpacket >= priv->index_table_size[vid]) { | |
1821 priv->current_vpacket = priv->index_table_size[vid] - 1; | |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1822 if (!retried) { |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1823 stream_seek(demuxer->stream, priv->index_table[vid][priv->current_vpacket].offset); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1824 add_index_segment(demuxer, vid, cur_timestamp + rel_seek_secs * 1000); |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1825 retried = 1; |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1826 } |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1827 else |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1828 break; |
11441 | 1829 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1830 } |
28549 | 1831 else if (rel_seek_secs < 0) { |
11441 | 1832 while ((cur_timestamp - priv->index_table[vid][priv->current_vpacket].timestamp) < - rel_seek_secs * 1000){ |
1833 priv->current_vpacket -= 1; | |
1834 if (priv->current_vpacket < 0) { | |
1835 priv->current_vpacket = 0; | |
1836 break; | |
1837 } | |
1838 } | |
28549 | 1839 } |
1840 priv->video_curpos = priv->index_table[vid][priv->current_vpacket].offset; | |
1841 priv->audio_need_keyframe = !priv->is_multirate; | |
11441 | 1842 priv->video_after_seek = 1; |
1843 } | |
28549 | 1844 if (streams & 2) { |
1845 if (!(streams & 1)) { | |
1846 cur_timestamp = | |
1847 priv->index_table[aid][priv->current_apacket].timestamp; | |
1848 } | |
11441 | 1849 if (rel_seek_secs > 0) |
1850 while ((priv->index_table[aid][priv->current_apacket].timestamp - cur_timestamp) < rel_seek_secs * 1000){ | |
1851 priv->current_apacket += 1; | |
1852 if (priv->current_apacket >= priv->index_table_size[aid]) { | |
1853 priv->current_apacket = priv->index_table_size[aid] - 1; | |
1854 break; | |
1855 } | |
1856 } | |
1857 else if (rel_seek_secs < 0) | |
1858 while ((cur_timestamp - priv->index_table[aid][priv->current_apacket].timestamp) < - rel_seek_secs * 1000){ | |
1859 priv->current_apacket -= 1; | |
1860 if (priv->current_apacket < 0) { | |
1861 priv->current_apacket = 0; | |
1862 break; | |
1863 } | |
1864 } | |
28549 | 1865 priv->audio_curpos = priv->index_table[aid][priv->current_apacket].offset; |
11441 | 1866 } |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1867 // } |
28549 | 1868 next_offset = streams & 1 ? priv->video_curpos : priv->audio_curpos; |
5918
dca3016882cf
completed real seeking - working very well with audio only files
alex
parents:
5810
diff
changeset
|
1869 // 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
|
1870 // next_offset, priv->current_apacket, priv->current_vpacket); |
11596
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1871 if (next_offset) |
6d377637ea60
Proper runtime index generation with support for growing files. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
11441
diff
changeset
|
1872 stream_seek(demuxer->stream, next_offset); |
11441 | 1873 |
16175 | 1874 demux_real_fill_buffer(demuxer, NULL); |
3882
c5cefeb78c40
added read_index_chunk, fixed audio_header parser for version5
alex
parents:
3877
diff
changeset
|
1875 } |
11441 | 1876 |
16175 | 1877 static int demux_real_control(demuxer_t *demuxer, int cmd, void *arg) |
11441 | 1878 { |
1879 real_priv_t *priv = demuxer->priv; | |
20139
1ef90de62efa
Fix problems on live streams with huge timestamps, causing overflows and
rtogni
parents:
19960
diff
changeset
|
1880 unsigned int lastpts = priv->v_pts ? priv->v_pts : priv->a_pts; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1881 |
11441 | 1882 switch (cmd) { |
1883 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
1884 if (priv->duration == 0) | |
1885 return DEMUXER_CTRL_DONTKNOW; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1886 |
16346
6ff303d2876b
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents:
16175
diff
changeset
|
1887 *((double *)arg) = (double)priv->duration; |
11441 | 1888 return DEMUXER_CTRL_OK; |
1889 | |
1890 case DEMUXER_CTRL_GET_PERCENT_POS: | |
1891 if (priv->duration == 0) | |
1892 return DEMUXER_CTRL_DONTKNOW; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1893 |
11441 | 1894 *((int *)arg) = (int)(100 * lastpts / priv->duration); |
1895 return DEMUXER_CTRL_OK; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29247
diff
changeset
|
1896 |
11441 | 1897 default: |
1898 return DEMUXER_CTRL_NOTIMPL; | |
1899 } | |
1900 } | |
16175 | 1901 |
1902 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25600
diff
changeset
|
1903 const demuxer_desc_t demuxer_desc_real = { |
16175 | 1904 "Realmedia demuxer", |
1905 "real", | |
1906 "REAL", | |
1907 "Alex Beregszasi, Florian Schneider, A'rpi, Roberto Togni", | |
1908 "handles new .RMF files", | |
1909 DEMUXER_TYPE_REAL, | |
1910 1, // safe autodetect | |
1911 real_check_file, | |
1912 demux_real_fill_buffer, | |
1913 demux_open_real, | |
1914 demux_close_real, | |
1915 demux_seek_real, | |
1916 demux_real_control | |
1917 }; |