[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[389] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-17 10:43:00
|
Revision: 389 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=389&view=rev Author: nickols_k Date: 2012-11-17 10:42:51 +0000 (Sat, 17 Nov 2012) Log Message: ----------- method af_play had a viral nature -> fully redesign it. Remove Mu-LAW & A_Law from filters because lavc supports them in decoders Modified Paths: -------------- TODO mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/postproc/Makefile mplayerxp/postproc/af.cpp mplayerxp/postproc/af.h mplayerxp/postproc/af_ao2.c mplayerxp/postproc/af_center.c mplayerxp/postproc/af_channels.c mplayerxp/postproc/af_comp.c mplayerxp/postproc/af_crystality.c mplayerxp/postproc/af_delay.c mplayerxp/postproc/af_dummy.c mplayerxp/postproc/af_dyn.c mplayerxp/postproc/af_echo3d.c mplayerxp/postproc/af_equalizer.c mplayerxp/postproc/af_export.cpp mplayerxp/postproc/af_extrastereo.c mplayerxp/postproc/af_ffenc.c mplayerxp/postproc/af_format.c mplayerxp/postproc/af_gate.c mplayerxp/postproc/af_hrtf.c mplayerxp/postproc/af_karaoke.c mplayerxp/postproc/af_lp.c mplayerxp/postproc/af_pan.c mplayerxp/postproc/af_raw.c mplayerxp/postproc/af_resample.c mplayerxp/postproc/af_scaletempo.c mplayerxp/postproc/af_sinesuppress.c mplayerxp/postproc/af_sub.c mplayerxp/postproc/af_surround.c mplayerxp/postproc/af_tools.c mplayerxp/postproc/af_volnorm.c mplayerxp/postproc/af_volume.c mplayerxp/postproc/aflib.h mplayerxp/postproc/aflib_accel.h mplayerxp/pvector/pvector_f32_x86.h mplayerxp/pvector/pvector_int_x86.h mplayerxp/xmpcore/mp_aframe.cpp mplayerxp/xmpcore/mp_aframe.h Added Paths: ----------- mplayerxp/postproc/aflib.cpp Removed Paths: ------------- mplayerxp/postproc/af_format_alaw.c mplayerxp/postproc/af_format_ulaw.c mplayerxp/postproc/aflib.c Modified: TODO =================================================================== --- TODO 2012-11-17 05:26:00 UTC (rev 388) +++ TODO 2012-11-17 10:42:51 UTC (rev 389) @@ -11,6 +11,7 @@ license=check_pin(Module_VideoDecoder,pin); ... vd_ffmpeg: init(sh_video_t *sh,any_t* libinput,uint32_t license) { + check_license(Module_VideoDecoder,license); ... PointerProtector lavc_guard(license); priv->lavc_ctx = lavc_guard.protect(avcodec_alloc_context3(priv->codec)); Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-11-17 10:42:51 UTC (rev 389) @@ -301,8 +301,6 @@ sh_audio_t* sh_audio = priv->parent; unsigned len; unsigned cp_size,cp_tile; - mp_aframe_t afd; // filter input - mp_aframe_t* pafd; // filter output if(!sh_audio->inited) return 0; // no codec MSG_DBG3("mpca_decode(%p,%p,%i,%i,%i,%p)\n",sh_audio,buf,minlen,maxlen,buflen,pts); @@ -329,6 +327,8 @@ MSG_DBG2("decaudio: %i bytes %f pts min %i max %i buflen %i o_bps=%i f_bps=%i\n",len,*pts,minlen,maxlen,buflen,sh_audio->o_bps,sh_audio->af_bps); if(len==0 || !sh_audio->afilter) return 0; // EOF? // run the filters: + mp_aframe_t afd; // filter input + mp_aframe_t* pafd; // filter output memset(&afd,0,sizeof(mp_aframe_t)); afd.audio=buf; afd.len=len; Modified: mplayerxp/postproc/Makefile =================================================================== --- mplayerxp/postproc/Makefile 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/Makefile 2012-11-17 10:42:51 UTC (rev 389) @@ -6,16 +6,38 @@ DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@ || exit; done DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done -CXXSRCS=af.cpp af_export.cpp vf.cpp +CXXSRCS=af.cpp aflib.cpp af_export.cpp vf.cpp SRCS=postprocess.c swscale.c -SRCS+=af_ao2.c af_crystality.c af_dummy.c af_delay.c af_channels.c -SRCS+=af_format.c af_resample.c af_volume.c af_equalizer.c af_tools.c af_comp.c -SRCS+=af_gate.c af_pan.c af_surround.c af_sub.c af_volnorm.c -SRCS+=af_extrastereo.c af_lp.c af_dyn.c af_echo3d.c af_hrtf.c af_ffenc.c -SRCS+=af_raw.c af_karaoke.c af_center.c af_sinesuppress.c af_scaletempo.c -SRCS+=af_null.c -SRCS+=aflib.c +SRCS+=af_ao2.c \ + af_center.c \ + af_channels.c \ + af_comp.c \ + af_crystality.c \ + af_delay.c \ + af_dummy.c \ + af_dyn.c \ + af_echo3d.c \ + af_equalizer.c \ + af_extrastereo.c \ + af_ffenc.c \ + af_format.c \ + af_gate.c \ + af_hrtf.c \ + af_karaoke.c \ + af_lp.c \ + af_null.c \ + af_pan.c \ + af_raw.c \ + af_resample.c \ + af_scaletempo.c \ + af_sinesuppress.c \ + af_sub.c \ + af_surround.c \ + af_tools.c \ + af_volnorm.c \ + af_volume.c + SRCS+=vf_vo.c vf_expand.c vf_flip.c vf_format.c vf_yuy2.c vf_rgb2bgr.c SRCS+=vf_rotate.c vf_mirror.c vf_palette.c vf_test.c vf_noise.c vf_yvu9.c SRCS+=vf_rectangle.c vf_eq.c vf_dint.c vf_1bpp.c vf_unsharp.c vf_swapuv.c Modified: mplayerxp/postproc/af.cpp =================================================================== --- mplayerxp/postproc/af.cpp 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af.cpp 2012-11-17 10:42:51 UTC (rev 389) @@ -248,101 +248,92 @@ failure */ static int af_reinit(af_stream_t* s, af_instance_t* af) { - if(!af) - return MPXP_Error; + if(!af) return MPXP_Error; - MSG_DBG2("af_reinit()\n"); - do{ - mp_aframe_t in; // Format of the input to current filter - int rv=0; // Return value + MSG_DBG2("af_reinit()\n"); + do { + af_conf_t in; // Format of the input to current filter + int rv=0; // Return value - // Check if this is the first filter - if(!af->prev) memcpy(&in,&(s->input),sizeof(mp_aframe_t)); - else memcpy(&in,af->prev->data,sizeof(mp_aframe_t)); + // Check if this is the first filter + if(!af->prev) memcpy(&in,&(s->input),sizeof(af_conf_t)); + else memcpy(&in,&af->prev->conf,sizeof(af_conf_t)); - // Reset just in case... - in.audio=NULL; - in.len=0; - - rv = af->config(af,&in); - switch(rv){ - case MPXP_Ok: - break; - case MPXP_False:{ // Configuration filter is needed - // Do auto insertion only if force is not specified - if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){ - af_instance_t* _new = NULL; - // Insert channels filter - if((af->prev?af->prev->data->nch:s->input.nch) != in.nch){ - if(NULL == (_new = af_prepend(s,af,"channels"))) return MPXP_Error; - if(MPXP_Ok != (rv = _new->control(_new,AF_CONTROL_CHANNELS,&in.nch))) return rv; - // Initialize channels filter - if(!_new->prev) memcpy(&in,&(s->input),sizeof(mp_aframe_t)); - else memcpy(&in,_new->prev->data,sizeof(mp_aframe_t)); - if(MPXP_Ok != (rv = _new->config(_new,&in))) return rv; - } - // Insert rate filter - if((af->prev?af->prev->data->rate:s->input.rate) != in.rate){ - if(NULL == (_new = af_prepend(s,af,"resample"))) return MPXP_Error; - if(MPXP_Ok != (rv = _new->control(_new,AF_CONTROL_RESAMPLE_RATE,&in.rate))) return rv; - // Initialize channels filter - if(!_new->prev) memcpy(&in,&(s->input),sizeof(mp_aframe_t)); - else memcpy(&in,_new->prev->data,sizeof(mp_aframe_t)); - if(MPXP_Ok != (rv = _new->config(_new,&in))) { - af_instance_t* af2 = af_prepend(s,af,"format"); - // Init the _new filter - if(af2) { - if((MPXP_Ok != af2->control(af2,AF_CONTROL_FORMAT,&in.format))) return -1; - if(MPXP_Ok != af_reinit(s,af2)) return MPXP_Error; - rv = _new->config(_new,&in); + rv = af->config(af,&in); + memcpy(&in,&af->conf,sizeof(af_conf_t)); + switch(rv){ + case MPXP_Ok: break; + case MPXP_False:{ // Configuration filter is needed + // Do auto insertion only if force is not specified + if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){ + af_instance_t* _new = NULL; + // Insert channels filter + if((af->prev?af->prev->conf.nch:s->input.nch) != in.nch){ + if(NULL == (_new = af_prepend(s,af,"channels"))) return MPXP_Error; + if(MPXP_Ok != (rv = _new->control(_new,AF_CONTROL_CHANNELS,&in.nch))) return rv; + // Initialize channels filter + if(!_new->prev) memcpy(&in,&(s->input),sizeof(af_conf_t)); + else memcpy(&in,&_new->prev->conf,sizeof(af_conf_t)); + if(MPXP_Ok != (rv = _new->config(_new,&in))) return rv; + } + // Insert rate filter + if((af->prev?af->prev->conf.rate:s->input.rate) != in.rate){ + if(NULL == (_new = af_prepend(s,af,"resample"))) return MPXP_Error; + if(MPXP_Ok != (rv = _new->control(_new,AF_CONTROL_RESAMPLE_RATE,&in.rate))) return rv; + // Initialize channels filter + if(!_new->prev) memcpy(&in,&(s->input),sizeof(af_conf_t)); + else memcpy(&in,&_new->prev->conf,sizeof(af_conf_t)); + if(MPXP_Ok != (rv = _new->config(_new,&in))) { + af_instance_t* af2 = af_prepend(s,af,"format"); + // Init the _new filter + if(af2) { + if((MPXP_Ok != af2->control(af2,AF_CONTROL_FORMAT,&in.format))) return -1; + if(MPXP_Ok != af_reinit(s,af2)) return MPXP_Error; + rv = _new->config(_new,&in); + } + return rv; + } + } + // Insert format filter + if(((af->prev?af->prev->conf.format:s->input.format) != in.format)) { + if(NULL == (_new = af_prepend(s,af,"format"))) return MPXP_Error; + if(MPXP_Ok != (rv = _new->control(_new,AF_CONTROL_FORMAT,&in.format))) return rv; + // Initialize format filter + if(!_new->prev) memcpy(&in,&(s->input),sizeof(af_conf_t)); + else memcpy(&in,&_new->prev->conf,sizeof(af_conf_t)); + if(MPXP_Ok != (rv = _new->config(_new,&in))) return rv; + } + if(!_new){ // Should _never_ happen + MSG_ERR("[libaf] Unable to correct audio format. " + "This error should never occur, please send bugreport.\n"); + return MPXP_Error; + } + af=_new; + } + break; } - return rv; - } + case MPXP_Detach:{ // Filter is redundant and wants to be unloaded + // Do auto remove only if force is not specified + if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){ + af_instance_t* aft=af->prev; + af_remove(s,af); + if(aft) af=aft; + else af=s->first; // Restart configuration + } + break; + } + default: + MSG_ERR("[libaf] Reinitialization did not work, audio" + " filter '%s' returned error code %i for r=%i c=%i fmt=%x\n",af->info->name,rv,in.rate,in.nch,in.format); + return MPXP_Error; } - // Insert format filter - if(((af->prev?af->prev->data->format:s->input.format) != in.format)) { - if(NULL == (_new = af_prepend(s,af,"format"))) return MPXP_Error; - if(MPXP_Ok != (rv = _new->control(_new,AF_CONTROL_FORMAT,&in.format))) return rv; - // Initialize format filter - if(!_new->prev) memcpy(&in,&(s->input),sizeof(mp_aframe_t)); - else memcpy(&in,_new->prev->data,sizeof(mp_aframe_t)); - if(MPXP_Ok != (rv = _new->config(_new,&in))) return rv; - } - if(!_new){ // Should _never_ happen - MSG_ERR("[libaf] Unable to correct audio format. " - "This error should never occur, please send bugreport.\n"); - return MPXP_Error; - } - af=_new; - } - break; - } - case MPXP_Detach:{ // Filter is redundant and wants to be unloaded - // Do auto remove only if force is not specified - if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){ - af_instance_t* aft=af->prev; - af_remove(s,af); - if(aft) - af=aft; - else - af=s->first; // Restart configuration - } - break; - } - default: - MSG_ERR("[libaf] Reinitialization did not work, audio" - " filter '%s' returned error code %i for r=%i c=%i fmt=%x\n",af->info->name,rv,in.rate,in.nch,in.format); - return MPXP_Error; - } - // Check if there are any filters left in the list - if(NULL == af){ - if(!(af=af_append(s,s->first,"dummy"))) - return -1; - } - else - af=af->next; - }while(af); - return MPXP_Ok; + // Check if there are any filters left in the list + if(NULL == af){ + if(!(af=af_append(s,s->first,"dummy"))) + return -1; + } else af=af->next; + }while(af); + return MPXP_Ok; } // Uninit and remove all filters @@ -368,10 +359,6 @@ // Sanity check if(!s) return MPXP_False; - // Precaution in case caller is misbehaving - s->input.audio = s->output.audio = NULL; - s->input.len = s->output.len = 0; - // Figure out how fast the machine is if(AF_INIT_AUTO == (AF_INIT_TYPE_MASK & s->cfg.force)) s->cfg.force = (s->cfg.force & ~AF_INIT_TYPE_MASK) | AF_INIT_TYPE(); @@ -402,7 +389,7 @@ // If force_output isn't set do not compensate for output format if(!force_output){ - memcpy(&s->output, s->last->data, sizeof(mp_aframe_t)); + memcpy(&s->output, &s->last->conf, sizeof(af_conf_t)); return MPXP_Ok; } @@ -410,7 +397,7 @@ if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){ af_instance_t* af = NULL; // New filter // Check output frequency if not OK fix with resample - if(s->last->data->rate!=s->output.rate){ + if(s->last->conf.rate!=s->output.rate){ if(NULL==(af=af_get(s,"resample"))){ if((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW){ if(!strcmp(s->first->info->name,"format")) @@ -441,7 +428,7 @@ // Check number of output channels fix if not OK // If needed always inserted last -> easy to screw up other filters - if(s->last->data->nch!=s->output.nch){ + if(s->last->conf.nch!=s->output.nch){ if(!strcmp(s->last->info->name,"format")) af = af_prepend(s,s->last,"channels"); else @@ -454,7 +441,7 @@ } // Check output format fix if not OK - if((s->last->data->format != s->output.format)){ + if((s->last->conf.format != s->output.format)){ if(strcmp(s->last->info->name,"format")) af = af_append(s,s->last,"format"); else @@ -470,9 +457,9 @@ if(MPXP_Ok != af_reinit(s,s->first)) return MPXP_False; - if((s->last->data->format != s->output.format) || - (s->last->data->nch != s->output.nch) || - (s->last->data->rate != s->output.rate)) { + if((s->last->conf.format != s->output.format) || + (s->last->conf.nch != s->output.nch) || + (s->last->conf.rate != s->output.rate)) { // Something is stuffed audio out will not work MSG_ERR("[libaf] Unable to setup filter system can not" " meet sound-card demands, please send bugreport. \n"); @@ -509,16 +496,20 @@ } // Filter data chunk through the filters in the list -mp_aframe_t* __FASTCALL__ RND_RENAME8(af_play)(af_stream_t* s, mp_aframe_t* data) +mp_aframe_t* __FASTCALL__ RND_RENAME8(af_play)(af_stream_t* s,const mp_aframe_t* data) { - af_instance_t* af=s->first; - // Iterate through all filters - do{ - MSG_DBG2("filtering %s\n",af->info->name); - data=af->play(af,data,af->next?0:1); - af=af->next; - }while(af && data); - return data; + mp_aframe_t* in = const_cast<mp_aframe_t*>(data); + mp_aframe_t* out; + af_instance_t* af=s->first; + // Iterate through all filters + do{ + MSG_DBG2("filtering %s\n",af->info->name); + out=af->play(af,in); + if(out!=in && in!=data) free_mp_aframe(in); + in=out; + af=af->next; + }while(af && out); + return out; } /* Helper function used to calculate the exact buffer length needed @@ -577,26 +568,6 @@ return delay; } -/* Helper function called by the macro with the same name this - function should not be called directly */ -MPXP_Rc __FASTCALL__ af_resize_local_buffer(af_instance_t* af,unsigned len) -{ - // Calculate _new length - MSG_V("[libaf] Reallocating memory in module %s, " - "old len = %i, _new len = %i\n",af->info->name,af->data->len,len); - // If there is a buffer mp_free it - if(af->data->audio) delete af->data->audio; - // Create _new buffer and check that it is OK - af->data->audio = new char [len]; - if(!af->data->audio){ - MSG_FATAL(MSGTR_OutOfMemory); - return MPXP_Error; - } - af->data->len=len; - check_pin("afilter",af->pin,AF_PIN); - return MPXP_Ok; -} - // send control to all filters, starting with the last until // one responds with MPXP_Ok MPXP_Rc __FASTCALL__ af_control_any_rev (af_stream_t* s, int cmd, any_t* arg) { @@ -611,50 +582,42 @@ MPXP_Rc __FASTCALL__ af_query_fmt (const af_stream_t* s,mpaf_format_e fmt) { - af_instance_t* filt = s?s->first:NULL; - const char *filt_name=filt?filt->info->name:"ao2"; - if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_FORMAT,fmt); - else - { - unsigned ifmt=mpaf_format_decode(fmt); - if(ifmt==filt->data->format) return MPXP_True; - } - return MPXP_False; + af_instance_t* filt = s?s->first:NULL; + const char *filt_name=filt?filt->info->name:"ao2"; + if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_FORMAT,fmt); + else if(mpaf_format_decode(fmt)==filt->conf.format) return MPXP_True; + return MPXP_False; } MPXP_Rc __FASTCALL__ af_query_rate (const af_stream_t* s,unsigned rate) { - af_instance_t* filt = s?s->first:NULL; - const char *filt_name=filt?filt->info->name:"ao2"; - if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_RATE,rate); - else { - if(rate==filt->data->rate) return MPXP_True; - } - return MPXP_False; + af_instance_t* filt = s?s->first:NULL; + const char *filt_name=filt?filt->info->name:"ao2"; + if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_RATE,rate); + else if(rate==filt->conf.rate) return MPXP_True; + return MPXP_False; } MPXP_Rc __FASTCALL__ af_query_channels (const af_stream_t* s,unsigned nch) { - af_instance_t* filt = s?s->first:NULL; - const char *filt_name=filt?filt->info->name:"ao2"; - if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_CHANNELS,nch); - else { - if(nch==filt->data->nch) return MPXP_True; - } - return MPXP_False; + af_instance_t* filt = s?s->first:NULL; + const char *filt_name=filt?filt->info->name:"ao2"; + if(strcmp(filt_name,"ao2")==0) return RND_RENAME7(ao_control)(ao_data,AOCONTROL_QUERY_CHANNELS,nch); + else if(nch==filt->conf.nch) return MPXP_True; + return MPXP_False; } void af_help (void) { - int i = 0; - MSG_INFO( "Available audio filters:\n"); - while (filter_list[i]) { - if (filter_list[i]->comment && filter_list[i]->comment[0]) - MSG_INFO( "\t%-10s: %s (%s)\n", filter_list[i]->name, filter_list[i]->info, filter_list[i]->comment); - else - MSG_INFO( "\t%-10s: %s\n", filter_list[i]->name, filter_list[i]->info); - i++; - } - MSG_INFO("\n"); + unsigned i = 0; + MSG_INFO( "Available audio filters:\n"); + while (filter_list[i]) { + if (filter_list[i]->comment && filter_list[i]->comment[0]) + MSG_INFO( "\t%-10s: %s (%s)\n", filter_list[i]->name, filter_list[i]->info, filter_list[i]->comment); + else + MSG_INFO( "\t%-10s: %s\n", filter_list[i]->name, filter_list[i]->info); + i++; + } + MSG_INFO("\n"); } af_stream_t *RND_RENAME6(af_new)(any_t*_parent) Modified: mplayerxp/postproc/af.h =================================================================== --- mplayerxp/postproc/af.h 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af.h 2012-11-17 10:42:51 UTC (rev 389) @@ -42,17 +42,24 @@ AF_PIN=RND_NUMBER6+RND_CHAR6 }; +typedef struct af_conf_s { + /*------ stream description ----------*/ + unsigned rate; /* rate of audio */ + unsigned nch; /* number of channels */ + mpaf_format_e format;/* PCM format of audio */ +}af_conf_t; + // Linked list of audio filters typedef struct af_instance_s { const af_info_t* info; char antiviral_hole[RND_CHAR6]; unsigned pin; // personal identification number - MPXP_Rc (* __FASTCALL__ config)(struct af_instance_s* af, const mp_aframe_t* arg); + MPXP_Rc (* __FASTCALL__ config)(struct af_instance_s* af, const af_conf_t* arg); MPXP_Rc (* __FASTCALL__ control)(struct af_instance_s* af, int cmd, any_t* arg); void (* __FASTCALL__ uninit)(struct af_instance_s* af); - mp_aframe_t* (* __FASTCALL__ play)(struct af_instance_s* af, mp_aframe_t* data,int final); + mp_aframe_t* (* __FASTCALL__ play)(struct af_instance_s* af,const mp_aframe_t* data); any_t* setup; // setup data for this specific instance and filter - mp_aframe_t* data; // configuration for outgoing data stream + af_conf_t conf; // configuration for outgoing data stream struct af_instance_s* next; struct af_instance_s* prev; any_t* parent; @@ -93,16 +100,16 @@ // Current audio stream typedef struct af_stream_s { - char antiviral_hole[RND_CHAR7]; - // The first and last filter in the list - af_instance_t* first; - af_instance_t* last; - // Storage for input and output data formats - mp_aframe_t input; - mp_aframe_t output; - // Configuration for this stream - af_cfg_t cfg; - any_t*parent; + char antiviral_hole[RND_CHAR7]; + // The first and last filter in the list + af_instance_t* first; + af_instance_t* last; + // Storage for input and output data formats + af_conf_t input; + af_conf_t output; + // Configuration for this stream + af_cfg_t cfg; + any_t* parent; }af_stream_t; @@ -128,7 +135,7 @@ void af_uninit(af_stream_t* s); // Filter data chunk through the filters in the list -mp_aframe_t* __FASTCALL__ RND_RENAME8(af_play)(af_stream_t* s, mp_aframe_t* data); +mp_aframe_t* __FASTCALL__ RND_RENAME8(af_play)(af_stream_t* s,const mp_aframe_t* data); // send control to all filters, starting with the last until // one accepts the command with MPXP_Ok. @@ -151,10 +158,6 @@ // Helper functions and macros used inside the audio filters -/* Helper function called by the macro with the same name only to be - called from inside filters */ -MPXP_Rc __FASTCALL__ af_resize_local_buffer(af_instance_t* af,unsigned len); - /* Helper function used to calculate the exact buffer length needed when buffers are resized. The returned length is >= than what is needed */ @@ -171,7 +174,7 @@ /* Helper function used to convert from sample time to ms */ int __FASTCALL__ af_to_ms(int n, int* in, float* out, int rate); /* Helper function for testing the output format */ -MPXP_Rc __FASTCALL__ af_test_output(struct af_instance_s* af,const mp_aframe_t* out); +MPXP_Rc __FASTCALL__ af_test_output(struct af_instance_s* af,const af_conf_t* out); /** Print a list of all available audio filters */ void af_help(void); @@ -186,13 +189,6 @@ /* print out configuration of filter's chain */ extern void af_showconf(af_instance_t *first); -/* Memory reallocation macro: if a local buffer is used (i.e. if the - filter doesn't operate on the incoming buffer this macro must be - called to ensure the buffer is big enough. */ -static inline int RESIZE_LOCAL_BUFFER(af_instance_t* a, mp_aframe_t* d) { - unsigned len=af_lencalc(a->mul,d); - return ((unsigned)a->data->len < len)?af_resize_local_buffer(a,len):MPXP_Ok; -} #ifdef __cplusplus } #endif Modified: mplayerxp/postproc/af_ao2.c =================================================================== --- mplayerxp/postproc/af_ao2.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_ao2.c 2012-11-17 10:42:51 UTC (rev 389) @@ -110,14 +110,14 @@ }af_ao2_t; // Initialization and runtime control -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af, const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af, const af_conf_t* arg) { af_ao2_t* s = af->setup; /* Sanity check */ if(!arg) return MPXP_Error; - s->rate = af->data->rate = find_best_rate(arg->rate); - s->nch = af->data->nch = find_best_ch(arg->nch); - s->format = af->data->format = mpaf_format_decode(find_best_fmt(mpaf_format_encode(arg->format))); + s->rate = af->conf.rate = find_best_rate(arg->rate); + s->nch = af->conf.nch = find_best_ch(arg->nch); + s->format = af->conf.format = mpaf_format_decode(find_best_fmt(mpaf_format_encode(arg->format))); return af_test_output(af,arg); } @@ -141,12 +141,11 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) mp_free(af->data); if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* data) { // Do something necessary to get rid of annoying warning during compile if(!af) MSG_ERR("EEEK: Argument af == NULL in af_dummy.c play()."); @@ -161,9 +160,8 @@ af->play=play; af->mul.d=1; af->mul.n=1; - af->data=mp_malloc(sizeof(mp_aframe_t)); af->setup=mp_calloc(1,sizeof(af_ao2_t)); - if((af->data == NULL) || (af->setup == NULL)) return MPXP_Error; + if(af->setup == NULL) return MPXP_Error; check_pin("afilter",af->pin,AF_PIN); return MPXP_Ok; } Modified: mplayerxp/postproc/af_center.c =================================================================== --- mplayerxp/postproc/af_center.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_center.c 2012-11-17 10:42:51 UTC (rev 389) @@ -25,15 +25,15 @@ }af_center_t; // Initialization and runtime control -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { af_center_t* s = af->setup; // Sanity check if(!arg) return MPXP_Error; - af->data->rate = arg->rate; - af->data->nch = max(s->ch+1,arg->nch); - af->data->format = MPAF_NE|MPAF_F|4; + af->conf.rate = arg->rate; + af->conf.nch = max(s->ch+1,arg->nch); + af->conf.format = MPAF_NE|MPAF_F|4; return af_test_output(af,arg); } @@ -66,30 +66,29 @@ // Deallocate memory static void uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); - if(af->setup) - mp_free(af->setup); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* play(struct af_instance_s* af,const mp_aframe_t* ind) { - mp_aframe_t* c = data; // Current working data - af_center_t* s = af->setup; // Setup for this instance - float* a = c->audio; // Audio data - int len = c->len/4; // Number of samples in current audio block - int nch = c->nch; // Number of channels - int ch = s->ch; // Channel in which to insert the center audio - register int i; + mp_aframe_t*c = ind; // Current working data + af_center_t*s = af->setup;// Setup for this instance + float* a = c->audio; // Audio data + unsigned len = c->len/4; // Number of samples in current audio block + unsigned nch = c->nch; // Number of channels + unsigned ch = s->ch; // Channel in which to insert the center audio + unsigned i; + mp_aframe_t*outd= new_mp_aframe_genome(ind); + mp_alloc_aframe(outd); - // Run filter - for(i=0;i<len;i+=nch){ - // Average left and right - a[i+ch] = (a[i]/2) + (a[i+1]/2); - } + // Run filter + for(i=0;i<len;i+=nch){ + // Average left and right + ((float*)outd->audio)[i+ch] = (a[i]/2) + (a[i+1]/2); + } - return c; + return outd; } // Allocate memory and set function pointers @@ -101,10 +100,8 @@ af->play=play; af->mul.n=1; af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); af->setup=s=mp_calloc(1,sizeof(af_center_t)); - if(af->data == NULL || af->setup == NULL) - return MPXP_Error; + if(af->setup == NULL) return MPXP_Error; // Set default values s->ch = 1; // Channel nr 2 check_pin("afilter",af->pin,AF_PIN); Modified: mplayerxp/postproc/af_channels.c =================================================================== --- mplayerxp/postproc/af_channels.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_channels.c 2012-11-17 10:42:51 UTC (rev 389) @@ -23,11 +23,11 @@ }af_channels_t; // Local function for copying data -static void __FASTCALL__ copy(any_t* in, any_t* out, int ins, int inos,int outs, int outos, int len, int bps) +static void __FASTCALL__ af_copy(const any_t* in, any_t* out, int ins, int inos,int outs, int outos, int len, int bps) { switch(bps){ case 1:{ - int8_t* tin = (int8_t*)in; + const int8_t* tin = (const int8_t*)in; int8_t* tout = (int8_t*)out; tin += inos; tout += outos; @@ -40,7 +40,7 @@ break; } case 2:{ - int16_t* tin = (int16_t*)in; + const int16_t* tin = (const int16_t*)in; int16_t* tout = (int16_t*)out; tin += inos; tout += outos; @@ -53,7 +53,7 @@ break; } case 3:{ - int8_t* tin = (int8_t*)in; + const int8_t* tin = (const int8_t*)in; int8_t* tout = (int8_t*)out; tin += 3 * inos; tout += 3 * outos; @@ -68,7 +68,7 @@ break; } case 4:{ - int32_t* tin = (int32_t*)in; + const int32_t* tin = (const int32_t*)in; int32_t* tout = (int32_t*)out; tin += inos; tout += outos; @@ -81,7 +81,7 @@ break; } case 8:{ - int64_t* tin = (int64_t*)in; + const int64_t* tin = (const int64_t*)in; int64_t* tout = (int64_t*)out; tin += inos; tout += outos; @@ -118,38 +118,38 @@ return MPXP_Ok; } -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { af_channels_t* s = af->setup; // Set default channel assignment if(!s->router){ int i; // Make sure this filter isn't redundant - if(af->data->nch == ((mp_aframe_t*)arg)->nch) + if(af->conf.nch == arg->nch) return MPXP_Detach; // If mono: fake stereo - if(((mp_aframe_t*)arg)->nch == 1){ - s->nr = min(af->data->nch,2); + if(arg->nch == 1){ + s->nr = min(af->conf.nch,2); for(i=0;i<s->nr;i++){ s->route[i][FR] = 0; s->route[i][TO] = i; } } else{ - s->nr = min(af->data->nch, ((mp_aframe_t*)arg)->nch); + s->nr = min(af->conf.nch, arg->nch); for(i=0;i<s->nr;i++){ s->route[i][FR] = i; s->route[i][TO] = i; } } } - s->ich=((mp_aframe_t*)arg)->nch; - af->data->rate = ((mp_aframe_t*)arg)->rate; - af->data->format = ((mp_aframe_t*)arg)->format; - af->mul.n = af->data->nch; - af->mul.d = ((mp_aframe_t*)arg)->nch; - return check_routes(s,((mp_aframe_t*)arg)->nch,af->data->nch); + s->ich=arg->nch; + af->conf.rate = arg->rate; + af->conf.format = arg->format; + af->mul.n = af->conf.nch; + af->mul.d = arg->nch; + return check_routes(s,arg->nch,af->conf.nch); } // Initialization and runtime control static MPXP_Rc __FASTCALL__ control(struct af_instance_s* af, int cmd, any_t* arg) @@ -157,7 +157,7 @@ af_channels_t* s = af->setup; switch(cmd){ case AF_CONTROL_SHOWCONF: - MSG_INFO("[af_channels] Changing channels %d -> %d\n",s->ich,af->data->nch); + MSG_INFO("[af_channels] Changing channels %d -> %d\n",s->ich,af->conf.nch); return MPXP_Ok; case AF_CONTROL_COMMAND_LINE:{ int nch = 0; @@ -199,13 +199,13 @@ return MPXP_Error; } - af->data->nch=((int*)arg)[0]; + af->conf.nch=((int*)arg)[0]; if(!s->router) MSG_V("[channels] Changing number of channels" - " to %i\n",af->data->nch); + " to %i\n",af->conf.nch); return MPXP_Ok; case AF_CONTROL_CHANNELS | AF_CONTROL_GET: - *(int*)arg = af->data->nch; + *(int*)arg = af->conf.nch; return MPXP_Ok; case AF_CONTROL_CHANNELS_ROUTING | AF_CONTROL_SET:{ int ch = ((af_control_ext_t*)arg)->ch; @@ -240,37 +240,33 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->setup) - mp_free(af->setup); - if(af->data) - mp_free(af->data); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* in) { - mp_aframe_t* c = data; // Current working data - af_channels_t* s = af->setup; - int i; + af_channels_t*s = af->setup; + int i; - if(MPXP_Ok != RESIZE_LOCAL_BUFFER(af,data)) - return NULL; - mp_aframe_t* l = af->data; // Local data + mp_aframe_t*out; + out=new_mp_aframe_genome(in); + out->len=af_lencalc(af->mul,in); + mp_alloc_aframe(out); - // Reset unused channels - memset(l->audio,0,(c->len*af->mul.n)/af->mul.d); + // Reset unused channels + memset(out->audio,0,(in->len*af->mul.n)/af->mul.d); - if(MPXP_Ok == check_routes(s,c->nch,l->nch)) - for(i=0;i<s->nr;i++) - copy(c->audio,l->audio,c->nch,s->route[i][FR], - l->nch,s->route[i][TO],c->len,c->format&MPAF_BPS_MASK); + if(MPXP_Ok == check_routes(s,in->nch,out->nch)) + for(i=0;i<s->nr;i++) + af_copy(in->audio,out->audio,in->nch,s->route[i][FR], + out->nch,s->route[i][TO],in->len,in->format&MPAF_BPS_MASK); - // Set output data - c->audio = l->audio; - c->len = (c->len*af->mul.n)/af->mul.d; - c->nch = l->nch; + // Set output data + out->len = (in->len*af->mul.n)/af->mul.d; + out->nch = in->nch; - return c; + return out; } // Allocate memory and set function pointers @@ -281,10 +277,8 @@ af->play=play; af->mul.n=1; af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); af->setup=mp_calloc(1,sizeof(af_channels_t)); - if((af->data == NULL) || (af->setup == NULL)) - return MPXP_Error; + if(af->setup == NULL) return MPXP_Error; check_pin("afilter",af->pin,AF_PIN); return MPXP_Ok; } Modified: mplayerxp/postproc/af_comp.c =================================================================== --- mplayerxp/postproc/af_comp.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_comp.c 2012-11-17 10:42:51 UTC (rev 389) @@ -33,15 +33,14 @@ float ratio[AF_NCH]; // Compression ratio }af_comp_t; -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { - af_comp_t* s = (af_comp_t*)af->setup; // Sanity check if(!arg) return MPXP_Error; - af->data->rate = arg->rate; - af->data->nch = arg->nch; - af->data->format = MPAF_F|MPAF_NE|4; + af->conf.rate = arg->rate; + af->conf.nch = arg->nch; + af->conf.format = MPAF_F|MPAF_NE|4; // Time constant set to 0.1s // s->alpha = (1.0/0.2)/(2.0*M_PI*(float)((mp_aframe_t*)arg)->rate); @@ -80,13 +79,13 @@ case AF_CONTROL_COMP_THRESH | AF_CONTROL_GET: return af_to_dB(AF_NCH,s->tresh,(float*)arg,10.0); case AF_CONTROL_COMP_ATTACK | AF_CONTROL_SET: - return af_from_ms(AF_NCH,(float*)arg,s->attack,af->data->rate,500.0,0.1); + return af_from_ms(AF_NCH,(float*)arg,s->attack,af->conf.rate,500.0,0.1); case AF_CONTROL_COMP_ATTACK | AF_CONTROL_GET: - return af_to_ms(AF_NCH,s->attack,(float*)arg,af->data->rate); + return af_to_ms(AF_NCH,s->attack,(float*)arg,af->conf.rate); case AF_CONTROL_COMP_RELEASE | AF_CONTROL_SET: - return af_from_ms(AF_NCH,(float*)arg,s->release,af->data->rate,3000.0,10.0); + return af_from_ms(AF_NCH,(float*)arg,s->release,af->conf.rate,3000.0,10.0); case AF_CONTROL_COMP_RELEASE | AF_CONTROL_GET: - return af_to_ms(AF_NCH,s->release,(float*)arg,af->data->rate); + return af_to_ms(AF_NCH,s->release,(float*)arg,af->conf.rate); case AF_CONTROL_COMP_RATIO | AF_CONTROL_SET: for(i=0;i<AF_NCH;i++) s->ratio[i] = clamp(((float*)arg)[i],1.0,10.0); @@ -103,43 +102,42 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); - if(af->setup) - mp_free(af->setup); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* in) { - mp_aframe_t* c = data; // Current working data - af_comp_t* s = (af_comp_t*)af->setup; // Setup for this instance - float* a = (float*)c->audio; // Audio data - int len = c->len/4; // Number of samples - int ch = 0; // Channel counter - register int nch = c->nch; // Number of channels - register int i = 0; + const mp_aframe_t*c = in; // Current working data + af_comp_t* s = (af_comp_t*)af->setup; // Setup for this instance + unsigned len = c->len/4; // Number of samples + unsigned ch = 0; // Channel counter + unsigned nch = c->nch; // Number of channels + unsigned i = 0; - // Compress/expand - for(ch = 0; ch < nch ; ch++){ - if(s->enable[ch]){ - float t = 1.0 - s->time[ch]; - for(i=ch;i<len;i+=nch){ - register float x = a[i]; - register float pow = x*x; - s->pow[ch] = t*s->pow[ch] + - pow*s->time[ch]; // LP filter - if(pow < s->pow[ch]){ - ; + mp_aframe_t* out = new_mp_aframe_genome(in); + mp_alloc_aframe(out); + + float* _in = (float*)c->audio; // Audio data + float* _out = (float*)out->audio; // Audio data + // Compress/expand + for(ch = 0; ch < nch ; ch++){ + if(s->enable[ch]){ + float t = 1.0 - s->time[ch]; + for(i=ch;i<len;i+=nch){ + register float x = _in[i]; + register float _pow = x*x; + s->pow[ch] = t*s->pow[ch] + _pow*s->time[ch]; // LP filter + if(_pow < s->pow[ch]){ + ; + } else{ + ; + } + _out[i] = x; + } } - else{ - ; - } - a[i] = x; - } } - } - return c; + return out; } // Allocate memory and set function pointers @@ -150,10 +148,8 @@ af->play=play; af->mul.n=1; af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); af->setup=mp_calloc(1,sizeof(af_comp_t)); - if(af->data == NULL || af->setup == NULL) - return MPXP_Error; + if(af->setup == NULL) return MPXP_Error; check_pin("afilter",af->pin,AF_PIN); return MPXP_Ok; } Modified: mplayerxp/postproc/af_crystality.c =================================================================== --- mplayerxp/postproc/af_crystality.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_crystality.c 2012-11-17 10:42:51 UTC (rev 389) @@ -196,14 +196,16 @@ static float buf[BUF_SIZE]; static unsigned _bufPos = BUF_SIZE - 1; static unsigned bufPos[3]; -static void __FASTCALL__ echo3d(af_crystality_t *setup,float *data, unsigned datasize) +static mp_aframe_t* __FASTCALL__ echo3d(af_crystality_t *setup,const mp_aframe_t* in) { - unsigned x,i; + unsigned x,i,datasize; float _left, _right, dif, difh, leftc, rightc, left[4], right[4]; float *dataptr; float lt, rt; + mp_aframe_t* out = new_mp_aframe_genome(in); + mp_alloc_aframe(out); + memcpy(out->audio,in->audio,out->len); - #if 0 float lsine,rsine; static float lharmb = 0, rharmb = 0, lhfb = 0, rhfb = 0; @@ -213,7 +215,8 @@ bufPos[0] = 1 + BUF_SIZE - DELAY1; bufPos[1] = 1 + BUF_SIZE - DELAY1 - DELAY2; bufPos[2] = 1 + BUF_SIZE - DELAY1 - DELAY2 - DELAY3; - dataptr = data; + dataptr = out->audio; + datasize= out->len; for (x = 0; x < datasize; x += 8) { @@ -293,6 +296,7 @@ dataptr[1] = _right;//clamp(_right,-1.0,1.0); dataptr += 2; } + return out; } /* @@ -393,19 +397,24 @@ /* * exact bandwidth extender ("exciter") routine */ -static void __FASTCALL__ bandext(af_crystality_t *setup,float *data, const unsigned datasize) +static mp_aframe_t* __FASTCALL__ bandext(af_crystality_t *setup,const mp_aframe_t*in) { - - unsigned x,i; + unsigned x,i,datasize; float _left, _right; - float *dataptr = data; + float *dataptr=NULL; static float lprev[4], rprev[4]; float left[5], right[5]; static float lamplUp, lamplDown; static float ramplUp, ramplDown; float lampl, rampl; float tmp; + mp_aframe_t* out=new_mp_aframe_genome(in); + mp_alloc_aframe(out); + memcpy(out->audio,in->audio,out->len); + dataptr = out->audio; + datasize= out->len; + for (x = 0; x < datasize; x += 8) { // ************ load sample ********** @@ -462,9 +471,10 @@ dataptr[1] = _right;//clamp(_right,-1.0,+1.0); dataptr += 2; } + return out; } -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { af_crystality_t* s = af->setup; unsigned i_bps,fmt; @@ -472,10 +482,10 @@ if(!arg) return MPXP_Error; if(arg->nch!=2) return MPXP_Error; - af->data->rate = arg->rate; - af->data->nch = arg->nch; - af->data->format = MPAF_NE|MPAF_F|4; - init_crystality(s,af->data->rate); + af->conf.rate = arg->rate; + af->conf.nch = arg->nch; + af->conf.format = MPAF_NE|MPAF_F|4; + init_crystality(s,af->conf.rate); i_bps=((sh_audio_t *)((af_stream_t *)af->parent)->parent)->i_bps*8; fmt=((sh_audio_t *)((af_stream_t *)af->parent)->parent)->wtag; if(fmt==0x55 || fmt==0x50) {/* MP3 */ @@ -511,19 +521,17 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); - if(af->setup) - mp_free(af->setup); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* in) { - mp_aframe_t* c = data; /* Current working data */ - echo3d(af->setup,(float*)c->audio, c->len); - bandext(af->setup,(float*)c->audio, c->len); - return c; + mp_aframe_t* out,*tmp; + tmp=echo3d(af->setup,in); + out=bandext(af->setup,tmp); + free_mp_aframe(tmp); + return out; } // Allocate memory and set function pointers @@ -534,10 +542,8 @@ af->play=play; af->mul.n=1; af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); af->setup=mp_calloc(1,sizeof(af_crystality_t)); - if(af->data == NULL || af->setup == NULL) - return MPXP_Error; + if(af->setup == NULL) return MPXP_Error; set_defaults(af->setup); init_crystality(af->setup,44100); left0p = right0p = 0; Modified: mplayerxp/postproc/af_delay.c =================================================================== --- mplayerxp/postproc/af_delay.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_delay.c 2012-11-17 10:42:51 UTC (rev 389) @@ -47,7 +47,7 @@ } case AF_CONTROL_DELAY_LEN | AF_CONTROL_SET:{ int i; - if(MPXP_Ok != af_from_ms(AF_NCH, arg, s->wi, af->data->rate, 0.0, 1000.0)) + if(MPXP_Ok != af_from_ms(AF_NCH, arg, s->wi, af->conf.rate, 0.0, 1000.0)) return MPXP_Error; s->ri = 0; for(i=0;i<AF_NCH;i++){ @@ -66,35 +66,30 @@ else s->wi[i] = s->wi[i] - s->ri; } - return af_to_ms(AF_NCH, s->wi, arg, af->data->rate); + return af_to_ms(AF_NCH, s->wi, arg, af->conf.rate); } default: break; } return MPXP_Unknown; } -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { af_delay_t* s = af->setup; unsigned i; // Free prevous delay queues - for(i=0;i<af->data->nch;i++){ - if(s->q[i]) - mp_free(s->q[i]); - } + for(i=0;i<af->conf.nch;i++) if(s->q[i]) mp_free(s->q[i]); - af->data->rate = arg->rate; - af->data->nch = arg->nch; - af->data->format = arg->format; + af->conf.rate = arg->rate; + af->conf.nch = arg->nch; + af->conf.format = arg->format; // Allocate new delay queues - for(i=0;i<af->data->nch;i++){ - s->q[i] = mp_calloc(L,af->data->format&MPAF_BPS_MASK); - if(NULL == s->q[i]) - MSG_FATAL(MSGTR_OutOfMemory); + for(i=0;i<af->conf.nch;i++){ + s->q[i] = mp_calloc(L,af->conf.format&MPAF_BPS_MASK); + if(NULL == s->q[i]) MSG_FATAL(MSGTR_OutOfMemory); } - return control(af,AF_CONTROL_DELAY_LEN | AF_CONTROL_SET,s->d); } @@ -102,8 +97,6 @@ static void __FASTCALL__ uninit(struct af_instance_s* af) { int i; - if(af->data) - mp_free(af->data); for(i=0;i<AF_NCH;i++) if(((af_delay_t*)(af->setup))->q[i]) mp_free(((af_delay_t*)(af->setup))->q[i]); @@ -112,78 +105,80 @@ } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* in) { - mp_aframe_t* c = data; // Current working data - af_delay_t* s = af->setup; // Setup for this instance - int nch = c->nch; // Number of channels - int len = c->len/(c->format&MPAF_BPS_MASK); // Number of sample in data chunk - int ri = 0; - int ch,i; - for(ch=0;ch<nch;ch++){ - switch(c->format&MPAF_BPS_MASK){ - case 1:{ - int8_t* a = c->audio; - int8_t* q = s->q[ch]; - int wi = s->wi[ch]; - ri = s->ri; - for(i=ch;i<len;i+=nch){ - q[wi] = a[i]; - a[i] = q[ri]; - UPDATEQI(wi); - UPDATEQI(ri); - } - s->wi[ch] = wi; - break; + mp_aframe_t* c=new_mp_aframe_genome(in); + mp_alloc_aframe(c); + memcpy(c->audio,in->audio,c->len); + + af_delay_t* s = af->setup; // Setup for this instance + int nch = c->nch; // Number of channels + int len = c->len/(c->format&MPAF_BPS_MASK); // Number of sample in data chunk + int ri = 0; + int ch,i; + + for(ch=0;ch<nch;ch++){ + switch(c->format&MPAF_BPS_MASK){ + case 1:{ + int8_t* a = c->audio; + int8_t* q = s->q[ch]; + int wi = s->wi[ch]; + ri = s->ri; + for(i=ch;i<len;i+=nch){ + q[wi] = a[i]; + a[i] = q[ri]; + UPDATEQI(wi); + UPDATEQI(ri); + } + s->wi[ch] = wi; + break; + } + case 2:{ + int16_t* a = c->audio; + int16_t* q = s->q[ch]; + int wi = s->wi[ch]; + ri = s->ri; + for(i=ch;i<len;i+=nch){ + q[wi] = a[i]; + a[i] = q[ri]; + UPDATEQI(wi); + UPDATEQI(ri); + } + s->wi[ch] = wi; + break; + } + case 4:{ + int32_t* a = c->audio; + int32_t* q = s->q[ch]; + int wi = s->wi[ch]; + ri = s->ri; + for(i=ch;i<len;i+=nch){ + q[wi] = a[i]; + a[i] = q[ri]; + UPDATEQI(wi); + UPDATEQI(ri); + } + s->wi[ch] = wi; + break; + } } - case 2:{ - int16_t* a = c->audio; - int16_t* q = s->q[ch]; - int wi = s->wi[ch]; - ri = s->ri; - for(i=ch;i<len;i+=nch){ - q[wi] = a[i]; - a[i] = q[ri]; - UPDATEQI(wi); - UPDATEQI(ri); - } - s->wi[ch] = wi; - break; } - case 4:{ - int32_t* a = c->audio; - int32_t* q = s->q[ch]; - int wi = s->wi[ch]; - ri = s->ri; - for(i=ch;i<len;i+=nch){ - q[wi] = a[i]; - a[i] = q[ri]; - UPDATEQI(wi); - UPDATEQI(ri); - } - s->wi[ch] = wi; - break; - } - } - } - s->ri = ri; - return c; + s->ri = ri; + return c; } // Allocate memory and set function pointers static MPXP_Rc __FASTCALL__ af_open(af_instance_t* af){ - af->config=config; - af->control=control; - af->uninit=uninit; - af->play=play; - af->mul.n=1; - af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); - af->setup=mp_calloc(1,sizeof(af_delay_t)); - if(af->data == NULL || af->setup == NULL) - return MPXP_Error; + af->config=config; + af->control=control; + af->uninit=uninit; + af->play=play; + af->mul.n=1; + af->mul.d=1; + af->setup=mp_calloc(1,sizeof(af_delay_t)); + if(af->setup == NULL) return MPXP_Error; check_pin("afilter",af->pin,AF_PIN); - return MPXP_Ok; + return MPXP_Ok; } // Description of this filter Modified: mplayerxp/postproc/af_dummy.c =================================================================== --- mplayerxp/postproc/af_dummy.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_dummy.c 2012-11-17 10:42:51 UTC (rev 389) @@ -9,10 +9,11 @@ #include "osdep/mplib.h" #include "pp_msg.h" -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { - memcpy(af->data,arg,sizeof(mp_aframe_t)); - MSG_V("[dummy] Was reinitialized, rate=%iHz, nch = %i, format = 0x%08X\n",af->data->rate,af->data->nch,af->data->format); + memcpy(&af->conf,arg,sizeof(af_conf_t)); + MSG_V("[dummy] Was reinitialized, rate=%iHz, nch = %i, format = 0x%08X\n" + ,af->conf.rate,af->conf.nch,af->conf.format); return MPXP_Ok; } // Initialization and runtime control @@ -24,17 +25,15 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* data) { - // Do something necessary to get rid of annoying warning during compile - if(!af) - MSG_ERR("EEEK: Argument af == NULL in af_dummy.c play()."); - return data; + // Do something necessary to get rid of annoying warning during compile + if(!af) + MSG_ERR("EEEK: Argument af == NULL in af_dummy.c play()."); + return data; } // Allocate memory and set function pointers @@ -45,10 +44,7 @@ af->play=play; af->mul.d=1; af->mul.n=1; - af->data=mp_malloc(sizeof(mp_aframe_t)); - if(af->data == NULL) - return MPXP_Error; - check_pin("afilter",af->pin,AF_PIN); + check_pin("afilter",af->pin,AF_PIN); return MPXP_Ok; } Modified: mplayerxp/postproc/af_dyn.c =================================================================== --- mplayerxp/postproc/af_dyn.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_dyn.c 2012-11-17 10:42:51 UTC (rev 389) @@ -26,15 +26,14 @@ float gain; }af_dyn_t; -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { - af_dyn_t* s = (af_dyn_t*)af->setup; // Sanity check if(!arg) return MPXP_Error; - af->data->rate = arg->rate; - af->data->nch = arg->nch; - af->data->format = MPAF_F|MPAF_NE|4; + af->conf.rate = arg->rate; + af->conf.nch = arg->nch; + af->conf.format = MPAF_F|MPAF_NE|4; return af_test_output(af,arg); } @@ -59,35 +58,36 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); - if(af->setup) - mp_free(af->setup); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* ind) { - register unsigned i = 0; - float *in = (float*)data->audio; // Audio data - af_dyn_t *s=af->setup; - unsigned nsamples = data->len/4; // Number of samples - float d,l; - int sign; - for(i = 0; i < nsamples; i++) { + unsigned i = 0; + float* in = (float*)ind->audio;// Audio data + af_dyn_t* s=af->setup; + unsigned nsamples = ind->len/4; // Number of samples + float d,l; + int sign; + mp_aframe_t*outd= new_mp_aframe_genome(ind); + mp_alloc_aframe(outd); + float* out = (float*)outd->audio;// Audio data + + for(i = 0; i < nsamples; i++) { d = *in; if (d == 0.0) l = 0; else { - if (d < 0.0) { - d *= -1.0; - sign = -1; - } else sign = 1; - l = pow(s->gain, log10(d))*sign; + if (d < 0.0) { + d *= -1.0; + sign = -1; + } else sign = 1; + l = pow(s->gain, log10(d))*sign; } - *in++ = l; - } + *out++ = l; + } - return data; + return outd; } // Allocate memory and set function pointers @@ -98,9 +98,8 @@ af->play=play; af->mul.n=1; af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); af->setup=mp_calloc(1,sizeof(af_dyn_t)); - if(af->data == NULL || af->setup==NULL) return MPXP_Error; + if(af->setup==NULL) return MPXP_Error; ((af_dyn_t *)(af->setup))->gain=8.; check_pin("afilter",af->pin,AF_PIN); return MPXP_Ok; Modified: mplayerxp/postproc/af_echo3d.c =================================================================== --- mplayerxp/postproc/af_echo3d.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_echo3d.c 2012-11-17 10:42:51 UTC (rev 389) @@ -88,80 +88,77 @@ * quite nice echo */ -static void __FASTCALL__ echo3d(af_crystality_t *s,float *data, unsigned datasize) +static mp_aframe_t* __FASTCALL__ echo3d(af_crystality_t *s,const mp_aframe_t* in) { - unsigned x,i; - float _left, _right, dif, leftc, rightc, left[4], right[4]; - float *dataptr; - float lt, rt; - unsigned weight[2][3] = { { 9, 8, 8 }, { 11, 9, 10 }}; + unsigned x,i; + float _left, _right, dif, leftc, rightc, left[4], right[4]; + float *inptr,*outptr; + float lt, rt; + unsigned weight[2][3] = { { 9, 8, 8 }, { 11, 9, 10 }}; + mp_aframe_t* out = new_mp_aframe_genome(in); + mp_alloc_aframe(out); - s->_bufPos = s->buf_size - 1; - s->bufPos[0] = 1 + s->buf_size - DELAY1; - s->bufPos[1] = 1 + s->buf_size - DELAY1 - DELAY2; - s->bufPos[2] = 1 + s->buf_size - DELAY1 - DELAY2 - DELAY3; - dataptr = data; + s->_bufPos = s->buf_size - 1; + s->bufPos[0] = 1 + s->buf_size - DELAY1; + s->bufPos[1] = 1 + s->buf_size - DELAY1 - DELAY2; + s->bufPos[2] = 1 + s->buf_size - DELAY1 - DELAY2 - DELAY3; + inptr = in->audio; + outptr = in->audio; - for (x = 0; x < datasize; x += 8) { + for (x = 0; x < in->len; x += 8) { + // ************ load sample ********** + left[0] = inptr[0]; + right[0] = inptr[1]; - // ************ load sample ********** - left[0] = dataptr[0]; - right[0] = dataptr[1]; - - leftc = rightc = 0; - // ************ calc echos ********** - for(i=0;i<(unsigned)s->echos;i++) - { - dif = (left[i] - right[i]); - // ************ slightly expand stereo for direct input ********** - left[i] += dif; - right[i] -= dif; - left[i] *= 0.5; - right[i] *= 0.5; - // ************ compute echo ********** - left[i+1] = s->buf[s->bufPos[i]++]; - if (s->bufPos[i] == s->buf_size) s->bufPos[i] = 0; - right[i+1] = s->buf[s->bufPos[i]++]; - if (s->bufPos[i] == s->buf_size) s->bufPos[i] = 0; - leftc += left[i]/weight[0][i]; - rightc += right[i]/weight[1][i]; + leftc = rightc = 0; + // ************ calc echos ********** + for(i=0;i<(unsigned)s->echos;i++) { + dif = (left[i] - right[i]); + // ************ slightly expand stereo for direct input ********** + left[i] += dif; + right[i] -= dif; + left[i] *= 0.5; + right[i] *= 0.5; + // ************ compute echo ********** + left[i+1] = s->buf[s->bufPos[i]++]; + if (s->bufPos[i] == s->buf_size) s->bufPos[i] = 0; + right[i+1] = s->buf[s->bufPos[i]++]; + if (s->bufPos[i] == s->buf_size) s->bufPos[i] = 0; + leftc += left[i]/weight[0][i]; + rightc += right[i]/weight[1][i]; + } + // ************ mix reverb with (near to) direct input ********** + _left = s->left0p + leftc * s->echo_sfactor / 16; + _right = s->right0p + rightc * s->echo_sfactor / 16; + /* do not reverb high frequencies (filter) */ + lt=(lowpass(&s->lp_reverb[0],leftc+left[0]/2)*s->feedback_sfactor)/256; + rt=(lowpass(&s->lp_reverb[1],rightc+right[0]/2)*s->feedback_sfactor)/256;; + s->buf[s->_bufPos++] = lt; + if (s->_bufPos == s->buf_size) s->_bufPos = 0; + s->buf[s->_bufPos++] = rt; + if (s->_bufPos == s->buf_size) s->_bufPos = 0; + s->left0p = left[0]; + s->right0p = right[0]; + // ************ store sample ********** + outptr[0] = clamp(_left,INT_MIN,INT_MAX); + outptr[1] = clamp(_right,INT_MIN,INT_MAX); + inptr += 2; + outptr += 2; } - - // ************ mix reverb with (near to) direct input ********** - _left = s->left0p + leftc * s->echo_sfactor / 16; - _right = s->right0p + rightc * s->echo_sfactor / 16; - - /* do not reverb high frequencies (filter) */ - lt=(lowpass(&s->lp_reverb[0],leftc+left[0]/2)*s->feedback_sfactor)/256; - rt=(lowpass(&s->lp_reverb[1],rightc+right[0]/2)*s->feedback_sfactor)/256;; - - s->buf[s->_bufPos++] = lt; - if (s->_bufPos == s->buf_size) s->_bufPos = 0; - s->buf[s->_bufPos++] = rt; - if (s->_bufPos == s->buf_size) s->_bufPos = 0; - - s->left0p = left[0]; - s->right0p = right[0]; - - // ************ store sample ********** - dataptr[0] = clamp(_left,INT_MIN,INT_MAX); - dataptr[1] = clamp(_right,INT_MIN,INT_MAX); - dataptr += 2; - - } + return out; } -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { af_crystality_t* s = (af_crystality_t*)af->setup; // Sanity check if(!arg) return MPXP_Error; if(arg->nch!=2) return MPXP_Error; - af->data->rate = arg->rate; - af->data->nch = arg->nch; - af->data->format = MPAF_NE|MPAF_F|4; - init_echo3d(s,af->data->rate); + af->conf.rate = arg->rate; + af->conf.nch = arg->nch; + af->conf.format = MPAF_NE|MPAF_F|4; + init_echo3d(s,af->conf.rate); return af_test_output(af,arg); } @@ -187,20 +184,14 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); - if(((af_crystality_t *)af->setup)->buf) mp_free(((af_crystality_t *)af->setup)->buf); - if(af->setup) - mp_free(af->setup); + if(((af_crystality_t *)af->setup)->buf) mp_free(((af_crystality_t *)af->setup)->buf); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af,const mp_aframe_t* in) { - mp_aframe_t* c = data; /* Current working data */ - - echo3d(af->setup,(float*)c->audio, c->len); - return c; + return echo3d(af->setup,in); } // Allocate memory and set function pointers @@ -211,10 +202,8 @@ af->play=play; af->mul.n=1; af->mul.d=1; - af->data=mp_calloc(1,sizeof(mp_aframe_t)); af->setup=mp_calloc(1,sizeof(af_crystality_t)); - if(af->data == NULL || af->setup == NULL) - return MPXP_Error; + if(af->setup == NULL) return MPXP_Error; set_defaults(af->setup); init_echo3d(af->setup,44100); check_pin("afilter",af->pin,AF_PIN); Modified: mplayerxp/postproc/af_equalizer.c =================================================================== --- mplayerxp/postproc/af_equalizer.c 2012-11-17 05:26:00 UTC (rev 388) +++ mplayerxp/postproc/af_equalizer.c 2012-11-17 10:42:51 UTC (rev 389) @@ -74,7 +74,7 @@ b[1] = -1.0050; } -static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const mp_aframe_t* arg) +static MPXP_Rc __FASTCALL__ config(struct af_instance_s* af,const af_conf_t* arg) { af_equalizer_t* s = (af_equalizer_t*)af->setup; unsigned k =0; @@ -83,14 +83,13 @@ // Sanity check if(!arg) return MPXP_Error; - af->data->rate = arg->rate; - af->data->nch = arg->nch; - af->data->format = MPAF_NE|MPAF_F|4; + af->conf.rate = arg->rate; + af->conf.nch = arg->nch; + af->conf.format = MPAF_NE|MPAF_F|4; // Calculate number of active filters s->K=KM; - while(F[s->K-1] > (float)af->data->rate/2.2) - s->K--; + while(F[s->K-1] > (float)af->conf.rate/2.2) s->K--; if(s->K != KM) MSG_INFO("[equalizer] Limiting the number of filters to" @@ -98,10 +97,10 @@ // Generate filter taps for(k=0;k<s->K;k++) - bp2(s->a[k],s->b[k],F[k]/((float)af->data->rate),Q); + bp2(s->a[k],s->b[k],F[k]/((float)af->conf.rate),Q); // Calculate how much this plugin adds to the overall time delay - af->delay += 2000.0/((float)af->data->rate); + af->delay += 2000.0/((float)af->conf.rate); return af_test_output(af,arg); } @@ -164,49 +163,47 @@ // Deallocate memory static void __FASTCALL__ uninit(struct af_instance_s* af) { - if(af->data) - mp_free(af->data); - if(af->setup) - mp_free(af->setup); + if(af->setup) mp_free(af->setup); } // Filter data through filter -static mp_aframe_t* __FASTCALL__ play(struct af_instance_s* af, mp_aframe_t* data,int final) +static mp_aframe_t* __FASTCA... [truncated message content] |