annotate libmpdemux/aviwrite.c @ 5762:26b3c8e7f6c8

alf2 working, added techsmith camtasia
author alex
date Sun, 21 Apr 2002 13:32:35 +0000
parents 8cd761968f35
children 62ac2cac100d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
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
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
6
2555
66837325b929 config.h cleanup, few things added to steram/demuxer headers
arpi
parents: 2529
diff changeset
7 #include "config.h"
66837325b929 config.h cleanup, few things added to steram/demuxer headers
arpi
parents: 2529
diff changeset
8
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
9 //#include "stream.h"
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
10 //#include "demuxer.h"
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
11 //#include "stheader.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
12
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
13 #include "wine/mmreg.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
14 #include "wine/avifmt.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
15 #include "wine/vfw.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
16
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
17 #include "aviwrite.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
19 aviwrite_stream_t* aviwrite_new_stream(aviwrite_t *muxer,int type){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
20 aviwrite_stream_t* s;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
21 if(muxer->avih.dwStreams>=AVIWRITE_MAX_STREAMS){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
22 printf("Too many streams! increase AVIWRITE_MAX_STREAMS !\n");
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
23 return NULL;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
24 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
25 s=malloc(sizeof(aviwrite_stream_t));
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
26 memset(s,0,sizeof(aviwrite_stream_t));
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
27 if(!s) return NULL; // no mem!?
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
28 muxer->streams[muxer->avih.dwStreams]=s;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
29 s->type=type;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
30 s->id=muxer->avih.dwStreams;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
31 s->timer=0.0;
2652
fd279f14b9ab new stream field: size
arpi
parents: 2635
diff changeset
32 s->size=0;
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
33 switch(type){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
34 case AVIWRITE_TYPE_VIDEO:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
35 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
36 s->h.fccType=streamtypeVIDEO;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
37 if(!muxer->def_v) muxer->def_v=s;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
38 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
39 case AVIWRITE_TYPE_AUDIO:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
40 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'w','b');
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
41 s->h.fccType=streamtypeAUDIO;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
42 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
43 default:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
44 printf("WarninG! unknown stream type: %d\n",type);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
45 return NULL;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
46 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
47 muxer->avih.dwStreams++;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
48 return s;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
49 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
51 aviwrite_t* aviwrite_new_muxer(){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
52 aviwrite_t* muxer=malloc(sizeof(aviwrite_t));
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
53 memset(muxer,0,sizeof(aviwrite_t));
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
54 return muxer;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
55 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
56
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
57 static void write_avi_chunk(FILE *f,unsigned int id,int len,void* data){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 fwrite(&id,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 fwrite(&len,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 if(len>0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 if(data){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 // DATA
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 fwrite(data,len,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 if(len&1){ // padding
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 unsigned char zerobyte=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 fwrite(&zerobyte,1,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 // JUNK
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 char *avi_junk_data="[= MPlayer junk data! =]";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 if(len&1) ++len; // padding
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 while(len>0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 int l=strlen(avi_junk_data);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 if(l>len) l=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 fwrite(avi_junk_data,l,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 len-=l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 }
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
80 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
81
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
82 void aviwrite_write_chunk(aviwrite_t *muxer,aviwrite_stream_t *s, FILE *f,int len,unsigned int flags){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
83
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
84 // add to the index:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
85 if(muxer->idx_pos>=muxer->idx_size){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
86 muxer->idx_size+=256; // 4kB
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
87 muxer->idx=realloc(muxer->idx,16*muxer->idx_size);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
88 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
89 muxer->idx[muxer->idx_pos].ckid=s->ckid;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
90 muxer->idx[muxer->idx_pos].dwFlags=flags; // keyframe?
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
91 muxer->idx[muxer->idx_pos].dwChunkOffset=ftell(f)-(muxer->movi_start-4);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
92 muxer->idx[muxer->idx_pos].dwChunkLength=len;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
93 ++muxer->idx_pos;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
94
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
95 // write out the chunk:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
96 write_avi_chunk(f,s->ckid,len,s->buffer);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
97
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
98 // alter counters:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
99 if(s->h.dwSampleSize){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
100 // CBR
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
101 s->h.dwLength+=len/s->h.dwSampleSize;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
102 if(len%s->h.dwSampleSize) printf("Warning! len isn't divisable by samplesize!\n");
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
103 } else {
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
104 // VBR
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
105 s->h.dwLength++;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
106 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
107 s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate;
2652
fd279f14b9ab new stream field: size
arpi
parents: 2635
diff changeset
108 s->size+=len;
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
109 if(len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
113 static void write_avi_list(FILE *f,unsigned int id,int len){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 unsigned int list_id=FOURCC_LIST;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 len+=4; // list fix
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 fwrite(&list_id,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 fwrite(&len,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 fwrite(&id,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120
2635
c1e24e01601b fixed AVI header creation - now should be compatible with NaNdub
arpi
parents: 2555
diff changeset
121 // muxer->streams[i]->wf->cbSize
c1e24e01601b fixed AVI header creation - now should be compatible with NaNdub
arpi
parents: 2555
diff changeset
122 #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
123
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
124 void aviwrite_write_header(aviwrite_t *muxer,FILE *f){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 unsigned int riff[3];
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
126 int i;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
127 unsigned int hdrsize;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 // RIFF header:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 riff[0]=mmioFOURCC('R','I','F','F');
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
130 riff[1]=muxer->file_end; // filesize
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 riff[2]=formtypeAVI; // 'AVI '
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 fwrite(&riff,12,1,f);
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
133
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
134 // update AVI header:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
135 if(muxer->def_v){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
136 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
137 // muxer->avih.dwMaxBytesPerSec=1000000; // dummy!!!!! FIXME
c1e24e01601b fixed AVI header creation - now should be compatible with NaNdub
arpi
parents: 2555
diff changeset
138 // muxer->avih.dwPaddingGranularity=2; // ???
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
139 muxer->avih.dwFlags|=AVIF_ISINTERLEAVED|AVIF_TRUSTCKTYPE;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
140 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
141 // muxer->avih.dwSuggestedBufferSize=muxer->def_v->h.dwSuggestedBufferSize;
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
142 muxer->avih.dwWidth=muxer->def_v->bih->biWidth;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
143 muxer->avih.dwHeight=muxer->def_v->bih->biHeight;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
144 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
145
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 // AVI header:
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
147 hdrsize=sizeof(muxer->avih)+8;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
148 // calc total header size:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
149 for(i=0;i<muxer->avih.dwStreams;i++){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
150 hdrsize+=12; // LIST
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
151 hdrsize+=sizeof(muxer->streams[i]->h)+8; // strh
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
152 switch(muxer->streams[i]->type){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
153 case AVIWRITE_TYPE_VIDEO:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
154 hdrsize+=muxer->streams[i]->bih->biSize+8; // strf
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
155 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
156 case AVIWRITE_TYPE_AUDIO:
2635
c1e24e01601b fixed AVI header creation - now should be compatible with NaNdub
arpi
parents: 2555
diff changeset
157 hdrsize+=WFSIZE(muxer->streams[i]->wf)+8; // strf
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
158 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
159 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
160 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
161 write_avi_list(f,listtypeAVIHEADER,hdrsize);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
162 write_avi_chunk(f,ckidAVIMAINHDR,sizeof(muxer->avih),&muxer->avih);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
163
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
164 // stream headers:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
165 for(i=0;i<muxer->avih.dwStreams;i++){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
166 hdrsize=sizeof(muxer->streams[i]->h)+8; // strh
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
167 switch(muxer->streams[i]->type){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
168 case AVIWRITE_TYPE_VIDEO:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
169 hdrsize+=muxer->streams[i]->bih->biSize+8; // strf
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
170 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
171 case AVIWRITE_TYPE_AUDIO:
2635
c1e24e01601b fixed AVI header creation - now should be compatible with NaNdub
arpi
parents: 2555
diff changeset
172 hdrsize+=WFSIZE(muxer->streams[i]->wf)+8; // strf
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
173 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
174 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
175 write_avi_list(f,listtypeSTREAMHEADER,hdrsize);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
176 write_avi_chunk(f,ckidSTREAMHEADER,sizeof(muxer->streams[i]->h),&muxer->streams[i]->h); // strh
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
177 switch(muxer->streams[i]->type){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
178 case AVIWRITE_TYPE_VIDEO:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
179 write_avi_chunk(f,ckidSTREAMFORMAT,muxer->streams[i]->bih->biSize,muxer->streams[i]->bih);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
180 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
181 case AVIWRITE_TYPE_AUDIO:
2635
c1e24e01601b fixed AVI header creation - now should be compatible with NaNdub
arpi
parents: 2555
diff changeset
182 write_avi_chunk(f,ckidSTREAMFORMAT,WFSIZE(muxer->streams[i]->wf),muxer->streams[i]->wf);
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
183 break;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
184 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
185 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
186
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
187 // JUNK:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 write_avi_chunk(f,ckidAVIPADDING,2048-(ftell(f)&2047)-8,NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 // 'movi' header:
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
190 write_avi_list(f,listtypeAVIMOVIE,muxer->movi_end-ftell(f)-12);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
191 muxer->movi_start=ftell(f);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193
2529
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
194 void aviwrite_write_index(aviwrite_t *muxer,FILE *f){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
195 muxer->movi_end=ftell(f);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
196 if(muxer->idx && muxer->idx_pos>0){
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
197 // fixup index entries:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
198 // int i;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
199 // for(i=0;i<muxer->idx_pos;i++) muxer->idx[i].dwChunkOffset-=muxer->movi_start-4;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
200 // write index chunk:
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
201 write_avi_chunk(f,ckidAVINEWINDEX,16*muxer->idx_pos,muxer->idx);
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
202 muxer->avih.dwFlags|=AVIF_HASINDEX;
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
203 }
266dab71162b AVI muxer rewritten
arpi
parents: 2310
diff changeset
204 muxer->file_end=ftell(f);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206