diff options
author | arpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-02-24 20:28:24 +0000 |
---|---|---|
committer | arpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-02-24 20:28:24 +0000 |
commit | d34041569e71fc9bd772354e94dc9d16061072a5 (patch) | |
tree | 8f481cae1c70f32d1756fbe5f39000577b73042d /TOOLS | |
parent | e95a95ece09bac96bdfd37322f96c6f57ef79ebc (diff) | |
download | mpv-d34041569e71fc9bd772354e94dc9d16061072a5.tar.bz2 mpv-d34041569e71fc9bd772354e94dc9d16061072a5.tar.xz |
Initial revision
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rwxr-xr-x | TOOLS/GL-test/compile.sh | 2 | ||||
-rw-r--r-- | TOOLS/GL-test/gltest.c | 189 | ||||
-rw-r--r-- | TOOLS/asfinfo.c | 255 | ||||
-rwxr-xr-x | TOOLS/c | 1 | ||||
-rw-r--r-- | TOOLS/movinfo.c | 124 |
5 files changed, 571 insertions, 0 deletions
diff --git a/TOOLS/GL-test/compile.sh b/TOOLS/GL-test/compile.sh new file mode 100755 index 0000000000..2bb40def0a --- /dev/null +++ b/TOOLS/GL-test/compile.sh @@ -0,0 +1,2 @@ + +gcc -g -O4 gltest.c ../../linux/timer-lx.o -o gltest -L/usr/X11/lib -lglut -lGL -lGLU -lX11 -lXext -lXmu -lXi -lm diff --git a/TOOLS/GL-test/gltest.c b/TOOLS/GL-test/gltest.c new file mode 100644 index 0000000000..e8c6d33146 --- /dev/null +++ b/TOOLS/GL-test/gltest.c @@ -0,0 +1,189 @@ +// OpenGL glTexSubImage() test/benchmark prg (C) 2001. by A'rpi/ESP-team + +#include <GL/glut.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <inttypes.h> + +// pixel size: 3 or 4 +#define BYTES_PP 3 + +// blit by lines (defined) or frames (not defined) +#define FAST_BLIT + +static uint32_t image_width=720; // DVD size +static uint32_t image_height=576; + +static uint32_t image_format; +static uint32_t image_bpp; +static uint32_t image_bytes; + +static uint32_t texture_width=512; +static uint32_t texture_height=512; + +static unsigned char *ImageData=NULL; + +static GLvoid resize(int x,int y){ + printf("Resize: %dx%d\n",x,y); + glViewport( 0, 0, x, y ); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, image_width, image_height, 0, -1,1); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +float akarmi=0; + +int counter=0; +float gen_time=0; +float up_time=0; +float render_time=0; + +unsigned char sintable[4096]; + +extern float GetRelativeTime(); + +static void redraw(void) +{ +// glClear(GL_COLOR_BUFFER_BIT); + int x,y,i; + unsigned char *d=ImageData; + int dstride=BYTES_PP*image_width; + + GetRelativeTime(); + + // generate some image: + for(y=0;y<image_height;y++){ + int y1=2048*sin(akarmi*0.36725+y*0.0165); + int y2=2048*sin(akarmi*0.45621+y*0.02753); + int y3=2048*sin(akarmi*0.15643+y*0.03732); + for(x=0;x<image_width;x++){ + d[0]=sintable[(y1+x*135)&4095]; + d[1]=sintable[(y2+x*62)&4095]; + d[2]=sintable[(y3+x*23)&4095]; + d+=BYTES_PP; + } + } + + gen_time+=GetRelativeTime(); + +#ifdef FAST_BLIT + // upload texture: + for(i=0;i<image_height;i++){ + glTexSubImage2D( GL_TEXTURE_2D, // target + 0, // level + 0, // x offset + i, // y offset + image_width, // width + 1, // height + (BYTES_PP==4)?GL_RGBA:GL_RGB, // format + GL_UNSIGNED_BYTE, // type + ImageData+i*dstride ); // *pixels + } +#else + glTexSubImage2D( GL_TEXTURE_2D, // target + 0, // level + 0, // x offset + 0, // y offset + image_width, // width + image_height, // height + (BYTES_PP==4)?GL_RGBA:GL_RGB, // format + GL_UNSIGNED_BYTE, // type + ImageData ); // *pixels +#endif + + up_time+=GetRelativeTime(); + + glColor3f(1,1,1); + glBegin(GL_QUADS); + glTexCoord2f(0,0);glVertex2i(0,0); + glTexCoord2f(0,1);glVertex2i(0,texture_height); + glTexCoord2f(1,1);glVertex2i(texture_width,texture_height); + glTexCoord2f(1,0);glVertex2i(texture_width,0); + glEnd(); + + glFinish(); + glutSwapBuffers(); + + render_time+=GetRelativeTime(); + + ++counter; + { float total=gen_time+up_time+render_time; + if(total>2.0){ + printf("%8.3f fps (gen: %2d%% upload: %2d%% render: %2d%%)\n", + (float)counter/total, + (int)(100.0*gen_time/total), + (int)(100.0*up_time/total), + (int)(100.0*render_time/total) + ); + gen_time=up_time=render_time=0; + counter=0; + } } + +} + +static GLvoid IdleFunc(){ + akarmi+=0.1; + glutPostRedisplay(); +} + +int +main(int argc, char **argv) +{ + int i; + + glutInit(&argc, argv); + glutInitWindowSize(640, 480); + glutInitDisplayMode(GLUT_DOUBLE); + (void) glutCreateWindow("csg"); + + glutDisplayFunc(redraw); + glutReshapeFunc(resize); + glutIdleFunc(IdleFunc); + + texture_width=32; + while(texture_width<image_width) texture_width*=2; + while(texture_width<image_height) texture_width*=2; + texture_height=texture_width; + + image_bpp=8*BYTES_PP; + image_bytes=BYTES_PP; + + ImageData=malloc(texture_width*texture_height*image_bytes); + memset(ImageData,128,texture_width*texture_height*image_bytes); + + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_CULL_FACE); + + glEnable(GL_TEXTURE_2D); + + printf("Creating %dx%d texture...\n",texture_width,texture_height); + +#if 1 +// glBindTexture(GL_TEXTURE_2D, texture_id); + glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); +#ifdef TEXTUREFORMAT_32BPP + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0, +#else + glTexImage2D(GL_TEXTURE_2D, 0, BYTES_PP, texture_width, texture_height, 0, +#endif + (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData); +#endif + + resize(640,480); + + glClearColor( 1.0f,0.0f,1.0f,0.0f ); + glClear( GL_COLOR_BUFFER_BIT ); + + for(i=0;i<4096;i++) sintable[i]=128+127*sin(2.0*3.14159265*i/4096.0); + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/TOOLS/asfinfo.c b/TOOLS/asfinfo.c new file mode 100644 index 0000000000..3e26bfe18a --- /dev/null +++ b/TOOLS/asfinfo.c @@ -0,0 +1,255 @@ +#define SAVE_STREAMS + +// simple ASF header display program by A'rpi/ESP-team +// .asf fileformat docs from http://divx.euro.ru + +#include <stdio.h> +#include <stdlib.h> + +typedef struct __attribute__((packed)) +{ + long biSize; // sizeof(BITMAPINFOHEADER) + long biWidth; + long biHeight; + short biPlanes; // unused + short biBitCount; + long biCompression; // fourcc of image + long biSizeImage; // size of image. For uncompressed images + // ( biCompression 0 or 3 ) can be zero. + + + long biXPelsPerMeter; // unused + long biYPelsPerMeter; // unused + long biClrUsed; // valid only for palettized images. + // Number of colors in palette. + long biClrImportant; +} BITMAPINFOHEADER; + +typedef struct +{ + short wFormatTag; // value that identifies compression format + short nChannels; + long nSamplesPerSec; + long nAvgBytesPerSec; + short nBlockAlign; // size of a data sample + short wBitsPerSample; + short cbSize; // size of format-specific data +} WAVEFORMATEX; + +typedef struct __attribute__((packed)) { + unsigned char guid[16]; + unsigned long long size; +} ASF_obj_header_t; + +typedef struct __attribute__((packed)) { + ASF_obj_header_t objh; + unsigned int cno; // number of subchunks + unsigned char v1; // unknown (0x01) + unsigned char v2; // unknown (0x02) +} ASF_header_t; + +typedef struct __attribute__((packed)) { + unsigned char client[16]; // Client GUID + unsigned long long file_size; + unsigned long long creat_time; //File creation time FILETIME 8 + unsigned long long packets; //Number of packets UINT64 8 + unsigned long long end_timestamp; //Timestamp of the end position UINT64 8 + unsigned long long duration; //Duration of the playback UINT64 8 + unsigned long start_timestamp; //Timestamp of the start position UINT32 4 + unsigned long unk1; //Unknown, maybe reserved ( usually contains 0 ) UINT32 4 + unsigned long flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4 + unsigned long packetsize; //Size of packet, in bytes UINT32 4 + unsigned long packetsize2; //Size of packet ( confirm ) UINT32 4 + unsigned long frame_size; //Size of uncompressed video frame UINT32 4 +} ASF_file_header_t; + +typedef struct __attribute__((packed)) { + unsigned char type[16]; // Stream type (audio/video) GUID 16 + unsigned char concealment[16]; // Audio error concealment type GUID 16 + unsigned long long unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8 + unsigned long type_size; //Total size of type-specific data UINT32 4 + unsigned long stream_size; //Size of stream-specific data UINT32 4 + unsigned short stream_no; //Stream number UINT16 2 + unsigned long unk2; //Unknown UINT32 4 +} ASF_stream_header_t; + +typedef struct __attribute__((packed)) { + unsigned char streamno; + unsigned char seq; + unsigned long x; + unsigned char flag; +} ASF_segmhdr_t; + + +ASF_header_t asfh; +ASF_obj_header_t objh; +ASF_file_header_t fileh; +ASF_stream_header_t streamh; +unsigned char buffer[8192]; + +int i; + +char* chunk_type(unsigned char* guid){ + switch(*((unsigned int*)guid)){ + case 0xF8699E40: return "guid_audio_stream"; + case 0xBC19EFC0: return "guid_video_stream"; + case 0x49f1a440: return "guid_audio_conceal_none"; + case 0xbfc3cd50: return "guid_audio_conceal_interleave"; + case 0x75B22630: return "guid_header"; + case 0x75b22636: return "guid_data_chunk"; + case 0x33000890: return "guid_index_chunk"; + case 0xB7DC0791: return "guid_stream_header"; + case 0xD6E229D1: return "guid_header_2_0"; + case 0x8CABDCA1: return "guid_file_header"; + } + return NULL; +} + +void print_wave_header(WAVEFORMATEX *h){ + + printf("======= WAVE Format =======\n"); + + printf("Format Tag: %d (0x%X)\n",h->wFormatTag,h->wFormatTag); + printf("Channels: %d\n",h->nChannels); + printf("Samplerate: %d\n",h->nSamplesPerSec); + printf("avg byte/sec: %d\n",h->nAvgBytesPerSec); + printf("Block align: %d\n",h->nBlockAlign); + printf("bits/sample: %d\n",h->wBitsPerSample); + printf("cbSize: %d\n",h->cbSize); + + switch(h->wFormatTag){ + case 0x01: printf("Audio in PCM format\n");break; + case 0x50: printf("Audio in MPEG Layer 1/2 format\n");break; + case 0x55: printf("Audio in MPEG Layer-3 format\n");break; // ACM + case 0x02: printf("Audio in MS ADPCM format\n");break; // ACM + case 0x11: printf("Audio in IMA ADPCM format\n");break; // ACM + case 0x31: + case 0x32: printf("Audio in MS GSM 6.10 format\n");break; // ACM + case 0x160: + case 0x161: printf("Audio in DivX WMA format\n");break; // ACM + default: printf("Audio in UNKNOWN (id=0x%X) format\n",h->wFormatTag); + } + + printf("===========================\n"); + + +} + +void print_video_header(BITMAPINFOHEADER *h){ + printf("======= VIDEO Format ======\n"); + printf(" biSize %d\n", h->biSize); + printf(" biWidth %d\n", h->biWidth); + printf(" biHeight %d\n", h->biHeight); + printf(" biPlanes %d\n", h->biPlanes); + printf(" biBitCount %d\n", h->biBitCount); + printf(" biCompression %d='%.4s'\n", h->biCompression, &h->biCompression); + printf(" biSizeImage %d\n", h->biSizeImage); + printf("===========================\n"); +} + +FILE* streams[128]; + +int main(int argc,char* argv[]){ +FILE *f=fopen(argc>1?argv[1]:"Alice Deejay - Back In My Life.asf","rb"); + +if(!f){ printf("file not found\n");exit(1);} + +//printf("sizeof=%d\n",sizeof(objh)); +//printf("sizeof=%d\n",sizeof(asfh)); + +fread(&asfh,sizeof(asfh),1,f); // header obj +//for(i=0;i<16;i++) printf("%02X ",asfh.objh.guid[i]); +printf("[%s] %d (subchunks: %d)\n",chunk_type(asfh.objh.guid),(int) asfh.objh.size,asfh.cno); + +while(fread(&objh,sizeof(objh),1,f)>0){ + int pos=ftell(f); +// for(i=0;i<16;i++) printf("%02X ",objh.guid[i]); + printf("0x%08X [%s] %d\n",pos-sizeof(objh), chunk_type(objh.guid),(int) objh.size); + switch(*((unsigned int*)&objh.guid)){ + case 0xB7DC0791: // guid_stream_header + fread(&streamh,sizeof(streamh),1,f); + printf("stream type: %s\n",chunk_type(streamh.type)); + printf("stream concealment: %s\n",chunk_type(streamh.concealment)); + printf("type: %d bytes, stream: %d bytes ID: %d\n",(int)streamh.type_size,(int)streamh.stream_size,(int)streamh.stream_no); + printf("FILEPOS=0x%X\n",ftell(f)); + // type-specific data: + fread(buffer,streamh.type_size,1,f); + switch(*((unsigned int*)&streamh.type)){ + case 0xF8699E40: // guid_audio_stream + print_wave_header((WAVEFORMATEX*)buffer); + break; + case 0xBC19EFC0: // guid_video_stream + print_video_header((BITMAPINFOHEADER*)&buffer[4+4+1+2]); + break; + } + // stream-specific data: + fread(buffer,streamh.stream_size,1,f); + break; +// case 0xD6E229D1: return "guid_header_2_0"; + case 0x8CABDCA1: // guid_file_header + fread(&fileh,sizeof(fileh),1,f); + 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); + break; + case 0x75b22636: // guid_data_chunk + { int endp=pos+objh.size-sizeof(objh); + unsigned char* packet=malloc((int)fileh.packetsize); + int fpos; + fseek(f,26,SEEK_CUR); + while((fpos=ftell(f))<endp){ + fread(packet,(int)fileh.packetsize,1,f); + if(packet[0]==0x82){ + unsigned char flags=packet[3]; + unsigned char* p=&packet[5]; + unsigned long time; + unsigned short duration; + int segs=1; + int seg; + int padding=0; + if(flags&8){ + padding=p[0];++p; + } else + if(flags&16){ + padding=p[0]|(p[1]<<8);p+=2; + } + time=*((unsigned long*)p);p+=4; + duration=*((unsigned short*)p);p+=2; + if(flags&1){ + segs=p[0]-0x80;++p; + } + printf("%08X: flag=%02X segs=%d pad=%d time=%d dur=%d\n", + fpos,flags,segs,padding,time,duration); + for(seg=0;seg<segs;seg++){ + ASF_segmhdr_t* sh=(ASF_segmhdr_t*)p; + int len=0; + p+=sizeof(ASF_segmhdr_t); + if(sh->flag&8) p+=8;// else + if(sh->flag&1) ++p; + if(flags&1){ + len=*((unsigned short*)p);p+=2; + } + printf(" seg #%d: streamno=%d seq=%d flag=%02X len=%d\n",seg,sh->streamno&0x7F,sh->seq,sh->flag,len); +#ifdef SAVE_STREAMS + if(!streams[sh->streamno&0x7F]){ + char name[256]; + sprintf(name,"stream%02X.dat",sh->streamno&0x7F); + streams[sh->streamno&0x7F]=fopen(name,"wb"); + } + fwrite(p,len,1,streams[sh->streamno&0x7F]); +#endif + p+=len; + } + } else + printf("%08X: UNKNOWN %02X %02X %02X %02X %02X...\n",fpos,packet[0],packet[1],packet[2],packet[3],packet[4]); + } + } + break; + +// case 0x33000890: return "guid_index_chunk"; + + } + fseek(f,pos+objh.size-sizeof(objh),SEEK_SET); +} + + +} + diff --git a/TOOLS/c b/TOOLS/c new file mode 100755 index 0000000000..5ba26feeb6 --- /dev/null +++ b/TOOLS/c @@ -0,0 +1 @@ +gcc movinfo.c -o movinfo diff --git a/TOOLS/movinfo.c b/TOOLS/movinfo.c new file mode 100644 index 0000000000..3c3c3ddd9e --- /dev/null +++ b/TOOLS/movinfo.c @@ -0,0 +1,124 @@ +// show QuickTime .mov file structure (C) 2001. by A'rpi/ESP-team + +#include <stdio.h> +#include <stdlib.h> + +unsigned int read_dword(FILE *f){ + unsigned char atom_size_b[4]; + if(fread(&atom_size_b,4,1,f)<=0) return -1; + return (atom_size_b[0]<<24)|(atom_size_b[1]<<16)|(atom_size_b[2]<<8)|atom_size_b[3]; +} + +void lschunks(FILE *f,int level,unsigned int endpos){ + unsigned int atom_size; + unsigned int atom_type; + int pos; + while(endpos==0 || ftell(f)<endpos){ + pos=ftell(f); + atom_size=read_dword(f);// if(fread(&atom_size_b,4,1,f)<=0) break; + if(fread(&atom_type,4,1,f)<=0) break; + + if(atom_size<8) break; // error + + printf("%08X: %*s %.4s (%08X) %d\n",pos,level*2,"",&atom_type,atom_type,atom_size); + + if(atom_type==0x64737473) { // stsd + unsigned int tmp; + unsigned int count; + int i; + fread(&tmp,4,1,f); + count=read_dword(f);// fread(&count,4,1,f); + printf("desc count = %d\n",count); + for(i=0;i<count;i++){ + unsigned int len; + unsigned int format; + len=read_dword(f); // fread(&len,4,1,f); + fread(&format,4,1,f); + printf(" desc #%d: %.4s (%d)\n",i+1,&format,len); + fseek(f,len-8,SEEK_CUR); + } + } + + if(atom_type==0x6F637473) { // stco + int len,i; + read_dword(f); + len=read_dword(f); + printf("Chunk table size :%d\n",len); + for(i=0;i<len;i++) printf(" chunk #%d: 0x%X\n",i+1,read_dword(f)); + } + + + if(atom_type==0x73747473) { // stts + int len,i; + read_dword(f); + len=read_dword(f); + printf("T->S table size :%d\n",len); + for(i=0;i<len;i++){ + int num=read_dword(f); + int dur=read_dword(f); + printf("%5d samples: %d duration\n",num,dur); + } + } + + if(atom_type==0x63737473) { // stsc + int len,i; + read_dword(f); + len=read_dword(f); + printf("S->C table size :%d\n",len); + for(i=0;i<len;i++){ + int first=read_dword(f); + int spc=read_dword(f); + int sdid=read_dword(f); + printf(" chunk %d... %d s/c desc: %d\n",first,spc,sdid); + } + } + + if(atom_type==0x7A737473) { // stsz + int len,i,ss; + read_dword(f); + ss=read_dword(f); + len=read_dword(f); + printf("Sample size table len: %d\n",len); + if(ss){ + printf(" common sample size: %d bytes\n",ss); + } else { + for(i=0;i<len;i++) printf(" sample #%d: %d bytes\n",i+1,read_dword(f)); + } + } + + +#if 1 + switch(atom_type){ + case 0x75716D72: // rmqu + case 0x65657266: // free JUNK + case 0x64686B74: // tkhd Track header + case 0x61746475: // udta User data + case 0x7461646D: // mdat Movie data + case 0x64737473: // stsd Sample description + case 0x6F637473: // stco Chunk offset table + case 0x73747473: // stts Sample time table + case 0x63737473: // stsc Sample->Chunk mapping table + case 0x7A737473: // stsz Sample size table + break; + default: lschunks(f,level+1,pos+atom_size); + } +#else + switch(atom_type){ + case 0x766F6F6D: // moov + case 0x61726D72: // rmra + case 0x61646D72: // rmda + lschunks(f,level+1,pos+atom_size); + } +#endif + fseek(f,pos+atom_size,SEEK_SET); + } +} + +int main(int argc,char* argv[]){ +int pos; +FILE *f=fopen(argc>1?argv[1]:"Akira.mov","rb"); +if(!f) return 1; + +lschunks(f,0,0); + +} |