Mercurial > mplayer.hg
annotate TOOLS/avi-fix.c @ 35802:2849b02700e5
Remove pointless menuIsInitialized.
The draw handler won't be called prior to the initialization,
because it is set only during initialization.
author | ib |
---|---|
date | Sat, 26 Jan 2013 00:45:58 +0000 |
parents | b573c7c7173b |
children |
rev | line source |
---|---|
30416
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
1 /* avi-fix v0.1 (C) A'rpi |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
2 * simple tool to fix chunk sizes in a RIFF AVI file |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
3 * it doesn't check/fix index, use mencoder -forceidx -oac copy -ovc copy to fix index! |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
4 * |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
8 * (at your option) any later version. |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
9 * |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
13 * GNU General Public License for more details. |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
14 * |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
15 * You should have received a copy of the GNU General Public License along |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
16 * with this program; if not, write to the Free Software Foundation, Inc., |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
b573c7c7173b
Add standard license header to C tools missing them.
diego
parents:
24235
diff
changeset
|
18 */ |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
19 |
17017 | 20 #include "config.h" |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
21 #ifdef MP_DEBUG |
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
22 #define mp_debug(...) printf(__VA_ARGS__) |
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
23 #else |
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
24 #define mp_debug(...) |
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
25 #endif |
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
26 |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
27 #include <stdio.h> |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
28 #include <stdlib.h> |
23657 | 29 #include <string.h> |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
30 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
31 #define FCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d)) |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
32 |
24235 | 33 static inline char xx(unsigned char c){ |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
34 if(c>=32 && c<128) return c; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
35 return '?'; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
36 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
37 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
38 static inline unsigned int getid(FILE* f){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
39 unsigned int id; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
40 id=fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
41 id=(id<<8)|fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
42 id=(id<<8)|fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
43 id=(id<<8)|fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
44 return id; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
45 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
46 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
47 int main(int argc,char* argv[]){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
48 //FILE* f=fopen("edgar.avi","rb"); // readonly (report errors) |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
49 //FILE* f=fopen("edgar.avi","rb+"); // fix mode (fix chunk sizes) |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
50 unsigned int lastgood=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
51 unsigned int fixat=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
52 unsigned int offset=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
53 int fix_flag=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
54 FILE* f; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
55 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
56 if(argc<=1){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
57 printf("Usage: %s [-fix] badfile.avi\n",argv[0]); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
58 exit(1); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
59 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
60 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
61 if(!strcmp(argv[1],"-fix")){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
62 fix_flag=1; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
63 f=fopen(argv[argc-1],"rb+"); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
64 } else |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
65 f=fopen(argv[argc-1],"rb"); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
66 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
67 if(!f){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
68 perror("error"); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
69 printf("couldnt open '%s'\n",argv[argc-1]); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
70 exit(2); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
71 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
72 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
73 while(1){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
74 unsigned int id,len; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
75 again: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
76 id=fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
77 id=(id<<8)|fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
78 id=(id<<8)|fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
79 faszom: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
80 if(feof(f)) break; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
81 // if(!lastgood && feof(f)) break; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
82 id=(id<<8)|fgetc(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
83 // lastgood=ftell(f); |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
84 mp_debug("%08X: %c%c%c%c\n",(int)ftell(f)-4,xx(id>>24),xx(id>>16),xx(id>>8),xx(id)); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
85 switch(id){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
86 case FCC('R','I','F','F'): |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
87 fread(&len,4,1,f); // filesize |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
88 id=getid(f); // AVI |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
89 mp_debug("RIFF header, filesize=0x%X format=%c%c%c%c\n",len,xx(id>>24),xx(id>>16),xx(id>>8),xx(id)); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
90 break; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
91 case FCC('L','I','S','T'): |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
92 fread(&len,4,1,f); // size |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
93 id=getid(f); // AVI |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
94 mp_debug("LIST size=0x%X format=%c%c%c%c\n",len,xx(id>>24),xx(id>>16),xx(id>>8),xx(id)); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
95 //case FCC('h','d','r','l'): |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
96 //case FCC('s','t','r','l'): |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
97 //case FCC('o','d','m','l'): |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
98 //case FCC('m','o','v','i'): |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
99 break; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
100 // legal chunk IDs: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
101 case FCC('a','v','i','h'): // avi header |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
102 case FCC('s','t','r','h'): // stream header |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
103 case FCC('s','t','r','f'): // stream format |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
104 case FCC('J','U','N','K'): // official shit |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
105 // index: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
106 case FCC('i','d','x','1'): // main index?? |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
107 case FCC('d','m','l','h'): // opendml header |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
108 case FCC('i','n','d','x'): // opendml main index?? |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
109 case FCC('i','x','0','0'): // opendml sub index?? |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
110 case FCC('i','x','0','1'): // opendml sub index?? |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
111 // data: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
112 case FCC('0','1','w','b'): // audio track #1 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
113 case FCC('0','2','w','b'): // audio track #2 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
114 case FCC('0','3','w','b'): // audio track #3 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
115 case FCC('0','0','d','b'): // uncompressed video |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
116 case FCC('0','0','d','c'): // compressed video |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
117 case FCC('0','0','_','_'): // A-V interleaved (type2 DV file) |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
118 // info: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
119 case FCC('I','S','F','T'): // INFO: software |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
120 case FCC('I','S','R','C'): // INFO: source |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
121 case FCC('I','N','A','M'): // INFO: name |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
122 case FCC('I','S','B','J'): // INFO: subject |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
123 case FCC('I','A','R','T'): // INFO: artist |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
124 case FCC('I','C','O','P'): // INFO: copyright |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
125 case FCC('I','C','M','T'): // INFO: comment |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
126 lastgood=ftell(f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
127 if(fixat && fix_flag){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
128 // fix last chunk's size field: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
129 fseek(f,fixat,SEEK_SET); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
130 len=lastgood-fixat-8; |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
131 mp_debug("Correct len to 0x%X\n",len); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
132 fwrite(&len,4,1,f); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
133 fseek(f,lastgood,SEEK_SET); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
134 fixat=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
135 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
136 fread(&len,4,1,f); // size |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
137 mp_debug("ID ok, chunk len=0x%X\n",len); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
138 len+=len&1; // align at 2 |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
139 fseek(f,len,SEEK_CUR); // skip data |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
140 break; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
141 default: |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
142 if(!lastgood){ |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
143 ++offset; |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
144 mp_debug("invalid ID, trying %d byte offset\n",offset); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
145 goto faszom; // try again @ next post |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
146 } |
16234
31660114d885
silly printf() is the onyl reason avi-fix was so slow, a printf for
ods15
parents:
11924
diff
changeset
|
147 mp_debug("invalid ID, parsing next chunk's data at 0x%X\n",lastgood); |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
148 fseek(f,lastgood,SEEK_SET); |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
149 fixat=lastgood; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
150 lastgood=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
151 goto again; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
152 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
153 offset=0; |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
154 } |
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
155 |
23659
f15f95c2671a
Fix "control reaches end of non-void function" warnings.
diego
parents:
23657
diff
changeset
|
156 return 0; |
11924
217d10ec0e18
avi-fix v0.1: simple tool to fix chunk sizes in a RIFF AVI file
arpi
parents:
diff
changeset
|
157 } |