Method and apparatus for calculating downmixed signal and residual signal
An audio signal encoding method is provided. According to the method, if a current frame is a switching frame, a to-be-encoded downmixed signal and a to-be-encoded residual signal of the subband corresponding to the preset frequency band in the current frame are obtained based on a switch fade-in/fade-out factor of a previous frame, an initial downmixed signal and an initial residual signal of the preset frequency band of the current frame.
1 . An audio signal encoding method, comprising:
obtaining an audio signal including at least two channel signals;
obtaining an initial residual signal of a subband of a current frame of the audio signal;
obtaining an initial downmixed signal of the subband;
determining whether a previous frame of the current frame is a switching frame; and
when the previous frame is a switching frame, obtaining a switch fade-in/fade-out factor of the current frame based on a residual signal coding parameter of the current frame and an inter-frame energy fluctuation parameter of the current frame, wherein the residual signal coding parameter represents an energy relationship between a downmixed signal and a residual signal of the current frame, and the inter-frame energy fluctuation parameter represents an energy relationship between the current frame and the previous frame;
obtaining a processed downmixed signal based on the switch fade-in/fade-out factor and the initial downmixed signal;
obtaining a processed residual signal based on the switch fade-in/fade-out factor and the initial residual signal; and
encoding the processed downmixed signal and the processed residual signal.
2 . The method according to claim 1 , wherein:
when frame_nrg_ratio>NRG_TH1 and res_dmx_ratio<RATIO_TH1 switch_fade_factor=FACTOR_1;
frame_nrg_ratio represents the inter-frame energy fluctuation parameter; NRG_TH1 represents a preset first threshold of the inter-frame energy fluctuation parameter; res_dmx_ratio represents the residual signal coding parameter of the previous frame; RATIO_TH1 represents a preset first threshold of the residual signal coding parameter; switch_fade_factor represents the switch fade-in/fade-out factor; and FACTOR_1 represents a preset value.
3 . The method according to claim 1 , wherein:
when frame_nrg_ratio>NRG_TH1 and res_dmx_ratio<RATIO_TH1,
switch_fade
_factor
=
(
1
-
1
frame_nrg
_ratio
)
*
(
1
-
rem_dmx
_ratio
)
*
FADE_FACTOR
_
1
;
when frame_nrg_ratio<NRG_TH2 and res_dmx_ratio>RATIO_TH2, switch_fade_factor=(1−frame_nrg_ratio)*rem_dmx_ratio*FADE_FACTOR_2; or
switch_fade_factor=FADE_FACTOR_3;
frame_nrg_ratio represents the inter-frame energy fluctuation parameter; NRG_TH1 represents a preset first threshold of the inter-frame energy fluctuation parameter; NRG_TH2 represents a preset second threshold of the inter-frame energy fluctuation parameter; res_dmx_ratio represents the residual signal coding parameter of the previous frame; RATIO_TH1 represents a preset first threshold of the residual signal coding parameter; RATIO_TH2 represents a preset second threshold of the residual signal coding parameter; switch_fade_factor represents the switch fade-in/fade-out factor; and FADE_FACTOR_1, FADE_FACTOR_2 and FADE_FACTOR_3 represent preset values; and
NRG_TH1>NRG_TH2, RATIO_TH1<RATIO_TH2, and, FADE_FACTOR_1>FADE_FACTOR_3>FADE_FACTOR_2.
4 . The method according to claim 3 , wherein FADE FACTOR_3=0.5.
5 . The method according to claim 2 , wherein FACTOR_1=0.75.
6 . The method according to claim 3 , wherein FADE FACTOR_2=0.25.
7 . An audio signal encoder, comprising:
a processor; and
a memory coupled to the processor and storing programming instructions, which when executed by the processor, cause the audio signal encoder to:
obtain an audio signal including at least two channel signals;
obtain an initial residual signal of a subband of a current frame of the audio signal;
obtain an initial downmixed signal of the subband;
determine whether a previous frame of the current frame is a switching frame; and
when the previous frame is a switching frame, obtain a switch fade-in/fade-out factor of the current frame based on a residual signal coding parameter of the current frame and an inter-frame energy fluctuation parameter of the current frame, wherein the residual signal coding parameter represents an energy relationship between a downmixed signal and a residual signal of the current frame, and the inter-frame energy fluctuation parameter represents an energy relationship between the current frame and the previous frame;
obtain a processed downmixed signal based on the switch fade-in/fade-out factor and the initial downmixed signal;
obtain a processed residual signal based on the switch fade-in/fade-out factor and the initial residual signal; and
encode the processed downmixed signal and the processed residual signal.
8 . The audio signal encoder according to claim 7 , wherein:
when frame_nrg_ratio>NRG_TH1 and res_dmx_ratio<RATIO_TH1, switch_fade_factor=FACTOR_1;
frame_nrg_ratio represents the inter-frame energy fluctuation parameter; NRG_TH1 represents a preset first threshold of the inter-frame energy fluctuation parameter; res_dmx_ratio represents the residual signal coding parameter of the previous frame; RATIO_TH1 represents a preset first threshold of the residual signal coding parameter; switch_fade_factor represents the switch fade-in/fade-out factor; and FACTOR_1 represents a preset value.
9 . The audio signal encoder according to claim 7 , wherein:
when frame_nrg_ratio>NRG_TH1 and res_dmx_ratio<RATIO_TH1,
switch_fade
_factor
=
(
1
-
1
frame_nrg
_ratio
)
*
(
1
-
rem_dmx
_ratio
)
*
FADE_FACTOR
_
1
;
when frame_nrg_ratio<NRG_TH2 and res_dmx_ratio>RATIO_TH2, switch_fade_factor=(1−frame_nrg_ratio)*rem_dmx_ratio*FADE_FACTOR_2; or
switch_fade_factor=FADE_FACTOR_3;
frame_nrg_ratio represents the inter-frame energy fluctuation parameter; NRG_TH1 represents a preset first threshold of the inter-frame energy fluctuation parameter; NRG_TH2 represents a preset second threshold of the inter-frame energy fluctuation parameter; res_dmx_ratio represents the residual signal coding parameter of the previous frame; RATIO_TH1 represents a preset first threshold of the residual signal coding parameter; RATIO_TH2 represents a preset second threshold of the residual signal coding parameter; switch_fade_factor represents the switch fade-in/fade-out factor; and FADE_FACTOR_1, FADE_FACTOR_2, and FADE_FACTOR_3 represent preset values; and
NRG_TH1>NRG_TH2, RATIO_TH1<RATIO_TH2 and, FADE_FACTOR_1>FADE_FACTOR_3>FADE_FACTOR_2.
10 . The audio signal encoder according to claim 9 , wherein FADE_FACTOR_3=0.5.
11 . The audio signal encoder according to claim 8 , wherein FACTOR_1=0.75.
12 . The audio signal encoder according to claim 9 , wherein FADE_FACTOR_2=0.25.
13 . A non-transitory computer-readable storage medium storing computer instructions, which when executed by one or more processors, cause the one or more processors to perform operations, the operations comprising:
obtaining an audio signal including at least two channel signals;
obtaining an initial residual signal of a subband of a current frame of the audio signal;
obtaining an initial downmixed signal of the subband;
determining whether a previous frame of the current frame is a switching frame; and
when the previous frame is a switching frame, obtaining a switch fade-in/fade-out factor of the current frame based on a residual signal coding parameter of the current frame and an inter-frame energy fluctuation parameter of the current frame, wherein the residual signal coding parameter represents an energy relationship between a downmixed signal and a residual signal of the current frame, and the inter-frame energy fluctuation parameter represents an energy relationship between the current frame and the previous frame;
obtaining a processed downmixed signal based on the switch fade-in/fade-out factor and the initial downmixed signal;
obtaining a processed residual signal based on the switch fade-in/fade-out factor and the initial residual signal; and
encoding the processed downmixed signal and the processed residual signal.
14 . The non-transitory computer-readable storage medium according to claim 13 , wherein:
when frame_nrg_ratio>NRG_TH1 and res_dmx_ratio<RATIO_TH1, switch_fade_factor=FACTOR_1;
frame_nrg_ratio represents the inter-frame energy fluctuation parameter; NRG_TH1 represents a preset first threshold of the inter-frame energy fluctuation parameter; res_dmx_ratio represents the residual signal coding parameter of the previous frame; RATIO_TH1 represents a preset first threshold of the residual signal coding parameter; switch_fade_factor represents the switch fade-in/fade-out factor; and FACTOR_1 represents a preset value.
15 . The non-transitory computer-readable storage medium according to claim 13 , wherein:
when frame_nrg_ratio>NRG_TH1 and res_dmx_ratio<RATIO_TH1,
switch_fade
_factor
=
(
1
-
1
frame_nrg
_ratio
)
*
(
1
-
rem_dmx
_ratio
)
*
FADE_FACTOR
_
1
;
when frame_nrg_ratio<NRG_TH2 and res_dmx_ratio>RATIO_TH2, switch_fade_factor=(1−frame_nrg_ratio)*rem_dmx_ratio*FADE_FACTOR_2; or
switch_fade_factor=FADE_FACTOR_3;
frame_nrg_ratio represents the inter-frame energy fluctuation parameter; NRG_TH1 represents a preset first threshold of the inter-frame energy fluctuation parameter; NRG_TH2 represents a preset second threshold of the inter-frame energy fluctuation parameter; res_dmx_ratio represents the residual signal coding parameter of the previous frame; RATIO_TH1 represents a preset first threshold of the residual signal coding parameter; RATIO_TH2 represents a preset second threshold of the residual signal coding parameter; switch_fade_factor represents the switch fade-in/fade-out factor; and FADE_FACTOR_1, FADE_FACTOR_2, and FADE_FACTOR_3 represent preset values; and
NRG_TH1>NRG_TH2, RATIO_TH1<RATIO_TH2, and FADE_FACTOR_1>FADE_FACTOR_3>FADE_FACTOR_2.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein FADE_FACTOR_3=0.5.
17 . The non-transitory computer-readable storage medium according to claim 14 , wherein FACTOR_1=0.75.
18 . The non-transitory computer-readable storage medium according to claim 15 , wherein FADE_FACTOR_2=0.25.