shithub: opus

Download patch

ref: eb17b5e00e2903e14f429988fcb5bc56ea0602db
parent: e2f1aac572994feaf6162df2c39ef755c00831fd
author: Jean-Marc Valin <[email protected]>
date: Thu Oct 13 08:39:15 EDT 2011

Doing a best for "unprotected" switches to 2.5 ms frames

--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -451,12 +451,23 @@
     }
     if (transition)
     {
-    	for (i=0;i<st->channels*F2_5;i++)
-    		pcm[i] = pcm_transition[i];
-    	if (audiosize >= F5)
-    	    smooth_fade(pcm_transition+st->channels*F2_5, pcm+st->channels*F2_5,
-    	            pcm+st->channels*F2_5, F2_5,
-    	            st->channels, window, st->Fs);
+       if (audiosize >= F5)
+       {
+          for (i=0;i<st->channels*F2_5;i++)
+             pcm[i] = pcm_transition[i];
+          smooth_fade(pcm_transition+st->channels*F2_5, pcm+st->channels*F2_5,
+                pcm+st->channels*F2_5, F2_5,
+                st->channels, window, st->Fs);
+       } else {
+          /* Not enough time to do a clean transition, but we do it anyway
+             This will not preserve amplitude perfectly and may introduce
+             a bit of temporal aliasing, but it shouldn't be too bad and
+             that's pretty much the best we can do. In any case, generating this
+             transition it pretty silly in the first place */
+          smooth_fade(pcm_transition, pcm,
+                pcm, F2_5,
+                st->channels, window, st->Fs);
+       }
     }
 
     if (len <= 1)