reas results with 2 bit slope and 1 bit mag quantiser 1-3k, with dec by 4, and refact...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 11 Aug 2017 07:47:14 +0000 (07:47 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 11 Aug 2017 07:47:14 +0000 (07:47 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3352 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/closed_quant_slope.m [new file with mode: 0644]
codec2-dev/octave/open_quant_slope.m [new file with mode: 0644]
codec2-dev/octave/vq_search_slope.m

diff --git a/codec2-dev/octave/closed_quant_slope.m b/codec2-dev/octave/closed_quant_slope.m
new file mode 100644 (file)
index 0000000..7d5a465
--- /dev/null
@@ -0,0 +1,3 @@
+function b = closed_quant_slope(b)
+  b(1) = max(0.5, b(1));
+end
diff --git a/codec2-dev/octave/open_quant_slope.m b/codec2-dev/octave/open_quant_slope.m
new file mode 100644 (file)
index 0000000..2096554
--- /dev/null
@@ -0,0 +1,4 @@
+function b = open_quant_slope(b)
+  b(2) = quantise([-1 -0.5 0.5 1], b(2));
+  b(1) = quantise([0.5 1.0], b(1));
+end
index f0c6cb820588fa6fcf8de51858576f2cc5540fba..7f4d3349bda4abb07cfe441af6b5ae570e756569 100644 (file)
@@ -27,9 +27,9 @@ function [idx contrib errors b_log2] = vq_search_slope(vq, data, closed_quant_fn
     for i=1:nVec
       c = [sum(target) target*(1:nCols)' target*vq(i,:)' ]';
       b = inv(A(:,:,i))*c;
-      if nargin == 3;
+      if nargin >= 3;
         b = feval(closed_quant_fn,b);
-      end;  
+      end
       b_log(i,:) = b; 
       
       diff(i,:) = target - (b(1)*vq(i,:) + b(2)*(1:nCols) + b(3));
@@ -43,9 +43,17 @@ function [idx contrib errors b_log2] = vq_search_slope(vq, data, closed_quant_fn
     errors(f) = mn; 
     idx(f) = min_ind(1);
     b = b_log(min_ind,:);
-    b_log2(f,:) = b;
+
+    % optional quantisation performed after error min loop
+    % - note we recalc gain to match energy after quantisation
     
-    %printf("f: %d i: %d mg: %f sl: %f g: %f\n", f, idx(f), b(1), b(2), b(3));
+    if nargin == 4
+      b = feval(open_quant_fn, b);
+      b(3) = (sum(target) - sum(b(1)*vq(min_ind,:) + b(2)*(1:nCols)))/nCols;    
+    end
+
+    printf("f: %d i: %d mg: %f sl: %f g: %f\n", f, idx(f), b(1), b(2), b(3));
+    b_log2(f,:) = b;
     contrib(f,:) = b(1)*vq(min_ind,:) + b(2)*(1:nCols) + b(3);
   end