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
388f2255
Commit
388f2255
authored
Jun 11, 2009
by
Vladimir Voroshilov
Committed by
Michael Niedermayer
Sep 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Frame erasure support for LSF decoding
parent
a5e0c4dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
g729data.h
libavcodec/g729data.h
+5
-0
g729dec.c
libavcodec/g729dec.c
+31
-4
No files found.
libavcodec/g729data.h
View file @
388f2255
...
...
@@ -268,6 +268,11 @@ static const int16_t cb_ma_predictor_sum[2][10] = { /* (0.15) */
{
14585
,
18333
,
19772
,
17344
,
16426
,
16459
,
15155
,
15220
,
16043
,
15708
}
};
static
const
int16_t
cb_ma_predictor_sum_inv
[
2
][
10
]
=
{
/* (3.12) */
{
17210
,
15888
,
16357
,
16183
,
16516
,
15833
,
15888
,
15421
,
14840
,
15597
},
{
9202
,
7320
,
6788
,
7738
,
8170
,
8154
,
8856
,
8818
,
8366
,
8544
}
};
/**
* initial LSP coefficients belongs to virtual frame preceding the
* first frame of the stream
...
...
libavcodec/g729dec.c
View file @
388f2255
...
...
@@ -90,6 +90,8 @@ typedef struct {
int16_t
lsfq
[
10
];
///< (2.13) quantized LSF coefficients from previous frame
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
int
ma_predictor_prev
;
///< switched MA predictor of LSP quantizer from last good frame
}
G729Context
;
static
const
G729FormatDescription
format_g729_8k
=
{
...
...
@@ -157,13 +159,26 @@ static void lsf_decode(int16_t* lsfq, int16_t* past_quantizer_outputs[MA_NP + 1]
lsfq
[
i
]
=
sum
>>
15
;
}
/* Rotate past_quantizer_outputs. */
memmove
(
past_quantizer_outputs
+
1
,
past_quantizer_outputs
,
MA_NP
*
sizeof
(
int16_t
*
));
past_quantizer_outputs
[
0
]
=
quantizer_output
;
ff_acelp_reorder_lsf
(
lsfq
,
LSFQ_DIFF_MIN
,
LSFQ_MIN
,
LSFQ_MAX
,
10
);
}
static
void
lsf_restore_from_previous
(
int16_t
*
lsfq
,
int16_t
*
past_quantizer_outputs
[
MA_NP
+
1
],
int
ma_predictor_prev
)
{
int16_t
*
quantizer_output
=
past_quantizer_outputs
[
MA_NP
];
int
i
,
k
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
int
tmp
=
lsfq
[
i
]
<<
15
;
for
(
k
=
0
;
k
<
MA_NP
;
k
++
)
tmp
-=
past_quantizer_outputs
[
k
][
i
]
*
cb_ma_predictor
[
ma_predictor_prev
][
k
][
i
];
quantizer_output
[
i
]
=
((
tmp
>>
15
)
*
cb_ma_predictor_sum_inv
[
ma_predictor_prev
][
i
])
>>
12
;
}
}
static
av_cold
int
decoder_init
(
AVCodecContext
*
avctx
)
{
G729Context
*
ctx
=
avctx
->
priv_data
;
...
...
@@ -201,6 +216,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
int
frame_erasure
=
0
;
///< frame erasure detected during decoding
int
bad_pitch
=
0
;
///< parity check failed
int
i
;
int16_t
*
tmp
;
G729Context
*
ctx
=
avctx
->
priv_data
;
int16_t
lp
[
2
][
11
];
// (3.12)
uint8_t
ma_predictor
;
///< switched MA predictor of LSP quantizer
...
...
@@ -238,9 +254,20 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
quantizer_2nd_lo
=
get_bits
(
&
gb
,
VQ_2ND_BITS
);
quantizer_2nd_hi
=
get_bits
(
&
gb
,
VQ_2ND_BITS
);
if
(
frame_erasure
)
lsf_restore_from_previous
(
ctx
->
lsfq
,
ctx
->
past_quantizer_outputs
,
ctx
->
ma_predictor_prev
);
else
{
lsf_decode
(
ctx
->
lsfq
,
ctx
->
past_quantizer_outputs
,
ma_predictor
,
quantizer_1st
,
quantizer_2nd_lo
,
quantizer_2nd_hi
);
ctx
->
ma_predictor_prev
=
ma_predictor
;
}
tmp
=
ctx
->
past_quantizer_outputs
[
MA_NP
];
memmove
(
ctx
->
past_quantizer_outputs
+
1
,
ctx
->
past_quantizer_outputs
,
MA_NP
*
sizeof
(
int16_t
*
));
ctx
->
past_quantizer_outputs
[
0
]
=
tmp
;
ff_acelp_lsf2lsp
(
ctx
->
lsp
[
1
],
ctx
->
lsfq
,
10
);
...
...
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