Mercurial > mplayer.hg
annotate libmpdemux/demux_avi.c @ 16996:17dd370a838a
Added new TOOL to convert 'anything supported' to VCD/SVCD (PAL/NTSC) using mencoder
author | reynaldo |
---|---|
date | Wed, 16 Nov 2005 19:15:27 +0000 |
parents | 9081ae3a702c |
children | adb64d908347 |
rev | line source |
---|---|
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
1 // AVI file parser for DEMUXER v2.9 by A'rpi/ESP-team |
1 | 2 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
3 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
4 #include <stdlib.h> |
1430 | 5 #include <unistd.h> |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
6 |
1567 | 7 #include "config.h" |
8 #include "mp_msg.h" | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
9 #include "help_mp.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
10 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
11 #include "stream.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
12 #include "demuxer.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
13 #include "stheader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
14 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
15 #include "aviheader.h" |
1 | 16 |
16175 | 17 extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer); |
18 extern int demux_ogg_open(demuxer_t* demuxer); | |
19 | |
16211
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
20 extern demuxer_desc_t demuxer_desc_avi_ni; |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
21 extern demuxer_desc_t demuxer_desc_avi_nini; |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
22 |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
23 // PTS: 0=interleaved 1=BPS-based |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
24 int pts_from_bps=1; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
25 |
1 | 26 // Select ds from ID |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
27 demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){ |
1 | 28 int stream_id=avi_stream_id(id); |
426 | 29 |
30 // printf("demux_avi_select_stream(%d) {a:%d/v:%d}\n",stream_id, | |
31 // demux->audio->id,demux->video->id); | |
32 | |
33 if(demux->video->id==-1) | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
34 if(demux->v_streams[stream_id]) |
426 | 35 demux->video->id=stream_id; |
36 | |
37 if(demux->audio->id==-1) | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
38 if(demux->a_streams[stream_id]) |
426 | 39 demux->audio->id=stream_id; |
40 | |
41 if(stream_id==demux->audio->id){ | |
42 if(!demux->audio->sh){ | |
7785
ffe8bfaa2851
fix & workaround possible sig8/sig11 in blocksize calculation
arpi
parents:
7501
diff
changeset
|
43 sh_audio_t* sh; |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
44 avi_priv_t *priv=demux->priv; |
7785
ffe8bfaa2851
fix & workaround possible sig8/sig11 in blocksize calculation
arpi
parents:
7501
diff
changeset
|
45 sh=demux->audio->sh=demux->a_streams[stream_id]; |
1567 | 46 mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI audio ID = %d\n",demux->audio->id); |
7785
ffe8bfaa2851
fix & workaround possible sig8/sig11 in blocksize calculation
arpi
parents:
7501
diff
changeset
|
47 if(sh->wf){ |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
48 priv->audio_block_size=sh->wf->nBlockAlign; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
49 if(!priv->audio_block_size){ |
7785
ffe8bfaa2851
fix & workaround possible sig8/sig11 in blocksize calculation
arpi
parents:
7501
diff
changeset
|
50 // for PCM audio we can calculate the blocksize: |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
51 if(sh->format==1) |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
52 priv->audio_block_size=sh->wf->nChannels*(sh->wf->wBitsPerSample/8); |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
53 else |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
54 priv->audio_block_size=1; // hope the best... |
8059 | 55 } else { |
56 // workaround old mencoder's bug: | |
57 if(sh->audio.dwSampleSize==1 && sh->audio.dwScale==1 && | |
58 (sh->wf->nBlockAlign==1152 || sh->wf->nBlockAlign==576)){ | |
59 mp_msg(MSGT_DEMUX,MSGL_WARN,"AVI: Workarounding CBR-MP3 nBlockAlign header bug!\n"); | |
60 priv->audio_block_size=1; | |
61 } | |
7785
ffe8bfaa2851
fix & workaround possible sig8/sig11 in blocksize calculation
arpi
parents:
7501
diff
changeset
|
62 } |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
63 } else { |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
64 priv->audio_block_size=sh->audio.dwSampleSize; |
7785
ffe8bfaa2851
fix & workaround possible sig8/sig11 in blocksize calculation
arpi
parents:
7501
diff
changeset
|
65 } |
8059 | 66 // printf("&&&&& setting blocksize to %d &&&&&\n",priv->audio_block_size); |
426 | 67 } |
68 return demux->audio; | |
69 } | |
70 if(stream_id==demux->video->id){ | |
71 if(!demux->video->sh){ | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
72 demux->video->sh=demux->v_streams[stream_id]; |
1567 | 73 mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI video ID = %d\n",demux->video->id); |
426 | 74 } |
75 return demux->video; | |
76 } | |
1 | 77 if(id!=mmioFOURCC('J','U','N','K')){ |
78 // unknown | |
1998 | 79 mp_msg(MSGT_DEMUX,MSGL_DBG2,"Unknown chunk: %.4s (%X)\n",(char *) &id,id); |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
80 //abort(); |
1 | 81 } |
82 return NULL; | |
83 } | |
84 | |
2438 | 85 static int valid_fourcc(unsigned int id){ |
86 unsigned char* fcc=(unsigned char*)(&id); | |
87 #define FCC_CHR_CHECK(x) (x<48 || x>=96) | |
88 if(FCC_CHR_CHECK(fcc[0])) return 0; | |
89 if(FCC_CHR_CHECK(fcc[1])) return 0; | |
90 if(FCC_CHR_CHECK(fcc[2])) return 0; | |
91 if(FCC_CHR_CHECK(fcc[3])) return 0; | |
92 return 1; | |
93 #undef FCC_CHR_CHECK | |
94 } | |
95 | |
96 static int choose_chunk_len(unsigned int len1,unsigned int len2){ | |
97 // len1 has a bit more priority than len2. len1!=len2 | |
98 // Note: this is a first-idea-logic, may be wrong. comments welcomed. | |
99 | |
100 // prefer small frames rather than 0 | |
101 if(!len1) return (len2>0x80000) ? len1 : len2; | |
102 if(!len2) return (len1>0x100000) ? len2 : len1; | |
103 | |
104 // choose the smaller value: | |
105 return (len1<len2)? len1 : len2; | |
106 } | |
107 | |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
108 static int demux_avi_read_packet(demuxer_t *demux,demux_stream_t *ds,unsigned int id,unsigned int len,int idxpos,int flags){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
109 avi_priv_t *priv=demux->priv; |
1 | 110 int skip; |
111 float pts=0; | |
112 | |
1567 | 113 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"demux_avi.read_packet: %X\n",id); |
1 | 114 |
115 if(ds==demux->audio){ | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
116 if(priv->pts_corrected==0){ |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
117 // printf("\rYYY-A A: %5.3f V: %5.3f \n",priv->avi_audio_pts,priv->avi_video_pts); |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
118 if(priv->pts_has_video){ |
1455 | 119 // we have video pts now |
2826 | 120 float delay=0; |
121 if(((sh_audio_t*)(ds->sh))->wf->nAvgBytesPerSec) | |
122 delay=(float)priv->pts_corr_bytes/((sh_audio_t*)(ds->sh))->wf->nAvgBytesPerSec; | |
1567 | 123 mp_msg(MSGT_DEMUX,MSGL_V,"XXX initial v_pts=%5.3f a_pos=%d (%5.3f) \n",priv->avi_audio_pts,priv->pts_corr_bytes,delay); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
124 //priv->pts_correction=-priv->avi_audio_pts+delay; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
125 priv->pts_correction=delay-priv->avi_audio_pts; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
126 priv->avi_audio_pts+=priv->pts_correction; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
127 priv->pts_corrected=1; |
1455 | 128 } else |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
129 priv->pts_corr_bytes+=len; |
1455 | 130 } |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
131 if(pts_from_bps){ |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
132 pts = priv->audio_block_no * |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
133 (float)((sh_audio_t*)demux->audio->sh)->audio.dwScale / |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
134 (float)((sh_audio_t*)demux->audio->sh)->audio.dwRate; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
135 } else |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
136 pts=priv->avi_audio_pts; //+priv->pts_correction; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
137 priv->avi_audio_pts=0; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
138 // update blockcount: |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
139 priv->audio_block_no+=priv->audio_block_size ? |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
140 ((len+priv->audio_block_size-1)/priv->audio_block_size) : 1; |
8059 | 141 // printf("\raudio_block_no=%d \n",priv->audio_block_no); |
1 | 142 } else |
1409 | 143 if(ds==demux->video){ |
1 | 144 // video |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
145 if(priv->skip_video_frames>0){ |
1 | 146 // drop frame (seeking) |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
147 --priv->skip_video_frames; |
1 | 148 ds=NULL; |
149 } | |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
150 |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
151 pts = priv->avi_video_pts = priv->video_pack_no * |
1368 | 152 (float)((sh_video_t*)demux->video->sh)->video.dwScale / |
153 (float)((sh_video_t*)demux->video->sh)->video.dwRate; | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
154 // printf("\rYYY-V A: %5.3f V: %5.3f \n",priv->avi_audio_pts,priv->avi_video_pts); |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
155 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
156 priv->avi_audio_pts=priv->avi_video_pts+priv->pts_correction; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
157 priv->pts_has_video=1; |
1455 | 158 |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
159 if(ds) ++priv->video_pack_no; |
1498 | 160 |
161 //printf("read pack_no: %d pts %5.3f \n",demux->video->pack_no+demux->video->packs,pts); | |
1 | 162 } |
163 | |
164 skip=(len+1)&(~1); // total bytes in this chunk | |
165 | |
166 if(ds){ | |
1567 | 167 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_AVI: Read %d data bytes from packet %04X\n",len,id); |
8059 | 168 // printf("READ[%c] %5.3f (%d) \n",ds==demux->video?'V':'A',pts,len); |
979 | 169 ds_read_packet(ds,demux->stream,len,pts,idxpos,flags); |
1 | 170 skip-=len; |
171 } | |
172 if(skip){ | |
1567 | 173 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_AVI: Skipping %d bytes from packet %04X\n",skip,id); |
1 | 174 stream_skip(demux->stream,skip); |
175 } | |
176 return ds?1:0; | |
177 } | |
178 | |
179 // return value: | |
180 // 0 = EOF or no stream found | |
181 // 1 = successfully read a packet | |
16175 | 182 static int demux_avi_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
183 avi_priv_t *priv=demux->priv; |
1 | 184 unsigned int id=0; |
185 unsigned int len; | |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
186 //int max_packs=128; |
1 | 187 int ret=0; |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
188 demux_stream_t *ds; |
1 | 189 |
190 do{ | |
9228 | 191 int flags=1; |
1 | 192 AVIINDEXENTRY *idx=NULL; |
1421 | 193 #if 0 |
1 | 194 demux->filepos=stream_tell(demux->stream); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
426
diff
changeset
|
195 if(demux->filepos>=demux->movi_end){ |
1 | 196 demux->stream->eof=1; |
197 return 0; | |
198 } | |
199 if(stream_eof(demux->stream)) return 0; | |
1421 | 200 #endif |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
201 if(priv->idx_size>0 && priv->idx_pos<priv->idx_size){ |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
202 off_t pos; |
1 | 203 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
204 //if(priv->idx_pos<0) printf("Fatal! idx_pos=%d\n",priv->idx_pos); |
1 | 205 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
206 idx=&((AVIINDEXENTRY *)priv->idx)[priv->idx_pos++]; |
1 | 207 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
208 //printf("[%d]",priv->idx_pos);fflush(stdout); |
1 | 209 |
210 //stream_seek(demux->stream,idx.dwChunkOffset); | |
211 //printf("IDX pos=%X idx.pos=%X idx.size=%X idx.flags=%X\n",demux->filepos, | |
212 // pos-4,idx->dwChunkLength,idx->dwFlags); | |
213 if(idx->dwFlags&AVIIF_LIST){ | |
214 // LIST | |
215 continue; | |
216 } | |
217 if(!demux_avi_select_stream(demux,idx->ckid)){ | |
1567 | 218 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"Skip chunk %.4s (0x%X) \n",(char *)&idx->ckid,(unsigned int)idx->ckid); |
1 | 219 continue; // skip this chunk |
220 } | |
221 | |
12036 | 222 pos = (off_t)priv->idx_offset+AVI_IDX_OFFSET(idx); |
11965 | 223 if((pos<demux->movi_start || pos>=demux->movi_end) && (demux->movi_end>demux->movi_start) && (demux->stream->flags & STREAM_SEEK)){ |
1567 | 224 mp_msg(MSGT_DEMUX,MSGL_V,"ChunkOffset out of range! idx=0x%X \n",pos); |
1 | 225 continue; |
226 } | |
227 #if 0 | |
228 if(pos!=demux->filepos){ | |
1567 | 229 mp_msg(MSGT_DEMUX,MSGL_V,"Warning! pos=0x%X idx.pos=0x%X diff=%d \n",demux->filepos,pos,pos-demux->filepos); |
1 | 230 } |
231 #endif | |
232 stream_seek(demux->stream,pos); | |
1421 | 233 demux->filepos=stream_tell(demux->stream); |
1 | 234 id=stream_read_dword_le(demux->stream); |
1421 | 235 if(stream_eof(demux->stream)) return 0; // EOF! |
236 | |
1 | 237 if(id!=idx->ckid){ |
1567 | 238 mp_msg(MSGT_DEMUX,MSGL_V,"ChunkID mismatch! raw=%.4s idx=%.4s \n",(char *)&id,(char *)&idx->ckid); |
2438 | 239 if(valid_fourcc(idx->ckid)) |
240 id=idx->ckid; // use index if valid | |
241 else | |
242 if(!valid_fourcc(id)) continue; // drop chunk if both id and idx bad | |
1 | 243 } |
244 len=stream_read_dword_le(demux->stream); | |
245 // if((len&(~1))!=(idx->dwChunkLength&(~1))){ | |
246 // if((len)!=(idx->dwChunkLength)){ | |
247 if((len!=idx->dwChunkLength)&&((len+1)!=idx->dwChunkLength)){ | |
1567 | 248 mp_msg(MSGT_DEMUX,MSGL_V,"ChunkSize mismatch! raw=%d idx=%ld \n",len,idx->dwChunkLength); |
2438 | 249 if(len>0x200000 && idx->dwChunkLength>0x200000) continue; // both values bad :( |
250 len=choose_chunk_len(idx->dwChunkLength,len); | |
1 | 251 } |
9228 | 252 if(!(idx->dwFlags&AVIIF_KEYFRAME)) flags=0; |
1 | 253 } else { |
1421 | 254 demux->filepos=stream_tell(demux->stream); |
11965 | 255 if(demux->filepos>=demux->movi_end && demux->movi_end>demux->movi_start && (demux->stream->flags & STREAM_SEEK)){ |
1421 | 256 demux->stream->eof=1; |
257 return 0; | |
258 } | |
1 | 259 id=stream_read_dword_le(demux->stream); |
260 len=stream_read_dword_le(demux->stream); | |
1421 | 261 if(stream_eof(demux->stream)) return 0; // EOF! |
262 | |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
263 if(id==mmioFOURCC('L','I','S','T') || id==mmioFOURCC('R', 'I', 'F', 'F')){ |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
264 id=stream_read_dword_le(demux->stream); // list or RIFF type |
1 | 265 continue; |
266 } | |
267 } | |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
268 |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
269 ds=demux_avi_select_stream(demux,id); |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
270 if(ds) |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
271 if(ds->packs+1>=MAX_PACKS || ds->bytes+len>=MAX_PACK_BYTES){ |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
272 // this packet will cause a buffer overflow, switch to -ni mode!!! |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
273 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_SwitchToNi); |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
274 if(priv->idx_size>0){ |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
275 // has index |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
276 demux->type=DEMUXER_TYPE_AVI_NI; |
16211
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
277 demux->desc=&demuxer_desc_avi_ni; |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
278 --priv->idx_pos; // hack |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
279 } else { |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
280 // no index |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
281 demux->type=DEMUXER_TYPE_AVI_NINI; |
16211
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
282 demux->desc=&demuxer_desc_avi_nini; |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
283 priv->idx_pos=demux->filepos; // hack |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
284 } |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
285 priv->idx_pos_v=priv->idx_pos_a=priv->idx_pos; |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
286 // quit now, we can't even (no enough buffer memory) read this packet :( |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
287 return -1; |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
288 } |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
289 |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
290 ret=demux_avi_read_packet(demux,ds,id,len,priv->idx_pos-1,flags); |
1998 | 291 // if(!ret && priv->skip_video_frames<=0) |
292 // if(--max_packs==0){ | |
293 // demux->stream->eof=1; | |
294 // mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_DoesntContainSelectedStream); | |
295 // return 0; | |
296 // } | |
1 | 297 } while(ret!=1); |
298 return 1; | |
299 } | |
300 | |
301 | |
302 // return value: | |
303 // 0 = EOF or no stream found | |
304 // 1 = successfully read a packet | |
305 int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t* ds){ | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
306 avi_priv_t *priv=demux->priv; |
1 | 307 unsigned int id=0; |
308 unsigned int len; | |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
309 //int max_packs=128; |
1 | 310 int ret=0; |
311 | |
312 do{ | |
9228 | 313 int flags=1; |
1 | 314 AVIINDEXENTRY *idx=NULL; |
315 int idx_pos=0; | |
316 demux->filepos=stream_tell(demux->stream); | |
317 | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
318 if(ds==demux->video) idx_pos=priv->idx_pos_v++; else |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
319 if(ds==demux->audio) idx_pos=priv->idx_pos_a++; else |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
320 idx_pos=priv->idx_pos++; |
1 | 321 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
322 if(priv->idx_size>0 && idx_pos<priv->idx_size){ |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
323 off_t pos; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
324 idx=&((AVIINDEXENTRY *)priv->idx)[idx_pos]; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
325 // idx=&priv->idx[idx_pos]; |
1 | 326 |
327 if(idx->dwFlags&AVIIF_LIST){ | |
328 // LIST | |
329 continue; | |
330 } | |
331 if(ds && demux_avi_select_stream(demux,idx->ckid)!=ds){ | |
1567 | 332 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"Skip chunk %.4s (0x%X) \n",(char *)&idx->ckid,(unsigned int)idx->ckid); |
1 | 333 continue; // skip this chunk |
334 } | |
335 | |
12036 | 336 pos = priv->idx_offset+AVI_IDX_OFFSET(idx); |
2439
022a7e7fec2d
while_encoding.avi (ffmpeg) fix (ignoring movi_ check if end<=start)
arpi
parents:
2438
diff
changeset
|
337 if((pos<demux->movi_start || pos>=demux->movi_end) && (demux->movi_end>demux->movi_start)){ |
1567 | 338 mp_msg(MSGT_DEMUX,MSGL_V,"ChunkOffset out of range! current=0x%X idx=0x%X \n",demux->filepos,pos); |
1 | 339 continue; |
340 } | |
341 #if 0 | |
342 if(pos!=demux->filepos){ | |
1567 | 343 mp_msg(MSGT_DEMUX,MSGL_V,"Warning! pos=0x%X idx.pos=0x%X diff=%d \n",demux->filepos,pos,pos-demux->filepos); |
1 | 344 } |
345 #endif | |
346 stream_seek(demux->stream,pos); | |
347 | |
348 id=stream_read_dword_le(demux->stream); | |
349 | |
350 if(stream_eof(demux->stream)) return 0; | |
351 | |
352 if(id!=idx->ckid){ | |
1567 | 353 mp_msg(MSGT_DEMUX,MSGL_V,"ChunkID mismatch! raw=%.4s idx=%.4s \n",(char *)&id,(char *)&idx->ckid); |
2438 | 354 if(valid_fourcc(idx->ckid)) |
355 id=idx->ckid; // use index if valid | |
356 else | |
357 if(!valid_fourcc(id)) continue; // drop chunk if both id and idx bad | |
1 | 358 } |
359 len=stream_read_dword_le(demux->stream); | |
360 if((len!=idx->dwChunkLength)&&((len+1)!=idx->dwChunkLength)){ | |
1567 | 361 mp_msg(MSGT_DEMUX,MSGL_V,"ChunkSize mismatch! raw=%d idx=%ld \n",len,idx->dwChunkLength); |
2438 | 362 if(len>0x200000 && idx->dwChunkLength>0x200000) continue; // both values bad :( |
363 len=choose_chunk_len(idx->dwChunkLength,len); | |
1 | 364 } |
9228 | 365 if(!(idx->dwFlags&AVIIF_KEYFRAME)) flags=0; |
1 | 366 } else return 0; |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
367 ret=demux_avi_read_packet(demux,demux_avi_select_stream(demux,id),id,len,idx_pos,flags); |
1998 | 368 // if(!ret && priv->skip_video_frames<=0) |
369 // if(--max_packs==0){ | |
370 // demux->stream->eof=1; | |
371 // mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_DoesntContainSelectedStream); | |
372 // return 0; | |
373 // } | |
1 | 374 } while(ret!=1); |
375 return 1; | |
376 } | |
377 | |
378 | |
379 // return value: | |
380 // 0 = EOF or no stream found | |
381 // 1 = successfully read a packet | |
382 int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t* ds){ | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
383 avi_priv_t *priv=demux->priv; |
1 | 384 unsigned int id=0; |
385 unsigned int len; | |
386 int ret=0; | |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
387 off_t *fpos=NULL; |
1 | 388 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
389 if(ds==demux->video) fpos=&priv->idx_pos_v; else |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
390 if(ds==demux->audio) fpos=&priv->idx_pos_a; else |
1 | 391 return 0; |
392 | |
393 stream_seek(demux->stream,fpos[0]); | |
394 | |
395 do{ | |
396 | |
397 demux->filepos=stream_tell(demux->stream); | |
2439
022a7e7fec2d
while_encoding.avi (ffmpeg) fix (ignoring movi_ check if end<=start)
arpi
parents:
2438
diff
changeset
|
398 if(demux->filepos>=demux->movi_end && (demux->movi_end>demux->movi_start)){ |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
399 //demux->stream->eof=1; |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
400 ds->eof=1; |
1 | 401 return 0; |
402 } | |
403 | |
404 id=stream_read_dword_le(demux->stream); | |
405 len=stream_read_dword_le(demux->stream); | |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
406 |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
407 if(stream_eof(demux->stream)) return 0; |
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
408 |
1 | 409 if(id==mmioFOURCC('L','I','S','T')){ |
410 id=stream_read_dword_le(demux->stream); // list type | |
411 continue; | |
412 } | |
413 | |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
414 if(id==mmioFOURCC('R','I','F','F')){ |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
415 mp_msg(MSGT_DEMUX,MSGL_V,"additional RIFF header...\n"); |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
416 id=stream_read_dword_le(demux->stream); // "AVIX" |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
417 continue; |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
418 } |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
419 |
1 | 420 if(ds==demux_avi_select_stream(demux,id)){ |
421 // read it! | |
6884
37946a0a155a
detection of badly interleaved avi files and auto-switch to -ni
arpi
parents:
6871
diff
changeset
|
422 ret=demux_avi_read_packet(demux,ds,id,len,priv->idx_pos-1,0); |
1 | 423 } else { |
424 // skip it! | |
425 int skip=(len+1)&(~1); // total bytes in this chunk | |
426 stream_skip(demux->stream,skip); | |
427 } | |
428 | |
429 } while(ret!=1); | |
430 fpos[0]=stream_tell(demux->stream); | |
431 return 1; | |
432 } | |
433 | |
2314 | 434 // AVI demuxer parameters: |
435 int index_mode=-1; // -1=untouched 0=don't use index 1=use (geneate) index | |
11234
9767665d49e0
Saving and loading external index file. Patch by Jason Tackaberry <tack@auc.ca>
alex
parents:
10709
diff
changeset
|
436 char *index_file_save = NULL, *index_file_load = NULL; |
2314 | 437 int force_ni=0; // force non-interleaved AVI parsing |
438 | |
2050 | 439 void read_avi_header(demuxer_t *demuxer,int index_mode); |
440 | |
16175 | 441 static demuxer_t* demux_open_avi(demuxer_t* demuxer){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
442 demux_stream_t *d_audio=demuxer->audio; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
443 demux_stream_t *d_video=demuxer->video; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
444 sh_audio_t *sh_audio=NULL; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
445 sh_video_t *sh_video=NULL; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
446 avi_priv_t* priv=malloc(sizeof(avi_priv_t)); |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
447 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
448 // priv struct: |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
449 priv->avi_audio_pts=priv->avi_video_pts=0.0f; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
450 priv->pts_correction=0.0f; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
451 priv->skip_video_frames=0; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
452 priv->pts_corr_bytes=0; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
453 priv->pts_has_video=priv->pts_corrected=0; |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
454 priv->video_pack_no=0; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
455 priv->audio_block_no=0; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
456 priv->audio_block_size=0; |
12036 | 457 priv->isodml = 0; |
458 priv->suidx_size = 0; | |
459 priv->suidx = NULL; | |
460 | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
461 demuxer->priv=(void*)priv; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
462 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
463 //---- AVI header: |
12018 | 464 read_avi_header(demuxer,(demuxer->stream->flags & STREAM_SEEK_BW)?index_mode:-2); |
7501 | 465 |
466 if(demuxer->audio->id>=0 && !demuxer->a_streams[demuxer->audio->id]){ | |
467 mp_msg(MSGT_DEMUX,MSGL_WARN,"AVI: invalid audio stream ID: %d - ignoring (nosound)\n",demuxer->audio->id); | |
468 demuxer->audio->id=-2; // disabled | |
469 } | |
470 if(demuxer->video->id>=0 && !demuxer->v_streams[demuxer->video->id]){ | |
471 mp_msg(MSGT_DEMUX,MSGL_WARN,"AVI: invalid video stream ID: %d - ignoring (using default)\n",demuxer->video->id); | |
472 demuxer->video->id=-1; // autodetect | |
473 } | |
474 | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
475 stream_reset(demuxer->stream); |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
476 stream_seek(demuxer->stream,demuxer->movi_start); |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
477 priv->idx_pos=0; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
478 priv->idx_pos_a=0; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
479 priv->idx_pos_v=0; |
4665 | 480 if(priv->idx_size>1){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
481 // decide index format: |
4665 | 482 #if 1 |
12036 | 483 if((AVI_IDX_OFFSET(&((AVIINDEXENTRY *)priv->idx)[0])<demuxer->movi_start || |
484 AVI_IDX_OFFSET(&((AVIINDEXENTRY *)priv->idx)[1])<demuxer->movi_start )&& !priv->isodml) | |
4665 | 485 priv->idx_offset=demuxer->movi_start-4; |
486 else | |
487 priv->idx_offset=0; | |
488 #else | |
12036 | 489 if(AVI_IDX_OFFSET(&((AVIINDEXENTRY *)priv->idx)[0])<demuxer->movi_start) |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
490 priv->idx_offset=demuxer->movi_start-4; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
491 else |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
492 priv->idx_offset=0; |
4665 | 493 #endif |
494 mp_msg(MSGT_DEMUX,MSGL_V,"AVI index offset: 0x%X (movi=0x%X idx0=0x%X idx1=0x%X)\n", | |
495 (int)priv->idx_offset,(int)demuxer->movi_start, | |
496 (int)((AVIINDEXENTRY *)priv->idx)[0].dwChunkOffset, | |
497 (int)((AVIINDEXENTRY *)priv->idx)[1].dwChunkOffset); | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
498 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
499 // demuxer->endpos=avi_header.movi_end; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
500 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
501 if(priv->idx_size>0){ |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
502 // check that file is non-interleaved: |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
503 int i; |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
504 off_t a_pos=-1; |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
4665
diff
changeset
|
505 off_t v_pos=-1; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
506 for(i=0;i<priv->idx_size;i++){ |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
507 AVIINDEXENTRY* idx=&((AVIINDEXENTRY *)priv->idx)[i]; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
508 demux_stream_t* ds=demux_avi_select_stream(demuxer,idx->ckid); |
12036 | 509 off_t pos = priv->idx_offset + AVI_IDX_OFFSET(idx); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
510 if(a_pos==-1 && ds==demuxer->audio){ |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
511 a_pos=pos; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
512 if(v_pos!=-1) break; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
513 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
514 if(v_pos==-1 && ds==demuxer->video){ |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
515 v_pos=pos; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
516 if(a_pos!=-1) break; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
517 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
518 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
519 if(v_pos==-1){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
520 mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI_NI: " MSGTR_MissingVideoStream); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
521 return NULL; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
522 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
523 if(a_pos==-1){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
524 mp_msg(MSGT_DEMUX,MSGL_INFO,"AVI_NI: " MSGTR_MissingAudioStream); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
525 sh_audio=NULL; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
526 } else { |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
527 if(force_ni || abs(a_pos-v_pos)>0x100000){ // distance > 1MB |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
528 mp_msg(MSGT_DEMUX,MSGL_INFO,MSGTR_NI_Message,force_ni?MSGTR_NI_Forced:MSGTR_NI_Detected); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
529 demuxer->type=DEMUXER_TYPE_AVI_NI; // HACK!!!! |
16211
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
530 demuxer->desc=&demuxer_desc_avi_ni; // HACK!!!! |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
531 pts_from_bps=1; // force BPS sync! |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
532 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
533 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
534 } else { |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
535 // no index |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
536 if(force_ni){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
537 mp_msg(MSGT_DEMUX,MSGL_INFO,MSGTR_UsingNINI); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
538 demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!! |
16211
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
539 demuxer->desc=&demuxer_desc_avi_nini; // HACK!!!! |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
540 priv->idx_pos_a= |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
541 priv->idx_pos_v=demuxer->movi_start; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
542 pts_from_bps=1; // force BPS sync! |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
543 } |
1623
5908dd344067
added demuxer->seekable flag to generalize seeking ability test
arpi
parents:
1567
diff
changeset
|
544 demuxer->seekable=0; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
545 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
546 if(!ds_fill_buffer(d_video)){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
547 mp_msg(MSGT_DEMUX,MSGL_ERR,"AVI: " MSGTR_MissingVideoStreamBug); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
548 return NULL; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
549 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
550 sh_video=d_video->sh;sh_video->ds=d_video; |
1496 | 551 if(d_audio->id!=-2){ |
1567 | 552 mp_msg(MSGT_DEMUX,MSGL_V,"AVI: Searching for audio stream (id:%d)\n",d_audio->id); |
2330 | 553 if(!priv->audio_streams || !ds_fill_buffer(d_audio)){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1737
diff
changeset
|
554 mp_msg(MSGT_DEMUX,MSGL_INFO,"AVI: " MSGTR_MissingAudioStream); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
555 sh_audio=NULL; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
556 } else { |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
557 sh_audio=d_audio->sh;sh_audio->ds=d_audio; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
558 sh_audio->format=sh_audio->wf->wFormatTag; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
559 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
560 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
561 // calc. FPS: |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
562 sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
563 sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
8516
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
564 |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
565 // calculating audio/video bitrate: |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
566 if(priv->idx_size>0){ |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
567 // we have index, let's count 'em! |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
568 size_t vsize=0; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
569 size_t asize=0; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
570 size_t vsamples=0; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
571 size_t asamples=0; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
572 int i; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
573 for(i=0;i<priv->idx_size;i++){ |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
574 int id=avi_stream_id(((AVIINDEXENTRY *)priv->idx)[i].ckid); |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
575 int len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
576 if(sh_video->ds->id == id) { |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
577 vsize+=len; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
578 ++vsamples; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
579 } |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
580 else if(sh_audio && sh_audio->ds->id == id) { |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
581 asize+=len; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
582 asamples+=(len+priv->audio_block_size-1)/priv->audio_block_size; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
583 } |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
584 } |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
585 mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%lu (%lu) audio size=%lu (%lu)\n",vsize,vsamples,asize,asamples); |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
586 priv->numberofframes=vsamples; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
587 sh_video->i_bps=((float)vsize/(float)vsamples)*(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
588 if(sh_audio) sh_audio->i_bps=((float)asize/(float)asamples)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
589 } else { |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
590 // guessing, results may be inaccurate: |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
591 size_t vsize; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
592 size_t asize=0; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
593 |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
594 if((priv->numberofframes=sh_video->video.dwLength)<=1) |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
595 // bad video header, try to get number of frames from audio |
8646 | 596 if(sh_audio && sh_audio->wf->nAvgBytesPerSec) priv->numberofframes=sh_video->fps*sh_audio->audio.dwLength/sh_audio->audio.dwRate*sh_audio->audio.dwScale; |
8516
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
597 if(priv->numberofframes<=1){ |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
598 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CouldntDetFNo); |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
599 priv->numberofframes=0; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
600 } |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
601 |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
602 if(sh_audio){ |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
603 if(sh_audio->wf->nAvgBytesPerSec && sh_audio->audio.dwSampleSize!=1){ |
8646 | 604 asize=(float)sh_audio->wf->nAvgBytesPerSec*sh_audio->audio.dwLength*sh_audio->audio.dwScale/sh_audio->audio.dwRate; |
8516
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
605 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
606 } else { |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
607 asize=sh_audio->audio.dwLength; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
608 sh_audio->i_bps=(float)asize/(sh_video->frametime*priv->numberofframes); |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
609 } |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
610 } |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
611 vsize=demuxer->movi_end-demuxer->movi_start-asize-8*priv->numberofframes; |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
612 mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%lu (%lu) audio size=%lu\n",vsize,priv->numberofframes,asize); |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
613 sh_video->i_bps=(float)vsize/(sh_video->frametime*priv->numberofframes); |
71e2ba5d6cdc
accurate bitrate calculation using index, and more accurate guessing
arpi
parents:
8254
diff
changeset
|
614 } |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
615 return demuxer; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
616 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
617 } |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
618 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
619 //extern float initial_pts_delay; |
1 | 620 |
1466 | 621 void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
622 avi_priv_t *priv=demuxer->priv; |
1466 | 623 demux_stream_t *d_audio=demuxer->audio; |
624 demux_stream_t *d_video=demuxer->video; | |
625 sh_audio_t *sh_audio=d_audio->sh; | |
626 sh_video_t *sh_video=d_video->sh; | |
627 float skip_audio_secs=0; | |
628 | |
629 //FIXME: OFF_T - Didn't check AVI case yet (avi files can't be >2G anyway?) | |
630 //================= seek in AVI ========================== | |
631 int rel_seek_frames=rel_seek_secs*sh_video->fps; | |
632 int video_chunk_pos=d_video->pos; | |
633 int i; | |
1628
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
634 |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
635 if(flags&1){ |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
636 // seek absolute |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
637 video_chunk_pos=0; |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
638 } |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
639 |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
640 if(flags&2){ |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
641 rel_seek_frames=rel_seek_secs*priv->numberofframes; |
1628
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1623
diff
changeset
|
642 } |
1466 | 643 |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
644 priv->skip_video_frames=0; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
645 priv->avi_audio_pts=0; |
1466 | 646 |
1481 | 647 // ------------ STEP 1: find nearest video keyframe chunk ------------ |
1466 | 648 // find nearest video keyframe chunk pos: |
649 if(rel_seek_frames>0){ | |
650 // seek forward | |
7002
518faaa2aee4
corrects an off-by-one error when trying to seek beyond the end of file.
arpi
parents:
6884
diff
changeset
|
651 while(video_chunk_pos<priv->idx_size-1){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
652 int id=((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].ckid; |
1466 | 653 if(avi_stream_id(id)==d_video->id){ // video frame |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
654 if((--rel_seek_frames)<0 && ((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; |
1466 | 655 } |
656 ++video_chunk_pos; | |
657 } | |
658 } else { | |
659 // seek backward | |
1498 | 660 while(video_chunk_pos>0){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
661 int id=((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].ckid; |
1466 | 662 if(avi_stream_id(id)==d_video->id){ // video frame |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
663 if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)priv->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; |
1466 | 664 } |
665 --video_chunk_pos; | |
666 } | |
667 } | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
668 priv->idx_pos_a=priv->idx_pos_v=priv->idx_pos=video_chunk_pos; |
1466 | 669 |
670 // re-calc video pts: | |
671 d_video->pack_no=0; | |
672 for(i=0;i<video_chunk_pos;i++){ | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
673 int id=((AVIINDEXENTRY *)priv->idx)[i].ckid; |
1466 | 674 if(avi_stream_id(id)==d_video->id) ++d_video->pack_no; |
675 } | |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
676 priv->video_pack_no= |
1546 | 677 sh_video->num_frames=sh_video->num_frames_decoded=d_video->pack_no; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
678 priv->avi_video_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
1481 | 679 d_video->pos=video_chunk_pos; |
1498 | 680 |
1567 | 681 mp_msg(MSGT_SEEK,MSGL_DBG2,"V_SEEK: pack=%d pts=%5.3f chunk=%d \n",d_video->pack_no,priv->avi_video_pts,video_chunk_pos); |
1481 | 682 |
683 // ------------ STEP 2: seek audio, find the right chunk & pos ------------ | |
684 | |
685 d_audio->pack_no=0; | |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
686 // d_audio->block_no=0; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
687 priv->audio_block_no=0; |
1481 | 688 d_audio->dpos=0; |
1466 | 689 |
690 if(sh_audio){ | |
691 int i; | |
692 int len=0; | |
693 int skip_audio_bytes=0; | |
1481 | 694 int curr_audio_pos=-1; |
695 int audio_chunk_pos=-1; | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
696 int chunk_max=(demuxer->type==DEMUXER_TYPE_AVI)?video_chunk_pos:priv->idx_size; |
1481 | 697 |
698 if(sh_audio->audio.dwSampleSize){ | |
699 // constant rate audio stream | |
700 #if 0 | |
701 int align; | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
702 curr_audio_pos=(priv->avi_video_pts) * sh_audio->wf->nAvgBytesPerSec; |
1481 | 703 if(curr_audio_pos<0)curr_audio_pos=0; |
704 align=sh_audio->audio.dwSampleSize; | |
705 if(sh_audio->wf->nBlockAlign>align) align=sh_audio->wf->nBlockAlign; | |
706 curr_audio_pos/=align; | |
707 curr_audio_pos*=align; | |
1466 | 708 #else |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
709 curr_audio_pos=(priv->avi_video_pts)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale; |
3302 | 710 curr_audio_pos-=sh_audio->audio.dwStart; |
1481 | 711 curr_audio_pos*=sh_audio->audio.dwSampleSize; |
1466 | 712 #endif |
713 | |
714 // find audio chunk pos: | |
1481 | 715 for(i=0;i<chunk_max;i++){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
716 int id=((AVIINDEXENTRY *)priv->idx)[i].ckid; |
1466 | 717 if(avi_stream_id(id)==d_audio->id){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
718 len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength; |
1481 | 719 if(d_audio->dpos<=curr_audio_pos && curr_audio_pos<(d_audio->dpos+len)){ |
1466 | 720 break; |
721 } | |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
722 ++d_audio->pack_no; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
723 priv->audio_block_no+=priv->audio_block_size ? |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
724 ((len+priv->audio_block_size-1)/priv->audio_block_size) : 1; |
1481 | 725 d_audio->dpos+=len; |
1466 | 726 } |
727 } | |
6640
2d3d4c628ece
hopefully fixed last A-V sync bug, and also fixed largefile bug in debug printf
arpi
parents:
6056
diff
changeset
|
728 audio_chunk_pos=i; |
1481 | 729 skip_audio_bytes=curr_audio_pos-d_audio->dpos; |
1466 | 730 |
6640
2d3d4c628ece
hopefully fixed last A-V sync bug, and also fixed largefile bug in debug printf
arpi
parents:
6056
diff
changeset
|
731 mp_msg(MSGT_SEEK,MSGL_V,"SEEK: i=%d (max:%d) dpos=%d (wanted:%d) \n", |
2d3d4c628ece
hopefully fixed last A-V sync bug, and also fixed largefile bug in debug printf
arpi
parents:
6056
diff
changeset
|
732 i,chunk_max,(int)d_audio->dpos,curr_audio_pos); |
2d3d4c628ece
hopefully fixed last A-V sync bug, and also fixed largefile bug in debug printf
arpi
parents:
6056
diff
changeset
|
733 |
1481 | 734 } else { |
735 // VBR audio | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
736 int chunks=(priv->avi_video_pts)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale; |
1481 | 737 audio_chunk_pos=0; |
738 | |
739 // find audio chunk pos: | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
740 for(i=0;i<priv->idx_size && chunks>0;i++){ |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
741 int id=((AVIINDEXENTRY *)priv->idx)[i].ckid; |
1481 | 742 if(avi_stream_id(id)==d_audio->id){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
743 len=((AVIINDEXENTRY *)priv->idx)[i].dwChunkLength; |
1481 | 744 if(i>chunk_max){ |
745 skip_audio_bytes+=len; | |
746 } else { | |
747 ++d_audio->pack_no; | |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
748 priv->audio_block_no+=priv->audio_block_size ? |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
749 ((len+priv->audio_block_size-1)/priv->audio_block_size) : 1; |
1481 | 750 d_audio->dpos+=len; |
751 audio_chunk_pos=i; | |
752 } | |
6871
88953ff93743
count blocks by rounded-up chunksizes instead of chunks -
arpi
parents:
6816
diff
changeset
|
753 // --chunks; |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
754 if(priv->audio_block_size) |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
755 chunks-=(len+priv->audio_block_size-1)/priv->audio_block_size; |
1481 | 756 } |
757 } | |
758 //if(audio_chunk_pos>chunk_max) audio_chunk_pos=chunk_max; | |
759 | |
760 // printf("VBR seek: %5.3f -> chunk_no %d -> chunk_idx %d + skip %d \n", | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
761 // priv->avi_video_pts, audio_chunk_pos, ); |
1481 | 762 |
763 } | |
764 | |
765 // Now we have: | |
766 // audio_chunk_pos = chunk no in index table (it's <=chunk_max) | |
767 // skip_audio_bytes = bytes to be skipped after chunk seek | |
768 // d-audio->pack_no = chunk_no in stream at audio_chunk_pos | |
769 // d_audio->dpos = bytepos in stream at audio_chunk_pos | |
770 // let's seek! | |
771 | |
1466 | 772 // update stream position: |
773 d_audio->pos=audio_chunk_pos; | |
1481 | 774 // d_audio->dpos=apos; |
775 // d_audio->pts=initial_pts_delay+(float)apos/(float)sh_audio->wf->nAvgBytesPerSec; | |
776 | |
777 if(demuxer->type==DEMUXER_TYPE_AVI){ | |
778 // interleaved stream: | |
779 if(audio_chunk_pos<video_chunk_pos){ | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
780 // calc priv->skip_video_frames & adjust video pts counter: |
1481 | 781 for(i=audio_chunk_pos;i<video_chunk_pos;i++){ |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
782 int id=((AVIINDEXENTRY *)priv->idx)[i].ckid; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
783 if(avi_stream_id(id)==d_video->id) ++priv->skip_video_frames; |
1481 | 784 } |
785 // requires for correct audio pts calculation (demuxer): | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
786 priv->avi_video_pts-=priv->skip_video_frames*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
787 priv->avi_audio_pts=priv->avi_video_pts; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
7785
diff
changeset
|
788 // set index position: |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
789 priv->idx_pos_a=priv->idx_pos_v=priv->idx_pos=audio_chunk_pos; |
1481 | 790 } |
791 } else { | |
792 // non-interleaved stream: | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
793 priv->idx_pos_a=audio_chunk_pos; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
794 priv->idx_pos_v=video_chunk_pos; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1481
diff
changeset
|
795 priv->idx_pos=(audio_chunk_pos<video_chunk_pos)?audio_chunk_pos:video_chunk_pos; |
1481 | 796 } |
1498 | 797 |
1508
6e752419c7e8
update pts to obtain OSD time display change while rewinding/forwarding
atlka
parents:
1498
diff
changeset
|
798 |
1466 | 799 |
1567 | 800 mp_msg(MSGT_SEEK,MSGL_V,"SEEK: idx=%d (a:%d v:%d) v.skip=%d a.skip=%d/%4.3f \n", |
6640
2d3d4c628ece
hopefully fixed last A-V sync bug, and also fixed largefile bug in debug printf
arpi
parents:
6056
diff
changeset
|
801 (int)priv->idx_pos,audio_chunk_pos,video_chunk_pos, |
2d3d4c628ece
hopefully fixed last A-V sync bug, and also fixed largefile bug in debug printf
arpi
parents:
6056
diff
changeset
|
802 (int)priv->skip_video_frames,skip_audio_bytes,skip_audio_secs); |
1466 | 803 |
804 if(skip_audio_bytes){ | |
805 demux_read_data(d_audio,NULL,skip_audio_bytes); | |
806 //d_audio->pts=0; // PTS is outdated because of the raw data skipping | |
807 } | |
808 | |
1481 | 809 // sh_audio->timer=-skip_audio_secs; |
1466 | 810 |
811 } | |
1508
6e752419c7e8
update pts to obtain OSD time display change while rewinding/forwarding
atlka
parents:
1498
diff
changeset
|
812 d_video->pts=priv->avi_video_pts; // OSD |
1466 | 813 |
814 } | |
815 | |
816 | |
6816 | 817 void demux_close_avi(demuxer_t *demuxer) { |
818 avi_priv_t* priv=demuxer->priv; | |
1466 | 819 |
6816 | 820 if(!priv) |
821 return; | |
822 | |
823 if(priv->idx_size > 0) | |
824 free(priv->idx); | |
825 free(priv); | |
826 } | |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
827 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
828 |
16199
acb7885f916d
demux_avi_control() missing in avi's demuxer struct.
ods15
parents:
16175
diff
changeset
|
829 static int demux_avi_control(demuxer_t *demuxer,int cmd, void *arg){ |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
830 avi_priv_t *priv=demuxer->priv; |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8208
diff
changeset
|
831 /* demux_stream_t *d_audio=demuxer->audio;*/ |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
832 demux_stream_t *d_video=demuxer->video; |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8208
diff
changeset
|
833 /* sh_audio_t *sh_audio=d_audio->sh;*/ |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
834 sh_video_t *sh_video=d_video->sh; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
835 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
836 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
837 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
838 switch(cmd) { |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
839 case DEMUXER_CTRL_GET_TIME_LENGTH: |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
840 if (!priv->numberofframes) return DEMUXER_CTRL_DONTKNOW; |
16346
6ff303d2876b
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents:
16211
diff
changeset
|
841 *((double *)arg)=(double)priv->numberofframes/sh_video->fps; |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
842 if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
843 return DEMUXER_CTRL_OK; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
844 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
845 case DEMUXER_CTRL_GET_PERCENT_POS: |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
846 if (!priv->numberofframes) { |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
12036
diff
changeset
|
847 return DEMUXER_CTRL_DONTKNOW; |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
848 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
849 *((int *)arg)=(int)(priv->video_pack_no*100/priv->numberofframes); |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
850 if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
851 return DEMUXER_CTRL_OK; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
852 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
853 default: |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
854 return DEMUXER_CTRL_NOTIMPL; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
855 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
856 } |
16175 | 857 |
858 | |
859 static int avi_check_file(demuxer_t *demuxer) | |
860 { | |
861 int id=stream_read_dword_le(demuxer->stream); // "RIFF" | |
862 | |
863 if((id==mmioFOURCC('R','I','F','F')) || (id==mmioFOURCC('O','N','2',' '))) { | |
864 stream_read_dword_le(demuxer->stream); //filesize | |
865 id=stream_read_dword_le(demuxer->stream); // "AVI " | |
866 if(id==formtypeAVI) | |
867 return DEMUXER_TYPE_AVI; | |
868 if(id==mmioFOURCC('O','N','2','f')){ | |
869 mp_msg(MSGT_DEMUXER,MSGL_INFO,"ON2 AVI format"); | |
870 return DEMUXER_TYPE_AVI; | |
871 } | |
872 } | |
873 | |
874 return 0; | |
875 } | |
876 | |
877 | |
878 static demuxer_t* demux_open_hack_avi(demuxer_t *demuxer) | |
879 { | |
880 sh_audio_t* sh_a; | |
881 | |
882 demuxer = (demuxer_t*) demux_open_avi(demuxer); | |
883 if(!demuxer) return NULL; // failed to open | |
884 sh_a = (sh_audio_t*)demuxer->audio->sh; | |
885 if(demuxer->audio->id != -2 && sh_a) { | |
886 #ifdef HAVE_OGGVORBIS | |
887 // support for Ogg-in-AVI: | |
888 if(sh_a->format == 0xFFFE) | |
889 demuxer = init_avi_with_ogg(demuxer); | |
890 else if(sh_a->format == 0x674F) { | |
891 stream_t* s; | |
892 demuxer_t *od; | |
893 s = new_ds_stream(demuxer->audio); | |
894 od = new_demuxer(s,DEMUXER_TYPE_OGG,-1,-2,-2,NULL); | |
895 if(!demux_ogg_open(od)) { | |
896 mp_msg( MSGT_DEMUXER,MSGL_ERR,MSGTR_ErrorOpeningOGGDemuxer); | |
897 free_stream(s); | |
898 demuxer->audio->id = -2; | |
899 } else | |
900 demuxer = new_demuxers_demuxer(demuxer,od,demuxer); | |
901 } | |
902 #endif | |
903 } | |
904 | |
905 return demuxer; | |
906 } | |
907 | |
908 | |
909 demuxer_desc_t demuxer_desc_avi = { | |
910 "AVI demuxer", | |
911 "avi", | |
912 "AVI", | |
913 "Arpi?", | |
914 "AVI files, including non interleaved files", | |
915 DEMUXER_TYPE_AVI, | |
916 1, // safe autodetect | |
917 avi_check_file, | |
918 demux_avi_fill_buffer, | |
919 demux_open_hack_avi, | |
920 demux_close_avi, | |
921 demux_seek_avi, | |
16199
acb7885f916d
demux_avi_control() missing in avi's demuxer struct.
ods15
parents:
16175
diff
changeset
|
922 demux_avi_control |
16175 | 923 }; |
16211
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
924 |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
925 demuxer_desc_t demuxer_desc_avi_ni = { |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
926 "AVI demuxer, non-interleaved", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
927 "avini", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
928 "AVI", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
929 "Arpi?", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
930 "AVI files, including non interleaved files", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
931 DEMUXER_TYPE_AVI, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
932 1, // safe autodetect |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
933 avi_check_file, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
934 demux_avi_fill_buffer_ni, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
935 demux_open_hack_avi, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
936 demux_close_avi, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
937 demux_seek_avi, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
938 demux_avi_control |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
939 }; |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
940 |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
941 demuxer_desc_t demuxer_desc_avi_nini = { |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
942 "AVI demuxer, non-interleaved and no index", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
943 "avinini", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
944 "AVI", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
945 "Arpi?", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
946 "AVI files, including non interleaved files", |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
947 DEMUXER_TYPE_AVI, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
948 1, // safe autodetect |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
949 avi_check_file, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
950 demux_avi_fill_buffer_nini, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
951 demux_open_hack_avi, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
952 demux_close_avi, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
953 demux_seek_avi, |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
954 demux_avi_control |
391b89e20a56
100l: fix avi demuxing for ni and nini cases, allow forcing ni and nini
rtognimp
parents:
16199
diff
changeset
|
955 }; |