Audio encoding method, audio decoding method, and related devices
Through the dynamic adjustment of hierarchical quantization coding and bandwidth cutoff coefficient, the switching of lossy and lossless coding characteristics of the audio signal is realized, the channel adaptive capability is improved, and the problem of low efficiency of coding characteristics switching in the existing technology is solved.
Patent Information
- Application Number
- PCT/CN2023/133321
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-28
- Filing Date
- 2023-11-22
- Publication Date
- 2024-09-06
AI Technical Summary
Existing audio coding methods cannot support lossy and lossless coding at the same time, resulting in low efficiency of coding feature switching, and the need to re-encode when the code rate changes, reducing channel adaptive capabilities.
By determining the bandwidth cutoff coefficient based on the currently used number of bits, channels and sampling points of the audio signal, layered quantization coding is performed, supporting lossy and lossless coding features, and allowing code stream truncation when the code rate changes to achieve a single frame Multiple code rate features.
It improves the channel adaptability of audio signals in the communication process, reduces algorithm complexity, avoids inefficient switching between lossy and lossless frames, and achieves efficient encoding and decoding processes.
Smart Images

Figure CN2023133321_06092024_PF_FP
Abstract
Description
Audio encoding and decoding method and related device
[0001] This application claims priority to Chinese patent application number 202310233443.4, filed on February 28, 2023, entitled “Audio Coding and Decoding Method and Related Devices,” the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of audio coding and decoding, and in particular to an audio coding and decoding method and related devices. Background Art
[0003] As people's quality of life improves, their demand for high-quality audio continues to grow. To better transmit audio signals using limited bandwidth, the audio signal is typically encoded at the encoder to generate a bitstream, which is then transmitted to the decoder. The decoder decodes the received bitstream to reconstruct the audio signal, which is then used for playback.
[0004] However, current encoding methods support either lossy or lossless encoding, but not both. This results in low switching efficiency between lossy and lossless encoding. Furthermore, when the encoding bit rate changes at the encoding end, re-encoding is required, significantly increasing the channel adaptability during audio signal transmission.
[0005] Summary of the Invention
[0006] This application provides an audio coding and decoding method and related devices that can support both lossy and lossless characteristics and improve the channel adaptability of audio signals during communication. The technical solution is as follows:
[0007] In a first aspect, an audio encoding method is provided, the method comprising: determining a current bandwidth cutoff coefficient based on a currently used number of bits, a number of channels, and a number of sampling points of an audio signal, where the currently used number of bits refers to the number of bits consumed by encoding a spectrum of a current audio frame of the audio signal before a current time; determining m subbands to be encoded from a plurality of subbands included in the spectrum based on the current bandwidth cutoff coefficient, where m is greater than or equal to 1 and less than or equal to the total number of the plurality of subbands; encoding target quantization scales corresponding to the m subbands into a bitstream based on the current bandwidth cutoff coefficient, where the target quantization scale refers to the number of bits required to encode information of a frequency band with the largest amplitude in the corresponding subband; allocating quantization bits to the m subbands based on the currently remaining quantization scales corresponding to the m subbands, where the currently remaining quantization scale refers to the quantization scale remaining unallocated after quantization bits were last allocated to the corresponding subbands; and encoding frequency band information in the m subbands into the bitstream based on the quantization bits currently allocated to the m subbands.
[0008] In this application, by performing layered quantization coding on the sub-bands included in the spectrum, when the bit rate is insufficient, it will correspond to a lossy coding state, and when the bit rate is sufficient, it will correspond to a lossless coding state. That is to say, the quantization coding method provided by this application can simultaneously support lossy and lossless coding characteristics, greatly reducing the complexity of the algorithm and avoiding inefficient switching between lossy and lossless frameworks. Moreover, in the process of layered quantization coding, by quantizing and encoding at the same time, the encoded code stream can be arbitrarily truncated when the bit rate changes. That is, the audio frame encoded by this scheme has the characteristics of single-frame multi-bit rate. Compared with the method of quantizing first and then encoding, it can avoid the situation where truncation cannot be performed when the bit rate changes and re-encoding is required, greatly improving its channel adaptability during the communication process.
[0009] The present application can perform hierarchical quantization encoding on the subbands included in the spectrum of the current audio frame of the audio signal, or perform multiple cycles of quantization encoding. Considering that it is not necessarily possible to encode to a high bandwidth at a low bit rate, it is possible to encode a higher bandwidth only when a certain bit rate is reached, that is, the frequency band information in all subbands may not be encoded at a low bit rate, and it may only be possible to encode the frequency band information in some subbands. Therefore, in each cycle of hierarchical quantization, the maximum bandwidth allowed for encoding under the current number of used bits can be determined, that is, the maximum subband to be encoded at the moment, and the maximum subband to be encoded at the moment can be determined by the current bandwidth cutoff coefficient.
[0010] Since the subbands included in the spectrum of the current audio frame of the audio signal are encoded through multiple rounds of quantization, the quantization bits allocated to the m subbands based on the current residual quantization scales corresponding to the m subbands can also be called the quantization bits currently allocated to the m subbands, or in other words, the quantization bits allocated to the m subbands in this round.
[0011] It should be noted that the quantization encoding process is performed on each audio frame. The encoder can perform quantization encoding for each audio frame according to this solution. The spectrum of the current audio frame of the audio signal refers to the spectrum obtained after the current audio frame is windowed and folded. The number of sampling points of the audio signal refers to the number of sampling points included in an audio frame.
[0012] The current bandwidth cutoff coefficient is usually a value between 0 and 1. When the current bandwidth cutoff coefficient is 1, it indicates that the bandwidth is currently full. When the current bandwidth cutoff coefficient is less than 1, it indicates that the bandwidth is currently not full.
[0013] In one possible implementation, the current cutoff frequency may be obtained by multiplying the current bandwidth cutoff coefficient by the number of sampling points of the audio signal. The subband where the current cutoff frequency is located is determined from multiple subbands included in the spectrum of the current audio frame of the audio signal. Then, subbands within the multiple subbands that are located before the subband where the current cutoff frequency is located are determined as the m subbands to be currently encoded.
[0014] It should be noted that the current bandwidth cutoff coefficient changes dynamically during each quantization cycle. Therefore, the value of m determined by the current bandwidth cutoff coefficient may vary. Furthermore, the m subbands currently to be encoded may or may not include the subband at which the current cutoff frequency is located.
[0015] Based on the description above, the current bandwidth cutoff coefficient is typically a value between 0 and 1. A value of 1 indicates full bandwidth, while a value less than 1 indicates partial bandwidth. In the full and partial bandwidth scenarios, the target quantization scales corresponding to the m subbands are encoded into the bitstream differently, as described below.
[0016] In a first case, when the current bandwidth cutoff coefficient indicates a non-full band, a target quantization scale difference between every two adjacent subbands in the m subbands is determined to obtain m-1 quantization scale differences; a minimum value and a maximum value of the m-1 quantization scale differences are determined; and if the minimum value is greater than a first threshold and the maximum value is less than a second threshold, differential coding is used to encode the target quantization scales corresponding to the m subbands into a bitstream.
[0017] When the current bandwidth cutoff coefficient indicates a non-full bandwidth, this indicates that among the target quantization scales corresponding to the m subbands, there are target quantization scales that have not been encoded into the bitstream. That is, the target quantization scales corresponding to the m subbands have not been encoded. In this case, the target quantization scales corresponding to the m subbands can be encoded into the bitstream in the above manner.
[0018] In the second case, when the current bandwidth cutoff coefficient indicates full bandwidth, it is not necessary to encode the target quantization scales corresponding to the m sub-bands into the bitstream.
[0019] When the current bandwidth cutoff coefficient indicates full bandwidth, it indicates that the target quantization scales corresponding to the m sub-bands have all been encoded into the bitstream. In this case, there is no need to encode the target quantization scales corresponding to the m sub-bands into the bitstream.
[0020] It should be noted that a subband includes multiple frequency bands, each of which has corresponding frequency band information that characterizes the corresponding frequency band. This frequency band information may include an amplitude and a sign. In other words, the value of the frequency band information may be positive or negative. When encoding the frequency band information into a bitstream, the amplitude and sign included in the frequency band information may be included in the bitstream. Typically, the amplitude and sign included in each frequency band information are encoded separately.
[0021] In the case that the current residual quantization scales corresponding to the m sub-bands are different, different ways of allocating quantization bits to the m sub-bands will be introduced below.
[0022] In the first case, when the current residual quantization scales corresponding to the m sub-bands are all 0, the quantization encoding loop of the spectrum of the audio signal is terminated.
[0023] When the current residual quantization scales corresponding to the m sub-bands are all 0, it indicates that the multiple sub-bands included in the spectrum of the audio signal have all been encoded into the bitstream. At this time, the quantization coding cycle of the multiple sub-bands can be ended and the quantization coding cycle of the sub-bands included in the next spectrum can be entered.
[0024] In the second case, when the current residual quantization scales respectively corresponding to the m subbands are not all 0 and are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
[0025] If the current remaining quantization scales corresponding to the m subbands are not all zero, it indicates that there are still uncoded subbands in the m subbands, so quantization bits need to be allocated to the m subbands. If the current remaining quantization scales corresponding to the m subbands are all smaller than the quantization step size, it indicates that the quantization bits of the m subbands are all within the range of the quantization step size, so the current remaining quantization scales corresponding to the m subbands can be directly used as the quantization bits allocated to the m subbands.
[0026] In a third case, when the current residual quantization scale of at least one subband among the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales corresponding to the m subbands to obtain masked residual quantization scales corresponding to the m subbands; based on the quantization step size, the masked residual quantization scales corresponding to the m subbands are scaled to obtain scaled residual quantization scales corresponding to the m subbands; and quantization bits are allocated to the m subbands based on the scaled residual quantization scales corresponding to the m subbands and the target quantization scales corresponding to the m subbands.
[0027] When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, it indicates that the quantization bits of some of the m subbands are not within the range of the quantization step size. Therefore, it is necessary to process the residual quantization scales corresponding to the m subbands respectively through psychoacoustic masking to achieve differentiation of the importance of the m subbands.
[0028] Because the audio signal's spectrum consists of multiple subbands that are quantized and encoded hierarchically, the frequency band information within a subband may also be quantized and encoded hierarchically. This means that different frequency bands within the same subband may reside in different quantization layers. The method for encoding the subband's frequency band information into the bitstream varies depending on the quantization layer. The following describes an example using any one of the m subbands.
[0029] In the first case, when the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, the frequency band information in the target subband is encoded into the bitstream based on the quantization bit currently allocated to the target subband using entropy coding, and the target subband is any one of the m subbands.
[0030] The current quantization level of the target subband refers to the number of quantization coding cycles in which the frequency band information of the target subband is currently encoded. The maximum quantization level is pre-set and may vary in different situations.
[0031] In the second case, when the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is encoded into the bitstream using binary coding based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0032] In the third case, when the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, the frequency band information in the target subband is encoded into the bitstream using binary coding based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0033] In one possible implementation, during the process of encoding the frequency band information of the m sub-bands into the bitstream, the current encoding bit rate may also be determined. If the current encoding bit rate is equal to the target encoding bit rate, the hierarchical quantization encoding loop of the sub-bands included in the spectrum of the current audio frame of the audio signal may be terminated.
[0034] In other words, the quantization coding cycle of a spectral subband may be terminated due to insufficient bit rate, so the intermediate state corresponds to a lossy coding state, which will be automatically encoded to lossless when the bit rate is sufficient. Therefore, this framework can support a large range of bit rate variations between lossy and lossless codecs.
[0035] The above-mentioned quantization coding process has two significant features. One is the simultaneous quantization and encoding mode. Unlike most audio codecs that separate the quantization and encoding processes, this feature enables the decoding side to decode as much information as it receives, thus achieving a single-frame multi-bitrate feature. That is, after encoding an audio frame, the encoding bit rate of the audio frame can be arbitrarily truncated, resulting in the audio frame having different bit rates. Another feature is the high symmetry of the quantization coding process on the encoding and decoding sides. That is, the decoding side has the same quantization process as the encoding side, which is different from the quantization process of most codecs in which quantization is performed on the encoding side and the decoding side only needs to decode the quantization information. In this scheme, the quantization bit allocation for each layer on the encoding side is calculated based on the number of encoded bits. Correspondingly, the quantization bit allocation for each layer on the decoding side is also calculated based on the number of decoded bits. The quantization bit allocation mechanism is the same, so both the encoding and decoding sides know how the bits are allocated in each quantization cycle.
[0036] The audio signal can be a monophonic audio signal, a dual-channel audio signal, or a multi-channel audio signal. In the embodiment of the present application, the audio signals of each channel can be quantized and encoded separately, or the audio signals of each channel can be mixed together for quantization and encoding.
[0037] As an example, an audio signal has side information, and the side information includes a coding flag. When the coding flag is a first value, the audio signal is a single-channel audio signal, that is, the audio signals of each channel are quantized and encoded separately. When the coding flag is a second value, the audio signal is a multi-channel audio signal, that is, the audio signals of each channel are mixed together and quantized and encoded.
[0038] Separately quantizing and encoding the audio signals of each channel facilitates separate transmission or decoding of the bitstreams of each channel. In this case, the bitrates of each channel are evenly distributed. Mixing the audio signals of each channel together for quantization encoding performs layered quantization encoding on a channel-by-channel basis. In this case, the bitrates of each channel are dynamically allocated, achieving a relatively optimal bitrate distribution. In other words, separate quantization encoding results in the bitstreams of each channel supporting multiple bitrates per frame, while mixed quantization encoding results in the mixed bitstreams of each channel supporting multiple bitrates per frame.
[0039] In a second aspect, an audio decoding method is provided, the method comprising: determining a current bandwidth cutoff coefficient based on a currently used number of bits, a number of channels, and a number of sampling points of an audio signal, where the currently used number of bits refers to the number of bits consumed by decoding the spectrum of a current audio frame of the audio signal before a current time; determining m subbands to be decoded from multiple subbands included in the spectrum based on the current bandwidth cutoff coefficient, where m is greater than or equal to 1 and less than or equal to the total number of the multiple subbands; parsing target quantization scales corresponding to the m subbands from a bitstream based on the current bandwidth cutoff coefficient, where the target quantization scale refers to the number of bits required to encode information of a frequency band with the largest amplitude in the corresponding subband; allocating quantization bits to the m subbands based on current remaining quantization scales corresponding to the m subbands, where the current remaining quantization scale refers to the quantization scale remaining unallocated after quantization bits were last allocated to the corresponding subbands; and parsing frequency band information for the m subbands from the bitstream based on the quantization bits currently allocated to the m subbands.
[0040] In the present application, by performing hierarchical quantization encoding on the sub-bands included in the spectrum, it is possible to support both lossy and lossless coding characteristics. Therefore, the decoding side can also support both lossy and lossless decoding characteristics, greatly reducing the complexity of the algorithm and avoiding inefficient switching between lossy and lossless frameworks. Moreover, in the process of hierarchical quantization decoding, by quantizing and decoding at the same time, no matter how much information is sent by the encoding side, the decoding side can parse it out from the code stream, greatly improving the channel adaptability of the code stream during the communication process. In addition, when the decoding side determines through analysis that the information of a certain frequency band is not lossless, it can also fill the value of the frequency band information by filling the low-order bits, reducing the overall quantization error, and effectively compensating for the reduction in the amplitude of the audio signal due to bit loss under lossy coding.
[0041] Since the subbands included in the spectrum of the current audio frame of the audio signal are decoded through multiple rounds of quantization, the quantization bits allocated to the m subbands based on the current residual quantization scales corresponding to the m subbands can also be called the quantization bits currently allocated to the m subbands, or in other words, the quantization bits allocated to the m subbands in this round.
[0042] The current bandwidth cutoff coefficient is typically a value between 0 and 1. A value of 1 indicates full bandwidth, while a value less than 1 indicates partial bandwidth. In the full and partial bandwidth cases, the target quantization scales corresponding to the m subbands are encoded into the bitstream differently, as described below.
[0043] In the first case, when the current bandwidth cutoff coefficient indicates a non-full bandwidth, the target quantization scales corresponding to the m sub-bands are parsed from the bitstream.
[0044] When the current bandwidth cutoff coefficient indicates a non-full bandwidth, this indicates that there are unsolved target quantization scales among the target quantization scales corresponding to the m subbands. That is, the target quantization scales corresponding to the m subbands have not been fully resolved. In this case, the target quantization scales corresponding to the m subbands can be resolved from the bitstream.
[0045] In the second case, when the current bandwidth cutoff coefficient indicates a full band, there is no need to parse the target quantization scales corresponding to the m sub-bands from the bitstream.
[0046] When the current bandwidth cutoff coefficient indicates full bandwidth, it indicates that the target quantization scales corresponding to the m subbands have been parsed from the bitstream. In this case, there is no need to parse the target quantization scales corresponding to the m subbands from the bitstream.
[0047] In the case that the current residual quantization scales corresponding to the m sub-bands are different, different ways of allocating quantization bits to the m sub-bands will be introduced below.
[0048] In the first case, when the current residual quantization scales corresponding to the m sub-bands are all 0, the quantization decoding loop of the spectrum of the audio signal is terminated.
[0049] When the current residual quantization scales corresponding to the m sub-bands are all 0, it indicates that all the sub-bands included in the spectrum of the audio signal have been parsed from the bitstream. At this time, the quantization decoding loop for the multiple sub-bands can be ended and the quantization decoding loop for the sub-band included in the next spectrum can be entered.
[0050] In the second case, when the current residual quantization scales respectively corresponding to the m subbands are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
[0051] If the current remaining quantization scales corresponding to the m subbands are not all zero, it indicates that there are still undecoded subbands among the m subbands, and therefore quantization bits need to be allocated to the m subbands. If the current remaining quantization scales corresponding to the m subbands are all smaller than the quantization step size, it indicates that the quantization bits corresponding to the m subbands are all within the range of the quantization step size, and therefore the current remaining quantization scales corresponding to the m subbands can be directly used as the quantization bits allocated to the m subbands.
[0052] In a third case, when the current residual quantization scale of at least one subband among the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales corresponding to the m subbands to obtain masked residual quantization scales corresponding to the m subbands; based on the quantization step size, the masked residual quantization scales corresponding to the m subbands are scaled to obtain scaled residual quantization scales corresponding to the m subbands; and quantization bits are allocated to the m subbands based on the scaled residual quantization scales corresponding to the m subbands and the target quantization scales corresponding to the m subbands.
[0053] Because the spectrum of the current audio frame of the audio signal includes multiple subbands that are decoded using hierarchical quantization, and the frequency band information within a subband may also be decoded using hierarchical quantization, different frequency band information within the same subband may be at different quantization layers. When the subband channels are at different quantization layers, the method for parsing the frequency band information from the bitstream varies. The following describes an example using any one of the m subbands.
[0054] In the first case, when the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, entropy decoding is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
[0055] The current quantization level of the target subband refers to the number of quantization decoding cycles in which the frequency band information of the target subband is currently decoded. The maximum quantization level is pre-set and may vary in different situations.
[0056] In the second case, when the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is parsed from the bitstream using a binary decoding method based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0057] In the third case, when the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, based on the quantization bits currently allocated to the target subband, a binary decoding method is used to parse the frequency band information in the target subband from the bit stream, and the target subband is any one of the m subbands.
[0058] In a possible implementation, after parsing frequency band information in the m subbands from the bitstream based on quantization bits currently allocated to the m subbands, the method further includes:
[0059] When the target subband is parsed, if the number of bits parsed out of the target frequency band information of the target subband is less than the target quantization scale of the target subband, low-order bits are padded on the target frequency band information, where the target subband is any one of the m subbands, and the target frequency band information is frequency band information of any one of the target subbands.
[0060] If the number of bits parsed from the target subband's target frequency band information is less than the target quantization scale of the target subband, indicating that the quantization coding of the target frequency band information is not lossless, low-order bit padding can be performed on the target frequency band information to reduce the overall quantization error and effectively compensate for the reduction in audio signal amplitude caused by missing bits under lossy coding. During the low-order bit padding process, random padding with 0s and 1s can be performed, and the probability of padding with 0s and 1s is equal.
[0061] In a third aspect, an audio encoding device is provided, wherein the audio encoding device has the function of implementing the audio encoding method of the first aspect. The audio encoding device includes at least one module, wherein the at least one module is used to implement the audio encoding method provided in the first aspect.
[0062] In a fourth aspect, an audio decoding device is provided, wherein the audio decoding device has the function of implementing the audio decoding method of the first aspect. The audio decoding device includes at least one module, wherein the at least one module is used to implement the audio decoding method provided in the second aspect.
[0063] In a fifth aspect, an audio encoding device is provided, comprising a processor and a memory, wherein the memory is configured to store a computer program for executing the audio encoding method provided in the first aspect. The processor is configured to execute the computer program stored in the memory to implement the audio encoding method described in the first aspect.
[0064] Optionally, the audio encoding device may further include a communication bus, which is used to establish a connection between the processor and the memory.
[0065] In a sixth aspect, an audio decoding device is provided, comprising a processor and a memory, wherein the memory is configured to store a computer program for executing the audio decoding method provided in the first aspect. The processor is configured to execute the computer program stored in the memory to implement the audio decoding method described in the first aspect.
[0066] Optionally, the audio decoding device may further include a communication bus, which is used to establish a connection between the processor and the memory.
[0067] In the seventh aspect, a computer-readable storage medium is provided, wherein the storage medium stores instructions. When the instructions are executed on a computer, the computer executes the audio encoding method described in the first aspect or the audio decoding method described in the second aspect.
[0068] In an eighth aspect, a computer program product comprising instructions is provided. When the instructions are executed on a computer, the computer is caused to perform the audio encoding method described in the first aspect or the audio decoding method described in the second aspect. Alternatively, a computer program is provided. When the computer program is executed on a computer, the computer is caused to perform the audio encoding method described in the first aspect or the audio decoding method described in the second aspect.
[0069] The technical effects obtained in the above-mentioned third to eighth aspects are similar to the technical effects obtained by the corresponding technical means in the first or second aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] FIG1 is a schematic diagram of a Bluetooth interconnection scenario provided by an embodiment of the present application;
[0071] FIG2 is a system framework diagram of an audio signal processing method provided in an embodiment of the present application;
[0072] FIG3 is a diagram of an overall framework of an audio codec provided in an embodiment of the present application;
[0073] FIG4 is a flowchart of an audio encoding method provided in an embodiment of the present application;
[0074] FIG5 is a schematic diagram of the principle of Huffman coding provided in an embodiment of the present application;
[0075] FIG6 is a schematic diagram of a quantization encoding process provided in an embodiment of the present application;
[0076] FIG7 is a schematic diagram of a quantization coding mechanism provided in an embodiment of the present application;
[0077] FIG8 is a flowchart of an audio decoding method provided in an embodiment of the present application;
[0078] FIG9 is a schematic diagram of the principle of Huffman decoding provided in an embodiment of the present application;
[0079] FIG10 is a schematic structural diagram of an audio encoding device provided in an embodiment of the present application;
[0080] FIG11 is a schematic structural diagram of an audio decoding device provided in an embodiment of the present application;
[0081] FIG12 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0082] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0083] First, the implementation environment and background knowledge involved in the embodiments of this application are introduced.
[0084] With the widespread popularity and use of wireless Bluetooth devices such as true wireless stereo (TWS) headphones, smart speakers and smart watches in people's daily lives, people's demand for high-quality audio playback experience in various scenarios has become increasingly urgent, especially in environments where Bluetooth signals are susceptible to interference, such as subways, airports, and train stations. In Bluetooth interconnection scenarios, due to the limitations of the Bluetooth channel connecting the audio sending device and the audio receiving device on the data transmission size, when transmitting audio signals, in order to reduce the bandwidth occupied by the audio signal transmission, the audio encoder in the audio sending device is usually used to encode the audio signal and then transmit it to the audio receiving device. After the audio receiving device receives the encoded audio signal, it needs to use the audio decoder in the audio receiving device to decode the encoded audio signal before it can be played. It can be seen that the popularization of wireless Bluetooth devices has also promoted the vigorous development of various Bluetooth audio codecs.
[0085] Currently, Bluetooth audio codecs include sub-band coding (SBC), the Moving Picture Experts Group (MPEG)'s Bluetooth advanced audio coding (AAC) series (such as AAC-LC, AAC-LD, AAC-HE, AAC-HEv2, etc.), the aptX series (such as aptX, aptX HD, aptX low latency) encoders, low-latency hi-definition audio codec (LHDC), the low-power and low-latency LC3 audio codec, and LC3plus.
[0086] It should be understood that the audio encoding and decoding method provided in the embodiment of the present application can be applied to an audio transmitting device (i.e., encoding end) and an audio receiving device (i.e., decoding end) in a Bluetooth interconnection scenario. Of course, in practical applications, it can also be applied to other short-range transmission scenarios. The embodiment of the present application is introduced using the Bluetooth interconnection scenario as an example.
[0087] Figure 1 is a schematic diagram of a Bluetooth interconnection scenario provided by an embodiment of the present application. Referring to Figure 1, the Bluetooth interconnection scenario includes an audio sending device and an audio receiving device. The audio sending device is configured with an audio encoder. The audio receiving device is configured with an audio decoder. The audio sending device can be a mobile phone, a computer, a tablet, etc. Among them, the computer can be a laptop computer, a desktop computer, etc., and the tablet can be a handheld tablet, a car-mounted tablet, etc. The audio receiving device can be a TWS headset, a smart speaker, a wireless headset, a wireless neckband headset, a smart watch, smart glasses, a smart car-mounted device, etc. In other embodiments, the audio receiving device in the Bluetooth interconnection scenario can also be a mobile phone, a computer, a tablet, etc.
[0088] It should be noted that the audio encoding and decoding method provided in the embodiment of the present application can be applied to other device interconnection scenarios in addition to Bluetooth interconnection scenarios. In other words, the system architecture and business scenarios described in the embodiment of the present application are intended to more clearly illustrate the technical solutions of the embodiment of the present application and do not constitute a limitation on the technical solutions provided in the embodiment of the present application. Those skilled in the art will know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiment of the present application are also applicable to similar technical problems.
[0089] FIG2 is a system framework diagram of the audio signal processing method provided in an embodiment of the present application. Referring to FIG2 , the system includes an encoding end and a decoding end. The encoding end includes an input module, an encoding module, and a transmitting module. The decoding end includes a receiving module, an input module, a decoding module, and a playback module.
[0090] On the encoder side, the user needs to provide the audio signal to be encoded (Pulse Code Modulation (PCM) data, as shown in Figure 2). The user also needs to set the target bit rate for the resulting encoded stream, i.e., the encoding bit rate of the audio signal. A higher target bit rate indicates better sound quality, but also worse interference resistance during short-distance transmission. A lower target bit rate indicates worse sound quality, but better interference resistance during short-distance transmission.
[0091] In addition, the user also needs to set other configuration information, such as encoding mode, frame length, delay information, etc. Among them, the embodiment of the present application can provide two encoding modes, which are low-delay encoding mode and high-quality sound encoding mode. The user determines one encoding mode from the two encoding modes according to the usage scenario. For example, if the usage scenario is playing games, live broadcast, making calls, etc., the user can choose the low-delay encoding mode, and if the usage scenario is enjoying music through headphones or speakers, the user can choose the high-quality sound encoding mode. Frame length refers to the length of a frame of audio signal, which can be measured by time. For example, for the above two encoding modes, the frame length of the low-delay encoding mode is 5 milliseconds (ms), and the frame length of the high-quality sound encoding mode is 10ms. Delay information refers to whether low-delay transformation is used when encoding audio signals.
[0092] Simply put, the input module of the encoding end obtains the target bit rate, the audio signal to be encoded, and other configuration information submitted by the user. After the input module of the encoding end obtains the user-submitted data, it inputs the user-submitted data into the frequency domain encoder of the encoding module.
[0093] The frequency domain encoder in the encoding module encodes the received data to generate a bitstream. The frequency domain encoder analyzes the audio signal to be encoded to determine its characteristics (including mono / dual channel, stationary / non-stationary, full-bandwidth / narrow-bandwidth signals, etc.). Based on the signal characteristics and the bitrate level (i.e., the target bitrate), the encoder enters the corresponding encoding processing submodule, which encodes the audio signal and the packet header of the packet stream (including sampling rate, number of channels, encoding mode, frame length, etc.), ultimately generating the bitstream.
[0094] The transmitting module at the encoding end transmits the code stream to the decoding end. For example, the transmitting module modulates the code stream of the digital signal into an analog signal and then transmits it wirelessly via an antenna. Optionally, the transmitting module is a short-range transmitting module as shown in FIG2 or another type of transmitting module. The short-range transmitting module may be a Bluetooth or wireless network, which is not limited in this embodiment of the present application.
[0095] At the decoding end, the receiving module of the decoding end receives the code stream, sends the code stream to the frequency domain decoder of the decoding module, and notifies the input module of the decoding end to obtain the configured audio signal bit depth, configuration information, channel decoding mode, etc. For example, the receiving module receives an analog signal via wireless waves and then demodulates the analog signal into a digital signal code stream. Optionally, the receiving module is a short-range receiving module as shown in Figure 2 or other types of receiving modules, and the short-range transmitting module can be Bluetooth or wireless network, which is not limited in this embodiment of the present application.
[0096] The input module of the decoding end inputs information such as the bit depth, configuration information, and channel decoding mode of the audio signal into the frequency domain decoder of the decoding module.
[0097] The frequency domain decoder of the decoding module parses the code stream based on the bit depth, configuration information, channel decoding mode, etc. of the audio signal to obtain the required audio data (PCM data as shown in Figure 2), and sends the obtained audio data to the playback module, which plays the audio. Among them, the channel decoding mode indicates the channel to be decoded. The channel decoding mode can be indicated by a flag bit, which can be a first value, a second value, or a third value. The first value indicates the left channel output, the second value indicates the right channel value, and the third value indicates the stereo output. For example, the first value is 0, the second value is 1, and the third value is 2.
[0098] Next, the encoding part and the decoding part in the system architecture shown in Figure 2 are explained in detail. Please refer to Figure 3, which is an overall framework diagram of an audio codec provided by an embodiment of the present application. There are two data streams in Figure 3, one is the control data stream (shown by the solid line), which is the data stream obtained by a series of algorithm processing after the audio signal enters the frequency domain encoder and the code stream enters the frequency domain decoder; the other is the coded data stream (shown by the dotted line), which is the data part that needs to be encoded into a bit stream and transmitted wirelessly, as well as the data stream that needs to be parsed on the decoding side.
[0099] The coding part includes the following modules:
[0100] (1) PCM input module
[0101] Input PCM data, which can be mono, dual, or multi-channel data. The bit depth of the PCM data can be 16-bit, 24-bit, 32-bit floating point, or 32-bit fixed point, and the supported sampling rates can be 44.1 kHz, 48 kHz, 88.2 kHz, 96 kHz, etc. Optionally, the PCM input module converts the input PCM data to a uniform bit depth, such as 24 bits, deinterleaves the PCM data, and places it according to each channel.
[0102] (2) Stream header encoding module
[0103] The sampling rate (such as 44.1kHz / 48kHz / 88.2kHz / 96kHz), number of channels (such as mono and dual channels), bit depth, frame length (such as 5ms and 10ms), and coding mode (such as time domain, frequency domain, time domain-to-frequency domain, or frequency domain-to-time domain mode) of PCM data are encoded into the bitstream.
[0104] (3) Low 8-bit processing module
[0105] Check whether the lower 8 bits of the PCM data are all 0. If so, shift the sampling rate of the PCM data right by 8 bits. Otherwise, keep the sampling rate unchanged. Then, encode the flag indicating whether the sampling rate of the PCM data is shifted into the bitstream.
[0106] In some cases, a 16-bit audio source will be converted to 24-bit, or a 24-bit audio source will be converted to 32-bit, or a 16-bit audio source will be converted to 32-bit. Therefore, by shifting the sampling rate of PCM data, the compression rate can be effectively improved.
[0107] (4) Integer windowing and INTMDCT transformation module
[0108] After integer windowing and INTMDCT transformation of the PCM data processed by module (3), spectrum data in the INTMDCT domain is obtained, that is, the spectrum of each frame of audio signal. The purpose of windowing is to prevent spectrum leakage.
[0109] The INTMDCT is similar to the MDCT, consisting of two main processes: windowing and folding, and the fourth type of DCT (i.e., DCT-IV). The windowing and folding process of the INTMDCT differs from that of the MDCT, and the DCT-IV transform is also an integer time-frequency transform. The INTMDCT's input PCM data and output spectrum are both integers. Its inverse transform (i.e., the integer inverse modified discrete cosine transform (INTIMDCT)) can restore the integer spectrum to integer PCM data, achieving complete bit-to-bit consistency with the input PCM data, except for a few points of sequence delay, unlike the floating-point calculation errors of the MDCT transform.
[0110] (5)INTMS channel conversion module
[0111] INTMS channel conversion, namely integer mid / side (INTMS) channel conversion, may also be called integer mid / side stereo transform coding (INTMS conversion for short).
[0112] The spectrum of each frame of audio data determined by module (4) is the spectrum of the left and right (LR) channels. At this time, the spectrum of the LR channels is divided into subbands, and the sum of the subband quantization scales of the LR channels is determined, that is, the sum of the quantization scales of each subband of the LR channels. The quantization scale refers to the number of bits required to encode the frequency band information with the largest amplitude in the corresponding subband. At the same time, the spectrum of the LR channels is converted into the spectrum of the MS channel, and the spectrum of the MS channel is divided into subbands, and the sum of the subband quantization scales of the MS channel is determined, that is, the sum of the quantization scales of each subband of the MS channel. If the sum of the quantization scales of the MS channels is less than the sum of the quantization scales of the LR channels, the spectrum of the LR channels is subjected to INTMS transformation.
[0113] It should be noted that the INTMS channel conversion is for dual-channel PCM data. That is, for dual-channel PCM data, after the spectrum data is calculated according to the above module (4), the sum of the quantization scales of the LR channels and the sum of the quantization scales of the MS channel are used for joint coding discrimination to determine whether to perform the INTMS channel conversion on the left and right channel data. For monophonic data and multi-channel data larger than dual channels, the INTMS conversion is not required.
[0114] After the joint judgment is performed, the flag indicating whether to perform INTMS channel conversion can also be encoded into the code stream.
[0115] (6) Subband quantization scale segment coding module
[0116] For a frame of audio signal processed by module (5), the embodiment of the present application performs hierarchical quantization coding on the subbands included in the spectrum of the frame of audio signal, or performs multiple rounds of quantization coding, that is, the multiple subbands included in the spectrum are divided into multiple parts, and the subbands of two adjacent parts may overlap or not overlap. After a part of the subband is quantized and coded, the next part of the subband is quantized and coded. Therefore, based on information such as the number of currently used bits, the number of channels, and the number of sampling points, the maximum bandwidth currently allowed for coding and the corresponding subbands can be determined, and these subbands can be used as the subbands currently to be coded. Then, the subbands whose quantization scales have not been coded in the subbands currently to be coded are determined, and the quantization scales of these subbands are encoded into the bitstream.
[0117] (7) Subband masking module
[0118] For the sub-band to be coded currently determined by module (6), a psychoacoustic masking method is adopted to perform sub-band masking on the quantization scale of the sub-band to be coded currently through adjacent sub-bands, thereby obtaining the quantization scale after sub-band masking.
[0119] (8) Quantization bit allocation module
[0120] The quantization scale after the sub-band masking calculation by module (7) is scaled to within the quantization step size, and then, based on the scaled quantization scale, quantization bits are allocated to each sub-band to be encoded.
[0121] For each cycle, the quantization step size may be the same or different.
[0122] (9) Subband quantization scale update module
[0123] After allocating quantization bits to the sub-bands to be encoded currently through module (8), the remaining quantization scales of these sub-bands are updated based on the quantization bits allocated to these sub-bands, and the next cycle is entered.
[0124] (10) Frequency band information encoding module
[0125] After allocating quantization bits to each sub-band to be encoded by module (8), frequency band information in these sub-bands is encoded into a bit stream by entropy coding or binary coding based on the quantization bits allocated to each sub-band.
[0126] The entropy coding may be Huffman coding, and of course, may be other coding methods.
[0127] The decoding part includes the following modules:
[0128] (1) Stream header parsing module
[0129] The packet header information is parsed from the received bitstream. The packet header information includes the sampling rate, channel information, frame length, encoding mode and other information of the audio signal. The target bitrate, i.e. the encoding bitrate or bitrate gear information, is calculated based on the bitstream size, sampling rate and frame length.
[0130] (2) Side information decoding module
[0131] Decode side information from the bitstream, including the flag indicating whether the sampling rate of the PCM data is shifted, the flag indicating whether INTMS channel conversion is performed, the quantization step size, and other configuration information.
[0132] (3) Subband quantization scale segment decoding module
[0133] When layered quantization or cyclic quantization is performed on the encoding side, layered decoding or cyclic decoding is also performed on the decoding side. That is, based on information such as the currently used number of bits, number of channels, and number of sampling points, the highest bandwidth and corresponding subbands allowed for decoding are calculated. These subbands are then used as the subbands to be decoded. The subbands whose quantization scales have not yet been decoded are then determined and the quantization scales of these subbands are extracted from the bitstream.
[0134] (4) Subband masking module
[0135] For the sub-band to be decoded currently determined by module (3), a psychoacoustic masking method is adopted to perform sub-band masking on the quantization scale of the sub-band to be decoded currently through adjacent sub-bands, thereby obtaining the quantization scale after sub-band masking.
[0136] (5) Quantization bit allocation module
[0137] The quantization scale after the sub-band masking calculation by module (4) is scaled to within the quantization step size, and then, based on the scaled quantization scale, quantization bits are allocated to each sub-band to be decoded.
[0138] For each cycle, the quantization step size may be the same or different.
[0139] (6) Subband quantization scale update module
[0140] After allocating quantization bits to the sub-bands to be decoded currently through module (5), the remaining quantization scales of these sub-bands are updated based on the quantization bits allocated to these sub-bands, and the next cycle is entered.
[0141] (7) Frequency band information decoding module
[0142] After allocating quantization bits to each sub-band to be decoded currently through module (5), frequency band information in these sub-bands is decoded from the code stream through entropy decoding or binary decoding based on the quantization bits allocated to each sub-band.
[0143] The entropy decoding may be Huffman decoding, and of course, may also be other decoding methods.
[0144] (8)INTMS channel inverse transformation module
[0145] After the spectrum data is parsed by module (7), whether to perform INTMS channel inverse transformation is determined based on the flag bit of whether to perform INTMS channel transformation parsed from the code stream by module (2). If INTMS channel inverse transformation is required, the INTMS channel inverse transformation is performed on the parsed spectrum data to obtain spectrum data of the LR channels.
[0146] The INTMS inverse channel transform is also called integer inverse mid / side (INTIMS) channel transform, or integer inverse mid / side stereo transform coding (INTIMS transform for short).
[0147] (9)INTIMDCT transform and integer windowing module
[0148] The spectrum data of the LR channels obtained by module (8) is subjected to INTIMDCT transformation and integer windowing to obtain PCM data.
[0149] The INTIMDCT is similar to the IMDCT, consisting of two main steps: the DCT-IV transform and the windowing and expansion. However, the DCT-IV transform and windowing and expansion steps of the INTIMDCT are different from those of the IMDCT. The input spectrum and output PCM of the INTIMDCT are both integers.
[0150] (10) Low 8-bit processing module
[0151] Based on the flag bit indicating whether the sampling rate of the PCM data parsed from the code stream by module (2) is shifted, it is determined whether the sample point value of the PCM data obtained by module (9) is shifted left by 8 bits.
[0152] (11) PCM output module
[0153] Outputs PCM data of the corresponding channel according to the configured bit depth and channel decoding mode.
[0154] (12) Low bit rate feature module
[0155] The decoding side provides several optional modules for lossy decoding to improve sound quality. Low-order bit padding is used to fill the undecoded low-order bits with random bits for frequency band information where the high-order bits are decoded but the low-order bits are not. Spectral hole filling replaces frequency band information where the subband quantization scale is non-zero but the decoded value is zero by generating random numbers based on the subband quantization scale. Time-domain band extension expands the output PCM bandwidth to the full bandwidth.
[0156] It should be noted that the audio codec framework shown in FIG3 is only an example of a terminal in an embodiment of the present application and is not used to limit the embodiment of the present application. Those skilled in the art can derive other codec frameworks based on FIG3.
[0157] Next, the quantization encoding process provided by the embodiment of the present application is introduced. Figure 4 is a flowchart of an audio encoding method provided by the embodiment of the present application, which is applied to the encoding end. Please refer to Figure 4, the method includes the following steps.
[0158] Step 401: Determine a current bandwidth cutoff coefficient based on the current number of used bits, the number of channels, and the number of sampling points of the audio signal. The current number of used bits refers to the number of bits consumed by the spectrum of the current audio frame of the audio signal encoded before the current time.
[0159] Based on the above description, the embodiment of the present application can perform hierarchical quantization encoding on the subbands included in the spectrum of the current audio frame of the audio signal, or perform multiple cycles of quantization encoding. Considering that it is not necessarily possible to encode to a high bandwidth at a low bit rate, it is possible to encode a higher bandwidth only when a certain bit rate is reached, that is, it is not necessarily possible to encode the frequency band information in all subbands at a low bit rate, and it may only be possible to encode the frequency band information in some subbands. Therefore, in each cycle of hierarchical quantization, the maximum bandwidth allowed for encoding under the current number of used bits can be determined, that is, the maximum subband to be encoded at the current time, and the maximum subband to be encoded at the current time can be determined by the current bandwidth cutoff coefficient.
[0160] In some embodiments, the current bandwidth cutoff coefficient may be determined based on the currently used number of bits, the number of channels, and the number of sampling points of the audio signal according to the following formula (1):
[0161] In the above formula (1), cutOffRatio represents the current bandwidth cutoff coefficient, bandLimitCoef represents the adjustment parameter of the current bandwidth cutoff coefficient, which is a constant, bitCount represents the number of bits currently used, nChannel represents the number of channels of the audio signal, and frameLen represents the number of sampling points of the audio signal.
[0162] It should be noted that the quantization encoding process is performed on each audio frame. The encoder can perform quantization encoding for each audio frame according to this solution. The spectrum of an audio signal refers to the spectrum obtained after windowing and folding an audio frame. The number of sampling points of the audio signal refers to the number of sampling points included in an audio frame.
[0163] The current bandwidth cutoff coefficient is usually a value between 0 and 1. When the current bandwidth cutoff coefficient is 1, it indicates that the bandwidth is currently full. When the current bandwidth cutoff coefficient is less than 1, it indicates that the bandwidth is currently not full.
[0164] Step 402: Based on the current bandwidth cutoff coefficient, determine m subbands to be encoded from multiple subbands included in the spectrum of the current audio frame, where m is greater than or equal to 1 and less than or equal to the total number of the multiple subbands.
[0165] In some embodiments, the current bandwidth cutoff coefficient may be multiplied by the number of sampling points of the audio signal to obtain the current cutoff frequency. The subband where the current cutoff frequency is located is determined from multiple subbands included in the spectrum of the current audio frame, and the subbands before the subband where the current cutoff frequency is located in the multiple subbands are determined as the m subbands to be currently encoded.
[0166] It should be noted that in each quantization cycle, the current bandwidth cutoff coefficient will change dynamically, so the value of m determined by the current bandwidth cutoff coefficient may be different.
[0167] In addition, the m sub-bands to be encoded may include the sub-band where the current cutoff frequency is located, or may not include the sub-band where the current cutoff frequency is located, and this embodiment of the present application does not limit this.
[0168] Step 403: Based on the current bandwidth cutoff coefficient, the target quantization scales corresponding to the m sub-bands are encoded into the bitstream. The target quantization scale refers to the number of bits required to encode the frequency band information with the maximum amplitude in the corresponding sub-band.
[0169] Based on the description above, the current bandwidth cutoff coefficient is typically a value between 0 and 1. A value of 1 indicates full bandwidth, while a value less than 1 indicates partial bandwidth. In the full and partial bandwidth scenarios, the target quantization scales corresponding to the m subbands are encoded into the bitstream differently, as described below.
[0170] In the first case, when the current bandwidth cutoff coefficient indicates a non-full band, the target quantization scale difference between every two adjacent subbands in the m subbands is determined to obtain m-1 quantization scale differences; the minimum and maximum values of the m-1 quantization scale differences are determined; and if the minimum value is greater than a first threshold and the maximum value is less than a second threshold, the target quantization scales corresponding to the m subbands are encoded into the bitstream using a differential coding method.
[0171] When the current bandwidth cutoff coefficient indicates a non-full bandwidth, this indicates that among the target quantization scales corresponding to the m subbands, there are target quantization scales that have not been encoded into the bitstream. That is, the target quantization scales corresponding to the m subbands have not been encoded. In this case, the target quantization scales corresponding to the m subbands can be encoded into the bitstream in the above manner.
[0172] The method for determining the target quantization scale difference between each two adjacent sub-bands in the m sub-bands can be expressed by the following formula (2), the method for determining the minimum and maximum values of the m-1 quantization scale differences can be expressed by the following formulas (3) and (4), and whether to adopt the differential coding method can be expressed by the following expression (5); bandQsTmp[b]=bandQs[b]-bandQs[b-1],b=1,2,…,nband (2) bandQsMin=Min(bandQsTmp[b],b=1,2,…,nband) (3) bandQsMax=Max(bandQsTmp[b],b=1,2,…,nband) (4) bandQsDiff=True if(bandQsMin>H1and bandQsMax <H2)else False (5)
[0173] In the above formula, bandQsTmp[b] represents the quantization scale difference, bandQs[b] represents the target quantization scale of the b-th subband, bandQs[b-1] represents the target quantization scale of the b-1-th subband, nband represents the total number of m subbands, bandQsMin represents the minimum value of the m-1 quantization scale differences, bandQsMax represents the maximum value of the m-1 quantization scale differences, bandQsDiff represents the use of differential coding, H1 represents the first threshold, and H2 represents the second threshold.
[0174] It should be noted that the above-mentioned first threshold and second threshold are obtained in advance through statistics. For example, the first threshold is -5 and the second threshold is 5. In different situations, the values of the first threshold and the second threshold may be different.
[0175] In some embodiments, the implementation process of encoding the target quantization scales corresponding to the m subbands into the bitstream using a differential coding method includes: for a first subband among the m subbands, using a non-differential entropy coding method to encode the target quantization scale of the first subband among the m subbands into the bitstream; for non-first subbands among the m subbands, subtracting the target quantization scale of the adjacent previous subband from the target quantization scale of the subband to obtain a quantization scale difference, and encoding the quantization scale difference into the bitstream using an entropy coding method.
[0176] Optionally, if the minimum value is not greater than the first threshold or the maximum value is not less than the second threshold, the target quantization scales corresponding to the m subbands are encoded into the bitstream using a non-differential encoding method. That is, the target quantization scale of each of the m subbands is directly encoded into the bitstream using an entropy encoding method.
[0177] It should be noted that the entropy coding may be Huffman coding or other coding methods, which are not limited in the present embodiment. Moreover, the encoding side may also encode the coding methods of the m subbands into the bitstream, that is, whether the m subbands are encoded using a differential coding method or a non-differential coding method.
[0178] When the entropy coding is Huffman coding, the coding codebook used by the non-differential entropy coding method is as follows:
[0179] {{0,244,8}, {1,245,8}, {2,246,8}, {3,247,8}, {4,248,8}, {5,249,8},
[0180] {6,250,8}, {7,251,8}, {8,252,8}, {9,116,7}, {10,117,7}, {11,118,7},
[0181] {12,56,6}, {13,24,5}, {14,25,5}, {15,26,5}, {16,8,4}, {17,9,4},
[0182] {18,10,4}, {19,0,3}, {20,1,3}, {21,2,3}, {22,3,3}, {23,11,4},
[0183] {24,27,5}, {25,57,6}, {26,119,7}, {27,253,8}, {28,254,8}, {29,120,7},
[0184] {30,121,7}, {31,255,8}};
[0185] When the entropy coding is Huffman coding, the encoding codebook used by the differential entropy coding method is as follows:
[0186] {{0,124,7}, {1,50,6}, {2,63,6}, {3,30,5}, {4,5,4}, {5,13,4},
[0187] {6,0,3}, {7,3,3}, {8,5,3}, {9,4,3}, {10,1,3}, {11,14,4},
[0188] {12,4,4}, {13,24,5}, {14,51,6}, {15,125,7}};
[0189] In the second case, when the current bandwidth cutoff coefficient indicates full bandwidth, it is not necessary to encode the target quantization scales corresponding to the m sub-bands into the bitstream.
[0190] When the current bandwidth cutoff coefficient indicates full bandwidth, it indicates that the target quantization scales corresponding to the m sub-bands have been encoded into the bitstream. In this case, there is no need to encode the target quantization scales corresponding to the m sub-bands into the bitstream.
[0191] In some embodiments, based on the current bandwidth cutoff coefficient, before encoding the target quantization scales corresponding to the m sub-bands into the bitstream, the target quantization scales corresponding to the m sub-bands may be determined.
[0192] For example, for any one of the m sub-bands, the target quantization scale of the sub-band can be determined according to the following formula (6) based on the frequency band information with the largest amplitude in the sub-band:
[0193] In the above formula (6), bandQs b represents the target quantization scale of the b-th subband, f max Indicates the maximum amplitude of the frequency band information in the b-th sub-band, which is a positive number.
[0194] For 24-bit PCM data, after the PCM data is time-frequency transformed, the number of bits required for encoding each frequency band information in the spectrum corresponding to the PCM data is usually in the range of 0 to 31.
[0195] It should be noted that a subband includes multiple frequency bands, each of which has corresponding frequency band information that characterizes the corresponding frequency band. This frequency band information may include an amplitude and a sign. In other words, the value of the frequency band information may be positive or negative. When encoding the frequency band information into a bitstream, the amplitude and sign included in the frequency band information may be included in the bitstream. Typically, the amplitude and sign included in each frequency band information are encoded separately.
[0196] Step 404: Allocate quantization bits to the m subbands based on the current remaining quantization scales corresponding to the m subbands, where the current remaining quantization scale refers to the quantization scale remaining unallocated after quantization bits were allocated to the corresponding subbands last time.
[0197] In the case that the current residual quantization scales corresponding to the m sub-bands are different, different ways of allocating quantization bits to the m sub-bands will be introduced below.
[0198] In the first case, when the current residual quantization scales corresponding to the m sub-bands are all 0, the quantization encoding loop of the spectrum of the audio signal is terminated.
[0199] When the current residual quantization scales corresponding to the m sub-bands are all 0, it indicates that the multiple sub-bands included in the spectrum of the audio signal have all been encoded into the bitstream. At this time, the quantization coding cycle of the multiple sub-bands can be ended and the quantization coding cycle of the sub-bands included in the next spectrum can be entered.
[0200] In the second case, when the current residual quantization scales corresponding to the m subbands are not all 0 and are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales corresponding to the m subbands.
[0201] If the current remaining quantization scales corresponding to the m subbands are not all zero, it indicates that there are still uncoded subbands in the m subbands, so quantization bits need to be allocated to the m subbands. If the current remaining quantization scales corresponding to the m subbands are all smaller than the quantization step size, it indicates that the quantization bits corresponding to the m subbands are all within the range of the quantization step size, so the current remaining quantization scales corresponding to the m subbands can be directly used as the quantization bits allocated to the m subbands.
[0202] It should be noted that, for different quantization coding cycles, the quantization step size corresponding to each quantization coding cycle may be the same or different, and the embodiments of the present application do not limit this.
[0203] In a third case, when the current residual quantization scale of at least one subband among the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales corresponding to the m subbands to obtain masked residual quantization scales corresponding to the m subbands; based on the quantization step size, the masked residual quantization scales corresponding to the m subbands are scaled to obtain scaled residual quantization scales corresponding to the m subbands; and quantization bits are allocated to the m subbands based on the scaled residual quantization scales corresponding to the m subbands and the target quantization scales corresponding to the m subbands.
[0204] When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, it indicates that the quantization bits of some of the m subbands are not within the range of the quantization step size. Therefore, it is necessary to process the residual quantization scales corresponding to the m subbands respectively through psychoacoustic masking to achieve differentiation of the importance of the m subbands.
[0205] In some embodiments, a maximum value among the masked quantization scales corresponding to the m subbands may be determined, and based on the masked quantization scales corresponding to the m subbands, the maximum value among the masked quantization scales corresponding to the m subbands, and the quantization step size, the masked residual quantization scales corresponding to the m subbands may be scaled to obtain the scaled residual quantization scales corresponding to the m subbands.
[0206] As an example, based on the masked quantization scales corresponding to the m subbands, the maximum value among the masked quantization scales corresponding to the m subbands, and the quantization step size, the remaining masked quantization scales corresponding to the m subbands are scaled according to the following formula (7): Q[b] = Max(bandQs[b] - Qmax + Qs, 0) (7)
[0207] In the above formula (7), Q[b] represents the residual quantization scale after scaling of the b-th subband, bandQs[b] represents the quantization scale after masking of the b-th subband, Qmax represents the maximum value of the masked quantization scales corresponding to the m subbands, and Qs represents the quantization step size.
[0208] As another example, based on the masked quantization scales corresponding to the m subbands, the maximum value among the masked quantization scales corresponding to the m subbands, and the quantization step size, the masked residual quantization scales corresponding to the m subbands are scaled according to the following formula (8);
[0209] The meanings of the letters in the above formula (8) are the same as those in the above formula (7), and are not repeated here.
[0210] After determining the scaled residual quantization scales corresponding to the m subbands respectively, for any one of the m subbands, a smaller value between the scaled residual quantization scale of the subband and the target quantization scale is determined as the quantization bits allocated to the subband.
[0211] After allocating quantization bits to the m subbands in the above manner, the residual quantization scales corresponding to the m subbands can be updated. That is, for any of the m subbands, the current residual quantization scale of the subband is subtracted from the quantization bits allocated to the subband to obtain the updated residual quantization scale of the subband.
[0212] Step 405: Based on the quantization bits currently allocated to the m sub-bands, encode the frequency band information of the m sub-bands into the bitstream.
[0213] Since the subbands included in the spectrum of the audio signal are encoded through multiple rounds of quantization, the quantization bits allocated to the m subbands based on the current residual quantization scales corresponding to the m subbands can also be called the quantization bits currently allocated to the m subbands, or in other words, the quantization bits allocated to the m subbands in this round.
[0214] Because the audio signal's spectrum consists of multiple subbands that are quantized and encoded hierarchically, the frequency band information within a subband may also be quantized and encoded hierarchically. This means that different frequency bands within the same subband may reside in different quantization layers. The method for encoding the subband's frequency band information into the bitstream varies depending on the quantization layer. The following describes an example using any one of the m subbands.
[0215] In the first case, when the current number of quantization levels of the target subband is less than or equal to the maximum number of quantization levels, if the quantization bit currently allocated to the target subband is 1, the frequency band information in the target subband is encoded into the bitstream based on the quantization bit currently allocated to the target subband using entropy coding, and the target subband is any one of the m subbands.
[0216] The current quantization level of the target subband refers to the number of quantization coding cycles in which the frequency band information of the target subband is currently encoded. The maximum quantization level is pre-set and may vary in different situations.
[0217] The implementation process of encoding the frequency band information of the target subband into the bitstream by using an entropy coding method based on the quantization bits currently allocated to the target subband includes: encoding each plurality of bits of the frequency band information of the target subband as a group into the bitstream by using an entropy coding method based on the quantization bits currently allocated to the target subband.
[0218] As an example, when the current quantization layer of the target subband is the first layer and the bandwidth of the target subband is greater than 1, based on the quantization bits currently allocated to the target subband, entropy coding is used to encode every n bits in the band information of the target subband as a group into the code stream, where n is an integer greater than 1; when the current quantization layer of the target subband is the second layer, based on the quantization bits currently allocated to the target subband, entropy coding is used to encode every k bits in the band information of the target subband as a group into the code stream, where k is an integer greater than 1; when the current quantization layer of the target subband is greater than or equal to the third layer, based on the quantization bits currently allocated to the target subband, entropy coding is used to encode every h bits in the band information of the target subband as a group into the code stream, where h is an integer greater than 1.
[0219] In some embodiments, when the current quantization layer of the target subband is the first layer and the bandwidth of the target subband is 1, it indicates that the value of the frequency band information of the target subband is 1 and does not need to be encoded.
[0220] The values of n, k, and h can be the same or different. For example, n is 4, k is 3, and h is 2. Depending on the requirements, the values of n, k, and h may vary. Furthermore, if ungrouped frequency band information exists within a subband, binary encoding can be used to encode this ungrouped frequency band information into the bitstream.
[0221] The entropy coding may be Huffman coding. For example, when n is 4, Huffman coding is used to encode every n bits of the frequency band information of the target subband into the bitstream as a group, and the encoding codebook used is as follows:
[0222] {{0,1,1}, {1,0,3}, {2,6,4}, {3,22,6}, {4,7,4}, {5,19,6},
[0223] {6,21,6}, {7,33,7}, {8,1,3}, {9,18,6}, {10,20,6}, {11,71,8},
[0224] {12,23,6}, {13,32,7}, {14,34,7}, {15,70,8}};
[0225] When k is 3, Huffman coding is used to encode every k bits of the target subband's frequency band information into the bitstream as a group, and the adopted coding codebook is as follows:
[0226] {{0,0,1}, {1,4,3}, {2,5,3}, {3,30,5}, {4,6,3}, {5,29,5}, {6,31,5}, {7,28,5}};
[0227] When h is 2, Huffman coding is used to encode every h bits of the target subband frequency band information into the bitstream as a group, and the coding codebook used is as follows:
[0228] {{0,0,1},{1,7,3},{2,2,2},{3,6,3}};
[0229] The Huffman codebook format is AudioHuffCode{value,code,len}, where value is the value before encoding, code is the value after encoding, and len is the code length, or the number of bits used in the code. The codebook construction can be based on experience or data training, generally adhering to the principle that frequently occurring values have shorter code lengths, while less frequently occurring values have longer code lengths. As shown in Figure 5, before encoding, each value requires an average of 5 bits to represent. After encoding, the maximum required value is 5 bits, and some values require only 2 bits. Clearly, the average number of bits required per value is less than 5 bits, significantly improving the compression ratio.
[0230] In the second case, when the current number of quantization levels of the target subband is less than or equal to the maximum number of quantization levels, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is encoded into the bitstream using binary coding based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0231] In the third case, when the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, the frequency band information in the target subband is encoded into the bitstream using binary coding based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0232] In some embodiments, during the process of encoding the frequency band information of the m sub-bands into the bitstream, the current encoding bit rate may also be determined. If the current encoding bit rate is equal to the target encoding bit rate, the hierarchical quantization encoding loop of the sub-bands included in the spectrum of the audio signal may be terminated.
[0233] In other words, the quantization coding cycle of a spectral subband may be terminated due to insufficient bit rate, so the intermediate state corresponds to a lossy coding state, which will be automatically encoded to lossless when the bit rate is sufficient. Therefore, this framework can support a large range of bit rate variations between lossy and lossless codecs.
[0234] The quantization encoding process described above is now described using Figure 6. Referring to Figure 6, after the spectrum of the current audio frame of the audio signal is divided into subbands, a target quantization scale for each of the multiple subbands included in the spectrum can be determined. Based on the currently used number of bits, number of channels, and number of sampling points of the audio signal, a current bandwidth cutoff coefficient is determined. Based on the current bandwidth cutoff coefficient, m subbands to be encoded are determined from the multiple subbands. If the current bandwidth cutoff coefficient is less than 1, the target quantization scales corresponding to the m subbands are encoded into the bitstream. If the current bandwidth cutoff coefficient is 1, or after the target quantization scales corresponding to the m subbands are encoded into the bitstream, it is determined whether subband masking is required for the m subbands. After subband masking is performed on the m subbands, quantization bits are allocated to the m subbands, the remaining quantization scales corresponding to the m subbands are updated, and based on the allocated quantization bits, the frequency band information for the m subbands is encoded into the bitstream using entropy coding or binary coding.
[0235] The above-mentioned quantization coding process has two significant features. One is the simultaneous quantization and encoding mode. Unlike most audio codecs that separate the quantization and encoding processes, this feature enables the decoding side to decode as much information as it receives, thus achieving a single-frame multi-bitrate feature. That is, after encoding an audio frame, the encoding bit rate of the audio frame can be arbitrarily truncated, resulting in the audio frame having different bit rates. Another feature is the high symmetry of the quantization coding process on the encoding and decoding sides. That is, the decoding side has the same quantization process as the encoding side, which is different from the quantization process of most codecs in which quantization is performed on the encoding side and the decoding side only needs to decode the quantization information. In this scheme, the quantization bit allocation for each layer on the encoding side is calculated based on the number of encoded bits. Correspondingly, the quantization bit allocation for each layer on the decoding side is also calculated based on the number of decoded bits. The quantization bit allocation mechanism is the same, so both the encoding and decoding sides know how the bits are allocated in each quantization cycle.
[0236] A frequency band information is usually represented by multiple bits. The high bits in the multiple bits are generally closer to the value of the frequency band information, and the low bits in the multiple bits are usually slightly different from the value of the frequency band information. In addition, during the encoding process, encoding is usually started from the high bits in the multiple bits, so the importance or priority of the high bits in the multiple bits is slightly higher than that of the low bits. In other words, the above-mentioned quantization encoding mechanism essentially sorts the bits according to their importance. As shown in Figure 7, each column in Figure 7 represents a frequency band information, and each small box in a column represents a bit. The smaller the number filled in each bit, the higher the priority of the bit. As can be seen from Figure 7, in the encoding process from left to right, the priority of the high bits is higher than that of the low bits.
[0237] Based on the above description, the audio signal can be a monophonic audio signal, a dual-channel audio signal, or a multi-channel audio signal. In the embodiment of the present application, the audio signals of each channel can be quantized and encoded separately, or the audio signals of each channel can be mixed together for quantization and encoding.
[0238] As an example, an audio signal has side information, and the side information includes a coding flag. When the coding flag is a first value, the audio signal is a single-channel audio signal, that is, the audio signals of each channel are quantized and encoded separately. When the coding flag is a second value, the audio signal is a multi-channel audio signal, that is, the audio signals of each channel are mixed together and quantized and encoded.
[0239] Separately quantizing and encoding the audio signals of each channel facilitates separate transmission or decoding of the bitstreams of each channel. In this case, the bitrates of each channel are evenly distributed. Mixing the audio signals of each channel together for quantization encoding performs layered quantization encoding on a channel-by-channel basis. In this case, the bitrates of each channel are dynamically allocated, achieving a relatively optimal bitrate distribution. In other words, separate quantization encoding results in the bitstreams of each channel supporting multiple bitrates per frame, while mixed quantization encoding results in the mixed bitstreams of each channel supporting multiple bitrates per frame.
[0240] In an embodiment of the present application, by performing layered quantization coding on the sub-bands included in the spectrum, when the bit rate is insufficient, it will correspond to a lossy coding state, and when the bit rate is sufficient, it will correspond to a lossless coding state. That is to say, the quantization coding method provided in the embodiment of the present application can simultaneously support lossy and lossless coding characteristics, greatly reducing the complexity of the algorithm and avoiding inefficient switching between lossy and lossless frameworks. Moreover, in the process of layered quantization coding, by quantizing and encoding at the same time, the encoded code stream can be arbitrarily truncated when the bit rate changes. That is, the audio frame encoded by this scheme has the characteristics of single-frame multi-bit rate. Compared with the method of quantizing first and then encoding, it can avoid the situation where truncation cannot be performed when the bit rate changes and re-encoding is required, greatly improving its channel adaptability during the communication process.
[0241] FIG8 is a flow chart of an audio decoding method provided by an embodiment of the present application, which is applied to a decoding end. Referring to FIG8 , the method includes the following steps.
[0242] Step 801: Determine a current bandwidth cutoff coefficient based on the currently used number of bits, the number of channels, and the number of sampling points of the audio signal. The currently used number of bits refers to the number of bits consumed by decoding the spectrum of the current audio frame of the audio signal before the current time.
[0243] The way in which the decoding side determines the current bandwidth cutoff coefficient is similar to the way in which the encoding side determines the current bandwidth cutoff coefficient. For the detailed implementation process, please refer to the relevant content in the above step 401, which will not be repeated here.
[0244] Step 802: Based on the current bandwidth cutoff coefficient, determine m subbands to be decoded from multiple subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the multiple subbands.
[0245] The way in which the decoding side determines the m subbands to be decoded is similar to the way in which the encoding side determines the m subbands to be encoded. For the detailed implementation process, please refer to the relevant content in the above step 402, which will not be repeated here.
[0246] Step 803: Based on the current bandwidth cutoff coefficient, the target quantization scales corresponding to the m sub-bands are parsed from the bitstream. The target quantization scale refers to the number of bits required to encode the frequency band information with the maximum amplitude in the corresponding sub-band.
[0247] Based on the description above, the current bandwidth cutoff coefficient is typically a value between 0 and 1. A value of 1 indicates full bandwidth, while a value less than 1 indicates partial bandwidth. In the full and partial bandwidth scenarios, the target quantization scales corresponding to the m subbands are encoded into the bitstream differently, as described below.
[0248] In the first case, when the current bandwidth cutoff coefficient indicates a non-full bandwidth, the target quantization scales corresponding to the m sub-bands are parsed from the bitstream.
[0249] When the current bandwidth cutoff coefficient indicates a non-full bandwidth, this indicates that there are unsolved target quantization scales among the target quantization scales corresponding to the m subbands. That is, the target quantization scales corresponding to the m subbands have not been fully resolved. In this case, the target quantization scales corresponding to the m subbands can be resolved from the bitstream.
[0250] When the encoding side encodes the target quantization scales corresponding to the m subbands into the bitstream using differential encoding, the decoding side can use differential decoding to parse the target quantization scales corresponding to the m subbands from the bitstream. When the encoding side encodes the target quantization scales corresponding to the m subbands into the bitstream using non-differential encoding, the decoding side can use non-differential decoding to parse the target quantization scales corresponding to the m subbands from the bitstream.
[0251] The process of implementing differential decoding to parse the target quantization scales corresponding to the m subbands from the bitstream includes: for a first subband among the m subbands, parse the target quantization scale of the first subband from the bitstream using a non-differential entropy decoding method; for non-first subbands among the m subbands, parse the quantization scale difference of the subband from the bitstream using an entropy decoding method, and then add the quantization scale difference to the target quantization scale of the previous adjacent subband to obtain the target quantization scale of the subband.
[0252] The implementation process of parsing the target quantization scales corresponding to the m subbands from the bitstream using a non-differential decoding method includes: parsing the target quantization scales corresponding to the m subbands from the bitstream using a non-differential entropy decoding method.
[0253] In some embodiments, the coding mode of the m sub-bands may be parsed from the code stream to determine whether the m sub-bands are encoded using a differential coding mode or a non-differential coding mode.
[0254] It should be noted that the entropy decoding may be Huffman decoding or other decoding methods, which is not limited in the embodiments of the present application.
[0255] When the entropy decoding is Huffman decoding, the decoding codebook used by the non-differential entropy decoding method is as follows:
[0256] {{0,19,3}, {1,19,3}, {2,19,3}, {3,19,3}, {4,19,3}, {5,19,3},
[0257] {6,19,3}, {7,19,3}, {8,19,3}, {9,19,3}, {10,19,3}, {11,19,3},
[0258] {12,19,3}, {13,19,3}, {14,19,3}, {15,19,3}, {16,19,3}, {17,19,3},
[0259] {18,19,3}, {19,19,3}, {20,19,3}, {21,19,3}, {22,19,3}, {23,19,3},
[0260] {24,19,3}, {25,19,3}, {26,19,3}, {27,19,3}, {28,19,3}, {29,19,3},
[0261] {30,19,3},{31,19,3},{32,20,3},{33,20,3},{34,20,3},{35,20,3},
[0262] {36,20,3},{37,20,3},{38,20,3},{39,20,3},{40,20,3},{41,20,3},
[0263] {42,20,3},{43,20,3},{44,20,3},{45,20,3},{46,20,3},{47,20,3},
[0264] {48,20,3},{49,20,3},{50,20,3},{51,20,3},{52,20,3},{53,20,3},
[0265] {54,20,3},{55,20,3},{56,20,3},{57,20,3},{58,20,3},{59,20,3},
[0266] {60,20,3},{61,20,3},{62,20,3},{63,20,3},{64,21,3},{65,21,3},
[0267] {66,21,3},{67,21,3},{68,21,3},{69,21,3},{70,21,3},{71,21,3},
[0268] {72,21,3},{73,21,3},{74,21,3},{75,21,3},{76,21,3},{77,21,3},
[0269] {78,21,3},{79,21,3},{80,21,3},{81,21,3},{82,21,3},{83,21,3},
[0270] {84,21,3},{85,21,3},{86,21,3},{87,21,3},{88,21,3},{89,21,3},
[0271] {90,21,3},{91,21,3},{92,21,3},{93,21,3},{94,21,3},{95,21,3},
[0272] {96,22,3},{97,22,3},{98,22,3},{99,22,3},{100,22,3},{101,22,3},
[0273] {102,22,3},{103,22,3},{104,22,3},{105,22,3},{106,22,3},{107,22,3},
[0274] {108,22,3},{109,22,3},{110,22,3},{111,22,3},{112,22,3},{113,22,3},
[0275] {114,22,3},{115,22,3},{116,22,3},{117,22,3},{118,22,3},{119,22,3},
[0276] {120,22,3},{121,22,3},{122,22,3},{123,22,3},{124,22,3},{125,22,3},
[0277] {126,22,3},{127,22,3},{128,16,4},{129,16,4},{130,16,4},{131,16,4},
[0278] {132,16,4},{133,16,4},{134,16,4},{135,16,4},{136,16,4},{137,16,4},
[0279] {138,16,4},{139,16,4},{140,16,4},{141,16,4},{142,16,4},{143,16,4},
[0280] {144,17,4},{145,17,4},{146,17,4},{147,17,4},{148,17,4},{149,17,4},
[0281] {150,17,4},{151,17,4},{152,17,4},{153,17,4},{154,17,4},{155,17,4},
[0282] {156,17,4},{157,17,4},{158,17,4},{159,17,4},{160,18,4},{161,18,4},
[0283] {162,18,4},{163,18,4},{164,18,4},{165,18,4},{166,18,4},{167,18,4},
[0284] {168,18,4},{169,18,4},{170,18,4},{171,18,4},{172,18,4},{173,18,4},
[0285] {174,18,4},{175,18,4},{176,23,4},{177,23,4},{178,23,4},{179,23,4},
[0286] {180,23,4},{181,23,4},{182,23,4},{183,23,4},{184,23,4},{185,23,4},
[0287] {186,23,4},{187,23,4},{188,23,4},{189,23,4},{190,23,4},{191,23,4},
[0288] {192,13,5},{193,13,5},{194,13,5},{195,13,5},{196,13,5},{197,13,5},
[0289] {198,13,5},{199,13,5},{200,14,5},{201,14,5},{202,14,5},{203,14,5},
[0290] {204,14,5},{205,14,5},{206,14,5},{207,14,5},{208,15,5},{209,15,5},
[0291] {210,15,5},{211,15,5},{212,15,5},{213,15,5},{214,15,5},{215,15,5},
[0292] {216,24,5},{217,24,5},{218,24,5},{219,24,5},{220,24,5},{221,24,5},
[0293] {222,24,5},{223,24,5},{224,12,6},{225,12,6},{226,12,6},{227,12,6},
[0294] {228,25,6}, {229,25,6}, {230,25,6}, {231,25,6}, {232,9,7}, {233,9,7},
[0295] {234,10,7}, {235,10,7}, {236,11,7}, {237,11,7}, {238,26,7}, {239,26,7},
[0296] {240,29,7}, {241,29,7}, {242,30,7}, {243,30,7}, {244,0,8}, {245,1,8},
[0297] {246,2,8}, {247,3,8}, {248,4,8}, {249,5,8}, {250,6,8}, {251,7,8},
[0298] {252,8,8}, {253,27,8}, {254,28,8}, {255,31,8}};
[0299] When the entropy decoding is Huffman decoding, the decoding codebook used by the differential entropy decoding method is as follows:
[0300] {{0,6,3}, {1,6,3}, {2,6,3}, {3,6,3}, {4,6,3}, {5,6,3},
[0301] {6,6,3}, {7,6,3}, {8,6,3}, {9,6,3}, {10,6,3}, {11,6,3},
[0302] {12,6,3}, {13,6,3}, {14,6,3}, {15,6,3}, {16,10,3}, {17,10,3},
[0303] {18,10,3}, {19,10,3}, {20,10,3}, {21,10,3}, {22,10,3}, {23,10,3},
[0304] {24,10,3}, {25,10,3}, {26,10,3}, {27,10,3}, {28,10,3}, {29,10,3},
[0305] {30,10,3}, {31,10,3}, {32,12,4}, {33,12,4}, {34,12,4}, {35,12,4},
[0306] {36,12,4},{37,12,4},{38,12,4},{39,12,4},{40,4,4},{41,4,4},
[0307] {42,4,4},{43,4,4},{44,4,4},{45,4,4},{46,4,4},{47,4,4},
[0308] {48,7,3},{49,7,3},{50,7,3},{51,7,3},{52,7,3},{53,7,3},
[0309] {54,7,3},{55,7,3},{56,7,3},{57,7,3},{58,7,3},{59,7,3},
[0310] {60,7,3},{61,7,3},{62,7,3},{63,7,3},{64,9,3},{65,9,3},
[0311] {66,9,3},{67,9,3},{68,9,3},{69,9,3},{70,9,3},{71,9,3},
[0312] {72,9,3},{73,9,3},{74,9,3},{75,9,3},{76,9,3},{77,9,3},
[0313] {78,9,3},{79,9,3},{80,8,3},{81,8,3},{82,8,3},{83,8,3},
[0314] {84,8,3},{85,8,3},{86,8,3},{87,8,3},{88,8,3},{89,8,3},
[0315] {90,8,3},{91,8,3},{92,8,3},{93,8,3},{94,8,3},{95,8,3},
[0316] {96,13,5},{97,13,5},{98,13,5},{99,13,5},{100,1,6},{101,1,6},
[0317] {102,14,6},{103,14,6},{104,5,4},{105,5,4},{106,5,4},{107,5,4},
[0318] {108,5,4}, {109,5,4}, {110,5,4}, {111,5,4}, {112,11,4}, {113,11,4},
[0319] {114,11,4}, {115,11,4}, {116,11,4}, {117,11,4}, {118,11,4}, {119,11,4},
[0320] {120,3,5}, {121,3,5}, {122,3,5}, {123,3,5}, {124,0,7}, {125,15,7},
[0321] {126,2,6}, {127,2,6}};
[0322] In the second case, when the current bandwidth cutoff coefficient indicates a full band, there is no need to parse the target quantization scales corresponding to the m sub-bands from the bitstream.
[0323] When the current bandwidth cutoff coefficient indicates full bandwidth, it indicates that the target quantization scales corresponding to the m subbands have been parsed from the bitstream. In this case, there is no need to parse the target quantization scales corresponding to the m subbands from the bitstream.
[0324] Step 804: Allocate quantization bits to the m subbands based on the current remaining quantization scales corresponding to the m subbands, where the current remaining quantization scale refers to the quantization scale remaining unallocated after quantization bits were allocated to the corresponding subbands last time.
[0325] In the case that the current residual quantization scales corresponding to the m sub-bands are different, different ways of allocating quantization bits to the m sub-bands will be introduced below.
[0326] In the first case, when the current residual quantization scales corresponding to the m sub-bands are all 0, the quantization decoding loop of the spectrum of the audio signal is terminated.
[0327] When the current residual quantization scales corresponding to the m sub-bands are all 0, it indicates that all the sub-bands included in the spectrum of the audio signal have been parsed from the bitstream. At this time, the quantization decoding loop for the multiple sub-bands can be ended and the quantization decoding loop for the sub-band included in the next spectrum can be entered.
[0328] In the second case, when the current residual quantization scales corresponding to the m subbands are not all 0 and are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales corresponding to the m subbands.
[0329] If the current remaining quantization scales corresponding to the m subbands are not all zero, it indicates that there are still undecoded subbands among the m subbands, and therefore quantization bits need to be allocated to the m subbands. If the current remaining quantization scales corresponding to the m subbands are all smaller than the quantization step size, it indicates that the quantization bits corresponding to the m subbands are all within the range of the quantization step size, and therefore the current remaining quantization scales corresponding to the m subbands can be directly used as the quantization bits allocated to the m subbands.
[0330] It should be noted that, for different quantization decoding cycles, the quantization step size corresponding to each quantization decoding cycle may be the same or different, and this embodiment of the present application does not limit this.
[0331] In a third case, when the current residual quantization scale of at least one subband among the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales corresponding to the m subbands to obtain masked residual quantization scales corresponding to the m subbands; based on the quantization step size, the masked residual quantization scales corresponding to the m subbands are scaled to obtain scaled residual quantization scales corresponding to the m subbands; and quantization bits are allocated to the m subbands based on the scaled residual quantization scales corresponding to the m subbands and the target quantization scales corresponding to the m subbands.
[0332] When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, it indicates that the quantization bits of some of the m subbands are not within the range of the quantization step size. Therefore, it is necessary to process the residual quantization scales corresponding to the m subbands respectively through psychoacoustic masking to achieve differentiation of the importance of the m subbands.
[0333] In some embodiments, a maximum value among the masked quantization scales corresponding to the m subbands may be determined, and based on the masked quantization scales corresponding to the m subbands, the maximum value among the masked quantization scales corresponding to the m subbands, and the quantization step size, the masked residual quantization scales corresponding to the m subbands may be scaled to obtain scaled residual quantization scales corresponding to the m subbands. For detailed implementation, please refer to the relevant content of step 404 above and will not be repeated here.
[0334] After determining the scaled residual quantization scales corresponding to the m subbands respectively, for any one of the m subbands, a smaller value between the scaled residual quantization scale of the subband and the target quantization scale is determined as the quantization bits allocated to the subband.
[0335] After allocating quantization bits to the m subbands in the above manner, the residual quantization scales corresponding to the m subbands can be updated. That is, for any of the m subbands, the current residual quantization scale of the subband is subtracted from the quantization bits allocated to the subband to obtain the updated residual quantization scale of the subband.
[0336] Step 805: Based on the quantization bits currently allocated to the m sub-bands, parse the frequency band information of the m sub-bands from the bitstream.
[0337] Since the subbands included in the spectrum of the audio signal are decoded through multiple rounds of quantization, the quantization bits allocated to the m subbands based on the current residual quantization scales corresponding to the m subbands can also be called the quantization bits currently allocated to the m subbands, or in other words, the quantization bits allocated to the m subbands in this round.
[0338] Because the audio signal's spectrum includes multiple subbands that are decoded using hierarchical quantization, and the frequency band information within a subband may also be decoded using hierarchical quantization, different frequency band information within the same subband may reside in different quantization layers. When the subband's channels reside in different quantization layers, the method for parsing the frequency band information from the bitstream differs. The following describes an example using any one of the m subbands.
[0339] In the first case, when the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, entropy decoding is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
[0340] The current quantization level of the target subband refers to the number of quantization decoding cycles in which the frequency band information of the target subband is currently decoded. The maximum quantization level is pre-set and may vary in different situations.
[0341] The implementation process of parsing frequency band information of the target subband from the bitstream using an entropy decoding method based on the quantization bits currently allocated to the target subband includes: based on the quantization bits currently allocated to the target subband, using the entropy decoding method, decoding each plurality of bits of the frequency band information of the target subband as a group from the bitstream.
[0342] As an example, when the current quantization layer of the target subband is the first layer and the bandwidth of the target subband is greater than 1, based on the quantization bits currently allocated to the target subband, entropy decoding is used to extract every n bits in the band information of the target subband from the bitstream as a group, where n is an integer greater than 1; when the current quantization layer of the target subband is the second layer, based on the quantization bits currently allocated to the target subband, entropy decoding is used to extract every k bits in the band information of the target subband from the bitstream as a group, where k is an integer greater than 1; when the current quantization layer of the target subband is greater than or equal to the third layer, based on the quantization bits currently allocated to the target subband, entropy decoding is used to extract every h bits in the band information of the target subband from the bitstream as a group, where h is an integer greater than 1.
[0343] In some embodiments, when the current quantization layer of the target subband is the first layer and the bandwidth of the target subband is 1, it indicates that the value of the frequency band information of the target subband is 1 and decoding is not required.
[0344] The values of n, k, and h can be the same or different. For example, n is 4, k is 3, and h is 2. Depending on the requirements, the values of n, k, and h may vary. Furthermore, if ungrouped frequency band information exists within a subband, binary decoding can be used to extract this ungrouped frequency band information from the bitstream.
[0345] The entropy decoding may be Huffman decoding. For example, when n is 4, Huffman decoding is used to extract every n bits of the target subband frequency band information from the bitstream as a group, and the decoding codebook used is as follows:
[0346] {{0,1,3}, {1,1,3}, {2,1,3}, {3,1,3}, {4,1,3}, {5,1,3}, {6,1,3},
[0347] {7,1,3}, {8,1,3}, {9,1,3}, {10,1,3}, {11,1,3}, {12,1,3}, {13,1,3},
[0348] {14,1,3}, {15,1,3}, {16,1,3}, {17,1,3}, {18,1,3}, {19,1,3}, {20,1,3},
[0349] {21,1,3}, {22,1,3}, {23,1,3}, {24,1,3}, {25,1,3}, {26,1,3}, {27,1,3},
[0350] {28,1,3},{29,1,3},{30,1,3},{31,1,3},{32,8,3},{33,8,3},{34,8,3},
[0351] {35,8,3},{36,8,3},{37,8,3},{38,8,3},{39,8,3},{40,8,3},{41,8,3},
[0352] {42,8,3},{43,8,3},{44,8,3},{45,8,3},{46,8,3},{47,8,3},{48,8,3},
[0353] {49,8,3},{50,8,3},{51,8,3},{52,8,3},{53,8,3},{54,8,3},{55,8,3},
[0354] {56,8,3},{57,8,3},{58,8,3},{59,8,3},{60,8,3},{61,8,3},{62,8,3},
[0355] {63,8,3},{64,13,7},{65,13,7},{66,7,7},{67,7,7},{68,14,7},{69,14,7},
[0356] {70,15,8},{71,11,8},{72,9,6},{73,9,6},{74,9,6},{75,9,6},{76,5,6},
[0357] {77,5,6},{78,5,6},{79,5,6},{80,10,6},{81,10,6},{82,10,6},{83,10,6},
[0358] {84,6,6},{85,6,6},{86,6,6},{87,6,6},{88,3,6},{89,3,6},{90,3,6},
[0359] {91,3,6},{92,12,6},{93,12,6},{94,12,6},{95,12,6},{96,2,4},{97,2,4},
[0360] {98,2,4},{99,2,4},{100,2,4},{101,2,4},{102,2,4},{103,2,4},{104,2,4},
[0361] {105,2,4},{106,2,4},{107,2,4},{108,2,4},{109,2,4},{110,2,4},{111,2,4},
[0362] {112,4,4},{113,4,4},{114,4,4},{115,4,4},{116,4,4},{117,4,4},{118,4,4},
[0363] {119,4,4},{120,4,4},{121,4,4},{122,4,4},{123,4,4},{124,4,4},{125,4,4},
[0364] {126,4,4},{127,4,4},{128,0,1},{129,0,1},{130,0,1},{131,0,1},{132,0,1},
[0365] {133,0,1},{134,0,1},{135,0,1},{136,0,1},{137,0,1},{138,0,1},{139,0,1},
[0366] {140,0,1},{141,0,1},{142,0,1},{143,0,1},{144,0,1},{145,0,1},{146,0,1},
[0367] {147,0,1},{148,0,1},{149,0,1},{150,0,1},{151,0,1},{152,0,1},{153,0,1},
[0368] {154,0,1},{155,0,1},{156,0,1},{157,0,1},{158,0,1},{159,0,1},{160,0,1},
[0369] {161,0,1},{162,0,1},{163,0,1},{164,0,1},{165,0,1},{166,0,1},{167,0,1},
[0370] {168,0,1},{169,0,1},{170,0,1},{171,0,1},{172,0,1},{173,0,1},{174,0,1},
[0371] {175,0,1},{176,0,1},{177,0,1},{178,0,1},{179,0,1},{180,0,1},{181,0,1},
[0372] {182,0,1},{183,0,1},{184,0,1},{185,0,1},{186,0,1},{187,0,1},{188,0,1},
[0373] {189,0,1},{190,0,1},{191,0,1},{192,0,1},{193,0,1},{194,0,1},{195,0,1},
[0374] {196,0,1},{197,0,1},{198,0,1},{199,0,1},{200,0,1},{201,0,1},{202,0,1},
[0375] {203,0,1},{204,0,1},{205,0,1},{206,0,1},{207,0,1},{208,0,1},{209,0,1},
[0376] {210,0,1},{211,0,1},{212,0,1},{213,0,1},{214,0,1},{215,0,1},{216,0,1},
[0377] {217,0,1},{218,0,1},{219,0,1},{220,0,1},{221,0,1},{222,0,1},{223,0,1},
[0378] {224,0,1},{225,0,1},{226,0,1},{227,0,1},{228,0,1},{229,0,1},{230,0,1},
[0379] {231,0,1},{232,0,1},{233,0,1},{234,0,1},{235,0,1},{236,0,1},{237,0,1},
[0380] {238,0,1},{239,0,1},{240,0,1},{241,0,1},{242,0,1},{243,0,1},{244,0,1},
[0381] {245,0,1}, {246,0,1}, {247,0,1}, {248,0,1}, {249,0,1}, {250,0,1}, {251,0,1},
[0382] {252,0,1}, {253,0,1}, {254,0,1}, {255,0,1}, {256,0,1}};
[0383] When k is 3, Huffman decoding is used to decode every k bits of the target subband frequency band information from the bitstream as a group, and the decoding codebook used is as follows:
[0384] {{0,0,1}, {1,0,1}, {2,0,1}, {3,0,1}, {4,0,1}, {5,0,1}, {6,0,1}, {7,0,1},
[0385] {8,0,1}, {9,0,1}, {10,0,1}, {11,0,1}, {12,0,1}, {13,0,1}, {14,0,1}, {15,0,1},
[0386] {16,1,3}, {17,1,3}, {18,1,3}, {19,1,3}, {20,2,3}, {21,2,3}, {22,2,3}, {23,2,3},
[0387] {24,4,3}, {25,4,3}, {26,4,3}, {27,4,3}, {28,7,5}, {29,5,5}, {30,3,5}, {31,6,5}};
[0388] When h is 2, Huffman decoding is used to decode every h bits of the target subband frequency band information from the bitstream as a group, and the decoding codebook used is as follows:
[0389] {{0,0,1}, {1,0,1}, {2,0,1}, {3,0,1}, {4,2,2}, {5,2,2}, {6,3,3}, {7,1,3}};
[0390] Huffman coding uses a unique prefix code. The codebook on the decoding side is expanded based on the maximum code length to ensure that the values mapped by encoding and decoding are unique. In other words, for the decoding side, as shown in Figure 9, the decoding codebook can be expanded from the encoding codebook. This is achieved by padding the Huffman tree to a complete binary tree, and unifying the number of bits read by the Huffman decoder on the decoding side to the maximum Huffman tree depth. This eliminates the need to encode the code value length and improves compression efficiency.
[0391] In the second case, when the current number of quantization levels of the target subband is less than or equal to the maximum number of quantization levels, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is parsed from the bitstream using binary decoding based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0392] In the third case, when the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, based on the quantization bits currently allocated to the target subband, binary decoding is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
[0393] In some embodiments, based on the quantization bits currently allocated to the m subbands, after parsing the frequency band information in the m subbands from the bitstream, the method further includes: when the parsing of the target subband is completed, if the number of bits parsed out of the target frequency band information of the target subband is less than the target quantization scale of the target subband, padding the target frequency band information with low bits, the target subband being any one of the m subbands, and the target frequency band information being any one of the frequency band information in the target subband.
[0394] If the number of bits parsed from the target subband's target frequency band information is less than the target quantization scale of the target subband, this indicates that the quantization coding of the target frequency band information is not lossless. In this case, low-order bit padding can be performed on the target frequency band information. During the low-order bit padding process, random padding with 0s and 1s can be performed, and the probability of padding with 0s and 1s is equal.
[0395] Based on the above description, the audio signal can be a monophonic audio signal, a dual-channel audio signal, or a multi-channel audio signal. Furthermore, the encoding side can quantize and encode the audio signals of each channel separately or mix the audio signals of each channel together for quantization encoding. Furthermore, the decoding side supports three decoding modes: left channel decoding, right channel decoding, and stereo decoding.
[0396] In some embodiments, the audio signal has side information, the side information including a coding flag. When the coding flag is a first value, the audio signal is a single-channel audio signal, i.e., the encoding side separately quantizes and encodes the audio signals of each channel. When the coding flag is a second value, the audio signal is a multi-channel audio signal, i.e., the encoding side mixes the audio signals of each channel together for quantization and encoding.
[0397] If the encoding side quantizes and encodes the audio signals of each channel separately, the audio signals of each channel can be directly parsed by parsing the bitstream. If the encoding side mixes the audio signals of each channel together and quantizes them, if the stereo bitstream is not interleaved, then after decompressing the packet header and some common side information, the remaining bits are evenly distributed among the channels to parse the audio signals of each channel.
[0398] In an embodiment of the present application, by performing hierarchical quantization encoding on the sub-bands included in the spectrum, it is possible to support both lossy and lossless coding characteristics. Therefore, the decoding side can also support both lossy and lossless decoding characteristics, greatly reducing the complexity of the algorithm and avoiding inefficient switching between lossy and lossless frameworks. Moreover, in the process of hierarchical quantization decoding, by quantizing and decoding at the same time, no matter how much information is sent by the encoding side, the decoding side can parse it out from the code stream, greatly improving the channel adaptability of the code stream during the communication process. In addition, when the decoding side determines through analysis that a certain frequency band information is not lossless, it can also fill the value of the frequency band information by filling the low-order bits, reducing the overall quantization error, and effectively compensating for the reduction in the amplitude of the audio signal due to bit loss under lossy coding.
[0399] Figure 10 is a schematic diagram of the structure of an audio encoding device provided in an embodiment of the present application. The audio encoding device can be implemented as part or all of an audio encoding device using software, hardware, or a combination of both. The audio encoding device can be the encoding end described above. Referring to Figure 10 , the device includes a coefficient determination module 1001, a subband determination module 1002, a quantization scale encoding module 1003, a quantization bit allocation module 1004, and a frequency band information encoding module 1005.
[0400] A coefficient determination module 1001 is configured to determine a current bandwidth cutoff coefficient based on a currently used number of bits, a number of channels, and a number of sampling points of the audio signal, where the currently used number of bits refers to the number of bits consumed by encoding the spectrum of the current audio frame of the audio signal before the current time.
[0401] a subband determination module 1002 configured to determine, based on the current bandwidth cutoff coefficient, m subbands to be currently encoded from a plurality of subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the plurality of subbands;
[0402] A quantization scale encoding module 1003 is configured to encode target quantization scales corresponding to the m sub-bands into a bitstream based on the current bandwidth cutoff coefficient, where the target quantization scale refers to the number of bits required to encode the frequency band information with the maximum amplitude in the corresponding sub-band;
[0403] a quantization bit allocation module 1004 configured to allocate quantization bits to the m subbands based on currently remaining quantization scales corresponding to the m subbands, where the currently remaining quantization scales refer to quantization scales remaining unallocated after quantization bits were last allocated to the corresponding subbands;
[0404] The frequency band information encoding module 1005 is configured to encode the frequency band information of the m sub-bands into a bitstream based on the quantization bits currently allocated to the m sub-bands.
[0405] Optionally, the quantization scale encoding module 1003 is specifically configured to:
[0406] When the current bandwidth cutoff coefficient indicates a non-full band, determining a target quantization scale difference between every two adjacent sub-bands in the m sub-bands to obtain m-1 quantization scale differences;
[0407] Determine the minimum and maximum values of the m-1 quantization scale differences;
[0408] If the minimum value is greater than the first threshold and the maximum value is less than the second threshold, a differential coding method is adopted to encode the target quantization scales corresponding to the m sub-bands into the bitstream.
[0409] Optionally, the quantization bit allocation module 1004 is specifically configured to:
[0410] When the current residual quantization scales respectively corresponding to the m subbands are not all 0 and are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
[0411] Optionally, the quantization bit allocation module 1004 is specifically configured to:
[0412] When a current residual quantization scale of at least one subband among the m subbands is greater than a quantization step size, psychoacoustic masking is performed on the current residual quantization scales corresponding to the m subbands to obtain masked residual quantization scales corresponding to the m subbands;
[0413] Based on the quantization step size, scaling the masked residual quantization scales corresponding to the m sub-bands respectively to obtain scaled residual quantization scales corresponding to the m sub-bands respectively;
[0414] Quantization bits are allocated to the m subbands based on the scaled residual quantization scales respectively corresponding to the m subbands and the target quantization scales respectively corresponding to the m subbands.
[0415] Optionally, the frequency band information encoding module 1005 is specifically configured to:
[0416] When the current number of quantization levels of the target subband is less than or equal to the maximum number of quantization levels, if the quantization bit currently allocated to the target subband is 1, the frequency band information in the target subband is encoded into the bitstream based on the quantization bit currently allocated to the target subband using entropy coding, and the target subband is any one of the m subbands.
[0417] Optionally, the frequency band information encoding module 1005 is specifically configured to:
[0418] When the current number of quantization levels of the target subband is less than or equal to the maximum number of quantization levels, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is encoded into the bitstream using a binary encoding method based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
[0419] Optionally, the frequency band information encoding module 1005 is specifically configured to:
[0420] When the current number of quantization levels of the target subband is greater than the maximum number of quantization levels, based on the quantization bits currently allocated to the target subband, the frequency band information of the target subband is encoded into the bitstream using a binary coding method. The target subband is any one of the m subbands.
[0421] Optionally, the audio signal has side information, the side information includes a coding flag, when the coding flag is a first value, the audio signal is a single-channel audio signal, when the coding flag is a second value, the audio signal is a multi-channel audio signal.
[0422] In an embodiment of the present application, by performing layered quantization coding on the sub-bands included in the spectrum, when the bit rate is insufficient, it will correspond to a lossy coding state, and when the bit rate is sufficient, it will correspond to a lossless coding state. That is to say, the quantization coding method provided in the embodiment of the present application can simultaneously support lossy and lossless coding characteristics, greatly reducing the complexity of the algorithm and avoiding inefficient switching between lossy and lossless frameworks. Moreover, in the process of layered quantization coding, by quantizing and encoding at the same time, the encoded code stream can be arbitrarily truncated when the bit rate changes. That is, the audio frame encoded by this scheme has the characteristics of single-frame multi-bit rate. Compared with the method of quantizing first and then encoding, it can avoid the situation where truncation cannot be performed when the bit rate changes and re-encoding is required, greatly improving its channel adaptability during the communication process.
[0423] It should be noted that the audio encoding device provided in the above embodiment only uses the division of the above functional modules as an example to illustrate audio encoding. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the audio encoding device provided in the above embodiment and the audio encoding method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0424] Figure 11 is a schematic diagram of the structure of an audio decoding device provided in an embodiment of the present application. The audio decoding device can be implemented as part or all of an audio decoding device using software, hardware, or a combination of both. The audio decoding device can be the aforementioned decoding end. Referring to Figure 11, the device includes a coefficient determination module 1101, a subband determination module 1102, a quantization scale analysis module 1103, a quantization bit allocation module 1104, and a frequency band information analysis module 1105.
[0425] a coefficient determination module 1101 for determining a current bandwidth cutoff coefficient based on a currently used number of bits, a number of channels, and a number of sampling points of the audio signal, where the currently used number of bits refers to the number of bits consumed by decoding the spectrum of the current audio frame of the audio signal before the current time;
[0426] a subband determination module 1102 configured to determine, based on the current bandwidth cutoff coefficient, m subbands to be currently decoded from the multiple subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the multiple subbands;
[0427] A quantization scale parsing module 1103 is configured to parse, from the bitstream, target quantization scales corresponding to the m sub-bands based on the current bandwidth cutoff coefficient, where the target quantization scale refers to the number of bits required to encode the frequency band information with the maximum amplitude in the corresponding sub-band;
[0428] a quantization bit allocation module 1104 configured to allocate quantization bits to the m subbands based on currently remaining quantization scales corresponding to the m subbands, where the currently remaining quantization scales refer to quantization scales remaining unallocated after quantization bits were last allocated to the corresponding subbands;
[0429] The frequency band information parsing module 1105 is configured to parse the frequency band information of the m sub-bands from the bitstream based on the quantization bits currently allocated to the m sub-bands.
[0430] Optionally, the quantization scale analysis module 1103 is specifically configured to:
[0431] When the current bandwidth cutoff coefficient indicates a non-full bandwidth, target quantization scales corresponding to the m sub-bands are parsed from the bitstream.
[0432] Optionally, the quantization bit allocation module 1104 is specifically configured to:
[0433] When the current residual quantization scales respectively corresponding to the m subbands are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
[0434] Optionally, the quantization bit allocation module 1104 is specifically configured to:
[0435] When a current residual quantization scale of at least one subband among the m subbands is greater than a quantization step size, psychoacoustic masking is performed on the current residual quantization scales corresponding to the m subbands to obtain masked residual quantization scales corresponding to the m subbands;
[0436] Based on the quantization step size, scaling the masked residual quantization scales corresponding to the m sub-bands respectively to obtain scaled residual quantization scales corresponding to the m sub-bands respectively;
[0437] Quantization bits are allocated to the m subbands based on the scaled residual quantization scales respectively corresponding to the m subbands and the target quantization scales respectively corresponding to the m subbands.
[0438] Optionally, the frequency band information parsing module 1105 is specifically configured to:
[0439] When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, entropy decoding is used to parse the frequency band information in the target subband from the bitstream, where the target subband is any one of the m subbands.
[0440] Optionally, the frequency band information parsing module 1105 is specifically configured to:
[0441] When the current number of quantization levels of the target subband is less than or equal to the maximum number of quantization levels, if the quantization bits currently allocated to the target subband are greater than 1, based on the quantization bits currently allocated to the target subband, a binary decoding method is used to parse the frequency band information in the target subband from the bitstream, where the target subband is any one of the m subbands.
[0442] Optionally, the frequency band information parsing module 1105 is specifically configured to:
[0443] When the current number of quantization levels of the target subband is greater than the maximum number of quantization levels, frequency band information of the target subband is parsed from the bitstream using a binary decoding method based on the quantization bits currently allocated to the target subband, where the target subband is any one of the m subbands.
[0444] Optionally, the device further comprises:
[0445] The bit filling module is configured to, when parsing of a target subband is completed, perform low-order bit filling on the target frequency band information if the number of bits parsed out of the target frequency band information of the target subband is less than the target quantization scale of the target subband, where the target subband is any one of the m subbands, and the target frequency band information is any one of the frequency band information of the target subband.
[0446] In an embodiment of the present application, by performing hierarchical quantization encoding on the sub-bands included in the spectrum, it is possible to support both lossy and lossless coding characteristics. Therefore, the decoding side can also support both lossy and lossless decoding characteristics, greatly reducing the complexity of the algorithm and avoiding inefficient switching between lossy and lossless frameworks. Moreover, in the process of hierarchical quantization decoding, by quantizing and decoding at the same time, no matter how much information is sent by the encoding side, the decoding side can parse it out from the code stream, greatly improving the channel adaptability of the code stream during the communication process. In addition, when the decoding side determines through analysis that a certain frequency band information is not lossless, it can also fill the value of the frequency band information by filling the low-order bits, reducing the overall quantization error, and effectively compensating for the reduction in the amplitude of the audio signal due to bit loss under lossy coding.
[0447] It should be noted that the audio decoding device provided in the above embodiment only uses the division of the above functional modules as an example to illustrate audio decoding. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the audio decoding device provided in the above embodiment and the audio decoding method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0448] Please refer to Figure 12, which is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Optionally, the electronic device can be the above-mentioned audio encoding device or audio decoding device, and the electronic device includes one or more processors 1201, a communication bus 1202, a memory 1203, and one or more communication interfaces 1204.
[0449] Processor 1201 is a general-purpose central processing unit (CPU), a network processing processor (NP), a microprocessor, or one or more integrated circuits for implementing the solution of the present application, such as an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. Optionally, the PLD is a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0450] Communication bus 1204 is used to transmit information between the above components. Optionally, communication bus 1202 is divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or one type of bus.
[0451] Optionally, the memory 1203 is a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compact disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1203 exists independently and is connected to the processor 1201 via the communication bus 1202, or the memory 1203 is integrated with the processor 1201.
[0452] Communication interface 1204 uses any transceiver-like device for communicating with other devices or communication networks. Communication interface 1204 includes a wired communication interface and, optionally, a wireless communication interface. Wired communication interfaces include, for example, Ethernet interfaces. Optionally, the Ethernet interface is an optical interface, an electrical interface, or a combination thereof. The wireless communication interface is a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof.
[0453] Optionally, in some embodiments, the electronic device includes multiple processors, such as processor 1201 and processor 1205 shown in Figure 12. Each of these processors is a single-core processor or a multi-core processor. Optionally, the processor here refers to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0454] In a specific implementation, as an embodiment, the electronic device further includes an output device 1206 and an input device 1207. The output device 1206 communicates with the processor 1201 and can display information in a variety of ways. For example, the output device 1206 is a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 1207 communicates with the processor 1201 and can receive user input in a variety of ways. For example, the input device 1207 is a mouse, a keyboard, a touch screen device, or a sensor device.
[0455] In some embodiments, the memory 1203 is used to store a program code 1210 for executing the solution of the present application, and the processor 1201 is capable of executing the program code 1210 stored in the memory 1203. The program code includes one or more software modules, and the electronic device can implement the audio signal processing method provided in the embodiment of Figure 4 or Figure 8 above through the processor 1201 and the program code 1210 in the memory 1203.
[0456] An embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores instructions. When the instructions are executed on a computer, the computer executes the audio encoding method or audio decoding method described above.
[0457] The present application also provides a computer program product comprising instructions that, when executed on a computer, cause the computer to perform the aforementioned audio encoding method or audio decoding method. Alternatively, a computer program is provided that, when executed on a computer, causes the computer to perform the aforementioned audio encoding method or audio decoding method.
[0458] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.
[0459] It should be understood that the "plurality" mentioned herein refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate a clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0460] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0461] The above description is an embodiment provided for this application and is not intended to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application should be included in the scope of protection of this application.
Claims
1. An audio encoding method, It is characterized in that The method comprises: Determine a current bandwidth cutoff coefficient based on the currently used number of bits, the number of channels, and the number of sampling points of the audio signal, wherein the currently used number of bits refers to the number of bits consumed by encoding the spectrum of the current audio frame of the audio signal before the current time; Based on the current bandwidth cutoff coefficient, determine m subbands to be currently encoded from a plurality of subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the plurality of subbands; Based on the current bandwidth cutoff coefficient, encoding the target quantization scales corresponding to the m sub-bands into a bitstream, wherein the target quantization scale refers to the number of bits required to encode the frequency band information with the largest amplitude in the corresponding sub-band; Allocate quantization bits to the m subbands based on current remaining quantization scales respectively corresponding to the m subbands, where the current remaining quantization scale refers to a quantization scale remaining unallocated after quantization bits were allocated to the corresponding subbands last time; Based on the quantization bits currently allocated to the m sub-bands, frequency band information in the m sub-bands is encoded into a bitstream.
2. The method according to claim 1, It is characterized in that The step of encoding the target quantization scales corresponding to the m sub-bands into a bitstream based on the current bandwidth cutoff coefficient comprises: In a case where the current bandwidth cutoff coefficient indicates a non-full band, determining a difference in target quantization scales between every two adjacent subbands in the m subbands to obtain m-1 quantization scale differences; Determine the minimum and maximum values of the m-1 quantization scale differences; If the minimum value is greater than the first threshold and the maximum value is less than the second threshold, the target quantization scales corresponding to the m sub-bands are encoded into the bitstream using a differential coding method.
3. The method according to claim 1 or 2, It is characterized in that The allocating quantization bits to the m subbands based on the current remaining quantization scales respectively corresponding to the m subbands includes: When the current residual quantization scales of the m subbands are not all 0 and are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
4. The method according to claim 1 or 2, It is characterized in that The allocating quantization bits to the m subbands based on the current remaining quantization scales respectively corresponding to the m subbands includes: When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales respectively corresponding to the m subbands to obtain masked residual quantization scales respectively corresponding to the m subbands; Based on the quantization step size, scaling the masked residual quantization scales respectively corresponding to the m sub-bands to obtain scaled residual quantization scales respectively corresponding to the m sub-bands; Quantization bits are allocated to the m subbands based on the scaled residual quantization scales respectively corresponding to the m subbands and the target quantization scales respectively corresponding to the m subbands.
5. The method according to any one of claims 1 to 4, It is characterized in that The step of encoding frequency band information in the m sub-bands into a bitstream based on the quantization bits currently allocated to the m sub-bands comprises: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, the frequency band information in the target subband is encoded into the bitstream using an entropy coding method, and the target subband is any one of the m subbands.
6. The method according to any one of claims 1 to 4, It is characterized in that The step of encoding frequency band information in the m sub-bands into a bitstream based on the quantization bits currently allocated to the m sub-bands comprises: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is encoded into the bitstream using a binary encoding method based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
7. The method according to any one of claims 1 to 4, It is characterized in that The step of encoding frequency band information in the m sub-bands into a bitstream based on the quantization bits currently allocated to the m sub-bands comprises: When the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, based on the quantization bits currently allocated to the target subband, the frequency band information in the target subband is encoded into the bitstream using a binary encoding method, and the target subband is any one of the m subbands.
8. The method according to any one of claims 1 to 7, It is characterized in that The audio signal has side information, and the side information includes a coding flag. When the coding flag is a first value, the audio signal is a single-channel audio signal. When the coding flag is a second value, the audio signal is a multi-channel audio signal.
9. An audio decoding method, It is characterized in that The method comprises: Determine a current bandwidth cutoff coefficient based on the currently used number of bits, the number of channels, and the number of sampling points of the audio signal, wherein the currently used number of bits refers to the number of bits consumed by decoding the spectrum of the current audio frame of the audio signal before the current time; Based on the current bandwidth cutoff coefficient, determine m subbands to be decoded currently from a plurality of subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the plurality of subbands; Based on the current bandwidth cutoff coefficient, parsing the target quantization scales corresponding to the m sub-bands from the bitstream, the target quantization scale refers to the number of bits required to encode the frequency band information with the largest amplitude in the corresponding sub-band; Allocate quantization bits to the m subbands based on current remaining quantization scales respectively corresponding to the m subbands, where the current remaining quantization scale refers to a quantization scale remaining unallocated after quantization bits were allocated to the corresponding subbands last time; Based on the quantization bits currently allocated to the m sub-bands, frequency band information in the m sub-bands is parsed from the bitstream.
10. The method according to claim 9, It is characterized in that The step of parsing target quantization scales corresponding to the m sub-bands from the bitstream based on the current bandwidth cutoff coefficient includes: When the current bandwidth cutoff coefficient indicates a non-full band, the target quantization scales respectively corresponding to the m sub-bands are parsed from the bitstream.
11. The method according to claim 9 or 10, It is characterized in that The allocating quantization bits to the m subbands based on the current remaining quantization scales respectively corresponding to the m subbands includes: In a case where current residual quantization scales respectively corresponding to the m subbands are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
12. The method according to claim 9 or 10, It is characterized in that The allocating quantization bits to the m subbands based on the current remaining quantization scales respectively corresponding to the m subbands includes: When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales respectively corresponding to the m subbands to obtain masked residual quantization scales respectively corresponding to the m subbands; Based on the quantization step size, scaling the masked residual quantization scales respectively corresponding to the m sub-bands to obtain scaled residual quantization scales respectively corresponding to the m sub-bands; Quantization bits are allocated to the m subbands based on the scaled residual quantization scales respectively corresponding to the m subbands and the target quantization scales respectively corresponding to the m subbands.
13. The method according to any one of claims 9 to 12, It is characterized in that The step of parsing frequency band information in the m subbands from the bitstream based on the quantization bits currently allocated to the m subbands includes: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, entropy decoding is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
14. The method according to any one of claims 9 to 12, It is characterized in that The step of parsing frequency band information in the m subbands from the bitstream based on the quantization bits currently allocated to the m subbands includes: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bits currently allocated to the target subband are greater than 1, based on the quantization bits currently allocated to the target subband, a binary decoding method is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
15. The method according to any one of claims 9 to 12, It is characterized in that The step of parsing frequency band information in the m subbands from the bitstream based on the quantization bits currently allocated to the m subbands includes: When the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, based on the quantization bits currently allocated to the target subband, a binary decoding method is used to parse the frequency band information in the target subband from the bit stream, and the target subband is any one of the m subbands.
16. The method according to any one of claims 9 to 15, It is characterized in that After parsing the frequency band information in the m subbands from the bitstream based on the quantization bits currently allocated to the m subbands, the method further includes: When the target subband is parsed, if the number of bits parsed from the target frequency band information of the target subband is less than the target quantization scale of the target subband, the target frequency band information is padded with low-order bits, and the target subband is any one of the m subbands, and the target frequency band information is any one of the frequency band information of the target subband.
17. An audio encoding device, It is characterized in that The device comprises: A coefficient determination module, configured to determine a current bandwidth cutoff coefficient based on a currently used number of bits, a number of channels, and a number of sampling points of an audio signal, wherein the currently used number of bits refers to the number of bits consumed by encoding a spectrum of a current audio frame of the audio signal before a current time; a subband determination module, configured to determine, based on the current bandwidth cutoff coefficient, m subbands to be currently encoded from a plurality of subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the plurality of subbands; A quantization scale encoding module, used for encoding the target quantization scales corresponding to the m sub-bands into a bitstream based on the current bandwidth cutoff coefficient, wherein the target quantization scale refers to the number of bits required to encode the frequency band information with the largest amplitude in the corresponding sub-band; A quantization bit allocation module, configured to allocate quantization bits to the m subbands based on current remaining quantization scales respectively corresponding to the m subbands, wherein the current remaining quantization scale refers to the quantization scale remaining unallocated after the quantization bits were allocated to the corresponding subbands last time; The frequency band information encoding module is used to encode the frequency band information in the m sub-bands into a bit stream based on the quantization bits currently allocated to the m sub-bands.
18. The device according to claim 17, It is characterized in that The quantization scale encoding module is specifically used for: In a case where the current bandwidth cutoff coefficient indicates a non-full band, determining a difference in target quantization scales between every two adjacent subbands in the m subbands to obtain m-1 quantization scale differences; Determine the minimum and maximum values of the m-1 quantization scale differences; If the minimum value is greater than the first threshold and the maximum value is less than the second threshold, a differential coding method is adopted to encode the target quantization scales corresponding to the m sub-bands into a bitstream.
19. The device according to claim 17 or 18, It is characterized in that The quantization bit allocation module is specifically used for: When the current residual quantization scales of the m subbands are not all 0 and are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
20. The device according to claim 17 or 18, It is characterized in that The quantization bit allocation module is specifically used for: When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales respectively corresponding to the m subbands to obtain masked residual quantization scales respectively corresponding to the m subbands; Based on the quantization step size, scaling the masked residual quantization scales respectively corresponding to the m sub-bands to obtain scaled residual quantization scales respectively corresponding to the m sub-bands; Based on the scaled residual quantization scales corresponding to the m sub-bands and the target quantization scales corresponding to the m sub-bands, The m subbands are allocated quantization bits.
21. The device according to any one of claims 17 to 20, It is characterized in that The frequency band information encoding module is specifically used for: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, the frequency band information in the target subband is encoded into the bitstream using an entropy coding method, and the target subband is any one of the m subbands.
22. The device according to any one of claims 17 to 20, It is characterized in that The frequency band information encoding module is specifically used for: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bits currently allocated to the target subband are greater than 1, the frequency band information in the target subband is encoded into the bitstream using a binary encoding method based on the quantization bits currently allocated to the target subband, and the target subband is any one of the m subbands.
23. The device according to any one of claims 17 to 20, It is characterized in that The frequency band information encoding module is specifically used for: When the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, based on the quantization bits currently allocated to the target subband, the frequency band information in the target subband is encoded into the bitstream using a binary encoding method, and the target subband is any one of the m subbands.
24. The device according to any one of claims 17 to 23, It is characterized in that The audio signal has side information, and the side information includes a coding flag. When the coding flag is a first value, the audio signal is a single-channel audio signal. When the coding flag is a second value, the audio signal is a multi-channel audio signal.
25. An audio decoding device, It is characterized in that The device comprises: A coefficient determination module, configured to determine a current bandwidth cutoff coefficient based on a currently used number of bits, a number of channels, and a number of sampling points of an audio signal, wherein the currently used number of bits refers to the number of bits consumed by decoding a spectrum of a current audio frame of the audio signal before a current time; a subband determination module, configured to determine, based on the current bandwidth cutoff coefficient, m subbands to be decoded from a plurality of subbands included in the spectrum, where m is greater than or equal to 1 and less than or equal to the total number of the plurality of subbands; A quantization scale parsing module, configured to parse, from a bitstream, target quantization scales corresponding to the m sub-bands respectively based on the current bandwidth cutoff coefficient, wherein the target quantization scale refers to the number of bits required to encode the frequency band information with the largest amplitude in the corresponding sub-band; A quantization bit allocation module, configured to allocate quantization bits to the m subbands based on current remaining quantization scales respectively corresponding to the m subbands, wherein the current remaining quantization scale refers to the quantization scale remaining unallocated after the quantization bits were allocated to the corresponding subbands last time; The frequency band information parsing module is used to parse the frequency band information in the m sub-bands from the bit stream based on the quantization bits currently allocated to the m sub-bands.
26. The device according to claim 25, It is characterized in that The quantization scale analysis module is specifically used for: When the current bandwidth cutoff coefficient indicates a non-full band, the target quantization scales respectively corresponding to the m sub-bands are parsed from the bitstream.
27. The device according to claim 25 or 26, It is characterized in that The quantization bit allocation module is specifically used for: When the current residual quantization scales of the m subbands are all smaller than the quantization step size, quantization bits are allocated to the m subbands based on the current residual quantization scales respectively corresponding to the m subbands.
28. The device according to claim 25 or 26, It is characterized in that The quantization bit allocation module is specifically used for: When the current residual quantization scale of at least one of the m subbands is greater than the quantization step size, psychoacoustic masking is performed on the current residual quantization scales respectively corresponding to the m subbands to obtain masked residual quantization scales respectively corresponding to the m subbands; Based on the quantization step size, scaling the masked residual quantization scales respectively corresponding to the m sub-bands to obtain scaled residual quantization scales respectively corresponding to the m sub-bands; Based on the scaled residual quantization scales corresponding to the m sub-bands and the target quantization scales corresponding to the m sub-bands, The m subbands are allocated quantization bits.
29. The device according to any one of claims 25 to 28, It is characterized in that The frequency band information analysis module is specifically used for: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bit currently allocated to the target subband is 1, based on the quantization bit currently allocated to the target subband, entropy decoding is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
30. The device according to any one of claims 25 to 28, It is characterized in that The frequency band information analysis module is specifically used for: When the current number of quantization layers of the target subband is less than or equal to the maximum number of quantization layers, if the quantization bits currently allocated to the target subband are greater than 1, based on the quantization bits currently allocated to the target subband, a binary decoding method is used to parse the frequency band information in the target subband from the bitstream, and the target subband is any one of the m subbands.
31. The device according to any one of claims 25 to 28, It is characterized in that The frequency band information analysis module is specifically used for: When the current number of quantization layers of the target subband is greater than the maximum number of quantization layers, based on the quantization bits currently allocated to the target subband, a binary decoding method is used to parse the frequency band information in the target subband from the bit stream, and the target subband is any one of the m subbands.
32. The device according to any one of claims 25 to 31, It is characterized in that The device also includes: The bit filling module is used to fill the target frequency band information with low bits when the target subband is parsed and the number of bits parsed out of the target frequency band information of the target subband is less than the target quantization scale of the target subband. The target subband is any one of the m subbands, and the target frequency band information is any one of the frequency band information of the target subband.
33. An audio encoding device, It is characterized in that The audio encoding device comprises a memory and a processor; The memory is used to store a computer program, wherein the computer program includes program instructions; The processor is used to call the computer program to implement the method according to any one of claims 1-8.
34. An audio decoding device, It is characterized in that The audio decoding device includes a memory and a processor; The memory is used to store a computer program, wherein the computer program includes program instructions; The processor is used to call the computer program to implement the method according to any one of claims 9 to 16.
35. A computer readable storage medium, It is characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 16 is implemented.
36. A computer program product, It is characterized in that The computer program product stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 16 is implemented.
Citation Information
Patent Citations
Audio encoding device5 audio decoding device, audio encoding method, audio decoding method, and information recording
CN101523485A
Layering audio coding and decoding method and system
CN102081927A
Wireless audio compression and decompression methods, audio coder and audio decoder
CN102436819A
Enhanced audio decoder
CN102598121A
Scalable audio coding / decoding method and apparatus
CN1195160A
