[MPlayer-dev-eng] Re: Proposed changes to af_resample

Anders Johansson ajh at watri.uwa.edu.au
Wed Jan 8 01:46:19 CET 2003


Hi,

> Anders Johansson wrote:
> > [Arpi wrote:]
> > > imho if they are almost same, then no resampling should be done!
> > > video will play a little bit slower/faster but no one can notice +-1% ...
> > 
> > I am trying to avoid this cause it will mean a redesign of the
> > automatic filter insertion or an interface redesign or an ugly
> > hack. Perhaps the best solution is to fix it in
> > libmpcodecs/dec_audio.c ?
> 
> I don't see why this would mean a redesign...
> AFAICS the resample plugin is inserted in af.c line 350ff:
> 
> |    // Check output frequency if not OK fix with resample
> |    if(s->last->data->rate!=s->output.rate){
> [...]
> 
> So if one could change the compare in the following way:
> 
> /*
>  * maxdeviation is between 0 and 1 and defines the maximum deviation
>  * from target allowed in percent.
>  */
> 
> #define almost_eq(x, target, maxdeviation) \
> 	((target*(1-maxdeviation) <= x) && \
> 	 (x <= target*(1+maxdeviation)))
> 
> // Check output frequency if not OK fix with resample
> if (!almost_eq(s->last->data->rate, s->output.rate, s->cfg.sloppycompareaccuracy){
> 

This is the redesign of the automatic filter insertion hack I was
talking about, don't miss-interpret me the code is not ugly it is a good
solution, but the result is ugly:

There is no override for a per instance exact resampling configuration
(resample is reentrant) option, which may be desirable in mencoder
when multiple streams are present.



Hence there are two other options to use adding one more return value
from the filter that says "I didn't fix anything but don't worry" to
libaf (thats the interface redesign) and the ugly hack (which may
actually be the best solution in this case), and that is for resample to
change the incoming sample frequency. This would include modifying
line 369 to 

if(!af || (AF_OK <= af->control(af,AF_CONTROL_RESAMPLE_RATE,
		          &(s->output.rate))))


and let resample edit s->output.rate, but as I said it is an ugly hack.

//Anders




More information about the MPlayer-dev-eng mailing list