Mercurial > mplayer.hg
changeset 587:8511095c5283
stage#1 completed: c files no more included from mplayer.c
author | arpi_esp |
---|---|
date | Mon, 23 Apr 2001 03:42:17 +0000 |
parents | e1b8c0b3ec35 |
children | 017ee00ac42c |
files | Makefile asfheader.c aviheader.c aviprint.c aviwrite.c dec_audio.c demux_asf.c demux_avi.c demux_mpg.c demuxer.c dll_init.c mplayer.c stheader.h vcd_read.h |
diffstat | 14 files changed, 421 insertions(+), 341 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Apr 23 03:39:34 2001 +0000 +++ b/Makefile Mon Apr 23 03:42:17 2001 +0000 @@ -20,8 +20,8 @@ prefix = /usr/local BINDIR = ${prefix}/bin # BINDIR = /usr/local/bin -SRCS = stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c -OBJS = stream.o codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o spudec.o +SRCS = find_sub.c aviprint.c dll_init.c dec_audio.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c +OBJS = find_sub.o aviprint.o dll_init.o dec_audio.o aviwrite.o aviheader.o asfheader.o demux_avi.o demux_asf.o demux_mpg.o demuxer.o stream.o codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o spudec.o CFLAGS = $(OPTFLAGS) $(CSS_INC) -Iloader -Ilibvo # -Wall A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3 VO_LIBS = -Llibvo -lvo $(X_LIBS)
--- a/asfheader.c Mon Apr 23 03:39:34 2001 +0000 +++ b/asfheader.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,5 +1,21 @@ // .asf fileformat docs from http://divx.euro.ru + +#include <stdio.h> +#include <stdlib.h> + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +#include "wine/mmreg.h" +#include "wine/avifmt.h" +#include "wine/vfw.h" + +#include "codec-cfg.h" +#include "stheader.h" + typedef struct __attribute__((packed)) { unsigned char guid[16]; unsigned long long size; @@ -38,38 +54,21 @@ } ASF_stream_header_t; -ASF_header_t asfh; -ASF_obj_header_t objh; -ASF_file_header_t fileh; -ASF_stream_header_t streamh; +static ASF_header_t asfh; +static ASF_obj_header_t objh; +static ASF_file_header_t fileh; +static ASF_stream_header_t streamh; + unsigned char* asf_packet=NULL; -//int asf_video_id=-1; int asf_scrambling_h=1; int asf_scrambling_w=1; int asf_scrambling_b=1; - -int i; +int asf_packetsize=0; -void asf_descrambling(unsigned char *src,int len){ - unsigned char *dst=malloc(len); - unsigned char *s2=src; - int i=0,x,y; - while(len-i>=asf_scrambling_h*asf_scrambling_w*asf_scrambling_b){ -// printf("descrambling! (w=%d b=%d)\n",w,asf_scrambling_b); - //i+=asf_scrambling_h*asf_scrambling_w; - for(x=0;x<asf_scrambling_w;x++) - for(y=0;y<asf_scrambling_h;y++){ - memcpy(dst+i,s2+(y*asf_scrambling_w+x)*asf_scrambling_b,asf_scrambling_b); - i+=asf_scrambling_b; - } - s2+=asf_scrambling_h*asf_scrambling_w*asf_scrambling_b; - } - //if(i<len) memcpy(dst+i,src+i,len-i); - memcpy(src,dst,i); - free(dst); -} +//int i; -char* asf_chunk_type(unsigned char* guid){ + +static char* asf_chunk_type(unsigned char* guid){ switch(*((unsigned int*)guid)){ case 0xF8699E40: return "guid_audio_stream"; case 0xBC19EFC0: return "guid_video_stream"; @@ -85,7 +84,7 @@ return NULL; } -int asf_check_header(){ +int asf_check_header(demuxer_t *demuxer){ unsigned char asfhdrguid[16]={0x30,0x26,0xB2,0x75,0x8E,0x66,0xCF,0x11,0xA6,0xD9,0x00,0xAA,0x00,0x62,0xCE,0x6C}; stream_read(demuxer->stream,(char*) &asfh,sizeof(asfh)); // header obj // for(i=0;i<16;i++) printf(" %02X",temp[i]);printf("\n"); @@ -101,7 +100,7 @@ return 1; } -int read_asf_header(){ +int read_asf_header(demuxer_t *demuxer){ unsigned char buffer[512]; #if 1 @@ -166,12 +165,13 @@ case 0x8CABDCA1: // guid_file_header stream_read(demuxer->stream,(char*) &fileh,sizeof(fileh)); if(verbose) printf("ASF: packets: %d flags: %d pack_size: %d frame_size: %d\n",(int)fileh.packets,(int)fileh.flags,(int)fileh.packetsize,(int)fileh.frame_size); - asf_packet=malloc(fileh.packetsize); // !!! + asf_packetsize=fileh.packetsize; + asf_packet=malloc(asf_packetsize); // !!! break; case 0x75b22636: // guid_data_chunk - avi_header.movi_start=stream_tell(demuxer->stream)+26; - avi_header.movi_end=endpos; - if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",avi_header.movi_start,avi_header.movi_end); + demuxer->movi_start=stream_tell(demuxer->stream)+26; + demuxer->movi_end=endpos; + if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); break; // case 0x33000890: return "guid_index_chunk";
--- a/aviheader.c Mon Apr 23 03:39:34 2001 +0000 +++ b/aviheader.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,7 +1,25 @@ + + +#include <stdio.h> +#include <stdlib.h> + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +#include "wine/mmreg.h" +#include "wine/avifmt.h" +#include "wine/vfw.h" + +#include "codec-cfg.h" +#include "stheader.h" #define MIN(a,b) (((a)<(b))?(a):(b)) -void read_avi_header(int index_mode){ +static MainAVIHeader avih; + +void read_avi_header(demuxer_t *demuxer,int index_mode){ sh_audio_t *sh_audio=NULL; sh_video_t *sh_video=NULL; int stream_id=-1; @@ -9,7 +27,7 @@ int idxfix_divx=0; //---- AVI header: -avi_header.idx_size=0; +demuxer->idx_size=0; while(1){ int id=stream_read_dword_le(demuxer->stream); int chunksize,size2; @@ -23,9 +41,9 @@ if(verbose>=2) printf("LIST %.4s len=%d\n",&id,len); if(id==listtypeAVIMOVIE){ // found MOVI header - avi_header.movi_start=stream_tell(demuxer->stream); - avi_header.movi_end=avi_header.movi_start+len; - if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",avi_header.movi_start,avi_header.movi_end); + demuxer->movi_start=stream_tell(demuxer->stream); + demuxer->movi_end=demuxer->movi_start+len; + if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); len=(len+1)&(~1); stream_skip(demuxer->stream,len); } @@ -36,9 +54,9 @@ chunksize=(size2+1)&(~1); switch(id){ case ckidAVIMAINHDR: // read 'avih' - stream_read(demuxer->stream,(char*) &avi_header.avih,MIN(size2,sizeof(avi_header.avih))); - chunksize-=MIN(size2,sizeof(avi_header.avih)); - if(verbose) print_avih(&avi_header.avih); + stream_read(demuxer->stream,(char*) &avih,MIN(size2,sizeof(avih))); + chunksize-=MIN(size2,sizeof(avih)); + if(verbose) print_avih(&avih); break; case ckidSTREAMHEADER: { // read 'strh' AVIStreamHeader h; @@ -79,6 +97,8 @@ case mmioFOURCC('d', 'i', 'v', '6'): case mmioFOURCC('M', 'P', '4', '3'): case mmioFOURCC('m', 'p', '4', '3'): + case mmioFOURCC('M', 'P', '4', '2'): + case mmioFOURCC('m', 'p', '4', '2'): case mmioFOURCC('A', 'P', '4', '1'): idxfix_divx=1; // we can fix keyframes only for divx coded files! } @@ -95,13 +115,13 @@ break; } case ckidAVINEWINDEX: if(index_mode){ - avi_header.idx_size=size2>>4; + demuxer->idx_size=size2>>4; if(verbose>=1) printf("Reading INDEX block, %d chunks for %d frames\n", - avi_header.idx_size,avi_header.avih.dwTotalFrames); - avi_header.idx=malloc(avi_header.idx_size<<4); - stream_read(demuxer->stream,(char*)avi_header.idx,avi_header.idx_size<<4); - chunksize-=avi_header.idx_size<<4; - if(verbose>=2) print_index(); + demuxer->idx_size,avih.dwTotalFrames); + demuxer->idx=malloc(demuxer->idx_size<<4); + stream_read(demuxer->stream,(char*)demuxer->idx,demuxer->idx_size<<4); + chunksize-=demuxer->idx_size<<4; + if(verbose>=2) print_index(demuxer->idx,demuxer->idx_size); break; } } @@ -110,20 +130,20 @@ } -if(index_mode>=2 || (avi_header.idx_size==0 && index_mode==1)){ +if(index_mode>=2 || (demuxer->idx_size==0 && index_mode==1)){ // build index for file: stream_reset(demuxer->stream); - stream_seek(demuxer->stream,avi_header.movi_start); + stream_seek(demuxer->stream,demuxer->movi_start); - avi_header.idx_pos=0; - avi_header.idx=NULL; + demuxer->idx_pos=0; + demuxer->idx=NULL; while(1){ int id,len,skip; AVIINDEXENTRY* idx; unsigned char c; demuxer->filepos=stream_tell(demuxer->stream); - if(demuxer->filepos>=avi_header.movi_end) break; + if(demuxer->filepos>=demuxer->movi_end) break; id=stream_read_dword_le(demuxer->stream); len=stream_read_dword_le(demuxer->stream); if(id==mmioFOURCC('L','I','S','T')){ @@ -131,12 +151,12 @@ continue; } if(stream_eof(demuxer->stream)) break; - if(avi_header.idx_pos<=avi_header.idx_size){ - avi_header.idx_size+=32; - avi_header.idx=realloc(avi_header.idx,avi_header.idx_size*sizeof(AVIINDEXENTRY)); - if(!avi_header.idx){avi_header.idx_pos=0; break;} // error! + if(demuxer->idx_pos<=demuxer->idx_size){ + demuxer->idx_size+=32; + demuxer->idx=realloc(demuxer->idx,demuxer->idx_size*sizeof(AVIINDEXENTRY)); + if(!demuxer->idx){demuxer->idx_pos=0; break;} // error! } - idx=&avi_header.idx[avi_header.idx_pos++]; + idx=&((AVIINDEXENTRY *)demuxer->idx)[demuxer->idx_pos++]; idx->ckid=id; idx->dwFlags=AVIIF_KEYFRAME; // FIXME idx->dwChunkOffset=demuxer->filepos; @@ -163,8 +183,8 @@ skip=(len+1)&(~1); // total bytes in this chunk stream_seek(demuxer->stream,8+demuxer->filepos+skip); } - avi_header.idx_size=avi_header.idx_pos; - printf("AVI: Generated index table for %d chunks!\n",avi_header.idx_size); + demuxer->idx_size=demuxer->idx_pos; + printf("AVI: Generated index table for %d chunks!\n",demuxer->idx_size); } }
--- a/aviprint.c Mon Apr 23 03:39:34 2001 +0000 +++ b/aviprint.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,3 +1,20 @@ + +#include <stdio.h> +#include <stdlib.h> + +//extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +#include "wine/mmreg.h" +#include "wine/avifmt.h" +#include "wine/vfw.h" + +//#include "codec-cfg.h" +//#include "stheader.h" + + void print_avih(MainAVIHeader *h){ printf("======= AVI Header =======\n"); printf("us/frame: %d (fps=%5.3f)\n",h->dwMicroSecPerFrame,1000000.0f/(float)h->dwMicroSecPerFrame); @@ -56,15 +73,15 @@ } -void print_index(){ +void print_index(AVIINDEXENTRY *idx,int idx_size){ int i; - for(i=0;i<avi_header.idx_size;i++){ - printf("%5d: %.4s %4X %08X (%08X) %d\n",i, - &avi_header.idx[i].ckid, - avi_header.idx[i].dwFlags, - avi_header.idx[i].dwChunkOffset, - avi_header.idx[i].dwChunkOffset+avi_header.movi_start, - avi_header.idx[i].dwChunkLength + for(i=0;i<idx_size;i++){ + printf("%5d: %.4s %4X %08X %d\n",i, + &idx[i].ckid, + idx[i].dwFlags, + idx[i].dwChunkOffset, +// idx[i].dwChunkOffset+demuxer->movi_start, + idx[i].dwChunkLength ); } }
--- a/aviwrite.c Mon Apr 23 03:39:34 2001 +0000 +++ b/aviwrite.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,3 +1,14 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "wine/mmreg.h" +#include "wine/avifmt.h" +#include "wine/vfw.h" + +extern char* encode_name; +extern char* encode_index_name; void write_avi_chunk(FILE *f,unsigned int id,int len,void* data){
--- a/dec_audio.c Mon Apr 23 03:39:34 2001 +0000 +++ b/dec_audio.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,3 +1,39 @@ + +#include <stdio.h> +#include <stdlib.h> + +#include "config.h" + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +#include "wine/mmreg.h" +#include "wine/avifmt.h" +#include "wine/vfw.h" + +#include "codec-cfg.h" +#include "stheader.h" + +#include "mp3lib/mp3.h" +#include "libac3/ac3.h" + +#include "alaw.c" +#include "xa/xa_gsm.h" + +static sh_audio_t* ac3_audio_sh=NULL; + +// AC3 decoder buffer callback: +static void ac3_fill_buffer(uint8_t **start,uint8_t **end){ + int len=ds_get_packet(ac3_audio_sh->ds,start); + //printf("<ac3:%d>\n",len); + if(len<0) + *start = *end = NULL; + else + *end = *start + len; +} + int init_audio(sh_audio_t *sh_audio){ @@ -79,6 +115,7 @@ } case 3: { // Dolby AC3 audio: + ac3_audio_sh=sh_audio; // save sh_audio for the callback: ac3_config.fill_buffer_callback = ac3_fill_buffer; ac3_config.num_output_ch = 2; ac3_config.flags = 0; @@ -91,7 +128,7 @@ ac3_init(); sh_audio->ac3_frame = ac3_decode_frame(); if(sh_audio->ac3_frame){ - sh_audio->samplerate=sh_audio->ac3_frame->sampling_rate; + sh_audio->samplerate=((ac3_frame_t*)sh_audio->ac3_frame)->sampling_rate; sh_audio->channels=2; } else { driver=0; // bad frame -> disable audio @@ -179,7 +216,7 @@ { unsigned char buf[65]; // 65 bytes / frame len=0; while(len<OUTBURST){ - if(demux_read_data(d_audio,buf,65)!=65) break; // EOF + if(demux_read_data(sh_audio->ds,buf,65)!=65) break; // EOF XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short len+=2*320; @@ -192,7 +229,7 @@ //printf("{2:%d}",avi_header.idx_pos);fflush(stdout); if(sh_audio->ac3_frame){ len = 256 * 6 *sh_audio->channels*sh_audio->samplesize; - memcpy(buf,sh_audio->ac3_frame->audio_data,len); + memcpy(buf,((ac3_frame_t*)sh_audio->ac3_frame)->audio_data,len); sh_audio->ac3_frame=NULL; } //printf("{3:%d}",avi_header.idx_pos);fflush(stdout);
--- a/demux_asf.c Mon Apr 23 03:39:34 2001 +0000 +++ b/demux_asf.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,5 +1,21 @@ // ASF file parser for DEMUXER v0.3 by A'rpi/ESP-team +#include <stdio.h> +#include <stdlib.h> + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +// defined at asfheader.c: +extern unsigned char* asf_packet; +extern int asf_scrambling_h; +extern int asf_scrambling_w; +extern int asf_scrambling_b; +extern int asf_packetsize; + + // based on asf file-format doc by Eugene [http://divx.euro.ru] //static float avi_pts_frametime=1.0f/25.0f; @@ -15,6 +31,25 @@ unsigned char flag; } ASF_segmhdr_t; +static void asf_descrambling(unsigned char *src,int len){ + unsigned char *dst=malloc(len); + unsigned char *s2=src; + int i=0,x,y; + while(len-i>=asf_scrambling_h*asf_scrambling_w*asf_scrambling_b){ +// printf("descrambling! (w=%d b=%d)\n",w,asf_scrambling_b); + //i+=asf_scrambling_h*asf_scrambling_w; + for(x=0;x<asf_scrambling_w;x++) + for(y=0;y<asf_scrambling_h;y++){ + memcpy(dst+i,s2+(y*asf_scrambling_w+x)*asf_scrambling_b,asf_scrambling_b); + i+=asf_scrambling_b; + } + s2+=asf_scrambling_h*asf_scrambling_w*asf_scrambling_b; + } + //if(i<len) memcpy(dst+i,src+i,len-i); + memcpy(src,dst,i); + free(dst); +} + static int demux_asf_read_packet(demuxer_t *demux,unsigned char *data,int len,int id,int seq,unsigned long time,unsigned short dur,int offs){ demux_stream_t *ds=NULL; @@ -22,18 +57,18 @@ if(verbose>=4) printf("demux_asf.read_packet: id=%d seq=%d len=%d\n",id,seq,len); if(demux->video->id==-1) - if(avi_header.v_streams[id]) + if(demux->v_streams[id]) demux->video->id=id; if(demux->audio->id==-1) - if(avi_header.a_streams[id]) + if(demux->a_streams[id]) demux->audio->id=id; if(id==demux->audio->id){ // audio ds=demux->audio; if(!ds->sh){ - ds->sh=avi_header.a_streams[id]; + ds->sh=demux->a_streams[id]; if(verbose) printf("Auto-selected ASF audio ID = %d\n",ds->id); } } else @@ -41,7 +76,7 @@ // video ds=demux->video; if(!ds->sh){ - ds->sh=avi_header.v_streams[id]; + ds->sh=demux->v_streams[id]; if(verbose) printf("Auto-selected ASF video ID = %d\n",ds->id); } } @@ -97,19 +132,19 @@ int demux_asf_fill_buffer(demuxer_t *demux){ demux->filepos=stream_tell(demux->stream); - if(demux->filepos>=demux->endpos){ + if(demux->filepos>=demux->movi_end){ demux->stream->eof=1; return 0; } - stream_read(demux->stream,asf_packet,(int)fileh.packetsize); + stream_read(demux->stream,asf_packet,asf_packetsize); if(demux->stream->eof) return 0; // EOF if(asf_packet[0]==0x82){ unsigned char flags=asf_packet[3]; unsigned char segtype=asf_packet[4]; unsigned char* p=&asf_packet[5]; - unsigned char* p_end=p+(int)fileh.packetsize; + unsigned char* p_end=p+asf_packetsize; unsigned long time; unsigned short duration; int segs=1; @@ -131,11 +166,11 @@ // Explicit (absoulte) packet size plen=p[0]|(p[1]<<8); p+=2; if(verbose>1)printf("Explicit packet size specified: %d \n",plen); - if(plen>fileh.packetsize) printf("Warning! plen>packetsize! (%d>%d) \n",plen,(int)fileh.packetsize); + if(plen>asf_packetsize) printf("Warning! plen>packetsize! (%d>%d) \n",plen,asf_packetsize); if(flags&(8|16)){ padding=p[0];p++; if(flags&16){ padding|=p[0]<<8; p++;} - if(verbose)printf("Warning! explicit=%d padding=%d \n",plen,fileh.packetsize-padding); + if(verbose)printf("Warning! explicit=%d padding=%d \n",plen,asf_packetsize-padding); } } else { // Padding (relative) size @@ -145,7 +180,7 @@ if(flags&16){ padding=p[0]|(p[1]<<8);p+=2; } - plen=fileh.packetsize-padding; + plen=asf_packetsize-padding; } time=*((unsigned long*)p);p+=4;
--- a/demux_avi.c Mon Apr 23 03:39:34 2001 +0000 +++ b/demux_avi.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,44 +1,51 @@ // AVI file parser for DEMUXER v2.6 by A'rpi/ESP-team +#include <stdio.h> +#include <stdlib.h> + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +#include "wine/mmreg.h" +#include "wine/avifmt.h" +#include "wine/vfw.h" + +#include "codec-cfg.h" +#include "stheader.h" + //static float avi_pts_frametime=1.0f/25.0f; -static float avi_audio_pts=0; -static float avi_video_pts=0; - -static int skip_video_frames=0; - -static inline int avi_stream_id(unsigned int id){ - unsigned char *p=(unsigned char *)&id; - unsigned char a,b; - a=p[0]-'0'; b=p[1]-'0'; - if(a>9 || b>9) return 100; // invalid ID - return a*10+b; -} +float avi_audio_pts=0; +float avi_video_pts=0; +//float avi_video_ftime=0.04; +int skip_video_frames=0; // Select ds from ID -static inline demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){ +demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){ int stream_id=avi_stream_id(id); // printf("demux_avi_select_stream(%d) {a:%d/v:%d}\n",stream_id, // demux->audio->id,demux->video->id); if(demux->video->id==-1) - if(avi_header.v_streams[stream_id]) + if(demux->v_streams[stream_id]) demux->video->id=stream_id; if(demux->audio->id==-1) - if(avi_header.a_streams[stream_id]) + if(demux->a_streams[stream_id]) demux->audio->id=stream_id; if(stream_id==demux->audio->id){ if(!demux->audio->sh){ - demux->audio->sh=avi_header.a_streams[stream_id]; + demux->audio->sh=demux->a_streams[stream_id]; if(verbose) printf("Auto-selected AVI audio ID = %d\n",demux->audio->id); } return demux->audio; } if(stream_id==demux->video->id){ if(!demux->video->sh){ - demux->video->sh=avi_header.v_streams[stream_id]; + demux->video->sh=demux->v_streams[stream_id]; if(verbose) printf("Auto-selected AVI video ID = %d\n",demux->video->id); } return demux->video; @@ -74,7 +81,9 @@ //avi_video_pts+=avi_pts_frametime; //avi_video_pts+=(float)avi_header.video.dwScale/(float)avi_header.video.dwRate; //avi_video_pts+=((sh_video_t*)ds->sh)->frametime; +// FIXME!!! avi_video_pts+=(float)((sh_video_t*)(demux->video->sh))->video.dwScale/(float)((sh_video_t*)(demux->video->sh))->video.dwRate; +// avi_video_pts+=avi_video_ftime; avi_audio_pts=avi_video_pts; } @@ -108,19 +117,19 @@ do{ AVIINDEXENTRY *idx=NULL; demux->filepos=stream_tell(demux->stream); - if(demux->filepos>=demux->endpos){ + if(demux->filepos>=demux->movi_end){ demux->stream->eof=1; return 0; } if(stream_eof(demux->stream)) return 0; - if(avi_header.idx_size>0 && avi_header.idx_pos<avi_header.idx_size){ + if(demux->idx_size>0 && demux->idx_pos<demux->idx_size){ unsigned int pos; - //if(avi_header.idx_pos<0) printf("Fatal! idx_pos=%d\n",avi_header.idx_pos); + //if(demux->idx_pos<0) printf("Fatal! idx_pos=%d\n",demux->idx_pos); - idx=&avi_header.idx[avi_header.idx_pos++]; + idx=&((AVIINDEXENTRY *)demux->idx)[demux->idx_pos++]; - //printf("[%d]",avi_header.idx_pos);fflush(stdout); + //printf("[%d]",demux->idx_pos);fflush(stdout); //stream_seek(demux->stream,idx.dwChunkOffset); //printf("IDX pos=%X idx.pos=%X idx.size=%X idx.flags=%X\n",demux->filepos, @@ -134,8 +143,8 @@ continue; // skip this chunk } - pos=idx->dwChunkOffset+avi_header.idx_offset; - if(pos<avi_header.movi_start || pos>=avi_header.movi_end){ + pos=idx->dwChunkOffset+demux->idx_offset; + if(pos<demux->movi_start || pos>=demux->movi_end){ printf("ChunkOffset out of range! current=0x%X idx=0x%X \n",demux->filepos,pos); continue; } @@ -165,7 +174,7 @@ continue; } } - ret=demux_avi_read_packet(demux,id,len,avi_header.idx_pos-1); + ret=demux_avi_read_packet(demux,id,len,demux->idx_pos-1); if(!ret && skip_video_frames<=0) if(--max_packs==0){ demux->stream->eof=1; @@ -191,13 +200,14 @@ int idx_pos=0; demux->filepos=stream_tell(demux->stream); - if(ds==demux->video) idx_pos=avi_header.idx_pos_a++; else - if(ds==demux->audio) idx_pos=avi_header.idx_pos_v++; else - idx_pos=avi_header.idx_pos++; + if(ds==demux->video) idx_pos=demux->idx_pos_a++; else + if(ds==demux->audio) idx_pos=demux->idx_pos_v++; else + idx_pos=demux->idx_pos++; - if(avi_header.idx_size>0 && idx_pos<avi_header.idx_size){ + if(demux->idx_size>0 && idx_pos<demux->idx_size){ unsigned int pos; - idx=&avi_header.idx[idx_pos]; + idx=&((AVIINDEXENTRY *)demux->idx)[idx_pos]; +// idx=&demux->idx[idx_pos]; if(idx->dwFlags&AVIIF_LIST){ // LIST @@ -208,8 +218,8 @@ continue; // skip this chunk } - pos=idx->dwChunkOffset+avi_header.idx_offset; - if(pos<avi_header.movi_start || pos>=avi_header.movi_end){ + pos=idx->dwChunkOffset+demux->idx_offset; + if(pos<demux->movi_start || pos>=demux->movi_end){ printf("ChunkOffset out of range! current=0x%X idx=0x%X \n",demux->filepos,pos); continue; } @@ -257,8 +267,8 @@ int ret=0; int *fpos=NULL; - if(ds==demux->video) fpos=&avi_header.idx_pos_a; else - if(ds==demux->audio) fpos=&avi_header.idx_pos_v; else + if(ds==demux->video) fpos=&demux->idx_pos_a; else + if(ds==demux->audio) fpos=&demux->idx_pos_v; else return 0; stream_seek(demux->stream,fpos[0]); @@ -266,7 +276,7 @@ do{ demux->filepos=stream_tell(demux->stream); - if(demux->filepos>=demux->endpos){ + if(demux->filepos>=demux->movi_end){ demux->stream->eof=1; return 0; } @@ -281,7 +291,7 @@ if(ds==demux_avi_select_stream(demux,id)){ // read it! - ret=demux_avi_read_packet(demux,id,len,avi_header.idx_pos-1); + ret=demux_avi_read_packet(demux,id,len,demux->idx_pos-1); } else { // skip it! int skip=(len+1)&(~1); // total bytes in this chunk
--- a/demux_mpg.c Mon Apr 23 03:39:34 2001 +0000 +++ b/demux_mpg.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,5 +1,13 @@ // MPG/VOB file parser for DEMUXER v2.5 by A'rpi/ESP-team +#include <stdio.h> +#include <stdlib.h> + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + //#define MAX_PS_PACKETSIZE 2048 #define MAX_PS_PACKETSIZE (224*1024) @@ -128,9 +136,9 @@ // subtitle: aid&=0x1F; - if(!avi_header.s_streams[aid]){ + if(!demux->s_streams[aid]){ printf("==> Found subtitle: %d\n",aid); - avi_header.s_streams[aid]=1; + demux->s_streams[aid]=1; // new_sh_audio(aid); } @@ -144,13 +152,13 @@ // aid=128+(aid&0x7F); // aid=0x80..0xBF - if(!avi_header.a_streams[aid]) new_sh_audio(aid); + if(!demux->a_streams[aid]) new_sh_audio(aid); if(demux->audio->id==-1) demux->audio->id=aid; if(demux->audio->id==aid){ // int type; ds=demux->audio; - if(!ds->sh) ds->sh=avi_header.a_streams[aid]; + if(!ds->sh) ds->sh=demux->a_streams[aid]; // READ Packet: Skip additional audio header data: c=stream_read_char(demux->stream);//type=c; c=stream_read_char(demux->stream);//type|=c<<8; @@ -197,22 +205,22 @@ if(id>=0x1C0 && id<=0x1DF){ // mpeg audio int aid=id-0x1C0; - if(!avi_header.a_streams[aid]) new_sh_audio(aid); + if(!demux->a_streams[aid]) new_sh_audio(aid); if(demux->audio->id==-1) demux->audio->id=aid; if(demux->audio->id==aid){ ds=demux->audio; - if(!ds->sh) ds->sh=avi_header.a_streams[aid]; + if(!ds->sh) ds->sh=demux->a_streams[aid]; if(ds->type==-1) ds->type=1; } } else if(id>=0x1E0 && id<=0x1EF){ // mpeg video int aid=id-0x1E0; - if(!avi_header.v_streams[aid]) new_sh_video(aid); + if(!demux->v_streams[aid]) new_sh_video(aid); if(demux->video->id==-1) demux->video->id=aid; if(demux->video->id==aid){ ds=demux->video; - if(!ds->sh) ds->sh=avi_header.v_streams[aid]; + if(!ds->sh) ds->sh=demux->v_streams[aid]; } } @@ -234,8 +242,8 @@ return 0; } -static int num_elementary_packets100=0; -static int num_elementary_packets101=0; +int num_elementary_packets100=0; +int num_elementary_packets101=0; int demux_mpg_es_fill_buffer(demuxer_t *demux){ //if(demux->type==DEMUXER_TYPE_MPEG_ES)
--- a/demuxer.c Mon Apr 23 03:39:34 2001 +0000 +++ b/demuxer.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,53 +1,12 @@ //=================== DEMUXER v2.5 ========================= -#define MAX_PACKS 2048 -#define MAX_PACK_BYTES 0x400000 - -typedef struct demux_packet_st { - int len; - float pts; - int pos; // pozicio indexben (AVI) ill. fileban (MPG) - unsigned char* buffer; - struct demux_packet_st* next; -} demux_packet_t; - -inline demux_packet_t* new_demux_packet(int len){ - demux_packet_t* dp=malloc(sizeof(demux_packet_t)); - dp->len=len; - dp->buffer=malloc(len); - dp->next=NULL; - dp->pts=0; - dp->pos=0; - return dp; -} +#include <stdio.h> +#include <stdlib.h> -inline void free_demux_packet(demux_packet_t* dp){ - free(dp->buffer); - free(dp); -} +extern int verbose; // defined in mplayer.c -typedef struct { - int buffer_pos; // current buffer position - int buffer_size; // current buffer size - unsigned char* buffer; // current buffer - float pts; // current buffer's pts - int eof; // end of demuxed stream? (true if all buffer empty) - int pos; // position in the input stream (file) - int dpos; // position in the demuxed stream -//--------------- - int packs; // number of packets in buffer - int bytes; // total bytes of packets in buffer - demux_packet_t *first; // read to current buffer from here - demux_packet_t *last; // append new packets from input stream to here - int id; // stream ID (for multiple audio/video streams) - int type; // stream type (currently used only for audio) - struct demuxer_st *demuxer; // parent demuxer structure (stream handler) -// ---- asf ----- - demux_packet_t *asf_packet; // read asf fragments here - int asf_seq; -// ---- stream header ---- - void* sh; -} demux_stream_t; +#include "stream.h" +#include "demuxer.h" demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){ demux_stream_t* ds=malloc(sizeof(demux_stream_t)); @@ -72,33 +31,9 @@ return ds; } -#define DEMUXER_TYPE_UNKNOWN 0 -#define DEMUXER_TYPE_MPEG_ES 1 -#define DEMUXER_TYPE_MPEG_PS 2 -#define DEMUXER_TYPE_AVI 3 -#define DEMUXER_TYPE_AVI_NI 4 -#define DEMUXER_TYPE_AVI_NINI 5 -#define DEMUXER_TYPE_ASF 6 - -#define DEMUXER_TIME_NONE 0 -#define DEMUXER_TIME_PTS 1 -#define DEMUXER_TIME_FILE 2 -#define DEMUXER_TIME_BPS 3 - -typedef struct demuxer_st { - stream_t *stream; - int synced; // stream synced (used by mpeg) - int filepos; // input stream current pos. - int endpos; // input stream end pos. (return EOF fi filepos>endpos) - int type; // mpeg system stream, mpeg elementary s., avi raw, avi indexed -// int time_src;// time source (pts/file/bps) - demux_stream_t *audio; - demux_stream_t *video; - demux_stream_t *sub; -} demuxer_t; - demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){ demuxer_t *d=malloc(sizeof(demuxer_t)); + memset(d,0,sizeof(demuxer_t)); d->stream=stream; d->synced=0; d->filepos=0; @@ -109,7 +44,7 @@ return d; } -static void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp){ +void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp){ // demux_packet_t* dp=new_demux_packet(len); // stream_read(stream,dp->buffer,len); // dp->pts=pts; //(float)pts/90000.0f; @@ -131,7 +66,7 @@ dp->len,dp->pts,dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs); } -static void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,int pos){ +void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,int pos){ demux_packet_t* dp=new_demux_packet(len); stream_read(stream,dp->buffer,len); dp->pts=pts; //(float)pts/90000.0f; @@ -140,7 +75,6 @@ ds_add_packet(ds,dp); } - // return value: // 0 = EOF or no stream found or invalid type // 1 = successfully read a packet @@ -167,13 +101,13 @@ // return value: // 0 = EOF // 1 = succesfull -inline static int ds_fill_buffer(demux_stream_t *ds){ +int ds_fill_buffer(demux_stream_t *ds){ demuxer_t *demux=ds->demuxer; if(ds->buffer) free(ds->buffer); if(verbose>2){ if(ds==demux->audio) printf("ds_fill_buffer(d_audio) called\n");else if(ds==demux->video) printf("ds_fill_buffer(d_video) called\n");else - printf("ds_fill_buffer(unknown 0x%X) called\n",ds); + printf("ds_fill_buffer(unknown 0x%X) called\n",(unsigned int)ds); } while(1){ if(ds->packs){ @@ -212,11 +146,7 @@ return 0; } -inline int ds_tell(demux_stream_t *ds){ - return (ds->dpos-ds->buffer_size)+ds->buffer_pos; -} - -int demux_read_data(demux_stream_t *ds,char* mem,int len){ +int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len){ int x; int bytes=0; while(len>0){ @@ -232,24 +162,6 @@ return bytes; } - -#if 1 -#define demux_getc(ds) (\ - (ds->buffer_pos<ds->buffer_size) ? ds->buffer[ds->buffer_pos++] \ - :((!ds_fill_buffer(ds))? (-1) : ds->buffer[ds->buffer_pos++] ) ) -#else -inline static int demux_getc(demux_stream_t *ds){ - if(ds->buffer_pos>=ds->buffer_size){ - if(!ds_fill_buffer(ds)){ -// printf("DEMUX_GETC: EOF reached!\n"); - return -1; // EOF - } - } -// printf("[%02X]",ds->buffer[ds->buffer_pos]); - return ds->buffer[ds->buffer_pos++]; -} -#endif - void ds_free_packs(demux_stream_t *ds){ demux_packet_t *dp=ds->first; while(dp){ @@ -273,7 +185,7 @@ ds->pts=0; } -int ds_get_packet(demux_stream_t *ds,char **start){ +int ds_get_packet(demux_stream_t *ds,unsigned char **start){ while(1){ int len; if(ds->buffer_pos>=ds->buffer_size){ @@ -290,7 +202,7 @@ } } -int ds_get_packet_sub(demux_stream_t *ds,char **start){ +int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start){ while(1){ int len; if(ds->buffer_pos>=ds->buffer_size){
--- a/dll_init.c Mon Apr 23 03:39:34 2001 +0000 +++ b/dll_init.c Mon Apr 23 03:42:17 2001 +0000 @@ -1,3 +1,27 @@ + +#include <stdio.h> +#include <stdlib.h> + +#include "config.h" + +extern int verbose; // defined in mplayer.c + +#include "stream.h" +#include "demuxer.h" + +#include "loader.h" +//#include "wine/mmreg.h" +//#include "wine/vfw.h" +#include "wine/avifmt.h" + +#include "codec-cfg.h" +#include "stheader.h" + +#include "libvo/img_format.h" +#include "linux/shmem.h" + +extern char* win32_codec_name; // must be set before calling DrvOpen() !!! + // ACM audio and VfW video codecs initialization // based on the avifile library [http://divx.euro.ru] @@ -100,7 +124,7 @@ -int init_video_codec(){ +int init_video_codec(sh_video_t *sh_video){ HRESULT ret; int yuv=0; unsigned int outfmt=sh_video->codec->outfmt[sh_video->outfmtidx];
--- a/mplayer.c Mon Apr 23 03:39:34 2001 +0000 +++ b/mplayer.c Mon Apr 23 03:42:17 2001 +0000 @@ -3,12 +3,6 @@ // Enable ALSA emulation (using 32kB audio buffer) - timer testing only //#define SIMULATE_ALSA -#ifdef USE_XMMP_AUDIO -#define OUTBURST 4096 -#else -//#define OUTBURST 1024 -#define OUTBURST 512 -#endif #include <stdio.h> #include <stdlib.h> @@ -90,6 +84,11 @@ #define ABS(x) (((x)>=0)?(x):(-(x))) +static subtitle* subtitles=NULL; +void find_sub(subtitle* subtitles,int key); + + +#if 0 //**************************************************************************// // .SUB //**************************************************************************// @@ -185,6 +184,7 @@ vo_sub=NULL; // no sub here } +#endif //**************************************************************************// // Config file @@ -234,15 +234,17 @@ //**************************************************************************// #include "stream.h" -#include "demuxer.c" +#include "demuxer.h" #include "stheader.h" +#if 0 + typedef struct { // file: - MainAVIHeader avih; - unsigned int movi_start; - unsigned int movi_end; +// MainAVIHeader avih; +// unsigned int movi_start; +// unsigned int movi_end; // index: AVIINDEXENTRY* idx; int idx_size; @@ -250,45 +252,46 @@ int idx_pos_a; int idx_pos_v; int idx_offset; // ennyit kell hozzaadni az index offset ertekekhez - // streams: - sh_audio_t* a_streams[256]; - sh_video_t* v_streams[256]; - char s_streams[32]; // dvd subtitles // video: unsigned int bitrate; } avi_header_t; avi_header_t avi_header; -#include "aviprint.c" +#endif + +int avi_bitrate=0; + +demuxer_t *demuxer=NULL; + +//#include "aviprint.c" sh_audio_t* new_sh_audio(int id){ - if(avi_header.a_streams[id]){ + if(demuxer->a_streams[id]){ printf("Warning! Audio stream header %d redefined!\n",id); } else { printf("==> Found audio stream: %d\n",id); - avi_header.a_streams[id]=malloc(sizeof(sh_audio_t)); - memset(avi_header.a_streams[id],0,sizeof(sh_audio_t)); + demuxer->a_streams[id]=malloc(sizeof(sh_audio_t)); + memset(demuxer->a_streams[id],0,sizeof(sh_audio_t)); } - return avi_header.a_streams[id]; + return demuxer->a_streams[id]; } sh_video_t* new_sh_video(int id){ - if(avi_header.v_streams[id]){ + if(demuxer->v_streams[id]){ printf("Warning! video stream header %d redefined!\n",id); } else { printf("==> Found video stream: %d\n",id); - avi_header.v_streams[id]=malloc(sizeof(sh_video_t)); - memset(avi_header.v_streams[id],0,sizeof(sh_video_t)); + demuxer->v_streams[id]=malloc(sizeof(sh_video_t)); + memset(demuxer->v_streams[id],0,sizeof(sh_video_t)); } - return avi_header.v_streams[id]; + return demuxer->v_streams[id]; } -#include "demux_avi.c" -#include "demux_mpg.c" +//#include "demux_avi.c" +//#include "demux_mpg.c" -demuxer_t *demuxer=NULL; demux_stream_t *d_audio=NULL; demux_stream_t *d_video=NULL; demux_stream_t *d_dvdsub=NULL; @@ -300,9 +303,25 @@ char* encode_index_name=NULL; int encode_bitrate=0; +extern int asf_packetsize; + +extern float avi_audio_pts; +extern float avi_video_pts; +extern float avi_video_ftime; +extern int skip_video_frames; + +void read_avi_header(demuxer_t *demuxer,int index_mode); +demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id); + +int asf_check_header(demuxer_t *demuxer); +int read_asf_header(demuxer_t *demuxer); + // MPEG video stream parser: #include "parse_es.c" +extern int num_elementary_packets100; +extern int num_elementary_packets101; + extern picture_t *picture; static const int frameratecode2framerate[16] = { @@ -321,20 +340,8 @@ return len; } -// AC3 decoder buffer callback: -static void ac3_fill_buffer(uint8_t **start,uint8_t **end){ - int len=ds_get_packet(sh_audio->ds,(char**)start); - //printf("<ac3:%d>\n",len); - if(len<0) - *start = *end = NULL; - else - *end = *start + len; -} -#include "alaw.c" -#include "xa/xa_gsm.h" - -#include "dec_audio.c" +//#include "dec_audio.c" //**************************************************************************// // The OpenDivX stuff: @@ -386,15 +393,15 @@ //**************************************************************************// // AVI file header reader/parser/writer: -#include "aviheader.c" -#include "aviwrite.c" +//#include "aviheader.c" +//#include "aviwrite.c" // ASF headers: -#include "asfheader.c" -#include "demux_asf.c" +//#include "asfheader.c" +//#include "demux_asf.c" // DLL codecs init routines -#include "dll_init.c" +//#include "dll_init.c" // Common FIFO functions, and keyboard/event FIFO code #include "fifo.c" @@ -443,7 +450,6 @@ } int divx_quality=0; -extern int vo_dbpp; int main(int argc,char* argv[], char *envp[]){ char* filename=NULL; //"MI2-Trailer.avi"; @@ -610,7 +616,7 @@ if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; } vcd_read_toc(f); ret=vcd_seek_to_track(f,vcd_track); - if(ret==-1){ printf("Error selecting VCD track!\n");return 1;} + if(ret<0){ printf("Error selecting VCD track!\n");return 1;} seek_to_byte+=ret; if(verbose) printf("VCD start byte position: 0x%X\n",seek_to_byte); stream_type=STREAMTYPE_VCD; @@ -638,7 +644,6 @@ } stream=new_stream(f,stream_type); - //============ Open & Sync stream and detect file format =============== if(!has_audio) audio_id=-2; // do NOT read audio packets... @@ -647,6 +652,7 @@ stream_reset(stream); demuxer=new_demuxer(stream,DEMUXER_TYPE_AVI,audio_id,video_id,dvdsub_id); stream_seek(demuxer->stream,seek_to_byte); +//printf("stream3=0x%X vs. 0x%X\n",demuxer->stream,stream); { //---- RIFF header: int id=stream_read_dword_le(demuxer->stream); // "RIFF" if(id==mmioFOURCC('R','I','F','F')){ @@ -663,7 +669,7 @@ stream_reset(stream); demuxer=new_demuxer(stream,DEMUXER_TYPE_ASF,audio_id,video_id,dvdsub_id); stream_seek(demuxer->stream,seek_to_byte); - if(asf_check_header()){ + if(asf_check_header(demuxer)){ printf("Detected ASF file format!\n"); file_format=DEMUXER_TYPE_ASF; } @@ -722,31 +728,31 @@ switch(file_format){ case DEMUXER_TYPE_AVI: { //---- AVI header: - read_avi_header(index_mode); + read_avi_header(demuxer,index_mode); stream_reset(demuxer->stream); - stream_seek(demuxer->stream,avi_header.movi_start); - avi_header.idx_pos=0; - avi_header.idx_pos_a=0; - avi_header.idx_pos_v=0; - if(avi_header.idx_size>0){ + stream_seek(demuxer->stream,demuxer->movi_start); + demuxer->idx_pos=0; + demuxer->idx_pos_a=0; + demuxer->idx_pos_v=0; + if(demuxer->idx_size>0){ // decide index format: - if(avi_header.idx[0].dwChunkOffset<avi_header.movi_start) - avi_header.idx_offset=avi_header.movi_start-4; + if(((AVIINDEXENTRY *)demuxer->idx)[0].dwChunkOffset<demuxer->movi_start) + demuxer->idx_offset=demuxer->movi_start-4; else - avi_header.idx_offset=0; - if(verbose) printf("AVI index offset: %d\n",avi_header.idx_offset); + demuxer->idx_offset=0; + if(verbose) printf("AVI index offset: %d\n",demuxer->idx_offset); } - demuxer->endpos=avi_header.movi_end; +// demuxer->endpos=avi_header.movi_end; - if(avi_header.idx_size>0){ + if(demuxer->idx_size>0){ // check that file is non-interleaved: int i; int a_pos=-1; int v_pos=-1; - for(i=0;i<avi_header.idx_size;i++){ - AVIINDEXENTRY* idx=&avi_header.idx[i]; + for(i=0;i<demuxer->idx_size;i++){ + AVIINDEXENTRY* idx=&((AVIINDEXENTRY *)demuxer->idx)[i]; demux_stream_t* ds=demux_avi_select_stream(demuxer,idx->ckid); - int pos=idx->dwChunkOffset+avi_header.idx_offset; + int pos=idx->dwChunkOffset+demuxer->idx_offset; if(a_pos==-1 && ds==demuxer->audio){ a_pos=pos; if(v_pos!=-1) break; @@ -775,8 +781,8 @@ if(force_ni){ printf("Using NON-INTERLEAVED Broken AVI file-format!\n"); demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!! - avi_header.idx_pos_a= - avi_header.idx_pos_v=avi_header.movi_start; + demuxer->idx_pos_a= + demuxer->idx_pos_v=demuxer->movi_start; pts_from_bps=1; // force BPS sync! } } @@ -800,27 +806,27 @@ sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; // calculating video bitrate: - avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8; - if(sh_audio) avi_header.bitrate-=sh_audio->audio.dwLength; - if(verbose) printf("AVI video length=%d\n",avi_header.bitrate); - avi_header.bitrate=((float)avi_header.bitrate/(float)sh_video->video.dwLength)*sh_video->fps; + avi_bitrate=demuxer->movi_end-demuxer->movi_start-demuxer->idx_size*8; + if(sh_audio) avi_bitrate-=sh_audio->audio.dwLength; + if(verbose) printf("AVI video length=%d\n",avi_bitrate); + avi_bitrate=((float)avi_bitrate/(float)sh_video->video.dwLength)*sh_video->fps; printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", &sh_video->bih->biCompression, sh_video->bih->biWidth, sh_video->bih->biHeight, sh_video->bih->biBitCount, sh_video->fps, - avi_header.bitrate*0.008f, - avi_header.bitrate/1024.0f ); + avi_bitrate*0.008f, + avi_bitrate/1024.0f ); break; } case DEMUXER_TYPE_ASF: { //---- ASF header: - read_asf_header(); + read_asf_header(demuxer); stream_reset(demuxer->stream); - stream_seek(demuxer->stream,avi_header.movi_start); - avi_header.idx_pos=0; - demuxer->endpos=avi_header.movi_end; + stream_seek(demuxer->stream,demuxer->movi_start); + demuxer->idx_pos=0; +// demuxer->endpos=avi_header.movi_end; if(!ds_fill_buffer(d_video)){ printf("ASF: missing video stream!? contact the author, it may be a bug :(\n"); exit(1); @@ -948,7 +954,7 @@ f=fopen(stream_dump_name?stream_dump_name:"stream.dump","wb"); if(!f){ printf("Can't open dump file!!!\n");exit(1); } while(!ds->eof){ - char* start; + unsigned char* start; int in_size=ds_get_packet(ds,&start); if(in_size>0) fwrite(start,in_size,1,f); } @@ -1011,7 +1017,7 @@ switch(sh_video->codec->driver){ case 2: { - if(!init_video_codec(out_fmt)) exit(1); + if(!init_video_codec(sh_video)) exit(1); if(verbose) printf("INFO: Win32 video codec init OK!\n"); break; } @@ -1439,7 +1445,7 @@ unsigned int t=GetTimer(); unsigned int t2; DEC_FRAME dec_frame; - char* start=NULL; + unsigned char* start=NULL; int in_size=ds_get_packet(d_video,&start); if(in_size<0){ eof=1;break;} if(in_size>max_framesize) max_framesize=in_size; @@ -1461,7 +1467,7 @@ } #ifdef USE_DIRECTSHOW case 4: { // W32/DirectShow - char* start=NULL; + unsigned char* start=NULL; unsigned int t=GetTimer(); unsigned int t2; int in_size=ds_get_packet(d_video,&start); @@ -1489,7 +1495,7 @@ #endif case 2: { HRESULT ret; - char* start=NULL; + unsigned char* start=NULL; unsigned int t=GetTimer(); unsigned int t2; int in_size=ds_get_packet(d_video,&start); @@ -1762,8 +1768,8 @@ break; } if(rel_seek_secs) - if(file_format==DEMUXER_TYPE_AVI && avi_header.idx_size<=0){ - printf("Can't seek in raw .AVI streams! (index required) \n"); + if(file_format==DEMUXER_TYPE_AVI && demuxer->idx_size<=0){ + printf("Can't seek in raw .AVI streams! (index required, try with the -idx switch!) \n"); } else { int skip_audio_bytes=0; float skip_audio_secs=0; @@ -1795,11 +1801,11 @@ // find video chunk pos: if(rel_seek_frames>0){ // seek forward - while(video_chunk_pos<avi_header.idx_size){ - int id=avi_header.idx[video_chunk_pos].ckid; + while(video_chunk_pos<demuxer->idx_size){ + int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid; // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame if(avi_stream_id(id)==d_video->id){ // video frame - if((--rel_seek_frames)<0 && avi_header.idx[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; + if((--rel_seek_frames)<0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; v_pts+=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; ++skip_audio_bytes; } @@ -1808,25 +1814,25 @@ } else { // seek backward while(video_chunk_pos>=0){ - int id=avi_header.idx[video_chunk_pos].ckid; + int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid; // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame if(avi_stream_id(id)==d_video->id){ // video frame - if((++rel_seek_frames)>0 && avi_header.idx[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; + if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; v_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; --skip_audio_bytes; } --video_chunk_pos; } } - avi_header.idx_pos_a=avi_header.idx_pos_v= - avi_header.idx_pos=video_chunk_pos; + demuxer->idx_pos_a=demuxer->idx_pos_v= + demuxer->idx_pos=video_chunk_pos; // printf("%d frames skipped\n",skip_audio_bytes); #if 1 // re-calc video pts: avi_video_pts=0; for(i=0;i<video_chunk_pos;i++){ - int id=avi_header.idx[i].ckid; + int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame if(avi_stream_id(id)==d_video->id){ // video frame avi_video_pts+=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; @@ -1854,17 +1860,17 @@ #else curr_audio_pos/=sh_audio->wf->nBlockAlign; curr_audio_pos*=sh_audio->wf->nBlockAlign; - avi_header.audio_seekable=1; + demuxer->audio_seekable=1; #endif // find audio chunk pos: for(i=0;i<video_chunk_pos;i++){ - int id=avi_header.idx[i].ckid; + int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; //if(TWOCCFromFOURCC(id)==cktypeWAVEbytes){ if(avi_stream_id(id)==d_audio->id){ int aid=StreamFromFOURCC(id); if(d_audio->id==aid || d_audio->id==-1){ - len=avi_header.idx[i].dwChunkLength; + len=((AVIINDEXENTRY *)demuxer->idx)[i].dwChunkLength; last=i; if(apos<=curr_audio_pos && curr_audio_pos<(apos+len)){ if(verbose)printf("break;\n"); @@ -1883,8 +1889,8 @@ // update stream position: d_audio->pos=audio_chunk_pos; d_audio->dpos=apos; - avi_header.idx_pos_a=avi_header.idx_pos_v= - avi_header.idx_pos=audio_chunk_pos; + demuxer->idx_pos_a=demuxer->idx_pos_v= + demuxer->idx_pos=audio_chunk_pos; if(!(sh_audio->codec->flags&CODECS_FLAG_SEEKABLE)){ #if 0 @@ -1906,9 +1912,9 @@ // calc skip_video_frames & adjust video pts counter: // i=last; - i=avi_header.idx_pos; + i=demuxer->idx_pos; while(i<video_chunk_pos){ - int id=avi_header.idx[i].ckid; + int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame if(avi_stream_id(id)==d_video->id){ // video frame ++skip_video_frames; @@ -1921,16 +1927,16 @@ } if(verbose) printf("SEEK: idx=%d (a:%d v:%d) v.skip=%d a.skip=%d/%4.3f \n", - avi_header.idx_pos,audio_chunk_pos,video_chunk_pos, + demuxer->idx_pos,audio_chunk_pos,video_chunk_pos, skip_video_frames,skip_audio_bytes,skip_audio_secs); // Set OSD: if(osd_level){ osd_visible=sh_video->fps; // 1 sec vo_osd_progbar_type=0; - vo_osd_progbar_value=(demuxer->filepos)/((avi_header.movi_end-avi_header.movi_start)>>8); + vo_osd_progbar_value=(demuxer->filepos)/((demuxer->movi_end-demuxer->movi_start)>>8); //printf("avi filepos = %d \n",vo_osd_progbar_value); - // printf("avi filepos = %d (len=%d) \n",demuxer->filepos,(avi_header.movi_end-avi_header.movi_start)); + // printf("avi filepos = %d (len=%d) \n",demuxer->filepos,(demuxer->movi_end-demuxer->movi_start)); } } @@ -1940,7 +1946,7 @@ //================= seek in ASF ========================== float p_rate=10; // packets / sec int rel_seek_packs=rel_seek_secs*p_rate; - int rel_seek_bytes=rel_seek_packs*fileh.packetsize; + int rel_seek_bytes=rel_seek_packs*asf_packetsize; int newpos; //printf("ASF: packs: %d duration: %d \n",(int)fileh.packets,*((int*)&fileh.duration)); // printf("ASF_seek: %d secs -> %d packs -> %d bytes \n", @@ -2057,7 +2063,7 @@ if(subtitles){ if(sub_fps==0) sub_fps=sh_video->fps; current_module="find_sub"; - find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter... + find_sub(subtitles,sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter... current_module=NULL; }
--- a/stheader.h Mon Apr 23 03:39:34 2001 +0000 +++ b/stheader.h Mon Apr 23 03:42:17 2001 +0000 @@ -33,7 +33,8 @@ int audio_in_minsize; int audio_out_minsize; // other codecs: - ac3_frame_t *ac3_frame; +// ac3_frame_t *ac3_frame; + void* ac3_frame; int pcm_bswap; } sh_audio_t; @@ -57,4 +58,6 @@ HIC hic; // handle } sh_video_t; +sh_audio_t* new_sh_audio(int id); +sh_video_t* new_sh_video(int id);
--- a/vcd_read.h Mon Apr 23 03:39:34 2001 +0000 +++ b/vcd_read.h Mon Apr 23 03:42:17 2001 +0000 @@ -1,7 +1,7 @@ //=================== VideoCD ========================== static struct cdrom_tocentry vcd_entry; -void vcd_set_msf(unsigned int sect){ +static inline void vcd_set_msf(unsigned int sect){ vcd_entry.cdte_addr.msf.frame=sect%75; sect=sect/75; vcd_entry.cdte_addr.msf.second=sect%60; @@ -9,7 +9,7 @@ vcd_entry.cdte_addr.msf.minute=sect; } -unsigned int vcd_get_msf(){ +static inline unsigned int vcd_get_msf(){ return vcd_entry.cdte_addr.msf.frame + (vcd_entry.cdte_addr.msf.second+ vcd_entry.cdte_addr.msf.minute*60)*75; @@ -20,9 +20,9 @@ vcd_entry.cdte_track = track; if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) { perror("ioctl dif1"); - return 0; + return -1; } - return 1; + return VCD_SECTOR_DATA*vcd_get_msf(); } void vcd_read_toc(int fd){ @@ -52,12 +52,9 @@ } } -#define VCD_SECTOR_SIZE 2352 -#define VCD_SECTOR_OFFS 24 -#define VCD_SECTOR_DATA 2324 static char vcd_buf[VCD_SECTOR_SIZE]; -int vcd_read(int fd,char *mem){ +static int vcd_read(int fd,char *mem){ memcpy(vcd_buf,&vcd_entry.cdte_addr.msf,sizeof(struct cdrom_msf)); if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; // EOF? @@ -91,7 +88,7 @@ memset(vcd_cache_sectors,255,s*sizeof(int)); } -void vcd_cache_seek(int sect){ +static inline void vcd_cache_seek(int sect){ vcd_cache_current=sect; }