annotate TOOLS/vivodump.c @ 13396:56b035c6514b

New translatable messages for vo_pnm (the portable anymap video output driver).
author ivo
date Mon, 20 Sep 2004 01:28:32 +0000
parents c671e9adbe22
children 4277e06630bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
1 #include <stdio.h>
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
2 #include <stdlib.h>
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
3 #include <string.h>
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
4
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
5 #include "wine/mmreg.h"
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
6 #include "wine/avifmt.h"
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
7 #include "wine/vfw.h"
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
8
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 3233
diff changeset
9 #include "muxer.h"
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
10
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
11 static const short h263_format[8][2] = {
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
12 { 0, 0 },
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
13 { 128, 96 },
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
14 { 176, 144 },
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
15 { 352, 288 },
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
16 { 704, 576 },
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
17 { 1408, 1152 },
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
18 { 320, 240 }
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
19 };
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
20
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
21 unsigned char* buffer;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
22 int bufptr=0;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
23 int bitcnt=0;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
24 unsigned char buf=0;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
25
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
26 unsigned int x_get_bits(int n){
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
27 unsigned int x=0;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
28 while(n-->0){
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
29 if(!bitcnt){
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
30 // fill buff
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
31 buf=buffer[bufptr++];
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
32 bitcnt=8;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
33 }
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
34 //x=(x<<1)|(buf&1);buf>>=1;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
35 x=(x<<1)|(buf>>7);buf<<=1;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
36 --bitcnt;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
37 }
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
38 return x;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
39 }
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
40
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
41 #define get_bits(xxx,n) x_get_bits(n)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
42 #define get_bits1(xxx) x_get_bits(1)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
43 #define skip_bits(xxx,n) x_get_bits(n)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
44 #define skip_bits1(xxx) x_get_bits(1)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
45
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
46 int format;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
47 int width=320;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
48 int height=240;
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
49
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
50 /* most is hardcoded. should extend to handle all h263 streams */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
51 int h263_decode_picture_header(unsigned char *b_ptr)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
52 {
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
53 int i;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
54
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
55 for(i=0;i<16;i++) printf(" %02X",b_ptr[i]); printf("\n");
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
56
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
57 buffer=b_ptr;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
58 bufptr=bitcnt=buf=0;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
59
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
60 /* picture header */
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
61 if (get_bits(&s->gb, 22) != 0x20){
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
62 printf("bad picture header\n");
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
63 return -1;
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
64 }
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
65 skip_bits(&s->gb, 8); /* picture timestamp */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
66
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
67 if (get_bits1(&s->gb) != 1){
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
68 printf("bad marker\n");
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
69 return -1; /* marker */
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
70 }
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
71 if (get_bits1(&s->gb) != 0){
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
72 printf("bad h263 id\n");
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
73 return -1; /* h263 id */
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
74 }
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
75 skip_bits1(&s->gb); /* split screen off */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
76 skip_bits1(&s->gb); /* camera off */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
77 skip_bits1(&s->gb); /* freeze picture release off */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
78
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
79 format = get_bits(&s->gb, 3);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
80
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
81 if (format != 7) {
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
82 printf("h263_plus = 0 format = %d\n",format);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
83 /* H.263v1 */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
84 width = h263_format[format][0];
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
85 height = h263_format[format][1];
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
86 printf("%d x %d\n",width,height);
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
87 // if (!width) return -1;
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
88
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
89 printf("pict_type=%d\n",get_bits1(&s->gb));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
90 printf("unrestricted_mv=%d\n",get_bits1(&s->gb));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
91 #if 1
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
92 printf("SAC: %d\n",get_bits1(&s->gb));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
93 printf("advanced prediction mode: %d\n",get_bits1(&s->gb));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
94 printf("PB frame: %d\n",get_bits1(&s->gb));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
95 #else
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
96 if (get_bits1(&s->gb) != 0)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
97 return -1; /* SAC: off */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
98 if (get_bits1(&s->gb) != 0)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
99 return -1; /* advanced prediction mode: off */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
100 if (get_bits1(&s->gb) != 0)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
101 return -1; /* not PB frame */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
102 #endif
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
103 printf("qscale=%d\n",get_bits(&s->gb, 5));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
104 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
105 } else {
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
106 printf("h263_plus = 1\n");
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
107 /* H.263v2 */
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
108 if (get_bits(&s->gb, 3) != 1){
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
109 printf("H.263v2 A error\n");
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
110 return -1;
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
111 }
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
112 if (get_bits(&s->gb, 3) != 6){ /* custom source format */
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
113 printf("custom source format\n");
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
114 return -1;
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
115 }
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
116 skip_bits(&s->gb, 12);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
117 skip_bits(&s->gb, 3);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
118 printf("pict_type=%d\n",get_bits(&s->gb, 3) + 1);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
119 // if (s->pict_type != I_TYPE &&
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
120 // s->pict_type != P_TYPE)
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
121 // return -1;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
122 skip_bits(&s->gb, 7);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
123 skip_bits(&s->gb, 4); /* aspect ratio */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
124 width = (get_bits(&s->gb, 9) + 1) * 4;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
125 skip_bits1(&s->gb);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
126 height = get_bits(&s->gb, 9) * 4;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
127 printf("%d x %d\n",width,height);
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
128 //if (height == 0)
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
129 // return -1;
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
130 printf("qscale=%d\n",get_bits(&s->gb, 5));
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
131 }
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
132
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
133 /* PEI */
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
134 while (get_bits1(&s->gb) != 0) {
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
135 skip_bits(&s->gb, 8);
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
136 }
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
137 // s->f_code = 1;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
138 // s->width = width;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
139 // s->height = height;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
140 return 0;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
141 }
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
142
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
143 int postable[32768];
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
144
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
145 int main(){
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
146 int c;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
147 unsigned int head=-1;
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
148 int pos=0;
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
149 int frames=0;
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
150 FILE *f=fopen("paulvandykforanangel.viv","rb");
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
151 FILE *f2=fopen("GB1.avi","wb");
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
152 muxer_t* avi=muxer_new_muxer(MUXER_TYPE_AVI,f2);
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 3233
diff changeset
153 muxer_stream_t* mux=muxer_new_stream(avi,MUXER_TYPE_VIDEO);
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
154 //unsigned char* buffer=malloc(0x200000);
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
155 int i,len;
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
156 int v_id=0;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
157 int flag=0;
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
158 int flag2=0;
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
159 int prefix=0;
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
160
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
161 mux->buffer_size=0x200000;
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
162 mux->buffer=malloc(mux->buffer_size);
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
163
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
164 mux->h.dwScale=1;
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
165 mux->h.dwRate=10;
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
166
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
167 mux->bih=malloc(sizeof(BITMAPINFOHEADER));
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
168 mux->bih->biSize=sizeof(BITMAPINFOHEADER);
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
169 mux->bih->biPlanes=1;
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
170 mux->bih->biBitCount=24;
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
171 mux->bih->biCompression=0x6f766976;// 7669766f;
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
172 muxer_write_header(avi);
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
173
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
174 /*
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
175 c=fgetc(f); if(c) printf("error! not vivo file?\n");
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
176 len=0;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
177 while((c=fgetc(f))>=0x80) len+=0x80*(c&0x0F);
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
178 len+=c;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
179 printf("hdr1: %d\n",len);
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
180 for(i=0;i<len;i++) fgetc(f);
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
181 */
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
182
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
183 while((c=fgetc(f))>=0){
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
184
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
185 printf("%08X %02X\n",ftell(f),c);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
186
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
187 prefix=0;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
188 if(c==0x82){
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
189 prefix=1;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
190 //continue;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
191 c=fgetc(f);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
192 printf("%08X %02X\n",ftell(f),c);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
193 }
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
194
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
195 if(c==0x00){
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
196 // header
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
197 int len=0;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
198 while((c=fgetc(f))>=0x80) len+=0x80*(c&0x0F);
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
199 len+=c;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
200 printf("header: 00 (%d)\n",len);
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
201 for(i=0;i<len;i++) fgetc(f);
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
202 continue;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
203 }
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
204
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
205 if((c&0xF0)==0x40){
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
206 // audio
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
207 len=24;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
208 if(prefix) len=fgetc(f);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
209 printf("audio: %02X (%d)\n",c,len);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
210 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
211 continue;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
212 }
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
213 if((c&0xF0)==0x30){
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
214 // audio
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
215 len=40;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
216 if(prefix) len=fgetc(f);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
217 printf("audio: %02X (%d)\n",c,len);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
218 for(i=0;i<len;i++) fgetc(f);
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
219 continue;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
220 }
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
221 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
222 // end of frame:
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
223 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
224 h263_decode_picture_header(mux->buffer);
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
225 muxer_write_chunk(mux,mux->buffer_len,0x10);
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
226 mux->buffer_len=0;
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
227
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
228 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
229 }
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
230 flag2=0;
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
231 if((c&0xF0)==0x10){
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
232 // 128 byte
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
233 len=128;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
234 if(prefix) len=fgetc(f);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
235 printf("video: %02X (%d)\n",c,len);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
236 fread(mux->buffer+mux->buffer_len,len,1,f);
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
237 mux->buffer_len+=len;
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
238 v_id=c;
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
239 continue;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
240 }
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
241 if((c&0xF0)==0x20){
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
242 int len=fgetc(f);
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
243 printf("video: %02X (%d)\n",c,len);
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
244 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
245 mux->buffer_len+=len;
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
246 flag2=1;
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
247 v_id=c;
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
248 continue;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
249 }
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
250 printf("error: %02X!\n",c);
3233
5a8d7b6920d6 0x82 support
arpi
parents: 2696
diff changeset
251 exit(1);
2665
e8d949b1bc5d dump h263 frame headers from vivo
arpi
parents:
diff changeset
252 }
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
253
2696
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
254 if(!width) width=320;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
255 if(!height) height=240;
d0f26c572633 vivo 2.0 support
arpi
parents: 2672
diff changeset
256
2672
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
257 mux->bih->biWidth=width;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
258 mux->bih->biHeight=height;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
259 mux->bih->biSizeImage=3*width*height;
1ff47e4ff44d works! copy video steram to .avi file playable with ivvideo.dll
arpi
parents: 2667
diff changeset
260
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
261 muxer_write_index(avi);
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
262 fseek(f2,0,SEEK_SET);
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
263 muxer_write_header(avi);
2667
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
264
a17fcca740ff convertiong to avi
arpi
parents: 2665
diff changeset
265 }