shithub: opus-tools

Download patch

ref: 4430ea0b032e95615a58969589a8bf5ecd8ccfbc
parent: 1229864e13f1e0818219bd54b097c9b08d4e1cc6
author: Gregory Maxwell <greg@xiph.org>
date: Tue Jul 10 20:08:39 EDT 2012

Add support for the OPUS_SET_GAIN CTL if available.

This moves the opus gain rescaling into the codec itself.

--- a/src/opusdec.c
+++ b/src/opusdec.c
@@ -452,7 +452,23 @@
 
    *streams=header.nb_streams;
 
-   *gain = pow(10., header.gain/5120.);
+   if(header.gain!=0)
+   {
+      /*Gain API added in a newer libopus version..*/
+#ifdef OPUS_SET_GAIN
+      err=opus_multistream_decoder_ctl(st,OPUS_SET_GAIN(header.gain));
+      if(err==OPUS_UNIMPLEMENTED)
+      {
+#endif
+         *gain = pow(10., header.gain/5120.);
+#ifdef OPUS_SET_GAIN
+      } else if (err!=OPUS_OK)
+      {
+         fprintf (stderr, "Error setting gain: %s\n", opus_strerror(err));
+         return NULL;
+      }
+#endif
+   }
 
    if (!quiet)
    {