annotate libmpdemux/demux_viv.c @ 3241:71075e783b04

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