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
adf87e26
Commit
adf87e26
authored
Feb 29, 2008
by
Jean-Marc Valin
Browse files
fixed-point: more energy quantisation stuff.
parent
47bf175f
Changes
1
Hide whitespace changes
Inline
Side-by-side
libcelt/quant_bands.c
View file @
adf87e26
...
...
@@ -43,7 +43,7 @@
#ifdef FIXED_POINT
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
floa
t
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
};
const
celt_word16_
t
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
/*const int frac[24] = {4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};*/
...
...
@@ -83,13 +83,6 @@ static inline celt_word16_t amp2dB(celt_ener_t amp)
static
const
celt_word16_t
base_resolution
=
QCONST16
(
6
.
f
,
8
);
#ifdef FIXED_POINT
#define Q8 256.f
#define Q8_1 (1.f/256.f)
#else
#define Q8 1.f
#define Q8_1 1.f
#endif
static
void
quant_energy_mono
(
const
CELTMode
*
m
,
celt_ener_t
*
eBands
,
celt_word16_t
*
oldEBands
,
int
budget
,
ec_enc
*
enc
)
{
int
i
;
...
...
@@ -148,12 +141,12 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1
/* Has to be without rounding */
q2
=
offset
>>
8
;
#else
q2
=
(
int
)
floor
(
Q8_1
*
offset
);
q2
=
(
int
)
floor
(
offset
);
#endif
if
(
q2
>
frac
[
i
]
-
1
)
q2
=
frac
[
i
]
-
1
;
ec_enc_uint
(
enc
,
q2
,
frac
[
i
]);
offset
=
(
Q8
*
(
q2
+
.
5
)
/
frac
[
i
])
-
QCONST16
(.
5
f
,
8
);
offset
=
DIV32_16
(
SHL16
(
q2
,
8
)
+
QCONST16
(.
5
,
8
),
frac
[
i
])
-
QCONST16
(.
5
f
,
8
);
oldEBands
[
i
]
+=
PSHR32
(
MULT16_16
(
DB_SCALING
*
6
,
offset
),
8
);
/*printf ("%f ", error[i] - offset);*/
}
...
...
@@ -202,7 +195,7 @@ static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_wor
if
(
ec_dec_tell
(
dec
,
0
)
-
bits
+
EC_ILOG
(
frac
[
i
])
>
budget
)
break
;
q2
=
ec_dec_uint
(
dec
,
frac
[
i
]);
offset
=
(
Q8
*
(
q2
+
.
5
)
/
frac
[
i
])
-
QCONST16
(.
5
f
,
8
);
offset
=
DIV32_16
(
SHL16
(
q2
,
8
)
+
QCONST16
(.
5
,
8
),
frac
[
i
])
-
QCONST16
(.
5
f
,
8
);
oldEBands
[
i
]
+=
PSHR32
(
MULT16_16
(
DB_SCALING
*
6
,
offset
),
8
);
}
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
...
...
@@ -243,10 +236,8 @@ void quant_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBan
{
int
i
;
int
NB
=
m
->
nbEBands
;
float
mid
[
NB
];
float
side
[
NB
];
float
left
;
float
right
;
celt_ener_t
mid
[
NB
];
celt_ener_t
side
[
NB
];
for
(
i
=
0
;
i
<
NB
;
i
++
)
{
//left = eBands[C*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