annotate TOOLS/movinfo.c @ 688:1a016347010a

movntq causes SIGILL on k6-3. Lets it be for K7, P3 cpus only
author nickols_k
date Wed, 02 May 2001 14:59:33 +0000
parents 3b5f5d1c5041
children f8bc3143449f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 // show QuickTime .mov file structure (C) 2001. by A'rpi/ESP-team
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 unsigned int read_dword(FILE *f){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 unsigned char atom_size_b[4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 if(fread(&atom_size_b,4,1,f)<=0) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 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
10 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 void lschunks(FILE *f,int level,unsigned int endpos){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 unsigned int atom_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 unsigned int atom_type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 int pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 while(endpos==0 || ftell(f)<endpos){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 pos=ftell(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 atom_size=read_dword(f);// if(fread(&atom_size_b,4,1,f)<=0) break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 if(fread(&atom_type,4,1,f)<=0) break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 if(atom_size<8) break; // error
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 printf("%08X: %*s %.4s (%08X) %d\n",pos,level*2,"",&atom_type,atom_type,atom_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 if(atom_type==0x64737473) { // stsd
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 unsigned int tmp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 unsigned int count;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 fread(&tmp,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 count=read_dword(f);// fread(&count,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 printf("desc count = %d\n",count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 for(i=0;i<count;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 unsigned int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 unsigned int format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 len=read_dword(f); // fread(&len,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 fread(&format,4,1,f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 printf(" desc #%d: %.4s (%d)\n",i+1,&format,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 fseek(f,len-8,SEEK_CUR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 if(atom_type==0x6F637473) { // stco
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 int len,i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 printf("Chunk table size :%d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 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
48 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 if(atom_type==0x73747473) { // stts
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 int len,i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 printf("T->S table size :%d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 for(i=0;i<len;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 int num=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 int dur=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 printf("%5d samples: %d duration\n",num,dur);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 if(atom_type==0x63737473) { // stsc
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 int len,i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 printf("S->C table size :%d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 for(i=0;i<len;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 int first=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 int spc=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 int sdid=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 printf(" chunk %d... %d s/c desc: %d\n",first,spc,sdid);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 if(atom_type==0x7A737473) { // stsz
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 int len,i,ss;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 ss=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 len=read_dword(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 printf("Sample size table len: %d\n",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 if(ss){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 printf(" common sample size: %d bytes\n",ss);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 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
86 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 switch(atom_type){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 case 0x75716D72: // rmqu
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 case 0x65657266: // free JUNK
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 case 0x64686B74: // tkhd Track header
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 case 0x61746475: // udta User data
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 case 0x7461646D: // mdat Movie data
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 case 0x64737473: // stsd Sample description
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 case 0x6F637473: // stco Chunk offset table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 case 0x73747473: // stts Sample time table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 case 0x63737473: // stsc Sample->Chunk mapping table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 case 0x7A737473: // stsz Sample size table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 default: lschunks(f,level+1,pos+atom_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 switch(atom_type){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 case 0x766F6F6D: // moov
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 case 0x61726D72: // rmra
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 case 0x61646D72: // rmda
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 lschunks(f,level+1,pos+atom_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 fseek(f,pos+atom_size,SEEK_SET);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 int main(int argc,char* argv[]){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 int pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 FILE *f=fopen(argc>1?argv[1]:"Akira.mov","rb");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 if(!f) return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 lschunks(f,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 }