summaryrefslogtreecommitdiff
path: root/celt
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2017-06-01 03:14:13 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2017-06-01 03:14:13 -0400
commit0cc4d9659aaa35c8a21af0e7a8927bf9132315bf (patch)
tree9479e536ccff07077dc9e5a2a27389e3f112617d /celt
parenta1c2d71803b0a4a0ceac644270b9ff23ee81a3f3 (diff)
downloadopus-0cc4d9659aaa35c8a21af0e7a8927bf9132315bf.tar.gz
Adding leakage modelling to boost bandsexp_leakage7
We boost bands that either cause leakage or are filled with leakage
Diffstat (limited to 'celt')
-rw-r--r--celt/celt.h4
-rw-r--r--celt/celt_encoder.c24
2 files changed, 22 insertions, 6 deletions
diff --git a/celt/celt.h b/celt/celt.h
index d69cd44c..70175301 100644
--- a/celt/celt.h
+++ b/celt/celt.h
@@ -50,6 +50,8 @@ extern "C" {
#define CELTDecoder OpusCustomDecoder
#define CELTMode OpusCustomMode
+#define LEAK_BANDS 19
+
typedef struct {
int valid;
float tonality;
@@ -60,6 +62,8 @@ typedef struct {
float vad_prob;
int bandwidth;
float activity_probability;
+ /* Store as Q6 char to save space. */
+ unsigned char leak_boost[LEAK_BANDS];
} AnalysisInfo;
typedef struct {
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index 187cccce..5729dc35 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -964,7 +964,7 @@ static opus_val16 median_of_3(const opus_val16 *x)
static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 *bandLogE2,
int nbEBands, int start, int end, int C, int *offsets, int lsb_depth, const opus_int16 *logN,
int isTransient, int vbr, int constrained_vbr, const opus_int16 *eBands, int LM,
- int effectiveBytes, opus_int32 *tot_boost_, int lfe, opus_val16 *surround_dynalloc)
+ int effectiveBytes, opus_int32 *tot_boost_, int lfe, opus_val16 *surround_dynalloc, AnalysisInfo *analysis)
{
int i, c;
opus_int32 tot_boost=0;
@@ -1054,14 +1054,26 @@ static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16
}
for (i=start;i<end;i++)
{
- int width;
- int boost;
- int boost_bits;
-
if (i<8)
follower[i] *= 2;
if (i>=12)
follower[i] = HALF16(follower[i]);
+ }
+#ifdef DISABLE_FLOAT_API
+ (void)analysis;
+#else
+ if (analysis->valid)
+ {
+ for (i=start;i<IMIN(LEAK_BANDS, end);i++)
+ follower[i] = follower[i] + QCONST16(1.f/64.f, DB_SHIFT)*analysis->leak_boost[i];
+ }
+#endif
+ for (i=start;i<end;i++)
+ {
+ int width;
+ int boost;
+ int boost_bits;
+
follower[i] = MIN16(follower[i], QCONST16(4, DB_SHIFT));
width = C*(eBands[i+1]-eBands[i])<<LM;
@@ -1893,7 +1905,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
maxDepth = dynalloc_analysis(bandLogE, bandLogE2, nbEBands, start, end, C, offsets,
st->lsb_depth, mode->logN, isTransient, st->vbr, st->constrained_vbr,
- eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc);
+ eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc, &st->analysis);
/* For LFE, everything interesting is in the first band */
if (st->lfe)
offsets[0] = IMIN(8, effectiveBytes/3);