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
2805a14e
Commit
2805a14e
authored
Feb 26, 2008
by
Jean-Marc Valin
Browse files
fixed-point: celt_pgain_t now a 16-bit value (Q15)
parent
5f09ea56
Changes
3
Hide whitespace changes
Inline
Side-by-side
libcelt/arch.h
View file @
2805a14e
...
...
@@ -54,19 +54,19 @@ typedef celt_int32_t celt_word32_t;
typedef
celt_word32_t
celt_sig_t
;
typedef
celt_word16_t
celt_norm_t
;
typedef
celt_word32_t
celt_ener_t
;
typedef
floa
t
celt_pgain_t
;
typedef
celt_word16_
t
celt_pgain_t
;
typedef
float
celt_mask_t
;
#define Q15ONE 32767
#define SIG_SCALING 16384.f
#define SIG_SCALING_1
0.000061035
#define SIG_SCALING_1
(1.f/16384.f)
#define NORM_SCALING 16384.f
#define NORM_SCALING_1
0.000061035
#define NORM_SCALING_1
(1.f/16384.f)
#define ENER_SCALING 16384.f
#define ENER_SCALING_1
0.000061035
#define PGAIN_SCALING
1
.f
#define PGAIN_SCALING_1 1.f
#define ENER_SCALING_1
(1.f/16384.f)
#define PGAIN_SCALING
32768
.f
#define PGAIN_SCALING_1
(
1.f
/32768.f)
#define VERY_SMALL 0
#define VERY_LARGE32 ((celt_word32_t)2147483647)
...
...
libcelt/bands.c
View file @
2805a14e
...
...
@@ -178,7 +178,7 @@ void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_
gain
=
0
.
0
f
;
/* We need to be a bit conservative, otherwise residual doesn't quantise well */
gain
*=
.
9
f
;
gains
[
i
]
=
gain
;
gains
[
i
]
=
PGAIN_SCALING
*
gain
;
/*printf ("%f ", 1-sqrt(1-gain*gain));*/
}
/*if(rand()%10==0)
...
...
@@ -201,7 +201,7 @@ void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_p
{
int
j
;
for
(
j
=
B
*
pBands
[
i
];
j
<
B
*
pBands
[
i
+
1
];
j
++
)
P
[
j
]
*=
gains
[
i
];
P
[
j
]
*=
PGAIN_SCALING_1
*
gains
[
i
];
/*printf ("%f ", gain);*/
}
for
(
i
=
B
*
pBands
[
m
->
nbPBands
];
i
<
B
*
pBands
[
m
->
nbPBands
+
1
];
i
++
)
...
...
libcelt/quant_pitch.c
View file @
2805a14e
...
...
@@ -69,12 +69,12 @@ int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc)
ALLOC
(
g2
,
len
,
float
);
/*for (i=0;i<len;i++) printf ("%f ", gains[i]);printf ("\n");*/
for
(
i
=
0
;
i
<
len
;
i
++
)
g2
[
i
]
=
1
-
sqrt
(
1
-
gains
[
i
]
*
gains
[
i
]);
g2
[
i
]
=
1
-
sqrt
(
1
-
PGAIN_SCALING_1
*
PGAIN_SCALING_1
*
gains
[
i
]
*
gains
[
i
]);
id
=
vq_index
(
g2
,
pgain_table
,
len
,
128
);
ec_enc_uint
(
enc
,
id
,
128
);
/*for (i=0;i<len;i++) printf ("%f ", pgain_table[id*len+i]);printf ("\n");*/
for
(
i
=
0
;
i
<
len
;
i
++
)
gains
[
i
]
=
(
sqrt
(
1
-
(
1
-
pgain_table
[
id
*
len
+
i
])
*
(
1
-
pgain_table
[
id
*
len
+
i
])));
gains
[
i
]
=
PGAIN_SCALING
*
(
sqrt
(
1
-
(
1
-
pgain_table
[
id
*
len
+
i
])
*
(
1
-
pgain_table
[
id
*
len
+
i
])));
return
id
!=
0
;
}
...
...
@@ -83,6 +83,6 @@ int unquant_pitch(celt_pgain_t *gains, int len, ec_dec *dec)
int
i
,
id
;
id
=
ec_dec_uint
(
dec
,
128
);
for
(
i
=
0
;
i
<
len
;
i
++
)
gains
[
i
]
=
(
sqrt
(
1
-
(
1
-
pgain_table
[
id
*
len
+
i
])
*
(
1
-
pgain_table
[
id
*
len
+
i
])));
gains
[
i
]
=
PGAIN_SCALING
*
(
sqrt
(
1
-
(
1
-
pgain_table
[
id
*
len
+
i
])
*
(
1
-
pgain_table
[
id
*
len
+
i
])));
return
id
!=
0
;
}
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