Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
98193470
Commit
98193470
authored
Feb 28, 2008
by
Jean-Marc Valin
Browse files
fixed-point: unquant_energy_mono() has received the fixed-point code from
quant_energy_mono()
parent
d0316201
Changes
1
Hide whitespace changes
Inline
Side-by-side
libcelt/quant_bands.c
View file @
98193470
...
...
@@ -40,7 +40,7 @@
#include "arch.h"
#ifdef FIXED_POINT
const
floa
t
eMeans
[
24
]
=
{
11520
,
-
2048
,
-
3072
,
-
640
,
256
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
const
celt_word16_
t
eMeans
[
24
]
=
{
11520
,
-
2048
,
-
3072
,
-
640
,
256
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
#else
const
float
eMeans
[
24
]
=
{
45
.
f
,
-
8
.
f
,
-
12
.
f
,
-
2
.
5
f
,
1
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
};
#endif
...
...
@@ -107,7 +107,6 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
q2
;
float
offset2
;
celt_word16_t
offset
=
(
error
[
i
]
+
QCONST16
(.
5
f
,
8
))
*
frac
[
i
];
/* FIXME: Instead of giving up without warning, we should degrade everything gracefully */
if
(
ec_enc_tell
(
enc
,
0
)
-
bits
+
EC_ILOG
(
frac
[
i
])
>
budget
)
...
...
@@ -140,7 +139,7 @@ static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_wor
{
int
i
;
int
bits
;
floa
t
prev
=
0
;
celt_word16_
t
prev
=
0
;
float
coef
=
m
->
ePredCoef
;
/* The .7 is a heuristic */
float
beta
=
.
7
*
coef
;
...
...
@@ -148,10 +147,10 @@ static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_wor
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
qi
;
floa
t
q
;
floa
t
res
;
floa
t
mean
=
(
1
-
coef
)
*
eMeans
[
i
];
res
=
6
.;
celt_word16_
t
q
;
celt_word16_
t
res
;
celt_word16_
t
mean
=
(
1
-
coef
)
*
eMeans
[
i
];
res
=
DB_SCALING
*
6
.;
/* If we didn't have enough bits to encode all the energy, just assume something safe. */
if
(
ec_dec_tell
(
dec
,
0
)
-
bits
>
budget
)
qi
=
-
1
;
...
...
@@ -159,19 +158,23 @@ static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_wor
qi
=
ec_laplace_decode
(
dec
,
6000
-
i
*
200
);
q
=
qi
*
res
;
oldEBands
[
i
]
=
DB_SCALING
*
(
DB_SCALING_1
*
mean
+
coef
*
DB_SCALING_1
*
oldEBands
[
i
]
+
prev
+
q
);
/*printf("%d ", qi);*/
/*printf("%f %f ", pred+prev+q, x);*/
/*printf("%f ", x-pred);*/
oldEBands
[
i
]
=
mean
+
coef
*
oldEBands
[
i
]
+
prev
+
q
;
prev
=
DB_SCALING_1
*
mean
+
prev
+
(
1
-
beta
)
*
q
;
prev
=
mean
+
prev
+
(
1
-
beta
)
*
q
;
}
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
q2
;
floa
t
offset
;
celt_word16_
t
offset
;
if
(
ec_dec_tell
(
dec
,
0
)
-
bits
+
EC_ILOG
(
frac
[
i
])
>
budget
)
break
;
q2
=
ec_dec_uint
(
dec
,
frac
[
i
]);
offset
=
((
q2
+
.
5
)
/
frac
[
i
])
-
.
5
;
oldEBands
[
i
]
+=
DB_SCALING
*
6
.
*
offset
;
offset
=
(
Q8
*
(
q2
+
.
5
)
/
frac
[
i
])
-
QCONST16
(.
5
f
,
8
)
;
oldEBands
[
i
]
+=
PSHR32
(
MULT16_16
(
DB_SCALING
*
6
,
offset
),
8
)
;
}
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment