[Mplayer-cvslog] CVS: main dec_audio.c,NONE,1.1 stheader.h,NONE,1.1 asfheader.c,1.2,1.3 aviheader.c,1.1.1.1,1.2 codecs.c,1.9,1.10 demux_avi.c,1.2,1.3 demuxer.c,1.1.1.1,1.2 dll_init.c,1.2,1.3 mplayer.c,1.35,1.36
GEREOFFY
arpi_esp at users.sourceforge.net
Fri Apr 6 03:19:01 CEST 2001
Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv10949
Modified Files:
asfheader.c aviheader.c codecs.c demux_avi.c demuxer.c
dll_init.c mplayer.c
Added Files:
dec_audio.c stheader.h
Log Message:
sh_audio/sh_video added, general codec cleanup
--- NEW FILE ---
// Audio decoding
int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int maxlen){
int len=-1;
switch(sh_audio->codec.driver){
case 1: // MPEG layer 2 or 3
len=MP3_DecodeFrame(buf,-1);
MP3_channels=2; // hack
break;
case 2: // PCM
{ len=demux_read_data(sh_audio->ds,buf,OUTBURST);
if(sh_audio->pcm_bswap){
int j;
//if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; }
for(j=0;j<len;j+=2){
char x=buf[j];
buf[j]=buf[j+1];
buf[j+1]=x;
}
}
break;
}
case 5: // aLaw decoder
{ int l=demux_read_data(sh_audio->ds,buf,OUTBURST/2);
unsigned short *d=(unsigned short *) buf;
unsigned char *s=buf;
len=2*l;
while(l>0){
--l;
d[l]=xa_alaw_2_sign[s[l]];
}
break;
}
case 6: // MS-GSM decoder
{ unsigned char buf[65]; // 65 bytes / frame
len=0;
while(len<OUTBURST){
if(demux_read_data(d_audio,buf,65)!=65) break; // EOF
XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short
// XA_GSM_Decoder(buf,(unsigned short *) &a_buffer[a_buffer_len]); // decodes 33 byte -> 160 short
len+=2*320;
}
break;
}
case 3: // AC3 decoder
//printf("{1:%d}",avi_header.idx_pos);fflush(stdout);
if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame();
//printf("{2:%d}",avi_header.idx_pos);fflush(stdout);
if(sh_audio->ac3_frame){
len = 256 * 6 *MP3_channels*MP3_bps;
memcpy(buf,sh_audio->ac3_frame->audio_data,len);
sh_audio->ac3_frame=NULL;
}
//printf("{3:%d}",avi_header.idx_pos);fflush(stdout);
break;
case 4:
{ len=acm_decode_audio(sh_audio,buf,maxlen);
break;
}
#ifdef USE_DIRECTSHOW
case 7: // DirectShow
{ int ret;
int size_in=0;
int size_out=0;
int srcsize=DS_AudioDecoder_GetSrcSize(maxlen);
if(verbose>2)printf("DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
if(sh_audio->a_in_buffer_len<srcsize){
sh_audio->a_in_buffer_len+=
demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
srcsize-sh_audio->a_in_buffer_len);
}
DS_AudioDecoder_Convert(sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
buf,maxlen, &size_in,&size_out);
if(verbose>2)printf("DShow: audio %d -> %d converted (in_buf_len=%d of %d)\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size);
if(size_in>=sh_audio->a_in_buffer_len){
sh_audio->a_in_buffer_len=0;
} else {
sh_audio->a_in_buffer_len-=size_in;
memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
}
len=size_out;
break;
}
#endif
}
return len;
}
--- NEW FILE ---
// Stream headers:
typedef struct {
int driver;
// codec descriptor from codec.conf
} codecinfo_t;
typedef struct {
demux_stream_t *ds;
codecinfo_t codec;
// output format:
int samplerate;
int samplesize;
int channels;
int o_bps; // == samplerate*samplesize*channels
// buffers:
char* a_in_buffer;
int a_in_buffer_len;
int a_in_buffer_size;
// win32 codec stuff:
AVIStreamHeader audio;
WAVEFORMATEX wf;
char wf_ext[64]; // in format
WAVEFORMATEX o_wf; // out format
HACMSTREAM srcstream; // handle
int audio_in_minsize;
int audio_out_minsize;
// other codecs:
ac3_frame_t *ac3_frame;
int pcm_bswap;
} sh_audio_t;
typedef struct {
demux_stream_t *ds;
codecinfo_t codec;
// output format:
float fps;
float frametime; // 1/fps
unsigned int outfmt;
// unsigned int bitrate;
// buffers:
char *our_out_buffer;
// win32 codec stuff:
AVIStreamHeader video;
BITMAPINFOHEADER bih; // in format
BITMAPINFOHEADER o_bih; // out format
HIC hic; // handle
} sh_video_t;
Index: asfheader.c
===================================================================
RCS file: /cvsroot/mplayer/main/asfheader.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** asfheader.c 2001/03/15 19:38:34 1.2
--- asfheader.c 2001/04/06 01:18:59 1.3
***************
*** 126,131 ****
stream_read(demuxer->stream,(char*) buffer,streamh.type_size);
switch(*((unsigned int*)&streamh.type)){
! case 0xF8699E40: // guid_audio_stream
! memcpy(avi_header.wf_ext,buffer,streamh.type_size<64?streamh.type_size:64);
if(verbose>=1) print_wave_header((WAVEFORMATEX*)buffer);
if((*((unsigned int*)&streamh.concealment))==0xbfc3cd50){
--- 126,132 ----
stream_read(demuxer->stream,(char*) buffer,streamh.type_size);
switch(*((unsigned int*)&streamh.type)){
! case 0xF8699E40: { // guid_audio_stream
! sh_audio_t *sh_audio=&sh_audio_i; // FIXME!
! memcpy(&sh_audio->wf,buffer,streamh.type_size<64?streamh.type_size:64);
if(verbose>=1) print_wave_header((WAVEFORMATEX*)buffer);
if((*((unsigned int*)&streamh.concealment))==0xbfc3cd50){
***************
*** 141,150 ****
if(demuxer->audio->id==-1) demuxer->audio->id=streamh.stream_no & 0x7F;
break;
! case 0xBC19EFC0: // guid_video_stream
! memcpy(&avi_header.bih,&buffer[4+4+1+2],sizeof(BITMAPINFOHEADER));
if(verbose>=1) print_video_header((BITMAPINFOHEADER*)&buffer[4+4+1+2]);
//asf_video_id=streamh.stream_no & 0x7F;
! if(demuxer->video->id==-1) demuxer->video->id=streamh.stream_no & 0x7F;
break;
}
// stream-specific data:
--- 142,156 ----
if(demuxer->audio->id==-1) demuxer->audio->id=streamh.stream_no & 0x7F;
break;
! }
! case 0xBC19EFC0: { // guid_video_stream
! sh_video_t *sh_video=&sh_video_i; // FIXME!
! memcpy(&sh_video->bih,&buffer[4+4+1+2],sizeof(BITMAPINFOHEADER));
! 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;
if(verbose>=1) print_video_header((BITMAPINFOHEADER*)&buffer[4+4+1+2]);
//asf_video_id=streamh.stream_no & 0x7F;
! if(demuxer->video->id==-1) demuxer->video->id=streamh.stream_no & 0x7F;
break;
+ }
}
// stream-specific data:
Index: aviheader.c
===================================================================
RCS file: /cvsroot/mplayer/main/aviheader.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** aviheader.c 2001/02/24 20:28:23 1.1.1.1
--- aviheader.c 2001/04/06 01:18:59 1.2
***************
*** 42,47 ****
stream_read(demuxer->stream,(char*) &h,MIN(size2,sizeof(h)));
chunksize-=MIN(size2,sizeof(h));
! if(h.fccType==streamtypeVIDEO) memcpy(&avi_header.video,&h,sizeof(h));else
! if(h.fccType==streamtypeAUDIO) memcpy(&avi_header.audio,&h,sizeof(h));
last_fccType=h.fccType;
if(verbose>=1) print_strh(&h);
--- 42,47 ----
stream_read(demuxer->stream,(char*) &h,MIN(size2,sizeof(h)));
chunksize-=MIN(size2,sizeof(h));
! if(h.fccType==streamtypeVIDEO) memcpy(&sh_video_i.video,&h,sizeof(h));else
! if(h.fccType==streamtypeAUDIO) memcpy(&sh_audio_i.audio,&h,sizeof(h));
last_fccType=h.fccType;
if(verbose>=1) print_strh(&h);
***************
*** 50,67 ****
case ckidSTREAMFORMAT: { // read 'strf'
if(last_fccType==streamtypeVIDEO){
! stream_read(demuxer->stream,(char*) &avi_header.bih,MIN(size2,sizeof(avi_header.bih)));
! chunksize-=MIN(size2,sizeof(avi_header.bih));
! // init_video_codec();
! // init_video_out();
if(demuxer->video->id==-1) demuxer->video->id=stream_id;
} else
if(last_fccType==streamtypeAUDIO){
int z=(chunksize<64)?chunksize:64;
if(verbose>=2) printf("found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX));
! stream_read(demuxer->stream,(char*) &avi_header.wf_ext,z);
chunksize-=z;
! if(verbose>=1) print_wave_header((WAVEFORMATEX*)&avi_header.wf_ext);
! // init_audio_codec();
! // init_audio_out();
if(demuxer->audio->id==-1) demuxer->audio->id=stream_id;
}
--- 50,67 ----
case ckidSTREAMFORMAT: { // read 'strf'
if(last_fccType==streamtypeVIDEO){
! sh_video_t *sh_video=&sh_video_i; // FIXME!
! stream_read(demuxer->stream,(char*) &sh_video->bih,MIN(size2,sizeof(sh_video->bih)));
! chunksize-=MIN(size2,sizeof(sh_video->bih));
! 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;
if(demuxer->video->id==-1) demuxer->video->id=stream_id;
} else
if(last_fccType==streamtypeAUDIO){
+ sh_audio_t *sh_audio=&sh_audio_i; // FIXME!
int z=(chunksize<64)?chunksize:64;
if(verbose>=2) printf("found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX));
! stream_read(demuxer->stream,(char*) &sh_audio->wf,z);
chunksize-=z;
! if(verbose>=1) print_wave_header(&sh_audio->wf);
if(demuxer->audio->id==-1) demuxer->audio->id=stream_id;
}
Index: codecs.c
===================================================================
RCS file: /cvsroot/mplayer/main/codecs.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** codecs.c 2001/04/01 19:42:41 1.9
--- codecs.c 2001/04/06 01:18:59 1.10
***************
*** 22,28 ****
! char* get_vids_codec_name(){
// unsigned long fccHandler=avi_header.video.fccHandler;
! unsigned long fccHandler=avi_header.bih.biCompression;
avi_header.yuv_supported=0;
avi_header.yuv_hack_needed=0;
--- 22,28 ----
! char* get_vids_codec_name(sh_video_t *sh){
// unsigned long fccHandler=avi_header.video.fccHandler;
! unsigned long fccHandler=sh->bih.biCompression;
avi_header.yuv_supported=0;
avi_header.yuv_hack_needed=0;
***************
*** 48,52 ****
case mmioFOURCC('m', 'p', '4', '3'):
printf("Video in MPEG-4 v3 (really DivX) format\n");
! avi_header.bih.biCompression=mmioFOURCC('d', 'i', 'v', '3'); // hack
avi_header.yuv_supported=1;
#ifdef USE_DIRECTSHOW
--- 48,52 ----
case mmioFOURCC('m', 'p', '4', '3'):
printf("Video in MPEG-4 v3 (really DivX) format\n");
! sh->bih.biCompression=mmioFOURCC('d', 'i', 'v', '3'); // hack
avi_header.yuv_supported=1;
#ifdef USE_DIRECTSHOW
***************
*** 70,74 ****
case mmioFOURCC('D', 'I', 'V', '6'):
case mmioFOURCC('d', 'i', 'v', '6'):
! avi_header.bih.biCompression-=0x02000000; // div5->div3, div6->div4
case mmioFOURCC('D', 'I', 'V', '3'):
case mmioFOURCC('d', 'i', 'v', '3'):
--- 70,74 ----
case mmioFOURCC('D', 'I', 'V', '6'):
case mmioFOURCC('d', 'i', 'v', '6'):
! sh->bih.biCompression-=0x02000000; // div5->div3, div6->div4
case mmioFOURCC('D', 'I', 'V', '3'):
case mmioFOURCC('d', 'i', 'v', '3'):
***************
*** 196,201 ****
}
! char* get_auds_codec_name(){
! int id=((WAVEFORMATEX*)avi_header.wf_ext)->wFormatTag;
avi_header.auds_guid=NULL;
switch (id){
--- 196,201 ----
}
! char* get_auds_codec_name(sh_audio_t *sh){
! int id=sh->wf.wFormatTag;
avi_header.auds_guid=NULL;
switch (id){
Index: demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_avi.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** demux_avi.c 2001/03/15 19:38:34 1.2
--- demux_avi.c 2001/04/06 01:18:59 1.3
***************
*** 49,53 ****
// ezt a 2 sort lehet hogy fell kell majd cserelni:
//avi_video_pts+=avi_pts_frametime;
! avi_video_pts+=(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
avi_audio_pts=avi_video_pts;
}
--- 49,55 ----
// ezt a 2 sort lehet hogy fell kell majd cserelni:
//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;
! avi_video_pts+=(float)((sh_video_t*)(demux->video->sh))->video.dwScale/(float)((sh_video_t*)(demux->video->sh))->video.dwRate;
avi_audio_pts=avi_video_pts;
}
Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/demuxer.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** demuxer.c 2001/02/24 20:28:35 1.1.1.1
--- demuxer.c 2001/04/06 01:18:59 1.2
***************
*** 46,49 ****
--- 46,51 ----
demux_packet_t *asf_packet; // read asf fragments here
int asf_seq;
+ // ---- stream header ----
+ void* sh;
} demux_stream_t;
***************
*** 66,69 ****
--- 68,73 ----
ds->asf_seq=-1;
ds->asf_packet=NULL;
+ //----------------
+ ds->sh=NULL;
return ds;
}
Index: dll_init.c
===================================================================
RCS file: /cvsroot/mplayer/main/dll_init.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** dll_init.c 2001/03/12 01:09:35 1.2
--- dll_init.c 2001/04/06 01:18:59 1.3
***************
*** 2,32 ****
// based on the avifile library [http://divx.euro.ru]
! static char* a_in_buffer=NULL;
! static int a_in_buffer_len=0;
! static int a_in_buffer_size=0;
!
! int init_audio_codec(){
HRESULT ret;
! WAVEFORMATEX *in_fmt=(WAVEFORMATEX*)&avi_header.wf_ext;
unsigned long srcsize=0;
if(verbose) printf("======= Win32 (ACM) AUDIO Codec init =======\n");
! avi_header.srcstream=NULL;
// if(in_fmt->nSamplesPerSec==0){ printf("Bad WAVE header!\n");exit(1); }
// MSACM_RegisterAllDrivers();
! avi_header.wf.nChannels=in_fmt->nChannels;
! avi_header.wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
! avi_header.wf.nAvgBytesPerSec=2*avi_header.wf.nSamplesPerSec*avi_header.wf.nChannels;
! avi_header.wf.wFormatTag=WAVE_FORMAT_PCM;
! avi_header.wf.nBlockAlign=2*in_fmt->nChannels;
! avi_header.wf.wBitsPerSample=16;
! avi_header.wf.cbSize=0;
win32_codec_name = avi_header.audio_codec;
! ret=acmStreamOpen(&avi_header.srcstream,(HACMDRIVER)NULL,
! in_fmt,&avi_header.wf,
NULL,0,0,0);
if(ret){
--- 2,28 ----
// based on the avifile library [http://divx.euro.ru]
! int init_audio_codec(sh_audio_t *sh_audio){
HRESULT ret;
! WAVEFORMATEX *in_fmt=&sh_audio->wf;
unsigned long srcsize=0;
if(verbose) printf("======= Win32 (ACM) AUDIO Codec init =======\n");
! sh_audio->srcstream=NULL;
// if(in_fmt->nSamplesPerSec==0){ printf("Bad WAVE header!\n");exit(1); }
// MSACM_RegisterAllDrivers();
! sh_audio->o_wf.nChannels=in_fmt->nChannels;
! sh_audio->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
! sh_audio->o_wf.nAvgBytesPerSec=2*sh_audio->o_wf.nSamplesPerSec*sh_audio->o_wf.nChannels;
! sh_audio->o_wf.wFormatTag=WAVE_FORMAT_PCM;
! sh_audio->o_wf.nBlockAlign=2*in_fmt->nChannels;
! sh_audio->o_wf.wBitsPerSample=16;
! sh_audio->o_wf.cbSize=0;
win32_codec_name = avi_header.audio_codec;
! ret=acmStreamOpen(&sh_audio->srcstream,(HACMDRIVER)NULL,
! in_fmt,&sh_audio->o_wf,
NULL,0,0,0);
if(ret){
***************
*** 35,39 ****
else
printf("ACM_Decoder: acmStreamOpen error %d", ret);
! avi_header.srcstream=NULL;
return 0;
}
--- 31,35 ----
else
printf("ACM_Decoder: acmStreamOpen error %d", ret);
! sh_audio->srcstream=NULL;
return 0;
}
***************
*** 41,72 ****
srcsize=in_fmt->nBlockAlign;
! acmStreamSize(avi_header.srcstream, srcsize, &srcsize, ACM_STREAMSIZEF_SOURCE);
if(srcsize<OUTBURST) srcsize=OUTBURST;
! avi_header.audio_out_minsize=srcsize; // audio output min. size
if(verbose) printf("Audio ACM output buffer min. size: %d\n",srcsize);
! acmStreamSize(avi_header.srcstream, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION);
! avi_header.audio_in_minsize=srcsize; // audio input min. size
if(verbose) printf("Audio ACM input buffer min. size: %d\n",srcsize);
! a_in_buffer_size=avi_header.audio_in_minsize;
! a_in_buffer=malloc(a_in_buffer_size);
! a_in_buffer_len=0;
return 1;
}
! int acm_decode_audio(void* a_buffer,int len){
ACMSTREAMHEADER ash;
HRESULT hr;
DWORD srcsize=0;
! acmStreamSize(avi_header.srcstream,len , &srcsize, ACM_STREAMSIZEF_DESTINATION);
! if(verbose>=3)printf("acm says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,a_in_buffer_size,len);
! // if(srcsize==0) srcsize=((WAVEFORMATEX *)&avi_header.wf_ext)->nBlockAlign;
! if(srcsize>a_in_buffer_size) srcsize=a_in_buffer_size; // !!!!!!
! if(a_in_buffer_len<srcsize){
! a_in_buffer_len+=
! demux_read_data(d_audio,&a_in_buffer[a_in_buffer_len],
! srcsize-a_in_buffer_len);
}
memset(&ash, 0, sizeof(ash));
--- 37,68 ----
srcsize=in_fmt->nBlockAlign;
! acmStreamSize(sh_audio->srcstream, srcsize, &srcsize, ACM_STREAMSIZEF_SOURCE);
if(srcsize<OUTBURST) srcsize=OUTBURST;
! sh_audio->audio_out_minsize=srcsize; // audio output min. size
if(verbose) printf("Audio ACM output buffer min. size: %d\n",srcsize);
! acmStreamSize(sh_audio->srcstream, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION);
! sh_audio->audio_in_minsize=srcsize; // audio input min. size
if(verbose) printf("Audio ACM input buffer min. size: %d\n",srcsize);
! sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize;
! sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
! sh_audio->a_in_buffer_len=0;
return 1;
}
! int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int len){
ACMSTREAMHEADER ash;
HRESULT hr;
DWORD srcsize=0;
! acmStreamSize(sh_audio->srcstream,len , &srcsize, ACM_STREAMSIZEF_DESTINATION);
! if(verbose>=3)printf("acm says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,len);
! // if(srcsize==0) srcsize=((WAVEFORMATEX *)&sh_audio->o_wf_ext)->nBlockAlign;
! if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
! if(sh_audio->a_in_buffer_len<srcsize){
! sh_audio->a_in_buffer_len+=
! demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
! srcsize-sh_audio->a_in_buffer_len);
}
memset(&ash, 0, sizeof(ash));
***************
*** 74,87 ****
ash.fdwStatus=0;
ash.dwUser=0;
! ash.pbSrc=a_in_buffer;
! ash.cbSrcLength=a_in_buffer_len;
ash.pbDst=a_buffer;
ash.cbDstLength=len;
! hr=acmStreamPrepareHeader(avi_header.srcstream,&ash,0);
if(hr){
printf("ACM_Decoder: acmStreamPrepareHeader error %d\n",hr);
return -1;
}
! hr=acmStreamConvert(avi_header.srcstream,&ash,0);
if(hr){
printf("ACM_Decoder: acmStreamConvert error %d\n",hr);
--- 70,83 ----
ash.fdwStatus=0;
ash.dwUser=0;
! ash.pbSrc=sh_audio->a_in_buffer;
! ash.cbSrcLength=sh_audio->a_in_buffer_len;
ash.pbDst=a_buffer;
ash.cbDstLength=len;
! hr=acmStreamPrepareHeader(sh_audio->srcstream,&ash,0);
if(hr){
printf("ACM_Decoder: acmStreamPrepareHeader error %d\n",hr);
return -1;
}
! hr=acmStreamConvert(sh_audio->srcstream,&ash,0);
if(hr){
printf("ACM_Decoder: acmStreamConvert error %d\n",hr);
***************
*** 89,100 ****
}
//printf("ACM convert %d -> %d (buf=%d)\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed,a_in_buffer_len);
! if(ash.cbSrcLengthUsed>=a_in_buffer_len){
! a_in_buffer_len=0;
} else {
! a_in_buffer_len-=ash.cbSrcLengthUsed;
! memcpy(a_in_buffer,&a_in_buffer[ash.cbSrcLengthUsed],a_in_buffer_len);
}
len=ash.cbDstLengthUsed;
! hr=acmStreamUnprepareHeader(avi_header.srcstream,&ash,0);
if(hr){
printf("ACM_Decoder: acmStreamUnprepareHeader error %d\n",hr);
--- 85,96 ----
}
//printf("ACM convert %d -> %d (buf=%d)\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed,a_in_buffer_len);
! if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){
! sh_audio->a_in_buffer_len=0;
} else {
! sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed;
! memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[ash.cbSrcLengthUsed],sh_audio->a_in_buffer_len);
}
len=ash.cbDstLengthUsed;
! hr=acmStreamUnprepareHeader(sh_audio->srcstream,&ash,0);
if(hr){
printf("ACM_Decoder: acmStreamUnprepareHeader error %d\n",hr);
***************
*** 110,127 ****
if(verbose) printf("======= Win32 (VFW) VIDEO Codec init =======\n");
! memset(&avi_header.o_bih, 0, sizeof(BITMAPINFOHEADER));
! avi_header.o_bih.biSize = sizeof(BITMAPINFOHEADER);
win32_codec_name = avi_header.video_codec;
! avi_header.hic = ICOpen( 0x63646976, avi_header.bih.biCompression, ICMODE_FASTDECOMPRESS);
! // avi_header.hic = ICOpen( 0x63646976, avi_header.bih.biCompression, ICMODE_DECOMPRESS);
! if(!avi_header.hic){
printf("ICOpen failed! unknown codec / wrong parameters?\n");
return 0;
}
! // avi_header.bih.biBitCount=32;
! ret = ICDecompressGetFormat(avi_header.hic, &avi_header.bih, &avi_header.o_bih);
if(ret){
printf("ICDecompressGetFormat failed: Error %d\n", ret);
--- 106,123 ----
if(verbose) printf("======= Win32 (VFW) VIDEO Codec init =======\n");
! memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
! sh_video->o_bih.biSize = sizeof(BITMAPINFOHEADER);
win32_codec_name = avi_header.video_codec;
! sh_video->hic = ICOpen( 0x63646976, sh_video->bih.biCompression, ICMODE_FASTDECOMPRESS);
! // sh_video->hic = ICOpen( 0x63646976, sh_video->bih.biCompression, ICMODE_DECOMPRESS);
! if(!sh_video->hic){
printf("ICOpen failed! unknown codec / wrong parameters?\n");
return 0;
}
! // sh_video->bih.biBitCount=32;
! ret = ICDecompressGetFormat(sh_video->hic, &sh_video->bih, &sh_video->o_bih);
if(ret){
printf("ICDecompressGetFormat failed: Error %d\n", ret);
***************
*** 132,181 ****
// printf("ICM_DECOMPRESS_QUERY=0x%X",ICM_DECOMPRESS_QUERY);
! // avi_header.o_bih.biWidth=avi_header.bih.biWidth;
! // avi_header.o_bih.biCompression = 0x32315659; // mmioFOURCC('U','Y','V','Y');
! // ret=ICDecompressGetFormatSize(avi_header.hic,&avi_header.o_bih);
! // avi_header.o_bih.biCompression = 3; //0x32315659;
! // avi_header.o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
! // avi_header.o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
! // avi_header.o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
! // avi_header.o_bih.biPlanes=3;
! // avi_header.o_bih.biBitCount=16;
if(outfmt==IMGFMT_YUY2)
! avi_header.o_bih.biBitCount=16;
else
! avi_header.o_bih.biBitCount=outfmt&0xFF;// //24;
! avi_header.o_bih.biSizeImage=avi_header.o_bih.biWidth*avi_header.o_bih.biHeight*(avi_header.o_bih.biBitCount/8);
if(!avi_header.flipped)
! avi_header.o_bih.biHeight=-avi_header.bih.biHeight; // flip image!
if(outfmt==IMGFMT_YUY2 && !avi_header.yuv_hack_needed)
! avi_header.o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
! // avi_header.o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
if(verbose) {
printf("Starting decompression, format:\n");
! printf(" biSize %d\n", avi_header.bih.biSize);
! printf(" biWidth %d\n", avi_header.bih.biWidth);
! printf(" biHeight %d\n", avi_header.bih.biHeight);
! printf(" biPlanes %d\n", avi_header.bih.biPlanes);
! printf(" biBitCount %d\n", avi_header.bih.biBitCount);
! printf(" biCompression %d='%.4s'\n", avi_header.bih.biCompression, &avi_header.bih.biCompression);
! printf(" biSizeImage %d\n", avi_header.bih.biSizeImage);
printf("Dest fmt:\n");
! printf(" biSize %d\n", avi_header.o_bih.biSize);
! printf(" biWidth %d\n", avi_header.o_bih.biWidth);
! printf(" biHeight %d\n", avi_header.o_bih.biHeight);
! printf(" biPlanes %d\n", avi_header.o_bih.biPlanes);
! printf(" biBitCount %d\n", avi_header.o_bih.biBitCount);
! printf(" biCompression %d='%.4s'\n", avi_header.o_bih.biCompression, &avi_header.o_bih.biCompression);
! printf(" biSizeImage %d\n", avi_header.o_bih.biSizeImage);
}
! ret = ICDecompressQuery(avi_header.hic, &avi_header.bih, &avi_header.o_bih);
if(ret){
printf("ICDecompressQuery failed: Error %d\n", ret);
--- 128,177 ----
// printf("ICM_DECOMPRESS_QUERY=0x%X",ICM_DECOMPRESS_QUERY);
! // sh_video->o_bih.biWidth=sh_video->bih.biWidth;
! // sh_video->o_bih.biCompression = 0x32315659; // mmioFOURCC('U','Y','V','Y');
! // ret=ICDecompressGetFormatSize(sh_video->hic,&sh_video->o_bih);
! // sh_video->o_bih.biCompression = 3; //0x32315659;
! // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
! // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
! // sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
! // sh_video->o_bih.biPlanes=3;
! // sh_video->o_bih.biBitCount=16;
if(outfmt==IMGFMT_YUY2)
! sh_video->o_bih.biBitCount=16;
else
! sh_video->o_bih.biBitCount=outfmt&0xFF;// //24;
! sh_video->o_bih.biSizeImage=sh_video->o_bih.biWidth*sh_video->o_bih.biHeight*(sh_video->o_bih.biBitCount/8);
if(!avi_header.flipped)
! sh_video->o_bih.biHeight=-sh_video->bih.biHeight; // flip image!
if(outfmt==IMGFMT_YUY2 && !avi_header.yuv_hack_needed)
! sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
! // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
if(verbose) {
printf("Starting decompression, format:\n");
! printf(" biSize %d\n", sh_video->bih.biSize);
! printf(" biWidth %d\n", sh_video->bih.biWidth);
! printf(" biHeight %d\n", sh_video->bih.biHeight);
! printf(" biPlanes %d\n", sh_video->bih.biPlanes);
! printf(" biBitCount %d\n", sh_video->bih.biBitCount);
! printf(" biCompression %d='%.4s'\n", sh_video->bih.biCompression, &sh_video->bih.biCompression);
! printf(" biSizeImage %d\n", sh_video->bih.biSizeImage);
printf("Dest fmt:\n");
! printf(" biSize %d\n", sh_video->o_bih.biSize);
! printf(" biWidth %d\n", sh_video->o_bih.biWidth);
! printf(" biHeight %d\n", sh_video->o_bih.biHeight);
! printf(" biPlanes %d\n", sh_video->o_bih.biPlanes);
! printf(" biBitCount %d\n", sh_video->o_bih.biBitCount);
! printf(" biCompression %d='%.4s'\n", sh_video->o_bih.biCompression, &sh_video->o_bih.biCompression);
! printf(" biSizeImage %d\n", sh_video->o_bih.biSizeImage);
}
! ret = ICDecompressQuery(sh_video->hic, &sh_video->bih, &sh_video->o_bih);
if(ret){
printf("ICDecompressQuery failed: Error %d\n", ret);
***************
*** 185,189 ****
! ret = ICDecompressBegin(avi_header.hic, &avi_header.bih, &avi_header.o_bih);
if(ret){
printf("ICDecompressBegin failed: Error %d\n", ret);
--- 181,185 ----
! ret = ICDecompressBegin(sh_video->hic, &sh_video->bih, &sh_video->o_bih);
if(ret){
printf("ICDecompressBegin failed: Error %d\n", ret);
***************
*** 193,202 ****
#if 0
! //avi_header.hic
//ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2)
{ int i;
for(i=73;i<256;i++){
printf("Calling ICM_USER+%d function...",i);fflush(stdout);
! ret = ICSendMessage(avi_header.hic,ICM_USER+i,NULL,NULL);
printf(" ret=%d\n",ret);
}
--- 189,198 ----
#if 0
! //sh_video->hic
//ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2)
{ int i;
for(i=73;i<256;i++){
printf("Calling ICM_USER+%d function...",i);fflush(stdout);
! ret = ICSendMessage(sh_video->hic,ICM_USER+i,NULL,NULL);
printf(" ret=%d\n",ret);
}
***************
*** 204,215 ****
#endif
! avi_header.our_out_buffer = malloc(avi_header.o_bih.biSizeImage);
! if(!avi_header.our_out_buffer){
! printf("not enough memory for decoded picture buffer (%d bytes)\n", avi_header.o_bih.biSizeImage);
return 0;
}
if(outfmt==IMGFMT_YUY2 && avi_header.yuv_hack_needed)
! avi_header.o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
// avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!!
--- 200,211 ----
#endif
! sh_video->our_out_buffer = malloc(sh_video->o_bih.biSizeImage);
! if(!sh_video->our_out_buffer){
! printf("not enough memory for decoded picture buffer (%d bytes)\n", sh_video->o_bih.biSizeImage);
return 0;
}
if(outfmt==IMGFMT_YUY2 && avi_header.yuv_hack_needed)
! sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
// avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!!
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -r1.35 -r1.36
*** mplayer.c 2001/04/01 23:01:37 1.35
--- mplayer.c 2001/04/06 01:18:59 1.36
***************
*** 185,199 ****
int idx_pos_v;
int idx_offset; // ennyit kell hozzaadni az index offset ertekekhez
- // int a_idx;
- // int v_idx;
// video:
- AVIStreamHeader video;
- char *video_codec;
- BITMAPINFOHEADER bih; // in format
- BITMAPINFOHEADER o_bih; // out format
- HIC hic;
- char *our_out_buffer;
unsigned int bitrate;
! // video format flags: (filled by codecs.c)
char yuv_supported; // 1 if codec support YUY2 output format
char yuv_hack_needed; // requires for divx & mpeg4
--- 185,192 ----
int idx_pos_v;
int idx_offset; // ennyit kell hozzaadni az index offset ertekekhez
// video:
unsigned int bitrate;
! // video codec info: (filled by codecs.c)
! char *video_codec;
char yuv_supported; // 1 if codec support YUY2 output format
char yuv_hack_needed; // requires for divx & mpeg4
***************
*** 201,214 ****
char flipped; // image is upside-down
GUID* vids_guid;
! // audio:
! AVIStreamHeader audio;
char *audio_codec;
int audio_seekable;
GUID* auds_guid;
- char wf_ext[64]; // in format
- WAVEFORMATEX wf; // out format
- HACMSTREAM srcstream;
- int audio_in_minsize;
- int audio_out_minsize;
} avi_header_t;
--- 194,201 ----
char flipped; // image is upside-down
GUID* vids_guid;
! // audio codec info: (filled by codecs.c)
char *audio_codec;
int audio_seekable;
GUID* auds_guid;
} avi_header_t;
***************
*** 216,220 ****
#include "aviprint.c"
- #include "codecs.c"
extern picture_t *picture;
--- 203,206 ----
***************
*** 230,233 ****
--- 216,222 ----
#include "stream.c"
#include "demuxer.c"
+
+ #include "stheader.h"
+
#include "demux_avi.c"
#include "demux_mpg.c"
***************
*** 237,240 ****
--- 226,234 ----
demux_stream_t *d_video=NULL;
+ sh_audio_t sh_audio_i; // FIXME later!
+ sh_video_t sh_video_i;
+ sh_audio_t *sh_audio=&sh_audio_i;
+ sh_video_t *sh_video=&sh_video_i;
+
// MPEG video stream parser:
#include "parse_es.c"
***************
*** 245,248 ****
--- 239,244 ----
};
+ #include "codecs.c"
+
//**************************************************************************//
// Audio codecs:
***************
*** 252,261 ****
int mplayer_audio_read(char *buf,int size){
int len;
! len=demux_read_data(d_audio,buf,size);
return len;
}
static void ac3_fill_buffer(uint8_t **start,uint8_t **end){
! int len=ds_get_packet(d_audio,(char**)start);
//printf("<ac3:%d>\n",len);
if(len<0)
--- 248,257 ----
int mplayer_audio_read(char *buf,int size){
int len;
! len=demux_read_data(sh_audio->ds,buf,size);
return len;
}
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)
***************
*** 269,272 ****
--- 265,270 ----
#include "xa/xa_gsm.h"
+ #include "dec_audio.c"
+
//**************************************************************************//
// The OpenDivX stuff:
***************
*** 650,653 ****
--- 648,653 ----
d_audio=demuxer->audio;
d_video=demuxer->video;
+ d_audio->sh=sh_audio; sh_audio->ds=d_audio;
+ d_video->sh=sh_video; sh_video->ds=d_video;
switch(file_format){
***************
*** 724,728 ****
has_audio=audio_format; // override type
else if(has_audio)
! switch(((WAVEFORMATEX *)&avi_header.wf_ext)->wFormatTag){
case 0:
has_audio=0;break; // disable/no audio
--- 724,728 ----
has_audio=audio_format; // override type
else if(has_audio)
! switch(sh_audio->wf.wFormatTag){
case 0:
has_audio=0;break; // disable/no audio
***************
*** 751,755 ****
if(verbose) printf("detected AVI audio format: %d\n",has_audio);
if(has_audio==4){
! if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name();
if(avi_header.auds_guid) has_audio=7; // force DShow
if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
--- 751,755 ----
if(verbose) printf("detected AVI audio format: %d\n",has_audio);
if(has_audio==4){
! if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name(sh_audio);
if(avi_header.auds_guid) has_audio=7; // force DShow
if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
***************
*** 763,767 ****
}
}
! default_fps=(float)avi_header.video.dwRate/(float)avi_header.video.dwScale;
break;
}
--- 763,767 ----
}
}
! default_fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
break;
}
***************
*** 792,796 ****
has_audio=audio_format; // override type
else if(has_audio)
! switch(((WAVEFORMATEX *)&avi_header.wf_ext)->wFormatTag){
case 0:
has_audio=0;break; // disable/no audio
--- 792,796 ----
has_audio=audio_format; // override type
else if(has_audio)
! switch(sh_audio->wf.wFormatTag){
case 0:
has_audio=0;break; // disable/no audio
***************
*** 819,823 ****
if(verbose) printf("detected ASF audio format: %d\n",has_audio);
if(has_audio==4){
! if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name();
if(avi_header.auds_guid) has_audio=7; // force DShow
if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
--- 819,823 ----
if(verbose) printf("detected ASF audio format: %d\n",has_audio);
if(has_audio==4){
! if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name(sh_audio);
if(avi_header.auds_guid) has_audio=7; // force DShow
if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
***************
*** 860,872 ****
if(has_video==2){
! if(avi_header.video.fccHandler==mmioFOURCC('d', 'v', 'x', '1')) has_video=3;
! if(avi_header.video.fccHandler==mmioFOURCC('d', 'i', 'v', 'x')) has_video=3;
! if(avi_header.bih.biCompression==mmioFOURCC('d', 'v', 'x', '1')) has_video=3;
! if(avi_header.bih.biCompression==mmioFOURCC('d', 'i', 'v', 'x')) has_video=3;
! // if(avi_header.bih.biCompression==mmioFOURCC('D', 'I', 'V', 'X')) has_video=3; // Gabucino
}
if(has_video==2){
! if(!avi_header.video_codec) avi_header.video_codec=get_vids_codec_name();
if(verbose)
printf("win32 video codec: '%s' %s%s%s\n",avi_header.video_codec,
--- 860,872 ----
if(has_video==2){
! if(sh_video->video.fccHandler==mmioFOURCC('d', 'v', 'x', '1')) has_video=3;
! if(sh_video->video.fccHandler==mmioFOURCC('d', 'i', 'v', 'x')) has_video=3;
! if(sh_video->bih.biCompression==mmioFOURCC('d', 'v', 'x', '1')) has_video=3;
! if(sh_video->bih.biCompression==mmioFOURCC('d', 'i', 'v', 'x')) has_video=3;
! // if(sh_video->bih.biCompression==mmioFOURCC('D', 'I', 'V', 'X')) has_video=3; // Gabucino
}
if(has_video==2){
! if(!avi_header.video_codec) avi_header.video_codec=get_vids_codec_name(sh_video);
if(verbose)
printf("win32 video codec: '%s' %s%s%s\n",avi_header.video_codec,
***************
*** 906,919 ****
// calculating video bitrate:
avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8;
! if(avi_header.audio.fccType) avi_header.bitrate-=avi_header.audio.dwLength;
if(verbose) printf("AVI video length=%d\n",avi_header.bitrate);
! avi_header.bitrate=((float)avi_header.bitrate/(float)avi_header.video.dwLength)
! *((float)avi_header.video.dwRate/(float)avi_header.video.dwScale);
! // default_fps=(float)avi_header.video.dwRate/(float)avi_header.video.dwScale;
printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n",
! &avi_header.bih.biCompression,
! avi_header.bih.biWidth,
! avi_header.bih.biHeight,
! avi_header.bih.biBitCount,
default_fps,
avi_header.bitrate*0.008f,
--- 906,919 ----
// calculating video bitrate:
avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8;
! if(sh_audio->audio.fccType) 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)
! *((float)sh_video->video.dwRate/(float)sh_video->video.dwScale);
! // default_fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
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,
default_fps,
avi_header.bitrate*0.008f,
***************
*** 921,926 ****
// display info:
! movie_size_x=avi_header.o_bih.biWidth;
! movie_size_y=abs(avi_header.o_bih.biHeight);
break;
}
--- 921,926 ----
// display info:
! movie_size_x=sh_video->o_bih.biWidth;
! movie_size_y=abs(sh_video->o_bih.biHeight);
break;
}
***************
*** 940,945 ****
//if(verbose) printf("AVI out_fmt=%X\n",out_fmt);
if(verbose) if(out_fmt==IMGFMT_YUY2) printf("Using YUV/YUY2 video output format!\n");
! avi_header.our_out_buffer=NULL;
! if(DS_VideoDecoder_Open(avi_header.video_codec,avi_header.vids_guid, &avi_header.bih, 0, &avi_header.our_out_buffer)){
printf("ERROR: Couldn't open required DirectShow codec: %s\n",avi_header.video_codec);
printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
--- 940,945 ----
//if(verbose) printf("AVI out_fmt=%X\n",out_fmt);
if(verbose) if(out_fmt==IMGFMT_YUY2) printf("Using YUV/YUY2 video output format!\n");
! sh_video->our_out_buffer=NULL;
! if(DS_VideoDecoder_Open(avi_header.video_codec,avi_header.vids_guid, &sh_video->bih, 0, &sh_video->our_out_buffer)){
printf("ERROR: Couldn't open required DirectShow codec: %s\n",avi_header.video_codec);
printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
***************
*** 964,977 ****
// calculating video bitrate:
avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8;
! if(avi_header.audio.fccType) avi_header.bitrate-=avi_header.audio.dwLength;
if(verbose) printf("AVI video length=%d\n",avi_header.bitrate);
! avi_header.bitrate=((float)avi_header.bitrate/(float)avi_header.video.dwLength)
! *((float)avi_header.video.dwRate/(float)avi_header.video.dwScale);
! // default_fps=(float)avi_header.video.dwRate/(float)avi_header.video.dwScale;
printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n",
! &avi_header.bih.biCompression,
! avi_header.bih.biWidth,
! avi_header.bih.biHeight,
! avi_header.bih.biBitCount,
default_fps,
avi_header.bitrate*0.008f,
--- 964,977 ----
// calculating video bitrate:
avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8;
! if(sh_audio->audio.fccType) 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)
! *((float)sh_video->video.dwRate/(float)sh_video->video.dwScale);
! // default_fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
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,
default_fps,
avi_header.bitrate*0.008f,
***************
*** 979,984 ****
// display info:
! movie_size_x=avi_header.bih.biWidth;
! movie_size_y=abs(avi_header.bih.biHeight);
break;
}
--- 979,984 ----
// display info:
! movie_size_x=sh_video->bih.biWidth;
! movie_size_y=abs(sh_video->bih.biHeight);
break;
}
***************
*** 994,999 ****
{ DEC_PARAM dec_param;
DEC_SET dec_set;
! dec_param.x_dim = avi_header.bih.biWidth;
! dec_param.y_dim = avi_header.bih.biHeight;
dec_param.color_depth = 32;
decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
--- 994,999 ----
{ DEC_PARAM dec_param;
DEC_SET dec_set;
! dec_param.x_dim = sh_video->bih.biWidth;
! dec_param.y_dim = sh_video->bih.biHeight;
dec_param.color_depth = 32;
decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
***************
*** 1005,1018 ****
// calculating video bitrate:
avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8;
! if(avi_header.audio.fccType) avi_header.bitrate-=avi_header.audio.dwLength;
if(verbose) printf("AVI video length=%d\n",avi_header.bitrate);
! avi_header.bitrate=((float)avi_header.bitrate/(float)avi_header.video.dwLength)
! *((float)avi_header.video.dwRate/(float)avi_header.video.dwScale);
! // default_fps=(float)avi_header.video.dwRate/(float)avi_header.video.dwScale;
printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n",
! &avi_header.bih.biCompression,
! avi_header.bih.biWidth,
! avi_header.bih.biHeight,
! avi_header.bih.biBitCount,
default_fps,
avi_header.bitrate*0.008f,
--- 1005,1018 ----
// calculating video bitrate:
avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8;
! if(sh_audio->audio.fccType) 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)
! *((float)sh_video->video.dwRate/(float)sh_video->video.dwScale);
! // default_fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
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,
default_fps,
avi_header.bitrate*0.008f,
***************
*** 1020,1026 ****
// display info:
! // movie_size_x=avi_header.bih.biWidth+(divx_quality?0:64);
! movie_size_x=avi_header.bih.biWidth;
! movie_size_y=abs(avi_header.bih.biHeight);
break;
}
--- 1020,1026 ----
// display info:
! // movie_size_x=sh_video->bih.biWidth+(divx_quality?0:64);
! movie_size_x=sh_video->bih.biWidth;
! movie_size_y=abs(sh_video->bih.biHeight);
break;
}
***************
*** 1186,1190 ****
int a_buffer_size=0;
int audio_fd=-1;
- int pcm_bswap=0;
float buffer_delay=0;
float frame_correction=0; // A-V timestamp kulonbseg atlagolas
--- 1186,1189 ----
***************
*** 1199,1203 ****
int eof=0;
int force_redraw=0;
- ac3_frame_t *ac3_frame=NULL;
float num_frames=0; // number of frames played
//int real_num_frames=0; // number of frames readed
--- 1198,1201 ----
***************
*** 1240,1256 ****
MP3_bps=2;
! pcm_bswap=0;
a_buffer_size=16384; // default size, maybe not enough for Win32/ACM
if(has_audio==4){
// Win32 ACM audio codec:
! if(init_audio_codec()){
! MP3_channels=avi_header.wf.nChannels;
! MP3_samplerate=avi_header.wf.nSamplesPerSec;
! if(a_buffer_size<avi_header.audio_out_minsize+OUTBURST)
! a_buffer_size=avi_header.audio_out_minsize+OUTBURST;
} else {
printf("Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n");
! if((((WAVEFORMATEX *)&avi_header.wf_ext)->wFormatTag)==0x55){
printf("Audio format is MP3 -> fallback to internal mp3lib/mpg123\n");
has_audio=1; // fallback to mp3lib
--- 1238,1254 ----
MP3_bps=2;
! sh_audio->pcm_bswap=0;
a_buffer_size=16384; // default size, maybe not enough for Win32/ACM
if(has_audio==4){
// Win32 ACM audio codec:
! if(init_audio_codec(sh_audio)){
! MP3_channels=sh_audio->o_wf.nChannels;
! MP3_samplerate=sh_audio->o_wf.nSamplesPerSec;
! if(a_buffer_size<sh_audio->audio_out_minsize+OUTBURST)
! a_buffer_size=sh_audio->audio_out_minsize+OUTBURST;
} else {
printf("Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n");
! if((sh_audio->wf.wFormatTag)==0x55){
printf("Audio format is MP3 -> fallback to internal mp3lib/mpg123\n");
has_audio=1; // fallback to mp3lib
***************
*** 1266,1287 ****
#else
// Win32 DShow audio codec:
! WAVEFORMATEX *in_fmt=(WAVEFORMATEX*)&avi_header.wf_ext;
! avi_header.wf.nChannels=in_fmt->nChannels;
! avi_header.wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
! avi_header.wf.nAvgBytesPerSec=2*avi_header.wf.nSamplesPerSec*avi_header.wf.nChannels;
! avi_header.wf.wFormatTag=WAVE_FORMAT_PCM;
! avi_header.wf.nBlockAlign=2*in_fmt->nChannels;
! avi_header.wf.wBitsPerSample=16;
! avi_header.wf.cbSize=0;
if(!DS_AudioDecoder_Open(avi_header.audio_codec,avi_header.auds_guid,in_fmt)){
! MP3_channels=avi_header.wf.nChannels;
! MP3_samplerate=avi_header.wf.nSamplesPerSec;
! avi_header.audio_in_minsize=2*avi_header.wf.nBlockAlign;
! if(avi_header.audio_in_minsize<8192) avi_header.audio_in_minsize=8192;
! a_in_buffer_size=avi_header.audio_in_minsize;
! a_in_buffer=malloc(a_in_buffer_size);
! a_in_buffer_len=0;
} else {
--- 1264,1285 ----
#else
// Win32 DShow audio codec:
! WAVEFORMATEX *in_fmt=&sh_audio->wf;
! sh_audio->o_wf.nChannels=in_fmt->nChannels;
! sh_audio->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
! sh_audio->o_wf.nAvgBytesPerSec=2*sh_audio->o_wf.nSamplesPerSec*sh_audio->o_wf.nChannels;
! sh_audio->o_wf.wFormatTag=WAVE_FORMAT_PCM;
! sh_audio->o_wf.nBlockAlign=2*in_fmt->nChannels;
! sh_audio->o_wf.wBitsPerSample=16;
! sh_audio->o_wf.cbSize=0;
if(!DS_AudioDecoder_Open(avi_header.audio_codec,avi_header.auds_guid,in_fmt)){
! MP3_channels=sh_audio->o_wf.nChannels;
! MP3_samplerate=sh_audio->o_wf.nSamplesPerSec;
! sh_audio->audio_in_minsize=2*sh_audio->o_wf.nBlockAlign;
! if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
! sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize;
! sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
! sh_audio->a_in_buffer_len=0;
} else {
***************
*** 1304,1308 ****
if(has_audio==4){
! int ret=acm_decode_audio(a_buffer,a_buffer_size);
if(ret<0){
printf("ACM error %d -> switching to nosound...\n",ret);
--- 1302,1306 ----
if(has_audio==4){
! int ret=acm_decode_audio(sh_audio,a_buffer,a_buffer_size);
if(ret<0){
printf("ACM error %d -> switching to nosound...\n",ret);
***************
*** 1317,1321 ****
if(file_format==DEMUXER_TYPE_AVI){
// AVI PCM Audio:
! WAVEFORMATEX *h=(WAVEFORMATEX*)&avi_header.wf_ext;
MP3_channels=h->nChannels;
MP3_samplerate=h->nSamplesPerSec;
--- 1315,1319 ----
if(file_format==DEMUXER_TYPE_AVI){
// AVI PCM Audio:
! WAVEFORMATEX *h=&sh_audio->wf;
MP3_channels=h->nChannels;
MP3_samplerate=h->nSamplesPerSec;
***************
*** 1325,1329 ****
MP3_channels=2;
MP3_samplerate=48000;
! pcm_bswap=1;
}
} else
--- 1323,1327 ----
MP3_channels=2;
MP3_samplerate=48000;
! sh_audio->pcm_bswap=1;
}
} else
***************
*** 1340,1346 ****
#endif
ac3_init();
! ac3_frame = ac3_decode_frame();
! if(ac3_frame){
! MP3_samplerate=ac3_frame->sampling_rate;
MP3_channels=2;
} else has_audio=0; // bad frame -> disable audio
--- 1338,1344 ----
#endif
ac3_init();
! sh_audio->ac3_frame = ac3_decode_frame();
! if(sh_audio->ac3_frame){
! MP3_samplerate=sh_audio->ac3_frame->sampling_rate;
MP3_channels=2;
} else has_audio=0; // bad frame -> disable audio
***************
*** 1349,1360 ****
// aLaw audio codec:
Gen_aLaw_2_Signed(); // init table
! MP3_channels=((WAVEFORMATEX*)&avi_header.wf_ext)->nChannels;
! MP3_samplerate=((WAVEFORMATEX*)&avi_header.wf_ext)->nSamplesPerSec;
} else
if(has_audio==6){
// MS-GSM audio codec:
GSM_Init();
! MP3_channels=((WAVEFORMATEX*)&avi_header.wf_ext)->nChannels;
! MP3_samplerate=((WAVEFORMATEX*)&avi_header.wf_ext)->nSamplesPerSec;
}
// must be here for Win32->mp3lib fallbacks
--- 1347,1358 ----
// aLaw audio codec:
Gen_aLaw_2_Signed(); // init table
! MP3_channels=sh_audio->wf.nChannels;
! MP3_samplerate=sh_audio->wf.nSamplesPerSec;
} else
if(has_audio==6){
// MS-GSM audio codec:
GSM_Init();
! MP3_channels=sh_audio->wf.nChannels;
! MP3_samplerate=sh_audio->wf.nSamplesPerSec;
}
// must be here for Win32->mp3lib fallbacks
***************
*** 1466,1472 ****
if(file_format==DEMUXER_TYPE_AVI){
a_pts=d_audio->pts-(buffer_delay+audio_delay);
! audio_delay-=(float)(avi_header.audio.dwInitialFrames-avi_header.video.dwInitialFrames)/default_fps;
! // audio_delay-=(float)(avi_header.audio.dwInitialFrames-avi_header.video.dwInitialFrames)/default_fps;
! printf("AVI Initial frame delay: %5.3f\n",(float)(avi_header.audio.dwInitialFrames-avi_header.video.dwInitialFrames)/default_fps);
printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n",
audio_delay,buffer_delay,a_pts,a_frame);
--- 1464,1470 ----
if(file_format==DEMUXER_TYPE_AVI){
a_pts=d_audio->pts-(buffer_delay+audio_delay);
! audio_delay-=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps;
! // audio_delay-=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps;
! printf("AVI Initial frame delay: %5.3f\n",(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps);
printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n",
audio_delay,buffer_delay,a_pts,a_frame);
***************
*** 1495,1594 ****
while(has_audio){
unsigned int t=GetTimer();
current_module="decode_audio"; // Enter AUDIO decoder module
! // Update buffer if needed
while(a_buffer_len<OUTBURST && !d_audio->eof){
! switch(has_audio){
! case 1: // MPEG layer 2 or 3
! a_buffer_len+=MP3_DecodeFrame(&a_buffer[a_buffer_len],-1);
! MP3_channels=2; // hack
! break;
! case 2: // PCM
! { int i=demux_read_data(d_audio,&a_buffer[a_buffer_len],OUTBURST);
! if(pcm_bswap){
! int j;
! if(i&3){ printf("Warning! pcm_audio_size&3 !=0 (%d)\n",i);i&=~3; }
! for(j=0;j<i;j+=2){
! char x=a_buffer[a_buffer_len+j];
! a_buffer[a_buffer_len+j]=a_buffer[a_buffer_len+j+1];
! a_buffer[a_buffer_len+j+1]=x;
! }
! }
! a_buffer_len+=i;
! break;
! }
! case 5: // aLaw decoder
! { int l=demux_read_data(d_audio,&a_buffer[a_buffer_len],OUTBURST/2);
! unsigned short *d=(unsigned short *) &a_buffer[a_buffer_len];
! unsigned char *s=&a_buffer[a_buffer_len];
! a_buffer_len+=2*l;
! while(l>0){
! --l;
! d[l]=xa_alaw_2_sign[s[l]];
! }
! break;
! }
! case 6: // MS-GSM decoder
! { unsigned char buf[65]; // 65 bytes / frame
! while(a_buffer_len<OUTBURST){
! if(demux_read_data(d_audio,buf,65)!=65) break; // EOF
! XA_MSGSM_Decoder(buf,(unsigned short *) &a_buffer[a_buffer_len]); // decodes 65 byte -> 320 short
! // XA_GSM_Decoder(buf,(unsigned short *) &a_buffer[a_buffer_len]); // decodes 33 byte -> 160 short
! a_buffer_len+=2*320;
! }
! break;
! }
! case 3: // AC3 decoder
! //printf("{1:%d}",avi_header.idx_pos);fflush(stdout);
! if(!ac3_frame) ac3_frame=ac3_decode_frame();
! //printf("{2:%d}",avi_header.idx_pos);fflush(stdout);
! if(ac3_frame){
! memcpy(&a_buffer[a_buffer_len],ac3_frame->audio_data,256 * 6 *MP3_channels*MP3_bps);
! a_buffer_len+=256 * 6 *MP3_channels*MP3_bps;
! ac3_frame=NULL;
! }
! //printf("{3:%d}",avi_header.idx_pos);fflush(stdout);
! break;
! case 4:
! { int ret=acm_decode_audio(&a_buffer[a_buffer_len],a_buffer_size-a_buffer_len);
! if(ret>0) a_buffer_len+=ret;
! break;
! }
! #ifdef USE_DIRECTSHOW
! case 7: // DirectShow
! { int ret;
! int len=a_buffer_size-a_buffer_len;
! int size_in=0;
! int size_out=0;
! int srcsize=DS_AudioDecoder_GetSrcSize(len);
! if(verbose>2)printf("DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,a_in_buffer_size,len);
! if(srcsize>a_in_buffer_size) srcsize=a_in_buffer_size; // !!!!!!
! if(a_in_buffer_len<srcsize){
! a_in_buffer_len+=
! demux_read_data(d_audio,&a_in_buffer[a_in_buffer_len],
! srcsize-a_in_buffer_len);
! }
! DS_AudioDecoder_Convert(a_in_buffer,a_in_buffer_len,
! &a_buffer[a_buffer_len],len, &size_in,&size_out);
! if(verbose>2)printf("DShow: audio %d -> %d converted (in_buf_len=%d of %d)\n",size_in,size_out,a_in_buffer_len,a_in_buffer_size);
! if(size_in>=a_in_buffer_len){
! a_in_buffer_len=0;
! } else {
! a_in_buffer_len-=size_in;
! memcpy(a_in_buffer,&a_in_buffer[size_in],a_in_buffer_len);
! }
! a_buffer_len+=size_out;
!
! break;
! }
! #endif
! }
}
current_module=NULL; // Leave AUDIO decoder module
! t=GetTimer()-t;
! audio_time_usage+=t*0.000001;
- // Play sound from the buffer:
if(a_buffer_len>=OUTBURST){ // if not EOF
#ifdef USE_XMMP_AUDIO
--- 1493,1510 ----
while(has_audio){
+
+ // Update buffer if needed
unsigned int t=GetTimer();
current_module="decode_audio"; // Enter AUDIO decoder module
! sh_audio->codec.driver=has_audio; // FIXME!
while(a_buffer_len<OUTBURST && !d_audio->eof){
! int ret=decode_audio(sh_audio,&a_buffer[a_buffer_len],a_buffer_size-a_buffer_len);
! if(ret>0) a_buffer_len+=ret; else break;
}
current_module=NULL; // Leave AUDIO decoder module
! t=GetTimer()-t;audio_time_usage+=t*0.000001;
+ // Play sound from the buffer:
if(a_buffer_len>=OUTBURST){ // if not EOF
#ifdef USE_XMMP_AUDIO
***************
*** 1697,1701 ****
++num_frames;
! v_frame+=1.0f/default_fps; //(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
break;
--- 1613,1617 ----
++num_frames;
! v_frame+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
break;
***************
*** 1717,1721 ****
t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
! video_out->draw_frame((uint8_t **)&avi_header.our_out_buffer);
// video_out->flip_page();
t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
--- 1633,1637 ----
t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
! video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
// video_out->flip_page();
t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
***************
*** 1727,1732 ****
if(d>0 && d<0.2) v_frame+=d;
} else
! v_frame+=1.0f/default_fps; //(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
! //v_pts+=1.0f/default_fps; //(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
break;
--- 1643,1648 ----
if(d>0 && d<0.2) v_frame+=d;
} else
! v_frame+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
! //v_pts+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
break;
***************
*** 1747,1760 ****
//if(in_size>0){
! avi_header.bih.biSizeImage = in_size;
! ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME,
// ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL),
! &avi_header.bih, start,
! &avi_header.o_bih, avi_header.our_out_buffer);
if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; }
//}
t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
! video_out->draw_frame((uint8_t **)&avi_header.our_out_buffer);
// video_out->flip_page();
t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
--- 1663,1676 ----
//if(in_size>0){
! sh_video->bih.biSizeImage = in_size;
! ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME,
// ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL),
! &sh_video->bih, start,
! &sh_video->o_bih, sh_video->our_out_buffer);
if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; }
//}
t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
! video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
// video_out->flip_page();
t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
***************
*** 1766,1771 ****
if(d>0 && d<0.2) v_frame+=d;
} else
! v_frame+=1.0f/default_fps; //(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
! //v_pts+=1.0f/default_fps; //(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
break;
--- 1682,1687 ----
if(d>0 && d<0.2) v_frame+=d;
} else
! v_frame+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
! //v_pts+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
break;
***************
*** 1945,1950 ****
if(has_audio){
if(pts_from_bps && (file_format==DEMUXER_TYPE_AVI)){
! // a_pts=(float)ds_tell(d_audio)/((WAVEFORMATEX*)avi_header.wf_ext)->nAvgBytesPerSec-(buffer_delay+audio_delay);
! a_pts=(float)ds_tell(d_audio)/((WAVEFORMATEX*)avi_header.wf_ext)->nAvgBytesPerSec-(buffer_delay);
delay_corrected=1; // hack
} else
--- 1861,1866 ----
if(has_audio){
if(pts_from_bps && (file_format==DEMUXER_TYPE_AVI)){
! // a_pts=(float)ds_tell(d_audio)/sh_audio->wf.nAvgBytesPerSec-(buffer_delay+audio_delay);
! a_pts=(float)ds_tell(d_audio)/sh_audio->wf.nAvgBytesPerSec-(buffer_delay);
delay_corrected=1; // hack
} else
***************
*** 2126,2130 ****
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;
! v_pts+=(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
++skip_audio_bytes;
}
--- 2042,2046 ----
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;
! v_pts+=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
++skip_audio_bytes;
}
***************
*** 2138,2142 ****
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;
! v_pts-=(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
--skip_audio_bytes;
}
--- 2054,2058 ----
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;
! v_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
--skip_audio_bytes;
}
***************
*** 2155,2159 ****
// if(LOWORD(id)==aviTWOCC('0','0')){ // video frame
if(avi_stream_id(id)==d_video->id){ // video frame
! avi_video_pts+=(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
}
}
--- 2071,2075 ----
// 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;
}
}
***************
*** 2173,2183 ****
// calc new audio position in audio stream: (using avg.bps value)
! curr_audio_pos=(avi_video_pts) * ((WAVEFORMATEX*)avi_header.wf_ext)->nAvgBytesPerSec;
if(curr_audio_pos<0)curr_audio_pos=0;
#if 1
curr_audio_pos&=~15; // requires for PCM formats!!!
#else
! curr_audio_pos/=((WAVEFORMATEX*)avi_header.wf_ext)->nBlockAlign;
! curr_audio_pos*=((WAVEFORMATEX*)avi_header.wf_ext)->nBlockAlign;
avi_header.audio_seekable=1;
#endif
--- 2089,2099 ----
// calc new audio position in audio stream: (using avg.bps value)
! curr_audio_pos=(avi_video_pts) * sh_audio->wf.nAvgBytesPerSec;
if(curr_audio_pos<0)curr_audio_pos=0;
#if 1
curr_audio_pos&=~15; // requires for PCM formats!!!
#else
! curr_audio_pos/=sh_audio->wf.nBlockAlign;
! curr_audio_pos*=sh_audio->wf.nBlockAlign;
avi_header.audio_seekable=1;
#endif
***************
*** 2215,2226 ****
#if 0
// curr_audio_pos=apos; // selected audio codec can't seek in chunk
! skip_audio_secs=(float)skip_audio_bytes/(float)((WAVEFORMATEX*)avi_header.wf_ext)->nAvgBytesPerSec;
//printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",skip_audio_bytes,skip_audio_secs);
skip_audio_bytes=0;
#else
! int d=skip_audio_bytes % ((WAVEFORMATEX*)avi_header.wf_ext)->nBlockAlign;
skip_audio_bytes-=d;
// curr_audio_pos-=d;
! skip_audio_secs=(float)d/(float)((WAVEFORMATEX*)avi_header.wf_ext)->nAvgBytesPerSec;
//printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",d,skip_audio_secs);
#endif
--- 2131,2142 ----
#if 0
// curr_audio_pos=apos; // selected audio codec can't seek in chunk
! skip_audio_secs=(float)skip_audio_bytes/(float)sh_audio->wf.nAvgBytesPerSec;
//printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",skip_audio_bytes,skip_audio_secs);
skip_audio_bytes=0;
#else
! int d=skip_audio_bytes % sh_audio->wf.nBlockAlign;
skip_audio_bytes-=d;
// curr_audio_pos-=d;
! skip_audio_secs=(float)d/(float)sh_audio->wf.nAvgBytesPerSec;
//printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",d,skip_audio_secs);
#endif
***************
*** 2239,2243 ****
++skip_video_frames;
// requires for correct audio pts calculation (demuxer):
! avi_video_pts-=(float)avi_header.video.dwScale/(float)avi_header.video.dwRate;
}
++i;
--- 2155,2159 ----
++skip_video_frames;
// requires for correct audio pts calculation (demuxer):
! avi_video_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
}
++i;
***************
*** 2320,2328 ****
ac3_bitstream_reset(); // reset AC3 bitstream buffer
// if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);}
! ac3_frame=ac3_decode_frame(); // resync
// if(verbose) printf(" OK!\n");
break;
case 4:
! a_in_buffer_len=0; // reset ACM audio buffer
break;
}
--- 2236,2245 ----
ac3_bitstream_reset(); // reset AC3 bitstream buffer
// if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);}
! sh_audio->ac3_frame=ac3_decode_frame(); // resync
// if(verbose) printf(" OK!\n");
break;
case 4:
! case 7:
! sh_audio->a_in_buffer_len=0; // reset ACM/DShow audio buffer
break;
}
***************
*** 2337,2341 ****
switch(has_audio){
case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame
! case 3: ac3_frame=ac3_decode_frame();break; // skip AC3 frame
default: ds_fill_buffer(d_audio); // skip PCM frame
}
--- 2254,2258 ----
switch(has_audio){
case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame
! case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame
default: ds_fill_buffer(d_audio); // skip PCM frame
}
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
More information about the MPlayer-cvslog
mailing list