Inter-channel phase difference parameter encoding method and apparatus

11568882 · 2023-01-31

Assignee

Inventors

Cpc classification

International classification

Abstract

This application discloses an IPD parameter encoding method, including: obtaining a reference parameter used to determine an IPD parameter encoding scheme of a current frame of a multi-channel signal; determining the IPD parameter encoding scheme of the current frame based on the reference parameter, where the determined IPD parameter encoding scheme of the current frame is one of at least two preset IPD parameter encoding schemes; and processing an IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame. The technical solutions provided in this application can improve encoding quality of the multi-channel signal.

Claims

1. An inter-channel phase difference parameter encoding method, comprising: obtaining a signal characteristic parameter of a current frame and an inter-channel phase difference (IPD) parameter encoding scheme of each of A frames prior to the current frame, wherein A is an integer not less than 1; determining an IPD parameter encoding scheme of the current frame based on both the signal characteristic parameter of the current frame and the IPD parameter encoding scheme of each of the A frames, wherein the determined IPD parameter encoding scheme of the current frame is one of at least two preset IPD parameter encoding schemes, which include a first encoding scheme and a second encoding scheme; and processing an IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame.

2. The method according to claim 1, wherein if the IPD parameter encoding scheme of each of the A frames is the first encoding scheme in the at least two preset IPD parameter encoding schemes, and the signal characteristic parameter of the current frame is greater than a preset threshold, the IPD parameter encoding scheme of the current frame is the first encoding scheme.

3. The method according to claim 1, wherein the first encoding scheme comprises at least one of the following manners: a group IPD parameter encoding scheme; skipping encoding an IPD parameter; or setting a value of an IPD parameter to 0.

4. The method according to claim 1, wherein if the IPD parameter encoding scheme of the current frame is not the first encoding scheme, the IPD parameter encoding scheme of the current frame is a second encoding scheme, and wherein the second encoding scheme comprises an IPD parameter encoding scheme of a subband set, or a subband IPD parameter encoding scheme, and the subband IPD parameter encoding scheme includes encoding subband IPD parameters of some or all of subbands of the current frame.

5. The method according to claim 4, wherein the processing the IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame comprises: calculating IPD parameters of all or some of subbands of a left channel frequency domain signal and a right channel frequency domain signal of the current frame; and encoding the IPD parameters that are of all or some of the subbands and that are obtained through calculation.

6. The method according to claim 1, wherein before processing the IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame, the method further comprises: determining whether the determined IPD parameter encoding scheme of the current frame needs to be adjusted; and adjusting the determined IPD parameter encoding scheme of the current frame when it is determined that the determined IPD parameter encoding scheme of the current frame needs to be adjusted, wherein the IPD parameter of the current frame is processed based on the adjusted IPD parameter encoding scheme of the current frame.

7. The method according to claim 6, wherein the determining whether the determined IPD parameter encoding scheme of the current frame needs to be adjusted is performed based on IPD parameter encoding schemes of the A frames prior to the current frame.

8. The method according to claim 1, wherein the IPD parameter is obtained by using the following calculation formula: corr = .Math. b = 0 N [ E l ( b ) + E r ( b ) + 2 × D r ( b ) ] [ E l ( b ) + E r ( b ) + 2 D r 2 ( b ) + D i 2 ( b ) ] , wherein E l ( b ) = .Math. k = 0 L .Math. L ( k ) .Math. 2 ; E r ( b ) = .Math. k = 0 L .Math. R ( k ) .Math. 2 ; D r ( b ) = .Math. k = 0 L [ L r ( k ) × R r ( k ) + L i ( k ) × R i ( k ) ] ; D i ( b ) = .Math. k = 0 L [ L i ( k ) × R r ( k ) - L r ( k ) × R i ( k ) ] ; L ( k ) = .Math. n = 0 Length - 1 x L ( n ) × e - j 2 π × n × k L , 0 k < L , and R ( k ) = .Math. n = 0 Length - 1 x R ( n ) × e - j 2 π × n × k L , 0 k < L , E.sub.l(b) indicates an energy sum of an audio-left channel, E.sub.r(b) indicates an energy sum of an audio-right channel, L.sub.r(k) indicates a real part of a k.sup.th frequency value of an audio-left channel frequency domain signal, R.sub.r(k) indicates a real part of a k.sup.th frequency value of an audio-right channel frequency domain signal, L.sub.i(k) indicates an imaginary part of the k.sup.th frequency value of the audio-left channel frequency domain signal, R.sub.i(k) indicates an imaginary part of the k.sup.th frequency value of the audio-right channel frequency domain signal, L indicates a quantity of subband spectral coefficients, and N indicates a quantity of subbands, n indicates an index value of a time domain signal, k indicates an index value of a frequency domain signal, Length indicates a frame length, χ.sub.L(n) indicates an audio-left channel time domain signal, χ.sub.R(n) indicates an audio-right channel time domain signal, L(k) indicates a k.sup.th frequency value that is of the audio-left channel frequency domain signal and that is used to calculate the IPD parameter, and R(k) indicates a k.sup.th frequency value that is of the audio-right channel frequency domain signal and that is used to calculate the IPD parameter, where χ.sub.L(n) and χ.sub.R(n) indicate sequences of real numbers.

9. An inter-channel phase difference parameter encoding apparatus, comprising: a memory for storing computer-executable instructions; and a processor operatively coupled to the memory, the processor being configured to execute the computer-executable instructions to: obtain a signal characteristic parameter of a current frame and an inter-channel phase difference (IPD) parameter encoding scheme of each of A frames prior to the current frame, wherein A is an integer not less than 1; determine an IPD parameter encoding scheme of the current frame based on both the signal characteristic parameter of the current frame and the IPD parameter encoding scheme of each of the A frames, wherein the determined IPD parameter encoding scheme of the current frame is one of at least two preset IPD parameter encoding schemes, which include a first encoding scheme and a second encoding scheme; and process an IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame.

10. The apparatus according to claim 9, wherein if the IPD parameter encoding scheme of each of the A frames is the first encoding scheme in the at least two preset IPD parameter encoding schemes, and the signal characteristic parameter of the current frame is greater than a preset threshold, the IPD parameter encoding scheme of the current frame is the first encoding scheme.

11. The apparatus according to claim 9, wherein the first encoding scheme comprises at least one of the following manners: a group IPD parameter encoding scheme; skipping encoding an IPD parameter; or setting a value of an IPD parameter to 0.

12. The apparatus according to claim 9, wherein if the IPD parameter encoding scheme of the current frame is not the first encoding scheme, the IPD parameter encoding scheme of the current frame is a second encoding scheme, and wherein the second encoding scheme comprises an IPD parameter encoding scheme of a subband set, or a subband IPD parameter encoding scheme, and the subband IPD parameter encoding scheme includes encoding subband IPD parameters of some or all of subbands of the current frame.

13. The apparatus according to claim 12, wherein in processing the IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame, the processor is further configured to execute the computer-executable instructions to: calculate IPD parameters of all or some of subbands of a left channel frequency domain signal and a right channel frequency domain signal of the current frame; and encode the IPD parameters that are of all or some of the subbands and that are obtained through calculation.

14. The apparatus according to claim 9, wherein the processor is further configured to execute the computer-executable instructions to: determine whether the IPD parameter encoding scheme of the current frame needs to be adjusted; adjust the determined IPD parameter encoding scheme of the current frame when determining that the determined IPD parameter encoding scheme of the current frame needs to be adjusted; and process the IPD parameter of the current frame based on the adjusted IPD parameter encoding scheme of the current frame.

15. The apparatus according to claim 14, wherein the determining whether the determined IPD parameter encoding scheme of the current frame needs to be adjusted is performed based on IPD parameter encoding schemes of the A frames prior to the current frame.

16. The apparatus according to claim 9, wherein the processor is further configured to execute the computer-executable instructions to: obtain the IPD parameter using the following calculation formula: corr = .Math. b = 0 N [ E l ( b ) + E r ( b ) + 2 × D r ( b ) ] [ E l ( b ) + E r ( b ) + 2 D r 2 ( b ) + D i 2 ( b ) ] , wherein E l ( b ) = .Math. k = 0 L .Math. L ( k ) .Math. 2 ; E r ( b ) = .Math. k = 0 L .Math. R ( k ) .Math. 2 ; D r ( b ) = .Math. k = 0 L [ L r ( k ) × R r ( k ) + L i ( k ) × R i ( k ) ] ; D i ( b ) = .Math. k = 0 L [ L i ( k ) × R r ( k ) - L r ( k ) × R i ( k ) ] ; L ( k ) = .Math. n = 0 Length - 1 x L ( n ) × e - j 2 π × n × k L , 0 k < L ; and R ( k ) = .Math. n = 0 Length - 1 x R ( n ) × e - j 2 π × n × k L , 0 k < L , wherein E.sub.l(b) indicates an energy sum of an audio-left channel, E.sub.r(b) indicates an energy sum of an audio-right channel, L.sub.r(k) indicates a real part of a k.sup.th frequency value of an audio-left channel frequency domain signal, R.sub.r(k) indicates a real part of a k.sup.th frequency value of an audio-right channel frequency domain signal, L.sub.i(k) indicates an imaginary part of the k.sup.th frequency value of the audio-left channel frequency domain signal, R.sub.i(k) indicates an imaginary part of the k.sup.th frequency value of the audio-right channel frequency domain signal, L indicates a quantity of subband spectral coefficients, and N indicates a quantity of subbands, n indicates an index value of a time domain signal, k indicates an index value of a frequency domain signal, Length indicates a frame length, χ.sub.L(n) indicates an audio-left channel time domain signal, χ.sub.R(n) indicates an audio-right channel time domain signal, L(k) indicates a k.sup.th frequency value that is of the audio-left channel frequency domain signal and that is used to calculate the IPD parameter, and R(k) indicates a k.sup.th frequency value that is of the audio-right channel frequency domain signal and that is used to calculate the IPD parameter, where χ.sub.L(n) and χ.sub.R(n) indicate sequences of real numbers.

17. A non-transitory computer readable storage medium, tangibly embodying computer program code, which, when executed by a computer processor, causes the computer processor to perform a method comprising: obtaining a signal characteristic parameter of a current frame and an inter-channel phase difference (IPD) parameter encoding scheme of each of A frames prior to the current frame, wherein A is an integer not less than 1; determining an IPD parameter encoding scheme of the current frame based on both the signal characteristic parameter of the current frame and the IPD parameter encoding scheme of each of the A frames, wherein the determined IPD parameter encoding scheme of the current frame is one of at least two preset IPD parameter encoding schemes, which include a first encoding scheme and a second encoding scheme; and processing an IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame.

18. The non-transitory computer readable storage medium of claim 17, wherein if the IPD parameter encoding scheme of each of the A frames is the first encoding scheme in the at least two preset IPD parameter encoding schemes, and the signal characteristic parameter of the current frame is greater than a preset threshold, the IPD parameter encoding scheme of the current frame is the first encoding scheme.

19. The non-transitory computer readable storage medium of claim 17, wherein the first encoding scheme comprises at least one of the following manners: a group IPD parameter encoding scheme; skipping encoding an IPD parameter; or setting a value of an IPD parameter to 0.

20. The non-transitory computer readable storage medium of claim 17, wherein if the IPD parameter encoding scheme of the current frame is not the first encoding scheme, the IPD parameter encoding scheme of the current frame is the second encoding scheme, and wherein the second encoding scheme comprises an IPD parameter encoding scheme of a subband set, or a subband IPD parameter encoding scheme, and the subband IPD parameter encoding scheme includes encoding subband IPD parameters of some or all of subbands of the current frame.

Description

BRIEF DESCRIPTION OF DRAWINGS

(1) To describe the technical solutions in the embodiments of the present disclosure more clearly, the following briefly describes the accompanying drawings required for describing the embodiments. Apparently, the accompanying drawings in the following description show merely some embodiments of the present disclosure, and a person of ordinary skill in the art may derive other drawings from these accompanying drawings without creative efforts.

(2) FIG. 1 is a schematic principle diagram of PS encoding;

(3) FIG. 2 is a schematic principle diagram of PS decoding;

(4) FIG. 3 is a schematic diagram of an application scenario of a solution of the present disclosure according to an embodiment of the present disclosure;

(5) FIG. 4 is a schematic diagram of another application scenario of a solution of the present disclosure according to an embodiment of the present disclosure;

(6) FIG. 5 is a schematic flowchart of an IPD parameter encoding method according to an embodiment of the present disclosure;

(7) FIG. 6 is another schematic flowchart of an IPD parameter encoding method according to an embodiment of the present disclosure;

(8) FIG. 7 is another schematic flowchart of an IPD parameter encoding method according to an embodiment of the present disclosure;

(9) FIG. 8 is a schematic structural diagram of an IPD parameter encoding apparatus according to an embodiment of the present disclosure; and

(10) FIG. 9 is a schematic structural diagram of an IPD parameter encoding apparatus according to another embodiment of the present disclosure.

DESCRIPTION OF EMBODIMENTS

(11) The following clearly describes technical solutions in the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are merely some but not all of the embodiments of the present disclosure. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.

(12) FIG. 1 is a schematic principle diagram of PS encoding.

(13) In PS encoding, an encoder downmixes a stereo signal input from a multi-channel (for example, an x1 channel and an x2 channel) into a mono audio signal, extracts spatial perception parameters of the stereo signal through spatial perception parameter analysis, obtains a mono audio bitstream through mono audio signal encoding, and obtains a spatial perception parameter bitstream through spatial perception parameter encoding. Further, the encoder performs bitstream multiplexing on the mono audio bitstream and the spatial perception parameter bitstream to obtain a bitstream for stereo signal encoding.

(14) FIG. 2 is a schematic principle diagram of PS decoding.

(15) A decoder performs bitstream demultiplexing on a bitstream for stereo signal encoding to obtain a mono audio bitstream and a spatial perception parameter bitstream, performs mono audio signal decoding on the mono audio bitstream, and performs spatial perception parameter decoding on the spatial perception parameter bitstream. Further, after decoding a mono audio signal, the decoder synthesizes a reconstructed stereo signal by using the spatial perception parameters.

(16) In one embodiment, the spatial perception parameters in the foregoing PS encoding and PS decoding include parameters such as IC, an ILD, an ITD, and an IPD. The IC describes an inter-channel correlation or correlation. This parameter determines perception of a sound field range, and can improve a sense of space and sound stability of an audio signal. An ILD parameter is used to distinguish between horizontal direction angles of stereo sources and describes an inter-channel intensity difference. This parameter affects frequency components of an entire spectrum. An ITD parameter and an IPD parameter are spatial perception parameters that indicate horizontal orientation of an acoustic source. The ILD parameter, the ITD parameter, and the IPD parameter determine human ears' perception of a location of a sound source, and can effectively determine a sound field location and is important for stereo signal restoration. Therefore, determining of parameters such as the IPD parameter is important for stereo signal restoration.

(17) An application scenario of a solution of the present disclosure is shown in FIG. 3. After encoding (including encoding an IPD parameter) a collected multi-channel signal, a terminal 301 sends a code stream obtained through encoding to a radio access network (RAN) 302, for example, may directly send the code stream to a based station 3021 in the RAN 302. After passing through the based station 3021, the code stream is transmitted to a packet data network gateway (PGW) 3022. After passing through the PGW 3022, the code stream is transmitted to a core network 303, and specifically, the code stream may pass through a session border controller (SBC) 3031 in the core network 303. The code stream passing through the core network 303 enters a RAN 304. The RAN 304 includes a PGW 3042 and a base station 3041. After the code stream passes through the PGW 3042 and arrives at the base station 3041, the base station 3041 sends the code stream to a terminal 305, and the terminal 305 decodes the code stream and plays a multi-channel signal obtained through decoding.

(18) It should be noted that, in the foregoing description, the RAN merely includes an example of two network elements (e.g., the base station and the PGW). During actual implementation, the RAN further includes a plurality of other network elements. For ease of description, another network element is omitted in the embodiments of the present disclosure. Similarly, the core network also merely includes an example of the SBC. For ease of description, another network element is omitted in the embodiments of the present disclosure. It may be understood that network elements in the foregoing network are merely examples, and names of the network elements may be different in different networks. For example, the PGW is referred to as an evolved packet data gateway (ePDG) in an LTE network. Similarly, a connection manner between the foregoing network elements may also change with evolution of a network. Therefore, in the embodiments of the present disclosure, an application scenario of the present disclosure is not limited to the foregoing examples.

(19) The terminal 301 and the terminal 305 are terminals that have a cellular network access capability, and may be a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a mobile phone, a tablet computer (Pad), a notebook computer (NB), a personal computer (PC), or the like.

(20) Another application scenario of a solution of the present disclosure is shown in FIG. 4. After encoding (including encoding an IPD parameter) a collected multi-channel signal, a terminal 401 sends the code stream obtained through encoding to a terminal 403 over an Internet 402. The terminal 403 decodes the code stream and plays a multi-channel signal obtained through decoding.

(21) The terminal 401 and the terminal 403 are terminals having an Internet access capability, and may be wearable devices, VR devices, AR devices, mobile phones, Pads, NBs, PCs, or the like.

(22) FIG. 5 is a schematic flowchart of an IPD parameter encoding method according to an embodiment of the present disclosure. The method includes the following operations.

(23) Operation S501. Obtain a reference parameter used to determine an IPD parameter encoding scheme of a current frame of a multi-channel signal.

(24) During specific implementation, according to one embodiment, the IPD parameter encoding method provided in this embodiment of the present disclosure may be performed by an encoder that can encode the multi-channel signal. After encoding an IPD parameter of the current frame by using the IPD parameter encoding method provided in this embodiment of the present disclosure, the encoder transmits the encoded IPD parameter. A decoder uses, for stereo synthesis processing, the IPD parameter obtained through decoding. The following describes in detail the IPD parameter encoding method provided in this embodiment of the present disclosure. It should be noted that the encoder and the decoder in this embodiment of the present disclosure are merely described in terms of a function, and actual forms of the encoder and the decoder may be the foregoing terminals. It may be understood that, in a call process, the terminal may have a function of both an encoder and a decoder. For ease of description, the current frame is directly used when the current frame of the multi-channel signal is subsequently described. The multi-channel signal in this embodiment of the present disclosure may be a dual-channel signal, a three-channel signal, a four-channel signal, or the like. A specific quantity of channels corresponding to the multi-channel signal is not limited in this embodiment of the present disclosure.

(25) In one embodiment, when encoding the IPD parameter of the current frame, the encoder may first obtain the reference parameter used to determine the IPD parameter encoding scheme of the current frame, and then determine the IPD parameter encoding scheme of the current frame based on the reference parameter. In other words, the reference parameter is used to determine the IPD parameter encoding scheme of the current frame. It may be understood that the reference parameter may alternatively be used to determine an encoding scheme for another parameter of the current frame. In this embodiment of the present disclosure, the reference parameter is not limited to being used to determine the IPD parameter encoding scheme. During specific implementation, the reference parameter may include at least one of a signal characteristic parameter of the current frame and signal characteristic parameters of A frames previous to the current frame. To be specific, the reference parameter may include the signal characteristic parameter of the current frame, the signal characteristic parameters of the A frames previous to the current frame, the signal characteristic parameter of the current frame and the signal characteristic parameters of the A frames previous to the current frame, or the like, and may specifically be determined based on an actual application scenario. This is not limited herein. Herein, A is an integer not less than 1. To be specific, the A frames previous to the current frame may be one frame, two frames, three frames, or the like previous to the current frame. This is not limited herein. The frame previous to the current frame and the current frame are consecutive in a time sequence. The two frames previous to the current frame are consecutive in a time sequence and include the frame previous to the current frame. The three frames previous to the current frame are consecutive in a time sequence and include the two frames previous to the current frame.

(26) During specific implementation, according to one embodiment, the signal characteristic parameter of the current frame may include one or more of parameters such as a parameter indicating correlation between left channel and right channel of the current frame, a variance of subband IPD parameters of the current frame, a signal type of the current frame, and an ITD parameter of the current frame. The parameter indicating the correlation between the left channel and right channel of the current frame, and the variance of the subband IPD parameterss of the current frame may be obtained through calculation based on left channel frequency domain signal and right channel frequency domain signal of the multi-channel signals. The ITD parameter of the current frame may be determined based on a manner of extracting an ITD parameter of the multi-channel signal of the current frame. The manner of extracting the ITD parameter of the current frame may include an extraction manner provided in a standard protocol or an extraction manner known to a person skilled in the art. This is not limited herein.

(27) The signal characteristic parameters of the A frames prior to the current frame (referred to herein as “previous A frames”) include one or more of parameters such as a parameter indicating correlation between left channel and right channel of each of the A frames previous to the current frame, a variance of subband IPD parameters of each of the A frames previous to the current frame, an ITD parameter of each of the A frames previous to the current frame, an IPD parameter encoding scheme of each of the A frames previous to the current frame, and a signal type of each of the A frames previous to the current frame. Selection of a specific parameter or specific parameters may be determined based on an actual application scenario. This is not limited herein. The IPD parameter encoding scheme of each of the A frames previous to the current frame may be stored in a cache or a memory. The signal type may include a voice type or a music type. The signal characteristic parameters of the A frames previous to the current frame may be stored in a cache. It may be understood that, after the signal characteristic parameter of the current frame is obtained, the signal characteristic parameter of the current frame is also stored in the cache to determine an IPD parameter encoding scheme of a following frame.

(28) In one embodiment, the encoder may perform time-frequency transformation on left channel and right channel time domain signals of the multi-channel signal of the current frame to obtain the left channel frequency domain signal and right channel frequency domain signal of the current frame. Specifically, the foregoing time-frequency transformation may be implemented by using an implementation such as fast fourier transformation (Fast Fourier Transformation, FFT) or modified discrete cosine transform (Modified Discrete Cosine Transform, MDCT). This is not limited herein. The time-frequency transformation performed on the left channel and right channel time domain signals of the multi-channel signal of the current frame may be performed in a form of a frame or in a form of a subframe. One frame may usually include four subframes, two subframes, or eight subframes. A specific quantity of subframes may be determined based on a specific situation.

(29) For example, in one embodiment, when the encoder transforms the left channel and right channel time domain signals of the multi-channel signal of the current frame into the left channel frequency domain signal and right channel frequency domain signal through the FFT, the following transformation formulas may specifically be used:

(30) R ( k ) = .Math. n = 0 Length - 1 x R ( n ) × e - j 2 π × n × k L , 0 k < M and L ( k ) = .Math. n = 0 Length - 1 x L ( n ) × e - j 2 π × n × k L , 0 k < M .

(31) Herein, n indicates an index value of a time domain signal, k indicates an index value of a frequency domain signal, Length indicates a frame length, M indicates a time-frequency transformation length for transforming a time domain signal into a frequency domain signal, χ.sub.L(n) indicates an audio-left channel time domain signal, χ.sub.R(n) indicates an audio-right channel time domain signal, L(k) indicates a k.sup.th frequency value that is of an audio-left channel frequency domain signal and that is used to calculate the IPD parameter, and R(k) indicates a k.sup.th frequency value that is of an audio-right channel frequency domain signal and that is used to calculate the IPD parameter, where, χ.sub.L(n) and χ.sub.R(n) indicate sequences of real numbers.

(32) A fourier transformation coefficient X(k) of a sequence of real numbers χ(n) (including χ.sub.L(n) and χ.sub.R(n)) is a complex number, and a real part of the sequence of real numbers χ(n) has an even symmetry and an imaginary part has an odd symmetry. To be specific, X(k) has a conjugate symmetry. Both X(0) and X(N/2) are real numbers and meet the following relationship formula:
X(k)=X*(N−k), where 1≤k≤L/2−1.

(33) When discrete fourier transformation is performed, by using this conjugate symmetry, the encoder does not need to calculate and store X(k), L/2+1≤k≤L−1, and imaginary parts of X(0) and X(L/2), but only needs to calculate X(0) to X(L/2), to reduce occupation of a computing resource and a storage resource of the encoder.

(34) After transforming the left channel and right channel time domain signals of the current frame into the left channel frequency domain signal and right channel frequency domain signal in a form of a frame or a subframe, the encoder may calculate, based on the left channel frequency domain signal and right channel frequency domain signal, the parameter indicating the correlation between the left channel and right channel of the current frame.

(35) In one embodiment, the parameter indicating the correlation between the left channel and right channel of the current frame may be obtained through calculation by using the following calculation formula:

(36) corr = .Math. b = 0 N [ E l ( b ) + E r ( b ) + 2 × D r ( b ) ] [ E l ( b ) + E r ( b ) + 2 D r 2 ( b ) + D i 2 ( b ) ] , E l ( b ) = .Math. k = 0 L .Math. L ( k ) .Math. 2 , where , E r ( b ) = .Math. k = 0 L .Math. R ( k ) .Math. 2 , D r ( b ) = .Math. k = 0 L [ L r ( k ) × R r ( k ) + L i ( k ) × R i ( k ) ] , and D i ( b ) = .Math. k = 0 L [ L i ( k ) × R r ( k ) - L r ( k ) × R i ( k ) ] .

(37) E.sub.l(b) indicates an energy sum of an audio-left channel, E.sub.r(b) indicates an energy sum of an audio-right channel, L.sub.r(k) indicates a real part of a k.sup.th frequency value of an audio-left channel frequency domain signal, R.sub.r(k) indicates a real part of a k.sup.th frequency value of an audio-right channel frequency domain signal, L.sub.i(k) indicates an imaginary part of a k.sup.th frequency value of the audio-left channel frequency domain signal, R.sub.i(k) indicates an imaginary part of a k.sup.th frequency value of the audio-right channel frequency domain signal, L indicates a quantity of subband spectral coefficients, and N indicates a quantity of subbands.

(38) In another implementation, the parameter indicating the correlation between the left channel and right channel of the current frame may be obtained through calculation by using the following calculation formula:

(39) corr = .Math. i = 0 L .Math. L ( k ) + R ( k ) .Math. 2 ( .Math. L ( k ) .Math. + .Math. R ( k ) .Math. ) 2 .

(40) In another embodiment, the parameter indicating the correlation between the left channel and right channel of the current frame may be obtained through calculation by using the following calculation formula:

(41) 0 corr = ( .Math. k = 1 L / 2 - 1 .Math. L ( k ) R * ( k ) .Math. ) 2 .Math. k = 1 L / 2 - 1 ( .Math. L ( k ) .Math. ) 2 .Math. k = 1 L / 2 - 1 ( .Math. R ( k ) .Math. ) 2 .

(42) Herein, R*(k) indicates a conjugate of R(k). To be specific, R*(k) indicates a conjugate of the k.sup.th frequency value of the audio-right channel frequency domain signal.

(43) In some feasible implementations, after transforming the left channel and right channel time domain signals of the current frame into the left channel frequency domain signal and right channel frequency domain signal, the encoder may further calculate the variance of the subband IPD parameterss of the current frame based on the left channel frequency domain signal and right channel frequency domain signal. Specifically, the encoder may first divide the left channel frequency domain signal and right channel frequency domain signal of the current frame into at least two subbands (in other words, a plurality of subbands). It is assumed that the left channel frequency domain signal and right channel frequency domain signal are divided into Nsubband subbands, Nsubband where is an integer greater than 2. Then, the encoder may calculate IPD parameters of all subbands based on frequency domain signals of the Nsubband subbands obtained through division, and calculate the variance of the subband IPD parameterss of the current frame based on the IPD parameters of the Nsubband subbands obtained through calculation.

(44) In an implementation, the encoder may specifically calculate the subband IPD parameter by using the following calculation formula:

(45) IPD ( b ) = arg ( .Math. k = A b - 1 A b - 1 L ( k ) R * ( k ) ) , 0 b < N subband .

(46) Herein, b indicates an index value of a subband, and a frequency included in a subband b is A.sub.b-1≤k≤A.sub.b−1.

(47) In an implementation, the encoder may calculate the variance of the subband IPD parameterss by using the following calculation formula:

(48) var = 1 N subband .Math. b = 0 N subband - 1 ( IPD ( b ) - avr ) 2 , where avr = 1 N subband .Math. b = 0 N subband - 1 IPD ( b ) .

(49) In another embodiment of the present disclosure, the subband IPD parameter may be obtained through calculation by using the following calculation formula:

(50) IPD ( b ) = atan 2 ( D i ( b ) D r ( b ) ) .

(51) Herein, atan2 indicates an arctan function.

(52) It may be understood that, during actual application, the subband IPD parameter may alternatively be obtained through calculation in another manner. A specific calculation manner of the subband IPD parameter is not limited in this embodiment of the present disclosure.

(53) S502. Determine the IPD parameter encoding scheme of the current frame based on the obtained reference parameter.

(54) During specific implementation, in one embodiment, the encoder may adaptively select, based on the obtained reference parameter, one of a plurality of preset IPD parameter encoding schemes as the IPD parameter encoding scheme of the current frame.

(55) The plurality of preset IPD parameter encoding schemes may include a first encoding scheme and a second encoding scheme. The first encoding scheme includes a group IPD parameter encoding scheme, skipping encoding an IPD parameter, setting a value of the IPD parameter to 0, or the like. The second encoding scheme includes an IPD parameter encoding scheme of a subband set, a subband IPD parameter encoding scheme, or the like. The subband IPD parameter encoding scheme may be encoding IPD parameters of all or some of subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame.

(56) It may be understood that, in one embodiment, it may be predetermined that the first encoding scheme is specifically one of the following: the group IPD parameter encoding scheme, skipping encoding the IPD parameter, and setting the value of the IPD parameter to 0. Therefore, the encoder may directly determine that an encoding scheme is the group IPD parameter encoding scheme, skipping encoding the IPD parameter, or setting the value of the IPD parameter to 0, and does not need to perform selection from three encoding schemes. Correspondingly, it may further be predetermined that the second encoding scheme is specifically one of the IPD parameter encoding scheme of the subband set and the subband IPD parameter encoding scheme. Therefore, the encoder may directly determine that an encoding scheme is the IPD parameter encoding scheme of the subband set or the subband IPD parameter encoding scheme, and does not need to perform selection from two encoding schemes.

(57) In another embodiment, the encoder may first determine the first encoding scheme or the second encoding scheme. When determining the first encoding scheme, the encoder selects one of the foregoing three encoding schemes. Correspondingly, when determining the second encoding scheme, the encoder selects one of the foregoing two second encoding schemes.

(58) In one embodiment, after the IPD parameter encoding scheme of the current frame is determined, the determined IPD parameter encoding scheme of the current frame may be encoded. A specific encoding scheme may be setting a preset parameter as a preset value, and indicating different encoding schemes by using different values. For example, in an implementation, the IPD parameter encoding scheme of the current frame may be indicated by using an encoding scheme flag bit. The flag bit may occupy one bit. When a value of this bit is 0, it indicates that the IPD parameter encoding scheme of the current frame is the first encoding scheme. When a value of this bit is 1, it indicates that the IPD parameter encoding scheme of the current frame is the second encoding scheme. Certainly, when a value of this bit is 1, it may alternatively indicate that the IPD parameter encoding scheme of the current frame is the first encoding scheme, and when a value of this bit is 0, it may alternatively indicate that the IPD parameter encoding scheme of the current frame is the second encoding scheme. The decoder may determine the IPD parameter encoding scheme based on the value of the flag bit, to determine a corresponding decoding manner.

(59) Operation S503. Process an IPD parameter of the current frame based on the determined IPD parameter encoding scheme of the current frame.

(60) In one embodiment, the reference parameter includes the parameter indicating the correlation between the left channel and right channel of the current frame. In this case, when the IPD parameter encoding scheme of the current frame is to be determined, the parameter indicating the correlation between the left channel and right channel of the current frame may be compared with a predefined first threshold. If a value of the parameter indicating the correlation between the left channel and right channel of the current frame is greater than or equal to the first threshold, the IPD parameter encoding scheme of the current frame is the first encoding scheme. On the contrary, if a value of the parameter indicating the correlation between the left channel and right channel of the current frame is less than the first threshold, the IPD parameter encoding scheme of the current frame is the second encoding scheme. A value of the predefined first threshold ranges from 0.6 to 0.95. For example, the value may specifically be 0.89, 0.8, 0.75, or the like.

(61) In one embodiment, the reference parameter includes the variance of the subband IPD parameterss of the current frame. In this case, when the IPD parameter encoding scheme of the current frame is to be determined, the variance of the subband IPD parameterss of the current frame may be compared with a predefined second threshold. If a value of the parameter indicating the correlation between the left channel and right channel of the current frame is less than the second threshold, it indicates that the IPD parameter encoding scheme of the current frame is the first encoding scheme. On the contrary, if a value of the parameter indicating the correlation between the left channel and right channel of the current frame is greater than or equal to the second threshold, it indicates that the IPD parameter encoding scheme of the current frame is the second encoding scheme. A value of the predefined second threshold ranges from 0.05 to 0.5. For example, the value may specifically be 0.45, 0.25, 0.3, or the like.

(62) In one embodiment, the reference parameter includes the signal type of the current frame. For example, in an implementation, when the signal type of the current frame is a voice type, it may be determined that the IPD parameter encoding scheme of the current frame is the second encoding scheme. When the signal type of the current frame is a music type, it may be determined that the IPD parameter encoding scheme of the current frame is a first IPD parameter encoding scheme. It may be understood that, in some other embodiments, the signal type of the current frame is not the only reference parameter for determining the IPD parameter encoding scheme of the current frame. The IPD parameter encoding scheme may further be determined with reference to another reference parameter.

(63) In one embodiment, the reference parameter includes an ITD parameter of the current frame. If a value of the ITD parameter of the current frame is greater than a preset threshold, it is determined that the IPD parameter encoding scheme of the current frame is the first encoding scheme. Otherwise, the IPD parameter encoding scheme of the current frame is the second encoding scheme. In an embodiment, the preset threshold may be 1, 2, 3, 4, or 5.

(64) It may be understood that the signal characteristic parameter of the current frame may include only one of the foregoing parameters. In this case, the IPD parameter encoding scheme of the current frame may be determined provided that the parameter meets a corresponding parameter condition. Certainly, the signal characteristic parameter of the current frame may alternatively include at least two of the foregoing parameters. In this case, the IPD parameter encoding scheme of the current frame may be determined only when the at least two parameters respectively meet corresponding parameter conditions.

(65) In one embodiment, the reference parameter includes the IPD parameter encoding scheme of each of the A frames previous to the current frame and the signal type of each of the A frames previous to the current frame. In this case, it may be determined whether the IPD parameter encoding scheme of each of the A frames previous to the current frame is a preset IPD parameter encoding scheme and whether the signal type of each of the A frames previous to the current frame is a preset signal type. If the IPD parameter encoding scheme of each of the A frames previous to the current frame is the first encoding scheme, and the signal type of each of the A frames of the current frame is a music type, the IPD parameter encoding scheme of the current frame may be determined as the first encoding scheme.

(66) For example, when A=1, the A frames previous to the current frame are one frame previous to the current frame. If the IPD parameter encoding scheme of the frame previous to the current frame is the first encoding scheme, and the signal type of the frame previous to the current frame is a music type, the IPD parameter encoding scheme of the current frame may be determined as the first encoding scheme. Otherwise, it is determined that the IPD parameter encoding scheme of the current frame is not the first encoding scheme, for example, the second encoding scheme.

(67) When A=2, the A frames previous to the current frame are two frames previous to the current frame. If IPD parameter encoding schemes of the two frames previous to the current frame both are first encoding schemes, and signal types of the two frames previous to the current frame are music types, the IPD parameter encoding scheme of the current frame may be determined as the first encoding scheme. Otherwise, it is determined that the IPD parameter encoding scheme of the current frame is not the first encoding scheme, for example, the second encoding scheme.

(68) In one embodiment, the reference parameter includes the ITD parameter of the current frame, the variance of the subband IPD parameterss of the current frame, and the signal type of each of the A frames previous to the current frame. In this case, an absolute value of the ITD parameter of the current frame may be compared with a predefined third threshold, the variance of the subband IPD parameterss of the current frame is compared with a predefined fourth threshold, and it is determined whether the signal type of each of the A frames previous to the current frame is a voice type. A value of the predefined third threshold may range from 0 to 4. For example, the value of the third threshold may be 4, 2, 0, or the like. A value of the predefined fourth threshold may range from 0.05 to 0.4. The value of the fourth threshold may be 0.4, 0.35, 0.25, 0.05, or the like. If the absolute value of the ITD parameter of the current frame is greater than the third threshold, the variance of the subband IPD parameters of the current frame is less than the fourth threshold, and the signal type of each of the A frames previous to the current frame is a voice type, the IPD parameter encoding scheme of the current frame may be determined as the first encoding scheme. Otherwise, it is determined that the IPD parameter encoding scheme of the current frame is not the first encoding scheme, for example, the second encoding scheme.

(69) If the A frames previous to the current frames are the frame previous to the current frame, when the absolute value of the ITD parameter of the current frame is greater than the third threshold, the variance of the subband IPD parameters of the current frame is less than the fourth threshold, and the signal type of the frame previous to the current frame is a voice type, the IPD parameter encoding scheme of the current frame may be determined as the first encoding scheme. If the A frames previous to the current frames are the two frames previous to the current frame, when the absolute value of the ITD parameter of the current frame is greater than the third threshold, the variance of the subband IPD parameters of the current frame is less than the fourth threshold, and a signal type of each of the two frames previous to the current frame is a voice type, the IPD parameter encoding scheme of the current frame may be determined as the first encoding scheme.

(70) In one embodiment, after determining that the IPD parameter encoding scheme of the current frame is the first encoding scheme, the encoder may process the IPD parameter of the current frame based on the first encoding scheme. For example, if the first encoding scheme is skipping encoding the IPD parameter, no operation is performed, to be specific, ending a process corresponding to encoding of the IPD parameter of the current frame. If the first encoding scheme is the group IPD parameter encoding scheme, the group IPD parameter of the current frame may be encoded. The group IPD parameter of the current frame is used as the IPD parameter of the current frame. If the first encoding scheme is setting the value of the IPD parameter to 0, the value of the IPD parameter of the current frame may be set to 0, and then the IPD parameter with a value of 0 is subsequently processed. For example, if the value of the IPD parameter is required as an input during some processing, after the value of the IPD parameter of the current frame is set to 0, 0 may be used as the input of the processing.

(71) In one embodiment, the reference parameter includes the parameter indicating the correlation between the left channel and right channel of the current frame, and may further include the IPD parameter encoding scheme of the frame previous to the current frame and the signal type of the previous frame. If the value of the parameter indicating the correlation between the left channel and right channel of the current frame is greater than or equal to the first threshold, it may be determined that the IPD parameter encoding scheme of the current frame is the first encoding scheme. If the value of the parameter indicating the correlation between the left channel and right channel of the current frame is less than the first threshold, and the IPD parameter encoding scheme of the frame previous to the current frame is the first encoding scheme and the signal type of the previous frame is a music signal type, it may also be determined that the IPD parameter encoding scheme of the current frame is the first encoding scheme. Otherwise, if the value of the parameter indicating the correlation between the left channel and right channel of the current frame is less than the first threshold, and the IPD parameter encoding scheme of the frame previous to the current frame is the second encoding scheme or the signal type of the frame previous to the current frame is a voice type, it is determined that the IPD parameter encoding scheme of the current frame is the second encoding scheme.

(72) Further, in one embodiment, after the IPD parameter encoding scheme of the current frame is determined by using the foregoing implementation, whether to adjust the IPD parameter encoding scheme of the current frame may further be determined based on the IPD parameter encoding schemes of the A frames previous to the current frame. For example, whether to adjust the IPD parameter encoding scheme of the current frame may be determined based on the IPD parameter encoding scheme of the frame, two frames, three frames, four frames, or five frames previous to the current frame. In a possible implementation, if the IPD parameter encoding scheme of the current frame is the same as the IPD parameter encoding scheme of the previous A frames, the IPD parameter encoding scheme of the current frame does not need to be adjusted. If the IPD parameter encoding scheme of the current frame is different from the IPD parameter encoding scheme of the previous A frames, adjusting the IPD parameter encoding scheme of the current frame may be considered. For example, the two frames, three frames, four frames, or five frames previous to the current frame, including the frame previous to the current frame use a same IPD parameter encoding scheme. In addition, when the IPD parameter encoding scheme used by the two frames, three frames, four frames, or five frames previous to the current frame is different from the IPD parameter encoding scheme of the current frame, the IPD parameter encoding scheme of the current frame may be adjusted. To be specific, the IPD parameter encoding scheme of the current frame is adjusted to be the same as the IPD parameter encoding scheme of the previous A frames. Adjusting the IPD parameter encoding scheme of the current frame may ensure that an encoding scheme of the current frame is kept consistent with that of a previous frame to some extent, so that an encoded code stream can ensure a smooth transition between the previous frame and the current frame during decoding, and auditory perception is better.

(73) In one embodiment, the encoder may extract IPD parameters of at least some subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame when the encoding scheme is the second encoding scheme. The at least some subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame may specifically include all or some of the Nsubband subbands obtained through division of the left channel frequency domain signal and right channel frequency domain signal of the current frame. This is not limited herein. During specific implementation, a user may determine, based on encoding requirements such as an encoding rate or encoding quality of multi-channel signal encoding, that a frequency domain range of the left channel frequency domain signal and right channel frequency domain signal that are of the current frame and that are used to encode the group IPD parameter of the current frame includes an entire frequency domain range of the left channel frequency domain signal and right channel frequency domain signal of the current frame, to be specific, frequency domain signals of all subbands in the left channel frequency domain signal and right channel frequency domain signal of the current frame, or includes a specific frequency domain range of the left channel frequency domain signal and right channel frequency domain signal of the current frame, to be specific, frequency domain signals of some frames in the left channel frequency domain signal and right channel frequency domain signal of the current frame. The frequency domain signals of some of the frames in the left channel frequency domain signal and right channel frequency domain signal of the current frame are included in the frequency domain signals of some of the subbands of the left channel frequency domain signal and right channel frequency domain signal.

(74) In one embodiment, the encoder may not first extract IPD parameters of all or some of subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame, and then determine the IPD parameter encoding scheme of the current frame. If the first encoding scheme is skipping encoding the IPD parameter of the current frame, the IPD parameters of all or some of the subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame may not be directly extracted. In some other implementations, an IPD parameter of each of all or some of the subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame may alternatively first be extracted, and then the IPD parameter encoding scheme of the current frame is determined.

(75) In one embodiment, if the encoder determines that the frequency domain range of the left channel frequency domain signal and right channel frequency domain signal that are of the current frame and that are used to encode the group IPD parameters of the left channel frequency domain signal and right channel frequency domain signal of the current frame is an entire frequency domain range of the left channel frequency domain signal and right channel frequency domain signal of the current frame, an IPD parameter of each of all subbands (to be specific, the Nsubband subbands of the current frame) of the left channel frequency domain signal and right channel frequency domain signal of the current frame may be extracted, an average value of IPD parameters of all extracted subbands may be calculated, and then the obtained average value of the IPD parameters of all of the subbands is used as the group IPD parameter of the current frame. In an implementation, a formula for calculating the group IPD parameter of the current frame is as follows:

(76) G_IPD = 1 N subband .Math. b = 0 N subband - 1 IPD ( b ) .

(77) G_IPD indicates the group IPD parameter of the current frame, and IPD(b) indicates an IPD parameter of a b.sup.th subband.

(78) In one embodiment, if the encoder determines that the frequency domain range of the left channel frequency domain signal and right channel frequency domain signal that are the current frame and that are used to encode the group IPD parameters of the left channel frequency domain signal and right channel frequency domain signal of the current frame is a specific frequency domain range of the left channel frequency domain signal and right channel frequency domain signal of the current frame, for example, [k1, k2], to be specific, frequency domain signals between a (k1).sup.th frequency and a (k2).sup.th frequency, an IPD parameter of each of some subbands (to be specific, subbands of the frequency domain signals between the (k1).sup.th frequency and the (k2).sup.th frequency) of the left channel frequency domain signal and right channel frequency domain signal of the current frame may be extracted, an average value of IPD parameters of all extracted subbands may be calculated, and then the obtained average value of the IPD parameters of all of the subbands is used as the group IPD parameter of the current frame.

(79) In one embodiment, the IPD parameters of the subbands of the frequency domain signals between the (k1).sup.th frequency and the (k2).sup.th frequency each may be predefined as an IPD parameter of each frequency. To be specific, in this case, calculation of the IPD parameters of the subbands may be replaced with calculation of the IPD parameter of each frequency. The group IPD parameter of the current frame is calculated by using the IPD parameter of each frequency as an IPD parameter of each subband. A manner of calculating the IPD parameter of each frequency one by one in a preset frequency domain range [k1, k2] is as follows:
IPD(k)=∠L(k)R*(k),k.sub.1≤k≤k.sub.2.

(80) Herein, ∠ indicates calculating an angle of a complex number. L(k) indicates a k.sup.th frequency value of an audio-left channel frequency domain signal, and R*(k) indicates a conjugate of a k.sup.th frequency value of an audio-right channel frequency domain signal.

(81) Further, statistical processing may be performed on IPD(k) in a preset range (a multi-frame signal of a multi-channel frequency domain signal, including a current frame and A frames previous to the current frame) to obtain the group IPD parameter.

(82) For example, if the specific frequency domain range [k1, k2] is a selection range of each of six frames of left channel frequency domain signal and right channel frequency domain signal, an average value of IPD parameters of (k2−k1+1).sup.th frequencies of each frame in left channel frequency domain signal and right channel frequency domain signal with the six frames may be calculated, and a calculation formula is as follows:

(83) M IPD [ 0 ] = 1 k 2 - k 1 + 1 .Math. k = k 1 k 2 IPD ( k ) .

(84) Further, an average value of IPD parameters of six consecutive frames including the current frame may be calculated, and is used as the group IPD parameter of the current frame:

(85) M IPD = 1 6 .Math. i = - 5 0 M IPD [ i ] .

(86) M.sup.[0].sub.IPD indicates an average value of IPD parameters of the current frame, M.sup.[−1].sub.IPD indicates an average value of IPD parameters of a frame previous to and adjacent to the current frame, M.sup.[−2].sub.IPD indicates an average value of IPD parameters of a frame previous to and adjacent to the frame previous to and adjacent to the current frame, and so on.

(87) In one embodiment, the second encoding scheme may be an IPD parameter encoding scheme of a subband set, or a subband IPD parameter encoding scheme. For example, when an IPD parameter encoding scheme of the current frame is a subband IPD parameter extraction manner, an IPD parameter of each of all or some of subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame are extracted, and then the IPD parameter of the subband is quantized in any quantization manner. This is not specifically limited.

(88) FIG. 6 describes a procedure of an IPD parameter encoding method according to another embodiment of the present disclosure. This embodiment is described by using an example in which a reference parameter includes: a parameter indicating correlation between left channel and right channel of a current frame, an IPD parameter encoding scheme of a frame previous to the current frame, and a signal type of the frame previous to the current frame, a value of a first threshold is 0.75, and a value of A is 1. As shown in FIG. 6, this embodiment includes the following operations.

(89) Operation S601. Obtain the parameter indicating the correlation between the left channel and right channel of the current frame.

(90) For a specific manner of obtaining the parameter indicating the correlation between the left channel and right channel of the current frame, refer to the foregoing description. Details are not described herein again.

(91) Operation S602. Determine whether a value of the parameter indicating the correlation between the left channel and right channel of the current frame is greater than or equal to 0.75. If the value of the parameter indicating the correlation between the left channel and right channel is less than 0.75, go to operation S603; if the value of the parameter indicating the correlation between the left channel and right channel is greater than or equal to 0.75, go to operation S607.

(92) Operation S603. Obtain the IPD parameter encoding scheme of the frame previous to the current frame.

(93) The IPD parameter encoding scheme of the frame previous to the current frame may be stored in a cache. The IPD parameter encoding scheme of the previous frame may be skipping encoding an IPD parameter, or encoding subband IPD parameters of all or some of subbands of left channel frequency domain signal and right channel frequency domain signal.

(94) Operation S604. Determine whether the IPD parameter encoding scheme of the frame previous to the current frame is skipping encoding the IPD parameter. If the IPD parameter encoding scheme of the frame previous to the current frame is skipping encoding the IPD parameter, go to operation S605. If the IPD parameter encoding scheme of the frame previous to the current frame is not skipping encoding the IPD parameter, go to operation S608.

(95) Operation S605. Obtain the signal type of the frame previous to the current frame.

(96) The signal type of the frame previous to the current frame may be stored in the cache. The signal type of the previous frame may be a music signal type or a voice signal type.

(97) Operation S606. Determine whether the signal type of the frame previous to the current frame is the music signal type. If the signal type of the frame previous to the current frame is the music signal type, go to operation S607; if the signal type of the frame previous to the current frame is not the music signal type, go to operation S608.

(98) Operation S607. Skip encoding the IPD parameter of the current frame, to be specific, determine that the IPD parameter encoding scheme of the current frame is skipping encoding the IPD parameter. End a processing procedure of the current frame.

(99) Operation S608. Encode the subband IPD parameters of all or some of the subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame. A subband is in a one-to-one correspondence to a subband IPD parameter. In other words, each subband has a corresponding subband IPD parameter.

(100) A specific process of obtaining the subband IPD parameter is described above, and details are not described herein again.

(101) When the subband IPD parameters of some of the subbands of the left channel frequency domain signal and right channel frequency domain signal of the current frame are encoded, to-be-encoded subband IPD parameters of a specific part of subbands may be set based on a requirement. For example, it is assumed that there are a subbands in total, and frequency values of the a subbands gradually increase from a 0.sup.th subband to an (a−1).sup.th subband. In an embodiment, only subband IPD parameters from the 0.sup.th subband to an (a−3).sup.th subband may be encoded. In other words, subband IPD parameters of two subbands respectively with the highest frequency and the second highest frequency are not encoded. In another embodiment, only subband IPD parameters from a second subband to an (a−1).sup.th subband may be encoded. In other words, subband IPD parameters of two subbands respectively with the lowest frequency and the second lowest frequency are not encoded. Certainly, subband IPD parameters of any two of the subbands may alternatively not be encoded. It may be understood that, in some embodiments, a quantity of subbands corresponding to encoded subband IPD parameters may be set based on a specific requirement. For example, subband IPD parameters of (a−1) subbands in the a subbands may be encoded, or subband IPD parameters of (a−2) subbands in the a subbands may be encoded, or subband IPD parameters of (a−3) subbands in the a subbands may be encoded, or subband IPD parameters of (a−4) subbands in the a subbands may be encoded.

(102) It may be understood that a performing sequence of obtaining operations S601, S603, and S605 in FIG. 6 is not limited. Any one of the obtaining operations S601, S603, and S605 may be first performed, or the obtaining operations S601, S603, and S605 may be simultaneously performed. Similarly, a performing sequence of determining operations S602, S604, and S606 is not limited, either. Any one of the determining operations S602, S604, and S606 may be first performed, or the determining operations S602, S604, and S606 may be simultaneously performed.

(103) FIG. 7 describes a procedure of an IPD parameter encoding method according to another embodiment of the present disclosure. This embodiment includes the following operations.

(104) Operation S701. Obtain a reference parameter used to determine an IPD parameter encoding scheme of a current frame of a multi-channel signal.

(105) For a specific reference parameter and a specific manner of obtaining the reference parameter, refer to description in the foregoing embodiment. Details are not described herein again.

(106) Operation S702. Determine the IPD parameter encoding scheme of the current frame based on the obtained parameter.

(107) For the IPD parameter encoding scheme of the current frame, refer to the description in the foregoing embodiment. Details are not described herein again.

(108) Operation S703. Determine whether the IPD parameter encoding scheme of the current frame is the same as an IPD parameter encoding scheme of a frame previous to the current frame. If the IPD parameter encoding scheme of the current frame is the same as the IPD parameter encoding scheme of the frame previous to the current frame, go to operation S704. If the IPD parameter encoding scheme of the current frame is different from the IPD parameter encoding scheme of the frame previous to the current frame, go to operation S705.

(109) Operation S704. Set a preset value of a counter to 0, and go to operation S707.

(110) In other words, the IPD parameter encoding scheme of the current frame does not need to be adjusted.

(111) Operation S705. Determine whether a preset value of the counter is less than 5. If the preset value of the counter is less than 5, go to operation S706. If the preset value of the counter is greater than or equal to 5, go to operation S707.

(112) Operation S706. Adjust the IPD parameter encoding scheme of the current frame, and increase the preset value of the counter by 1, and go to operation S708.

(113) When the IPD parameter encoding scheme of the current frame is a first encoding scheme, the IPD parameter encoding scheme of the current frame is adjusted to a second encoding scheme. For example, when the IPD parameter encoding scheme of the current frame is skipping encoding an IPD parameter, the IPD parameter encoding scheme of the current frame is adjusted to encoding subband IPD parameters of all or some of subbands of left channel frequency domain signal and right channel frequency domain signal of the current frame. Alternatively, when the IPD parameter encoding scheme of the current frame is a second encoding scheme, the IPD parameter encoding scheme of the current frame is adjusted to a first encoding scheme. For example, when the IPD parameter encoding scheme of the current frame is encoding subband IPD parameters of all or some of subbands of left channel frequency domain signal and right channel frequency domain signal of the current frame, the IPD parameter encoding scheme of the current frame is adjusted to skipping encoding an IPD parameter.

(114) Operation S707. Process an IPD parameter of the current frame by using the determined IPD parameter encoding scheme of the current frame. End a procedure.

(115) Operation S708. Process an IPD parameter of the current frame by using the adjusted IPD parameter encoding scheme of the current frame.

(116) In another embodiment of the present disclosure, when whether to adjust the IPD parameter encoding scheme of the current frame is to be determined, two counters may be used. A specific processing manner is as follows:

(117) When the IPD parameter encoding scheme of the current frame and the IPD parameter encoding scheme of the frame previous to the current frame both are first encoding schemes, a value of a first counter is set to 0. If the IPD parameter encoding scheme of the frame previous to the current frame is the first encoding scheme, the IPD parameter encoding scheme of the current frame is the second encoding scheme, and the value of the first counter is less than 5, the IPD parameter encoding scheme of the current frame is adjusted to the first encoding scheme, and the value of the first counter is increased by 1. The first encoding scheme may be skipping encoding the IPD parameter, and the second encoding scheme may be encoding the subband IPD parameters of all or some of the subbands of the left channel frequency domain signal and right channel frequency domain signal.

(118) When the IPD parameter encoding scheme of the current frame and the IPD parameter encoding scheme of the frame previous to the current frame both are second encoding schemes, a value of a second counter is set to 0. If the IPD parameter encoding scheme of the frame previous to the current frame is the second encoding scheme, the IPD parameter encoding scheme of the current frame is the first encoding scheme, and the value of the second counter is less than 5, the IPD parameter encoding scheme of the current frame is adjusted to the second encoding scheme, and the value of the second counter is increased by 1. The first encoding scheme may be skipping encoding the IPD parameter, and the second encoding scheme may be encoding the subband IPD parameters of all or some of the subbands of the left channel frequency domain signal and right channel frequency domain signal.

(119) It may be understood that, if the IPD parameter encoding scheme of the current frame is adjusted, the adjusted IPD parameter encoding scheme of the current frame is cached. In other words, when an IPD parameter encoding scheme of a frame after the current frame is to be determined, refer to the adjusted IPD parameter encoding scheme of the current frame.

(120) FIG. 8 is a schematic structural diagram of an embodiment of an IPD parameter encoding apparatus 800 according to an embodiment of the present disclosure. The IPD parameter encoding apparatus 800 includes:

(121) an obtaining unit 801, configured to obtain a reference parameter, where the reference parameter is used to determine an IPD parameter encoding scheme of a current frame of a multi-channel signal, and

(122) for a specific reference parameter and a specific obtaining parameter of the reference parameter, reference may be made to description in the foregoing embodiment, and details are not described herein again;

(123) a determining unit 802, configured to determine an IPD parameter encoding scheme of the current frame based on the reference parameter obtained by the obtaining unit 801, where the determined IPD parameter encoding scheme of the current frame is one of at least two preset IPD parameter encoding schemes, and

(124) for determining the IPD parameter encoding scheme of the current frame, reference may specifically be made to description in a method embodiment part, for specific encoding schemes of the at least two preset IPD parameter encoding schemes, reference may also be made to description in the method embodiment part, and details are not described herein again; and

(125) a processing unit 803, configured to process an IPD parameter of the current frame based on the IPD parameter encoding scheme that is of the current frame and that is determined by the determining unit 802.

(126) For a specific processing process, refer to description in the method embodiment part. Details are not described herein again.

(127) In another embodiment of the present disclosure, the determining unit 802 may further be configured to determine whether the determined IPD parameter encoding scheme of the current frame needs to be adjusted. In this case, as shown in FIG. 8, the IPD parameter encoding apparatus 800 may further include an adjusting unit 804, configured to adjust the determined IPD parameter encoding scheme of the current frame when the determining unit 802 determines that the determined IPD parameter encoding scheme of the current frame needs to be adjusted. Correspondingly, the processing unit 803 is specifically configured to process the IPD parameter of the current frame based on the adjusted IPD parameter encoding scheme of the current frame. For how to determine whether the determined IPD parameter encoding scheme of the current frame needs to be adjusted, and how to adjust the IPD parameter encoding scheme of the current frame, refer to description in the method embodiment. Details are not described herein again.

(128) As shown in FIG. 8, in another embodiment of the present disclosure, the IPD parameter encoding apparatus 800 may further include an encoding unit 805, configured to encode the IPD parameter encoding scheme that is of the current frame and that is determined by the determining unit 802. For example, an encoding scheme flag bit may be set, and the flag bit occupies one bit, to indicate whether the IPD parameter encoding scheme of the current frame is a first encoding scheme or a second encoding scheme. In this way, a decoder can determine the IPD parameter encoding scheme of the current frame based on the encoding scheme flag bit, to perform decoding by using a corresponding decoding manner. It may be understood that, in some implementations, the encoding unit 805 and the processing unit 803 may be one logical unit.

(129) FIG. 9 describes a structure of a terminal according to another embodiment of the present disclosure. The terminal may be a wearable device, a VR device, an AR device, a mobile phone, a pad, a notebook, a PC, or the like. As shown in FIG. 9, the terminal provided in this embodiment of the present disclosure includes a network interface 910 (as shown in a dotted line box in FIG. 9). The network interface 910 is configured to send and receive data. For example, when the terminal serves as an encoder, sent data includes a multi-channel signal (carried in a code stream) encoded by the terminal. When an IPD parameter is encoded, the sent data further includes the IPD parameter (the IPD parameter is also carried in the code stream and may be used as a part of the multi-channel signal). When the terminal serves as a decoder, received data includes a code stream carrying the multi-channel signal. When the encoder encodes the IPD parameter, the received data may further include the IPD parameter. A specific form of the network interface 910 may be various, and may specifically be different based on a specific form of the terminal and different application scenarios. FIG. 9 shows three examples. A first example is a cellular network access module including a radio frequency transceiver (RF Transceiver) 901 and a modem (Modem) 902. The cellular network access module is configured to access a mobile communications network provided by a mobile operator, such as a 2G (2.sup.nd Generation), 3G (3.sup.rd Generation), 4G (4.sup.th Generation), to be specific, a long term evolution (LTE) network, future 5G (5.sup.th Generation) or 6G (6.sup.th Generation) network, or the like. A second example is a wireless fidelity (WiFi) module 903, configured to access a network by accessing an accessing point (AP). A third example is an Ethernet network adapter 904, configured to access the network by using a twisted pair cable or an optical fiber. It should be noted that the terminal does not need to include all of the foregoing three network interfaces, and may include only at least one of the foregoing three network interface terminals, so that the terminal can access the network. In addition, a network interface included in the terminal may not be one of the foregoing three types, for example, may be a Bluetooth interface or a modem. Therefore, a specific form of the network interface 910 is not limited in this embodiment of the present disclosure, and implementation of this embodiment of the present disclosure is not affected provided that the terminal can access the network through the network interface 910.

(130) As shown in FIG. 9, the terminal may further include a microphone 905, configured to collect a multi-channel signal. An analog-to-digital converter may be built in the microphone 905. Therefore, the microphone may convert a collected multi-channel signal in an analog signal form into a multi-channel signal in a digital signal form. Certainly, no analog-to-digital converter may alternatively be built in the microphone 905. In this case, the terminal further needs to include an analog-to-digital converter, to perform analog-to-digital conversion on a multi-channel signal in an analog signal form collected by the microphone 905 and obtain a multi-channel signal in a digital signal form. There may be one, two, three, or more microphones 905. A specific quantity of microphones 905 is not limited in this embodiment of the present disclosure. It may be understood that the terminal may alternatively collect the multi-channel signal by using an external microphone. In this case, the terminal needs to include an adaptation interface of the external microphone, to facilitate insertion of the external microphone and then implement data exchange between the terminal and the external microphone.

(131) As shown in FIG. 9, the terminal may further include a loudspeaker 906, configured to play a multi-channel signal obtained through decoding by the terminal. If a bitstream that includes the multi-channel signal and that is received by the terminal includes an IPD parameter, this decoding process may be performed based on the IPD parameter. A digital-to-analog converter may be built in the loudspeaker 906. In other words, the terminal may send a multi-channel signal in a digital signal form to the loudspeaker 906, and the loudspeaker 906 performs analog-to-digital conversion on the multi-channel signal in the digital signal form, to convert the multi-channel signal in the digital signal form into and play a multi-channel signal in an analog signal form. Certainly, no digital-to-analog converter may alternatively be built in the loudspeaker 906. In this case, the terminal needs to include an analog-to-digital converter to convert the multi-channel signal in the digital signal form into the multi-channel signal in the analog signal form, and sends the multi-channel signal in the analog signal form to the loudspeaker 906 for playing. There may be one, two, three, or more loudspeakers 906. A quantity of loudspeakers 906 is not limited in this embodiment of the present disclosure. It may be understood that the terminal may alternatively play the multi-channel signal by using an external loudspeaker. In this case, the terminal needs to include an adaptation interface of the external loudspeaker, to facilitate insertion of the external loudspeaker and then implement data exchange with the external loudspeaker.

(132) As shown in FIG. 9, the terminal further includes a processor 908 and a memory 909. The memory 909 is configured to store code executable by the processor, and the processor 908 is configured to execute the code stored in the memory 909, to implement the method described in the foregoing method embodiments.

(133) As shown in FIG. 9, the terminal further includes a bus 907. Data exchange between the foregoing components such as the network interface 910, the microphone 905, the loudspeaker 906, the processor 908, and the memory 909 may be performed by using the bus 907. It may be understood that FIG. 9 merely describes an example of the structure of the terminal. Some connection relationships in the structure are simplified. During actual application, components such as the network interface 910, the microphone 905, or the loudspeaker 906 may not be directly connected to the bus 907. In other words, data exchange between the components such as the network interface 910, the microphone 905, or the loudspeaker 906 may further need to pass through another component.

(134) In one embodiment, the processor 908 and the memory 909 may further have a data exchange interface. Data exchange between the processor 908 and the memory 909 may be directly performed through the data exchange interface, and does not need to pass through the bus 907, to improve data exchange efficiency between the processor 908 and the memory 909.

(135) In one embodiment, the processor 908 and the memory 909 may be a processor and a memory in a digital signal processor (DSP: Digital Signal Processor). In other words, both the processor 908 and the memory 909 are encapsulated in the DSP. In this case, data exchange between the processor 908 and the memory 909 may be performed through a data exchange interface inside the DSP. In addition, because both the processor 908 and the memory 909 are encapsulated in the DSP, the processor 908 and the memory 909 may exchange data with another component through one data exchange interface between the DSP and the bus 907.

(136) An embodiment of the present disclosure further provides a computer program. When the computer program is executed, a procedure of any one of the foregoing method embodiments may be executed.

(137) An embodiment of the present disclosure further provides a storage medium. The storage medium stores executable code, and when the executable code is executed, a procedure in any one of the foregoing method embodiments may be executed.

(138) A person of ordinary skill in the art may understand that all or some of procedures of the method in the embodiments may be implemented by a computer program instructing related hardware. The program may be stored in a computer readable storage medium. When the program runs, the procedures of the method in the embodiments are included. The storage medium may include: a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), or the like.

(139) In the specification, claims, and accompanying drawings of the present disclosure, the terms “first”, “second”, “third”, “fourth”, and the like are intended to distinguish between different objects but do not indicate a specific order. In addition, the terms “include”, “have”, and any other variant thereof are intended to cover a non-exclusive inclusion. For example, a process, a method, a system, a product, or a device that includes a series of operations or units is not limited to the listed operations or units, but optionally further includes a operation or unit that is not listed, or optionally further includes another inherent operation or unit of the process, method, system, product, or device.

(140) What is disclosed above is merely example embodiments of the present disclosure, and certainly is not intended to limit the protection scope of the present disclosure. Therefore, equivalent variations made in accordance with the claims of the present disclosure shall fall within the scope of the present disclosure.