Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/celt
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-04-23 07:34:53 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-02 22:13:35 +0300
commit822c26b3e9655019d3d3d18bedd2bc185c8709ad (patch)
treef3af5f74b88bb4aaa27b81309ba8e52aa34fdc24 /celt
parentcc5776a24a5c1613a453d7809e80766ac11ab5e2 (diff)
Quality: Increase CELT rate for voiced frames in hybrid mode
Diffstat (limited to 'celt')
-rw-r--r--celt/celt.h12
-rw-r--r--celt/celt_encoder.c11
2 files changed, 22 insertions, 1 deletions
diff --git a/celt/celt.h b/celt/celt.h
index a423b950..1b8b86f9 100644
--- a/celt/celt.h
+++ b/celt/celt.h
@@ -58,12 +58,19 @@ typedef struct {
float activity;
float music_prob;
int bandwidth;
-}AnalysisInfo;
+} AnalysisInfo;
+
+typedef struct {
+ int signalType;
+ int offset;
+} SILKInfo;
#define __celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)))
#define __celt_check_analysis_ptr(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(ptr)))
+#define __celt_check_silkinfo_ptr(ptr) ((ptr) + ((ptr) - (const SILKInfo*)(ptr)))
+
/* Encoder/decoder Requests */
/* Expose this option again when variable framesize actually works */
@@ -116,6 +123,9 @@ typedef struct {
#define OPUS_SET_ENERGY_MASK_REQUEST 10026
#define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_ptr(x)
+#define CELT_SET_SILK_INFO_REQUEST 10028
+#define CELT_SET_SILK_INFO(x) CELT_SET_SILK_INFO_REQUEST, __celt_check_silkinfo_ptr(x)
+
/* Encoder stuff */
int celt_encoder_get_size(int channels);
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index 614f421f..763adcfc 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -98,6 +98,7 @@ struct OpusCustomEncoder {
#endif
int consec_transient;
AnalysisInfo analysis;
+ SILKInfo silk_info;
opus_val32 preemph_memE[2];
opus_val32 preemph_memD[2];
@@ -1935,6 +1936,9 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
temporal_vbr);
} else {
target = base_target;
+ /* Tonal frames (offset<100) need more bits than noisy (offset>100) ones. */
+ if (st->silk_info.offset < 100) target += 12 << BITRES >> (3-LM);
+ if (st->silk_info.offset > 100) target -= 18 << BITRES >> (3-LM);
/* If we have a strong transient, let's make sure it has enough bits to code
the first two bands, so that it can use folding rather than noise. */
if (tf_estimate > QCONST16(.7f,14))
@@ -2383,6 +2387,13 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...)
OPUS_COPY(&st->analysis, info, 1);
}
break;
+ case CELT_SET_SILK_INFO_REQUEST:
+ {
+ SILKInfo *info = va_arg(ap, SILKInfo *);
+ if (info)
+ OPUS_COPY(&st->silk_info, info, 1);
+ }
+ break;
case CELT_GET_MODE_REQUEST:
{
const CELTMode ** value = va_arg(ap, const CELTMode**);