annotate TOOLS/movinfo.c @ 37177:d50c97393dc1

Cosmetic: Adjust indent.
author ib
date Mon, 08 Sep 2014 20:18:29 +0000
parents 1c35122fba8c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30416
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
1 /* show QuickTime .mov file structure (C) 2001. by A'rpi/ESP-team
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
2 * various hacks by alex@naxine.org
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
3 *
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
4 * This program is free software; you can redistribute it and/or modify
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
8 *
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
9 * This program is distributed in the hope that it will be useful,
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
13 *
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
15 * with this program; if not, write to the Free Software Foundation, Inc.,
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b573c7c7173b Add standard license header to C tools missing them.
diego
parents: 29263
diff changeset
17 */
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
18
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
19 /*
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
20 Blocks: 4bytes atom_size
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
21 4bytes atom_type (name)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
22 ...
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
23
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
24 By older files, mdat is at the beginning, and moov follows it later,
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
25 by newer files, moov is at the begininng.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
26
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
27 Fontosabb typeok:
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
28
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
29 trak: track: ezeken belul van egy-egy stream (video/audio)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
30 tkhd: track header: fps (video esten picture size is itt van)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
31 vmhd: video media handler (video stream informaciok)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
32 smhd: sound media handler (audio stream informaciok)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
33 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
38 #undef NO_SPECIAL
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
39
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 26474
diff changeset
40 static char *atom2human_type(int type)
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
41 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
42 switch (type)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
43 {
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
44 case 0x766F6F6D: return "Information sections"; /* moov */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
45 case 0x6468766D: return "Movie header"; /* mvhd */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
46 case 0x6169646D: return "Media stream"; /* mdia */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
47 case 0x64686D76: return "Video media header"; /* vmhd */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
48 case 0x64686D73: return "Sound media header"; /* smhd */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
49 case 0x6468646D: return "Media header"; /* mdhd */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
50 case 0x666E696D: return "Media information"; /* minf */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
51 case 0x726C6468: return "Handler reference"; /* hdlr */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
52 case 0x6B617274: return "New track (stream)"; /* trak */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
53 case 0x75716D72: return "rmqu";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
54 case 0x65657266: return "free";
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
55 case 0x64686B74: return "Track header"; /* tkhd */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
56 case 0x61746475: return "User data"; /* udta */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
57 case 0x7461646D: return "Movie data"; /* mdat */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
58 case 0x6C627473: return "Sample information table"; /* stbl */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
59 case 0x64737473: return "Sample description"; /* stsd */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
60 case 0x6F637473: return "Chunk offset table"; /* stco */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
61 case 0x73747473: return "Sample time table"; /* stts */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
62 case 0x63737473: return "Sample->Chunk mapping table"; /* stsc */
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
63 case 0x7A737473: return "Sample size table"; /* stsz */
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
64 }
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26576
diff changeset
65 return "unknown";
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
66 }
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
67
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
68 #define S_NONE 0
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
69 #define S_AUDIO 1
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
70 #define S_VIDEO 2
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
71 int stream = S_NONE;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
72 int v_stream = 0;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
73 int a_stream = 0;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
74
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 26474
diff changeset
75 static unsigned int read_dword(FILE *f){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 unsigned char atom_size_b[4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 if(fread(&atom_size_b,4,1,f)<=0) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 return (atom_size_b[0]<<24)|(atom_size_b[1]<<16)|(atom_size_b[2]<<8)|atom_size_b[3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 26474
diff changeset
81 static void video_stream_info(FILE *f, int len)
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
82 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
83 int orig_pos = ftell(f);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
84 unsigned char data[len-8];
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
85 int i;
23658
22201fbf9c0e Fix unused variable warnings.
diego
parents: 6908
diff changeset
86 // char codec[len-8];
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
87
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
88 len -= 8;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
89 for (i=0; i<len; i++)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
90 fread(&data[i], 1, 1, f);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
91
6908
598f58f545ec small fixes...
arpi
parents: 6870
diff changeset
92 // strncpy(codec, &data[43], len-43);
598f58f545ec small fixes...
arpi
parents: 6870
diff changeset
93 // printf(" [codec: %s]\n", &codec);
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
94 fseek(f,orig_pos,SEEK_SET);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
95 }
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
96
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 26474
diff changeset
97 static void audio_stream_info(FILE *f, int len)
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
98 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
99 int orig_pos = ftell(f);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
100 unsigned char data[len-8];
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
101 int i;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
102
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
103 len -= 8;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
104 for (i=0; i<len; i++)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
105 fread(&data[i], 1, 1, f);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
106
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
107 printf(" [%d bit", data[19]);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
108 if (data[17] == 1)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
109 printf(" mono");
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
110 else
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
111 printf(" %d channels", data[17]);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
112 printf("]\n");
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
113 fseek(f,orig_pos,SEEK_SET);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
114 }
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
115
26576
89b58769e45b Disable unused function.
diego
parents: 26575
diff changeset
116 #if 0
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 26474
diff changeset
117 static void userdata_info(FILE *f, int len, int pos, int level)
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
118 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
119 int orig_pos = pos; /*ftell(f);*/
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
120 unsigned int atom_size = 1;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
121 unsigned int atom_type;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
122
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
123 // printf("userdata @ %d:%d (%d)\n", pos, pos+len, len);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
124
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
125 // fseek(f, pos+3, SEEK_SET);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
126
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
127 while (atom_size != 0)
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
128 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
129 atom_size=read_dword(f);// if(fread(&atom_size_b,4,1,f)<=0) break;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
130 if(fread(&atom_type,4,1,f)<=0) break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
131
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
132 if(atom_size<8) break; // error
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
133
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
134 // printf("%08X: %*s %.4s (%08X) %05d (begin: %08X)\n",pos,level*2,"",
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
135 // &atom_type,atom_type,atom_size,pos+8);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
136
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
137 switch(atom_type)
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
138 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
139 case 0x797063A9: /* cpy (copyright) */
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
140 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
141 char *data = malloc(atom_size-8);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
142
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
143 fseek(f, pos+6, SEEK_SET);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
144 fread(data, atom_size-8, 1, f);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
145 printf(" Copyright: %s\n", data);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
146 free(data);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
147 }
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
148 break;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
149 case 0x666E69A9: /* inf (information) */
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
150 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
151 char data[atom_size-8];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
152
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
153 fread(&data, 1, atom_size-8, f);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
154 printf(" Owner: %s\n", &data);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
155 }
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
156 break;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
157 case 0x6D616EA9: /* nam (name) */
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
158 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
159 char data[atom_size-8];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
160
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
161 fread(&data, 1, atom_size-8, f);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
162 printf(" Name: %s\n", &data);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
163 }
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
164 break;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
165 }
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
166 }
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
167 fseek(f,orig_pos,SEEK_SET);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
168 }
26576
89b58769e45b Disable unused function.
diego
parents: 26575
diff changeset
169 #endif
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
170
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
171 int time_scale = 0;
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
172
26575
1ca484e74f18 Mark all functions that are only used within the file as static.
diego
parents: 26474
diff changeset
173 static void lschunks(FILE *f,int level,unsigned int endpos){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 unsigned int atom_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 unsigned int atom_type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 int pos;
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
177
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 while(endpos==0 || ftell(f)<endpos){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 pos=ftell(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 atom_size=read_dword(f);// if(fread(&atom_size_b,4,1,f)<=0) break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 if(fread(&atom_type,4,1,f)<=0) break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
182
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 if(atom_size<8) break; // error
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
184
34247
1c35122fba8c Remove obsolete ALSA 0.5 audio output and ALSA 0.9 audio input.
diego
parents: 30416
diff changeset
185 printf("%08X: %*s %.4s (%08X) %05d [%s] (begin: %08X)\n",
1c35122fba8c Remove obsolete ALSA 0.5 audio output and ALSA 0.9 audio input.
diego
parents: 30416
diff changeset
186 pos, level * 2, "", &atom_type, atom_type,
1c35122fba8c Remove obsolete ALSA 0.5 audio output and ALSA 0.9 audio input.
diego
parents: 30416
diff changeset
187 atom_size, atom2human_type(atom_type),
1c35122fba8c Remove obsolete ALSA 0.5 audio output and ALSA 0.9 audio input.
diego
parents: 30416
diff changeset
188 pos + 8); // 8: atom_size fields (4) + atom_type fields (4)
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
189
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
190 #ifndef NO_SPECIAL
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
191 // if (atom_type == 0x61746475)
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
192 // userdata_info(f, atom_size, pos, level);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
193
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
194 if (atom_type == 0x6468646D)
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
195 {
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
196 char data[4];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
197
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
198 fread(&data, 1, 1, f); // char
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
199 printf("mdhd version %d\n", data[0]);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
200 fread(&data, 3, 1, f); // int24
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
201 fread(&data, 4, 1, f); // int32
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
202 fread(&data, 4, 1, f); // int32
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
203 fread(&data, 4, 1, f); // int32
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
204 time_scale = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
205 printf("timescale: %d\n", time_scale);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
206 fread(&data, 4, 1, f); // int32
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
207 fread(&data, 2, 1, f); // int16
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
208 fread(&data, 2, 1, f); // int16
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
209 }
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
210
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
211 if (atom_type == 0x64686D76)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
212 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
213 stream = S_VIDEO;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
214 printf(" Found VIDEO Stream #%d\n", v_stream++);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
215 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
216
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
217 if (atom_type == 0x64686D73)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
218 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
219 stream = S_AUDIO;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
220 printf(" Found AUDIO Stream #%d\n", a_stream++);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
221 }
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
222
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
223 if (atom_type == 0x64686B74) // tkhd - track header
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
224 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
225 int i;
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
226 unsigned char data[atom_size];
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
227 int x, y;
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
228
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
229 for (i=0; i<atom_size; i++)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
230 fread(&data[i], 1, 1, f);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
231
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
232 x = data[77];
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
233 y = data[81];
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
234 printf(" Flags: %d\n", data[3]);
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
235 printf(" Picture size: %dx%d\n", x, y);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
236 if (x == 0 && y == 0)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
237 printf(" Possible audio stream!\n");
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
238 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
239
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 if(atom_type==0x64737473) { // stsd
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 unsigned int tmp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 unsigned int count;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 fread(&tmp,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 count=read_dword(f);// fread(&count,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 printf("desc count = %d\n",count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 for(i=0;i<count;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 unsigned int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 unsigned int format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 len=read_dword(f); // fread(&len,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 fread(&format,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 printf(" desc #%d: %.4s (%d)\n",i+1,&format,len);
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
253 if (stream == S_VIDEO)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
254 video_stream_info(f, len);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
255 if (stream == S_AUDIO)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
256 audio_stream_info(f, len);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 fseek(f,len-8,SEEK_CUR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
260
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 if(atom_type==0x6F637473) { // stco
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 int len,i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 printf("Chunk table size :%d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 for(i=0;i<len;i++) printf(" chunk #%d: 0x%X\n",i+1,read_dword(f));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 if(atom_type==0x73747473) { // stts
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 int len,i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 printf("T->S table size :%d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 for(i=0;i<len;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 int num=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 int dur=read_dword(f);
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
278 printf("%5d samples: %d duration", num, dur);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
279 if (stream == S_AUDIO)
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
280 printf("(rate: %f Hz)\n", (float)time_scale/dur);
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
281 else
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
282 printf("(fps: %f)\n", (float)time_scale/dur);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 if(atom_type==0x63737473) { // stsc
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 int len,i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 printf("S->C table size :%d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 for(i=0;i<len;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 int first=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 int spc=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 int sdid=read_dword(f);
1199
75bd6146cc77 fps es frequency megallapitas mukodik :)
al3x
parents: 1175
diff changeset
295 printf(" chunk %d... %d s/c desc: %d\n",first,spc,sdid);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 if(atom_type==0x7A737473) { // stsz
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 int len,i,ss;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 ss=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 printf("Sample size table len: %d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 if(ss){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 printf(" common sample size: %d bytes\n",ss);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 for(i=0;i<len;i++) printf(" sample #%d: %d bytes\n",i+1,read_dword(f));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 }
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
311 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
312
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 switch(atom_type){
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
315 case 0x7461646D: // mdat Movie data
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 case 0x75716D72: // rmqu
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 case 0x65657266: // free JUNK
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 case 0x64686B74: // tkhd Track header
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 case 0x61746475: // udta User data
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 case 0x64737473: // stsd Sample description
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 case 0x6F637473: // stco Chunk offset table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 case 0x73747473: // stts Sample time table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 case 0x63737473: // stsc Sample->Chunk mapping table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 case 0x7A737473: // stsz Sample size table
6870
dad5f8b3e8a0 ignore pnot/PICT
arpi
parents: 1199
diff changeset
325 case 0x746f6e70: // pnot
dad5f8b3e8a0 ignore pnot/PICT
arpi
parents: 1199
diff changeset
326 case 0x54434950: // PICT
6908
598f58f545ec small fixes...
arpi
parents: 6870
diff changeset
327 case 0x70797466:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 default: lschunks(f,level+1,pos+atom_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 switch(atom_type){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 case 0x766F6F6D: // moov
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 case 0x61726D72: // rmra
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 case 0x61646D72: // rmda
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 lschunks(f,level+1,pos+atom_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 fseek(f,pos+atom_size,SEEK_SET);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
343 int main(int argc,char* argv[])
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
344 {
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
345 FILE *f;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26759
diff changeset
346
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
347 if ((f = fopen(argc>1?argv[1]:"Akira.mov","rb")) == NULL)
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
348 return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349
26474
5ac02417f474 Remove useless 0 flag from s printf conversion specifier, fixes the warning:
diego
parents: 24202
diff changeset
350 printf("%.8s %.4s (%.8s) %5s [%s]\n\n",
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
351 "position", "atom", "atomtype", "len", "human readable atom name");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352
1175
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
353 lschunks(f, 0, 0);
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
354
f8bc3143449f sok hacking
al3x
parents: 1
diff changeset
355 printf("\nSummary: streams: %d video/%d audio\n", v_stream, a_stream);
23659
f15f95c2671a Fix "control reaches end of non-void function" warnings.
diego
parents: 23658
diff changeset
356
f15f95c2671a Fix "control reaches end of non-void function" warnings.
diego
parents: 23658
diff changeset
357 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 }