annotate TOOLS/asfinfo.c @ 18306:f10ade0e0c3e

sync with 1.248
author luran
date Thu, 27 Apr 2006 07:37:10 +0000
parents f5491f58af9b
children f15f95c2671a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 #define SAVE_STREAMS
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 // simple ASF header display program by A'rpi/ESP-team
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 // .asf fileformat docs from http://divx.euro.ru
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 typedef struct __attribute__((packed))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 long biSize; // sizeof(BITMAPINFOHEADER)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 long biWidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 long biHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 short biPlanes; // unused
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 short biBitCount;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 long biCompression; // fourcc of image
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 long biSizeImage; // size of image. For uncompressed images
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 // ( biCompression 0 or 3 ) can be zero.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 long biXPelsPerMeter; // unused
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 long biYPelsPerMeter; // unused
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 long biClrUsed; // valid only for palettized images.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 // Number of colors in palette.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 long biClrImportant;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 } BITMAPINFOHEADER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 short wFormatTag; // value that identifies compression format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 short nChannels;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 long nSamplesPerSec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 long nAvgBytesPerSec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 short nBlockAlign; // size of a data sample
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 short wBitsPerSample;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 short cbSize; // size of format-specific data
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 } WAVEFORMATEX;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 typedef struct __attribute__((packed)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 unsigned char guid[16];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 unsigned long long size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 } ASF_obj_header_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 typedef struct __attribute__((packed)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 ASF_obj_header_t objh;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 unsigned int cno; // number of subchunks
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 unsigned char v1; // unknown (0x01)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 unsigned char v2; // unknown (0x02)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 } ASF_header_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 typedef struct __attribute__((packed)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 unsigned char client[16]; // Client GUID
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 unsigned long long file_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 unsigned long long creat_time; //File creation time FILETIME 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 unsigned long long packets; //Number of packets UINT64 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 unsigned long long end_timestamp; //Timestamp of the end position UINT64 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 unsigned long long duration; //Duration of the playback UINT64 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 unsigned long start_timestamp; //Timestamp of the start position UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 unsigned long unk1; //Unknown, maybe reserved ( usually contains 0 ) UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 unsigned long flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 unsigned long packetsize; //Size of packet, in bytes UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 unsigned long packetsize2; //Size of packet ( confirm ) UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 unsigned long frame_size; //Size of uncompressed video frame UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 } ASF_file_header_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 typedef struct __attribute__((packed)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 unsigned char type[16]; // Stream type (audio/video) GUID 16
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 unsigned char concealment[16]; // Audio error concealment type GUID 16
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 unsigned long long unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 unsigned long type_size; //Total size of type-specific data UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 unsigned long stream_size; //Size of stream-specific data UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 unsigned short stream_no; //Stream number UINT16 2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 unsigned long unk2; //Unknown UINT32 4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 } ASF_stream_header_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 typedef struct __attribute__((packed)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 unsigned char streamno;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 unsigned char seq;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 unsigned long x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 unsigned char flag;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 } ASF_segmhdr_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 ASF_header_t asfh;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 ASF_obj_header_t objh;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 ASF_file_header_t fileh;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 ASF_stream_header_t streamh;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 unsigned char buffer[8192];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 char* chunk_type(unsigned char* guid){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 switch(*((unsigned int*)guid)){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 case 0xF8699E40: return "guid_audio_stream";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 case 0xBC19EFC0: return "guid_video_stream";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 case 0x49f1a440: return "guid_audio_conceal_none";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 case 0xbfc3cd50: return "guid_audio_conceal_interleave";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 case 0x75B22630: return "guid_header";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 case 0x75b22636: return "guid_data_chunk";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 case 0x33000890: return "guid_index_chunk";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 case 0xB7DC0791: return "guid_stream_header";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 case 0xD6E229D1: return "guid_header_2_0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 case 0x8CABDCA1: return "guid_file_header";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107
17983
f5491f58af9b Remove verbosity parameter added to print_*_header call in last revision again.
diego
parents: 17977
diff changeset
108 void print_wave_header(WAVEFORMATEX *h){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 printf("======= WAVE Format =======\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 printf("Format Tag: %d (0x%X)\n",h->wFormatTag,h->wFormatTag);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 printf("Channels: %d\n",h->nChannels);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 printf("Samplerate: %d\n",h->nSamplesPerSec);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 printf("avg byte/sec: %d\n",h->nAvgBytesPerSec);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 printf("Block align: %d\n",h->nBlockAlign);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 printf("bits/sample: %d\n",h->wBitsPerSample);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 printf("cbSize: %d\n",h->cbSize);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 switch(h->wFormatTag){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 case 0x01: printf("Audio in PCM format\n");break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 case 0x50: printf("Audio in MPEG Layer 1/2 format\n");break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 case 0x55: printf("Audio in MPEG Layer-3 format\n");break; // ACM
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 case 0x02: printf("Audio in MS ADPCM format\n");break; // ACM
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 case 0x11: printf("Audio in IMA ADPCM format\n");break; // ACM
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 case 0x31:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 case 0x32: printf("Audio in MS GSM 6.10 format\n");break; // ACM
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 case 0x160:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 case 0x161: printf("Audio in DivX WMA format\n");break; // ACM
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 default: printf("Audio in UNKNOWN (id=0x%X) format\n",h->wFormatTag);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 printf("===========================\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137
17983
f5491f58af9b Remove verbosity parameter added to print_*_header call in last revision again.
diego
parents: 17977
diff changeset
138 void print_video_header(BITMAPINFOHEADER *h){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 printf("======= VIDEO Format ======\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 printf(" biSize %d\n", h->biSize);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 printf(" biWidth %d\n", h->biWidth);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 printf(" biHeight %d\n", h->biHeight);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 printf(" biPlanes %d\n", h->biPlanes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 printf(" biBitCount %d\n", h->biBitCount);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 printf(" biCompression %d='%.4s'\n", h->biCompression, &h->biCompression);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 printf(" biSizeImage %d\n", h->biSizeImage);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 printf("===========================\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 FILE* streams[128];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 int main(int argc,char* argv[]){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 FILE *f=fopen(argc>1?argv[1]:"Alice Deejay - Back In My Life.asf","rb");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 if(!f){ printf("file not found\n");exit(1);}
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 //printf("sizeof=%d\n",sizeof(objh));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 //printf("sizeof=%d\n",sizeof(asfh));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 fread(&asfh,sizeof(asfh),1,f); // header obj
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 //for(i=0;i<16;i++) printf("%02X ",asfh.objh.guid[i]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 printf("[%s] %d (subchunks: %d)\n",chunk_type(asfh.objh.guid),(int) asfh.objh.size,asfh.cno);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 while(fread(&objh,sizeof(objh),1,f)>0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 int pos=ftell(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 // for(i=0;i<16;i++) printf("%02X ",objh.guid[i]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 printf("0x%08X [%s] %d\n",pos-sizeof(objh), chunk_type(objh.guid),(int) objh.size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 switch(*((unsigned int*)&objh.guid)){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 case 0xB7DC0791: // guid_stream_header
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 fread(&streamh,sizeof(streamh),1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 printf("stream type: %s\n",chunk_type(streamh.type));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 printf("stream concealment: %s\n",chunk_type(streamh.concealment));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 printf("type: %d bytes, stream: %d bytes ID: %d\n",(int)streamh.type_size,(int)streamh.stream_size,(int)streamh.stream_no);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 printf("FILEPOS=0x%X\n",ftell(f));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 // type-specific data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 fread(buffer,streamh.type_size,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 switch(*((unsigned int*)&streamh.type)){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 case 0xF8699E40: // guid_audio_stream
17983
f5491f58af9b Remove verbosity parameter added to print_*_header call in last revision again.
diego
parents: 17977
diff changeset
179 print_wave_header((WAVEFORMATEX*)buffer);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 case 0xBC19EFC0: // guid_video_stream
17983
f5491f58af9b Remove verbosity parameter added to print_*_header call in last revision again.
diego
parents: 17977
diff changeset
182 print_video_header((BITMAPINFOHEADER*)&buffer[4+4+1+2]);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 // stream-specific data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 fread(buffer,streamh.stream_size,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 // case 0xD6E229D1: return "guid_header_2_0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 case 0x8CABDCA1: // guid_file_header
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 fread(&fileh,sizeof(fileh),1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 printf("packets: %d flags: %d pack_size: %d frame_size: %d\n",(int)fileh.packets,(int)fileh.flags,(int)fileh.packetsize,(int)fileh.frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 case 0x75b22636: // guid_data_chunk
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 { int endp=pos+objh.size-sizeof(objh);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 unsigned char* packet=malloc((int)fileh.packetsize);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 int fpos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 fseek(f,26,SEEK_CUR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 while((fpos=ftell(f))<endp){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 fread(packet,(int)fileh.packetsize,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 if(packet[0]==0x82){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 unsigned char flags=packet[3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 unsigned char* p=&packet[5];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 unsigned long time;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 unsigned short duration;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 int segs=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 int seg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 int padding=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 if(flags&8){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 padding=p[0];++p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 if(flags&16){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 padding=p[0]|(p[1]<<8);p+=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 time=*((unsigned long*)p);p+=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 duration=*((unsigned short*)p);p+=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 if(flags&1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 segs=p[0]-0x80;++p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 printf("%08X: flag=%02X segs=%d pad=%d time=%d dur=%d\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 fpos,flags,segs,padding,time,duration);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 for(seg=0;seg<segs;seg++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 ASF_segmhdr_t* sh=(ASF_segmhdr_t*)p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 int len=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 p+=sizeof(ASF_segmhdr_t);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 if(sh->flag&8) p+=8;// else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 if(sh->flag&1) ++p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 if(flags&1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 len=*((unsigned short*)p);p+=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 printf(" seg #%d: streamno=%d seq=%d flag=%02X len=%d\n",seg,sh->streamno&0x7F,sh->seq,sh->flag,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 #ifdef SAVE_STREAMS
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 if(!streams[sh->streamno&0x7F]){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 char name[256];
1096
bf973bffe240 some possible buffer overflow places fixed
al3x
parents: 1
diff changeset
234 snprintf(name,256,"stream%02X.dat",sh->streamno&0x7F);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 streams[sh->streamno&0x7F]=fopen(name,"wb");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 fwrite(p,len,1,streams[sh->streamno&0x7F]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 p+=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 printf("%08X: UNKNOWN %02X %02X %02X %02X %02X...\n",fpos,packet[0],packet[1],packet[2],packet[3],packet[4]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 // case 0x33000890: return "guid_index_chunk";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 fseek(f,pos+objh.size-sizeof(objh),SEEK_SET);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255