[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[501] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-12-03 15:31:02
|
Revision: 501 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=501&view=rev Author: nickols_k Date: 2012-12-03 15:30:49 +0000 (Mon, 03 Dec 2012) Log Message: ----------- Next step towards object-oriented progarming: hide decoder private from demuxer. Note: disabled demux_ogg - requires to be fully redesigned. Project lost stability and some decoders (like ad_lavc) became unstable (mainly due: 'any_t* opaque' which avoids type controls from side of g++). Modified Paths: -------------- mplayerxp/configure mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/ad.h mplayerxp/libmpcodecs/ad_a52.cpp mplayerxp/libmpcodecs/ad_acm.cpp mplayerxp/libmpcodecs/ad_dca.cpp mplayerxp/libmpcodecs/ad_dmo.cpp mplayerxp/libmpcodecs/ad_dshow.cpp mplayerxp/libmpcodecs/ad_dvdpcm.cpp mplayerxp/libmpcodecs/ad_faad.cpp mplayerxp/libmpcodecs/ad_hwac3.cpp mplayerxp/libmpcodecs/ad_internal.h mplayerxp/libmpcodecs/ad_lavc.cpp mplayerxp/libmpcodecs/ad_libdv.cpp mplayerxp/libmpcodecs/ad_mp3.cpp mplayerxp/libmpcodecs/ad_null.cpp mplayerxp/libmpcodecs/ad_pcm.cpp mplayerxp/libmpcodecs/ad_qtaudio.cpp mplayerxp/libmpcodecs/ad_real.cpp mplayerxp/libmpcodecs/ad_twin.cpp mplayerxp/libmpcodecs/ad_vorbis.cpp mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_audio.h mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpcodecs/vd.h mplayerxp/libmpcodecs/vd_divx4.cpp mplayerxp/libmpcodecs/vd_dmo.cpp mplayerxp/libmpcodecs/vd_dshow.cpp mplayerxp/libmpcodecs/vd_huffyuv.cpp mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpcodecs/vd_lavc.cpp mplayerxp/libmpcodecs/vd_libdv.cpp mplayerxp/libmpcodecs/vd_libmpeg2.cpp mplayerxp/libmpcodecs/vd_mpegpes.cpp mplayerxp/libmpcodecs/vd_null.cpp mplayerxp/libmpcodecs/vd_nuv.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpcodecs/vd_raw.cpp mplayerxp/libmpcodecs/vd_real.cpp mplayerxp/libmpcodecs/vd_theora.cpp mplayerxp/libmpcodecs/vd_vfw.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpcodecs/vd_xvid.cpp mplayerxp/libmpdemux/stheader.h mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/configure 2012-12-03 15:30:49 UTC (rev 501) @@ -79,7 +79,6 @@ "libdvdnav|build with libdvdnav support|http://dvd.sourceforge.net", "libdv|build with libdv support|http://libdv.sourceforge.net/", "libvcd|build with libvcd support|http://www.gnu.org/software/vcdimager", - "libvorbis|build with libvorbis support|http://www.vorbis.com", "libtheora|build with libtheora support|http://www.theora.org", "libbz2|build with libbz2 support|http://www.bzip.org" ) @@ -93,6 +92,7 @@ "sdl|build with SDL video and audio output|http://www.libsdl.org", "sdl_image|build with SDL_image for screenshots|http://www.libsdl.org/projects/SDL_image", "im_sure_that_must_have_streaming| the key to unlock streaming" + "libvorbis|build with libvorbis support|http://www.vorbis.com", ) AUTOCONF_LIST=( Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -87,12 +87,12 @@ return NULL; } -const audio_probe_t* afm_probe_driver(sh_audio_t *sh) { +const audio_probe_t* afm_probe_driver(ad_private_t*ctx,sh_audio_t *sh) { unsigned i; const audio_probe_t* probe; for (i=0; mpcodecs_ad_drivers[i] != &mpcodecs_ad_null; i++) { MSG_V("Probing: %s\n",mpcodecs_ad_drivers[i]->info->driver_name); - if((probe=mpcodecs_ad_drivers[i]->probe(sh,sh->wtag))!=NULL) { + if((probe=mpcodecs_ad_drivers[i]->probe(ctx,sh->wtag))!=NULL) { MSG_V("Driver: %s supports these outfmt for 0x%X wtag:\n" ,mpcodecs_ad_drivers[i]->info->driver_name,sh->wtag); for(i=0;i<Audio_MaxOutSample;i++) { Modified: mplayerxp/libmpcodecs/ad.h =================================================================== --- mplayerxp/libmpcodecs/ad.h 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad.h 2012-12-03 15:30:49 UTC (rev 501) @@ -41,20 +41,21 @@ }audio_probe_t; /* interface of video decoder drivers */ +struct ad_private_t; typedef struct ad_functions_s { const ad_info_t* info; const config_t* options;/**< Optional: MPlayerXP's option related */ - const audio_probe_t*(* __FASTCALL__ probe)(sh_audio_t *,uint32_t wtag); - MPXP_Rc (* __FASTCALL__ preinit)(sh_audio_t *); - MPXP_Rc (* __FASTCALL__ init)(sh_audio_t *sh); - void (* __FASTCALL__ uninit)(sh_audio_t *sh); - MPXP_Rc (*control_ad)(sh_audio_t *sh,int cmd,any_t* arg, ...); - unsigned (* __FASTCALL__ decode)(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts); + const audio_probe_t*(* __FASTCALL__ probe)(ad_private_t *,uint32_t wtag); + ad_private_t* (* __FASTCALL__ preinit)(sh_audio_t *); + MPXP_Rc (* __FASTCALL__ init)(ad_private_t *ctx); + void (* __FASTCALL__ uninit)(ad_private_t *ctx); + MPXP_Rc (*control_ad)(ad_private_t *ctx,int cmd,any_t* arg, ...); + unsigned (* __FASTCALL__ decode)(ad_private_t *ctx,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts); } ad_functions_t; extern const ad_functions_t* afm_find_driver(const char *name); -extern const audio_probe_t* afm_probe_driver(sh_audio_t* sh); +extern const audio_probe_t* afm_probe_driver(ad_private_t*ctx,sh_audio_t* sh); #define FIX_APTS(sh_audio,pts,in_size) (sh_audio->i_bps?((float)(pts)+(float)(in_size)/(float)sh_audio->i_bps):((float)(pts))) #endif Modified: mplayerxp/libmpcodecs/ad_a52.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_a52.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_a52.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -22,9 +22,10 @@ #include "libao2/audio_out.h" #include "postproc/af.h" -typedef struct priv_s { +struct ad_private_t { + sh_audio_t* sh; float last_pts; -}priv_t; +}; #define MAX_AC3_FRAME 3840 @@ -55,21 +56,22 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { unsigned i; + UNUSED(ctx); for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) return &probes[i]; return NULL; } -int a52_fillbuff(sh_audio_t *sh_audio,float *pts){ +int a52_fillbuff(ad_private_t *priv,float *pts){ int length=0; int flags=0; int sample_rate=0; int bit_rate=0; float apts=0.,null_pts; - priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; sh_audio->a_in_buffer_len=0; /* sync frame:*/ @@ -126,8 +128,9 @@ return (flags&A52_LFE) ? (channels+1) : channels; } -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { + ad_private_t* ctx=new(zeromem) ad_private_t; /* Dolby AC3 audio: */ /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ #ifdef WORDS_BIGENDIAN @@ -145,12 +148,13 @@ } sh->audio_out_minsize=mp_conf.ao_channels*afmt2bps(sh->afmt)*256*6; sh->audio_in_minsize=MAX_AC3_FRAME; - sh->context=mp_malloc(sizeof(priv_t)); - return MPXP_Ok; + ctx->sh=sh; + return ctx; } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t *ctx) { + sh_audio_t* sh_audio = ctx->sh; sample_t level=1, bias=384; float pts; int flags=0; @@ -161,12 +165,12 @@ MSG_ERR("A52 init failed\n"); return MPXP_False; } - if(a52_fillbuff(sh_audio,&pts)<0){ + if(a52_fillbuff(ctx,&pts)<0){ MSG_ERR("A52 sync failed\n"); return MPXP_False; } /* 'a52 cannot upmix' hotfix:*/ - a52_printinfo(sh_audio); + a52_printinfo(ctx->sh); sh_audio->nch=mp_conf.ao_channels; while(sh_audio->nch>0){ switch(sh_audio->nch){ @@ -202,13 +206,14 @@ return MPXP_Ok; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *ctx) { - delete sh->context; + delete ctx; } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *ctx,int cmd,any_t* arg, ...) { + sh_audio_t* sh = ctx->sh; UNUSED(arg); switch(cmd) { case ADCTRL_RESYNC_STREAM: @@ -216,7 +221,7 @@ return MPXP_True; case ADCTRL_SKIP_FRAME: { float pts; - a52_fillbuff(sh,&pts); // skip AC3 frame + a52_fillbuff(ctx,&pts); // skip AC3 frame return MPXP_True; } default: @@ -225,18 +230,18 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *ctx,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { + sh_audio_t* sh_audio = ctx->sh; sample_t level=1, bias=384; int flags=mpxp_a52_flags|A52_ADJUST_LEVEL; unsigned i; unsigned len=0; UNUSED(minlen); UNUSED(maxlen); - priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); if(!sh_audio->a_in_buffer_len) { - if(a52_fillbuff(sh_audio,pts)<0) return len; /* EOF */ - } else *pts=priv->last_pts; + if(a52_fillbuff(ctx,pts)<0) return len; /* EOF */ + } else *pts=ctx->last_pts; sh_audio->a_in_buffer_len=0; if (a52_frame (mpxp_a52_state, (uint8_t*)sh_audio->a_in_buffer, &flags, &level, bias)){ MSG_WARN("a52: error decoding frame\n"); Modified: mplayerxp/libmpcodecs/ad_acm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_acm.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_acm.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -26,19 +26,20 @@ LIBAD_EXTERN(msacm) -typedef struct priv_s { +struct ad_private_t { float pts; WAVEFORMATEX o_wf; // out format HACMSTREAM srcstream; // handle -}priv_t; + sh_audio_t* sh; +}; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* p,uint32_t wtag) { return NULL; } -static int init_acm_audio_codec(sh_audio_t *sh_audio){ +static int init_acm_audio_codec(ad_private_t *priv){ + sh_audio_t* sh_audio = priv->sh; HRESULT ret; WAVEFORMATEX *in_fmt=sh_audio->wf; unsigned int srcsize=0; - priv_t*priv=reinterpret_cast<priv_t*>(sh_audio->context); MSG_V("======= Win32 (ACM) AUDIO Codec init =======\n"); @@ -101,10 +102,10 @@ return 1; } -static int close_acm_audio_codec(sh_audio_t *sh_audio) +static int close_acm_audio_codec(ad_private_t *priv) { + sh_audio_t* sh_audio = priv->sh; HRESULT ret; - priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); ret = acmStreamClose(priv->srcstream, 0); @@ -115,7 +116,7 @@ case ACMERR_CANCELED: MSG_DBG2( "ACM_Decoder: stream busy, waiting..\n"); sleep(100); - return(close_acm_audio_codec(sh_audio)); + return(close_acm_audio_codec(priv)); case ACMERR_UNPREPARED: case ACMERR_NOTPOSSIBLE: return(0); @@ -127,10 +128,11 @@ return(1); } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t *priv) { + sh_audio_t* sh_audio = priv->sh; float pts; - int ret=decode(sh_audio,reinterpret_cast<unsigned char*>(sh_audio->a_buffer),4096,sh_audio->a_buffer_size,&pts); + int ret=decode(priv,reinterpret_cast<unsigned char*>(sh_audio->a_buffer),4096,sh_audio->a_buffer_size,&pts); if(ret<0){ MSG_INFO("ACM decoding error: %d\n",ret); return MPXP_False; @@ -139,29 +141,31 @@ return MPXP_Ok; } -MPXP_Rc preinit(sh_audio_t *sh_audio) +ad_private_t* preinit(sh_audio_t *sh_audio) { /* Win32 ACM audio codec: */ - priv_t *priv; - if(!(priv=new(zeromem) priv_t)) return MPXP_False; - sh_audio->context=priv; - if(!init_acm_audio_codec(sh_audio)){ + ad_private_t *priv; + if(!(priv=new(zeromem) ad_private_t)) return NULL; + priv->sh = sh_audio; + if(!init_acm_audio_codec(priv)){ MSG_ERR(MSGTR_ACMiniterror); - return MPXP_False; + delete priv; + return NULL; } MSG_V("INFO: Win32/ACM init OK!\n"); - return MPXP_Ok; + return priv; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *p) { - close_acm_audio_codec(sh); - delete sh->context; + close_acm_audio_codec(p); + delete p; } -MPXP_Rc control_ad(sh_audio_t *sh_audio,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { - int skip; + sh_audio_t* sh_audio = priv->sh; + int skip; switch(cmd) { // case ADCTRL_RESYNC_STREAM: // sh_audio->a_in_buffer_len=0;/* reset ACM/DShow audio buffer */ @@ -182,13 +186,13 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { + sh_audio_t* sh_audio = priv->sh; ACMSTREAMHEADER ash; HRESULT hr; DWORD srcsize=0; DWORD len=minlen; - priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); acmStreamSize(priv->srcstream,len , &srcsize, ACM_STREAMSIZEF_DESTINATION); MSG_V("acm says: srcsize=%ld (bufflen=%d size=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,len); Modified: mplayerxp/libmpcodecs/ad_dca.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dca.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_dca.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -28,11 +28,11 @@ uint32_t mpxp_dca_accel=0; uint32_t mpxp_dca_flags=0; -typedef struct priv_s { +struct ad_private_t { float last_pts; -}priv_t; + sh_audio_t* sh; +}; - static const ad_info_t info = { "DTS Coherent Acoustics", "libdca", @@ -58,7 +58,8 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { + UNUSED(ctx); unsigned i; for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) @@ -66,13 +67,13 @@ return NULL; } -int dca_fillbuff(sh_audio_t *sh_audio,float *pts){ +int dca_fillbuff(ad_private_t *priv,float *pts){ int length=0,flen=0; int flags=0; int sample_rate=0; int bit_rate=0; float apts=0.,null_pts; - priv_t *priv=reinterpret_cast<priv_t*>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; sh_audio->a_in_buffer_len=0; /* sync frame:*/ @@ -125,8 +126,7 @@ return (flags&DCA_LFE) ? (channels+1) : channels; } - -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { /* DTS audio: however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ @@ -146,12 +146,14 @@ } sh->audio_out_minsize=mp_conf.ao_channels*afmt2bps(sh->afmt)*256*8; sh->audio_in_minsize=MAX_AC5_FRAME; - sh->context=mp_malloc(sizeof(priv_t)); - return MPXP_Ok; + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + return priv; } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t *priv) { + sh_audio_t* sh_audio = priv->sh; sample_t level=1, bias=384; float pts; int flags=0; @@ -162,7 +164,7 @@ MSG_ERR("dca init failed\n"); return MPXP_False; } - if(dca_fillbuff(sh_audio,&pts)<0){ + if(dca_fillbuff(priv,&pts)<0){ MSG_ERR("dca sync failed\n"); return MPXP_False; } @@ -202,13 +204,14 @@ return MPXP_Ok; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *ctx) { - delete sh->context; + delete ctx; } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { + sh_audio_t* sh = priv->sh; UNUSED(arg); switch(cmd) { case ADCTRL_RESYNC_STREAM: @@ -216,7 +219,7 @@ return MPXP_True; case ADCTRL_SKIP_FRAME: { float pts; - dca_fillbuff(sh,&pts); // skip AC3 frame + dca_fillbuff(priv,&pts); // skip AC3 frame return MPXP_True; } default: @@ -225,16 +228,16 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { sample_t level=1, bias=384; unsigned i,nblocks,flags=mpxp_dca_flags|DCA_ADJUST_LEVEL; unsigned len=0; - priv_t *priv=reinterpret_cast<priv_t *>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; UNUSED(minlen); UNUSED(maxlen); if(!sh_audio->a_in_buffer_len) { - if(dca_fillbuff(sh_audio,pts)<0) return len; /* EOF */ + if(dca_fillbuff(priv,pts)<0) return len; /* EOF */ } else *pts=priv->last_pts; sh_audio->a_in_buffer_len=0; Modified: mplayerxp/libmpcodecs/ad_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dmo.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_dmo.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -28,30 +28,31 @@ #include "loader/dmo/DMO_AudioDecoder.h" -typedef struct dmo_priv_s { +struct ad_private_t { float pts; DMO_AudioDecoder* ds_adec; -}priv_t; + sh_audio_t* sh; +}; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* p,uint32_t wtag) { return NULL; } -static MPXP_Rc init(sh_audio_t *sh) +static MPXP_Rc init(ad_private_t *p) { - UNUSED(sh); + UNUSED(p); return MPXP_Ok; } -static MPXP_Rc preinit(sh_audio_t *sh_audio) +static ad_private_t* preinit(sh_audio_t *sh_audio) { - priv_t*priv; + ad_private_t*priv; int chans=(mp_conf.ao_channels==sh_audio->wf->nChannels) ? mp_conf.ao_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1); - if(!(priv=new(zeromem) priv_t)) return MPXP_False; - sh_audio->context=priv; + if(!(priv=new(zeromem) ad_private_t)) return NULL; + priv->sh=sh_audio; if(!(priv->ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll_name,&sh_audio->codec->guid,sh_audio->wf,chans))) { MSG_ERR(MSGTR_MissingDLLcodec,sh_audio->codec->dll_name); - delete sh_audio->context; - return MPXP_False; + delete priv; + return NULL; } sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; sh_audio->nch=chans; @@ -60,18 +61,18 @@ if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; sh_audio->audio_out_minsize=4*16384; MSG_V("INFO: Win32/DMO audio codec init OK!\n"); - return MPXP_Ok; + return priv; } -static void uninit(sh_audio_t *sh) +static void uninit(ad_private_t *priv) { - priv_t*priv = reinterpret_cast<priv_t*>(sh->context); DMO_AudioDecoder_Destroy(priv->ds_adec); delete priv; } -static MPXP_Rc control_ad(sh_audio_t *sh_audio,int cmd,any_t* arg, ...) +static MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { + sh_audio_t* sh_audio = priv->sh; int skip; UNUSED(arg); switch(cmd) { @@ -89,9 +90,9 @@ return MPXP_Unknown; } -static unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +static unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { - priv_t* priv = reinterpret_cast<priv_t*>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; unsigned len=0; UNUSED(minlen); { Modified: mplayerxp/libmpcodecs/ad_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dshow.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_dshow.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -23,28 +23,29 @@ LIBAD_EXTERN(dshow) -typedef struct dshow_priv_s { +struct ad_private_t { float pts; DS_AudioDecoder* ds_adec; -}priv_t; + sh_audio_t* sh; +}; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* p,uint32_t wtag) { return NULL; } -MPXP_Rc init(sh_audio_t *sh) +MPXP_Rc init(ad_private_t *p) { - UNUSED(sh); + UNUSED(p); return MPXP_Ok; } -MPXP_Rc preinit(sh_audio_t *sh_audio) +ad_private_t* preinit(sh_audio_t *sh_audio) { - priv_t *priv; - if(!(priv=new(zeromem) priv_t)) return MPXP_False; - sh_audio->context=priv; + ad_private_t *priv; + if(!(priv=new(zeromem) ad_private_t)) return NULL; + priv->sh = sh_audio; if(!(priv->ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll_name,&sh_audio->codec->guid,sh_audio->wf))) { MSG_ERR(MSGTR_MissingDLLcodec,sh_audio->codec->dll_name); - delete sh_audio->context; - return MPXP_False; + delete priv; + return NULL; } sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; sh_audio->nch=sh_audio->wf->nChannels; @@ -53,18 +54,18 @@ if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; sh_audio->audio_out_minsize=16384; MSG_V("INFO: Win32/DShow init OK!\n"); - return MPXP_Ok; + return priv; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *priv) { - priv_t* priv = reinterpret_cast<priv_t*>(sh->context); DS_AudioDecoder_Destroy(priv->ds_adec); delete priv; } -MPXP_Rc control_ad(sh_audio_t *sh_audio,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *p,int cmd,any_t* arg, ...) { + sh_audio_t* sh_audio = p->sh; int skip; UNUSED(arg); switch(cmd) { @@ -87,9 +88,9 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { - priv_t* priv = reinterpret_cast<priv_t*>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; unsigned len=0; UNUSED(minlen); { unsigned size_in=0; Modified: mplayerxp/libmpcodecs/ad_dvdpcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -8,6 +8,10 @@ #include "osdep/bswap.h" #include "libao2/afmt.h" +struct ad_private_t { + sh_audio_t* sh; +}; + static const ad_info_t info = { "Uncompressed DVD/VOB LPCM audio decoder", "dvdpcm", @@ -26,7 +30,8 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { + UNUSED(ctx); unsigned i; for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) @@ -34,9 +39,10 @@ return NULL; } -MPXP_Rc init(sh_audio_t *sh) +MPXP_Rc init(ad_private_t *priv) { /* DVD PCM Audio:*/ + sh_audio_t* sh = priv->sh; sh->i_bps = 0; if(sh->codecdata_len==3){ // we have LPCM header: @@ -72,19 +78,22 @@ return MPXP_Ok; } -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { sh->audio_out_minsize=2048; - return MPXP_Ok; + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + return priv; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *priv) { - UNUSED(sh); + delete priv; } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { + sh_audio_t* sh = priv->sh; int skip; UNUSED(arg); switch(cmd) { @@ -101,8 +110,9 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { + sh_audio_t* sh_audio = priv->sh; unsigned j; unsigned len; float null_pts; Modified: mplayerxp/libmpcodecs/ad_faad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_faad.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_faad.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -35,9 +35,10 @@ LIBAD_EXTERN(faad) -typedef struct faad_priv_s { - float pts; -}priv_t; +struct ad_private_t { + float pts; + sh_audio_t* sh; +}; static const audio_probe_t probes[] = { { "faad", "libfaad", 0xFF, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE} }, @@ -56,8 +57,8 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - UNUSED(sh); +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { + UNUSED(ctx); unsigned i; for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) @@ -178,16 +179,22 @@ } -static MPXP_Rc preinit(sh_audio_t *sh) +static ad_private_t* preinit(sh_audio_t *sh) { sh->audio_out_minsize=8192*FAAD_MAX_CHANNELS; sh->audio_in_minsize=FAAD_BUFFLEN; - if(!(sh->context=mp_malloc(sizeof(priv_t)))) return MPXP_False; - return load_dll("libfaad"SLIBSUFFIX); + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + if(load_dll("libfaad"SLIBSUFFIX)!=MPXP_Ok) { + delete priv; + return NULL; + } + return priv; } -static MPXP_Rc init(sh_audio_t *sh) +static MPXP_Rc init(ad_private_t *priv) { + sh_audio_t* sh = priv->sh; unsigned long NeAAC_samplerate; unsigned char NeAAC_channels; float pts; @@ -268,24 +275,24 @@ return MPXP_Ok; } -static void uninit(sh_audio_t *sh) +static void uninit(ad_private_t *priv) { MSG_V("FAAD: Closing decoder!\n"); NeAACDecClose(NeAAC_hdec); - delete sh->context; + delete priv; } -static MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +static MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { - UNUSED(sh); + UNUSED(priv); UNUSED(cmd); UNUSED(arg); return MPXP_Unknown; } -static unsigned decode(sh_audio_t *sh,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +static unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { - priv_t *priv=reinterpret_cast<priv_t*>(sh->context); + sh_audio_t* sh = priv->sh; int j = 0; unsigned len = 0; any_t*NeAAC_sample_buffer; Modified: mplayerxp/libmpcodecs/ad_hwac3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -18,9 +18,10 @@ #define IEC61937_DATA_TYPE_AC3 1 -typedef struct priv_s { +struct ad_private_t { + sh_audio_t* sh; float last_pts; -}priv_t; +}; struct hwac3info { unsigned bitrate, framesize, samplerate, bsmod; @@ -142,7 +143,7 @@ extern a52_state_t *mpxp_a52_state; extern uint32_t mpxp_a52_accel; extern uint32_t mpxp_a52_flags; -int a52_fillbuff(sh_audio_t *sh_audio,float *pts); +int a52_fillbuff(ad_private_t *sh_audio,float *pts); static const ad_info_t info = { "AC3/DTS pass-through S/PDIF", @@ -170,8 +171,9 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { unsigned i; + UNUSED(ctx); for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) return &probes[i]; @@ -179,19 +181,20 @@ } -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { /* Dolby AC3 audio: */ - mpcodecs_ad_a52.preinit(sh); + ad_private_t* ctx=mpcodecs_ad_a52.preinit(sh); sh->audio_out_minsize=4*256*6; sh->audio_in_minsize=3840; sh->nch=2; sh->afmt=AFMT_AC3; - return MPXP_Ok; + return ctx; } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t *ctx) { + sh_audio_t* sh_audio = ctx->sh; /* Dolby AC3 passthrough:*/ float pts; mpxp_a52_state=a52_init (mpxp_a52_accel); /* doesn't require mmx optimzation */ @@ -199,7 +202,7 @@ MSG_ERR("A52 init failed\n"); return MPXP_False; } - if(a52_fillbuff(sh_audio,&pts)<0) { + if(a52_fillbuff(ctx,&pts)<0) { MSG_ERR("A52 sync failed\n"); return MPXP_False; } @@ -217,13 +220,14 @@ return MPXP_Ok; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *ctx) { - mpcodecs_ad_a52.uninit(sh); + mpcodecs_ad_a52.uninit(ctx); } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *ctx,int cmd,any_t* arg, ...) { + sh_audio_t* sh = ctx->sh; UNUSED(arg); switch(cmd) { case ADCTRL_RESYNC_STREAM: @@ -231,7 +235,7 @@ return MPXP_True; case ADCTRL_SKIP_FRAME: { float pts; - a52_fillbuff(sh,&pts); // skip AC3 frame + a52_fillbuff(ctx,&pts); // skip AC3 frame return MPXP_True; } default: @@ -240,13 +244,14 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *ctx,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { + sh_audio_t* sh_audio = ctx->sh; unsigned len=0; UNUSED(minlen); UNUSED(maxlen); if(!sh_audio->a_in_buffer_len) - if((int)(len=a52_fillbuff(sh_audio,pts))<0) return 0; /*EOF*/ + if((int)(len=a52_fillbuff(ctx,pts))<0) return 0; /*EOF*/ sh_audio->a_in_buffer_len=0; len = ac3_iec958_build_burst(len, 0x01, 1, (unsigned char *)sh_audio->a_in_buffer, buf); return len; Modified: mplayerxp/libmpcodecs/ad_internal.h =================================================================== --- mplayerxp/libmpcodecs/ad_internal.h 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_internal.h 2012-12-03 15:30:49 UTC (rev 501) @@ -11,12 +11,12 @@ #include "ad_msg.h" -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag); -static MPXP_Rc __FASTCALL__ init(sh_audio_t *sh); -static MPXP_Rc __FASTCALL__ preinit(sh_audio_t *sh); -static void __FASTCALL__ uninit(sh_audio_t *sh); -static MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...); -static unsigned __FASTCALL__ decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts); +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag); +static MPXP_Rc __FASTCALL__ init(ad_private_t *ctx); +static ad_private_t* __FASTCALL__ preinit(sh_audio_t *ctx); +static void __FASTCALL__ uninit(ad_private_t *ctx); +static MPXP_Rc control_ad(ad_private_t *ctx,int cmd,any_t* arg, ...); +static unsigned __FASTCALL__ decode(ad_private_t *ctx,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts); #define LIBAD_EXTERN(x) extern const ad_functions_t mpcodecs_ad_##x = {\ &info,\ Modified: mplayerxp/libmpcodecs/ad_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_lavc.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_lavc.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -18,27 +18,24 @@ #include "mp_conf_lavc.h" #include "codecs_ld.h" -typedef struct priv_s { - AVCodecContext *lavc_ctx; - audio_probe_t* probe; -}priv_t; +struct ad_private_t { + AVCodecContext* lavc_ctx; + sh_audio_t* sh; +}; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* priv,uint32_t wtag) { unsigned i; audio_probe_t* acodec = NULL; const char *what="AVCodecID"; - priv_t* priv=reinterpret_cast<priv_t*>(sh->context); enum AVCodecID id = ff_codec_get_id(ff_codec_wav_tags,wtag); if (id <= 0) { prn_err: MSG_ERR("Cannot find %s for '0x%X' tag! Try force -ac option\n" ,what - ,sh->wtag); + ,wtag); return NULL; } if(!priv){ - priv=new(zeromem) priv_t; - sh->context=priv; // avcodec_init(); avcodec_register_all(); } @@ -54,12 +51,12 @@ if(codec->sample_fmts[i]==-1) break; acodec->sample_fmt[i]=ff_codec_get_tag(ff_codec_wav_tags,id); } - priv->probe=acodec; return acodec; } -struct codecs_st* __FASTCALL__ find_lavc_audio(sh_audio_t* sh) { - const audio_probe_t* aprobe=probe(sh,sh->wtag); +struct codecs_st* __FASTCALL__ find_lavc_audio(ad_private_t* priv) { + sh_audio_t* sh = priv->sh; + const audio_probe_t* aprobe=probe(priv,sh->wtag); struct codecs_st* acodec = NULL; if(aprobe) { acodec=new(zeromem) struct codecs_st; @@ -88,22 +85,22 @@ LIBAD_EXTERN(lavc) -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { + ad_private_t* priv = new(zeromem) ad_private_t; sh->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; - return MPXP_Ok; + priv->sh = sh; + return priv; } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t *priv) { int x; float pts; AVCodec *lavc_codec=NULL; - priv_t* priv=reinterpret_cast<priv_t*>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; MSG_V("LAVC audio codec\n"); if(!priv){ - priv=new(zeromem) priv_t; - sh_audio->context=priv; // avcodec_init(); avcodec_register_all(); } @@ -145,7 +142,7 @@ MSG_V("INFO: libavcodec init OK!\n"); // Decode at least 1 byte: (to get header filled) - x=decode(sh_audio,reinterpret_cast<unsigned char*>(sh_audio->a_buffer),1,sh_audio->a_buffer_size,&pts); + x=decode(priv,reinterpret_cast<unsigned char*>(sh_audio->a_buffer),1,sh_audio->a_buffer_size,&pts); if(x>0) sh_audio->a_buffer_len=x; sh_audio->nch=priv->lavc_ctx->channels; @@ -169,21 +166,17 @@ return MPXP_Ok; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *priv) { - priv_t* priv=reinterpret_cast<priv_t*>(sh->context); avcodec_close(priv->lavc_ctx); if (priv->lavc_ctx->extradata) delete priv->lavc_ctx->extradata; delete priv->lavc_ctx; - if(priv->probe) { delete priv->probe->codec_dll; delete priv->probe; } delete priv; - sh->context=NULL; } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { UNUSED(arg); - priv_t* priv = reinterpret_cast<priv_t*>(sh->context); switch(cmd){ case ADCTRL_RESYNC_STREAM: avcodec_flush_buffers(priv->lavc_ctx); @@ -193,9 +186,9 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { - priv_t* priv = reinterpret_cast<priv_t*>(sh_audio->context); + sh_audio_t* sh_audio = priv->sh; unsigned char *start=NULL; int y; unsigned len=0; Modified: mplayerxp/libmpcodecs/ad_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_libdv.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_libdv.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -20,6 +20,12 @@ #include "osdep/bswap.h" #include "ad_internal.h" +struct ad_private_t { + dv_decoder_t* decoder; + int16_t* audioBuffers[4]; + sh_audio_t* sh; +}; + static const ad_info_t info = { "Raw DV Audio Decoder", "libdv", @@ -38,7 +44,8 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* priv,uint32_t wtag) { + UNUSED(priv); unsigned i; for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) @@ -49,21 +56,18 @@ // defined in vd_libdv.c: dv_decoder_t* init_global_rawdv_decoder(void); -static MPXP_Rc preinit(sh_audio_t *sh_audio) +static ad_private_t* preinit(sh_audio_t *sh_audio) { sh_audio->audio_out_minsize=4*DV_AUDIO_MAX_SAMPLES*2; - return MPXP_Ok; + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh_audio; + return priv; } -typedef struct libdv_priv_s { - dv_decoder_t* decoder; - int16_t *audioBuffers[4]; -}priv_t; - -static MPXP_Rc init(sh_audio_t *sh) +static MPXP_Rc init(ad_private_t *priv) { unsigned i; - priv_t *priv; + sh_audio_t* sh = priv->sh; WAVEFORMATEX *h=sh->wf; if(!h) return MPXP_False; @@ -72,42 +76,38 @@ sh->nch=h->nChannels; sh->rate=h->nSamplesPerSec; sh->afmt=bps2afmt((h->wBitsPerSample+7)/8); - priv = new(zeromem) priv_t; priv->decoder=init_global_rawdv_decoder(); - sh->context = priv; for (i=0; i < 4; i++) priv->audioBuffers[i] = new int16_t[DV_AUDIO_MAX_SAMPLES]; return MPXP_Ok; } -static void uninit(sh_audio_t *sh_audio) +static void uninit(ad_private_t *priv) { - priv_t *priv = reinterpret_cast<priv_t*>(sh_audio->context); unsigned i; - UNUSED(sh_audio); - for (i=0; i < 4; i++) - delete priv->audioBuffers[i]; + for (i=0; i < 4; i++) delete priv->audioBuffers[i]; + delete priv; } -static MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +static MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { // TODO!!! - UNUSED(sh); + UNUSED(priv); UNUSED(cmd); UNUSED(arg); return MPXP_Unknown; } -static unsigned decode(sh_audio_t *sh, unsigned char *buf, unsigned minlen, unsigned maxlen,float *pts) +static unsigned decode(ad_private_t *priv, unsigned char *buf, unsigned minlen, unsigned maxlen,float *pts) { - priv_t *priv = reinterpret_cast<priv_t*>(sh->context); - dv_decoder_t* decoder=priv->decoder; //global_rawdv_decoder; - unsigned char* dv_audio_frame=NULL; - unsigned xx; - size_t len=0; - float apts; - UNUSED(maxlen); + sh_audio_t* sh = priv->sh; + dv_decoder_t* decoder=priv->decoder; //global_rawdv_decoder; + unsigned char* dv_audio_frame=NULL; + unsigned xx; + size_t len=0; + float apts; + UNUSED(maxlen); while(len<minlen) { xx=ds_get_packet_r(sh->ds,&dv_audio_frame,len>0?&apts:pts); if((int)xx<=0 || !dv_audio_frame) return 0; // EOF? Modified: mplayerxp/libmpcodecs/ad_mp3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_mp3.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_mp3.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -29,26 +29,6 @@ LIBAD_EXTERN(mp3) -static const audio_probe_t probes[] = { - { "mp3lib", "libmpg123", 0x50, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", 0x55, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", 0x55005354, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", 0x5000736D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", 0x5500736D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", FOURCC_TAG('.','M','P','3'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", FOURCC_TAG('L','A','M','E'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { "mp3lib", "libmpg123", FOURCC_TAG('M','P','3',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, - { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} -}; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - for(i=0;probes[i].driver;i++) - if(wtag==probes[i].wtag) - return &probes[i]; - return NULL; -} - /** Opaque structure for the libmpg123 decoder handle. */ struct mpg123_handle_struct; typedef struct mpg123_handle_struct mpg123_handle; @@ -258,22 +238,45 @@ MPXP_Ok:MPXP_False; } -MPXP_Rc preinit(sh_audio_t *sh) -{ - int rval; - sh->audio_out_minsize=9216; - rval = load_dll("libmpg123"SLIBSUFFIX); /* try standard libmpg123 first */ - return rval?MPXP_Ok:MPXP_False; -} - -typedef struct priv_s { +struct ad_private_t { mpg123_handle *mh; off_t pos; float pts; -}priv_t; + sh_audio_t* sh; +}; -MPXP_Rc init(sh_audio_t *sh) +static const audio_probe_t probes[] = { + { "mp3lib", "libmpg123", 0x50, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", 0x55, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", 0x55005354, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", 0x5000736D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", 0x5500736D, ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", FOURCC_TAG('.','M','P','3'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", FOURCC_TAG('L','A','M','E'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { "mp3lib", "libmpg123", FOURCC_TAG('M','P','3',' '), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S16_LE} }, + { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} +}; + +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* priv,uint32_t wtag) { + UNUSED(priv); + unsigned i; + for(i=0;probes[i].driver;i++) + if(wtag==probes[i].wtag) + return &probes[i]; + return NULL; +} + +ad_private_t* preinit(sh_audio_t *sh) { + sh->audio_out_minsize=9216; + if(load_dll("libmpg123"SLIBSUFFIX)!=MPXP_Ok) return NULL; + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + return priv; +} + +MPXP_Rc init(ad_private_t *priv) +{ // MPEG Audio: float pts; long param,rate; @@ -281,11 +284,9 @@ int err=0,nch,enc; unsigned char *indata; struct mpg123_frameinfo fi; - priv_t *priv; + sh_audio_t* sh = priv->sh; sh->afmt=AFMT_FLOAT32; mpg123_init(); - priv = new(zeromem) priv_t; - sh->context = priv; priv->mh = mpg123_new(NULL,&err); if(err) { err_exit: @@ -313,7 +314,6 @@ mpg123_close(priv->mh); mpg123_delete(priv->mh); mpg123_exit(); - delete priv; return MPXP_False; } mpg123_getformat(priv->mh, &rate, &nch, &enc); @@ -344,9 +344,8 @@ return MPXP_Ok; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *priv) { - priv_t *priv=reinterpret_cast<priv_t*>(sh->context); mpg123_close(priv->mh); mpg123_delete(priv->mh); mpg123_exit(); @@ -354,17 +353,17 @@ dlclose(dll_handle); } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { - UNUSED(sh); + UNUSED(priv); UNUSED(cmd); UNUSED(arg); return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { - priv_t *priv=reinterpret_cast<priv_t*>(sh->context); + sh_audio_t* sh = priv->sh; unsigned char *indata=NULL,*outdata=NULL; int err=MPG123_OK,indata_size=0; off_t offset,cpos; Modified: mplayerxp/libmpcodecs/ad_null.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_null.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_null.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -6,6 +6,10 @@ #include <unistd.h> #include "ad_internal.h" +struct ad_private_t { + sh_audio_t* sh; +}; + static const ad_info_t info = { "Null audio decoder", "null", @@ -19,36 +23,37 @@ LIBAD_EXTERN(null) -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { return NULL; } -MPXP_Rc init(sh_audio_t *sh) +MPXP_Rc init(ad_private_t *priv) { - UNUSED(sh); + UNUSED(priv); return MPXP_Ok; } -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { - UNUSED(sh); - return MPXP_Ok; + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + return priv; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *priv) { - UNUSED(sh); + delete priv; } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { - UNUSED(sh); + UNUSED(priv); UNUSED(cmd); UNUSED(arg); return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { - UNUSED(sh_audio); + UNUSED(priv); UNUSED(buf); UNUSED(minlen); UNUSED(maxlen); Modified: mplayerxp/libmpcodecs/ad_pcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_pcm.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_pcm.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -8,6 +8,10 @@ #include "libao2/afmt.h" #include "osdep/bswap.h" +struct ad_private_t { + sh_audio_t* sh; +}; + static const ad_info_t info = { "Uncompressed PCM audio decoder", "pcm", @@ -40,7 +44,8 @@ { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} }; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* ctx,uint32_t wtag) { + UNUSED(ctx); unsigned i; for(i=0;probes[i].driver;i++) if(wtag==probes[i].wtag) @@ -49,8 +54,9 @@ } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t *priv) { + sh_audio_t* sh_audio = priv->sh; WAVEFORMATEX *h=sh_audio->wf; sh_audio->i_bps=h->nAvgBytesPerSec; sh_audio->nch=h->nChannels; @@ -81,19 +87,22 @@ return MPXP_Ok; } -MPXP_Rc preinit(sh_audio_t *sh) +ad_private_t* preinit(sh_audio_t *sh) { sh->audio_out_minsize=16384; - return MPXP_Ok; + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + return priv; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *priv) { - UNUSED(sh); + delete priv; } -MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { + sh_audio_t* sh = priv->sh; int skip; UNUSED(arg); switch(cmd) { @@ -110,8 +119,9 @@ return MPXP_Unknown; } -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) { + sh_audio_t* sh_audio = priv->sh; unsigned len = sh_audio->nch*afmt2bps(sh_audio->afmt); len = (minlen + len - 1) / len * len; if (len > maxlen) Modified: mplayerxp/libmpcodecs/ad_qtaudio.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -33,7 +33,6 @@ LIBAD_EXTERN(qtaudio) -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } typedef struct OpaqueSoundConverter* SoundConverter; typedef unsigned long OSType; @@ -157,7 +156,13 @@ static int InFrameSize; static int OutFrameSize; -static MPXP_Rc preinit(sh_audio_t *sh){ +struct ad_private_t { + sh_audio_t* sh; +}; + +static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } + +static ad_private_t* preinit(sh_audio_t *sh){ int error; unsigned long FramesToGet=0; //how many frames the demuxer has to get unsigned long InputBufferSize=0; //size of the input buffer @@ -166,20 +171,20 @@ if(mp_conf.s_cache_size) { MSG_FATAL("Disabling sound:\nwin32 quicktime DLLs must be initialized in single-threaded mode! Try -nocache\n"); - return MPXP_False; + return NULL; } MSG_INFO("win32 libquicktime loader (c) Sascha Sommer\n"); #ifdef MACOSX EnterMovies(); #else - if(loader_init()) return MPXP_False; // failed to load DLL + if(loader_init()) return NULL; // failed to load DLL MSG_V("loader_init DONE!\n"); error = InitializeQTML(6+16); MSG_ERR("InitializeQTML:%i\n",error); - if(error) return MPXP_False; + if(error) return NULL; #endif #if 1 @@ -196,7 +201,7 @@ error = SoundConverterOpen(&InputFormatInfo, &OutputFormatInfo, &myConverter); MSG_V("SoundConverterOpen:%i\n",error); - if(error) return MPXP_False; + if(error) return NULL; if(sh->codecdata){ error = SoundConverterSetInfo(myConverter,siDecompressionParams,sh->codecdata); @@ -220,7 +225,7 @@ error = SoundConverterBeginConversion(myConverter); MSG_V("SoundConverterBeginConversion:%i\n",error); - if(error) return MPXP_False; + if(error) return NULL; sh->audio_out_minsize=OutputBufferSize; sh->audio_in_minsize=InputBufferSize; @@ -233,17 +238,19 @@ //InputBufferSize*WantedBufferSize/OutputBufferSize; #endif - - return MPXP_Ok; // return values: 1=OK 0=ERROR + ad_private_t* priv = new(zeromem) ad_private_t; + priv->sh = sh; + return priv; // return values: 1=OK 0=ERROR } -static MPXP_Rc init(sh_audio_t *sh_audio) +static MPXP_Rc init(ad_private_t *p) { - UNUSED(sh_audio); + UNUSED(p); return MPXP_Ok; // return values: 1=OK 0=ERROR } -static void uninit(sh_audio_t *sh){ +static void uninit(ad_private_t *p){ + sh_audio_t* sh = p->sh; int error; unsigned long ConvertedFrames=0; unsigned long ConvertedBytes=0; @@ -260,9 +267,11 @@ #ifdef MACOSX ExitMovies(); #endif + delete p; } -static unsigned decode(sh_audio_t *sh,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts){ +static unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts){ + sh_audio_t* sh = priv->sh; int error; unsigned long FramesToGet=0; //how many frames the demuxer has to get unsigned long InputBufferSize=0; //size of the input buffer @@ -307,9 +316,9 @@ return ConvertedBytes; } -static MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...){ +static MPXP_Rc control_ad(ad_private_t *p,int cmd,any_t* arg, ...){ // various optional functions you MAY implement: - UNUSED(sh); + UNUSED(p); UNUSED(cmd); UNUSED(arg); return MPXP_Unknown; Modified: mplayerxp/libmpcodecs/ad_real.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_real.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_real.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -28,23 +28,7 @@ LIBAD_EXTERN(real) -static const audio_probe_t probes[] = { - { "realaudio", "14_4.so.6.0", FOURCC_TAG('1','4','_','4'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, - { "realaudio", "28_8.so.6.0", FOURCC_TAG('2','8','_','8'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, - { "realaudio", "cook.so.6.0", FOURCC_TAG('C','O','O','K'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, - { "realaudio", "sipr.so.6.0", FOURCC_TAG('S','I','P','R'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, - { "realaudio", "atrc.so.6.0", FOURCC_TAG('A','T','R','C'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, - { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} -}; -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - for(i=0;probes[i].driver;i++) - if(wtag==probes[i].wtag) - return &probes[i]; - return NULL; -} - static any_t*handle=NULL; any_t*__builtin_new(unsigned long size) { @@ -84,12 +68,31 @@ any_t* extradata; } ra_init_t; -typedef struct priv_s { +struct ad_private_t { any_t*internal; float pts; -} priv_t; + sh_audio_t* sh; +}; -static MPXP_Rc preinit(sh_audio_t *sh){ +static const audio_probe_t probes[] = { + { "realaudio", "14_4.so.6.0", FOURCC_TAG('1','4','_','4'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, + { "realaudio", "28_8.so.6.0", FOURCC_TAG('2','8','_','8'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, + { "realaudio", "cook.so.6.0", FOURCC_TAG('C','O','O','K'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, + { "realaudio", "sipr.so.6.0", FOURCC_TAG('S','I','P','R'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, + { "realaudio", "atrc.so.6.0", FOURCC_TAG('A','T','R','C'), ACodecStatus_Working, {AFMT_FLOAT32, AFMT_S24_LE, AFMT_S16_LE, AFMT_S8} }, + { NULL, NULL, 0x0, ACodecStatus_NotWorking, {AFMT_S8}} +}; + +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* p,uint32_t wtag) { + UNUSED(p); + unsigned i; + for(i=0;probes[i].driver;i++) + if(wtag==probes[i].wtag) + return &probes[i]; + return NULL; +} + +static ad_private_t* preinit(sh_audio_t *sh){ // let's check if the driver is available, return 0 if not. // (you should do that if you use external lib(s) which is optional) unsigned int result; @@ -97,11 +100,12 @@ any_t* prop; char path[4096]; char cpath[4096]; - priv_t *priv; - sh->context=priv=new(zeromem) priv_t; + ad_private_t *priv; + priv=new(zeromem) ad_private_t; + priv->sh = sh; if(!(handle = dlopen (sh->codec->dll_name, RTLD_LAZY))) { - delete sh->context; - return MPXP_False; + delete priv; + return NULL; } raCloseCodec = (uint32_t (*)(uint32_t))ld_sym(handle, "RACloseCodec"); @@ -118,8 +122,8 @@ if(!raCloseCodec || !raDecode || !raFreeDecoder || !raGetFlavorProperty || !(raOpenCodec2||raOpenCodec) || !raSetFlavor || !raInitDecoder){ - delete sh->context; - return MPXP_False; + delete priv; + return NULL; } char *end; @@ -144,8 +148,8 @@ else result=raOpenCodec(&priv->internal); if(result){ MSG_WARN("Decoder open failed, error code: 0x%X\n",result); - delete sh->context; - return MPXP_False; + delete priv; + return NULL; } sh->rate=sh->wf->nSamplesPerSec; @@ -165,8 +169,8 @@ result=raInitDecoder(priv->internal,&init_data); if(result){ MSG_WARN("Decoder init failed, error code: 0x%X\n",result); - delete sh->context; - return MPXP_False; + delete priv; + return NULL; } if(raSetPwd){ @@ -177,8 +181,8 @@ result=raSetFlavor(priv->internal,((short*)(sh->wf+1))[2]); if(result){ MSG_WARN("Decoder flavor setup failed, error code: 0x%X\n",result); - delete sh->context; - return MPXP_False; + delete priv; + return NULL; } prop=raGetFlavorProperty(priv->internal,((short*)(sh->wf+1))[2],0,&len); @@ -196,22 +200,21 @@ sh->audio_out_minsize=128000; // no idea how to get... :( sh->audio_in_minsize=((short*)(sh->wf+1))[1]*sh->wf->nBlockAlign; - return MPXP_True; // return values: 1=OK 0=ERROR + return priv; // return values: 1=OK 0=ERROR } -static MPXP_Rc init(sh_audio_t *sh_audio){ +static MPXP_Rc init(ad_private_t *p){ // initialize the decoder, set tables etc... // set sample format/rate parameters if you didn't do it in preinit() yet. - UNUSED(sh_audio); + UNUSED(p); return MPXP_Ok; // return values: 1=OK 0=ERROR } -static void uninit(sh_audio_t *sh){ +static void uninit(ad_private_t *priv){ // uninit the decoder etc... - priv_t *priv = reinterpret_cast<priv_t*>(sh->context); if (raFreeDecoder) raFreeDecoder(long(priv->internal)); if (raCloseCodec) raCloseCodec(long(priv->internal)); - delete sh->context; + delete priv; } static const unsigned char sipr_swaps[38][2]={ @@ -221,8 +224,8 @@ {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83}, {77,80} }; -static unsigned decode(sh_audio_t *sh,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts){ - priv_t *priv = reinterpret_cast<priv_t*>(sh->context); +static unsigned decode(ad_private_t *priv,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts){ + sh_audio_t* sh = priv->sh; float null_pts; int result; unsigned len=0; @@ -296,8 +299,8 @@ // or -1 for EOF (or uncorrectable error) } -static MPXP_Rc control_ad(sh_audio_t *sh,int cmd,any_t* arg, ...){ - UNUSED(sh); +static MPXP_Rc control_ad(ad_private_t *p,int cmd,any_t* arg, ...){ + UNUSED(p); UNUSED(arg); // various optional functions you MAY implement: switch(cmd){ Modified: mplayerxp/libmpcodecs/ad_twin.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_twin.cpp 2012-12-02 12:21:15 UTC (rev 500) +++ mplayerxp/libmpcodecs/ad_twin.cpp 2012-12-03 15:30:49 UTC (rev 501) @@ -26,7 +26,6 @@ LIBAD_EXTERN(twin) -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { return NULL; } /************************/ /*** General settings ***/ @@ -202,7 +201,7 @@ #define BYTE_BIT 8 #define BBUFSIZ 1024 /* Bit buffer size (bytes) */ #define BBUFLEN (BBUFSIZ*BYTE_BIT) /* Bit buffer length (bits) */ -typedef struct priv_s +struct ad_private_t { float pts; WAVEFORMATEX o_wf; // out format @@ -216,8 +215,11 @@ int ptr; /* current point in the bit buffer */ int nbuf; /* bit buffer size */ char buf[BBUFSIZ]; /* the bit buffer */ -}priv_t; + sh_audio_t* sh; +}; +static const audio_probe_t* __FASTCALL__ probe(ad_private_t* p,uint32_t wtag) { return NULL; } + static HINSTANCE vqf_dll; static int load_dll( const char *libname ) @@ -246,9 +248,9 @@ TvqGetNumFixedBitsPerFrame_ptr; } -static int init_vqf_audio_codec(sh_audio_t *sh_audio){ +static int init_vqf_audio_codec(ad_private_t *priv){ + sh_audio_t* sh_audio = priv->sh; WAVEFORMATEX *in_fmt=sh_audio->wf; - priv_t*priv=reinterpret_cast<priv_t*>(sh_audio->context); int ver; MSG_V("======= Win32 (TWinVQ) AUDIO Codec init =======\n"); @@ -298,46 +300,48 @@ return 1; } -static int close_vqf_audio_codec(sh_audio_t *sh_audio) +static int close_vqf_audio_codec(ad_private_t *priv) { - priv_t*priv=reinterpret_cast<priv_t*>(sh_audio->context); TvqTerminate(&priv->index); return 1; } -MPXP_Rc init(sh_audio_t *sh_audio) +MPXP_Rc init(ad_private_t*p) { - UNUSED(sh_audio); + UNUSED(p); return MPXP_Ok; } -MPXP_Rc preinit(sh_audio_t *sh_audio) +ad_private_t* preinit(sh_audio_t *sh_audio) { /* Win32 VQF audio codec: */ - priv_t *priv; - if(!(priv=new(zeromem) priv_t)) return MPXP_False; - sh_audio->context=priv; + ad_private_t *priv; + if(!(priv=new(zeromem) ad_private_t)) return NULL; + priv->sh = sh_audio; if(!load_dll((const char *)sh_audio->codec->dll_name)) { MSG_ERR("win32.dll looks broken :(\n"); - return MPXP_False; + delete priv; + return NULL; } - if(!init_vqf_audio_codec(sh_audio)){ + if(!init_vqf_audio_codec(priv)){ MSG_ERR("TWinVQ initialization fail\n"); - return MPXP_False; + delete priv; + return NULL; } MSG_V("INFO: TWinVQ audio codec init OK!\n"); - return MPXP_Ok; + return priv; } -void uninit(sh_audio_t *sh) +void uninit(ad_private_t *p) { - close_vqf_audio_codec(sh); - delete sh->context; + close_vqf_audio_codec(p); + delete p; FreeLibrary(vqf_dll); } -MPXP_Rc control_ad(sh_audio_t *sh_audio,int cmd,any_t* arg, ...) +MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) { + sh_audio_t* sh_audio = priv->sh; int skip; UNUSED(arg); switch(cmd) { @@ -360,14 +364,14 @@ static int bread(char *data, /* Output: Output data array */ int size, /* Input: Length of each data */ int nbits, /* Input: Number of bits to write */ - sh_audio_t *sh, /* Input: File pointer */ + ad_private_t *priv, /* Input: File pointer */ float *pts) { /*--- Variables ---*/ int ibits, iptr, idata, ibufadr, ibufbit, icl; unsigned char mask, tmpdat; int retval; - priv_t *priv=reinterpret_cast<priv_t*>(sh->context... [truncated message content] |