summaryrefslogtreecommitdiff
path: root/pjmedia/src
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-03-21 11:59:15 +0000
committerBenny Prijono <bennylp@teluu.com>2006-03-21 11:59:15 +0000
commit1ac65f3b18e59cd2206dfb8c237ca1007e1d873e (patch)
treec1c34eca18160c62a9effc79e09ffdd449bc8ae7 /pjmedia/src
parent61ff349aa29d8d3457120275a7213b72b57b785f (diff)
Added macro to exclude filters in resample and added options to select resample algorithm in conference
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@347 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/src')
-rw-r--r--pjmedia/src/pjmedia/conference.c19
-rw-r--r--pjmedia/src/pjmedia/largefilter.h4
-rw-r--r--pjmedia/src/pjmedia/resample.c50
-rw-r--r--pjmedia/src/pjmedia/smallfilter.h4
4 files changed, 63 insertions, 14 deletions
diff --git a/pjmedia/src/pjmedia/conference.c b/pjmedia/src/pjmedia/conference.c
index 456dcc4f..c6cb1278 100644
--- a/pjmedia/src/pjmedia/conference.c
+++ b/pjmedia/src/pjmedia/conference.c
@@ -237,18 +237,21 @@ static pj_status_t create_conf_port( pj_pool_t *pool,
*/
if (conf_port->clock_rate != conf->clock_rate) {
- double factor;
+ pj_bool_t high_quality;
+ pj_bool_t large_filter;
- factor = 1.0 * conf_port->clock_rate / conf->clock_rate;
+ high_quality = ((conf->options & PJMEDIA_CONF_USE_LINEAR)==0);
+ large_filter = ((conf->options & PJMEDIA_CONF_SMALL_FILTER)==0);
/* Create resample for rx buffer. */
status = pjmedia_resample_create( pool,
- PJ_TRUE, /* High quality */
- PJ_TRUE, /* Large filter */
+ high_quality,
+ large_filter,
conf_port->clock_rate,/* Rate in */
conf->clock_rate, /* Rate out */
- (unsigned)(conf->samples_per_frame *
- factor),
+ conf->samples_per_frame *
+ conf_port->clock_rate /
+ conf->clock_rate,
&conf_port->rx_resample);
if (status != PJ_SUCCESS)
return status;
@@ -256,8 +259,8 @@ static pj_status_t create_conf_port( pj_pool_t *pool,
/* Create resample for tx buffer. */
status = pjmedia_resample_create(pool,
- PJ_TRUE, /* High quality */
- PJ_TRUE, /* Large filter */
+ high_quality,
+ large_filter,
conf->clock_rate, /* Rate in */
conf_port->clock_rate, /* Rate out */
conf->samples_per_frame,
diff --git a/pjmedia/src/pjmedia/largefilter.h b/pjmedia/src/pjmedia/largefilter.h
index 16c0c3fc..d237b5cb 100644
--- a/pjmedia/src/pjmedia/largefilter.h
+++ b/pjmedia/src/pjmedia/largefilter.h
@@ -2,7 +2,7 @@
#define LARGE_FILTER_NMULT ((HWORD)65)
#define LARGE_FILTER_SCALE 14746 /* Unity-gain scale factor */
#define LARGE_FILTER_NWING 8192 /* Filter table length */
-static HWORD LARGE_FILTER_IMP[] /* Impulse response */ = {
+static const HWORD LARGE_FILTER_IMP[] /* Impulse response */ = {
32767,
32766,
32764,
@@ -8196,7 +8196,7 @@ static HWORD LARGE_FILTER_IMP[] /* Impulse response */ = {
0,
0};
-static HWORD LARGE_FILTER_IMPD[] /* Impulse response differences */ = {
+static const HWORD LARGE_FILTER_IMPD[] /* Impulse response differences */ = {
-1,
-2,
-3,
diff --git a/pjmedia/src/pjmedia/resample.c b/pjmedia/src/pjmedia/resample.c
index 246f4cc6..9045a02c 100644
--- a/pjmedia/src/pjmedia/resample.c
+++ b/pjmedia/src/pjmedia/resample.c
@@ -65,9 +65,12 @@
#include <pjmedia/resample.h>
#include <pjmedia/errno.h>
#include <pj/assert.h>
+#include <pj/log.h>
#include <pj/pool.h>
+#define THIS_FILE "resample.c"
+
/*
* Taken from stddefs.h
@@ -191,8 +194,26 @@ typedef unsigned int UWORD;
# pragma warning(disable: 4761) // integral size mismatch in argument; conversion supplied
#endif
-#include "smallfilter.h"
-#include "largefilter.h"
+#if defined(PJMEDIA_HAS_SMALL_FILTER) && PJMEDIA_HAS_SMALL_FILTER!=0
+# include "smallfilter.h"
+#else
+# define SMALL_FILTER_NMULT 0
+# define SMALL_FILTER_SCALE 0
+# define SMALL_FILTER_NWING 0
+# define SMALL_FILTER_IMP NULL
+# define SMALL_FILTER_IMPD NULL
+#endif
+
+#if defined(PJMEDIA_HAS_LARGE_FILTER) && PJMEDIA_HAS_LARGE_FILTER!=0
+# include "largefilter.h"
+#else
+# define LARGE_FILTER_NMULT 0
+# define LARGE_FILTER_SCALE 0
+# define LARGE_FILTER_NWING 0
+# define LARGE_FILTER_IMP NULL
+# define LARGE_FILTER_IMPD NULL
+#endif
+
#undef INLINE
#define INLINE
@@ -480,6 +501,31 @@ PJ_DEF(pj_status_t) pjmedia_resample_create( pj_pool_t *pool,
high_quality = 0;
}
+#if !defined(PJMEDIA_HAS_LARGE_FILTER) || PJMEDIA_HAS_LARGE_FILTER==0
+ /*
+ * If large filter is excluded in the build, then prevent application
+ * from using it.
+ */
+ if (high_quality && large_filter) {
+ large_filter = PJ_FALSE;
+ PJ_LOG(5,(THIS_FILE,
+ "Resample uses small filter because large filter is "
+ "disabled"));
+ }
+#endif
+
+#if !defined(PJMEDIA_HAS_SMALL_FILTER) || PJMEDIA_HAS_SMALL_FILTER==0
+ /*
+ * If small filter is excluded in the build and application wants to
+ * use it, then drop to linear conversion.
+ */
+ if (high_quality && large_filter == 0) {
+ high_quality = PJ_FALSE;
+ PJ_LOG(4,(THIS_FILE,
+ "Resample uses linear because small filter is disabled"));
+ }
+#endif
+
resample->factor = rate_out * 1.0 / rate_in;
resample->large_filter = large_filter;
resample->high_quality = high_quality;
diff --git a/pjmedia/src/pjmedia/smallfilter.h b/pjmedia/src/pjmedia/smallfilter.h
index 6f6f0f84..367999d4 100644
--- a/pjmedia/src/pjmedia/smallfilter.h
+++ b/pjmedia/src/pjmedia/smallfilter.h
@@ -2,7 +2,7 @@
#define SMALL_FILTER_NMULT ((HWORD)13)
#define SMALL_FILTER_SCALE 13128 /* Unity-gain scale factor */
#define SMALL_FILTER_NWING 1536 /* Filter table length */
-static HWORD SMALL_FILTER_IMP[] /* Impulse response */ = {
+static const HWORD SMALL_FILTER_IMP[] /* Impulse response */ = {
32767,
32766,
32764,
@@ -1541,7 +1541,7 @@ static HWORD SMALL_FILTER_IMP[] /* Impulse response */ = {
-1
};
-static HWORD SMALL_FILTER_IMPD[] = {
+static const HWORD SMALL_FILTER_IMPD[] = {
-1,
-2,
-4,