File: diff_codec.m

package info (click to toggle)
codec2 0.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 113,072 kB
  • sloc: ansic: 412,877; python: 4,004; sh: 1,540; objc: 817; asm: 683; makefile: 588
file content (96 lines) | stat: -rw-r--r-- 1,989 bytes parent folder | download | duplicates (6)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
% diff_codec.m
%
% Plots differences between two states in two runs of the codec,
% e.g. x86 and embedded.
%
% Copyright David Rowe 2013
%
% This program is distributed under the terms of the GNU General Public License 
% Version 2

function diff_codec(samname1, samname2, model1_prefix, model2_prefix)
  
  fs1=fopen(samname1,"rb");
  s1=fread(fs1,Inf,"short");
  fs2=fopen(samname2,"rb");
  s2=fread(fs2,Inf,"short");

  st = 1;
  en = length(s1);

  figure(1);
  clf;
  subplot(211);
  l1 = strcat("r;",samname1,";");
  plot(s1(st:en), l1);
  axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
  subplot(212);
  l2 = strcat("r;",samname2,";");
  plot(s2(st:en),l2);
  axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
 
  figure(2)
  plot(s1(st:en)-s2(st:en));
  max(s1(st:en)-s2(st:en));
  
  model_name1 = strcat(model1_prefix,"_model.txt");
  model1 = load(model_name1);
  model_name1q = strcat(model1_prefix,"_qmodel.txt");
  model1q = load(model_name1q);

  model_name2 = strcat(model2_prefix,"_model.txt");
  model2 = load(model_name2);
  model_name2q = strcat(model2_prefix,"_qmodel.txt");
  model2q = load(model_name2q);

  Wo1 = model1(:,1);
  L1 = model1(:,2);
  Am1 = model1(:,3:82);
  Wo1q = model1q(:,1);
  L1q = model1q(:,2);
  Am1q = model1q(:,3:82);

  Wo2 = model2(:,1);
  L2 = model2(:,2);
  Am2 = model2(:,3:82);
  Wo2q = model2q(:,1);
  L2q = model2q(:,2);
  Am2q = model2q(:,3:82);

  figure(3)
  subplot(211)
  plot(Wo1)
  title('Wo1');
  subplot(212)
  plot(Wo1-Wo2)
  figure(4)
  subplot(211)
  plot(Wo1q)
  title('Wo1q');
  subplot(212)
  plot(Wo1q-Wo2q)

  figure(5)
  subplot(211)
  plot(L1)
  title('L1');
  subplot(212)
  plot(L1-L2)
  figure(6)
  subplot(211)
  plot(L1q)
  title('L1q');
  subplot(212)
  plot(L1q-L2q)
  
  figure(7)
  l=length(L1q);
  sm=zeros(1,l);
  for f=1:l
    %printf("f %d L1q %d L2q %d\n",f,L1q(f),L2q(f));  
    sm(f) = sum(10*log10(Am1q(f,1:L1q(f))) - 10*log10(Am2q(f,1:L2q(f))));
  end
  plot(sm)
  title('Am1q - Am2q');

endfunction