[MPlayer-dev-eng] [PATCH] patch for af_hrtf to relieve noises

Xidorn Quan quanxunzhen at gmail.com
Sun Oct 21 12:44:12 CEST 2012


On Sun, Oct 21, 2012 at 4:00 PM, Vladimir Mosgalin <mosgalin at vm10124.spb.edu
> wrote:

> Hi Xidorn Quan!
>
>  On 2012.10.21 at 10:45:19 +0800, Xidorn Quan wrote next:
>
> > > On Sat, Oct 20, 2012 at 11:21:32PM +0800, Xidorn Quan wrote:
> > > > Hi,
> > > >
> > > > A simple patch is attached which is intend to relieve noises for
> > > > af_hrtf by using clamp instead of casting directly.
> > >
> > > Not sure if overflows are supposed to be possible, it might just hide
> > > an issue somewhere else.
> > >
> >
> > Well, I think it is true that it hides an issue somewhere else since
> > there are still some noises after clamping when remixing stereo. This
> > patch only relieve some of the noises.
>
> Clamp will produce distortion just as well..
>

Yes, but at least it can significantly alleviate noises at present.


> Maybe hrtf filter doesn't use correct (properly downscaled) coefficients
> or something when downmixing?
>

I do not know exactly what's wrong inside the filter yet. But as
I have said above, I will try to solve this problem thoroughly when
I have time.


> It's quite common problem for hrtf filter to cause crackling noise when
> there is loud sound in original multichannel track. For many tracks it's
> a must to use something like -af volume=-5,hrtf and for some very loud
> tracks in action movies sometimes even volume=-10 is required. In
> neither case original tracks have overflows in any channel, they are
> produced in hrtf filter itself.
>

Decreasing the volume can indeed relieve the noise as well. And since
it could overflow, I think it is a good idea to clamp it.

BTW, the patch using av_clip_* instead has been attached.
-------------- next part --------------
Index: libaf/af_hrtf.c
===================================================================
--- libaf/af_hrtf.c	(revision 35255)
+++ libaf/af_hrtf.c	(working copy)
@@ -26,6 +26,7 @@
 #include <inttypes.h>
 
 #include <math.h>
+#include <libavutil/common.h>
 
 #include "mp_msg.h"
 #include "af.h"
@@ -542,16 +543,16 @@
 	      perception.  Note: Too much will destroy the acoustic space
 	      and may even result in headaches. */
 	   diff = STEXPAND2 * (left - right);
-	   out[0] = (int16_t)(left  + diff);
-	   out[1] = (int16_t)(right - diff);
+	   out[0] = av_clip_int16(left  + diff);
+	   out[1] = av_clip_int16(right - diff);
 	   break;
 	case HRTF_MIX_MATRIX2CH:
 	   /* Do attempt any stereo expansion with matrix encoded
 	      sources.  The L, R channels are already stereo expanded
 	      by the steering, any further stereo expansion will sound
 	      very unnatural. */
-	   out[0] = (int16_t)left;
-	   out[1] = (int16_t)right;
+	   out[0] = av_clip_int16(left);
+	   out[1] = av_clip_int16(right);
 	   break;
 	}
 


More information about the MPlayer-dev-eng mailing list