Mercurial > mplayer.hg
annotate TOOLS/vivodump.c @ 27409:e2de11109139
If (has outline) blur(outline) else blur(glyph).
If there is an outline, the glyph itself should not be blurred. Keeps
the border between glyph and outline clear (unblurred), which is
probably how it should be.
Patch by Diogo Franco (diogomfranco gmail com).
author | eugeni |
---|---|
date | Thu, 07 Aug 2008 22:20:58 +0000 |
parents | 8825552ee585 |
children | 0f1b5b68af32 |
rev | line source |
---|---|
2665 | 1 #include <stdio.h> |
2667 | 2 #include <stdlib.h> |
3 #include <string.h> | |
13783 | 4 #include <inttypes.h> |
2667 | 5 |
13783 | 6 #include "loader/wine/mmreg.h" |
7 #include "loader/wine/vfw.h" | |
8 | |
22627 | 9 #include "stream/stream.h" |
13783 | 10 #include "libmpdemux/muxer.h" |
22627 | 11 #include "libmpdemux/demuxer.h" |
2667 | 12 |
26963
8825552ee585
Fix the linking of TOOLS/netstream and TOOLS/vivodump.
diego
parents:
26580
diff
changeset
|
13 /* linking hacks */ |
13783 | 14 char *info_name; |
15 char *info_artist; | |
16 char *info_genre; | |
17 char *info_subject; | |
18 char *info_copyright; | |
19 char *info_sourceform; | |
20 char *info_comment; | |
2665 | 21 |
26963
8825552ee585
Fix the linking of TOOLS/netstream and TOOLS/vivodump.
diego
parents:
26580
diff
changeset
|
22 char* out_filename = NULL; |
8825552ee585
Fix the linking of TOOLS/netstream and TOOLS/vivodump.
diego
parents:
26580
diff
changeset
|
23 char* force_fourcc=NULL; |
8825552ee585
Fix the linking of TOOLS/netstream and TOOLS/vivodump.
diego
parents:
26580
diff
changeset
|
24 char* passtmpfile="divx2pass.log"; |
8825552ee585
Fix the linking of TOOLS/netstream and TOOLS/vivodump.
diego
parents:
26580
diff
changeset
|
25 |
2665 | 26 static const short h263_format[8][2] = { |
27 { 0, 0 }, | |
28 { 128, 96 }, | |
29 { 176, 144 }, | |
30 { 352, 288 }, | |
31 { 704, 576 }, | |
32 { 1408, 1152 }, | |
2696 | 33 { 320, 240 } |
2665 | 34 }; |
35 | |
36 unsigned char* buffer; | |
37 int bufptr=0; | |
38 int bitcnt=0; | |
39 unsigned char buf=0; | |
40 | |
26575
1ca484e74f18
Mark all functions that are only used within the file as static.
diego
parents:
25309
diff
changeset
|
41 static unsigned int x_get_bits(int n){ |
2665 | 42 unsigned int x=0; |
43 while(n-->0){ | |
44 if(!bitcnt){ | |
45 // fill buff | |
46 buf=buffer[bufptr++]; | |
47 bitcnt=8; | |
48 } | |
49 //x=(x<<1)|(buf&1);buf>>=1; | |
50 x=(x<<1)|(buf>>7);buf<<=1; | |
51 --bitcnt; | |
52 } | |
53 return x; | |
54 } | |
55 | |
56 #define get_bits(xxx,n) x_get_bits(n) | |
57 #define get_bits1(xxx) x_get_bits(1) | |
58 #define skip_bits(xxx,n) x_get_bits(n) | |
59 #define skip_bits1(xxx) x_get_bits(1) | |
60 | |
2696 | 61 int format; |
62 int width=320; | |
63 int height=240; | |
2667 | 64 |
2665 | 65 /* most is hardcoded. should extend to handle all h263 streams */ |
26575
1ca484e74f18
Mark all functions that are only used within the file as static.
diego
parents:
25309
diff
changeset
|
66 static int h263_decode_picture_header(unsigned char *b_ptr) |
2665 | 67 { |
2696 | 68 int i; |
69 | |
70 for(i=0;i<16;i++) printf(" %02X",b_ptr[i]); printf("\n"); | |
2665 | 71 |
72 buffer=b_ptr; | |
73 bufptr=bitcnt=buf=0; | |
74 | |
75 /* picture header */ | |
2696 | 76 if (get_bits(&s->gb, 22) != 0x20){ |
77 printf("bad picture header\n"); | |
2665 | 78 return -1; |
2696 | 79 } |
2665 | 80 skip_bits(&s->gb, 8); /* picture timestamp */ |
81 | |
2696 | 82 if (get_bits1(&s->gb) != 1){ |
83 printf("bad marker\n"); | |
2665 | 84 return -1; /* marker */ |
2696 | 85 } |
86 if (get_bits1(&s->gb) != 0){ | |
87 printf("bad h263 id\n"); | |
2665 | 88 return -1; /* h263 id */ |
2696 | 89 } |
2665 | 90 skip_bits1(&s->gb); /* split screen off */ |
91 skip_bits1(&s->gb); /* camera off */ | |
92 skip_bits1(&s->gb); /* freeze picture release off */ | |
93 | |
94 format = get_bits(&s->gb, 3); | |
95 | |
96 if (format != 7) { | |
97 printf("h263_plus = 0 format = %d\n",format); | |
98 /* H.263v1 */ | |
99 width = h263_format[format][0]; | |
100 height = h263_format[format][1]; | |
101 printf("%d x %d\n",width,height); | |
2696 | 102 // if (!width) return -1; |
2665 | 103 |
104 printf("pict_type=%d\n",get_bits1(&s->gb)); | |
105 printf("unrestricted_mv=%d\n",get_bits1(&s->gb)); | |
106 #if 1 | |
107 printf("SAC: %d\n",get_bits1(&s->gb)); | |
108 printf("advanced prediction mode: %d\n",get_bits1(&s->gb)); | |
109 printf("PB frame: %d\n",get_bits1(&s->gb)); | |
110 #else | |
111 if (get_bits1(&s->gb) != 0) | |
112 return -1; /* SAC: off */ | |
113 if (get_bits1(&s->gb) != 0) | |
114 return -1; /* advanced prediction mode: off */ | |
115 if (get_bits1(&s->gb) != 0) | |
116 return -1; /* not PB frame */ | |
117 #endif | |
118 printf("qscale=%d\n",get_bits(&s->gb, 5)); | |
119 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ | |
120 } else { | |
121 printf("h263_plus = 1\n"); | |
122 /* H.263v2 */ | |
2696 | 123 if (get_bits(&s->gb, 3) != 1){ |
124 printf("H.263v2 A error\n"); | |
2665 | 125 return -1; |
2696 | 126 } |
127 if (get_bits(&s->gb, 3) != 6){ /* custom source format */ | |
128 printf("custom source format\n"); | |
2665 | 129 return -1; |
2696 | 130 } |
2665 | 131 skip_bits(&s->gb, 12); |
132 skip_bits(&s->gb, 3); | |
133 printf("pict_type=%d\n",get_bits(&s->gb, 3) + 1); | |
134 // if (s->pict_type != I_TYPE && | |
135 // s->pict_type != P_TYPE) | |
136 // return -1; | |
137 skip_bits(&s->gb, 7); | |
138 skip_bits(&s->gb, 4); /* aspect ratio */ | |
139 width = (get_bits(&s->gb, 9) + 1) * 4; | |
140 skip_bits1(&s->gb); | |
141 height = get_bits(&s->gb, 9) * 4; | |
142 printf("%d x %d\n",width,height); | |
2696 | 143 //if (height == 0) |
144 // return -1; | |
2665 | 145 printf("qscale=%d\n",get_bits(&s->gb, 5)); |
146 } | |
147 | |
148 /* PEI */ | |
149 while (get_bits1(&s->gb) != 0) { | |
150 skip_bits(&s->gb, 8); | |
151 } | |
152 // s->f_code = 1; | |
153 // s->width = width; | |
154 // s->height = height; | |
155 return 0; | |
156 } | |
157 | |
2667 | 158 int postable[32768]; |
2665 | 159 |
13801
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
160 int main(int argc,char ** argv){ |
2665 | 161 int c; |
13784
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
162 FILE *f; |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
163 FILE *f2; |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
164 muxer_t* avi; |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
165 muxer_stream_t* mux; |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
166 //unsigned char* buffer=malloc(0x200000); |
2696 | 167 int i,len; |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
168 int v_id=0; |
2696 | 169 int flag2=0; |
3233 | 170 int prefix=0; |
2667 | 171 |
13801
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
172 // check if enough args were given |
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
173 if ( argc < 3 ){ |
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
174 printf("Too few arguments given!\n" |
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
175 "Usage: %s <input_file> <output_file>\n", argv[0]); |
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
176 |
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
177 return -1; |
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
178 } |
13784
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
179 // input |
13801
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
180 if(!(f=fopen(argv[1],"rb"))){ |
13784
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
181 printf("Couldn't open input file.\n"); |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
182 return -1; |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
183 } |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
184 // output |
13801
245f5d4b4af7
Fixed the assumption user will always give 2+ args to the program.
al
parents:
13784
diff
changeset
|
185 if(!(f2=fopen(argv[2],"wb"))){ |
13784
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
186 printf("Couldn't open output file.\n"); |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
187 return -1; |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
188 } |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
189 |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
190 avi=muxer_new_muxer(MUXER_TYPE_AVI,f2); |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
191 mux=muxer_new_stream(avi,MUXER_TYPE_VIDEO); |
7d3b84ddd2fd
Remove hardcoded filenames in favor of command line parameters, some error
diego
parents:
13783
diff
changeset
|
192 |
2667 | 193 mux->buffer_size=0x200000; |
194 mux->buffer=malloc(mux->buffer_size); | |
195 | |
196 mux->h.dwScale=1; | |
197 mux->h.dwRate=10; | |
2665 | 198 |
2667 | 199 mux->bih=malloc(sizeof(BITMAPINFOHEADER)); |
200 mux->bih->biSize=sizeof(BITMAPINFOHEADER); | |
201 mux->bih->biPlanes=1; | |
202 mux->bih->biBitCount=24; | |
203 mux->bih->biCompression=0x6f766976;// 7669766f; | |
9014
c671e9adbe22
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
204 muxer_write_header(avi); |
2667 | 205 |
2696 | 206 /* |
207 c=fgetc(f); if(c) printf("error! not vivo file?\n"); | |
208 len=0; | |
209 while((c=fgetc(f))>=0x80) len+=0x80*(c&0x0F); | |
210 len+=c; | |
211 printf("hdr1: %d\n",len); | |
212 for(i=0;i<len;i++) fgetc(f); | |
213 */ | |
214 | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
215 while((c=fgetc(f))>=0){ |
2696 | 216 |
25309
8e73e469970c
Fix printf format string length modifiers, removes the warnings:
diego
parents:
24203
diff
changeset
|
217 printf("%08lX %02X\n",ftell(f),c); |
3233 | 218 |
219 prefix=0; | |
220 if(c==0x82){ | |
221 prefix=1; | |
222 //continue; | |
223 c=fgetc(f); | |
25309
8e73e469970c
Fix printf format string length modifiers, removes the warnings:
diego
parents:
24203
diff
changeset
|
224 printf("%08lX %02X\n",ftell(f),c); |
3233 | 225 } |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
226 |
2696 | 227 if(c==0x00){ |
228 // header | |
229 int len=0; | |
230 while((c=fgetc(f))>=0x80) len+=0x80*(c&0x0F); | |
231 len+=c; | |
232 printf("header: 00 (%d)\n",len); | |
233 for(i=0;i<len;i++) fgetc(f); | |
234 continue; | |
235 } | |
236 | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
237 if((c&0xF0)==0x40){ |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
238 // audio |
3233 | 239 len=24; |
240 if(prefix) len=fgetc(f); | |
241 printf("audio: %02X (%d)\n",c,len); | |
242 for(i=0;i<len;i++) fgetc(f); | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
243 continue; |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
244 } |
2696 | 245 if((c&0xF0)==0x30){ |
246 // audio | |
3233 | 247 len=40; |
248 if(prefix) len=fgetc(f); | |
249 printf("audio: %02X (%d)\n",c,len); | |
250 for(i=0;i<len;i++) fgetc(f); | |
2696 | 251 continue; |
252 } | |
253 if(flag2 || (((c&0xF0)==0x10 || (c&0xF0)==0x20) && (c&0x0F)!=(v_id&0xF))){ | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
254 // end of frame: |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
255 printf("Frame size: %d\n",mux->buffer_len); |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
256 h263_decode_picture_header(mux->buffer); |
17487
fa17424b4c7b
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents:
13801
diff
changeset
|
257 muxer_write_chunk(mux,mux->buffer_len,0x10, MP_NOPTS_VALUE, MP_NOPTS_VALUE); |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
258 mux->buffer_len=0; |
2696 | 259 |
260 if((v_id&0xF0)==0x10) fprintf(stderr,"hmm. last video packet %02X\n",v_id); | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
261 } |
2696 | 262 flag2=0; |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
263 if((c&0xF0)==0x10){ |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
264 // 128 byte |
3233 | 265 len=128; |
266 if(prefix) len=fgetc(f); | |
267 printf("video: %02X (%d)\n",c,len); | |
268 fread(mux->buffer+mux->buffer_len,len,1,f); | |
269 mux->buffer_len+=len; | |
270 v_id=c; | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
271 continue; |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
272 } |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
273 if((c&0xF0)==0x20){ |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
274 int len=fgetc(f); |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
275 printf("video: %02X (%d)\n",c,len); |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
276 fread(mux->buffer+mux->buffer_len,len,1,f); |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
277 mux->buffer_len+=len; |
2696 | 278 flag2=1; |
3233 | 279 v_id=c; |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
280 continue; |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
281 } |
2696 | 282 printf("error: %02X!\n",c); |
3233 | 283 exit(1); |
2665 | 284 } |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
285 |
2696 | 286 if(!width) width=320; |
287 if(!height) height=240; | |
288 | |
2672
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
289 mux->bih->biWidth=width; |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
290 mux->bih->biHeight=height; |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
291 mux->bih->biSizeImage=3*width*height; |
1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents:
2667
diff
changeset
|
292 |
9014
c671e9adbe22
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
293 muxer_write_index(avi); |
2667 | 294 fseek(f2,0,SEEK_SET); |
9014
c671e9adbe22
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
295 muxer_write_header(avi); |
2667 | 296 |
24203 | 297 return 0; |
2667 | 298 } |