annotate TOOLS/asfinfo.c @ 29367:1d4dd0f12c98

Use enum PixelFormat in sws_format_name() prototype
author mru
date Wed, 01 Jul 2009 12:40:28 +0000
parents b45a3ae01e54
children b573c7c7173b
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
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
9 typedef struct __attribute__((packed))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 {
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
11 long biSize; // sizeof(BITMAPINFOHEADER)
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
12 long biWidth;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
13 long biHeight;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
14 short biPlanes; // unused
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
15 short biBitCount;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
16 long biCompression; // fourcc of image
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
17 long biSizeImage; // size of image. For uncompressed images
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
18 // ( biCompression 0 or 3 ) can be zero.
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
21 long biXPelsPerMeter; // unused
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
22 long biYPelsPerMeter; // unused
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
23 long biClrUsed; // valid only for palettized images.
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
24 // Number of colors in palette.
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
25 long biClrImportant;
1
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 {
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
30 short wFormatTag; // value that identifies compression format
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
31 short nChannels;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
32 long nSamplesPerSec;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
33 long nAvgBytesPerSec;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
34 short nBlockAlign; // size of a data sample
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
35 short wBitsPerSample;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
36 short cbSize; // size of format-specific data
1
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)) {
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
40 unsigned char guid[16];
1
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;
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
46 unsigned int cno; // number of subchunks
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
47 unsigned char v1; // unknown (0x01)
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
48 unsigned char v2; // unknown (0x02)
1
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
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 25308
diff changeset
92 static char* chunk_type(unsigned char* guid){
1
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
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 25308
diff changeset
108 static void print_wave_header(WAVEFORMATEX *h){
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
109 printf("======= WAVE Format =======\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
111 printf("Format Tag: %d (0x%X)\n", h->wFormatTag, h->wFormatTag);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
112 printf("Channels: %d\n", h->nChannels);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
113 printf("Samplerate: %ld\n", h->nSamplesPerSec);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
114 printf("avg byte/sec: %ld\n", h->nAvgBytesPerSec);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
115 printf("Block align: %d\n", h->nBlockAlign);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
116 printf("bits/sample: %d\n", h->wBitsPerSample);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
117 printf("cbSize: %d\n", h->cbSize);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
118
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 switch(h->wFormatTag){
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
120 case 0x01: printf("Audio in PCM format\n"); break;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
121 case 0x50: printf("Audio in MPEG Layer 1/2 format\n"); break;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
122 case 0x55: printf("Audio in MPEG Layer-3 format\n"); break; // ACM
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
123 case 0x02: printf("Audio in MS ADPCM format\n"); break; // ACM
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
124 case 0x11: printf("Audio in IMA ADPCM format\n"); break; // ACM
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
125 case 0x31:
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
126 case 0x32: printf("Audio in MS GSM 6.10 format\n"); break; // ACM
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
127 case 0x160:
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
128 case 0x161: printf("Audio in DivX WMA format\n"); break; // ACM
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
129 default: printf("Audio in UNKNOWN (id=0x%X) format\n", h->wFormatTag);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 printf("===========================\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 25308
diff changeset
135 static void print_video_header(BITMAPINFOHEADER *h){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 printf("======= VIDEO Format ======\n");
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
137 printf(" biSize %ld\n", h->biSize);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
138 printf(" biWidth %ld\n", h->biWidth);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
139 printf(" biHeight %ld\n", h->biHeight);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
140 printf(" biPlanes %d\n", h->biPlanes);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
141 printf(" biBitCount %d\n", h->biBitCount);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
142 printf(" biCompression %ld='%.4s'\n", h->biCompression, &h->biCompression);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
143 printf(" biSizeImage %ld\n", h->biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 printf("===========================\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 FILE* streams[128];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
149 int main(int argc, char* argv[]){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
150 FILE *f = fopen(argc > 1 ? argv[1] : "Alice Deejay - Back In My Life.asf", "rb");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
152 if(!f){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
153 printf("file not found\n");
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
154 exit(1);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
155 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
157 //printf("sizeof=%d\n", sizeof(objh));
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
158 //printf("sizeof=%d\n", sizeof(asfh));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
160 fread(&asfh, sizeof(asfh), 1, f); // header obj
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
161 //for(i = 0; i < 16; i++)
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
162 // printf("%02X ", asfh.objh.guid[i]);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
163 printf("[%s] %d (subchunks: %d)\n", chunk_type(asfh.objh.guid),
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
164 (int) asfh.objh.size, asfh.cno);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
166 while(fread(&objh, sizeof(objh), 1, f) > 0){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
167 int pos = ftell(f);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
168 //for(i = 0; i < 16; i++)
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
169 // printf("%02X ", objh.guid[i]);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
170 printf("0x%08X [%s] %d\n", pos-sizeof(objh), chunk_type(objh.guid),
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
171 (int) objh.size);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
172 switch(*((unsigned int*)&objh.guid)){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
173 case 0xB7DC0791: // guid_stream_header
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
174 fread(&streamh, sizeof(streamh), 1, f);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
175 printf("stream type: %s\n", chunk_type(streamh.type));
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
176 printf("stream concealment: %s\n", chunk_type(streamh.concealment));
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
177 printf("type: %d bytes, stream: %d bytes ID: %d\n",
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
178 (int)streamh.type_size, (int)streamh.stream_size,
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
179 (int)streamh.stream_no);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
180 printf("FILEPOS=0x%lX\n", ftell(f));
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
181 // type-specific data:
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
182 fread(buffer,streamh.type_size,1,f);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
183 switch(*((unsigned int*)&streamh.type)){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
184 case 0xF8699E40: // guid_audio_stream
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
185 print_wave_header((WAVEFORMATEX*)buffer);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
186 break;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
187 case 0xBC19EFC0: // guid_video_stream
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
188 print_video_header((BITMAPINFOHEADER*)&buffer[4 + 4 + 1 + 2]);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
189 break;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
190 }
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
191 // stream-specific data:
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
192 fread(buffer, streamh.stream_size, 1, f);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 break;
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
194 //case 0xD6E229D1:
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
195 // return "guid_header_2_0";
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
196 case 0x8CABDCA1: // guid_file_header
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
197 fread(&fileh, sizeof(fileh), 1, f);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
198 printf("packets: %d flags: %d pack_size: %d frame_size: %d\n",
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
199 (int)fileh.packets, (int)fileh.flags, (int)fileh.packetsize,
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
200 (int)fileh.frame_size);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 break;
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
202 case 0x75b22636: // guid_data_chunk
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
203 { int endp = pos + objh.size - sizeof(objh);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
204 unsigned char* packet = malloc((int)fileh.packetsize);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
205 int fpos;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
206 fseek(f, 26, SEEK_CUR);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
207 while((fpos = ftell(f)) < endp){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
208 fread(packet, (int)fileh.packetsize, 1, f);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
209 if(packet[0] == 0x82){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
210 unsigned char flags = packet[3];
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
211 unsigned char* p = &packet[5];
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
212 unsigned long time;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
213 unsigned short duration;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
214 int segs = 1;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
215 int seg;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
216 int padding=0;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
217 if(flags & 8){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
218 padding = p[0];
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
219 ++p;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
220 } else
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
221 if(flags & 16){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
222 padding = p[0] | (p[1] << 8);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
223 p += 2;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
224 }
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
225 time = *((unsigned long*)p);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
226 p += 4;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
227 duration = *((unsigned short*)p);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
228 p += 2;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
229 if(flags & 1){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
230 segs = p[0] - 0x80;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
231 ++p;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
232 }
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
233 printf("%08X: flag=%02X segs=%d pad=%d time=%ld dur=%d\n",
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
234 fpos, flags, segs, padding, time, duration);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
235 for(seg = 0; seg < segs; seg++){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
236 ASF_segmhdr_t* sh = (ASF_segmhdr_t*)p;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
237 int len = 0;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
238 p += sizeof(ASF_segmhdr_t);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
239 if(sh->flag & 8) p+=8;// else
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
240 if(sh->flag & 1) ++p;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
241 if(flags & 1){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
242 len = *((unsigned short*)p);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
243 p += 2;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
244 }
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
245 printf(" seg #%d: streamno=%d seq=%d flag=%02X len=%d\n",
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
246 seg, sh->streamno&0x7F, sh->seq, sh->flag, len);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
247 #ifdef SAVE_STREAMS
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
248 if(!streams[sh->streamno & 0x7F]){
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
249 char name[256];
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
250 snprintf(name, 256, "stream%02X.dat", sh->streamno & 0x7F);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
251 streams[sh->streamno & 0x7F] = fopen(name, "wb");
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
252 }
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
253 fwrite(p, len, 1, streams[sh->streamno & 0x7F]);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
254 #endif
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
255 p += len;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
256 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 } else
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
258 printf("%08X: UNKNOWN %02X %02X %02X %02X %02X...\n", fpos,
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
259 packet[0], packet[1], packet[2], packet[3], packet[4]);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
260 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 }
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
262 break;
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
263
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
264 //case 0x33000890:
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
265 // return "guid_index_chunk";
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
267 }
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
268 fseek(f, pos + objh.size - sizeof(objh), SEEK_SET);
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
269 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
27636
b45a3ae01e54 cosmetics: prettyprinting
diego
parents: 26575
diff changeset
271 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273