Delay Estimation Method and Apparatus
20220191635 · 2022-06-16
Inventors
Cpc classification
H04S2400/03
ELECTRICITY
H04S5/00
ELECTRICITY
G10L19/008
PHYSICS
International classification
Abstract
A delay estimation method includes determining a cross-correlation coefficient of a multi-channel signal of a current frame, determining a delay track estimation value of the current frame based on buffered inter-channel time difference information of at least one past frame, determining an adaptive window function of the current frame, performing weighting on the cross-correlation coefficient based on the delay track estimation value of the current frame and the adaptive window function of the current frame, to obtain a weighted cross-correlation coefficient, and determining an inter-channel time difference of the current frame based on the weighted cross-correlation coefficient.
Claims
1. A delay estimation method, comprising: determining a cross-correlation coefficient of a multi-channel signal of a current frame; determining a delay track estimation value of the current frame based on buffered inter-channel time difference information of at least one past frame; determining an adaptive parameter of an adaptive window function of the current frame based on a coding parameter of the at least one past frame, wherein the coding parameter indicates a first type of the at least one past frame or a second type of the at least one past frame on which time-domain downmixing processing is performed; determining the adaptive window function of the current frame according to the adaptive parameter; performing weighting on the cross-correlation coefficient, based on the delay track estimation value and the adaptive window function, to obtain a weighted cross-correlation coefficient; and determining an inter-channel time difference of the current frame based on the weighted cross-correlation coefficient.
2. The delay estimation method of claim 1, wherein determining the delay track estimation value of the current frame comprises: performing delay track estimation based on the buffered inter-channel time difference information of the at least one past frame; and using a linear regression method to determine the delay track estimation value of the current frame.
3. The delay estimation method of claim 1, wherein determining the delay track estimation value of the current frame comprises: performing delay track estimation based on the buffered inter-channel time difference information of the at least one past frame; and using a weighted linear regression method to determine the delay track estimation value of the current frame.
4. The delay estimation method of claim 1, wherein after determining the inter-channel time difference of the current frame, the delay estimation method further comprises updating the buffered inter-channel time difference information of the at least one past frame, and wherein the buffered inter-channel time difference information of the at least one past frame is an inter-channel time difference smoothed value of the at least one past frame or a second inter-channel time difference of the at least one past frame.
5. The delay estimation method of claim 4, wherein the buffered inter-channel time difference information of the at least one past frame is the inter-channel time difference smoothed value of the at least one past frame, wherein updating the buffered inter-channel time difference information of the at least one past frame comprises: determining a second inter-channel time difference smoothed value of the current frame based on the delay track estimation value of the current frame and the inter-channel time difference of the current frame; and updating a buffered inter-channel time difference smoothed value of the at least one past frame based on the second inter-channel time difference smoothed value of the current frame, wherein the second inter-channel time difference smoothed value of the current frame is calculated using a formula comprising:
cur_itd_smooth=φ*reg_prv_corr+(1−φ)*cur_itd, wherein cur_itd_smooth is the second inter-channel time difference smoothed value of the current frame, wherein φ is a second smoothing factor comprising a constant greater than or equal to 0 and less than or equal to 1, wherein reg_prv_corr is the delay track estimation value of the current frame, and wherein cur itd is the inter-channel time difference of the current frame.
6. The delay estimation method of claim 4, wherein updating the buffered inter-channel time difference information of the at least one past frame comprises updating the buffered inter-channel time difference information when a first voice activation detection result of the at least one past frame is a first active frame or a second voice activation detection result of the current frame is a second active frame.
7. The delay estimation method of claim 3, wherein after determining the inter-channel time difference of the current frame, the delay estimation method further comprises updating a buffered weighting coefficient of the at least one past frame, and wherein the buffered weighting coefficient of the at least one past frame is a weighting coefficient in the weighted linear regression method.
8. The delay estimation method of claim 7, wherein when the adaptive window function of the current frame is determined based on a smoothed inter-channel time difference of the at least one past frame, updating the buffered weighting coefficient of the at least one past frame comprises: calculating a first weighting coefficient of the current frame based on a smoothed inter-channel time difference estimation deviation of the current frame; and updating a buffered first weighting coefficient of the at least one past frame based on the first weighting coefficient of the current frame, wherein the first weighting coefficient of the current frame is calculated using formulas comprising:
wgt_par1=a_wgt1*smooth_dist_reg_update+b_wgt1;
a_wgt1=(xl_wgt1−xh_wgt1)/(yh_dist1′−yl_dist1′); and
b_wgt1=xl_wgt1−a_wgt1*yh_dist1′, wherein wgt_par 1 is the first weighting coefficient of the current frame, wherein smooth_dist_reg_update is the smoothed inter-channel time difference estimation deviation of the current frame, wherein xh_wgt is an upper limit value of the first weighting coefficient, wherein xl_wgt is a lower limit value of the first weighting coefficient, wherein yh_dist1′ is a first smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the first weighting coefficient, wherein yl_dist1′ is a second smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the first weighting coefficient, and wherein yh_dist1′, yl_dist1′, xh_wgt1, and xl_wgt1 are all positive numbers.
9. The delay estimation method of claim 8, wherein the first weighting coefficient of the current frame is further calculated using additional formulas comprising:
wgt_par1=min(wgt_par1, xh_wgt1); and
wgt_par1=max(wgt_par1, xl_wgt1), wherein min represents taking of a minimum value, and wherein max represents taking of a maximum value.
10. The delay estimation method of claim 7, wherein when the adaptive window function of the current frame is determined based on an inter-channel time difference estimation deviation of the current frame, updating the buffered weighting coefficient of the at least one past frame comprises: calculating a second weighting coefficient of the current frame based on the inter-channel time difference estimation deviation of the current frame; and updating a buffered second weighting coefficient of the at least one past frame based on the second weighting coefficient of the current frame.
11. The delay estimation method of claim 7, wherein updating the buffered weighting coefficient of the at least one past frame comprises updating the buffered weighting coefficient of the at least one past frame when a first voice activation detection result of the at least one past frame is a first active frame or a second voice activation detection result of the current frame is a second active frame.
12. An audio coding device comprising: at least one processor; and one or more memories coupled to the at least one processor and configured to store programming instructions for execution by the at least one processor to cause the audio coding device to: determine a cross-correlation coefficient of a multi-channel signal of a current frame; determine a delay track estimation value of the current frame based on buffered inter-channel time difference information of at least one past frame; determine an adaptive parameter of an adaptive window function of the current frame based on a coding parameter of the at least one past frame, wherein the coding parameter indicates a first type of the at least one past frame or a second type of the at least one past frame on which time-domain downmixing processing is performed; determine an adaptive window function of the current frame according to the adaptive parameter; perform weighting on the cross-correlation coefficient, based on the delay track estimation value of the current frame and the adaptive window function of the current frame, to obtain a weighted cross-correlation coefficient; and determine an inter-channel time difference of the current frame based on the weighted cross-correlation coefficient.
13. The audio coding device of claim 12, wherein when determining the delay track estimation value of the current frame, the programming instructions for execution by the at least one processor cause the audio coding device further to: perform delay track estimation based on the buffered inter-channel time difference information of the at least one past frame; and use a linear regression audio coding device to determine the delay track estimation value of the current frame.
14. The audio coding device of claim 12, wherein when determining the delay track estimation value of the current frame, the programming instructions for execution by the at least one processor cause the audio coding device further to: perform delay track estimation based on the buffered inter-channel time difference information of the at least one past frame; and use a weighted linear regression audio coding device to determine the delay track estimation value of the current frame.
15. The audio coding device of claim 12, wherein the programming instructions for execution by the at least one processor cause the audio coding device further to update the buffered inter-channel time difference information of the at least one past frame, and wherein the buffered inter-channel time difference information of the at least one past frame is an inter-channel time difference smoothed value of the at least one past frame or a second inter-channel time difference of the at least one past frame.
16. The audio coding device of claim 15, wherein the buffered inter-channel time difference information of the at least one past frame is the inter-channel time difference smoothed value of the at least one past frame, wherein when updating the buffered inter-channel time difference information of the at least one past frame, the programming instructions for execution by the at least one processor cause the audio coding device further to: determine a second inter-channel time difference smoothed value of the current frame based on the delay track estimation value of the current frame and the inter-channel time difference of the current frame; and update a buffered inter-channel time difference smoothed value of the at least one past frame based on the second inter-channel time difference smoothed value of the current frame, wherein the second inter-channel time difference smoothed value of the current frame is calculated using a formula comprising:
cur_itd_smooth=φ*reg_prv_corr+(1−φ)*cur_itd, wherein cur_itd_smooth is the second inter-channel time difference smoothed value of the current frame, wherein φ is a second smoothing factor comprising a constant greater than or equal to 0 and less than or equal to 1, wherein reg_prv_corr is the delay track estimation value of the current frame, and wherein cur itd is the inter-channel time difference of the current frame.
17. The audio coding device of claim 15, wherein the programming instructions for execution by the at least one processor cause the audio coding device further to update the buffered inter-channel time difference information of the at least one past frame when a first voice activation detection result of the at least one past frame is a first active frame or a second voice activation detection result of the current frame is a second active frame.
18. The audio coding device of claim 14, wherein the programming instructions for execution by the at least one processor cause the audio coding device further to update a buffered weighting coefficient of the at least one past frame, and wherein the buffered weighting coefficient of the at least one past frame is a weighting coefficient in the weighted linear regression audio coding device.
19. The audio coding device of claim 18, wherein the adaptive window function of the current frame is determined based on a smoothed inter-channel time difference of the at least one past frame, wherein when updating the buffered weighting coefficient of the at least one past frame, the programming instructions for execution by the at least one processor cause the audio coding device further to: calculate a first weighting coefficient of the current frame based on a smoothed inter-channel time difference estimation deviation of the current frame; and update a buffered first weighting coefficient of the at least one past frame based on the first weighting coefficient of the current frame, wherein the first weighting coefficient of the current frame is calculated using formulas comprising:
wgt_par1=a_wgt1*smooth_dist_reg_update+b_wgt1;
a_wgt1=(xl_wgt1−xh_wgt1)/(yh_dist1′−yl_dist1′); and
b_wgt1=xl_wgt1−a_wgt1*yh_dist1′, wherein wgt_par 1 is the first weighting coefficient of the current frame, wherein smooth_dist_reg_update is the smoothed inter-channel time difference estimation deviation of the current frame, wherein xh_wgt is an upper limit value of the first weighting coefficient, wherein xl_wgt is a lower limit value of the first weighting coefficient, wherein yh_dist1′ is a first smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the first weighting coefficient, wherein yl_dist1′ is a second smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the first weighting coefficient, and wherein yh_dist1yl_dist1′, xh_wgt1, and xl_wgt1 are all positive numbers.
20. The audio coding device of claim 19, wherein the first weighting coefficient of the current frame is further calculated using additional formulas comprising:
wgt_par1=min(wgt_par1, xh_wgt1); and
wgt_par1=max(wgt_par1, xl_wgt1), wherein min represents taking of a minimum value, and wherein max represents taking of a maximum value.
21. The audio coding device of claim 18, wherein the adaptive window function of the current frame is determined based on an inter-channel time difference estimation deviation of the current frame, and wherein when updating the buffered weighting coefficient of the at least one past frame, the programming instructions for execution by the at least one processor cause the audio coding device further to: calculate a second weighting coefficient of the current frame based on the inter-channel time difference estimation deviation of the current frame; and update a buffered second weighting coefficient of the at least one past frame based on the second weighting coefficient of the current frame.
22. The audio coding device of claim 18, wherein the programming instructions for execution by the at least one processor cause the audio coding device further to update the buffered weighting coefficient of the at least one past frame when a first voice activation detection result of the at least one past frame is a first active frame or a second voice activation detection result of the current frame is a second active frame.
Description
BRIEF DESCRIPTION OF DRAWINGS
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
[0071]
[0072]
[0073]
[0074]
DESCRIPTION OF EMBODIMENTS
[0075] The words “first”, “second” and similar words mentioned in this specification do not mean any order, quantity or importance, but are used to distinguish between different components. Likewise, “one”, “a/an”, or the like is not intended to indicate a quantity limitation either, but is intended to indicate existing at least one. “Connection”, “link” or the like is not limited to a physical or mechanical connection, but may include an electrical connection, regardless of a direct connection or an indirect connection.
[0076] In this specification, “a plurality of” refers to two or more than two. The term “and/or” describes an association relationship for describing associated objects and represents that three relationships may exist. For example, A and/or B may represent the following three cases. Only A exists, both A and B exist, and only B exists. The character “/” generally indicates an “or” relationship between the associated objects.
[0077]
[0078] The encoding component 110 is configured to encode a stereo signal in time domain. Optionally, the encoding component 110 may be implemented using software, may be implemented using hardware, or may be implemented in a form of a combination of software and hardware. This is not limited in this embodiment.
[0079] The encoding a stereo signal in time domain by the encoding component 110 includes the following steps.
[0080] (1) Perform time-domain preprocessing on an obtained stereo signal to obtain a preprocessed left channel signal and a preprocessed right channel signal.
[0081] The stereo signal is collected by a collection component and sent to the encoding component 110. Optionally, the collection component and the encoding component 110 may be disposed in a same device or in different devices.
[0082] The preprocessed left channel signal and the preprocessed right channel signal are two signals of the preprocessed stereo signal.
[0083] Optionally, the preprocessing includes at least one of high-pass filtering processing, pre-emphasis processing, sampling rate conversion, or channel conversion. This is not limited in this embodiment.
[0084] (2) Perform delay estimation based on the preprocessed left channel signal and the preprocessed right channel signal to obtain an inter-channel time difference between the preprocessed left channel signal and the preprocessed right channel signal.
[0085] (3) Perform delay alignment processing on the preprocessed left channel signal and the preprocessed right channel signal based on the inter-channel time difference, to obtain a left channel signal obtained after delay alignment processing and a right channel signal obtained after delay alignment processing.
[0086] (4) Encode the inter-channel time difference to obtain an encoding index of the inter-channel time difference.
[0087] (5) Calculate a stereo parameter used for time-domain downmixing processing, and encode the stereo parameter used for time-domain downmixing processing to obtain an encoding index of the stereo parameter used for time-domain downmixing processing.
[0088] The stereo parameter used for time-domain downmixing processing is used to perform time-domain downmixing processing on the left channel signal obtained after delay alignment processing and the right channel signal obtained after delay alignment processing.
[0089] (6) Perform, based on the stereo parameter used for time-domain downmixing processing, time-domain downmixing processing on the left channel signal and the right channel signal that are obtained after delay alignment processing, to obtain a primary channel signal and a secondary channel signal.
[0090] Time-domain downmixing processing is used to obtain the primary channel signal and the secondary channel signal.
[0091] After the left channel signal and the right channel signal that are obtained after delay alignment processing are processed using a time-domain downmixing technology, the primary channel signal (or primary channel, which may also be referred to as a middle channel (or mid channel) signal) and the secondary channel signal (or secondary channel, which may also be referred to as a side channel signal) are obtained.
[0092] The primary channel signal is used to represent information about correlation between channels, and the secondary channel signal is used to represent information about a difference between channels. When the left channel signal and the right channel signal that are obtained after delay alignment processing are aligned in time domain, the secondary channel signal is the weakest, and in this case, the stereo signal has a best effect.
[0093] Reference is made to a preprocessed left channel signal L and a preprocessed right channel signal R in an n.sup.th frame shown in
[0094] (7) Separately encode the primary channel signal and the secondary channel signal to obtain a first mono encoded bitstream corresponding to the primary channel signal and a second mono encoded bitstream corresponding to the secondary channel signal.
[0095] (8) Write the encoding index of the inter-channel time difference, the encoding index of the stereo parameter, the first mono encoded bitstream, and the second mono encoded bitstream into a stereo encoded bitstream.
[0096] The decoding component 120 is configured to decode the stereo encoded bitstream generated by the encoding component 110 to obtain the stereo signal.
[0097] Optionally, the encoding component 110 is connected to the decoding component 120 wiredly or wirelessly, and the decoding component 120 obtains, through the connection, the stereo encoded bitstream generated by the encoding component 110. Alternatively, the encoding component 110 stores the generated stereo encoded bitstream into a memory, and the decoding component 120 reads the stereo encoded bitstream in the memory.
[0098] Optionally, the decoding component 120 may be implemented using software, may be implemented using hardware, or may be implemented in a form of a combination of software and hardware. This is not limited in this embodiment.
[0099] The decoding the stereo encoded bitstream to obtain the stereo signal by the decoding component 120 includes the following several steps.
[0100] (1) Decode the first mono encoded bitstream and the second mono encoded bitstream in the stereo encoded bitstream to obtain the primary channel signal and the secondary channel signal.
[0101] (2) Obtain, based on the stereo encoded bitstream, an encoding index of a stereo parameter used for time-domain upmixing processing, and perform time-domain upmixing processing on the primary channel signal and the secondary channel signal to obtain a left channel signal obtained after time-domain upmixing processing and a right channel signal obtained after time-domain upmixing processing.
[0102] (3) Obtain the encoding index of the inter-channel time difference based on the stereo encoded bitstream, and perform delay adjustment on the left channel signal obtained after time-domain upmixing processing and the right channel signal obtained after time-domain upmixing processing to obtain the stereo signal.
[0103] Optionally, the encoding component 110 and the decoding component 120 may be disposed in a same device, or may be disposed in different devices. The device may be a mobile terminal that has an audio signal processing function, such as a mobile phone, a tablet computer, a laptop portable computer, a desktop computer, a BLUETOOTH speaker, a pen recorder, or a wearable device, or may be a network element that has an audio signal processing capability in a core network or a radio network. This is not limited in this embodiment.
[0104] For example, referring to
[0105] Optionally, the mobile terminal 130 includes a collection component 131, the encoding component 110, and a channel encoding component 132. The collection component 131 is connected to the encoding component 110, and the encoding component 110 is connected to the channel encoding component 132.
[0106] Optionally, the mobile terminal 140 includes an audio playing component 141, the decoding component 120, and a channel decoding component 142. The audio playing component 141 is connected to the decoding component 110, and the decoding component 110 is connected to the channel encoding component 132.
[0107] After collecting the stereo signal using the collection component 131, the mobile terminal 130 encodes the stereo signal using the encoding component 110 to obtain the stereo encoded bitstream. Then, the mobile terminal 130 encodes the stereo encoded bitstream using the channel encoding component 132 to obtain a transmit signal.
[0108] The mobile terminal 130 sends the transmit signal to the mobile terminal 140 using the wireless or wired network.
[0109] After receiving the transmit signal, the mobile terminal 140 decodes the transmit signal using the channel decoding component 142 to obtain the stereo encoded bitstream, decodes the stereo encoded bitstream using the decoding component 110 to obtain the stereo signal, and plays the stereo signal using the audio playing component 141.
[0110] For example, referring to
[0111] Optionally, the network element 150 includes a channel decoding component 151, the decoding component 120, the encoding component 110, and a channel encoding component 152. The channel decoding component 151 is connected to the decoding component 120, the decoding component 120 is connected to the encoding component 110, and the encoding component 110 is connected to the channel encoding component 152.
[0112] After receiving a transmit signal sent by another device, the channel decoding component 151 decodes the transmit signal to obtain a first stereo encoded bitstream, decodes the stereo encoded bitstream using the decoding component 120 to obtain a stereo signal, encodes the stereo signal using the encoding component 110 to obtain a second stereo encoded bitstream, and encodes the second stereo encoded bitstream using the channel encoding component 152 to obtain a transmit signal.
[0113] The other device may be a mobile terminal that has an audio signal processing capability, or may be another network element that has an audio signal processing capability. This is not limited in this embodiment.
[0114] Optionally, the encoding component 110 and the decoding component 120 in the network element may transcode a stereo encoded bitstream sent by the mobile terminal.
[0115] Optionally, in this embodiment, a device on which the encoding component 110 is installed is referred to as an audio coding device. In an embodiment, the audio coding device may also have an audio decoding function. This is not limited in this embodiment.
[0116] Optionally, in this embodiment, only the stereo signal is used as an example for description. In this application, the audio coding device may further process a multi-channel signal, where the multi-channel signal includes at least two channel signals.
[0117] Several nouns in the embodiments of this application are described below.
[0118] A multi-channel signal of a current frame is a frame of multi-channel signals used to estimate a current inter-channel time difference. The multi-channel signal of the current frame includes at least two channel signals. Channel signals of different channels may be collected using different audio collection components in the audio coding device, or channel signals of different channels may be collected by different audio collection components in another device. The channel signals of different channels are transmitted from a same sound source.
[0119] For example, the multi-channel signal of the current frame includes a left channel signal L and a right channel signal R. The left channel signal L is collected using a left channel audio collection component, the right channel signal R is collected using a right channel audio collection component, and the left channel signal L and the right channel signal R are from a same sound source.
[0120] Referring to
[0121] A previous frame of the current frame is a first frame that is located before the current frame, for example, if the current frame is the n.sup.th frame, the previous frame of the current frame is an (n−1).sup.th frame.
[0122] Optionally, the previous frame of the current frame may also be briefly referred to as the previous frame.
[0123] A past frame is located before the current frame in time domain, and the past frame includes the previous frame of the current frame, first two frames of the current frame, first three frames of the current frame, and the like. Referring to
[0124] Optionally, in this application, at least one past frame may be M frames located before the current frame, for example, eight frames located before the current frame.
[0125] A next frame is a first frame after the current frame. Referring to
[0126] A frame length is duration of a frame of multi-channel signals. Optionally, the frame length is represented by a quantity of sampling points, for example, a frame length N=320 sampling points.
[0127] A cross-correlation coefficient is used to represent a degree of cross correlation between channel signals of different channels in the multi-channel signal of the current frame under different inter-channel time differences. The degree of cross correlation is represented using a cross-correlation value. For any two channel signals in the multi-channel signal of the current frame, under an inter-channel time difference, if two channel signals obtained after delay adjustment is performed based on the inter-channel time difference are more similar, the degree of cross correlation is stronger, and the cross-correlation value is greater, or if a difference between two channel signals obtained after delay adjustment is performed based on the inter-channel time difference is greater, the degree of cross correlation is weaker, and the cross-correlation value is smaller.
[0128] An index value of the cross-correlation coefficient corresponds to an inter-channel time difference, and a cross-correlation value corresponding to each index value of the cross-correlation coefficient represents a degree of cross correlation between two mono signals that are obtained after delay adjustment and that correspond to each inter-channel time difference.
[0129] Optionally, the cross-correlation coefficient may also be referred to as a group of cross-correlation values or referred to as a cross-correlation function. This is not limited in this application.
[0130] Referring to
[0131] For example, when the index value of the cross-correlation coefficient is 0, the inter-channel time difference is −N/2 sampling points, and the inter-channel time difference is used to align the left channel signal L and the right channel signal R to obtain the cross-correlation value k0, when the index value of the cross-correlation coefficient is 1, the inter-channel time difference is (−N/2+1) sampling points, and the inter-channel time difference is used to align the left channel signal L and the right channel signal R to obtain the cross-correlation value kl, when the index value of the cross-correlation coefficient is 2, the inter-channel time difference is (−N/2+2) sampling points, and the inter-channel time difference is used to align the left channel signal L and the right channel signal R to obtain the cross-correlation value k2, when the index value of the cross-correlation coefficient is 3, the inter-channel time difference is (−N/2+3) sampling points, and the inter-channel time difference is used to align the left channel signal L and the right channel signal R to obtain the cross-correlation value k3, . . . , and when the index value of the cross-correlation coefficient is N, the inter-channel time difference is N/2 sampling points, and the inter-channel time difference is used to align the left channel signal L and the right channel signal R to obtain the cross-correlation value kN.
[0132] A maximum value in k0 to kN is searched, for example, k3 is maximum. In this case, it indicates that when the inter-channel time difference is (−N/2+3) sampling points, the left channel signal L and the right channel signal R are most similar, in other words, the inter-channel time difference is closest to a real inter-channel time difference.
[0133] It should be noted that this embodiment is only used to describe a principle that the audio coding device determines the inter-channel time difference using the cross-correlation coefficient. In an embodiment, the inter-channel time difference may not be determined using the foregoing method.
[0134]
[0135] Step 301. Determine a cross-correlation coefficient of a multi-channel signal of a current frame.
[0136] Step 302. Determine a delay track estimation value of the current frame based on buffered inter-channel time difference information of at least one past frame.
[0137] Optionally, the at least one past frame is consecutive in time, and a last frame in the at least one past frame and the current frame are consecutive in time. In other words, the last past frame in the at least one past frame is a previous frame of the current frame. Alternatively, the at least one past frame is spaced by a predetermined quantity of frames in time, and a last past frame in the at least one past frame is spaced by a predetermined quantity of frames from the current frame. Alternatively, the at least one past frame is inconsecutive in time, a quantity of frames spaced between the at least one past frame is not fixed, and a quantity of frames between a last past frame in the at least one past frame and the current frame is not fixed. A value of the predetermined quantity of frames is not limited in this embodiment, for example, two frames.
[0138] In this embodiment, a quantity of past frames is not limited. For example, the quantity of past frames is 8, 12, and 25.
[0139] The delay track estimation value is used to represent a predicted value of an inter-channel time difference of the current frame. In this embodiment, a delay track is simulated based on the inter-channel time difference information of the at least one past frame, and the delay track estimation value of the current frame is calculated based on the delay track.
[0140] Optionally, the inter-channel time difference information of the at least one past frame is an inter-channel time difference of the at least one past frame, or an inter-channel time difference smoothed value of the at least one past frame.
[0141] An inter-channel time difference smoothed value of each past frame is determined based on a delay track estimation value of the frame and an inter-channel time difference of the frame.
[0142] Step 303. Determine an adaptive window function of the current frame.
[0143] Optionally, the adaptive window function is a raised cosine-like window function. The adaptive window function has a function of relatively enlarging a middle part and suppressing an edge part.
[0144] Optionally, adaptive window functions corresponding to frames of channel signals are different.
[0145] The adaptive window function is represented using the following formulas.
When 0≤k≤TRUNC(A*L_NCSHIFT_DS/2)−2*win_width1−1, loc_weight_win(k)=win_bias1;
when TRUNC(A*L_NCSHIFT_DS/2)−2*win_width1≤k≤TRUNC(A* L_NCSHIFT_DS/2)+2*win_width1−1,
loc_weight_win(k)=0.5*(1+win_bias1)+0.5*(1−win_bias1)*cos(π*(k−TRUNC(A* L_NCSHIFT_DS/2))/(2*win_width1)); and
when TRUNC(A*L_NCSHIFT_DS/2)+2*win_width1≤k≤A*L_NCSHIFT_DS, loc_weight_win(k)=win_bias1,
where loc weight win(k) is used to represent the adaptive window function, where k=0, 1, . . . , A * L_NCSHIFT_DS, A is a preset constant greater than or equal to 4, for example, A=4, TRUNC indicates rounding a value, for example, rounding a value of A*L_NCSHIFT_DS/2 in the formula of the adaptive window function, L_NCSHIFT_DS is a maximum value of an absolute value of an inter-channel time difference, win width is used to represent a raised cosine width parameter of the adaptive window function, and win_bias is used to represent a raised cosine height bias of the adaptive window function.
[0146] Optionally, the maximum value of the absolute value of the inter-channel time difference is a preset positive number, and is usually a positive integer greater than zero and less than or equal to a frame length, for example, 40, 60, or 80.
[0147] Optionally, a maximum value of the inter-channel time difference or a minimum value of the inter-channel time difference is a preset positive integer, and the maximum value of the absolute value of the inter-channel time difference is obtained by taking an absolute value of the maximum value of the inter-channel time difference, or the maximum value of the absolute value of the inter-channel time difference is obtained by taking an absolute value of the minimum value of the inter-channel time difference.
[0148] For example, the maximum value of the inter-channel time difference is 40, the minimum value of the inter-channel time difference is −40, and the maximum value of the absolute value of the inter-channel time difference is 40, which is obtained by taking an absolute value of the maximum value of the inter-channel time difference and is also obtained by taking an absolute value of the minimum value of the inter-channel time difference.
[0149] For another example, the maximum value of the inter-channel time difference is 40, the minimum value of the inter-channel time difference is −20, and the maximum value of the absolute value of the inter-channel time difference is 40, which is obtained by taking an absolute value of the maximum value of the inter-channel time difference.
[0150] For another example, the maximum value of the inter-channel time difference is 40, the minimum value of the inter-channel time difference is −60, and the maximum value of the absolute value of the inter-channel time difference is 60, which is obtained by taking an absolute value of the minimum value of the inter-channel time difference.
[0151] It can be learned from the formula of the adaptive window function that the adaptive window function is a raised cosine-like window with a fixed height on both sides and a convexity in the middle. The adaptive window function includes a constant-weight window and a raised cosine window with a height bias. A weight of the constant-weight window is determined based on the height bias. The adaptive window function is mainly determined by two parameters the raised cosine width parameter and the raised cosine height bias.
[0152] Reference is made to a schematic diagram of an adaptive window function shown in
[0153] The raised cosine width parameter and the raised cosine height bias of the adaptive window function are related to inter-channel time difference estimation deviation information of a multi-channel signal of each frame. The inter-channel time difference estimation deviation information is used to represent a deviation between a predicted value of an inter-channel time difference and an actual value.
[0154] Reference is made to a schematic diagram of a relationship between a raised cosine width parameter and inter-channel time difference estimation deviation information shown in
[0155] Reference is made to a schematic diagram of a relationship between a raised cosine height bias and inter-channel time difference estimation deviation information shown in
[0156] Step 304. Perform weighting on the cross-correlation coefficient based on the delay track estimation value of the current frame and the adaptive window function of the current frame, to obtain a weighted cross-correlation coefficient.
[0157] The weighted cross-correlation coefficient may be obtained through calculation using the following calculation formula:
c_weight(x)=c(x)*loc_weight_win(x−TRUNC(reg_prv_corr)+TRUNC(A* L_NCSHIFT_DS/2)−L_NCSHIFT_DS),
where c_weight(x) is the weighted cross-correlation coefficient, c(x) is the cross-correlation coefficient, loc weight win is the adaptive window function of the current frame, TRUNC indicates rounding a value, for example, rounding reg_prv_corr in the formula of the weighted cross-correlation coefficient, and rounding a value of A*L_NCSHIFT_DS/2, reg_prv_corr is the delay track estimation value of the current frame, and x is an integer greater than or equal to zero and less than or equal to 2 L_NCSHIFT_DS.
[0158] The adaptive window function is the raised cosine-like window, and has the function of relatively enlarging a middle part and suppressing an edge part. Therefore, when weighting is performed on the cross-correlation coefficient based on the delay track estimation value of the current frame and the adaptive window function of the current frame, if an index value is closer to the delay track estimation value, a weighting coefficient of a corresponding cross-correlation value is greater, and if the index value is farther from the delay track estimation value, the weighting coefficient of the corresponding cross-correlation value is smaller. The raised cosine width parameter and the raised cosine height bias of the adaptive window function adaptively suppress the cross-correlation value corresponding to the index value, away from the delay track estimation value, in the cross-correlation coefficient.
[0159] Step 305. Determine an inter-channel time difference of the current frame based on the weighted cross-correlation coefficient.
[0160] The determining an inter-channel time difference of the current frame based on the weighted cross-correlation coefficient includes searching for a maximum value of the cross-correlation value in the weighted cross-correlation coefficient, and determining the inter-channel time difference of the current frame based on an index value corresponding to the maximum value.
[0161] Optionally, the searching for a maximum value of the cross-correlation value in the weighted cross-correlation coefficient includes comparing a second cross-correlation value with a first cross-correlation value in the cross-correlation coefficient to obtain a maximum value in the first cross-correlation value and the second cross-correlation value, comparing a third cross-correlation value with the maximum value to obtain a maximum value in the third cross-correlation value and the maximum value, and in a cyclic order, comparing an i.sup.th cross-correlation value with a maximum value obtained through previous comparison to obtain a maximum value in the i.sup.th cross-correlation value and the maximum value obtained through previous comparison. It is assumed that i=i+1, and the step of comparing an i.sup.th cross-correlation value with a maximum value obtained through previous comparison is continuously performed until all cross-correlation values are compared, to obtain a maximum value in the cross-correlation values, where i is an integer greater than 2.
[0162] Optionally, the determining the inter-channel time difference of the current frame based on an index value corresponding to the maximum value includes using a sum of the index value corresponding to the maximum value and the minimum value of the inter-channel time difference as the inter-channel time difference of the current frame.
[0163] The cross-correlation coefficient can reflect a degree of cross correlation between two channel signals obtained after a delay is adjusted based on different inter-channel time differences, and there is a correspondence between an index value of the cross-correlation coefficient and an inter-channel time difference. Therefore, an audio coding device can determine the inter-channel time difference of the current frame based on an index value corresponding to a maximum value of the cross-correlation coefficient (with a highest degree of cross correlation).
[0164] In conclusion, according to the delay estimation method provided in this embodiment, the inter-channel time difference of the current frame is predicted based on the delay track estimation value of the current frame, and weighting is performed on the cross-correlation coefficient based on the delay track estimation value of the current frame and the adaptive window function of the current frame. The adaptive window function is the raised cosine-like window, and has the function of relatively enlarging the middle part and suppressing the edge part. Therefore, when weighting is performed on the cross-correlation coefficient based on the delay track estimation value of the current frame and the adaptive window function of the current frame, if an index value is closer to the delay track estimation value, a weighting coefficient is greater, avoiding a problem that a first cross-correlation coefficient is excessively smoothed, and if the index value is farther from the delay track estimation value, the weighting coefficient is smaller, avoiding a problem that a second cross-correlation coefficient is insufficiently smoothed. In this way, the adaptive window function adaptively suppresses a cross-correlation value corresponding to the index value, away from the delay track estimation value, in the cross-correlation coefficient, thereby improving accuracy of determining the inter-channel time difference in the weighted cross-correlation coefficient. The first cross-correlation coefficient is a cross-correlation value corresponding to an index value, near the delay track estimation value, in the cross-correlation coefficient, and the second cross-correlation coefficient is a cross-correlation value corresponding to an index value, away from the delay track estimation value, in the cross-correlation coefficient.
[0165] Steps 301 to 303 in the embodiment shown in
[0166] First, that the cross-correlation coefficient of the multi-channel signal of the current frame is determined in step 301 is described.
[0167] (1) The audio coding device determines the cross-correlation coefficient based on a left channel time domain signal and a right channel time domain signal of the current frame.
[0168] A maximum value T.sub.max of the inter-channel time difference and a minimum value T.sub.min of the inter-channel time difference usually need to be preset in order to determine a calculation range of the cross-correlation coefficient. Both the maximum value T.sub.max of the inter-channel time difference and the minimum value T.sub.max of the inter-channel time difference are real numbers, and T.sub.max>T.sub.min. Values of T.sub.max and T.sub.min are related to a frame length, or values of T.sub.max and T.sub.min are related to a current sampling frequency.
[0169] Optionally, a maximum value L_NCSHIFT_DS of an absolute value of the inter-channel time difference is preset, to determine the maximum value T.sub.max of the inter-channel time difference and the minimum value T.sub.min of the inter-channel time difference. For example, the maximum value T.sub.max of the inter-channel time difference=L_NCSHIFT_DS, and the minimum value T.sub.max of the inter-channel time difference=−L_NCSHIFT_DS.
[0170] The values of T.sub.max and T.sub.min are not limited in this application. For example, if the maximum value L_NCSHIFT_DS of the absolute value of the inter-channel time difference is 40, T.sub.max=40, and T.sub.min=−40.
[0171] In an implementation, an index value of the cross-correlation coefficient is used to indicate a difference between the inter-channel time difference and the minimum value of the inter-channel time difference. In this case, determining the cross-correlation coefficient based on the left channel time domain signal and the right channel time domain signal of the current frame is represented using the following formulas.
[0172] N is a frame length, {tilde over (x)}.sub.L(j) is the left channel time domain signal of the current frame, {tilde over (x)}.sub.R (j) is the right channel time domain signal of the current frame, c(k) is the cross-correlation coefficient of the current frame, k is the index value of the cross-correlation coefficient, k is an integer not less than 0, and a value range of k is [0, T.sub.max−T.sub.min].
[0173] It is assumed that T.sub.max=40, and T.sub.min=−40. In this case, the audio coding device determines the cross-correlation coefficient of the current frame using the calculation manner corresponding to the case that T.sub.min≤0 and 0<T.sub.max. In this case, the value range of k is [0, 80].
[0174] In another implementation, the index value of the cross-correlation coefficient is used to indicate the inter-channel time difference. In this case, determining, by the audio coding device, the cross-correlation coefficient based on the maximum value of the inter-channel time difference and the minimum value of the inter-channel time difference is represented using the following formulas.
[0175] N is a frame length, {tilde over (X)}.sub.L(i) is the left channel time domain signal of the current frame, {tilde over (X)}.sub.R(j) is the right channel time domain signal of the current frame, c(i) is the cross-correlation coefficient of the current frame, i is the index value of the cross-correlation coefficient, and a value range of i is [T.sub.min, T.sub.max].
[0176] It is assumed that T.sub.max=40, and T.sub.min=−40. In this case, the audio coding device determines the cross-correlation coefficient of the current frame using the calculation formula corresponding to T.sub.min≥0 and 0<T.sub.max. In this case, the value range of i is [−40, 40].
[0177] Second, the determining a delay track estimation value of the current frame in step 302 is described.
[0178] In a first implementation, delay track estimation is performed based on the buffered inter-channel time difference information of the at least one past frame using a linear regression method, to determine the delay track estimation value of the current frame.
[0179] This implementation is implemented using the following several steps.
[0180] (1) Generate M data pairs based on the inter-channel time difference information of the at least one past frame and a corresponding sequence number, where M is a positive integer.
[0181] A buffer stores inter-channel time difference information of M past frames.
[0182] Optionally, the inter-channel time difference information is an inter-channel time difference. Alternatively, the inter-channel time difference information is an inter-channel time difference smoothed value.
[0183] Optionally, inter-channel time differences that are of the M past frames and that are stored in the buffer follow a first in first out principle. In an embodiment, a buffer location of an inter-channel time difference that is buffered first and that is of a past frame is in the front, and a buffer location of an inter-channel time difference that is buffered later and that is of a past frame is in the back.
[0184] In addition, for the inter-channel time difference that is buffered later and that is of the past frame, the inter-channel time difference that is buffered first and that is of the past frame moves out of the buffer first.
[0185] Optionally, in this embodiment, each data pair is generated using inter-channel time difference information of each past frame and a corresponding sequence number.
[0186] A sequence number is referred to as a location of each past frame in the buffer. For example, if eight past frames are stored in the buffer, sequence numbers are 0, 1, 2, 3, 4, 5, 6, and 7 respectively.
[0187] For example, the generated M data pairs are {(x.sub.0, y.sub.0), (x.sub.1, y.sub.1), (x.sub.2, y.sub.2) . . . (x.sub.r, y.sub.r), . . . , and (x.sub.M−1, y.sub.M−1)}. (x.sub.r, y.sub.r) is an (r+1).sup.th data pair, and x.sub.r is used to indicate a sequence number of the (r+1).sup.th data pair, that is, x.sub.r=r, and y.sub.r is used to indicate an inter-channel time difference that is of a past frame and that corresponds to the (r+1).sup.th data pair, where r=0, 1, . . . , and (M−1).
[0188]
[0189] (2) Calculate a first linear regression parameter and a second linear regression parameter based on the M data pairs.
[0190] In this embodiment, it is assumed that yr in the data pairs is a linear function that is about xr and that has a measurement error of Er. The linear function is as follows.
y.sub.r=α+β*x.sub.r+ε.sub.r,
where α is the first linear regression parameter, β is the second linear regression parameter, and ε.sub.r is the measurement error.
[0191] The linear function needs to meet the following condition. A distance between the observed value yr (inter-channel time difference information actually buffered) corresponding to the observation point xr and an estimation value α+β* x.sub.r calculated based on the linear function is the smallest, in an embodiment, minimization of a cost function Q (α, β) is met.
[0192] The cost function Q (α, β) is as follows.
[0193] To meet the foregoing condition, the first linear regression parameter and the second linear regression parameter in the linear function need to meet the following.
where x.sub.r is used to indicate the sequence number of the (r+1).sup.th data pair in the M data pairs, and y.sub.r is inter-channel time difference information of the (r+1).sup.th data pair.
[0194] (3) Obtain the delay track estimation value of the current frame based on the first linear regression parameter and the second linear regression parameter.
[0195] An estimation value corresponding to a sequence number of an (M+1).sup.th data pair is calculated based on the first linear regression parameter and the second linear regression parameter, and the estimation value is determined as the delay track estimation value of the current frame. A formula is as follows.
reg_prv_corr=α+β*M,
where reg_prv_corr represents the delay track estimation value of the current frame, M is the sequence number of the (M+1).sup.th data pair, and α+β*M is the estimation value of the (M+1).sup.th data pair.
[0196] For example, M=8. After α and β are determined based on the eight generated data pairs, an inter-channel time difference in a ninth data pair is estimated based on α and β, and the inter-channel time difference in the ninth data pair is determined as the delay track estimation value of the current frame, that is, reg_prv_corr=α+β*8.
[0197] Optionally, in this embodiment, only a manner of generating a data pair using a sequence number and an inter-channel time difference is used as an example for description. In an embodiment, the data pair may alternatively be generated in another manner. This is not limited in this embodiment.
[0198] In a second implementation, delay track estimation is performed based on the buffered inter-channel time difference information of the at least one past frame using a weighted linear regression method, to determine the delay track estimation value of the current frame.
[0199] This implementation is implemented using the following several steps.
[0200] (1) Generate M data pairs based on the inter-channel time difference information of the at least one past frame and a corresponding sequence number, where M is a positive integer.
[0201] This step is the same as the related description in step (1) in the first implementation, and details are not described herein in this embodiment.
[0202] (2) Calculate a first linear regression parameter and a second linear regression parameter based on the M data pairs and weighting coefficients of the M past frames.
[0203] Optionally, the buffer stores not only the inter-channel time difference information of the M past frames, but also stores the weighting coefficients of the M past frames. A weighting coefficient is used to calculate a delay track estimation value of a corresponding past frame.
[0204] Optionally, a weighting coefficient of each past frame is obtained through calculation based on a smoothed inter-channel time difference estimation deviation of the past frame. Alternatively, a weighting coefficient of each past frame is obtained through calculation based on an inter-channel time difference estimation deviation of the past frame.
[0205] In this embodiment, it is assumed that ε.sub.r in the data pairs is a linear function that is about x.sub.r and that has a measurement error of ε.sub.r. The linear function is as follows.
y.sub.r=α+β*x.sub.r+ε.sub.r,
where α is the first linear regression parameter, β is the second linear regression parameter, and ε.sub.r is the measurement error.
[0206] The linear function needs to meet the following condition. A weighting distance between the observed value y.sub.r (inter-channel time difference information actually buffered) corresponding to the observation point x.sub.r and an estimation value α+β*x.sub.r calculated based on the linear function is the smallest, in an embodiment, minimization of a cost function Q (α, β) is met.
[0207] The cost function Q (α, β) is as follows.
[0208] where w.sub.r is a weighting coefficient of a past frame corresponding to an r.sup.th data pair.
[0209] To meet the foregoing condition, the first linear regression parameter and the second linear regression parameter in the linear function need to meet the following.
where x.sub.r is used to indicate a sequence number of the (r+1).sup.th data pair in the M data pairs, y.sub.r is inter-channel time difference information in the (r+1).sup.th data pair, wr is a weighting coefficient corresponding to the inter-channel time difference information in the (r+1).sup.th data pair in at least one past frame.
[0210] (3) Obtain the delay track estimation value of the current frame based on the first linear regression parameter and the second linear regression parameter.
[0211] This step is the same as the related description in step (3) in the first implementation, and details are not described herein in this embodiment.
[0212] Optionally, in this embodiment, only a manner of generating a data pair using a sequence number and an inter-channel time difference is used as an example for description. In an embodiment, the data pair may alternatively be generated in another manner. This is not limited in this embodiment.
[0213] It should be noted that in this embodiment, description is provided using an example in which a delay track estimation value is calculated only using the linear regression method or in the weighted linear regression manner. In an embodiment, the delay track estimation value may alternatively be calculated in another manner. This is not limited in this embodiment. For example, the delay track estimation value is calculated using a B-spline (B-spline) method, or the delay track estimation value is calculated using a cubic spline method, or the delay track estimation value is calculated using a quadratic spline method.
[0214] Third, the determining an adaptive window function of the current frame in step 303 is described.
[0215] In this embodiment, two manners of calculating the adaptive window function of the current frame are provided. In a first manner, the adaptive window function of the current frame is determined based on a smoothed inter-channel time difference estimation deviation of a previous frame. In this case, inter-channel time difference estimation deviation information is the smoothed inter-channel time difference estimation deviation, and the raised cosine width parameter and the raised cosine height bias of the adaptive window function are related to the smoothed inter-channel time difference estimation deviation. In a second manner, the adaptive window function of the current frame is determined based on the inter-channel time difference estimation deviation of the current frame. In this case, the inter-channel time difference estimation deviation information is the inter-channel time difference estimation deviation, and the raised cosine width parameter and the raised cosine height bias of the adaptive window function are related to the inter-channel time difference estimation deviation.
[0216] The two manners are separately described below.
[0217] This first manner is implemented using the following several steps.
[0218] (1) Calculate a first raised cosine width parameter based on the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame.
[0219] Because accuracy of calculating the adaptive window function of the current frame using a multi-channel signal near the current frame is relatively high, in this embodiment, description is provided using an example in which the adaptive window function of the current frame is determined based on the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame.
[0220] Optionally, the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame is stored in the buffer.
[0221] This step is represented using the following formulas:
win_width1=TRUNC(width_par1*(A*L_NCSHIFT_DS+1)), and
width_par1=a_width1*smooth_dist_reg+b width1, where
a_width1=(xh_width1−xl_width1)/(yh_dist1−yl_dist1),
b_width1=xh_width1−a_width1*yh_dist1,
where win width1 is the first raised cosine width parameter, TRUNC indicates rounding a value, L_NCSHIFT_DS is the maximum value of the absolute value of the inter-channel time difference, A is a preset constant, and A is greater than or equal to 4.
[0222] xh_width1 is an upper limit value of the first raised cosine width parameter, for example, 0.25 in
[0223] smooth_dist_reg is the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame, and xh_width1, xl_width1, yh_dist1, and yl_dist1 are all positive numbers.
[0224] Optionally, in the foregoing formula, b_width1=xh_width1−a_width1*yh_dist1 may be replaced with b_width1=xl_width1−a_width1*yl_dist1.
[0225] Optionally, in this step, width_par1=min(width_par1, xh_width1), and width_par1=max(width_par1, xl_width1), where min represents taking of a minimum value, and max represents taking of a maximum value. In an embodiment, when width_par1 obtained through calculation is greater than xh_width1, width_par1 is set to xh_width1, or when width_par1 obtained through calculation is less than xl_width1, width_par1 is set to xl_width1.
[0226] In this embodiment, when width_par1 is greater than the upper limit value of the first raised cosine width parameter, width_par1 is limited to be the upper limit value of the first raised cosine width parameter, or when width_par1 is less than the lower limit value of the first raised cosine width parameter, width_par1 is limited to the lower limit value of the first raised cosine width parameter in order to ensure that a value of width_par1 does not exceed a normal value range of the raised cosine width parameter, thereby ensuring accuracy of a calculated adaptive window function.
[0227] (2) Calculate a first raised cosine height bias based on the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame.
[0228] This step is represented using the following formula:
win_bias1=a_bias1*smooth_dist_reg+b_bias1, a_bias1=(xh_bias1−xl_bias1)/(yh_dist2−yl_dist2), and
b_bias1=xh_bias1−a_bias1*yh_dist2,
where win_bias1 is the first raised cosine height bias, xh_bias1 is an upper limit value of the first raised cosine height bias, for example, 0.7 in
[0229] Optionally, in the foregoing formula, b_bias1=xh_bias1−a_bias1*yh_dist2 may be replaced with b_bias1=xl_bias1−a_bias1*yl_dist2.
[0230] Optionally, in this embodiment, win_bias1=min(win_bias1, xh_bias1), and win_bias1 =max(win_bias1, xl_bias1). In an embodiment, when win_bias1 obtained through calculation is greater than xh_bias1, win_bias1 is set to xh_bias1, or when win_bias1 obtained through calculation is less than xl_bias1, win_bias1 is set to xl_bias1.
[0231] Optionally, yh_dist2=yh_dist1, and yl_dist2=yl_dist1.
[0232] (3) Determine the adaptive window function of the current frame based on the first raised cosine width parameter and the first raised cosine height bias.
[0233] The first raised cosine width parameter and the first raised cosine height bias are brought into the adaptive window function in step 303 to obtain the following calculation formulas.
When 0≤k≤TRUNC(A*L_NCSHIFT_DS/2)−2*win_width1−1, loc_weight_win(k)=win_bias1;
when TRUNC(A*L_NCSHIFT_DS/2)−2*win_width1≤k≤TRUNC(A* L_NCSHIFT_DS/2)+2*win_width1−1,
loc_weight_win(k)=0.5*(1+win_bias1)+0.5*(1−win_bias1)*cos(π*(k−TRUNC(A* L_NCSHIFT_DS/2))/(2*win_width1)); and
when TRUNC(A*L_NCSHIFT_DS/2)+2*win_width1≤k≤A*L_NCSHIFT_DS, loc_weight_win(k)=win_bias1,
where loc_weight_win(k) is used to represent the adaptive window function, where k=0, 1, . . . , A *L_NCSHIFT_DS, A is the preset constant greater than or equal to 4, for example, A=4, L_NCSHIFT_DS is the maximum value of the absolute value of the inter-channel time difference, win_width1 is the first raised cosine width parameter, and win_bias1 is the first raised cosine height bias.
[0234] In this embodiment, the adaptive window function of the current frame is calculated using the smoothed inter-channel time difference estimation deviation of the previous frame such that a shape of the adaptive window function is adjusted based on the smoothed inter-channel time difference estimation deviation, thereby avoiding a problem that a generated adaptive window function is inaccurate due to an error of the delay track estimation of the current frame, and improving accuracy of generating an adaptive window function.
[0235] Optionally, after the inter-channel time difference of the current frame is determined based on the adaptive window function determined in the first manner, the smoothed inter-channel time difference estimation deviation of the current frame may be further determined based on the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame, the delay track estimation value of the current frame, and the inter-channel time difference of the current frame.
[0236] Optionally, the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame in the buffer is updated based on the smoothed inter-channel time difference estimation deviation of the current frame.
[0237] Optionally, after the inter-channel time difference of the current frame is determined each time, the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame in the buffer is updated based on the smoothed inter-channel time difference estimation deviation of the current frame.
[0238] Optionally, updating the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame in the buffer based on the smoothed inter-channel time difference estimation deviation of the current frame includes replacing the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame in the buffer with the smoothed inter-channel time difference estimation deviation of the current frame.
[0239] The smoothed inter-channel time difference estimation deviation of the current frame is obtained through calculation using the following calculation formulas:
smooth_dist_reg_update=(1−γ)*smooth_dist_reg+γ*dist_reg', and dist_reg'=|reg_prv_corr−cur_itd|,
where smooth_dist_reg_update is the smoothed inter-channel time difference estimation deviation of the current frame, γ is a first smoothing factor, 0<γ<1, for example, γ=0.02, smooth_dist_reg is the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame, reg_prv_corr is the delay track estimation value of the current frame, and cur_itd is the inter-channel time difference of the current frame.
[0240] In this embodiment, after the inter-channel time difference of the current frame is determined, the smoothed inter-channel time difference estimation deviation of the current frame is calculated. When an inter-channel time difference of a next frame is to be determined, an adaptive window function of the next frame can be determined using the smoothed inter-channel time difference estimation deviation of the current frame, thereby ensuring accuracy of determining the inter-channel time difference of the next frame.
[0241] Optionally, after the inter-channel time difference of the current frame is determined based on the adaptive window function determined in the foregoing first manner, the buffered inter-channel time difference information of the at least one past frame may be further updated.
[0242] In an update manner, the buffered inter-channel time difference information of the at least one past frame is updated based on the inter-channel time difference of the current frame.
[0243] In another update manner, the buffered inter-channel time difference information of the at least one past frame is updated based on an inter-channel time difference smoothed value of the current frame.
[0244] Optionally, the inter-channel time difference smoothed value of the current frame is determined based on the delay track estimation value of the current frame and the inter-channel time difference of the current frame.
[0245] For example, based on the delay track estimation value of the current frame and the inter-channel time difference of the current frame, the inter-channel time difference smoothed value of the current frame may be determined using the following formula:
cur_itd_smooth=φ*reg_prv_corr+(1−φ)*cur_itd,
where cur_itd_smooth is the inter-channel time difference smoothed value of the current frame, φ is a second smoothing factor, reg_prv_corr is the delay track estimation value of the current frame, cur_itd is the inter-channel time difference of the current frame, and γ is a constant greater than or equal to 0 and less than or equal to 1.
[0246] The updating the buffered inter-channel time difference information of the at least one past frame includes adding the inter-channel time difference of the current frame or the inter-channel time difference smoothed value of the current frame to the buffer.
[0247] Optionally, for example, the inter-channel time difference smoothed value in the buffer is updated. The buffer stores inter-channel time difference smoothed values corresponding to a fixed quantity of past frames, for example, the buffer stores inter-channel time difference smoothed values of eight past frames. If the inter-channel time difference smoothed value of the current frame is added to the buffer, an inter-channel time difference smoothed value of a past frame that is originally located in a first bit (a head of a queue) in the buffer is deleted. Correspondingly, an inter-channel time difference smoothed value of a past frame that is originally located in a second bit is updated to the first bit. By analogy, the inter-channel time difference smoothed value of the current frame is located in a last bit (a tail of the queue) in the buffer.
[0248] Reference is made to a buffer updating process shown in
[0249] If the inter-channel time difference smoothed value 601 of the current frame is added to the buffer, the first bit (which is represented by a dashed box in the figure) is deleted, a sequence number of the second bit becomes a sequence number of the first bit, a sequence number of the third bit becomes the sequence number of the second bit, . . . , and a sequence number of the eighth bit becomes a sequence number of a seventh bit. The inter-channel time difference smoothed value 601 of the current frame (an i.sup.th frame) is located in the eighth bit, to obtain eight past frames corresponding to a next frame.
[0250] Optionally, after the inter-channel time difference smoothed value of the current frame is added to the buffer, the inter-channel time difference smoothed value buffered in the first bit may not be deleted, instead, inter-channel time difference smoothed values in the second bit to a ninth bit are directly used to calculate an inter-channel time difference of a next frame. Alternatively, inter-channel time difference smoothed values in the first bit to a ninth bit are used to calculate an inter-channel time difference of a next frame. In this case, a quantity of past frames corresponding to each current frame is variable. A buffer update manner is not limited in this embodiment.
[0251] In this embodiment, after the inter-channel time difference of the current frame is determined, the inter-channel time difference smoothed value of the current frame is calculated. When a delay track estimation value of the next frame is to be determined, the delay track estimation value of the next frame can be determined using the inter-channel time difference smoothed value of the current frame. This ensures accuracy of determining the delay track estimation value of the next frame.
[0252] Optionally, if the delay track estimation value of the current frame is determined based on the foregoing second implementation of determining the delay track estimation value of the current frame, after the buffered inter-channel time difference smoothed value of the at least one past frame is updated, a buffered weighting coefficient of the at least one past frame may be further updated. The weighting coefficient of the at least one past frame is a weighting coefficient in the weighted linear regression method.
[0253] In the first manner of determining the adaptive window function, the updating the buffered weighting coefficient of the at least one past frame includes calculating a first weighting coefficient of the current frame based on the smoothed inter-channel time difference estimation deviation of the current frame, and updating a buffered first weighting coefficient of the at least one past frame based on the first weighting coefficient of the current frame.
[0254] In this embodiment, for related descriptions of buffer updating, refer to
[0255] The first weighting coefficient of the current frame is obtained through calculation using the following calculation formulas:
wgt_par1=a_wgt1*smooth_dist_reg_update+b wgt1;
a_wgt1=(xl_wgt1−xh_wgt1)/(yh_dist1′−yl_dist1′); and
b_wgt1=xl_wgt1−a_wgt1*yh_dist1′,
where wgt_par1 is the first weighting coefficient of the current frame, smooth_dist_reg_update is the smoothed inter-channel time difference estimation deviation of the current frame, xh_wgt is an upper limit value of the first weighting coefficient, xl_wgt is a lower limit value of the first weighting coefficient, yh_dist1′ is a smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the first weighting coefficient, yl_dist1′ is a smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the first weighting coefficient, and yh_dist1′, yl_dist1′, xh_wgt1, and xl_wgt1 are all positive numbers.
[0256] Optionally, wgt_par1=min(wgt_par1, xh_wgt1), and wgt_par1=max(wgt_par1, xl_wgt1).
[0257] Optionally, in this embodiment, values of yh_dist1′, yl_dist1′, xh_wgt1, and xl_wgt1 are not limited. For example, xl_wgt1=0.05, xh_wgt1=1.0, yl_dist1′=2.0, and yh_dist1′=1.0.
[0258] Optionally, in the foregoing formula, b_wgt1=xl_wgt1_a_wgt1*yh_dist1′ may be replaced with b_wgt1=xh_wgt1−a_wgt1*yl_dist_1′.
[0259] In this embodiment, xh_wgt1>xl_wgt1, and yh_dist1′<yl_dist1′.
[0260] In this embodiment, when wgt_par1 is greater than the upper limit value of the first weighting coefficient, wgt_par1 is limited to be the upper limit value of the first weighting coefficient, or when wgt_par1 is less than the lower limit value of the first weighting coefficient, wgt_par1 is limited to the lower limit value of the first weighting coefficient in order to ensure that a value of wgt_par1 does not exceed a normal value range of the first weighting coefficient, thereby ensuring accuracy of the calculated delay track estimation value of the current frame.
[0261] In addition, after the inter-channel time difference of the current frame is determined, the first weighting coefficient of the current frame is calculated. When the delay track estimation value of the next frame is to be determined, the delay track estimation value of the next frame can be determined using the first weighting coefficient of the current frame, thereby ensuring accuracy of determining the delay track estimation value of the next frame.
[0262] In the second manner, an initial value of the inter-channel time difference of the current frame is determined based on the cross-correlation coefficient, the inter-channel time difference estimation deviation of the current frame is calculated based on the delay track estimation value of the current frame and the initial value of the inter-channel time difference of the current frame, and the adaptive window function of the current frame is determined based on the inter-channel time difference estimation deviation of the current frame.
[0263] Optionally, the initial value of the inter-channel time difference of the current frame is a maximum value that is of a cross-correlation value in the cross-correlation coefficient and that is determined based on the cross-correlation coefficient of the current frame, and an inter-channel time difference determined based on an index value corresponding to the maximum value.
[0264] Optionally, determining the inter-channel time difference estimation deviation of the current frame based on the delay track estimation value of the current frame and the initial value of the inter-channel time difference of the current frame is represented using the following formula:
dist_reg=|reg_prv_corr−cur_itd_init|,
where dist_reg is the inter-channel time difference estimation deviation of the current frame, reg_prv_con is the delay track estimation value of the current frame, and cur_itd_init is the initial value of the inter-channel time difference of the current frame.
[0265] Based on the inter-channel time difference estimation deviation of the current frame, determining the adaptive window function of the current frame is implemented using the following steps.
[0266] (1) Calculate a second raised cosine width parameter based on the inter-channel time difference estimation deviation of the current frame.
[0267] This step may be represented using the following formulas:
win_width2=TRUNC(width_par2*(A*L_NCSHIFT_DS+1)),
width_par2=a_width2*dist_reg+b_width2,
a_width2=(xh_width2−xl_width2)/(yh_dist3−yl_dist1), and
b_width2=xh_width2−a_width1*yh_dist3,
where win width2 is the second raised cosine width parameter, TRUNC indicates rounding a value, L_NCSHIFT_DS is a maximum value of an absolute value of an inter-channel time difference, A is a preset constant, A is greater than or equal to 4, A*L_NCSHIFT_DS+1 is a positive integer greater than zero, xh_width2 is an upper limit value of the second raised cosine width parameter, xl_width2 is a lower limit value of the second raised cosine width parameter, yh_dist3 is an inter-channel time difference estimation deviation corresponding to the upper limit value of the second raised cosine width parameter, yl_dist3 is an inter-channel time difference estimation deviation corresponding to the lower limit value of the second raised cosine width parameter, dist_reg is the inter-channel time difference estimation deviation, and xh_width2, xl_width2, yh_dist3, and yl_dist3 are all positive numbers.
[0268] Optionally, in this step, b_width2=xh_width2−a_width2*yh_dist3 may be replaced with b_width2=xl_width2−a_width2*yl_dist3.
[0269] Optionally, in this step, width_par2 32 min(width_par2, xh_width2), and width_par2=max(width_par2, xl_width2), where min represents taking of a minimum value, and max represents taking of a maximum value. In an embodiment, when width_par2 obtained through calculation is greater than xh_width2, width_par2 is set to xh_width2, or when width_par2 obtained through calculation is less than xl_width2, width_par2 is set to xl_width2.
[0270] In this embodiment, when width_par2 is greater than the upper limit value of the second raised cosine width parameter, width_par2 is limited to be the upper limit value of the second raised cosine width parameter, or when width_par2 is less than the lower limit value of the second raised cosine width parameter, width_par2 is limited to the lower limit value of the second raised cosine width parameter in order to ensure that a value of width_par2 does not exceed a normal value range of the raised cosine width parameter, thereby ensuring accuracy of a calculated adaptive window function.
[0271] (2) Calculate a second raised cosine height bias based on the inter-channel time difference estimation deviation of the current frame.
[0272] This step may be represented using the following formula:
win_bias2=a_bias2*dist_reg+b_bias2, where
a_bias2=(xh_bias2−xl_bias2)/(yh_dist4−yl_dist4), and
b_bias2=xh_bias2−a_bias2*yh_dist4,
where win_bias2 is the second raised cosine height bias, xh_bias2 is an upper limit value of the second raised cosine height bias, xl_bias2 is a lower limit value of the second raised cosine height bias, yh_dist4 is an inter-channel time difference estimation deviation corresponding to the upper limit value of the second raised cosine height bias, yl_dist4 is an inter-channel time difference estimation deviation corresponding to the lower limit value of the second raised cosine height bias, dist_reg is the inter-channel time difference estimation deviation, and yh_dist4, yl)dist4, xh_bias2, and xl_bias2 are all positive numbers.
[0273] Optionally, in this step, b_bias2=xh_bias2−a_bias2*yh_dist4 may be replaced with b_bias2=xl_bias2−a_bias2*yl_dist4.
[0274] Optionally, in this embodiment, win_bias2=min(win_bias2, xh_bias2), and win_bias2 =max(win_bias2, xl_bias2). In an embodiment, when win_bias2 obtained through calculation is greater than xh_bias2, win_bias2 is set to xh_bias2, or when win_bias2 obtained through calculation is less than xl_bias2, win_bias2 is set to xl_bias2.
[0275] Optionally, yh_dist4=yh_dist3, and yl_dist4=yl_dist3.
[0276] (3) The audio coding device determines the adaptive window function of the current frame based on the second raised cosine width parameter and the second raised cosine height bias.
[0277] The audio coding device brings the second raised cosine width parameter and the second raised cosine height bias into the adaptive window function in step 303 to obtain the following calculation formulas.
When 0≤k≤TRUNC(A*L_NCSHIFT_DS/2)−2*win_width1−1, loc_weight_win(k)=win_bias1;
when TRUNC(A*L_NCSHIFT_DS/2)−2*win_width1≤k≤TRUNC(A* L_NCSHIFT_DS/2)+2*win_width1−1,
loc_weight_win(k)=0.5*(1+win_bias1)+0.5*(1−win_bias1)*cos(π*(k−TRUNC(A* L_NCSHIFT_DS/2))/(2*win_width1)); and
when TRUNC(A*L_NCSHIFT_DS/2)+2*win_width1≤k≤A*L_NCSHIFT_DS, loc_weight_win(k)=win_bias1,
where loc_weight_win(k) is used to represent the adaptive window function, where k=0, 1, . . . , A *L_NCSHIFT_DS, A is the preset constant greater than or equal to 4, for example, A=4, L_NCSHIFT_DS is the maximum value of the absolute value of the inter-channel time difference, win_width2 is the second raised cosine width parameter, and win_bias2 is the second raised cosine height bias.
[0278] In this embodiment, the adaptive window function of the current frame is determined based on the inter-channel time difference estimation deviation of the current frame, and when the smoothed inter-channel time difference estimation deviation of the previous frame does not need to be buffered, the adaptive window function of the current frame can be determined, thereby saving a storage resource.
[0279] Optionally, after the inter-channel time difference of the current frame is determined based on the adaptive window function determined in the foregoing second manner, the buffered inter-channel time difference information of the at least one past frame may be further updated. For related descriptions, refer to the first manner of determining the adaptive window function. Details are not described again herein in this embodiment.
[0280] Optionally, if the delay track estimation value of the current frame is determined based on the second implementation of determining the delay track estimation value of the current frame, after the buffered inter-channel time difference smoothed value of the at least one past frame is updated, a buffered weighting coefficient of the at least one past frame may be further updated.
[0281] In the second manner of determining the adaptive window function, the weighting coefficient of the at least one past frame is a second weighting coefficient of the at least one past frame.
[0282] Updating the buffered weighting coefficient of the at least one past frame includes calculating a second weighting coefficient of the current frame based on the inter-channel time difference estimation deviation of the current frame, and updating a buffered second weighting coefficient of the at least one past frame based on the second weighting coefficient of the current frame.
[0283] Calculating the second weighting coefficient of the current frame based on the inter-channel time difference estimation deviation of the current frame is represented using the following formulas:
wgt_par2=a_wgt2*dist_reg+b_wgt2;
a_wgt2=(xl_wgt2−xh_wgt2)/(yh_dist2′−yl_dist2′); and
b_wgt2=xl_wgt2−a_wgt2*yh_dist2′,
where wgt_par2 is the second weighting coefficient of the current frame, dist_reg is the inter-channel time difference estimation deviation of the current frame, xh_wgt2 is an upper limit value of the second weighting coefficient, xl_wgt2 is a lower limit value of the second weighting coefficient, yh_dist2′ is an inter-channel time difference estimation deviation corresponding to the upper limit value of the second weighting coefficient, yl_dist2′ is an inter-channel time difference estimation deviation corresponding to the lower limit value of the second weighting coefficient, and yh_dist2′, yl_dist2′, xh_wgt2, and xl_wgt2 are all positive numbers.
[0284] Optionally, wgt_par2=min(wgt_par2, xh_wgt2), and wgt_par2=max(wgt_par2, xl_wgt2).
[0285] Optionally, in this embodiment, values of yh_dist2′, yl_dist2′, xh wgt2, and xl_wgt2 are not limited. For example, xl_wgt2=0.05, xh_wgt2=1.0, yl_dist2′=2.0, and yh_dist2′=1.0.
[0286] Optionally, in the foregoing formula, b_wgt2=xl_wgt2−a_wgt2*yh_dist2′ may be replaced with b_wgt2=xh_wgt2−a_wgt2*yl_dist2′.
[0287] In this embodiment, xh_wgt2>x2 wgt1, and yh_dist2′<yl_dist2′.
[0288] In this embodiment, when wgt_par2 is greater than the upper limit value of the second weighting coefficient, wgt_par2 is limited to be the upper limit value of the second weighting coefficient, or when wgt_par2 is less than the lower limit value of the second weighting coefficient, wgt_par2 is limited to the lower limit value of the second weighting coefficient in order to ensure that a value of wgt_par2 does not exceed a normal value range of the second weighting coefficient, thereby ensuring accuracy of the calculated delay track estimation value of the current frame.
[0289] In addition, after the inter-channel time difference of the current frame is determined, the second weighting coefficient of the current frame is calculated. When the delay track estimation value of the next frame is to be determined, the delay track estimation value of the next frame can be determined using the second weighting coefficient of the current frame, thereby ensuring accuracy of determining the delay track estimation value of the next frame.
[0290] Optionally, in the foregoing embodiments, the buffer is updated regardless of whether the multi-channel signal of the current frame is a valid signal. For example, the inter-channel time difference information of the at least one past frame and/or the weighting coefficient of the at least one past frame in the buffer are/is updated.
[0291] Optionally, the buffer is updated only when the multi-channel signal of the current frame is a valid signal. In this way, validity of data in the buffer is improved.
[0292] The valid signal is a signal whose energy is higher than preset energy, and/or belongs to preset type, for example, the valid signal is a speech signal, or the valid signal is a periodic signal.
[0293] In this embodiment, a voice activity detection (VAD) algorithm is used to detect whether the multi-channel signal of the current frame is an active frame. If the multi-channel signal of the current frame is an active frame, it indicates that the multi-channel signal of the current frame is the valid signal. If the multi-channel signal of the current frame is not an active frame, it indicates that the multi-channel signal of the current frame is not the valid signal.
[0294] In a manner, it is determined, based on a voice activation detection result of the previous frame of the current frame, whether to update the buffer.
[0295] When the voice activation detection result of the previous frame of the current frame is the active frame, it indicates that it is of great possibility that the current frame is the active frame. In this case, the buffer is updated. When the voice activation detection result of the previous frame of the current frame is not the active frame, it indicates that it is of great possibility that the current frame is not the active frame. In this case, the buffer is not updated.
[0296] Optionally, the voice activation detection result of the previous frame of the current frame is determined based on a voice activation detection result of a primary channel signal of the previous frame of the current frame and a voice activation detection result of a secondary channel signal of the previous frame of the current frame.
[0297] If both the voice activation detection result of the primary channel signal of the previous frame of the current frame and the voice activation detection result of the secondary channel signal of the previous frame of the current frame are active frames, the voice activation detection result of the previous frame of the current frame is the active frame. If the voice activation detection result of the primary channel signal of the previous frame of the current frame and/or the voice activation detection result of the secondary channel signal of the previous frame of the current frame are/is not active frames/an active frame, the voice activation detection result of the previous frame of the current frame is not the active frame.
[0298] In another manner, it is determined, based on a voice activation detection result of the current frame, whether to update the buffer.
[0299] When the voice activation detection result of the current frame is an active frame, it indicates that it is of great possibility that the current frame is the active frame. In this case, the audio coding device updates the buffer. When the voice activation detection result of the current frame is not an active frame, it indicates that it is of great possibility that the current frame is not the active frame. In this case, the audio coding device does not update the buffer.
[0300] Optionally, the voice activation detection result of the current frame is determined based on voice activation detection results of a plurality of channel signals of the current frame.
[0301] If the voice activation detection results of the plurality of channel signals of the current frame are all active frames, the voice activation detection result of the current frame is the active frame. If a voice activation detection result of at least one channel of channel signal of the plurality of channel signals of the current frame is not the active frame, the voice activation detection result of the current frame is not the active frame.
[0302] It should be noted that, in this embodiment, description is provided using an example in which the buffer is updated using only a criterion about whether the current frame is the active frame. In an embodiment, the buffer may alternatively be updated based on at least one of unvoicing or voicing, period or aperiodic, transient or non-transient, or speech or non-speech of the current frame.
[0303] For example, if both the primary channel signal and the secondary channel signal of the previous frame of the current frame are voiced, it indicates that there is a great probability that the current frame is voiced. In this case, the buffer is updated. If at least one of the primary channel signal or the secondary channel signal of the previous frame of the current frame is unvoiced, there is a great probability that the current frame is not voiced. In this case, the buffer is not updated.
[0304] Optionally, based on the foregoing embodiments, an adaptive parameter of a preset window function model may be further determined based on a coding parameter of the previous frame of the current frame. In this way, the adaptive parameter in the preset window function model of the current frame is adaptively adjusted, and accuracy of determining the adaptive window function is improved.
[0305] The coding parameter is used to indicate a type of a multi-channel signal of the previous frame of the current frame, or the coding parameter is used to indicate a type of a multi-channel signal of the previous frame of the current frame in which time-domain downmixing processing is performed, for example, an active frame or an inactive frame, unvoicing or voicing, periodic or aperiodic, transient or non-transient, or speech or music.
[0306] The adaptive parameter includes at least one of an upper limit value of a raised cosine width parameter, a lower limit value of the raised cosine width parameter, an upper limit value of a raised cosine height bias, a lower limit value of the raised cosine height bias, a smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter, a smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter, a smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine height bias, or a smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine height bias.
[0307] Optionally, when the audio coding device determines the adaptive window function in the first manner of determining the adaptive window function, the upper limit value of the raised cosine width parameter is the upper limit value of the first raised cosine width parameter, the lower limit value of the raised cosine width parameter is the lower limit value of the first raised cosine width parameter, the upper limit value of the raised cosine height bias is the upper limit value of the first raised cosine height bias, and the lower limit value of the raised cosine height bias is the lower limit value of the first raised cosine height bias. Correspondingly, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the first raised cosine width parameter, the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the first raised cosine width parameter, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine height bias is the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the first raised cosine height bias, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine height bias is the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the first raised cosine height bias.
[0308] Optionally, when the audio coding device determines the adaptive window function in the second manner of determining the adaptive window function, the upper limit value of the raised cosine width parameter is the upper limit value of the second raised cosine width parameter, the lower limit value of the raised cosine width parameter is the lower limit value of the second raised cosine width parameter, the upper limit value of the raised cosine height bias is the upper limit value of the second raised cosine height bias, and the lower limit value of the raised cosine height bias is the lower limit value of the second raised cosine height bias. Correspondingly, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the second raised cosine width parameter, the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the second raised cosine width parameter, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine height bias is the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the second raised cosine height bias, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine height bias is the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the second raised cosine height bias.
[0309] Optionally, in this embodiment, description is provided using an example in which the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is equal to the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine height bias, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is equal to the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine height bias.
[0310] Optionally, in this embodiment, description is provided using an example in which the coding parameter of the previous frame of the current frame is used to indicate unvoicing or voicing of the primary channel signal of the previous frame of the current frame and unvoicing or voicing of the secondary channel signal of the previous frame of the current frame.
[0311] (1) Determine the upper limit value of the raised cosine width parameter and the lower limit value of the raised cosine width parameter in the adaptive parameter based on the coding parameter of the previous frame of the current frame.
[0312] Unvoicing or voicing of the primary channel signal of the previous frame of the current frame and unvoicing or voicing of the secondary channel signal of the previous frame of the current frame are determined based on the coding parameter. If both the primary channel signal and the secondary channel signal are unvoiced, the upper limit value of the raised cosine width parameter is set to a first unvoicing parameter, and the lower limit value of the raised cosine width parameter is set to a second unvoicing parameter, that is, xh_width=xh_width_uv, and xl_width=xl_width_uv.
[0313] If both the primary channel signal and the secondary channel signal are voiced, the upper limit value of the raised cosine width parameter is set to a first voicing parameter, and the lower limit value of the raised cosine width parameter is set to a second voicing parameter, that is, xh_width=xh_width_v, and xl_width=xl_width_v.
[0314] If the primary channel signal is voiced, and the secondary channel signal is unvoiced, the upper limit value of the raised cosine width parameter is set to a third voicing parameter, and the lower limit value of the raised cosine width parameter is set to a fourth voicing parameter, that is, xh_width=xh_width_v2, and xl_width=xl_width_v2.
[0315] If the primary channel signal is unvoiced, and the secondary channel signal is voiced, the upper limit value of the raised cosine width parameter is set to a third unvoicing parameter, and the lower limit value of the raised cosine width parameter is set to a fourth unvoicing parameter, that is, xh_width=xh_width_uv2, and xl_width=xl_width_uv2.
[0316] The first unvoicing parameter xh_width_uv, the second unvoicing parameter xl_width_uv, the third unvoicing parameter xh_width_uv2, the fourth unvoicing parameter xl_width_uv2, the first voicing parameter xh_width_v, the second voicing parameter xl_width_v, the third voicing parameter xh_width_v2, and the fourth voicing parameter xl_width_v2 are all positive numbers, where xh_width_v<xh_width_v2<xh_width_uv2<xh_width_uv, and xl_width_uv<xl_width_uv2<xl_width_v2<xl_width_v.
[0317] Values of xh_width_v, xh_width_v2, xh_width_uv2, xh_width_uv, xl_width_uv, xl_width_uv2, xl_width_v2, and xl_width_v are not limited in this embodiment. For example, xh_width_v=0.2, xh_width_v2=0.25, xh_width_uv2=0.35, xh_width_uv=0.3, xl_width_uv=0.03, xl_width_uv2=0.02, xl_width_v2=0.04, and xl_width_v=0.05.
[0318] Optionally, at least one parameter of the first unvoicing parameter, the second unvoicing parameter, the third unvoicing parameter, the fourth unvoicing parameter, the first voicing parameter, the second voicing parameter, the third voicing parameter, and the fourth voicing parameter is adjusted using the coding parameter of the previous frame of the current frame.
[0319] For example, that the audio coding device adjusts at least one parameter of the first unvoicing parameter, the second unvoicing parameter, the third unvoicing parameter, the fourth unvoicing parameter, the first voicing parameter, the second voicing parameter, the third voicing parameter, and the fourth voicing parameter based on the coding parameter of a channel signal of the previous frame of the current frame is represented using the following formulas:
xh_width_uv=fach_uv* xh_width_init;
xl_width_uv=facl_uv*xl_width_init;
xh_width_v=fach_v*xh_width_init;
xl_width_v=facl_v*xl_width_init;
xh_width_v2=fach_v2*xh_width_init;
xl_width_v2=facl_v2*xl_width_init;
xh_width_uv2=fach_uv2*xh_width_init; and
xl_width_uv2=facl_uv2*xl_width_init,
where fach_uv, fach_v, fach_v2, fach_uv2, xh_width_init, and xl_width_init are positive numbers determined based on the coding parameter.
[0320] In this embodiment, values of fach_uv, fach_v, fach_v2, fach_uv2, xh_width_init, and xl_width_init are not limited. For example, fach_uv=1.4, fach_v=0.8, fach_v2=1.0, fach_uv2 =1.2, xh_width_init=0.25, and xl_width_init=0.04.
[0321] (2) Determine the upper limit value of the raised cosine height bias and the lower limit value of the raised cosine height bias in the adaptive parameter based on the coding parameter of the previous frame of the current frame.
[0322] Unvoicing or voicing of the primary channel signal of the previous frame of the current frame and unvoicing or voicing of the secondary channel signal of the previous frame of the current frame are determined based on the coding parameter. If both the primary channel signal and the secondary channel signal are the unvoiced, the upper limit value of the raised cosine height bias is set to a fifth unvoicing parameter, and the lower limit value of the raised cosine height bias is set to a sixth unvoicing parameter, that is, xh_bias=xh_bias_uv, and xl_bias=xl_bias_uv.
[0323] If both the primary channel signal and the secondary channel signal are voiced, the upper limit value of the raised cosine height bias is set to a fifth voicing parameter, and the lower limit value of the raised cosine height bias is set to a sixth voicing parameter, that is, xh_bias =xh_bias_v, and xl_bias=xl_bias_v.
[0324] If the primary channel signal is voiced, and the secondary channel signal is unvoiced, the upper limit value of the raised cosine height bias is set to a seventh voicing parameter, and the lower limit value of the raised cosine height bias is set to an eighth voicing parameter, that is, xh_bias=xh_bias_v2, and xl_bias=xl_bias_v2.
[0325] If the primary channel signal is unvoiced, and the secondary channel signal is voiced, the upper limit value of the raised cosine height bias is set to a seventh unvoicing parameter, and the lower limit value of the raised cosine height bias is set to an eighth unvoicing parameter, that is, xh_bias=xh_bias_uv2, and xl_bias=xl_bias_uv2.
[0326] The fifth unvoicing parameter xh_bias uv, the sixth unvoicing parameter xl_bias_uv, the seventh unvoicing parameter xh_bias uv2, the eighth unvoicing parameter xl_bias_uv2, the fifth voicing parameter xh_bias_v, the sixth voicing parameter xl_bias_v, the seventh voicing parameter xh_bias_v2, and the eighth voicing parameter xl_bias_v2 are all positive numbers, where xh_bias_v<xh_bias_v2<xh_bias_uv2<xh_bias_uv, xl_bias_v<xl_bias_v2<xl_bias_uv2 21 xl_bias_uv, xh_bias is the upper limit value of the raised cosine height bias, and xl_bias is the lower limit value of the raised cosine height bias.
[0327] In this embodiment, values of xh_bias_v, xh_bias_v2, xh_bias_uv2, xh_bias_uv, xl_bias_v, xl_bias_v2, xl_bias_uv2, and xl_bias_uv are not limited. For example, xh_bias_v=0.8, xl_bias_v=0.5, xh_bias_v2=0.7, xl_bias_v2=0.4, xh_bias_uv=0.6, xl_bias_uv=0.3, xh_bias_uv2=0.5, and xl_bias_uv2=0.2
[0328] Optionally, at least one of the fifth unvoicing parameter, the sixth unvoicing parameter, the seventh unvoicing parameter, the eighth unvoicing parameter, the fifth voicing parameter, the sixth voicing parameter, the seventh voicing parameter, or the eighth voicing parameter is adjusted based on the coding parameter of a channel signal of the previous frame of the current frame.
[0329] For example, the following formula is used for representation:
xh_bias_uv=fach_uv′*xh_bias_init;
xl_bias_uv=facl_uv′*xl_bias_init;
xh_bias_v=fach_v′*xh_bias_init;
xl_bias_v=facl_v′*xl_bias_init;
xh_bias_v2=fach_v2′*xh_bias_init;
xl_bias_v2=facl_v2′*xl_bias_init;
xh_bias_uv2=fach_uv2′*xh_bias_init; and
xl_bias_uv2=facl_uv2′*xl_bias_init,
where fach_uv′, fach_v′, fach_v2′, fach_uv2′, xh_bias_init, and xl_bias_init are positive numbers determined based on the coding parameter.
[0330] In this embodiment, values of fach_uv′, fach_v′, fach_v2′, fach_uv2′, xh_bias_init, and xl_bias_init are not limited. For example, fach_v′=1.15, fach_v2′=1.0, fach_uv2′=0.85, fach_uv′=0.7, xh_bias_init=0.7, and xl_bias_init=0.4.
[0331] (3) Determine, based on the coding parameter of the previous frame of the current frame, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter in the adaptive parameter.
[0332] The unvoiced and voiced primary channel signals of the previous frame of the current frame and the unvoiced and voiced secondary channel signals of the previous frame of the current frame are determined based on the coding parameter. If both the primary channel signal and the secondary channel signal are unvoiced, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is set to a ninth unvoicing parameter, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is set to a tenth unvoicing parameter, that is, yh_dist=yh_dist_uv, and yl_dist =yl_dist_uv.
[0333] If both the primary channel signal and the secondary channel signal are voiced, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is set to a ninth voicing parameter, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is set to a tenth voicing parameter, that is, yh_dist=yh_dist_v, and yl_dist =yl_dist_v.
[0334] If the primary channel signal is voiced, and the secondary channel signal is unvoiced, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is set to an eleventh voicing parameter, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is set to a twelfth voicing parameter, that is, yh_dist=yh_dist_v2, and yl_dist=yl_dist_v2.
[0335] If the primary channel signal is unvoiced, and the secondary channel signal is voiced, the smoothed inter-channel time difference estimation deviation corresponding to the upper limit value of the raised cosine width parameter is set to an eleventh unvoicing parameter, and the smoothed inter-channel time difference estimation deviation corresponding to the lower limit value of the raised cosine width parameter is set to a twelfth unvoicing parameter, that is, yh_dist=yh_dist_uv2, and yl_dist=yl_dist_uv2.
[0336] The ninth unvoicing parameter yh_dist_uv, the tenth unvoicing parameter yl_dist_uv, the eleventh unvoicing parameter yh_dist_uv2, the twelfth unvoicing parameter yl_dist_uv2, the ninth voicing parameter yh_dist_v, the tenth voicing parameter yl_dist_v, the eleventh voicing parameter yh_dist_v2, and the twelfth voicing parameter yl_dist_v2 are all positive numbers, where yh_dist_v<yh_dist_v2<yh_dist_uv2<yh_dist_uv, and yl_dist_uv<yl_dist_uv2 <yl_dist_v2<yl_dist_v.
[0337] In this embodiment, values of yh_dist_v, yh_dist_v2, yh_dist_uv2, yh_dist_uv, yl_dist_uv, yl_dist_uv2, yl_dist_v2, and yl_dist_v are not limited.
[0338] Optionally, at least one parameter of the ninth unvoicing parameter, the tenth unvoicing parameter, the eleventh unvoicing parameter, the twelfth unvoicing parameter, the ninth voicing parameter, the tenth voicing parameter, the eleventh voicing parameter, and the twelfth voicing parameter is adjusted using the coding parameter of the previous frame of the current frame.
[0339] For example, the following formula/formulas is/are used for representation:
yh_dist_uv=fach_uv″*yh_dist_init;
yl_dist_uv=facl_uv″*yl_dist_init;
yh_dist_v=fach_v″*yh_dist_init;
yl_dist_v=facl_v″*yl_dist_init;
yh_dist_v2=fach_v2″*yh_dist_init;
yl_dist_v2=facl_v2″*yl_dist_init;
yh_dist_uv2=fach_uv2″*yh_dist_init; and
yl_dist_uv2=facl_uv2″*yl_dist_init,
where fach_uv″, fach_v″, fach_v2″, fach_uv2″, yh_dist_init, and yl_dist_init are positive numbers determined based on the coding parameter, and values of the parameters are not limited in this embodiment.
[0340] In this embodiment, the adaptive parameter in the preset window function model is adjusted based on the coding parameter of the previous frame of the current frame such that an appropriate adaptive window function is determined adaptively based on the coding parameter of the previous frame of the current frame, thereby improving accuracy of generating an adaptive window function, and improving accuracy of estimating an inter-channel time difference.
[0341] Optionally, based on the foregoing embodiments, before step 301, time-domain preprocessing is performed on the multi-channel signal.
[0342] Optionally, the multi-channel signal of the current frame in this embodiment of this application is a multi-channel signal input to the audio coding device, or a multi-channel signal obtained through preprocessing after the multi-channel signal is input to the audio coding device.
[0343] Optionally, the multi-channel signal input to the audio coding device may be collected by a collection component in the audio coding device, or may be collected by a collection device independent of the audio coding device, and is sent to the audio coding device.
[0344] Optionally, the multi-channel signal input to the audio coding device is a multi-channel signal obtained after through analog-to-digital (A/D) conversion. Optionally, the multi-channel signal is a pulse code modulation (PCM) signal.
[0345] A sampling frequency of the multi-channel signal may be 8 kilohertz (kHz), 16 kHz, 32 kHz, 44.1 kHz, 48 kHz, or the like. This is not limited in this embodiment.
[0346] For example, the sampling frequency of the multi-channel signal is 16 kHz. In this case, duration of a frame of multi-channel signals is 20 milliseconds (ms), and a frame length is denoted as N, where N=320, in other words, the frame length is 320 sampling points. The multi-channel signal of the current frame includes a left channel signal and a right channel signal, the left channel signal is denoted as x.sub.L(n), and the right channel signal is denoted as x.sub.R(n), where n is a sampling point sequence number, and n=0, 1, 2, . . . , and (N−1).
[0347] Optionally, if high-pass filtering processing is performed on the current frame, a processed left channel signal is denoted as x.sub.L_HP(n), and a processed right channel signal is denoted as x.sub.R_HP(n), where n is a sampling point sequence number, and n=0, 1, 2, . . . , and (N−1).
[0348]
[0349] The audio coding device includes a processor 701, a memory 702, and a bus 703.
[0350] The processor 701 includes one or more processing cores, and the processor 701 runs a software program and a module, to perform various function applications and process information.
[0351] The memory 702 is connected to the processor 701 using the bus 703. The memory 702 stores an instruction necessary for the audio coding device.
[0352] The processor 701 is configured to execute the instruction in the memory 702 to implement the delay estimation method provided in the method embodiments of this application.
[0353] In addition, the memory 702 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optic disc.
[0354] The memory 702 is further configured to buffer inter-channel time difference information of at least one past frame and/or a weighting coefficient of the at least one past frame.
[0355] Optionally, the audio coding device includes a collection component, and the collection component is configured to collect a multi-channel signal.
[0356] Optionally, the collection component includes at least one microphone. Each microphone is configured to collect one channel of channel signal.
[0357] Optionally, the audio coding device includes a receiving component, and the receiving component is configured to receive a multi-channel signal sent by another device.
[0358] Optionally, the audio coding device further has a decoding function.
[0359] It may be understood that
[0360] Optionally, this application provides a computer readable storage medium. The computer readable storage medium stores an instruction. When the instruction is run on the audio coding device, the audio coding device is enabled to perform the delay estimation method provided in the foregoing embodiments.
[0361]
[0362] The cross-correlation coefficient determining unit 810 is configured to determine a cross-correlation coefficient of a multi-channel signal of a current frame.
[0363] The delay track estimation unit 820 is configured to determine a delay track estimation value of the current frame based on buffered inter-channel time difference information of at least one past frame.
[0364] The adaptive function determining unit 830 is configured to determine an adaptive window function of the current frame.
[0365] The weighting unit 840 is configured to perform weighting on the cross-correlation coefficient based on the delay track estimation value of the current frame and the adaptive window function of the current frame, to obtain a weighted cross-correlation coefficient.
[0366] The inter-channel time difference determining unit 850 is configured to determine an inter-channel time difference of the current frame based on the weighted cross-correlation coefficient.
[0367] Optionally, the adaptive function determining unit 830 is further configured to calculate a first raised cosine width parameter based on a smoothed inter-channel time difference estimation deviation of a previous frame of the current frame, calculate a first raised cosine height bias based on the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame, and determine the adaptive window function of the current frame based on the first raised cosine width parameter and the first raised cosine height bias.
[0368] Optionally, the apparatus further includes a smoothed inter-channel time difference estimation deviation determining unit 860.
[0369] The smoothed inter-channel time difference estimation deviation determining unit 860 is configured to calculate a smoothed inter-channel time difference estimation deviation of the current frame based on the smoothed inter-channel time difference estimation deviation of the previous frame of the current frame, the delay track estimation value of the current frame, and the inter-channel time difference of the current frame.
[0370] Optionally, the adaptive function determining unit 830 is further configured to determine an initial value of the inter-channel time difference of the current frame based on the cross-correlation coefficient, calculate an inter-channel time difference estimation deviation of the current frame based on the delay track estimation value of the current frame and the initial value of the inter-channel time difference of the current frame, and determine the adaptive window function of the current frame based on the inter-channel time difference estimation deviation of the current frame.
[0371] Optionally, the adaptive function determining unit 830 is further configured to calculate a second raised cosine width parameter based on the inter-channel time difference estimation deviation of the current frame, calculate a second raised cosine height bias based on the inter-channel time difference estimation deviation of the current frame, and determine the adaptive window function of the current frame based on the second raised cosine width parameter and the second raised cosine height bias.
[0372] Optionally, the apparatus further includes an adaptive parameter determining unit 870.
[0373] The adaptive parameter determining unit 870 is configured to determine an adaptive parameter of the adaptive window function of the current frame based on a coding parameter of the previous frame of the current frame.
[0374] Optionally, the delay track estimation unit 820 is further configured to perform delay track estimation based on the buffered inter-channel time difference information of the at least one past frame using a linear regression method, to determine the delay track estimation value of the current frame.
[0375] Optionally, the delay track estimation unit 820 is further configured to perform delay track estimation based on the buffered inter-channel time difference information of the at least one past frame using a weighted linear regression method, to determine the delay track estimation value of the current frame.
[0376] Optionally, the apparatus further includes an update unit 880.
[0377] The update unit 880 is configured to update the buffered inter-channel time difference information of the at least one past frame.
[0378] Optionally, the buffered inter-channel time difference information of the at least one past frame is an inter-channel time difference smoothed value of the at least one past frame, and the update unit 880 is configured to: determine an inter-channel time difference smoothed value of the current frame based on the delay track estimation value of the current frame and the inter-channel time difference of the current frame; and update a buffered inter-channel time difference smoothed value of the at least one past frame based on the inter-channel time difference smoothed value of the current frame.
[0379] Optionally, the update unit 880 is further configured to determine, based on a voice activation detection result of the previous frame of the current frame or a voice activation detection result of the current frame, whether to update the buffered inter-channel time difference information of the at least one past frame.
[0380] Optionally, the update unit 880 is further configured to update a buffered weighting coefficient of the at least one past frame, where the weighting coefficient of the at least one past frame is a coefficient in the weighted linear regression method.
[0381] Optionally, when the adaptive window function of the current frame is determined based on a smoothed inter-channel time difference of the previous frame of the current frame, the update unit 880 is further configured to: calculate a first weighting coefficient of the current frame based on the smoothed inter-channel time difference estimation deviation of the current frame; and update a buffered first weighting coefficient of the at least one past frame based on the first weighting coefficient of the current frame.
[0382] Optionally, when the adaptive window function of the current frame is determined based on the smoothed inter-channel time difference estimation deviation of the current frame, the update unit 880 is further configured to: calculate a second weighting coefficient of the current frame based on the inter-channel time difference estimation deviation of the current frame; and update a buffered second weighting coefficient of the at least one past frame based on the second weighting coefficient of the current frame.
[0383] Optionally, the update unit 880 is further configured to, when the voice activation detection result of the previous frame of the current frame is an active frame or the voice activation detection result of the current frame is an active frame, update the buffered weighting coefficient of the at least one past frame.
[0384] For related details, refer to the foregoing method embodiments.
[0385] Optionally, the foregoing units may be implemented by a processor in the audio coding device by executing an instruction in a memory.
[0386] It may be clearly understood by a person of ordinary skill in the art that, for ease and brief description, for a detailed working process of the foregoing apparatus and units, refer to a corresponding process in the foregoing method embodiments, and details are not described herein again.
[0387] In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the described apparatus embodiments are merely examples. For example, the unit division may merely be logical function division and may be other division in an embodiment. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed.
[0388] The foregoing descriptions are merely optional implementations of this application, but are not intended to limit the protection scope of this application. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in this application shall fall within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.