diff -rC5 MPlayer-0.50/codec-cfg.c MPlayer-0.50_mad/codec-cfg.c *** MPlayer-0.50/codec-cfg.c Wed Oct 3 00:37:28 2001 --- MPlayer-0.50_mad/codec-cfg.c Thu Oct 18 14:45:28 2001 *************** *** 207,216 **** --- 207,217 ---- "dshow", "dvdpcm", "hwac3", "libvorbis", "ffmpeg", + "libmad", NULL }; static char *videodrv[] = { "null", "libmpeg2", diff -rC5 MPlayer-0.50/codec-cfg.h MPlayer-0.50_mad/codec-cfg.h *** MPlayer-0.50/codec-cfg.h Thu Sep 27 14:59:35 2001 --- MPlayer-0.50_mad/codec-cfg.h Thu Oct 18 14:25:04 2001 *************** *** 27,36 **** --- 27,37 ---- #define AFM_DSHOW 7 #define AFM_DVDPCM 8 #define AFM_HWAC3 9 #define AFM_VORBIS 10 #define AFM_FFMPEG 11 + #define AFM_MAD 12 #define VFM_MPEG 1 #define VFM_VFW 2 #define VFM_ODIVX 3 #define VFM_DSHOW 4 diff -rC5 MPlayer-0.50/dec_audio.c MPlayer-0.50_mad/dec_audio.c *** MPlayer-0.50/dec_audio.c Tue Oct 2 23:44:45 2001 --- MPlayer-0.50_mad/dec_audio.c Thu Oct 18 16:09:48 2001 *************** *** 51,60 **** --- 51,109 ---- static AVCodec *lavc_codec=NULL; static AVCodecContext lavc_context; extern int avcodec_inited; #endif + + + #ifdef USE_LIBMAD + #include + static struct mad_stream mad_stream; + static struct mad_frame mad_frame; + static struct mad_synth mad_synth; + + + // ensure buffer is filled with some data + static void mad_prepare_buffer(sh_audio_t* sh_audio, struct mad_stream* ms, int length) + { + if(sh_audio->a_in_buffer_len < length) { + int len = demux_read_data(sh_audio->ds, sh_audio->a_in_buffer+sh_audio->a_in_buffer_len, length-sh_audio->a_in_buffer_len); + sh_audio->a_in_buffer_len += len; + } + } + + static void mad_postprocess_buffer(sh_audio_t* sh_audio, struct mad_stream* ms) + { + int delta = (unsigned char*)ms->next_frame - (unsigned char *)sh_audio->a_in_buffer; + if(delta != 0) { + sh_audio->a_in_buffer_len -= delta; + memcpy(sh_audio->a_in_buffer, ms->next_frame, sh_audio->a_in_buffer_len); + } + } + + + static inline + signed short mad_scale(mad_fixed_t sample) + { + /* round */ + sample += (1L << (MAD_F_FRACBITS - 16)); + + /* clip */ + if (sample >= MAD_F_ONE) + sample = MAD_F_ONE - 1; + else if (sample < -MAD_F_ONE) + sample = -MAD_F_ONE; + + /* quantize */ + return sample >> (MAD_F_FRACBITS + 1 - 16); + } + #endif + + + + + int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); static sh_audio_t* dec_audio_sh=NULL; *************** *** 179,188 **** --- 228,248 ---- #else // FFmpeg Audio: sh_audio->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; break; #endif + + #ifdef USE_LIBMAD + case AFM_MAD: + printf(__FILE__ ":%d:mad: setting minimum outputsize\n", __LINE__); + sh_audio->audio_out_minsize=4608; + 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; + break; + #endif } if(!driver) return 0; // allocate audio out buffer: *************** *** 476,485 **** --- 536,576 ---- mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Init OK!\n"); break; } #endif + + #ifdef USE_LIBMAD + case AFM_MAD: + { + printf(__FILE__ ":%d:mad: initialising\n", __LINE__); + mad_frame_init(&mad_frame); + mad_stream_init(&mad_stream); + + printf(__FILE__ ":%d:mad: preparing buffer\n", __LINE__); + mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); + mad_stream_buffer(&mad_stream, (unsigned char*)(sh_audio->a_in_buffer), sh_audio->a_in_buffer_len); + mad_stream_sync(&mad_stream); + mad_synth_init(&mad_synth); + + if(mad_frame_decode(&mad_frame, &mad_stream) == 0) + { + printf(__FILE__ ":%d:mad: post processing buffer\n", __LINE__); + mad_postprocess_buffer(sh_audio, &mad_stream); + } + else + { + printf(__FILE__ ":%d:mad: frame decoding failed\n", __LINE__); + } + + sh_audio->channels=2; // hack + sh_audio->samplerate=mad_frame.header.sfreq; + sh_audio->i_bps=mad_frame.header.bitrate; + printf(__FILE__ ":%d:mad: continuing\n", __LINE__); + break; + } + #endif } if(!sh_audio->channels || !sh_audio->samplerate){ mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_UnknownAudio); driver=0; *************** *** 729,738 **** --- 820,865 ---- } len=size_out; break; } #endif + + #ifdef USE_LIBMAD + case AFM_MAD: + { + mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); + mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); + if(mad_frame_decode(&mad_frame, &mad_stream) == 0) + { + mad_synth_frame(&mad_synth, &mad_frame); + mad_postprocess_buffer(sh_audio, &mad_stream); + + /* and fill buffer */ + + { + int i; + int end_size = mad_synth.pcm.length; + signed short* samples = (signed short*)buf; + if(end_size > maxlen/4) + end_size=maxlen/4; + + for(i=0; ia_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 AFM_MPEG: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame --- 885,904 ---- case AFM_ACM: case AFM_DSHOW: case AFM_HWAC3: sh_audio->a_in_buffer_len=0; // reset ACM/DShow audio buffer break; + + #ifdef USE_LIBMAD + case AFM_MAD: + mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); + mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); + mad_stream_sync(&mad_stream); + mad_postprocess_buffer(sh_audio, &mad_stream); + break; } ! #endif } void skip_audio_frame(sh_audio_t *sh_audio){ switch(sh_audio->codec->driver){ case AFM_MPEG: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame *************** *** 784,791 **** --- 919,938 ---- int skip=sh_audio->i_bps/16; skip=skip&(~3); demux_read_data(sh_audio->ds,NULL,skip); break; } + #ifdef USE_LIBMAD + case AFM_MAD: + { + mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); + mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); + mad_stream_skip(&mad_stream, 2); + mad_stream_sync(&mad_stream); + mad_postprocess_buffer(sh_audio, &mad_stream); + break; + } + #endif + default: ds_fill_buffer(sh_audio->ds); // skip PCM frame } } diff -rC5 MPlayer-0.50/etc/codecs.conf MPlayer-0.50_mad/etc/codecs.conf *** MPlayer-0.50/etc/codecs.conf Sat Oct 6 13:30:07 2001 --- MPlayer-0.50_mad/etc/codecs.conf Thu Oct 18 14:29:59 2001 *************** *** 497,506 **** --- 497,517 ---- format 0x55 driver mp3lib dll "mp3lib (mpglib)" flags seekable + ;MAD library + audiocodec mad + info "MAD MPEG layer-2, layer-3" + status working + comment "Optimized for ARM" + format 0x50 + format 0x55 + driver libmad + dll "libmad" + flags seekable + audiocodec ffmp3 info "FFmpeg layer-123 audio decoder - integer only" status working format 0x50 format 0x55 diff -rC5 MPlayer-0.50/configure MPlayer-0.50_mad/configure *** MPlayer-0.50/configure Sun Oct 7 23:36:29 2001 --- MPlayer-0.50_mad/configure Mon Oct 22 18:29:37 2001 *************** *** 4,13 **** --- 4,16 ---- # MPlayer configurator. (C) 2000 Pontscho/fresh!mindworkz # pontscho@makacs.poliod.hu # # Changes in reversed order: # + # 2001/10/22 by Jeroen Dobbelaere + # - added selection of libmad + # # 2001/08/27 by Johannes Feigl # - added manual selection of language # # 2001/08/22 by Nick Kurshev # - added autodetection of local language *************** *** 156,165 **** --- 159,169 ---- --enable-vorbis build with OggVorbis support [autodetect] --enable-termcap use termcap database for key codes --enable-xmmp use XMMP audio drivers --enable-lirc enable LIRC (remote control) support + --enable-mad enable mad audio support --disable-ossaudio disable OSS sound support [autodetect] --disable-alsa disable alsa sound support [autodetect] --disable-esd disable esd sound support [autodetect] --disable-sunaudio disable Sun sound support [autodetect] *************** *** 191,200 **** --- 195,206 ---- (only needed if autodetection fails) --with-extraincdir=DIR extra headers (png, SDL) are in DIR (only needed if autodetection fails) --size-x=SIZE default screen width --size-y=SIZE default screen height + --with-madlibdir=DIR libmad library files are in DIR + --with-madincdir=DIR libmad header is in DIR EOF exit 0 fi done # for parm in ... *************** *** 246,255 **** --- 252,267 ---- _extralibdir=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'` ;; --with-extraincdir=*) _extraincdir=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'` ;; + --with-madlibdir=*) + _madlibdir=-L`echo $ac_option | cut -d '=' -f 2` + ;; + --with-madincdir=*) + _madincdir=-I`echo $ac_option | cut -d '=' -f 2` + ;; esac done # LGB: Some inital help *************** *** 1243,1252 **** --- 1255,1270 ---- _streaming=yes ;; --enable-divx4) _divx4linux=yes ;; + --enable-mad) + _madlibrary=yes + ;; + --disable-mad) + _madlibrary=no + ;; --disable-css) _css=no ;; --disable-png) _png=no *************** *** 1569,1578 **** --- 1587,1597 ---- echo "Checking for Sun Audio ... $_sun_audio" echo "Checking for Sun mediaLib ... $_mlib" echo "Checking for DeCSS support ... $_css" echo "Checking for DVDread support ... $_dvdread" echo "Checking for PNG support ... $_png" + echo "Checking for mad support ... $_madlibrary" echo "Checking for OggVorbis support ... $_vorbis" echo "Checking for Win32 DLL support ... $_win32dll" echo "Checking for DirectShow ... $_dshow" # check if compiler supports C++ and C++-libs are installed correctly *************** *** 1839,1848 **** --- 1858,1871 ---- if [ $_png = yes ]; then _libpng='-lpng -lz' fi + if [ $_madlibrary = yes ]; then + _libmad='-lmad' + fi + if [ $_vorbis = yes ]; then _vorbis='#define HAVE_OGGVORBIS' _libvorbis='-lvorbis -lm' else _vorbis='#undef HAVE_OGGVORBIS' *************** *** 2001,2010 **** --- 2024,2038 ---- _vosrc=$_vosrc' vo_png.c' else _png='#undef HAVE_PNG' fi + if [ $_madlibrary = yes ]; then + _madlibrary='#define USE_LIBMAD' + else + _madlibrary='#undef USE_LIBMAD' + fi if [ $_mlib = yes ]; then _mlibdef='#define HAVE_MLIB' _mlibinc="-I$_mlibdir/include" _mliblib="-L$_mlibdir/lib -R$_mlibdir/lib -lmlib" *************** *** 2168,2178 **** EXTRA_INC=$_extraincdir $_gtkinc WIN32_PATH=-DWIN32_PATH=\\"$_win32libdir\\" X11_INC=$_x11incdir X11DIR=$_x11libdir ! X_LIBS=$_x11libdir $_extralibdir $_gllib $_ggilib $_sdllib $_dgalib $_x11lib $_xvlib $_vmlib $_svgalib $_libpng $_socklib $_aalib $_libvorbis TERMCAP_LIB=$_libtermcap XMM_LIBS = $_xmmplibs LIRC_LIBS = $_lirclibs CSS_USE=$_css --- 2196,2206 ---- EXTRA_INC=$_extraincdir $_gtkinc WIN32_PATH=-DWIN32_PATH=\\"$_win32libdir\\" X11_INC=$_x11incdir X11DIR=$_x11libdir ! X_LIBS=$_x11libdir $_extralibdir $_gllib $_ggilib $_sdllib $_dgalib $_x11lib $_xvlib $_vmlib $_svgalib $_libpng $_socklib $_aalib $_libvorbis $_libmad TERMCAP_LIB=$_libtermcap XMM_LIBS = $_xmmplibs LIRC_LIBS = $_lirclibs CSS_USE=$_css *************** *** 2191,2200 **** --- 2219,2230 ---- STREAM_SRCS = $_streamingsrcs DECORE_LIBS = $_decorelibs DIVX4LINUX=$_divx4linux MLIB_INC = $_mlibinc MLIB_LIB = $_mliblib + MADLIB_INC = $_madincdir + MADLIB_LIB = $_madlibdir # --- Some stuff for autoconfigure ---- $_target_arch $_confcygwin TARGET_CPU=$iproc *************** *** 2370,2379 **** --- 2400,2412 ---- /* enable PNG support */ $_png /* enable OggVorbis support */ $_vorbis + + /* libmad support */ + $_madlibrary $_streamingdef /* Extension defines */ $_3dnowm // only define if you have 3DNOW (AMD k6-2, AMD Athlon, iDT WinChip, etc.) diff -rC5 MPlayer-0.50/Makefile MPlayer-0.50_mad/Makefile *** MPlayer-0.50/Makefile Fri Oct 5 15:39:43 2001 --- MPlayer-0.50_mad/Makefile Mon Oct 22 17:39:59 2001 *************** *** 16,27 **** #prefix = /usr/local BINDIR = ${prefix}/bin # BINDIR = /usr/local/bin SRCS = mp_msg.c open.c parse_es.c ac3-iec958.c find_sub.c aviprint.c dec_audio.c dec_video.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demux_mov.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c xa/rle8.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c $(STREAM_SRCS) OBJS = $(SRCS:.c=.o) ! CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo $(CSS_INC) $(EXTRA_INC) # -Wall ! A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3 $(ALSA_LIB) $(ESD_LIB) VO_LIBS = -Llibvo -lvo $(MLIB_LIB) $(X_LIBS) PARTS = mp3lib libac3 libmpeg2 opendivx libavcodec encore libvo libao2 drivers drivers/syncfb ifeq ($(GUI),yes) PARTS += Gui --- 16,27 ---- #prefix = /usr/local BINDIR = ${prefix}/bin # BINDIR = /usr/local/bin SRCS = mp_msg.c open.c parse_es.c ac3-iec958.c find_sub.c aviprint.c dec_audio.c dec_video.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demux_mov.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c xa/rle8.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c $(STREAM_SRCS) OBJS = $(SRCS:.c=.o) ! CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo $(CSS_INC) $(MADLIB_INC) $(EXTRA_INC) # -Wall ! A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3 $(ALSA_LIB) $(ESD_LIB) $(MADLIB_LIB) VO_LIBS = -Llibvo -lvo $(MLIB_LIB) $(X_LIBS) PARTS = mp3lib libac3 libmpeg2 opendivx libavcodec encore libvo libao2 drivers drivers/syncfb ifeq ($(GUI),yes) PARTS += Gui