Mercurial > mplayer.hg
annotate libmpdemux/demux_viv.c @ 3347:21af9f3d5372
Minor fixes
author | nick |
---|---|
date | Thu, 06 Dec 2001 10:21:02 +0000 |
parents | 1e2a87b7cae8 |
children | 192449c155c7 |
rev | line source |
---|---|
2687 | 1 // VIVO file parser by A'rpi |
2784 | 2 // VIVO text header parser by alex |
2687 | 3 |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <unistd.h> | |
2928 | 7 #include <string.h> /* strtok */ |
2687 | 8 |
9 #include "config.h" | |
10 #include "mp_msg.h" | |
11 #include "help_mp.h" | |
12 | |
13 #include "stream.h" | |
14 #include "demuxer.h" | |
15 #include "stheader.h" | |
16 | |
17 #include "bswap.h" | |
18 | |
19 typedef struct { | |
2784 | 20 /* generic */ |
3113
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
21 char version; |
2784 | 22 int supported; |
23 /* info */ | |
24 char *title; | |
25 char *author; | |
26 char *copyright; | |
27 char *producer; | |
28 /* video */ | |
29 float fps; | |
30 int width; | |
31 int height; | |
32 int disp_width; | |
33 int disp_height; | |
34 /* audio */ | |
35 int br; | |
36 int samplerate; | |
2687 | 37 } vivo_priv_t; |
38 | |
2784 | 39 /* parse all possible extra headers */ |
40 /* (audio headers are seperate - mostly with recordtype=3) */ | |
41 #define TEXTPARSE_ALL 1 | |
42 | |
43 static void vivo_parse_text_header(demuxer_t *demux, int header_len) | |
44 { | |
45 vivo_priv_t* priv = demux->priv; | |
46 char *buf; | |
47 int i; | |
48 char *token; | |
49 char *opt, *param; | |
50 | |
51 if (!demux->priv) | |
52 { | |
53 priv = malloc(sizeof(vivo_priv_t)); | |
54 memset(priv, 0, sizeof(vivo_priv_t)); | |
55 demux->priv = priv; | |
56 priv->supported = 0; | |
57 } | |
58 | |
59 buf = malloc(header_len); | |
60 opt = malloc(header_len); | |
61 param = malloc(header_len); | |
62 stream_read(demux->stream, buf, header_len); | |
63 i=0; | |
64 while(i<header_len && buf[i]==0x0D && buf[i+1]==0x0A) i+=2; // skip empty lines | |
65 | |
66 token = strtok(buf, (char *)&("\x0d\x0a")); | |
67 while (token && (header_len>2)) | |
68 { | |
69 header_len -= strlen(token)+2; | |
70 if (sscanf(token, "%[^:]:%[^\n]", opt, param) != 2) | |
71 { | |
72 mp_msg(MSGT_DEMUX, MSGL_V, "viv_text_header_parser: bad line: '%s' at ~%p\n", | |
73 token, stream_tell(demux->stream)); | |
74 break; | |
75 } | |
76 mp_msg(MSGT_DEMUX, MSGL_DBG3, "token: '%s' (%d bytes/%d bytes left)\n", | |
77 token, strlen(token), header_len); | |
78 mp_msg(MSGT_DEMUX, MSGL_DBG3, "token => o: '%s', p: '%s'\n", | |
79 opt, param); | |
80 | |
81 /* checking versions: only v1 or v2 is suitable (or known?:) */ | |
82 if (!strcmp(opt, "Version")) | |
83 { | |
84 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Version: %s\n", param); | |
2928 | 85 if (!strncmp(param, "Vivo/1", 6) || !strncmp(param, "Vivo/2", 6)) |
3113
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
86 { |
2928 | 87 // if (atoi(param) == 1 || atoi(param) == 2) |
2784 | 88 priv->supported = 1; |
3113
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
89 /* safe version for fourcc */ |
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
90 priv->version = param[5]; |
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
91 } |
2784 | 92 } |
93 | |
94 /* video specific */ | |
95 if (!strcmp(opt, "FPS")) | |
96 { | |
97 mp_msg(MSGT_DEMUX, MSGL_DBG2, "FPS: %f\n", atof(param)); | |
98 priv->fps = atof(param); | |
99 } | |
100 if (!strcmp(opt, "Width")) | |
101 { | |
102 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Width: %d\n", atoi(param)); | |
103 priv->width = atoi(param); | |
104 } | |
105 if (!strcmp(opt, "Height")) | |
106 { | |
107 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Height: %d\n", atoi(param)); | |
108 priv->height = atoi(param); | |
109 } | |
110 if (!strcmp(opt, "DisplayWidth")) | |
111 { | |
112 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Display Width: %d\n", atoi(param)); | |
113 priv->disp_width = atoi(param); | |
114 } | |
115 if (!strcmp(opt, "DisplayHeight")) | |
116 { | |
117 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Display Height: %d\n", atoi(param)); | |
118 priv->disp_height = atoi(param); | |
119 } | |
120 | |
121 /* audio specific */ | |
122 if (!strcmp(opt, "NominalBitrate")) | |
123 { | |
124 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Bitrate: %d\n", atoi(param)); | |
125 priv->br = atoi(param); | |
126 } | |
127 if (!strcmp(opt, "SamplingFrequency")) | |
128 { | |
129 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Samplerate: %d\n", atoi(param)); | |
130 priv->samplerate = atoi(param); | |
131 } | |
132 | |
133 /* only for displaying some informations about movie*/ | |
134 if (!strcmp(opt, "Title")) | |
135 { | |
136 mp_msg(MSGT_DEMUX, MSGL_INFO, " Title: %s\n", param); | |
3068 | 137 demux_info_add(demux, "name", param); |
2784 | 138 priv->title = malloc(strlen(param)); |
139 strcpy(priv->title, param); | |
140 } | |
141 if (!strcmp(opt, "Author")) | |
142 { | |
143 mp_msg(MSGT_DEMUX, MSGL_INFO, " Author: %s\n", param); | |
3068 | 144 demux_info_add(demux, "author", param); |
2784 | 145 priv->author = malloc(strlen(param)); |
146 strcpy(priv->author, param); | |
147 } | |
148 if (!strcmp(opt, "Copyright")) | |
149 { | |
150 mp_msg(MSGT_DEMUX, MSGL_INFO, " Copyright: %s\n", param); | |
3068 | 151 demux_info_add(demux, "copyright", param); |
2784 | 152 priv->copyright = malloc(strlen(param)); |
153 strcpy(priv->copyright, param); | |
154 } | |
155 if (!strcmp(opt, "Producer")) | |
156 { | |
157 mp_msg(MSGT_DEMUX, MSGL_INFO, " Producer: %s\n", param); | |
3069 | 158 demux_info_add(demux, "encoder", param); |
2784 | 159 priv->producer = malloc(strlen(param)); |
160 strcpy(priv->producer, param); | |
161 } | |
162 | |
163 /* get next token */ | |
164 token = strtok(NULL, (char *)&("\x0d\x0a")); | |
165 } | |
2788 | 166 |
167 if (buf) | |
168 free(buf); | |
169 if (opt) | |
170 free(opt); | |
171 if (param) | |
172 free(param); | |
2784 | 173 } |
174 | |
2687 | 175 int vivo_check_file(demuxer_t* demuxer){ |
176 int flags=0; | |
177 int i=0; | |
178 int len; | |
179 int len2; | |
180 int c; | |
181 unsigned char buf[2048+256]; | |
182 vivo_priv_t* priv; | |
2784 | 183 int orig_pos = stream_tell(demuxer->stream); |
2687 | 184 |
185 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for VIVO\n"); | |
186 | |
187 c=stream_read_char(demuxer->stream); | |
2792 | 188 if(c==-256) return 0; |
2687 | 189 len=0; |
190 while((c=stream_read_char(demuxer->stream))>=0x80){ | |
191 len+=0x80*(c-0x80); | |
192 if(len>1024) return 0; | |
193 } | |
194 len+=c; | |
195 printf("header block 1 size: %d\n",len); | |
196 //stream_skip(demuxer->stream,len); | |
2928 | 197 |
198 priv=malloc(sizeof(vivo_priv_t)); | |
199 memset(priv,0,sizeof(vivo_priv_t)); | |
200 demuxer->priv=priv; | |
2784 | 201 |
2805 | 202 #if 0 |
2785 | 203 vivo_parse_text_header(demuxer, len); |
2784 | 204 if (priv->supported == 0) |
205 return 0; | |
206 #else | |
2928 | 207 /* this is enought for check (for now) */ |
208 stream_read(demuxer->stream,buf,len); | |
209 buf[len]=0; | |
210 // printf("VIVO header: '%s'\n",buf); | |
211 | |
2687 | 212 // parse header: |
213 i=0; | |
214 while(i<len && buf[i]==0x0D && buf[i+1]==0x0A) i+=2; // skip empty lines | |
2695 | 215 if(strncmp(buf+i,"Version:Vivo/",13)) return 0; // bad version/type! |
2784 | 216 #endif |
2687 | 217 |
2695 | 218 #if 0 |
2687 | 219 c=stream_read_char(demuxer->stream); |
220 if(c) return 0; | |
221 len2=0; | |
222 while((c=stream_read_char(demuxer->stream))>=0x80){ | |
223 len2+=0x80*(c-0x80); | |
224 if(len+len2>2048) return 0; | |
225 } | |
226 len2+=c; | |
227 printf("header block 2 size: %d\n",len2); | |
228 stream_skip(demuxer->stream,len2); | |
229 // stream_read(demuxer->stream,buf+len,len2); | |
2695 | 230 #endif |
2687 | 231 |
232 // c=stream_read_char(demuxer->stream); | |
233 // printf("first packet: %02X\n",c); | |
234 | |
2784 | 235 stream_seek(demuxer->stream, orig_pos); |
236 | |
2687 | 237 return 1; |
238 } | |
239 | |
240 // return value: | |
241 // 0 = EOF or no stream found | |
242 // 1 = successfully read a packet | |
243 int demux_vivo_fill_buffer(demuxer_t *demux){ | |
244 demux_stream_t *ds=NULL; | |
245 int c; | |
246 int len=0; | |
247 int seq; | |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
248 int prefix=0; |
2687 | 249 demux->filepos=stream_tell(demux->stream); |
250 | |
251 c=stream_read_char(demux->stream); | |
2792 | 252 if (c == -256) /* EOF */ |
253 return 0; | |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
254 // printf("c=%x,%02X\n",c,c&0xf0); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
255 if (c == 0x82) |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
256 { |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
257 /* ok, this works, but pts calculating from header is required! */ |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
258 #warning "Calculate PTS from picture header!" |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
259 prefix = 1; |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
260 c = stream_read_char(demux->stream); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
261 printf("packet 0x82(pos=%lu) chunk=%x\n", |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
262 stream_tell(demux->stream), c); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
263 } |
2687 | 264 switch(c&0xF0){ |
2695 | 265 case 0x00: // header - skip it! |
2784 | 266 { |
2687 | 267 len=stream_read_char(demux->stream); |
2695 | 268 if(len>=0x80) len=0x80*(len-0x80)+stream_read_char(demux->stream); |
269 printf("vivo extra header: %d bytes\n",len); | |
2784 | 270 #ifdef TEXTPARSE_ALL |
271 { | |
272 int pos; | |
273 /* also try to parse all headers */ | |
274 pos = stream_tell(demux->stream); | |
275 vivo_parse_text_header(demux, len); | |
276 stream_seek(demux->stream, pos); | |
277 } | |
278 #endif | |
2687 | 279 break; |
2784 | 280 } |
2687 | 281 case 0x10: // video packet |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
282 if (prefix == 1) |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
283 len = stream_read_char(demux->stream); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
284 else |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
285 len=128; |
2687 | 286 ds=demux->video; |
287 break; | |
288 case 0x20: // video packet | |
289 len=stream_read_char(demux->stream); | |
290 ds=demux->video; | |
291 break; | |
3068 | 292 case 0x30: // audio packet |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
293 if (prefix == 1) |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
294 len = stream_read_char(demux->stream); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
295 else |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
296 len=40; /* 40kbps */ |
2695 | 297 ds=demux->audio; |
298 break; | |
2687 | 299 case 0x40: // audio packet |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
300 if (prefix == 1) |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
301 len = stream_read_char(demux->stream); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
302 else |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
303 len=24; /* 24kbps */ |
2687 | 304 ds=demux->audio; |
305 break; | |
306 default: | |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
307 mp_msg(MSGT_DEMUX,MSGL_WARN,"VIVO - unknown ID found: %02X at pos %lu contact author!\n", |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
308 c, stream_tell(demux->stream)); |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
309 return 0; |
2687 | 310 } |
3245
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
311 |
1e2a87b7cae8
added support for packet 0x82 (from vivodump.c by arpi)
alex
parents:
3113
diff
changeset
|
312 // printf("chunk=%x, len=%d\n", c, len); |
2687 | 313 |
2695 | 314 if(!ds || ds->id<-1){ |
2687 | 315 if(len) stream_skip(demux->stream,len); |
316 return 1; | |
317 } | |
318 | |
319 seq=c&0x0F; | |
320 | |
321 if(ds->asf_packet){ | |
322 if(ds->asf_seq!=seq){ | |
323 // closed segment, finalize packet: | |
324 ds_add_packet(ds,ds->asf_packet); | |
325 ds->asf_packet=NULL; | |
2695 | 326 // printf("packet!\n"); |
2687 | 327 } else { |
328 // append data to it! | |
329 demux_packet_t* dp=ds->asf_packet; | |
330 dp->buffer=realloc(dp->buffer,dp->len+len); | |
331 //memcpy(dp->buffer+dp->len,data,len); | |
332 stream_read(demux->stream,dp->buffer+dp->len,len); | |
333 mp_dbg(MSGT_DEMUX,MSGL_DBG4,"data appended! %d+%d\n",dp->len,len); | |
334 dp->len+=len; | |
335 // we are ready now. | |
2695 | 336 if((c&0xF0)==0x20) --ds->asf_seq; // hack! |
2687 | 337 return 1; |
338 } | |
339 } | |
340 // create new packet: | |
341 { demux_packet_t* dp; | |
342 dp=new_demux_packet(len); | |
343 //memcpy(dp->buffer,data,len); | |
344 stream_read(demux->stream,dp->buffer,len); | |
345 // dp->pts=time*0.001f; | |
346 // dp->flags=keyframe; | |
347 // if(ds==demux->video) printf("ASF time: %8d dur: %5d \n",time,dur); | |
348 dp->pos=demux->filepos; | |
349 ds->asf_packet=dp; | |
350 ds->asf_seq=seq; | |
351 // we are ready now. | |
352 return 1; | |
353 } | |
354 | |
355 } | |
356 | |
357 static const short h263_format[8][2] = { | |
358 { 0, 0 }, | |
359 { 128, 96 }, | |
360 { 176, 144 }, | |
361 { 352, 288 }, | |
362 { 704, 576 }, | |
363 { 1408, 1152 }, | |
2784 | 364 { 320, 240 } // ??????? or 240x180 (found in vivo2) ? |
2687 | 365 }; |
366 | |
367 static unsigned char* buffer; | |
368 static int bufptr=0; | |
369 static int bitcnt=0; | |
370 static unsigned char buf=0; | |
371 static int format, width, height; | |
372 | |
373 static unsigned int x_get_bits(int n){ | |
374 unsigned int x=0; | |
375 while(n-->0){ | |
376 if(!bitcnt){ | |
377 // fill buff | |
378 buf=buffer[bufptr++]; | |
379 bitcnt=8; | |
380 } | |
381 //x=(x<<1)|(buf&1);buf>>=1; | |
382 x=(x<<1)|(buf>>7);buf<<=1; | |
383 --bitcnt; | |
384 } | |
385 return x; | |
386 } | |
387 | |
388 #define get_bits(xxx,n) x_get_bits(n) | |
389 #define get_bits1(xxx) x_get_bits(1) | |
390 #define skip_bits(xxx,n) x_get_bits(n) | |
391 #define skip_bits1(xxx) x_get_bits(1) | |
392 | |
393 /* most is hardcoded. should extend to handle all h263 streams */ | |
394 static int h263_decode_picture_header(unsigned char *b_ptr) | |
395 { | |
2928 | 396 // int i; |
2695 | 397 |
398 // for(i=0;i<16;i++) printf(" %02X",b_ptr[i]); printf("\n"); | |
2687 | 399 |
400 buffer=b_ptr; | |
401 bufptr=bitcnt=buf=0; | |
402 | |
403 /* picture header */ | |
2695 | 404 if (get_bits(&s->gb, 22) != 0x20){ |
405 printf("bad picture header\n"); | |
2687 | 406 return -1; |
2695 | 407 } |
2687 | 408 skip_bits(&s->gb, 8); /* picture timestamp */ |
409 | |
2695 | 410 if (get_bits1(&s->gb) != 1){ |
411 printf("bad marker\n"); | |
2687 | 412 return -1; /* marker */ |
2695 | 413 } |
414 if (get_bits1(&s->gb) != 0){ | |
415 printf("bad h263 id\n"); | |
2687 | 416 return -1; /* h263 id */ |
2695 | 417 } |
2687 | 418 skip_bits1(&s->gb); /* split screen off */ |
419 skip_bits1(&s->gb); /* camera off */ | |
420 skip_bits1(&s->gb); /* freeze picture release off */ | |
421 | |
422 format = get_bits(&s->gb, 3); | |
423 | |
424 if (format != 7) { | |
425 printf("h263_plus = 0 format = %d\n",format); | |
426 /* H.263v1 */ | |
427 width = h263_format[format][0]; | |
428 height = h263_format[format][1]; | |
429 printf("%d x %d\n",width,height); | |
2695 | 430 // if (!width) return -1; |
2687 | 431 |
432 printf("pict_type=%d\n",get_bits1(&s->gb)); | |
433 printf("unrestricted_mv=%d\n",get_bits1(&s->gb)); | |
434 #if 1 | |
435 printf("SAC: %d\n",get_bits1(&s->gb)); | |
436 printf("advanced prediction mode: %d\n",get_bits1(&s->gb)); | |
437 printf("PB frame: %d\n",get_bits1(&s->gb)); | |
438 #else | |
439 if (get_bits1(&s->gb) != 0) | |
440 return -1; /* SAC: off */ | |
441 if (get_bits1(&s->gb) != 0) | |
442 return -1; /* advanced prediction mode: off */ | |
443 if (get_bits1(&s->gb) != 0) | |
444 return -1; /* not PB frame */ | |
445 #endif | |
446 printf("qscale=%d\n",get_bits(&s->gb, 5)); | |
447 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ | |
448 } else { | |
449 printf("h263_plus = 1\n"); | |
450 /* H.263v2 */ | |
2695 | 451 if (get_bits(&s->gb, 3) != 1){ |
452 printf("H.263v2 A error\n"); | |
2687 | 453 return -1; |
2695 | 454 } |
455 if (get_bits(&s->gb, 3) != 6){ /* custom source format */ | |
456 printf("custom source format\n"); | |
2687 | 457 return -1; |
2695 | 458 } |
2687 | 459 skip_bits(&s->gb, 12); |
460 skip_bits(&s->gb, 3); | |
461 printf("pict_type=%d\n",get_bits(&s->gb, 3) + 1); | |
462 // if (s->pict_type != I_TYPE && | |
463 // s->pict_type != P_TYPE) | |
464 // return -1; | |
465 skip_bits(&s->gb, 7); | |
466 skip_bits(&s->gb, 4); /* aspect ratio */ | |
467 width = (get_bits(&s->gb, 9) + 1) * 4; | |
468 skip_bits1(&s->gb); | |
469 height = get_bits(&s->gb, 9) * 4; | |
470 printf("%d x %d\n",width,height); | |
2695 | 471 //if (height == 0) |
472 // return -1; | |
2687 | 473 printf("qscale=%d\n",get_bits(&s->gb, 5)); |
474 } | |
475 | |
476 /* PEI */ | |
477 while (get_bits1(&s->gb) != 0) { | |
478 skip_bits(&s->gb, 8); | |
479 } | |
480 // s->f_code = 1; | |
481 // s->width = width; | |
482 // s->height = height; | |
483 return 0; | |
484 } | |
485 | |
486 | |
2695 | 487 |
2687 | 488 void demux_open_vivo(demuxer_t* demuxer){ |
489 vivo_priv_t* priv=demuxer->priv; | |
490 | |
491 if(!ds_fill_buffer(demuxer->video)){ | |
492 mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingVideoStreamBug); | |
493 return; | |
494 } | |
495 | |
496 h263_decode_picture_header(demuxer->video->buffer); | |
497 | |
498 | |
499 { sh_video_t* sh=new_sh_video(demuxer,0); | |
3113
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
500 |
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
501 /* viv1, viv2 (for better codecs.conf) */ |
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
502 sh->format = mmioFOURCC('v', 'i', 'v', priv->version); |
c0e6a39d2ab7
changed to generate fourcc's like: viv<version> -> viv1,viv2
alex
parents:
3069
diff
changeset
|
503 // sh->format=0x6f766976; // "vivo" |
2784 | 504 if(!sh->fps) |
2928 | 505 { |
2784 | 506 if (priv->fps) |
507 sh->fps=priv->fps; | |
508 else | |
509 sh->fps=15.0f; | |
2928 | 510 } |
2687 | 511 sh->frametime=1.0f/sh->fps; |
2805 | 512 |
513 #warning "FIXME! we can't scale" | |
514 priv->disp_width = priv->width; | |
515 priv->disp_height = priv->height; | |
516 | |
2784 | 517 if (priv->disp_width) |
518 sh->disp_w = priv->disp_width; | |
519 else | |
520 sh->disp_w = width; | |
521 if (priv->disp_height) | |
522 sh->disp_h = priv->disp_height; | |
523 else | |
524 sh->disp_h = height; | |
2687 | 525 |
526 // emulate BITMAPINFOHEADER: | |
527 sh->bih=malloc(sizeof(BITMAPINFOHEADER)); | |
528 memset(sh->bih,0,sizeof(BITMAPINFOHEADER)); | |
529 sh->bih->biSize=40; | |
2784 | 530 if (priv->width) |
531 sh->bih->biWidth = priv->width; | |
532 else | |
533 sh->bih->biWidth = width; | |
534 if (priv->height) | |
535 sh->bih->biHeight = priv->height; | |
536 else | |
537 sh->bih->biHeight = height; | |
2687 | 538 sh->bih->biPlanes=1; |
539 sh->bih->biBitCount=24; | |
540 sh->bih->biCompression=sh->format; | |
541 sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight*3; | |
542 demuxer->video->sh=sh; sh->ds=demuxer->video; | |
543 demuxer->video->id=0; | |
2928 | 544 |
545 demuxer->seekable = 0; | |
2788 | 546 |
2928 | 547 printf("VIVO Video stream %d size: display: %dx%d, codec: %lux%lu\n", |
2788 | 548 demuxer->video->id, sh->disp_w, sh->disp_h, sh->bih->biWidth, |
549 sh->bih->biHeight); | |
2687 | 550 } |
551 | |
2695 | 552 if(demuxer->audio->id>=-1){ |
2687 | 553 if(!ds_fill_buffer(demuxer->audio)){ |
554 mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingAudioStream); | |
555 } else | |
556 { sh_audio_t* sh=new_sh_audio(demuxer,1); | |
2788 | 557 |
2687 | 558 sh->format=0x111; // 0x112 |
3068 | 559 // if (sh->format == 0x111) /* G.723 */ |
560 // sh->samplesize = demuxer->audio->buffer_size; | |
561 // printf("samplesize: %d\n", sh->samplesize); | |
2687 | 562 // Emulate WAVEFORMATEX struct: |
563 sh->wf=malloc(sizeof(WAVEFORMATEX)); | |
564 memset(sh->wf,0,sizeof(WAVEFORMATEX)); | |
565 sh->wf->nChannels=1; | |
566 sh->wf->wBitsPerSample=16; | |
2788 | 567 // sh->wf->wBitsPerSample=8; |
2784 | 568 if (priv->samplerate) |
569 sh->wf->nSamplesPerSec=priv->samplerate; | |
570 else | |
571 sh->wf->nSamplesPerSec=22050; | |
2788 | 572 // sh->wf->nSamplesPerSec=8000; |
2687 | 573 sh->wf->nAvgBytesPerSec=sh->wf->nChannels*sh->wf->wBitsPerSample*sh->wf->nSamplesPerSec/8; |
574 demuxer->audio->sh=sh; sh->ds=demuxer->audio; | |
575 demuxer->audio->id=1; | |
576 } | |
2695 | 577 } |
2687 | 578 |
579 } | |
580 | |
2788 | 581 void demux_close_vivo(demuxer_t *demuxer) |
582 { | |
583 vivo_priv_t* priv=demuxer->priv; | |
2809 | 584 |
585 if (priv) { | |
586 if (priv->title) | |
587 free(priv->title); | |
588 if (priv->author) | |
589 free(priv->author); | |
590 if (priv->copyright) | |
591 free(priv->copyright); | |
592 if (priv->producer) | |
593 free(priv->producer); | |
2788 | 594 free(priv); |
2809 | 595 } |
2788 | 596 return; |
597 } |