summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--silk/dred_coding.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/silk/dred_coding.c b/silk/dred_coding.c
index d2e71c74..9b0381d2 100644
--- a/silk/dred_coding.c
+++ b/silk/dred_coding.c
@@ -77,6 +77,8 @@ void dred_encode_latents(ec_enc *enc, const float *x, const opus_uint16 *scale,
xq = x[i]*scale[i]*(1.f/256.f);
xq = xq - delta*tanh(xq/(delta+eps));
q = (int)floor(.5f+xq);
+ /* Make the impossible actually impossible. */
+ if (r[i] == 0 || p0[i] >= 32768) q = 0;
ec_laplace_encode_p0(enc, q, p0[i], r[i]);
}
}
@@ -190,4 +192,4 @@ int main()
printf("\n");
}
}
-#endif \ No newline at end of file
+#endif