File: 20-overflow-fixes.patch

package info (click to toggle)
gramofile 1.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,440 kB
  • sloc: ansic: 11,252; makefile: 60
file content (59 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Patch by James Tappin <james@xena.uklinux.net>
# Rediffed into unified format. [dk]
Index: gramofile/signpr_cmf2.c
===================================================================
--- gramofile.orig/signpr_cmf2.c	2011-08-14 13:21:45.869218469 +0200
+++ gramofile/signpr_cmf2.c	2011-08-14 13:27:14.797217296 +0200
@@ -646,19 +646,25 @@
 
   /* Should be /64, but the signal is extremely soft, so divide by less to
      get more quantization levels (more accurate) */
-  sum.left /= 10;
-  sum.right /= 10;
+  sum.left /= 4;
+  sum.right /= 4;
 #endif
 
-  if (sum.left < 32767)
-    sample.left = sum.left;
-  else
+  if (sum.left > 32767)
     sample.left = 32767;
-
-  if (sum.right < 32767)
-    sample.right = sum.right;
+  else if (sum.left < -32768)
+    sample.left = -32768;
   else
+    sample.left = sum.left;
+
+
+  if (sum.right > 32767)
     sample.right = 32767;
+  else if (sum.right < -32768)
+    sample.right = -32768;
+  else 
+    sample.right = sum.right;
+
 
   return sample;
 }
@@ -762,6 +768,9 @@
     b_t.left;
   if (i > 32767)
     i = 32767;
+  else if (i < -32768)
+    i = -32768;
+
   returnval.left = i;
 
   i = (labs (w_t.right - b_t.right) * 1000)
@@ -769,6 +778,8 @@
     b_t.right;
   if (i > 32767)
     i = 32767;
+  else if (i < -32768)
+    i = -32768;
   returnval.right = i;
 
   return returnval;