Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
0a333788
Commit
0a333788
authored
Jun 04, 2009
by
Vladimir Voroshilov
Committed by
Michael Niedermayer
Sep 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed- and adaptive-codebook gains
parent
7fadc015
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
g729data.h
libavcodec/g729data.h
+7
-0
g729dec.c
libavcodec/g729dec.c
+33
-0
No files found.
libavcodec/g729data.h
View file @
0a333788
...
@@ -307,6 +307,13 @@ static const int16_t cb_ma_predictor_sum_inv[2][10] = { /* (3.12) */
...
@@ -307,6 +307,13 @@ static const int16_t cb_ma_predictor_sum_inv[2][10] = { /* (3.12) */
{
9202
,
7320
,
6788
,
7738
,
8170
,
8154
,
8856
,
8818
,
8366
,
8544
}
{
9202
,
7320
,
6788
,
7738
,
8170
,
8154
,
8856
,
8818
,
8366
,
8544
}
};
};
/**
* MA prediction coefficients (3.9.1 of G.729, near Equation 69)
*/
static
const
uint16_t
ma_prediction_coeff
[
4
]
=
{
/* (0.13) */
5571
,
4751
,
2785
,
1556
};
/**
/**
* initial LSP coefficients belongs to virtual frame preceding the
* initial LSP coefficients belongs to virtual frame preceding the
* first frame of the stream
* first frame of the stream
...
...
libavcodec/g729dec.c
View file @
0a333788
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "avcodec.h"
#include "avcodec.h"
#include "libavutil/avutil.h"
#include "libavutil/avutil.h"
#include "get_bits.h"
#include "get_bits.h"
#include "dsputil.h"
#include "g729.h"
#include "g729.h"
#include "lsp.h"
#include "lsp.h"
...
@@ -71,6 +72,11 @@
...
@@ -71,6 +72,11 @@
*/
*/
#define SHARP_MAX 13017
#define SHARP_MAX 13017
/**
* MR_ENERGY (mean removed energy) = mean_energy + 10 * log10(2^26 * subframe_size) in (7.13)
*/
#define MR_ENERGY 1018156
typedef
enum
{
typedef
enum
{
FORMAT_G729_8K
=
0
,
FORMAT_G729_8K
=
0
,
FORMAT_G729D_6K4
,
FORMAT_G729D_6K4
,
...
@@ -87,6 +93,8 @@ typedef struct {
...
@@ -87,6 +93,8 @@ typedef struct {
}
G729FormatDescription
;
}
G729FormatDescription
;
typedef
struct
{
typedef
struct
{
DSPContext
dsp
;
int
pitch_delay_int_prev
;
///< integer part of previous subframe's pitch delay (4.1.3)
int
pitch_delay_int_prev
;
///< integer part of previous subframe's pitch delay (4.1.3)
/// (2.13) LSP quantizer outputs
/// (2.13) LSP quantizer outputs
...
@@ -97,6 +105,14 @@ typedef struct {
...
@@ -97,6 +105,14 @@ typedef struct {
int16_t
lsp_buf
[
2
][
10
];
///< (0.15) LSP coefficients (previous and current frames) (3.2.5)
int16_t
lsp_buf
[
2
][
10
];
///< (0.15) LSP coefficients (previous and current frames) (3.2.5)
int16_t
*
lsp
[
2
];
///< pointers to lsp_buf
int16_t
*
lsp
[
2
];
///< pointers to lsp_buf
int16_t
quant_energy
[
4
];
///< (5.10) past quantized energy
/// (1.14) pitch gain of previous subframe
int16_t
gain_pitch
;
/// (14.1) gain code from previous subframe
int16_t
gain_code
;
uint16_t
rand_value
;
///< random number generator value (4.4.4)
uint16_t
rand_value
;
///< random number generator value (4.4.4)
int
ma_predictor_prev
;
///< switched MA predictor of LSP quantizer from last good frame
int
ma_predictor_prev
;
///< switched MA predictor of LSP quantizer from last good frame
}
G729Context
;
}
G729Context
;
...
@@ -228,6 +244,12 @@ static av_cold int decoder_init(AVCodecContext * avctx)
...
@@ -228,6 +244,12 @@ static av_cold int decoder_init(AVCodecContext * avctx)
/* random seed initialization */
/* random seed initialization */
ctx
->
rand_value
=
21845
;
ctx
->
rand_value
=
21845
;
/* quantized prediction error */
for
(
i
=
0
;
i
<
4
;
i
++
)
ctx
->
quant_energy
[
i
]
=
-
14336
;
// -14 in (5.10)
dsputil_init
(
&
ctx
->
dsp
,
avctx
);
return
0
;
return
0
;
}
}
...
@@ -306,6 +328,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
...
@@ -306,6 +328,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
FFSWAP
(
int16_t
*
,
ctx
->
lsp
[
1
],
ctx
->
lsp
[
0
]);
FFSWAP
(
int16_t
*
,
ctx
->
lsp
[
1
],
ctx
->
lsp
[
0
]);
for
(
i
=
0
;
i
<
2
;
i
++
)
{
for
(
i
=
0
;
i
<
2
;
i
++
)
{
int
gain_corr_factor
;
uint8_t
ac_index
;
///< adaptive codebook index
uint8_t
ac_index
;
///< adaptive codebook index
uint8_t
pulses_signs
;
///< fixed-codebook vector pulse signs
uint8_t
pulses_signs
;
///< fixed-codebook vector pulse signs
int
fc_indexes
;
///< fixed-codebook indexes
int
fc_indexes
;
///< fixed-codebook indexes
...
@@ -389,6 +413,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
...
@@ -389,6 +413,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
gain_corr_factor
=
cb_gain_1st_8k
[
gc_1st_index
][
1
]
+
gain_corr_factor
=
cb_gain_1st_8k
[
gc_1st_index
][
1
]
+
cb_gain_2nd_8k
[
gc_2nd_index
][
1
];
cb_gain_2nd_8k
[
gc_2nd_index
][
1
];
/* Decode the fixed-codebook gain. */
ctx
->
gain_code
=
ff_acelp_decode_gain_code
(
&
ctx
->
dsp
,
gain_corr_factor
,
fc
,
MR_ENERGY
,
ctx
->
quant_energy
,
ma_prediction_coeff
,
SUBFRAME_SIZE
,
4
);
}
ff_acelp_update_past_gain
(
ctx
->
quant_energy
,
gain_corr_factor
,
2
,
frame_erasure
);
ff_acelp_weighted_vector_sum
(
ctx
->
exc
+
i
*
SUBFRAME_SIZE
,
ff_acelp_weighted_vector_sum
(
ctx
->
exc
+
i
*
SUBFRAME_SIZE
,
ctx
->
exc
+
i
*
SUBFRAME_SIZE
,
fc
,
ctx
->
exc
+
i
*
SUBFRAME_SIZE
,
fc
,
(
!
voicing
&&
frame_erasure
)
?
0
:
ctx
->
gain_pitch
,
(
!
voicing
&&
frame_erasure
)
?
0
:
ctx
->
gain_pitch
,
...
...
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