Mercurial > mplayer.hg
annotate libmpdemux/aviwrite.c @ 7214:f335b0da380c
Remove config files on purge.
author | diego |
---|---|
date | Sun, 01 Sep 2002 09:33:36 +0000 |
parents | aa9debe16559 |
children | f04130a7f146 |
rev | line source |
---|---|
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
1 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
2 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
3 #include <stdlib.h> |
2529 | 4 #include <string.h> |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
2652
diff
changeset
|
5 #include <sys/types.h> |
2529 | 6 |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2529
diff
changeset
|
7 #include "config.h" |
7149 | 8 #include "../version.h" |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2529
diff
changeset
|
9 |
2529 | 10 //#include "stream.h" |
11 //#include "demuxer.h" | |
12 //#include "stheader.h" | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
13 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
14 #include "wine/mmreg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
15 #include "wine/avifmt.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
16 #include "wine/vfw.h" |
6918 | 17 #include "bswap.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
1
diff
changeset
|
18 |
2529 | 19 #include "aviwrite.h" |
6918 | 20 #include "aviheader.h" |
1 | 21 |
7145
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
22 extern char *info_name; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
23 extern char *info_artist; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
24 extern char *info_genre; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
25 extern char *info_subject; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
26 extern char *info_copyright; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
27 extern char *info_sourceform; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
28 extern char *info_comment; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
29 |
2529 | 30 aviwrite_stream_t* aviwrite_new_stream(aviwrite_t *muxer,int type){ |
31 aviwrite_stream_t* s; | |
32 if(muxer->avih.dwStreams>=AVIWRITE_MAX_STREAMS){ | |
33 printf("Too many streams! increase AVIWRITE_MAX_STREAMS !\n"); | |
34 return NULL; | |
35 } | |
36 s=malloc(sizeof(aviwrite_stream_t)); | |
37 memset(s,0,sizeof(aviwrite_stream_t)); | |
38 if(!s) return NULL; // no mem!? | |
39 muxer->streams[muxer->avih.dwStreams]=s; | |
40 s->type=type; | |
41 s->id=muxer->avih.dwStreams; | |
42 s->timer=0.0; | |
2652 | 43 s->size=0; |
2529 | 44 switch(type){ |
45 case AVIWRITE_TYPE_VIDEO: | |
46 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c'); | |
47 s->h.fccType=streamtypeVIDEO; | |
48 if(!muxer->def_v) muxer->def_v=s; | |
49 break; | |
50 case AVIWRITE_TYPE_AUDIO: | |
51 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'w','b'); | |
52 s->h.fccType=streamtypeAUDIO; | |
53 break; | |
54 default: | |
55 printf("WarninG! unknown stream type: %d\n",type); | |
56 return NULL; | |
57 } | |
58 muxer->avih.dwStreams++; | |
59 return s; | |
60 } | |
1 | 61 |
2529 | 62 aviwrite_t* aviwrite_new_muxer(){ |
63 aviwrite_t* muxer=malloc(sizeof(aviwrite_t)); | |
64 memset(muxer,0,sizeof(aviwrite_t)); | |
65 return muxer; | |
66 } | |
67 | |
68 static void write_avi_chunk(FILE *f,unsigned int id,int len,void* data){ | |
6918 | 69 int le_len = le2me_32(len); |
70 int le_id = le2me_32(id); | |
71 fwrite(&le_id,4,1,f); | |
72 fwrite(&le_len,4,1,f); | |
73 | |
1 | 74 if(len>0){ |
75 if(data){ | |
76 // DATA | |
77 fwrite(data,len,1,f); | |
78 if(len&1){ // padding | |
79 unsigned char zerobyte=0; | |
80 fwrite(&zerobyte,1,1,f); | |
81 } | |
82 } else { | |
83 // JUNK | |
84 char *avi_junk_data="[= MPlayer junk data! =]"; | |
85 if(len&1) ++len; // padding | |
86 while(len>0){ | |
87 int l=strlen(avi_junk_data); | |
88 if(l>len) l=len; | |
89 fwrite(avi_junk_data,l,1,f); | |
90 len-=l; | |
91 } | |
92 } | |
93 } | |
2529 | 94 } |
95 | |
96 void aviwrite_write_chunk(aviwrite_t *muxer,aviwrite_stream_t *s, FILE *f,int len,unsigned int flags){ | |
97 | |
98 // add to the index: | |
99 if(muxer->idx_pos>=muxer->idx_size){ | |
100 muxer->idx_size+=256; // 4kB | |
101 muxer->idx=realloc(muxer->idx,16*muxer->idx_size); | |
102 } | |
103 muxer->idx[muxer->idx_pos].ckid=s->ckid; | |
104 muxer->idx[muxer->idx_pos].dwFlags=flags; // keyframe? | |
105 muxer->idx[muxer->idx_pos].dwChunkOffset=ftell(f)-(muxer->movi_start-4); | |
106 muxer->idx[muxer->idx_pos].dwChunkLength=len; | |
107 ++muxer->idx_pos; | |
108 | |
109 // write out the chunk: | |
6918 | 110 write_avi_chunk(f,s->ckid,len,s->buffer); /* unsigned char */ |
111 | |
2529 | 112 // alter counters: |
113 if(s->h.dwSampleSize){ | |
114 // CBR | |
115 s->h.dwLength+=len/s->h.dwSampleSize; | |
116 if(len%s->h.dwSampleSize) printf("Warning! len isn't divisable by samplesize!\n"); | |
117 } else { | |
118 // VBR | |
119 s->h.dwLength++; | |
120 } | |
121 s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate; | |
2652 | 122 s->size+=len; |
2529 | 123 if(len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len; |
1 | 124 |
125 } | |
126 | |
2529 | 127 static void write_avi_list(FILE *f,unsigned int id,int len){ |
1 | 128 unsigned int list_id=FOURCC_LIST; |
6918 | 129 int le_len; |
130 int le_id; | |
1 | 131 len+=4; // list fix |
6918 | 132 list_id = le2me_32(list_id); |
133 le_len = le2me_32(len); | |
134 le_id = le2me_32(id); | |
1 | 135 fwrite(&list_id,4,1,f); |
6918 | 136 fwrite(&le_len,4,1,f); |
137 fwrite(&le_id,4,1,f); | |
1 | 138 } |
139 | |
2635
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
140 // muxer->streams[i]->wf->cbSize |
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
141 #define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(((wf)->cbSize)?((wf)->cbSize-2):0)) |
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
142 |
2529 | 143 void aviwrite_write_header(aviwrite_t *muxer,FILE *f){ |
1 | 144 unsigned int riff[3]; |
2529 | 145 int i; |
146 unsigned int hdrsize; | |
7145
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
147 aviwrite_info_t info[16]; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
148 |
1 | 149 // RIFF header: |
6918 | 150 #ifdef WORDS_BIGENDIAN |
151 /* FIXME: updating the header on big-endian causes the video | |
152 * to be unreadable ("AVI_NI: No video stream found!"). | |
153 * Just don't update it (no seeking, not playable with WMP, | |
154 * but better than nothing) | |
155 */ | |
156 if(muxer->file_end != 0) | |
157 return; | |
158 #endif | |
1 | 159 riff[0]=mmioFOURCC('R','I','F','F'); |
7144
4f912998013e
fixed RIFF chunk size - patch by "Andriy N. Gritsenko" <andrej@lucky.net>
arpi
parents:
6918
diff
changeset
|
160 riff[1]=muxer->file_end-2*sizeof(unsigned int); // filesize |
1 | 161 riff[2]=formtypeAVI; // 'AVI ' |
6918 | 162 riff[0]=le2me_32(riff[0]); |
163 riff[1]=le2me_32(riff[1]); | |
164 riff[2]=le2me_32(riff[2]); | |
1 | 165 fwrite(&riff,12,1,f); |
2529 | 166 // update AVI header: |
167 if(muxer->def_v){ | |
168 muxer->avih.dwMicroSecPerFrame=1000000.0*muxer->def_v->h.dwScale/muxer->def_v->h.dwRate; | |
2635
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
169 // muxer->avih.dwMaxBytesPerSec=1000000; // dummy!!!!! FIXME |
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
170 // muxer->avih.dwPaddingGranularity=2; // ??? |
2529 | 171 muxer->avih.dwFlags|=AVIF_ISINTERLEAVED|AVIF_TRUSTCKTYPE; |
172 muxer->avih.dwTotalFrames=muxer->def_v->h.dwLength; | |
2635
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
173 // muxer->avih.dwSuggestedBufferSize=muxer->def_v->h.dwSuggestedBufferSize; |
2529 | 174 muxer->avih.dwWidth=muxer->def_v->bih->biWidth; |
175 muxer->avih.dwHeight=muxer->def_v->bih->biHeight; | |
176 } | |
177 | |
1 | 178 // AVI header: |
2529 | 179 hdrsize=sizeof(muxer->avih)+8; |
180 // calc total header size: | |
181 for(i=0;i<muxer->avih.dwStreams;i++){ | |
182 hdrsize+=12; // LIST | |
183 hdrsize+=sizeof(muxer->streams[i]->h)+8; // strh | |
184 switch(muxer->streams[i]->type){ | |
185 case AVIWRITE_TYPE_VIDEO: | |
186 hdrsize+=muxer->streams[i]->bih->biSize+8; // strf | |
187 break; | |
188 case AVIWRITE_TYPE_AUDIO: | |
2635
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
189 hdrsize+=WFSIZE(muxer->streams[i]->wf)+8; // strf |
2529 | 190 break; |
191 } | |
192 } | |
193 write_avi_list(f,listtypeAVIHEADER,hdrsize); | |
6918 | 194 |
195 le2me_MainAVIHeader(&muxer->avih); | |
196 write_avi_chunk(f,ckidAVIMAINHDR,sizeof(muxer->avih),&muxer->avih); /* MainAVIHeader */ | |
197 le2me_MainAVIHeader(&muxer->avih); | |
2529 | 198 |
199 // stream headers: | |
200 for(i=0;i<muxer->avih.dwStreams;i++){ | |
201 hdrsize=sizeof(muxer->streams[i]->h)+8; // strh | |
202 switch(muxer->streams[i]->type){ | |
203 case AVIWRITE_TYPE_VIDEO: | |
204 hdrsize+=muxer->streams[i]->bih->biSize+8; // strf | |
205 break; | |
206 case AVIWRITE_TYPE_AUDIO: | |
2635
c1e24e01601b
fixed AVI header creation - now should be compatible with NaNdub
arpi
parents:
2555
diff
changeset
|
207 hdrsize+=WFSIZE(muxer->streams[i]->wf)+8; // strf |
2529 | 208 break; |
209 } | |
210 write_avi_list(f,listtypeSTREAMHEADER,hdrsize); | |
6918 | 211 le2me_AVIStreamHeader(&muxer->streams[i]->h); |
212 write_avi_chunk(f,ckidSTREAMHEADER,sizeof(muxer->streams[i]->h),&muxer->streams[i]->h); /* AVISTreamHeader */ // strh | |
213 le2me_AVIStreamHeader(&muxer->streams[i]->h); | |
214 | |
2529 | 215 switch(muxer->streams[i]->type){ |
216 case AVIWRITE_TYPE_VIDEO: | |
6918 | 217 { |
218 int biSize=muxer->streams[i]->bih->biSize; | |
219 le2me_BITMAPINFOHEADER(muxer->streams[i]->bih); | |
220 write_avi_chunk(f,ckidSTREAMFORMAT,biSize,muxer->streams[i]->bih); /* BITMAPINFOHEADER */ | |
221 le2me_BITMAPINFOHEADER(muxer->streams[i]->bih); | |
222 } | |
2529 | 223 break; |
224 case AVIWRITE_TYPE_AUDIO: | |
6918 | 225 { |
226 int wfsize = WFSIZE(muxer->streams[i]->wf); | |
227 le2me_WAVEFORMATEX(muxer->streams[i]->wf); | |
228 write_avi_chunk(f,ckidSTREAMFORMAT,wfsize,muxer->streams[i]->wf); /* WAVEFORMATEX */ | |
229 le2me_WAVEFORMATEX(muxer->streams[i]->wf); | |
230 } | |
2529 | 231 break; |
232 } | |
233 } | |
234 | |
7145
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
235 // ============= INFO =============== |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
236 // always include software info |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
237 info[0].id=mmioFOURCC('I','S','F','T'); // Software: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
238 info[0].text="MEncoder " VERSION; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
239 // include any optional strings |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
240 i=1; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
241 if(info_name!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
242 info[i].id=mmioFOURCC('I','N','A','M'); // Name: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
243 info[i++].text=info_name; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
244 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
245 if(info_artist!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
246 info[i].id=mmioFOURCC('I','A','R','T'); // Artist: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
247 info[i++].text=info_artist; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
248 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
249 if(info_genre!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
250 info[i].id=mmioFOURCC('I','G','N','R'); // Genre: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
251 info[i++].text=info_genre; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
252 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
253 if(info_subject!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
254 info[i].id=mmioFOURCC('I','S','B','J'); // Subject: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
255 info[i++].text=info_subject; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
256 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
257 if(info_copyright!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
258 info[i].id=mmioFOURCC('I','C','O','P'); // Copyright: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
259 info[i++].text=info_copyright; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
260 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
261 if(info_sourceform!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
262 info[i].id=mmioFOURCC('I','S','R','F'); // Source Form: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
263 info[i++].text=info_sourceform; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
264 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
265 if(info_comment!=NULL){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
266 info[i].id=mmioFOURCC('I','C','M','T'); // Comment: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
267 info[i++].text=info_comment; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
268 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
269 info[i].id=0; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
270 |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
271 hdrsize=0; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
272 // calc info size: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
273 for(i=0;info[i].id!=0;i++) if(info[i].text){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
274 size_t sz=strlen(info[i].text)+1; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
275 hdrsize+=sz+8+sz%2; |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
276 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
277 // write infos: |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
278 if (hdrsize!=0){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
279 write_avi_list(f,mmioFOURCC('I','N','F','O'),hdrsize); |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
280 for(i=0;info[i].id!=0;i++) if(info[i].text){ |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
281 write_avi_chunk(f,info[i].id,strlen(info[i].text)+1,info[i].text); |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
282 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
283 } |
3854945aefbb
new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents:
7144
diff
changeset
|
284 |
2529 | 285 // JUNK: |
6918 | 286 write_avi_chunk(f,ckidAVIPADDING,2048-(ftell(f)&2047)-8,NULL); /* junk */ |
1 | 287 // 'movi' header: |
2529 | 288 write_avi_list(f,listtypeAVIMOVIE,muxer->movi_end-ftell(f)-12); |
289 muxer->movi_start=ftell(f); | |
1 | 290 } |
291 | |
2529 | 292 void aviwrite_write_index(aviwrite_t *muxer,FILE *f){ |
293 muxer->movi_end=ftell(f); | |
294 if(muxer->idx && muxer->idx_pos>0){ | |
6918 | 295 int i; |
2529 | 296 // fixup index entries: |
297 // for(i=0;i<muxer->idx_pos;i++) muxer->idx[i].dwChunkOffset-=muxer->movi_start-4; | |
298 // write index chunk: | |
6918 | 299 for (i=0; i<muxer->idx_pos; i++) le2me_AVIINDEXENTRY((&muxer->idx[i])); |
300 write_avi_chunk(f,ckidAVINEWINDEX,16*muxer->idx_pos,muxer->idx); /* AVIINDEXENTRY */ | |
301 for (i=0; i<muxer->idx_pos; i++) le2me_AVIINDEXENTRY((&muxer->idx[i])); | |
2529 | 302 muxer->avih.dwFlags|=AVIF_HASINDEX; |
303 } | |
304 muxer->file_end=ftell(f); | |
1 | 305 } |
306 |