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
70c8ffdd
Commit
70c8ffdd
authored
Dec 07, 2007
by
Jean-Marc Valin
Browse files
More decoding work
parent
fc08d0a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
libcelt/bands.c
View file @
70c8ffdd
...
...
@@ -177,39 +177,29 @@ void quant_bands(const CELTMode *m, float *X, float *P, ec_enc *enc)
X
[
i
]
=
0
;
}
/* Scales the pulse-codebook entry in each band such that unit-energy is conserved when
adding the pitch */
void
pitch_renormalise_bands
(
const
CELTMode
*
m
,
float
*
X
,
float
*
P
)
void
unquant_bands
(
const
CELTMode
*
m
,
float
*
X
,
float
*
P
,
ec_dec
*
dec
)
{
int
i
,
B
;
int
i
,
j
,
B
;
const
int
*
eBands
=
m
->
eBands
;
B
=
m
->
nbMdctBlocks
;
float
norm
[
B
*
eBands
[
m
->
nbEBands
+
1
]];
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
j
;
float
Rpp
=
0
;
float
Rxp
=
0
;
float
Rxx
=
0
;
float
gain1
;
for
(
j
=
B
*
eBands
[
i
];
j
<
B
*
eBands
[
i
+
1
];
j
++
)
{
Rxp
+=
X
[
j
]
*
P
[
j
];
Rpp
+=
P
[
j
]
*
P
[
j
];
Rxx
+=
X
[
j
]
*
X
[
j
];
}
float
arg
=
Rxp
*
Rxp
+
1
-
Rpp
;
if
(
arg
<
0
)
arg
=
0
;
gain1
=
sqrt
(
arg
)
-
Rxp
;
Rxx
=
0
;
for
(
j
=
B
*
eBands
[
i
];
j
<
B
*
eBands
[
i
+
1
];
j
++
)
{
X
[
j
]
=
P
[
j
]
+
gain1
*
X
[
j
];
Rxx
+=
X
[
j
]
*
X
[
j
];
int
q
,
id
;
q
=
m
->
nbPulses
[
i
];
if
(
q
>
0
)
{
float
n
=
sqrt
(
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]));
alg_unquant
(
X
+
B
*
eBands
[
i
],
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]),
q
,
P
+
B
*
eBands
[
i
],
dec
);
for
(
j
=
B
*
eBands
[
i
];
j
<
B
*
eBands
[
i
+
1
];
j
++
)
norm
[
j
]
=
X
[
j
]
*
n
;
}
else
{
float
n
=
sqrt
(
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]));
//copy_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), -q, norm, B, eBands[i], dec);
for
(
j
=
B
*
eBands
[
i
];
j
<
B
*
eBands
[
i
+
1
];
j
++
)
norm
[
j
]
=
X
[
j
]
*
n
;
}
}
for
(
i
=
B
*
eBands
[
m
->
nbEBands
];
i
<
B
*
eBands
[
m
->
nbEBands
+
1
];
i
++
)
X
[
i
]
=
0
;
}
libcelt/bands.h
View file @
70c8ffdd
...
...
@@ -35,6 +35,7 @@
#include "modes.h"
#include "entenc.h"
#include "entdec.h"
void
compute_band_energies
(
const
CELTMode
*
m
,
float
*
X
,
float
*
bands
);
...
...
@@ -48,6 +49,6 @@ void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains);
void
quant_bands
(
const
CELTMode
*
m
,
float
*
X
,
float
*
P
,
ec_enc
*
enc
);
void
pitch_renormalise
_bands
(
const
CELTMode
*
m
,
float
*
X
,
float
*
P
);
void
unquant
_bands
(
const
CELTMode
*
m
,
float
*
X
,
float
*
P
,
ec_dec
*
dec
);
#endif
/* BANDS_H */
libcelt/celt.c
View file @
70c8ffdd
...
...
@@ -243,6 +243,16 @@ int celt_encode(CELTEncoder *st, short *pcm)
/* Residual quantisation */
quant_bands
(
st
->
mode
,
X
,
P
,
&
st
->
enc
);
if
(
0
)
{
//This is just for debugging
ec_enc_done
(
&
st
->
enc
);
ec_dec
dec
;
ec_byte_readinit
(
&
st
->
buf
,
ec_byte_get_buffer
(
&
st
->
buf
),
ec_byte_bytes
(
&
st
->
buf
));
ec_dec_init
(
&
dec
,
&
st
->
buf
);
unquant_bands
(
st
->
mode
,
X
,
P
,
&
dec
);
//printf ("\n");
}
/* Synthesis */
denormalise_bands
(
st
->
mode
,
X
,
bandE
);
...
...
@@ -362,7 +372,17 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
float
bandE
[
st
->
mode
->
nbEBands
];
float
gains
[
st
->
mode
->
nbPBands
];
int
pitch_index
;
ec_dec
dec
;
ec_byte_buffer
buf
;
ec_byte_readinit
(
&
buf
,
data
,
len
);
ec_dec_init
(
&
dec
,
&
buf
);
/* Get band energies */
/* Get the pitch index */
/* Pitch MDCT */
compute_mdcts
(
&
st
->
mdct_lookup
,
st
->
window
,
st
->
out_mem
+
pitch_index
,
P
,
N
,
B
);
//haar1(P, B*N);
...
...
@@ -373,12 +393,14 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
normalise_bands
(
st
->
mode
,
P
,
bandEp
);
}
/* Apply pitch gains */
/* Decode fixed codebook */
/* Merge pitch and fixed codebook */
/* Get the pitch gains */
/* Apply pitch gains */
pitch_quant_bands
(
st
->
mode
,
X
,
P
,
gains
);
/* Decode fixed codebook and merge with pitch */
unquant_bands
(
st
->
mode
,
X
,
P
,
&
dec
);
/* Synthesis */
denormalise_bands
(
st
->
mode
,
X
,
bandE
);
...
...
libcelt/vq.c
View file @
70c8ffdd
...
...
@@ -184,6 +184,8 @@ void alg_quant(float *x, int N, int K, float *p, ec_enc *enc)
}
int
comb
[
K
];
int
signs
[
K
];
//for (i=0;i<N;i++)
// printf ("%d ", iy[0][i]);
pulse2comb
(
N
,
K
,
comb
,
signs
,
iy
[
0
]);
ec_enc_uint
(
enc
,
icwrs
(
N
,
K
,
comb
,
signs
),
ncwrs
(
N
,
K
));
}
...
...
@@ -267,7 +269,8 @@ void alg_unquant(float *x, int N, int K, float *p, ec_dec *dec)
id
=
ec_dec_uint
(
dec
,
ncwrs
(
N
,
K
));
cwrsi
(
N
,
K
,
id
,
comb
,
signs
);
comb2pulse
(
N
,
K
,
iy
,
comb
,
signs
);
//for (i=0;i<N;i++)
// printf ("%d ", iy[i]);
for
(
i
=
0
;
i
<
N
;
i
++
)
Rpp
+=
p
[
i
]
*
p
[
i
];
...
...
@@ -275,7 +278,7 @@ void alg_unquant(float *x, int N, int K, float *p, ec_dec *dec)
Ryp
+=
iy
[
i
]
*
p
[
i
];
for
(
i
=
0
;
i
<
N
;
i
++
)
y
[
i
]
=
iy
[
i
]
-
Ryp
*
p
[
i
];
y
[
i
]
=
iy
[
i
]
-
alpha
*
Ryp
*
p
[
i
];
/* Recompute after the projection (I think it's right) */
Ryp
=
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