annotate demux_mov.c @ 2175:1deee7703f33

just version update
author eyck
date Fri, 12 Oct 2001 11:56:02 +0000
parents 0c6cef85d507
children 10b279d72a8f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
1 // QuickTime MOV file parser by A'rpi
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
2 // based on TOOLS/movinfo.c by me & Al3x
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
3 // compressed header support from moov.c of the openquicktime lib.
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
4
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
5 #include <stdio.h>
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
6 #include <stdlib.h>
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
7 #include <unistd.h>
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
8
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
9 #include "config.h"
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
10
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
11 #ifdef HAVE_PNG
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
12 // should be detected by ./configure...
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
13 #define HAVE_ZLIB
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
14 #endif
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
15
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
16 #include "mp_msg.h"
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1567
diff changeset
17 #include "help_mp.h"
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
18
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
19 #include "stream.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
20 #include "demuxer.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
21
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
22 #include "wine/mmreg.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
23 #include "wine/avifmt.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
24 #include "wine/vfw.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
25
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
26 #include "codec-cfg.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
27 #include "stheader.h"
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
28
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
29 #ifdef HAVE_ZLIB
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
30 #include <zlib.h>
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
31 #endif
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
32
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
33 typedef struct {
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
34 unsigned int pts; // duration
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
35 unsigned int size;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
36 off_t pos;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
37 } mov_sample_t;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
38
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
39 typedef struct {
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
40 unsigned int sample; // number of the first sample in teh chunk
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
41 unsigned int size; // number of samples in the chunk
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
42 int desc; // for multiple codecs mode - not used
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
43 off_t pos;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
44 } mov_chunk_t;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
45
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
46 typedef struct {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
47 unsigned int first;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
48 unsigned int spc;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
49 unsigned int sdid;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
50 } mov_chunkmap_t;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
51
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
52 typedef struct {
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
53 unsigned int num;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
54 unsigned int dur;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
55 } mov_durmap_t;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
56
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
57 typedef struct {
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
58 int id;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
59 int type;
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
60 int pos;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
61 //
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
62 int timescale;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
63 unsigned int length;
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
64 int samplesize; // 0 = variable
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
65 int duration; // 0 = variable
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
66 int width,height; // for video
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
67 unsigned int fourcc;
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
68 //
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
69 int tkdata_len; // track data
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
70 unsigned char* tkdata;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
71 int stdata_len; // stream data
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
72 unsigned char* stdata;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
73 int samples_size;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
74 mov_sample_t* samples;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
75 int chunks_size;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
76 mov_chunk_t* chunks;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
77 int chunkmap_size;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
78 mov_chunkmap_t* chunkmap;
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
79 int durmap_size;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
80 mov_durmap_t* durmap;
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
81 } mov_track_t;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
82
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
83 void mov_build_index(mov_track_t* trak){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
84 int i,j,s;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
85 int last=trak->chunks_size;
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
86 unsigned int pts=0;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
87 printf("MOV track: %d chunks, %d samples\n",trak->chunks_size,trak->samples_size);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
88 printf("pts=%d scale=%d time=%5.3f\n",trak->length,trak->timescale,(float)trak->length/(float)trak->timescale);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
89 // process chunkmap:
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
90 i=trak->chunkmap_size;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
91 while(i>0){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
92 --i;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
93 for(j=trak->chunkmap[i].first;j<last;j++){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
94 trak->chunks[j].desc=trak->chunkmap[i].sdid;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
95 trak->chunks[j].size=trak->chunkmap[i].spc;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
96 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
97 last=trak->chunkmap[i].first;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
98 }
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
99
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
100 // calc pts of chunks:
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
101 s=0;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
102 for(j=0;j<trak->chunks_size;j++){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
103 trak->chunks[j].sample=s;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
104 s+=trak->chunks[j].size;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
105 }
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
106
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
107 if(!trak->samples_size){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
108 // constant sampesize
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
109 if(trak->durmap_size==1 || (trak->durmap_size==2 && trak->durmap[1].num==1)){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
110 } else printf("*** constant samplesize & variable duration not yet supported! ***\nContact the author if you have such sample file!\n");
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
111 return;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
112 }
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
113
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
114 // calc pts:
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
115 s=0;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
116 for(j=0;j<trak->durmap_size;j++){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
117 for(i=0;i<trak->durmap[j].num;i++){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
118 trak->samples[s].pts=pts;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
119 ++s;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
120 pts+=trak->durmap[j].dur;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
121 }
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
122 }
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
123
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
124 // calc sample offsets
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
125 s=0;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
126 for(j=0;j<trak->chunks_size;j++){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
127 off_t pos=trak->chunks[j].pos;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
128 for(i=0;i<trak->chunks[j].size;i++){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
129 trak->samples[s].pos=pos;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
130 #if 0
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
131 printf("Sample %5d: pts=%8d off=0x%08X size=%d\n",s,
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
132 trak->samples[s].pts,
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
133 (int)trak->samples[s].pos,
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
134 trak->samples[s].size);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
135 #endif
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
136 pos+=trak->samples[s].size;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
137 ++s;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
138 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
139 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
140
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
141 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
142
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
143 #define MOV_MAX_TRACKS 256
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
144
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
145 #define MOV_TRAK_UNKNOWN 0
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
146 #define MOV_TRAK_VIDEO 1
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
147 #define MOV_TRAK_AUDIO 2
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
148
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
149 typedef struct {
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
150 off_t moov_start;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
151 off_t moov_end;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
152 off_t mdat_start;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
153 off_t mdat_end;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
154 int track_db;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
155 mov_track_t* tracks[MOV_MAX_TRACKS];
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
156 } mov_priv_t;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
157
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
158 #define MOV_FOURCC(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d))
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
159
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
160 int mov_check_file(demuxer_t* demuxer){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
161 int flags=0;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
162 mov_priv_t* priv=malloc(sizeof(mov_priv_t));
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
163
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
164 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for MOV\n");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
165
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
166 memset(priv,0,sizeof(mov_priv_t));
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
167 demuxer->priv=priv;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
168
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
169 while(1){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
170 off_t len=stream_read_dword(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
171 unsigned int id=stream_read_dword(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
172 if(stream_eof(demuxer->stream)) break; // EOF
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
173 if(len<8) break; // invalid chunk
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
174 switch(id){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
175 case MOV_FOURCC('m','o','o','v'):
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
176 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Movie header found!\n");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
177 priv->moov_start=stream_tell(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
178 priv->moov_end=priv->moov_start+len-8;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
179 flags|=1;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
180 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
181 case MOV_FOURCC('m','d','a','t'):
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
182 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Movie DATA found!\n");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
183 priv->mdat_start=stream_tell(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
184 priv->mdat_end=priv->mdat_start+len-8;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
185 flags|=2;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
186 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
187 default:
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
188 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: unknown chunk: %.4s %d\n",&id,(int)len);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
189 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
190 if(!stream_skip(demuxer->stream,len-8)) break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
191 }
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
192
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
193 if(flags==1)
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
194 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: missing data (mdat) chunk! Maybe broken file...\n");
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
195 else if(flags==2)
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
196 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: missing header (moov/cmov) chunk! Maybe broken file...\n");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
197
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
198 return (flags==3);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
199 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
200
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
201 static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
202 mov_priv_t* priv=demuxer->priv;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
203 while(1){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
204 off_t pos;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
205 off_t len;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
206 unsigned int id;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
207 //
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
208 pos=stream_tell(demuxer->stream);
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
209 // printf("stream_tell==%d\n",pos);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
210 if(pos>=endpos) return; // END
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
211 len=stream_read_dword(demuxer->stream);
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
212 // printf("len==%d\n",len);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
213 if(len<8) return; // error
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
214 len-=8;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
215 id=stream_read_dword(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
216 //
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
217 mp_msg(MSGT_DEMUX,MSGL_DBG2,"lschunks %.4s %d\n",&id,(int)len);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
218 //
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
219 if(trak){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
220 switch(id){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
221 case MOV_FOURCC('t','k','h','d'): {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
222 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sTrack header!\n",level,"");
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
223 // read codec data
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
224 trak->tkdata_len=len;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
225 trak->tkdata=malloc(trak->tkdata_len);
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
226 stream_read(demuxer->stream,trak->tkdata,trak->tkdata_len);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
227 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
228 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
229 case MOV_FOURCC('m','d','h','d'): {
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
230 unsigned int tmp;
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
231 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia header!\n",level,"");
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
232 #if 0
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
233 tmp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
234 printf("dword1: 0x%08X (%d)\n",tmp,tmp);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
235 tmp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
236 printf("dword2: 0x%08X (%d)\n",tmp,tmp);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
237 tmp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
238 printf("dword3: 0x%08X (%d)\n",tmp,tmp);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
239 tmp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
240 printf("dword4: 0x%08X (%d)\n",tmp,tmp);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
241 tmp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
242 printf("dword5: 0x%08X (%d)\n",tmp,tmp);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
243 tmp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
244 printf("dword6: 0x%08X (%d)\n",tmp,tmp);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
245 #endif
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
246 stream_skip(demuxer->stream,12);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
247 // read timescale
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
248 trak->timescale=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
249 // read length
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
250 trak->length=stream_read_dword(demuxer->stream);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
251 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
252 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
253 case MOV_FOURCC('v','m','h','d'): {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
254 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sVideo header!\n",level,"");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
255 trak->type=MOV_TRAK_VIDEO;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
256 // read video data
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
257 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
258 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
259 case MOV_FOURCC('s','m','h','d'): {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
260 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSound header!\n",level,"");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
261 trak->type=MOV_TRAK_AUDIO;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
262 // read audio data
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
263 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
264 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
265 case MOV_FOURCC('s','t','s','d'): {
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
266 int i=stream_read_dword(demuxer->stream); // temp!
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
267 int count=stream_read_dword(demuxer->stream);
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
268 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sDescription list! (cnt:%d)\n",level,"",count);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
269 for(i=0;i<count;i++){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
270 off_t pos=stream_tell(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
271 off_t len=stream_read_dword(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
272 unsigned int fourcc=stream_read_dword_le(demuxer->stream);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
273 if(len<8) break; // error
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
274 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*s desc #%d: %.4s",level,"",i,&fourcc);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
275 if(!i){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
276 trak->fourcc=fourcc;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
277 // read codec data
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
278 trak->stdata_len=len-8;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
279 trak->stdata=malloc(trak->stdata_len);
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
280 stream_read(demuxer->stream,trak->stdata,trak->stdata_len);
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
281 if(trak->type==MOV_TRAK_VIDEO && trak->stdata_len>43){
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
282 mp_msg(MSGT_DEMUX,MSGL_V," '%.*s'",trak->stdata_len-43,trak->stdata+43);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
283 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
284 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
285 mp_msg(MSGT_DEMUX,MSGL_V,"\n");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
286 if(fourcc!=trak->fourcc && i)
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1567
diff changeset
287 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVvariableFourCC);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
288 if(!stream_seek(demuxer->stream,pos+len)) break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
289 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
290 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
291 }
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
292 case MOV_FOURCC('s','t','t','s'): {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
293 int temp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
294 int len=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
295 int i;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
296 int x=0;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
297 unsigned int pts=0;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
298 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample duration table! (%d blocks)\n",level,"",len);
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
299 trak->durmap=malloc(sizeof(mov_durmap_t)*len);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
300 memset(trak->durmap,0,sizeof(mov_durmap_t)*len);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
301 trak->durmap_size=len;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
302 for(i=0;i<len;i++){
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
303 trak->durmap[i].num=stream_read_dword(demuxer->stream);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
304 trak->durmap[i].dur=stream_read_dword(demuxer->stream);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
305 pts+=trak->durmap[i].num*trak->durmap[i].dur;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
306 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
307 if(trak->length!=pts) printf("Warning! pts=%d length=%d\n",pts,trak->length);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
308 break;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
309 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
310 case MOV_FOURCC('s','t','s','c'): {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
311 int temp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
312 int len=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
313 int i;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
314 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample->Chunk mapping table! (%d blocks)\n",level,"",len);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
315 // read data:
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
316 trak->chunkmap_size=len;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
317 trak->chunkmap=malloc(sizeof(mov_chunkmap_t)*len);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
318 for(i=0;i<len;i++){
2103
3e55202cfdab ehh. first chunk is counted from 1. fixed...
arpi
parents: 2101
diff changeset
319 trak->chunkmap[i].first=stream_read_dword(demuxer->stream)-1;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
320 trak->chunkmap[i].spc=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
321 trak->chunkmap[i].sdid=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
322 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
323 break;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
324 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
325 case MOV_FOURCC('s','t','s','z'): {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
326 int temp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
327 int ss=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
328 int len=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
329 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample size table! len=%d ss=%d\n",level,"",len,ss);
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
330 trak->samplesize=ss;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
331 if(!ss){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
332 // variable samplesize
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
333 int i;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
334 trak->samples=realloc(trak->samples,sizeof(mov_sample_t)*len);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
335 trak->samples_size=len;
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
336 for(i=0;i<len;i++)
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
337 trak->samples[i].size=stream_read_dword(demuxer->stream);
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
338 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
339 break;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
340 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
341 case MOV_FOURCC('s','t','c','o'): {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
342 int temp=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
343 int len=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
344 int i;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
345 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sChunk offset table! (%d chunks)\n",level,"",len);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
346 // extend array if needed:
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
347 if(len>trak->chunks_size){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
348 trak->chunks=realloc(trak->chunks,sizeof(mov_chunk_t)*len);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
349 trak->chunks_size=len;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
350 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
351 // read elements:
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
352 for(i=0;i<len;i++) trak->chunks[i].pos=stream_read_dword(demuxer->stream);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
353 break;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
354 }
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
355 case MOV_FOURCC('m','d','i','a'): {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
356 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia stream!\n",level,"");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
357 lschunks(demuxer,level+1,pos+len,trak);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
358 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
359 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
360 case MOV_FOURCC('m','i','n','f'): {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
361 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia info!\n",level,"");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
362 lschunks(demuxer,level+1,pos+len,trak);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
363 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
364 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
365 case MOV_FOURCC('s','t','b','l'): {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
366 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample info!\n",level,"");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
367 lschunks(demuxer,level+1,pos+len,trak);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
368 break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
369 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
370 }//switch(id)
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
371 } else
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
372 if(id==MOV_FOURCC('t','r','a','k')){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
373 // if(trak) printf("MOV: Warning! trak in trak?\n");
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
374 if(priv->track_db>=MOV_MAX_TRACKS){
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1567
diff changeset
375 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVtooManyTrk);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
376 return;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
377 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
378 trak=malloc(sizeof(mov_track_t));
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
379 memset(trak,0,sizeof(mov_track_t));
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1490
diff changeset
380 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Track #%d:\n",priv->track_db);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
381 trak->id=priv->track_db;
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
382 priv->tracks[priv->track_db]=trak;
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
383 lschunks(demuxer,level+1,pos+len,trak);
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
384 mov_build_index(trak);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
385 switch(trak->type){
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
386 case MOV_TRAK_AUDIO: {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
387 sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
388 sh->format=trak->fourcc;
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
389 printf("!!! audio bits: %d chans: %d\n",trak->stdata[19],trak->stdata[17]);
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
390 printf("Fourcc: %.4s\n",&trak->fourcc);
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
391 // Emulate WAVEFORMATEX struct:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
392 sh->wf=malloc(sizeof(WAVEFORMATEX));
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
393 memset(sh->wf,0,sizeof(WAVEFORMATEX));
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
394 sh->wf->nChannels=trak->stdata[17];
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
395 sh->wf->wBitsPerSample=trak->stdata[19];
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
396 sh->wf->nSamplesPerSec=trak->timescale;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
397 sh->wf->nAvgBytesPerSec=sh->wf->nChannels*((sh->wf->wBitsPerSample+7)/8)*sh->wf->nSamplesPerSec;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
398 // Selection:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
399 if(demuxer->audio->id==-1 || demuxer->audio->id==priv->track_db){
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
400 // (auto)selected audio track:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
401 demuxer->audio->id=priv->track_db;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
402 demuxer->audio->sh=sh; sh->ds=demuxer->audio;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
403 }
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
404 break;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
405 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
406 case MOV_TRAK_VIDEO: {
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
407 sh_video_t* sh=new_sh_video(demuxer,priv->track_db);
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
408 sh->format=trak->fourcc;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
409 sh->fps=trak->timescale;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
410 sh->frametime=1.0f/sh->fps;
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
411 sh->disp_w=trak->tkdata[77]|(trak->tkdata[76]<<8);
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
412 sh->disp_h=trak->tkdata[81]|(trak->tkdata[80]<<8);
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
413
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
414 // emulate BITMAPINFOHEADER:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
415 sh->bih=malloc(sizeof(BITMAPINFOHEADER));
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
416 memset(sh->bih,0,sizeof(BITMAPINFOHEADER));
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
417 sh->bih->biSize=40;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
418 sh->bih->biWidth=sh->disp_w;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
419 sh->bih->biHeight=sh->disp_h;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
420 sh->bih->biPlanes=0;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
421 sh->bih->biBitCount=16;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
422 sh->bih->biCompression=trak->fourcc;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
423 sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
424
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
425 printf("Image size: %d x %d\n",sh->disp_w,sh->disp_h);
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
426 printf("Fourcc: %.4s Codec: '%.*s'\n",&trak->fourcc,trak->stdata_len-43,trak->stdata+43);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
427
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
428 if(demuxer->video->id==-1 || demuxer->video->id==priv->track_db){
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
429 // (auto)selected video track:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
430 demuxer->video->id=priv->track_db;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
431 demuxer->video->sh=sh; sh->ds=demuxer->video;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
432 }
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
433 break;
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
434 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
435 }
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
436 printf("--------------\n");
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
437 priv->track_db++;
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
438 trak=NULL;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
439 } else
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
440 #ifndef HAVE_ZLIB
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
441 if(id==MOV_FOURCC('c','m','o','v')){
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1567
diff changeset
442 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
443 return;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
444 }
2148
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
445 #else
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
446 if(id==MOV_FOURCC('c','m','o','v')){
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
447 // mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
448 lschunks(demuxer,level+1,pos+len,NULL);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
449 } else
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
450 if(id==MOV_FOURCC('d','c','o','m')){
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
451 // int temp=stream_read_dword(demuxer->stream);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
452 unsigned int len=stream_read_dword(demuxer->stream);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
453 printf("Compressed header uses %.4s algo!\n",&len);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
454 } else
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
455 if(id==MOV_FOURCC('c','m','v','d')){
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
456 // int temp=stream_read_dword(demuxer->stream);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
457 unsigned int moov_sz=stream_read_dword(demuxer->stream);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
458 unsigned int cmov_sz=len-4;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
459 unsigned char* cmov_buf=malloc(cmov_sz);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
460 unsigned char* moov_buf=malloc(moov_sz+16);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
461 int zret;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
462 z_stream zstrm;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
463 stream_t* backup;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
464
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
465 printf("Compressed header size: %d / %d\n",cmov_sz,moov_sz);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
466
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
467 stream_read(demuxer->stream,cmov_buf,cmov_sz);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
468
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
469 zstrm.zalloc = (alloc_func)0;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
470 zstrm.zfree = (free_func)0;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
471 zstrm.opaque = (voidpf)0;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
472 zstrm.next_in = cmov_buf;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
473 zstrm.avail_in = cmov_sz;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
474 zstrm.next_out = moov_buf;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
475 zstrm.avail_out = moov_sz;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
476
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
477 zret = inflateInit(&zstrm);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
478 if (zret != Z_OK)
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
479 { fprintf(stderr,"QT cmov: inflateInit err %d\n",zret);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
480 return;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
481 }
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
482 zret = inflate(&zstrm, Z_NO_FLUSH);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
483 if ((zret != Z_OK) && (zret != Z_STREAM_END))
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
484 { fprintf(stderr,"QT cmov inflate: ERR %d\n",zret);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
485 return;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
486 }
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
487 #if 0
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
488 else {
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
489 FILE *DecOut;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
490 DecOut = fopen("Out.bin", "w");
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
491 fwrite(moov_buf, 1, moov_sz, DecOut);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
492 fclose(DecOut);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
493 }
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
494 #endif
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
495 if(moov_sz != zstrm.total_out) printf("Warning! moov size differs cmov: %d zlib: %d\n",moov_sz,zstrm.total_out);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
496 zret = inflateEnd(&zstrm);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
497
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
498 backup=demuxer->stream;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
499 demuxer->stream=new_memory_stream(moov_buf,moov_sz);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
500 stream_skip(demuxer->stream,8);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
501 lschunks(demuxer,level+1,moov_sz,NULL); // parse uncompr. 'moov'
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
502 //free_stream(demuxer->stream);
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
503 demuxer->stream=backup;
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
504
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
505 }
0c6cef85d507 compressed headers support
arpi
parents: 2127
diff changeset
506 #endif
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
507
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
508 pos+=len+8;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
509 if(pos>=endpos) break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
510 if(!stream_seek(demuxer->stream,pos)) break;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
511 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
512 }
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
513
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
514 int mov_read_header(demuxer_t* demuxer){
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
515 mov_priv_t* priv=demuxer->priv;
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
516
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
517 printf("mov_read_header!\n");
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
518
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
519 // Parse header:
2100
6f6eb4f8e7a0 finished mov header and index processing
arpi
parents: 1973
diff changeset
520 stream_reset(demuxer->stream);
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
521 if(!stream_seek(demuxer->stream,priv->moov_start)) return 0; // ???
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
522 lschunks(demuxer, 0, priv->moov_end, NULL);
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
523
2127
e6ce221dee06 .mov support can be disabled
arpi
parents: 2115
diff changeset
524 #if 1
e6ce221dee06 .mov support can be disabled
arpi
parents: 2115
diff changeset
525 return 1;
e6ce221dee06 .mov support can be disabled
arpi
parents: 2115
diff changeset
526 #else
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1567
diff changeset
527 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVnotyetsupp);
2127
e6ce221dee06 .mov support can be disabled
arpi
parents: 2115
diff changeset
528 return 0;
e6ce221dee06 .mov support can be disabled
arpi
parents: 2115
diff changeset
529 #endif
1490
71424eb2b282 MOV file support - not works yet
arpi
parents:
diff changeset
530 }
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
531
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
532 // return value:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
533 // 0 = EOF or no stream found
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
534 // 1 = successfully read a packet
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
535 int demux_mov_fill_buffer(demuxer_t *demuxer,demux_stream_t* ds){
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
536 mov_priv_t* priv=demuxer->priv;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
537 mov_track_t* trak=NULL;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
538 float pts;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
539
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
540 if(ds->id<0 || ds->id>=priv->track_db) return 0;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
541 trak=priv->tracks[ds->id];
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
542
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
543 if(trak->samplesize){
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
544 // read chunk:
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
545 if(trak->pos>=trak->chunks_size) return 0; // EOF
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
546 stream_seek(demuxer->stream,trak->chunks[trak->pos].pos);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
547 pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale;
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
548 ds_read_packet(ds,demuxer->stream,trak->chunks[trak->pos].size*trak->samplesize,pts,trak->chunks[trak->pos].pos,0);
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
549 } else {
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
550 // read sample:
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
551 if(trak->pos>=trak->samples_size) return 0; // EOF
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
552 stream_seek(demuxer->stream,trak->samples[trak->pos].pos);
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
553 pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
554 ds_read_packet(ds,demuxer->stream,trak->samples[trak->pos].size,pts,trak->samples[trak->pos].pos,0);
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
555 }
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
556 ++trak->pos;
2115
fe1cd4a5109a optimized demuxer for fixed samplesize (raw audio)
arpi
parents: 2103
diff changeset
557
2101
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
558 return 1;
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
559
4ca146a57d17 implemented simple demuxer
arpi
parents: 2100
diff changeset
560 }