1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-20 13:52:10 +00:00

some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1328 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2001-07-16 12:53:48 +00:00
parent 4fb4b7b314
commit 0d99276222
4 changed files with 47 additions and 59 deletions

View File

@ -32,6 +32,10 @@ int fakemono=0;
#include "loader/DirectShow/DS_AudioDec.h"
#endif
extern int init_acm_audio_codec(sh_audio_t *sh_audio);
extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen);
static sh_audio_t* dec_audio_sh=NULL;
// AC3 decoder buffer callback:
@ -51,15 +55,9 @@ int mplayer_audio_read(char *buf,int size){
return len;
}
int init_audio(sh_audio_t *sh_audio){
int driver=sh_audio->codec->driver;
extern int init_acm_audio_codec(sh_audio_t *sh_audio);
//extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int len);
extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen);
sh_audio->samplesize=2;
#if WORDS_BIGENDIAN
sh_audio->sample_format=AFMT_S16_BE;
@ -344,8 +342,7 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
#ifdef USE_DIRECTSHOW
case 7: // DirectShow
{ int ret;
int size_in=0;
{ 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);
@ -373,4 +370,30 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
return len;
}
void resync_audio_stream(sh_audio_t *sh_audio){
switch(sh_audio->codec->driver){
case 1:
MP3_DecodeFrame(NULL,-2); // resync
MP3_DecodeFrame(NULL,-2); // resync
MP3_DecodeFrame(NULL,-2); // resync
break;
case 3:
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;
}
}
void skip_audio_frame(sh_audio_t *sh_audio){
switch(sh_audio->codec->driver){
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(sh_audio->ds); // skip PCM frame
}
}

View File

@ -10,6 +10,8 @@ extern int divx_quality;
extern double video_time_usage;
extern double vout_time_usage;
#include "linux/timer.h"
#include "stream.h"
#include "demuxer.h"
@ -383,9 +385,7 @@ else
break;
#endif
case 1: {
int in_frame=0;
int t=0;
float newfps;
t-=GetTimer();
mpeg2_decode_data(video_out, start, start+in_size,drop_frame);

View File

@ -239,6 +239,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){
break;
default:
printf("Warning! unknown segtype == 0x%2X \n",segtype);
x=0;
}
type=p[0]; p++; // 0x01: grouping 0x08: single

View File

@ -30,12 +30,6 @@
#define DEFAULT_CDROM_DEVICE "/dev/cdrom"
#endif
#ifndef MAX_OUTBURST
#error "============================================="
#error "Please re-run ./configure and then try again!"
#error "============================================="
#endif
#include "cfgparser.h"
#include "cfg-mplayer-def.h"
@ -46,9 +40,6 @@
#include "libao2/audio_out.h"
// CODECS:
#include "mp3lib/mp3.h"
#include "libac3/ac3.h"
#include "libmpeg2/mpeg2.h"
#include "libmpeg2/mpeg2_internal.h"
@ -60,17 +51,8 @@
#include "dvdauth.h"
#include "spudec.h"
#ifdef USE_DIRECTSHOW
//#include "DirectShow/DS_VideoDec.h"
//#include "DirectShow/DS_AudioDec.h"
#endif
//#include "opendivx/decore.h"
extern char* win32_codec_name; // must be set before calling DrvOpen() !!!
// extern int errno;
#include "linux/getch2.h"
#include "linux/keycodes.h"
#include "linux/timer.h"
@ -153,7 +135,6 @@ char *get_path(char *filename){
//**************************************************************************//
static int max_framesize=0;
//static int show_packets=0;
#include "stream.h"
#include "demuxer.h"
@ -162,8 +143,6 @@ static int max_framesize=0;
static int avi_bitrate=0;
//#include "aviprint.c"
sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
if(demuxer->a_streams[id]){
printf("Warning! Audio stream header %d redefined!\n",id);
@ -261,6 +240,7 @@ int video_family=-1; // override video codec family
// IMHO this stuff is no longer of use, or is there a special
// reason why dshow should be completely disabled? - atmos ::
// yes, people without working c++ compiler can disable it - A'rpi
#ifdef USE_DIRECTSHOW
int allow_dshow=1;
#else
@ -395,13 +375,19 @@ void exit_sighandler(int x){
}
extern int vcd_get_track_end(int fd,int track);
extern int init_audio(sh_audio_t *sh_audio);
extern int init_video_codec(sh_video_t *sh_video);
extern void mpeg2_allocate_image_buffers(picture_t * picture);
//extern void mpeg2_allocate_image_buffers(picture_t * picture);
extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height);
extern int vo_init(void);
extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen);
// dec_audio.c:
extern int init_audio(sh_audio_t *sh_audio);
extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen);
extern void resync_audio_stream(sh_audio_t *sh_audio);
extern void skip_audio_frame(sh_audio_t *sh_audio);
// dec_video.c:
extern int init_video(sh_video_t *sh_video);
extern int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame);
#include "mixer.h"
#include "cfg-mplayer.h"
@ -1517,7 +1503,6 @@ if(1)
if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){
int in_frame=0;
int t=0;
float newfps;
videobuf_len=0;
while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
@ -2106,24 +2091,7 @@ switch(file_format){
}
current_module="resync_audio";
switch(sh_audio->codec->driver){
case 1:
MP3_DecodeFrame(NULL,-2); // resync
MP3_DecodeFrame(NULL,-2); // resync
MP3_DecodeFrame(NULL,-2); // resync
break;
case 3:
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;
}
resync_audio_stream(sh_audio);
// re-sync PTS (MPEG-PS only!!!)
if(file_format==DEMUXER_TYPE_MPEG_PS)
@ -2132,11 +2100,7 @@ switch(file_format){
} else {
while(d_video->pts > d_audio->pts){
switch(sh_audio->codec->driver){
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
}
skip_audio_frame(sh_audio);
}
}
}