Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
25298f29
Commit
25298f29
authored
17 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Allowing to add pulses on top of intra-band prediction
parent
50d11168
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libcelt/bands.c
+10
-6
10 additions, 6 deletions
libcelt/bands.c
libcelt/vq.c
+29
-7
29 additions, 7 deletions
libcelt/vq.c
with
39 additions
and
13 deletions
libcelt/bands.c
+
10
−
6
View file @
25298f29
...
...
@@ -36,10 +36,10 @@
const
int
qbank
[
NBANDS
+
2
]
=
{
0
,
2
,
4
,
6
,
8
,
12
,
16
,
20
,
24
,
28
,
36
,
44
,
52
,
68
,
84
,
116
,
128
};
const
int
qpulses
[
NBANDS
]
=
{
7
,
5
,
4
,
4
,
3
,
3
,
3
,
3
,
3
,
4
,
4
,
4
,
0
,
0
,
0
};
const
int
qpulses
[
NBANDS
]
=
{
7
,
5
,
4
,
4
,
3
,
3
,
3
,
4
,
4
,
4
,
-
2
,
-
1
,
-
1
,
-
1
,
0
};
//const int qpulses[NBANDS ] = {17,15,14,14,13, 13, 13, 13, 13, 14, 14, 14, 10, 10, 10};
#define WAVEFORM_END
52
#define WAVEFORM_END
36
/* Start frequency of each band */
int
pbank
[]
=
{
0
,
4
,
8
,
12
,
20
,
WAVEFORM_END
,
128
};
...
...
@@ -147,24 +147,28 @@ void quant_bands(float *X, int B, float *P)
{
int
i
,
j
;
float
norm
[
B
*
qbank
[
NBANDS
+
1
]];
//float bits = 0;
for
(
i
=
0
;
i
<
NBANDS
;
i
++
)
{
int
q
;
q
=
qpulses
[
i
];
if
(
q
)
{
if
(
q
>
0
)
{
float
n
=
sqrt
(
B
*
(
qbank
[
i
+
1
]
-
qbank
[
i
]));
alg_quant2
(
X
+
B
*
qbank
[
i
],
B
*
(
qbank
[
i
+
1
]
-
qbank
[
i
]),
q
,
P
+
B
*
qbank
[
i
]);
for
(
j
=
B
*
qbank
[
i
];
j
<
B
*
qbank
[
i
+
1
];
j
++
)
norm
[
j
]
=
X
[
j
]
*
n
;
//bits += log2(ncwrs(B*(qbank[i+1]-qbank[i]), q));
}
else
{
float
n
=
sqrt
(
B
*
(
qbank
[
i
+
1
]
-
qbank
[
i
]));
copy_quant
(
X
+
B
*
qbank
[
i
],
B
*
(
qbank
[
i
+
1
]
-
qbank
[
i
]),
q
,
norm
,
B
,
qbank
[
i
]);
copy_quant
(
X
+
B
*
qbank
[
i
],
B
*
(
qbank
[
i
+
1
]
-
qbank
[
i
]),
-
q
,
norm
,
B
,
qbank
[
i
]);
for
(
j
=
B
*
qbank
[
i
];
j
<
B
*
qbank
[
i
+
1
];
j
++
)
norm
[
j
]
=
X
[
j
]
*
n
;
//bits += 1+log2(qbank[i])+log2(ncwrs(B*(qbank[i+1]-qbank[i]), -q));
//noise_quant(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]);
}
}
//printf ("%f\n", bits);
for
(
i
=
B
*
qbank
[
NBANDS
];
i
<
B
*
qbank
[
NBANDS
+
1
];
i
++
)
X
[
i
]
=
0
;
}
...
...
@@ -189,9 +193,9 @@ void pitch_renormalise_bands(float *X, int B, float *P)
Rxx
+=
X
[
j
]
*
X
[
j
];
}
float
arg
=
Rxp
*
Rxp
+
1
-
Rpp
;
if
(
arg
<
0
)
arg
=
0
;
gain1
=
sqrt
(
arg
)
-
Rxp
;
if
(
Rpp
>
.
9999
)
Rpp
=
.
9999
;
Rxx
=
0
;
for
(
j
=
B
*
qbank
[
i
];
j
<
B
*
qbank
[
i
+
1
];
j
++
)
{
...
...
This diff is collapsed.
Click to expand it.
libcelt/vq.c
+
29
−
7
View file @
25298f29
...
...
@@ -219,6 +219,8 @@ void noise_quant(float *x, int N, int K, float *p)
}
}
static
const
float
pg
[
5
]
=
{
1
.
f
,
.
82
f
,
.
75
f
,
0
.
7
f
,
0
.
6
f
};
/* Finds the right offset into Y and copy it */
void
copy_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
Y
,
int
B
,
int
N0
)
{
...
...
@@ -249,13 +251,33 @@ void copy_quant(float *x, int N, int K, float *Y, int B, int N0)
}
}
//printf ("%d %f\n", best, best_score);
E
=
1e-10
;
for
(
j
=
0
;
j
<
N
;
j
++
)
if
(
K
==
0
)
{
x
[
j
]
=
s
*
Y
[
best
+
j
];
E
+=
x
[
j
]
*
x
[
j
];
E
=
1e-10
;
for
(
j
=
0
;
j
<
N
;
j
++
)
{
x
[
j
]
=
s
*
Y
[
best
+
j
];
E
+=
x
[
j
]
*
x
[
j
];
}
E
=
1
/
sqrt
(
E
);
for
(
j
=
0
;
j
<
N
;
j
++
)
x
[
j
]
*=
E
;
}
else
{
float
P
[
N
];
float
pred_gain
;
if
(
K
>
4
)
pred_gain
=
.
5
;
else
pred_gain
=
pg
[
K
];
E
=
1e-10
;
for
(
j
=
0
;
j
<
N
;
j
++
)
{
P
[
j
]
=
s
*
Y
[
best
+
j
];
E
+=
P
[
j
]
*
P
[
j
];
}
E
=
.
8
/
sqrt
(
E
);
for
(
j
=
0
;
j
<
N
;
j
++
)
P
[
j
]
*=
E
;
alg_quant2
(
x
,
N
,
K
,
P
);
}
E
=
1
/
sqrt
(
E
);
for
(
j
=
0
;
j
<
N
;
j
++
)
x
[
j
]
*=
E
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment