Audio coding method and apparatus
By dynamically switching between low-bitrate and high-bitrate encoding methods between audio sending and receiving devices in Bluetooth devices, the problem of audio quality transition in Bluetooth channel-limited environments is solved, enabling high-quality music playback in different scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2020-11-11
- Publication Date
- 2026-06-05
AI Technical Summary
In environments with limited Bluetooth channels, how can a smooth transition be achieved between high-bitrate and low-bitrate codecs to meet users' needs for high-quality music in different scenarios?
By working together between the audio transmitting and receiving devices, low-bit-rate encoding and high-bit-rate encoding methods are dynamically switched to ensure that the encoding and decoding of audio frames are adaptively adjusted according to the channel status and the encoding method of the previous frame, thus achieving seamless integration.
Under Bluetooth channel limitations, we maximize audio quality, improve Bluetooth channel anti-interference capabilities, and provide an optimized audio experience.
Smart Images

Figure CN114495951B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to audio coding technology, and in particular to an audio coding method and device. BACKGROUND
[0002] With the wide popularity and use of wireless Bluetooth devices such as true wireless stereo (TWS) earphones, smart sound boxes, and smart watches in people's daily life, people's demand for high-quality music playing experience in various scenarios has become increasingly urgent, especially in environments such as subways, airports, and train stations where Bluetooth signals are easily disturbed. Due to the size limitation of the Bluetooth channel for data transmission, the music data stream must be compressed by the audio encoder of the Bluetooth device sending end before being transmitted to the Bluetooth device receiving end for decoding, which also promotes the vigorous development of various Bluetooth audio codecs.
[0003] Bluetooth audio codecs are mainly applied between Bluetooth interconnected devices (earphones, sound boxes, smart wearable devices, etc.) to provide high-quality music transmission and playback under different scene requirements. Currently, audio coding technology is divided into two types: one is high-bit-rate coding technology, which can be applied to scenarios with high requirements for Bluetooth channel transmission quality, and the other is low-bit-rate coding technology, which can be applied to scenarios with high requirements for sound quality.
[0004] Therefore, how to achieve a smooth transition between high-bit-rate coding and low-bit-rate coding is the key to meeting users' demand for high-quality music in any scenario. SUMMARY
[0005] The present application provides an audio coding method and device to achieve seamless integration of low-bit-rate coding processing and high-bit-rate coding processing, so as to maximize the sound quality of the audio under the premise of meeting the size limitation of the Bluetooth channel for data transmission, improve the anti-interference ability of the Bluetooth channel, and bring users a more optimized audio experience.
[0006] In a first aspect, this application provides an audio encoding / decoding method, comprising: an audio transmitting device obtaining a set bitrate of the current audio frame to be encoded and the final encoding method of the previous audio frame, wherein the final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding method to the second bitrate encoding method, or a switching encoding method from the second bitrate encoding method to the first bitrate encoding method, wherein the first bitrate is lower than the second bitrate; determining the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame; and encoding the current audio frame according to the final encoding method of the current audio frame. The audio transmitting device then transmits the bitstream information to an audio receiving device. The audio receiving device obtains the bitstream information; it parses the bitstream information to obtain the decoding method and the encoded bitstream. The encoded bitstream includes a first bitrate encoded bitstream and / or a second bitrate encoded bitstream. The decoding method includes a first bitrate decoding method, a second bitrate decoding method, a switching decoding method from first bitrate decoding to second bitrate decoding, or a switching decoding method from second bitrate decoding to first bitrate decoding. When the decoding method is the first bitrate decoding method, the encoded bitstream includes the first bitrate encoded bitstream. When the decoding method is the second bitrate decoding method, the encoded bitstream includes the second bitrate encoded bitstream. When the decoding method is a switching decoding method from first bitrate decoding to second bitrate decoding or a switching decoding method from second bitrate decoding to first bitrate decoding, the encoded bitstream includes both the first bitrate encoded bitstream and the second bitrate encoded bitstream. The encoded bitstream is decoded according to the decoding method to obtain the target audio frame.
[0007] An audio frame can be any frame of audio sent from an audio transmitting device to an audio receiving device. In this application, each encoding operation can target a single audio frame; that is, the audio encoding method provided in this application is for a single audio frame, and the encoding method described below applies to every audio frame. Therefore, for distinction, the audio frame being encoded by the audio transmitting device is referred to as the audio frame or the current audio frame, and the audio frame encoded by the audio transmitting device prior to the current audio frame is referred to as the previous audio frame. Optionally, the audio frame can be represented in the form of audio pulse code modulation (PCM) data.
[0008] The set code rate can be a target coding code rate preset by the user based on the current channel conditions. This set code rate can be, for example, 192kbps, 256kbps, 400kbps, or 600kbps.
[0009] The final encoding method refers to the actual encoding method used by the audio transmitting device when encoding audio frames. This can include a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding to the second bitrate encoding, or a switching encoding method from the second bitrate encoding to the first bitrate encoding. The first bitrate is lower than the second bitrate. For example, the first bitrate could be 64kbps, 128kbps, 192kbps, 256kbps, 400kbps, or 600kbps, etc., and the second bitrate could be 128kbps, 192kbps, 256kbps, 400kbps, or 600kbps, etc. It should be noted that the specific values of the first and second bitrates are not limited in this embodiment of the invention, as long as the first bitrate is lower than the second bitrate. In the following text, the first bitrate can also be referred to as the low bitrate, and the second bitrate as the high bitrate.
[0010] This application involves two types of encoding processing: a first bitrate encoding processing and a second bitrate encoding processing, namely low bitrate encoding processing and high bitrate encoding processing. The low bitrate encoding processing may include, for example, an advanced audio coding (AAC) encoder, a low-complexity communication codec (LC3) that is the default for next-generation Bluetooth, and so on. The high bitrate encoding processing may include, for example, a low-latency hi-definition audio codec (LHDC) encoder, a low-complexity communication codec plus (LC3plus) encoder, and so on.
[0011] In one possible implementation, where the frame length of low-bitrate encoding is the same as that of high-bitrate encoding, and the total encoding / decoding latency of low-bitrate encoding is the same as that of high-bitrate encoding, then when the set bitrate is less than a set threshold, and the final encoding method of the previous audio frame was low-bitrate encoding, the final encoding method of the current audio frame is determined to be low-bitrate encoding; or...
[0012] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame was high bitrate encoding, the encoding method of the current audio frame is determined to switch from high bitrate encoding to low bitrate encoding; or,
[0013] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame was a switch from low bitrate encoding to high bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from high bitrate encoding to low bitrate encoding; or,
[0014] When the set bitrate is less than the set threshold, and the previous audio frame's final encoding method was a switch from high bitrate encoding to low bitrate encoding, the current audio frame's final encoding method is determined to be low bitrate encoding; or,
[0015] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame was low bitrate encoding, the final encoding method of the current audio frame is determined to switch from low bitrate encoding to high bitrate encoding; or,
[0016] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame was a high bitrate encoding method, the final encoding method of the current audio frame is determined to be a high bitrate encoding method; or,
[0017] When the set bitrate is greater than the set threshold, and the previous audio frame's final encoding method was a switch from low bitrate encoding to high bitrate encoding, the current audio frame's final encoding method is determined to be high bitrate encoding; or,
[0018] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is a switch from high bitrate encoding to low bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from low bitrate encoding to high bitrate encoding.
[0019] The threshold value mentioned above is related to the number of channels in the audio frame. For example, when the audio frame has only one channel, the threshold can be set to 150kbps; when the audio frame has two channels, the threshold can be set to 300kbps.
[0020] In one possible implementation, when the frame lengths for low-bitrate encoding and high-bitrate encoding are different, if the set bitrate is less than a set threshold and the final encoding method of the previous audio frame was low-bitrate encoding, then the final encoding method of the current audio frame is determined to be low-bitrate encoding; or...
[0021] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is high bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from high bitrate encoding to low bitrate encoding. A first counter is started, with an initial value of a first set value. The first counter terminates when its value reaches 0. The purpose of starting the first counter is to track the processing of switching frames. It is started when processing the first switching frame, and its initial value is set to the number of calculated switching frames (the first set value). After processing each switching frame, the first counter is decremented by 1. When the first counter's value is 0, it indicates that all switching frames have been encoded, and the first counter is terminated. A first counter value of the first set value indicates that the current processing is the first switching frame; a first counter value of 1 indicates that the current processing is the last switching frame; a first counter value less than the first set value but greater than 1 indicates that the current processing is an intermediate switching frame; or...
[0022] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame was a high bitrate encoding method, the final encoding method of the current audio frame is determined to be a high bitrate encoding method; or,
[0023] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is low bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from low bitrate encoding to high bitrate encoding. A second counter is then started, with its initial value being the first set value. The second counter terminates when its value reaches 0. Similarly, the purpose of starting the second counter is to track the processing of switching frames. This second counter is started when processing the first switching frame, and its initial value is set to the number of switching frames obtained (the first set value). After processing each switching frame, the second counter is decremented by 1. When the value of the second counter is 0, it indicates that all switching frames have been encoded, and the second counter is then terminated. A value of the second counter equal to the first set value indicates that the current processing is the first switching frame; a value of the second counter equal to 1 indicates that the current processing is the last switching frame; a value of the second counter less than the first set value but greater than 1 indicates that the current processing is an intermediate switching frame; or...
[0024] When the previous audio frame's final encoding method was a high-bitrate to low-bitrate switching encoding, and the first counter is active (i.e., the first counter's value is greater than 0), the first counter's value is decremented by 1. If the first counter is still active, the current audio frame's final encoding method is determined to be a high-bitrate to low-bitrate switching encoding. Alternatively, if the first counter terminates (i.e., the first counter's value is 0), the current audio frame's final encoding method is determined to be a low-bitrate encoding.
[0025] When the final encoding method of the previous audio frame is a low bitrate encoding to high bitrate encoding switching encoding method, and the second counter is in the started state (that is, the value of the second counter is greater than 0), the value of the second counter is decremented by 1; if the second counter is still in the started state, it is determined that the final encoding method of the current audio frame is a low bitrate encoding to high bitrate encoding switching encoding method; or, if the second counter is terminated (that is, the value of the second counter is 0), it is determined that the final encoding method of the current audio frame is a high bitrate encoding method.
[0026] Similarly, the value of the threshold mentioned above is related to the number of channels in the audio frame. For example, when the audio frame has a mono channel, the threshold can be set to 165kbps, and when the audio frame has a stereo channel, the threshold can be set to 330kbps.
[0027] The number of switching frames D can be obtained using the following method, where A represents low bitrate encoding, B represents high bitrate encoding, A→B represents switching from low bitrate encoding to high bitrate encoding, and B→A represents switching from high bitrate encoding to low bitrate encoding.
[0028] (1) Number of switching frames from A to B
[0029] D = ((max(total delay of low bitrate encoding / decoding, total delay of high bitrate encoding / decoding) + low bitrate to high bitrate overlap length + processing frame length - 1) / processing frame length)
[0030] (2) Number of switching frames from B to A
[0031] D = ((max(total delay of low bitrate encoding / decoding, total delay of high bitrate encoding / decoding) + high bitrate to low bitrate overlap length + processing frame length - 1) / processing frame length)
[0032] Wherein, the processing frame length = max(the frame length processed by low bitrate encoding, the frame length processed by high bitrate encoding), the low bitrate to high bitrate overlap length = processing frame length - total delay of low bitrate encoding and decoding % processing frame length, the high bitrate to low bitrate overlap length = processing frame length - total delay of high bitrate encoding and decoding % processing frame length, and % represents the modulo operation.
[0033] The audio transmitting device encodes the current audio frame, so the following situations are possible:
[0034] 1. The frame length of low-bitrate encoding is the same as that of high-bitrate encoding, and the total encoding / decoding latency of low-bitrate encoding is the same as that of high-bitrate encoding.
[0035] (1) The final encoding method of the current audio frame is low bitrate encoding.
[0036] The audio transmitting device performs low-bitrate encoding on the current audio frame.
[0037] In one possible implementation, the audio transmitting device can first determine whether the low bitrate encoding process supports the sampling rate of the current audio frame. If the low bitrate encoding process supports the sampling rate of the current audio frame, the current audio frame can be directly encoded using the low bitrate encoding process. Alternatively, if the low bitrate encoding process does not support the sampling rate of the current audio frame, the current audio frame can be downsampled or upsampled first to obtain the downsampled or upsampled current audio frame, and then the downsampled or upsampled current audio frame can be encoded using the low bitrate encoding process, which supports the sampling rate of the downsampled or upsampled current audio frame. For example, since low bitrate encoding does not support sampling rates of 88.2kHz and 96kHz, audio transmitting devices can use quadrature mirror filter (QMF) for downsampling. This divides the frequency band corresponding to 88.2kHz (0–44.1kHz) into two sub-bands: 0–22.05kHz and 22.05–44.1kHz, and selects the lower sub-band 0–22.05kHz for low bitrate encoding. Similarly, it divides the frequency band corresponding to 96kHz (0–48kHz) into two sub-bands: 0–24kHz and 24–48kHz, and selects the lower sub-band 0–24kHz for low bitrate encoding.
[0038] (2) The final encoding method of the current audio frame is high bitrate encoding.
[0039] The audio transmitting device performs high-bitrate encoding on the current audio frame.
[0040] In one possible implementation, the audio transmitting device can first determine whether the high bitrate encoding process supports the sampling rate of the current audio frame. If the high bitrate encoding process supports the sampling rate of the current audio frame, the current audio frame can be directly encoded using the high bitrate encoding process. Alternatively, if the high bitrate encoding process does not support the sampling rate of the current audio frame, the current audio frame can be downsampled or upsampled first to obtain the downsampled or upsampled current audio frame, and then the downsampled or upsampled current audio frame can be encoded using the high bitrate encoding process, which supports the sampling rate of the downsampled or upsampled current audio frame.
[0041] (3) The final encoding method of the current audio frame is either switching from low bitrate encoding to high bitrate encoding or switching from high bitrate encoding to low bitrate encoding.
[0042] The audio transmitting device can perform low-bitrate encoding and high-bitrate encoding on the current audio frame. Similarly, the audio transmitting device can first determine whether the high-bitrate and low-bitrate encoding processes support the sampling rate of the current audio frame, as described above; this will not be elaborated further here.
[0043] 2. The frame lengths of low-bitrate encoding and high-bitrate encoding are different, or the frame lengths of low-bitrate encoding and high-bitrate encoding are the same, but the total encoding and decoding latency is different.
[0044] (1) The final encoding method of the current audio frame is low bitrate encoding.
[0045] The audio transmitting device can first determine whether the low bitrate encoding process supports the sampling rate of the current audio frame. If the low bitrate encoding process supports the sampling rate of the current audio frame, it can directly perform low bitrate encoding processing on the current audio frame. Alternatively, if the low bitrate encoding process does not support the sampling rate of the current audio frame, it can first perform downsampling or upsampling processing on the current audio frame to obtain the downsampled or upsampled current audio frame, and then perform low bitrate encoding processing on the downsampled or upsampled current audio frame. This low bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
[0046] (2) The final encoding method of the current audio frame is high bitrate encoding.
[0047] The audio transmitting device can first determine whether the high bitrate encoding process supports the sampling rate of the current audio frame. If the high bitrate encoding process supports the sampling rate of the current audio frame, it can directly perform high bitrate encoding processing on the current audio frame. Alternatively, if the high bitrate encoding process does not support the sampling rate of the current audio frame, it can first perform downsampling or upsampling processing on the current audio frame to obtain the downsampled or upsampled current audio frame, and then perform high bitrate encoding processing on the downsampled or upsampled current audio frame. This high bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
[0048] (3) The final encoding method of the current audio frame is a switching encoding method from low bitrate encoding to high bitrate encoding.
[0049] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0050] As described above, the function of the second counter is to track the processing status of switching frames. When the second counter is active, it indicates that the currently processed frame is still a switching frame. At this time, if the value of the second counter is greater than 1 (indicating that the currently processed frame is still a switching frame but not the last frame in the switching frame sequence), low-bitrate encoding is performed on the current audio frame; otherwise, high-bitrate encoding is performed. Alternatively, if the value of the second counter is equal to 1 (indicating that the currently processed frame is the last frame in the switching frame sequence), high-bitrate encoding is performed on the current audio frame.
[0051] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0052] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0053] As described above, the function of the second counter is to track the processing status of switching frames. When the second counter is active, it indicates that the currently processed frame is still a switching frame. When the value of the second counter equals the first set value (indicating that the currently processed frame is the first frame in the switching frame), the current audio frame is encoded at a low bitrate; or it is encoded at a high bitrate. Alternatively, when the value of the second counter is less than the first set value (indicating that the currently processed frame is still a switching frame but not the first frame in the switching frame), the current audio frame is encoded at a high bitrate.
[0054] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0055] (4) The final encoding method of the current audio frame is a switch from high bitrate encoding to low bitrate encoding.
[0056] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0057] As described above, the function of the first counter is to track the processing status of switching frames. When the first counter is in the active state, it indicates that the currently processed frame is still a switching frame. At this time, when the value of the first counter is equal to the first set value (indicating that the currently processed frame is the first frame in the switching frame), the current audio frame is processed by low bitrate encoding; or by high bitrate encoding. Alternatively, when the value of the first counter is less than the first set value (indicating that the currently processed frame is still a switching frame but not the first frame in the switching frame), the current audio frame is processed by low bitrate encoding.
[0058] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0059] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0060] As described above, the function of the first counter is to track the processing status of switching frames. When the first counter is active, it indicates that the currently processed frame is still a switching frame. At this time, if the value of the first counter is greater than 1 (indicating that the currently processed frame is still a switching frame but not the last frame in the switching frame sequence), low-bitrate encoding is performed on the current audio frame; otherwise, high-bitrate encoding is performed. Alternatively, if the value of the first counter is equal to 1 (indicating that the currently processed frame is the last frame in the switching frame sequence), low-bitrate encoding is performed on the current audio frame.
[0061] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0062] The encoded bitstream information corresponding to the current audio frame includes header information, a low-bitrate encoded bitstream, and / or a high-bitrate encoded bitstream. The header information includes the final encoding method, sampling rate, number of channels, frame length, and length of the low-bitrate encoded bitstream for the current audio frame. If the audio transmitting device only performs low-bitrate encoding on the current audio frame, the bitstream information will only contain the low-bitrate encoded bitstream; if the audio transmitting device only performs high-bitrate encoding on the current audio frame, the bitstream information will only contain the high-bitrate encoded bitstream; if the audio transmitting device performs both low-bitrate and high-bitrate encoding on the current audio frame, the bitstream information will contain both low-bitrate and high-bitrate encoded bitstreams.
[0063] Audio transmitting devices can send bitstream information to audio receiving devices via communication methods such as Bluetooth connections.
[0064] Corresponding to the encoding end, the encoding method used by the audio transmitting device to encode the audio frame must be matched by the corresponding decoding method used at the decoding end to decode the encoded bitstream. Therefore, the following decoding methods exist:
[0065] 1. The frame length of low-bitrate encoding is the same as that of high-bitrate encoding, and the total encoding / decoding latency of low-bitrate encoding is the same as that of high-bitrate encoding.
[0066] (1) The decoding method is low bit rate decoding method.
[0067] Audio receiving devices perform low-bitrate decoding on low-bitrate encoded streams.
[0068] In one possible implementation, the audio receiving device can first determine whether the low-bitrate decoding process supports the sampling rate corresponding to the low-bitrate encoded stream. If the low-bitrate decoding process supports the sampling rate, it can directly perform low-bitrate decoding on the low-bitrate encoded stream. Alternatively, if the low-bitrate decoding process does not support the sampling rate, it can first perform low-bitrate decoding on the low-bitrate encoded stream, and then perform upsampling or downsampling on the decoded data to obtain the target audio frame. It should be noted that the upsampling or downsampling performed at the encoding and decoding ends are corresponding; that is, if the encoding end uses downsampling, the decoding end can use upsampling, and vice versa. For example, in the above description, at the encoding end, the audio transmitting device downsamples the audio frame and then encodes the low-frequency subband. Correspondingly, at the decoding end, after decoding the low-bitrate encoded stream, the audio receiving device, lacking data in the high-frequency subband, upsamples by padding with zeros to obtain the target audio frame.
[0069] (2) The decoding method is high bitrate decoding.
[0070] Audio receiving devices perform high-bitrate decoding on high-bitrate encoded streams.
[0071] In one possible implementation, the audio receiving device can first determine whether the high bitrate decoding process supports the sampling rate corresponding to the high bitrate encoded bitstream. If the high bitrate decoding process supports the sampling rate, the high bitrate encoded bitstream can be directly decoded at a high bitrate. Alternatively, if the high bitrate decoding process does not support the sampling rate, the high bitrate encoded bitstream can be decoded at a high bitrate first, and then the decoded data can be upsampled or downsampled to obtain the target audio frame.
[0072] (3) The decoding method is a switch from low bitrate decoding to high bitrate decoding.
[0073] The audio receiving device performs low-bitrate decoding on the low-bitrate encoded bitstream to obtain second data, and performs high-bitrate decoding on the high-bitrate encoded bitstream to obtain first data. After obtaining the second and first data, the audio receiving device can perform smoothing processing on the back end of the second data and the front end of the first data to ensure a smooth switch between low and high bitrates. The smoothed data length is N sample data points, that is, the weighted average of the last N sample data points of the second data and the first N sample data points of the first data is used to obtain N sample smoothed data points. The target audio frame is obtained based on the other data of the second data points excluding the last N sample data points and the N sample smoothed data points.
[0074] Similarly, the audio receiving device can first determine whether the high and low bit rate decoding processes support the sampling rate as described above, which will not be repeated here.
[0075] (4) The decoding method is to switch from high bitrate decoding to low bitrate decoding.
[0076] The audio receiving device performs high-bitrate decoding on the high-bitrate encoded stream to obtain first data, and low-bitrate decoding on the low-bitrate encoded stream to obtain second data. After obtaining the first and second data, the audio receiving device can perform smoothing processing on the back end data of the first data and the front end data of the second data to ensure smooth switching between high and low bitrates. The smoothed data length is N sample data points, that is, the weighted average of the last N sample data points of the first data and the first N sample data points of the second data is used to obtain N sample smoothed data points. The target audio frame is obtained based on the other data of the first data points excluding the last N sample data points and the N sample smoothed data points.
[0077] Similarly, the audio receiving device can first determine whether the high and low bit rate decoding processes support the sampling rate as described above, which will not be repeated here.
[0078] 2. Low bitrate encoding and high bitrate encoding have different frame lengths.
[0079] (1) The decoding method is low bit rate decoding method.
[0080] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0081] Audio receiving devices perform low-bitrate decoding on low-bitrate encoded streams.
[0082] In one possible implementation, the audio receiving device can first determine whether the low bitrate decoding process supports the sampling rate corresponding to the low bitrate encoded bitstream. If the low bitrate decoding process supports the sampling rate, the low bitrate encoded bitstream can be directly decoded at a low bitrate. Alternatively, if the low bitrate decoding process does not support the sampling rate, the low bitrate encoded bitstream can be decoded at a low bitrate first, and then the decoded data can be upsampled or downsampled to obtain the target audio frame.
[0083] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0084] The audio receiving device performs low-bitrate decoding on the low-bitrate encoded bitstream to obtain the second data. Since the frame length of the low-bitrate decoding process is shorter than that of the high-bitrate decoding process, to align the audio frames obtained from the low-bitrate and high-bitrate decoding processes, the audio receiving device, after obtaining the second data, can overflow M sample data points from the head of the second data queue corresponding to the low-bitrate decoding process, and place the second data into the second data queue in a first-in-first-out (FIFO) manner. Then, it extracts M sample data points from the head of the second data queue to obtain the target audio frame. This second data queue follows the FIFO principle. M is associated with the frame length of the high-bitrate decoding process; for example, M = processing frame length × number of channels, where the processing frame length is the same as the frame length of the high-bitrate decoding process.
[0085] Similarly, the audio receiving device can first determine whether the low bit rate decoding process supports the sampling rate as described above, which will not be repeated here.
[0086] (2) The decoding method is high bitrate decoding.
[0087] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0088] The audio receiving device performs high-bitrate decoding on the high-bitrate encoded stream to obtain the first data. Since the frame length of the low-bitrate encoded stream is longer than that of the high-bitrate encoded stream, to align the audio frames obtained from the low-bitrate and high-bitrate decoding processes, the audio receiving device, after obtaining the first data, can overflow M sample data points from the head of the first data queue corresponding to the high-bitrate decoding process and place the first data points at the tail of the first data queue. Then, it can extract M sample data points from the head of the first data queue to obtain the target audio frame. This first data queue follows a first-in, first-out (FIFO) principle. M is associated with the frame length of the low-bitrate decoding process.
[0089] Similarly, the audio receiving device can first determine whether the high bitrate decoding process supports the sampling rate as described above, which will not be repeated here.
[0090] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0091] Audio receiving devices perform high-bitrate decoding on high-bitrate encoded streams.
[0092] In one possible implementation, the audio receiving device can first determine whether the high bitrate decoding process supports the sampling rate corresponding to the high bitrate encoded bitstream. If the high bitrate decoding process supports the sampling rate, the high bitrate encoded bitstream can be directly decoded at a high bitrate. Alternatively, if the high bitrate decoding process does not support the sampling rate, the high bitrate encoded bitstream can be decoded at a high bitrate first, and then the decoded data can be upsampled or downsampled to obtain the target audio frame.
[0093] (3) The decoding method is a switch from low bitrate decoding to high bitrate decoding.
[0094] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0095] When the decoding method of the previous audio frame is not a switch from low bitrate decoding to high bitrate decoding, the first data queue corresponding to the high bitrate decoding process is set to all zeros. The first data queue follows the first-in-first-out principle. The low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data. The high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data. M sample data points overflow from the head of the first data queue and the first data points are placed at the tail of the first data queue. M is associated with the frame length of the low bitrate decoding process. M sample data points are extracted from the head of the first data queue to obtain the third data. The last N sample data points of the second data points and the first N sample data points of the third data points are weighted and averaged to obtain N sample smooth data points. The target audio frame is obtained based on the other data points of the second data points excluding the last N sample data points and the N sample smooth data points.
[0096] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0097] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0098] When the decoding method of the previous audio frame is not a switch from low bitrate decoding to high bitrate decoding, the low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data; M sample data points overflow from the head of the second data queue corresponding to the low bitrate decoding processing, and the second data points are placed at the tail of the second data queue. The second data queue follows the first-in-first-out principle, and M is associated with the frame length of the high bitrate decoding processing; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data; the last N sample data points of the fourth data points are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points. Alternatively, when the decoding method of the previous audio frame is switching from low bitrate decoding to high bitrate decoding, M sample data points overflow from the head of the second data queue; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data; the last N sample data points of the fourth data and the first N sample data points of the first data are weighted and averaged to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points.
[0099] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0100] (4) The decoding method is to switch from high bitrate decoding to low bitrate decoding.
[0101] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0102] When the decoding method of the previous audio frame is not a switch from high bitrate decoding to low bitrate decoding, the high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data; M sample data points overflow from the head of the first data queue corresponding to the high bitrate decoding processing, and the first data points are placed at the tail of the first data queue. The first data queue follows the first-in-first-out principle, and M is associated with the frame length of the low bitrate decoding processing; M sample data points are extracted from the head of the first data queue to obtain the third data; the low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data points to obtain N sample smooth data points; the target audio frame is obtained based on the other data points of the third data points excluding the last N sample data points and the N sample smooth data points. Alternatively, when the decoding method of the previous audio frame is switching from high bitrate decoding to low bitrate decoding, M sample data points are overflowed from the head of the first data queue; M sample data points are extracted from the head of the first data queue to obtain the third data; the low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the third data points excluding the last N sample data points and the N sample smooth data points.
[0103] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0104] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0105] When the decoding method of the previous audio frame is not a switch from high bitrate decoding to low bitrate decoding, the second data queue corresponding to the low bitrate decoding processing is set to all 0s. The second data queue follows the first-in-first-out principle. High bitrate decoding processing is performed on the high bitrate encoded bitstream to obtain the first data. Low bitrate decoding processing is performed on the low bitrate encoded bitstream to obtain the second data. M sample data points overflow from the head of the second data queue and the second data points are placed at the tail of the second data queue. M is associated with the frame length of the high bitrate decoding processing. M sample data points are extracted from the head of the second data queue to obtain the fourth data. The last N sample data points of the first data points and the first N sample data points of the fourth data points are weighted and averaged to obtain N sample smooth data points. The target audio frame is obtained based on the other data of the first data points excluding the last N sample data points and the N sample smooth data points.
[0106] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0107] In one possible implementation, the audio transmitting device can determine a first bitrate corresponding to low bitrate encoding and a second bitrate corresponding to high bitrate encoding based on the set bitrate of the previous audio frame and the set bitrate of the current audio frame. The sum of the first bitrate and the second bitrate is the set bitrate of the current audio frame.
[0108] (1) The final encoding method of the current audio frame is a switch from high bitrate encoding to low bitrate encoding, which can be:
[0109] A. If the set bitrate brp of the previous audio frame satisfies: stereo: 600kbps < brp ≤ 990kbps, mono: 300kbps < brp ≤ 495kbps, and the set bitrate brf of the current audio frame satisfies: stereo: brf < 300kbps, mono: brf < 150kbps, then the bitrate allocation of the current audio frame is: the first bitrate is brf, and the second bitrate is brp - brf.
[0110] B. If the set bitrate brip of the previous audio frame satisfies: stereo: 364kbps < brip ≤ 600kbps, mono: 182kbps < brip ≤ 300kbps, and the set bitrate brip of the current audio frame satisfies: stereo: brip < 300kbps, mono: brip < 150kbps, then the bitrate allocation of the current audio frame is: the first bitrate for stereo is brip - 300kbps, the first bitrate for mono is brip - 150kbps, the second bitrate for stereo is 300kbps, and the second bitrate for mono is 150kbps.
[0111] C. If the set bitrate brip of the previous audio frame satisfies: stereo: 300kbps≤brp≤364kbps, mono: 150kbps≤brp≤182kbps, and the set bitrate brip of the current audio frame satisfies: stereo: brip<300kbps, mono: brip<150kbps, then the bitrate allocation of the current audio frame is: the first bitrate is 64kbps for stereo, the second bitrate is 32kbps for mono, the third bitrate is 300kbps for stereo, and the fourth bitrate is 150kbps for mono.
[0112] (2) The final encoding method of the current audio frame is a switch from low bitrate encoding to high bitrate encoding. Possible encoding methods include:
[0113] A. If the set bitrate brip of the previous audio frame satisfies: stereo: 64kbps≤brp<300kbps, mono: 32kbps≤brp<150kbps, and the set bitrate brip of the current audio frame satisfies: stereo: 600kbps<brf≤990kbps, mono: 300kbps<brf≤495kbps, then the bitrate allocation for the current audio frame is: the first bitrate is brip, and the second bitrate is brip-brp.
[0114] B. If the bitrate (brp) of the previous audio frame satisfies the following conditions: stereo: 364kbps < brf ≤ 600kbps, mono: 182kbps < brf ≤ 300kbps, then the bitrate allocation for the current audio frame is as follows: the first bitrate for stereo is brf-300kbps, the second bitrate for mono is brf-150kbps, the third bitrate for stereo is 300kbps, and the fourth bitrate for mono is 150kbps.
[0115] C. If the bitrate (brp) of the previous audio frame satisfies the following conditions: stereo: 300kbps≤brf≤364kbps, mono: 150kbps≤brf≤182kbps, then the bitrate allocation of the current audio frame is as follows: the first bitrate is 64kbps for stereo, the second bitrate is 32kbps for mono, the third bitrate is 300kbps for stereo, and the fourth bitrate is 150kbps for mono.
[0116] D. If the set bitrate brip of the previous audio frame satisfies: stereo: 600kbps < brip ≤ 990kbps, mono: 300kbps < brip ≤ 495kbps, and the set bitrate brip of the current audio frame satisfies: stereo: 600kbps < brip ≤ 990kbps, mono: 300kbps < brip ≤ 495kbps, then the bitrate allocation of the current audio frame is: the first bitrate and the second bitrate are consistent with the allocation of the previous audio frame.
[0117] E. If the set bitrate bpr of the previous audio frame satisfies: stereo: 364kbps≤brp≤600kbps, mono: 182kbps≤brp≤300kbps, and the set bitrate bref of the current audio frame satisfies: stereo: 600kbps<brf≤990kbps, mono: 300kbps<brf≤495kbps, then the bitrate allocation of the current audio frame is: the first bitrate is 299kbps for stereo, the second bitrate is 149kbps for mono, the third bitrate is brf-299kbps for stereo, and the fourth bitrate is brf-149kbps for mono.
[0118] This application determines the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame. Accordingly, it sets the corresponding bitrates for low-bitrate and high-bitrate encoding processing on audio frames where high and low bitrate switching occurs. The encoding end sends the bitstream information to the decoding end. The decoding end parses the bitstream information to obtain the decoding method and then decodes the bitstream data. In particular, it performs smoothing processing on the decoded data at both high and low bitrates on audio frames where high and low bitrate switching occurs, achieving seamless integration of low-bitrate and high-bitrate encoding / decoding processing. This maximizes audio quality while adhering to Bluetooth channel data transmission size limitations, improves Bluetooth channel anti-interference capabilities, and provides users with a more optimized audio experience.
[0119] Secondly, this application provides an audio encoding apparatus, comprising: an obtaining module, configured to obtain a set bitrate of a current audio frame to be encoded and a final encoding method of a previous audio frame, wherein the final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a first bitrate encoding switching to a second bitrate encoding method, or a second bitrate encoding switching to a first bitrate encoding method, wherein the first bitrate is lower than the second bitrate; a determining module, configured to determine the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame; and an encoding module, configured to encode the current audio frame according to the final encoding method of the current audio frame.
[0120] In one possible implementation, when the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the determining module is specifically configured to: determine that the final encoding mode of the current audio frame is the first bitrate encoding mode when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the first bitrate encoding mode; or, determine that the final encoding mode of the current audio frame is a switch from second bitrate encoding to first bitrate encoding when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the second bitrate encoding mode; or, determine that the final encoding mode of the current audio frame is a switch from second bitrate encoding to first bitrate encoding when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding; or, determine that the final encoding mode of the current audio frame is a switch from second bitrate encoding to first bitrate encoding when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding. When changing the encoding method, the final encoding method of the current audio frame is determined to be the first bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the first bitrate encoding method to the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method. When the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding; wherein, the value of the set threshold is related to the number of channels of the audio frame.
[0121] In one possible implementation, when the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are not the same, the determining module is specifically used to determine that the final encoding method of the current audio frame is the first bitrate encoding method when the set bitrate is less than a set threshold and the final encoding method of the previous audio frame is the first bitrate encoding method; or, when the set bitrate is less than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, determine that the final encoding method of the current audio frame is a switch from the second bitrate encoding method to the first bitrate encoding method. The encoding method is determined as follows: The first bitrate is set to a first set value, and the first counter is activated. The first counter terminates when its value reaches 0. Alternatively, if the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is a second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method. Or, if the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is a first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding. Furthermore, a second counter is started, with an initial value of a first set value, and the second counter terminates when its value is 0; or, when the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, and the value of the first counter is greater than 0, the value of the first counter is decremented by 1; if the value of the first counter is still greater than 0, then the final encoding method of the current audio frame is determined to be a switch from second bitrate encoding to first bitrate encoding; or, if the value of the first counter is 0, then the final encoding method of the current audio frame is determined to be first bitrate encoding; or, when the final encoding method of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding, and the value of the second counter is greater than 0, the value of the second counter is decremented by 1; if the value of the second counter is still greater than 0, then the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding; or, if the value of the second counter is 0, then the final encoding method of the current audio frame is determined to be second bitrate encoding; wherein, the value of the set threshold is related to the number of channels of the audio frame.
[0122] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding or a switching encoding method from a second bitrate encoding to a first bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame; and to perform second bitrate encoding processing on the current audio frame.
[0123] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the first counter is equal to the first set value; to perform second bitrate encoding processing on the current audio frame; or, when the value of the first counter is less than the first set value, to perform first bitrate encoding processing on the current audio frame.
[0124] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the second counter is greater than 1; and to perform second bitrate encoding processing on the current audio frame; or, when the value of the second counter is equal to 1, to perform second bitrate encoding processing on the current audio frame.
[0125] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the first counter is greater than 1; perform second bitrate encoding processing on the current audio frame; or, perform first bitrate encoding processing on the current audio frame when the value of the first counter is equal to 1.
[0126] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the second counter is equal to the first set value; and to perform second bitrate encoding processing on the current audio frame; or, when the value of the second counter is less than the first set value, to perform second bitrate encoding processing on the current audio frame.
[0127] In one possible implementation, the encoding module is specifically configured to perform the first bitrate encoding process on the current audio frame when the first bitrate encoding process supports the sampling rate of the current audio frame; or, when the first bitrate encoding process does not support the sampling rate of the current audio frame, to perform downsampling or upsampling processing on the current audio frame to obtain a downsampled or upsampled current audio frame, and to perform the first bitrate encoding process on the downsampled or upsampled current audio frame, wherein the first bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
[0128] In one possible implementation, the encoding module is specifically configured to perform the second bitrate encoding process on the current audio frame when the second bitrate encoding process supports the sampling rate of the current audio frame; or, when the second bitrate encoding process does not support the sampling rate of the current audio frame, to perform downsampling or upsampling processing on the current audio frame to obtain a downsampled or upsampled current audio frame, and to perform the second bitrate encoding process on the downsampled or upsampled current audio frame, wherein the second bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
[0129] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding or a switching encoding method from a second bitrate encoding to a first bitrate encoding, the determining module is further configured to determine the first bitrate corresponding to the first bitrate encoding process and the second bitrate corresponding to the second bitrate encoding process based on the set bitrate of the previous audio frame and the set bitrate of the current audio frame, wherein the sum of the first bitrate and the second bitrate is the set bitrate of the current audio frame; the encoding module is specifically configured to perform the first bitrate encoding process on the current audio frame using the first bitrate; and perform the second bitrate encoding process on the current audio frame using the second bitrate.
[0130] In one possible implementation, the bitstream information corresponding to the encoded current audio frame includes packet header information, a first bitrate encoded bitstream, and / or a second bitrate encoded bitstream, wherein the packet header information includes the final encoding method, sampling rate, number of channels, frame length, and length of the first bitrate encoded bitstream of the current audio frame.
[0131] Thirdly, this application provides an audio decoding apparatus, comprising: an acquisition module for acquiring bitstream information; a parsing module for parsing the bitstream information to obtain a decoding method and an encoded bitstream, wherein the encoded bitstream includes a first bitrate encoded bitstream and / or a second bitrate encoded bitstream, the decoding method includes a first bitrate decoding method, a second bitrate decoding method, a first bitrate decoding switching to a second bitrate decoding method, or a second bitrate decoding switching to a first bitrate decoding method, wherein when the decoding method is the first bitrate decoding method, the encoded bitstream includes the first bitrate encoded bitstream; when the decoding method is the second bitrate decoding method, the encoded bitstream includes the second bitrate encoded bitstream; and when the decoding method is a first bitrate decoding switching to a second bitrate decoding method or a second bitrate decoding switching to a first bitrate decoding method, the encoded bitstream includes both the first bitrate encoded bitstream and the second bitrate encoded bitstream; and a decoding module for decoding the encoded bitstream according to the decoding method to obtain a target audio frame.
[0132] In one possible implementation, when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, or when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain the target audio frame.
[0133] In one possible implementation, when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; overflow M sample data points from the head of the second data queue corresponding to the first bitrate decoding process, and put the second data into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding process; and extract M sample data points from the head of the second data queue to obtain the target audio frame.
[0134] In one possible implementation, when the decoding method is a second bitrate decoding method, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, or when the decoding method is a second bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain the target audio frame.
[0135] In one possible implementation, when the decoding method is a second bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; overflow M sample data points from the head of the first data queue corresponding to the second bitrate decoding process, and put the first data into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; and extract M sample data points from the head of the first data queue to obtain the target audio frame.
[0136] In one possible implementation, when the decoding method is a switch from a first bitrate decoding to a second bitrate decoding, and the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the decoding module is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; perform a weighted average of the last N sample data of the second data and the first N sample data of the first data to obtain N sample smooth data, where N is a second set value; and obtain the target audio frame based on the other data of the second data excluding the last N sample data and the N sample smooth data.
[0137] In one possible implementation, when the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to: set the first data queue corresponding to the second bitrate decoding process to all zeros when the decoding method of the previous audio frame is not a switch from first bitrate decoding to second bitrate decoding, the first data queue following a first-in-first-out principle; decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain the second data; and decode the second bitrate encoded bitstream according to the second bitrate decoding method. The second bitrate encoded bitstream is decoded to obtain first data; M sample data points overflow from the head of the first data queue and the first data points are placed at the tail of the first data queue, where M is associated with the frame length of the first bitrate decoding process; M sample data points are extracted from the head of the first data queue to obtain third data; the last N sample data points of the second data points are weighted and averaged with the first N sample data points of the third data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the second data points excluding the last N sample data points and the N sample smooth data points.
[0138] In one possible implementation, when the decoding method is a switching from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module is specifically used to: When the decoding method of the previous audio frame is not a switching from first bitrate decoding to second bitrate decoding, decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; overflow M sample data points from the head of the second data queue corresponding to the first bitrate decoding process, and place the second data points into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding process; extract M sample data points from the head of the second data queue to obtain fourth data; decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; and process the fourth data points... The last N sample data points of the fourth data are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points; or, when the decoding method of the previous audio frame is a switching decoding method from the first bitrate decoding to the second bitrate decoding, M sample data points overflow from the head of the second data queue; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; the last N sample data points of the fourth data points are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points.
[0139] In one possible implementation, when the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the decoding module is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; perform a weighted average of the last N sample data of the first data and the first N sample data of the second data to obtain N sample smooth data, where N is a second set value; and obtain the target audio frame based on the other data of the first data excluding the last N sample data and the N sample smooth data.
[0140] In one possible implementation, when the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to: When the decoding method of the previous audio frame is not a switch from second bitrate decoding to first bitrate decoding, decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; overflow M sample data from the head of the first data queue corresponding to the second bitrate decoding process, and place the first data into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; extract M sample data from the head of the first data queue to obtain third data; decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; and process the third data... The last N sample data points of the first data are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data points of the third data points excluding the last N sample data points and the N sample smooth data points; or, when the decoding method of the previous audio frame is a switch from the second bitrate decoding to the first bitrate decoding, M sample data points overflow from the head of the first data queue; M sample data points are extracted from the head of the first data queue to obtain the third data; the first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data points of the third data points excluding the last N sample data points and the N sample smooth data points.
[0141] In one possible implementation, when the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module is specifically used to: set the second data queue corresponding to the first bitrate decoding process to all zeros when the decoding method of the previous audio frame is not a switch from second bitrate decoding to first bitrate decoding; the second data queue follows a first-in-first-out principle; decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain the first data; and decode the second bitrate encoded bitstream according to the first bitrate decoding method. The first bitrate encoded bitstream is decoded to obtain second data; M sample data points overflow from the head of the second data queue and the second data points are placed at the tail of the second data queue, where M is associated with the frame length of the second bitrate decoding process; M sample data points are extracted from the head of the second data queue to obtain fourth data; the last N sample data points of the first data points and the first N sample data points of the fourth data points are weighted and averaged to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the first data points excluding the last N sample data points and the N sample smooth data points.
[0142] In one possible implementation, the decoding module is specifically used to determine whether the first bitrate decoding process supports the sampling rate corresponding to the first bitrate encoded bitstream; if the first bitrate decoding process supports the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process; or, if the first bitrate decoding process does not support the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process to obtain fifth data, and the fifth data is subjected to upsampling or downsampling processing.
[0143] In one possible implementation, the decoding module is specifically used to determine whether the second bitrate decoding process supports the sampling rate corresponding to the second bitrate encoded bitstream; if the second bitrate decoding process supports the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process; or, if the second bitrate decoding process does not support the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process to obtain the sixth data, and the sixth data is subjected to upsampling or downsampling processing.
[0144] Fourthly, this application provides an audio encoding device, comprising: one or more processors; a memory for storing one or more programs; wherein when the one or more programs are executed by the one or more processors, the one or more processors perform any of the methods described in the first aspect above, as performed by the audio transmitting device.
[0145] Fifthly, this application provides an audio decoding device, comprising: one or more processors; a memory for storing one or more programs; and when the one or more programs are executed by the one or more processors, causing the one or more processors to implement any of the methods described in the first aspect above, as executed by the audio receiving device.
[0146] In a sixth aspect, this application provides a computer-readable storage medium including a computer program that, when executed on a computer, causes the computer to perform the method described in any one of the first aspects above.
[0147] In a seventh aspect, this application provides a computer-readable storage medium including bitstream information obtained according to any of the audio encoding methods performed by an audio transmitting device as described in the first aspect above.
[0148] Eighthly, this application provides a computer-readable storage medium comprising an audio frame obtained according to any of the audio decoding methods performed by an audio receiving device as described in the first aspect above. Attached Figure Description
[0149] Figure 1 This is an exemplary structural diagram of the audio playback system of this application;
[0150] Figure 2 This is an exemplary structural block diagram of the audio decoding system 10 of this application;
[0151] Figure 3 This is an exemplary flowchart of the audio encoding / decoding method of this application;
[0152] Figure 4 This is an exemplary format diagram of the bitstream information in this application;
[0153] Figure 5a This is an exemplary schematic diagram illustrating the data smoothing process described in this application;
[0154] Figure 5b This is an exemplary schematic diagram illustrating the data smoothing process described in this application;
[0155] Figure 6 This is an exemplary schematic diagram of the data queue in this application;
[0156] Figure 7 This is an exemplary schematic diagram illustrating the encoding and decoding processing of audio frames in this application;
[0157] Figure 8 This is a schematic diagram of the structure of an embodiment of the audio encoding device of this application;
[0158] Figure 9This is a schematic diagram of the structure of an embodiment of the audio decoding device of this application. Detailed Implementation
[0159] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0160] The terms "first," "second," etc., used in the specification, embodiments, claims, and drawings of this application are for distinguishing purposes only and should not be construed as indicating or implying relative importance or order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, such as including a series of steps or units. A method, system, product, or apparatus is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0161] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0162] Explanation of relevant terms used in this application:
[0163] Audio frame: Audio data is streamed. In practical applications, in order to facilitate audio processing and transmission, the amount of audio data within a certain duration is usually taken as an audio frame. This duration is called the "sampling time". Its value can be determined according to the codec and the specific application requirements. For example, this duration is 2.0ms to 60ms, where ms stands for millisecond.
[0164] Figure 1 Here is an exemplary structural diagram of the audio playback system of this application, such as Figure 1As shown, the audio playback system includes: an audio transmitting device and an audio receiving device. The audio transmitting device includes devices such as mobile phones, computers (laptops, desktops, etc.), and tablets (handheld tablets, in-vehicle tablets, etc.) that can encode audio and transmit audio streams. The audio receiving device includes devices such as TWS earphones, ordinary wireless earphones, speakers, smartwatches, and smart glasses that can receive audio streams, decode audio streams, and play them.
[0165] A Bluetooth connection can be established between the audio transmitting device and the audio receiving device, supporting the transmission of voice and music. Common examples of audio transmitting and receiving devices include connections between a mobile phone and TWS earphones, wireless headphones, or wireless neckband headphones, or between a mobile phone and other terminal devices (such as smart speakers, smartwatches, smart glasses, and car speakers). Alternatively, examples of audio transmitting and receiving devices can also include connections between a tablet, laptop, or desktop computer and TWS earphones, wireless headphones, wireless neckband headphones, or other terminal devices (such as smart speakers, smartwatches, smart glasses, and car speakers).
[0166] It should be noted that, in addition to Bluetooth, the audio transmitting device and the audio receiving device can also be connected via other communication methods, such as WiFi, wired connection or other wireless connection, and this application does not make any specific limitations on this.
[0167] Figure 2 Here is an exemplary structural block diagram of the audio decoding system 10 of this application, as shown below. Figure 2 As shown, the audio decoding system 10 may include a source device 12 and a destination device 14. The source device 12 may be... Figure 1 The audio transmission device, the destination device 14 can be Figure 1 The source device 12 generates encoded bitstream information; therefore, the source device 12 can be referred to as an audio encoding device. The destination device 14 can decode the encoded bitstream information generated by the source device 12; therefore, the destination device 14 can be referred to as an audio decoding device.
[0168] The source device 12 includes an encoder 20, and optionally may include an input interface 16, an audio preprocessor 18, and a communication interface 22.
[0169] Input interface 16 is used to input audio pulse code modulation (PCM) data and set the bit rate. The audio PCM data can be divided into speech type or music type, and the bit rate can be preset by the user.
[0170] The audio preprocessor 18 determines the encoding method based on the set bitrate input through the input interface 16. Specifically, based on the desired outcome: when the set bitrate is less than a threshold, low-bitrate encoding is used to encode the audio frame; when the set bitrate is greater than the threshold, high-bitrate encoding is used to encode the audio frame. Therefore, the final encoding method of an audio frame depends on the set bitrate of the current frame and the final encoding method of the previous frame.
[0171] The encoder 20 is used to encode audio frames according to the encoding method determined by the audio preprocessor 18 to obtain bitstream information.
[0172] The communication interface 22 in the source device 12 can be used to receive the bit stream information and send the bit stream to the destination device 14 through the communication channel 13.
[0173] The target device 14 includes a decoder 30, and optionally may include a communication interface 28, an audio post-processor 32, and a playback device 34.
[0174] The communication interface 28 in the destination device 14 is used to receive the bit stream directly from the source device 12 and provide the bit stream to the decoder 30.
[0175] Communication interfaces 22 and 28 can be used to send or receive bitstreams through a communication link between source device 12 and destination device 14, such as a Bluetooth connection.
[0176] For example, communication interface 22 can be used to encapsulate the bitstream into a suitable format such as a message, and / or use Bluetooth transmission encoding or processing to process the bitstream for transmission over a communication link.
[0177] Communication interface 28 corresponds to communication interface 22. For example, it can be used to receive a bitstream and use the corresponding transmission to decode or process and / or decapsulate to obtain the bitstream.
[0178] Both communication interface 22 and communication interface 28 can be configured as follows: Figure 2 The arrow pointing from the source device 12 to the corresponding communication channel 13 of the destination device 14 indicates a one-way or two-way communication interface, which can be used to send and receive messages, establish connections, acknowledge and exchange any other information related to the data transmission of communication links and / or encoded audio data, etc.
[0179] Decoder 30 is used to receive bitstream information and decode the bitstream in the bitstream information according to the decoding method in the bitstream information to obtain audio data.
[0180] The audio post-processor 32 is used to post-process the decoded audio data to obtain post-processed audio data. The post-processing performed by the audio post-processor 32 may include, for example, trimming or resampling.
[0181] Playback device 34 is used to receive post-processed audio data for playing audio to a user or listener. Playback device 34 can be or includes any type of player for playing reconstructed audio, such as an integrated or external speaker. For example, a speaker may include a loudspeaker, a stereo, etc.
[0182] Based on the description of the above embodiments, this application provides an audio encoding and decoding method.
[0183] Figure 3 This is an exemplary flowchart of the audio encoding / decoding method of this application. This process 300 can be executed by an audio transmitting device and an audio receiving device in an audio playback system; that is, the audio transmitting device performs audio encoding, then sends the bitstream information to the audio receiving device, which decodes the bitstream information to obtain the target audio frame. Process 300 is described as a series of steps or operations. It should be understood that process 300 can be executed in various orders and / or occur simultaneously, and is not limited to... Figure 3 The execution order is shown. Figure 3 As shown, the method includes:
[0184] Step 301: The audio transmitting device obtains the set bitrate of the current audio frame to be encoded and the final encoding method of the previous audio frame.
[0185] An audio frame can be any frame of audio sent from an audio transmitting device to an audio receiving device. In this application, each encoding operation can target a single audio frame; that is, the audio encoding method provided in this application is for a single audio frame. The method for determining the encoding method described below applies to every single audio frame in the audio. Therefore, for distinction, the audio frame being encoded by the audio transmitting device is referred to as the audio frame or the current audio frame, while the audio frame encoded by the audio transmitting device prior to the current audio frame is referred to as the previous audio frame. Optionally, the audio frame can be represented in the form of PCM data.
[0186] The set code rate can be a target coding code rate preset by the user based on the current channel conditions. This set code rate can be, for example, 192kbps, 256kbps, 400kbps, or 600kbps.
[0187] The final encoding method refers to the actual encoding method used by the audio transmitting device when encoding audio frames. This can include a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding to the second bitrate encoding, or a switching encoding method from the second bitrate encoding to the first bitrate encoding. The first bitrate is lower than the second bitrate. For example, the first bitrate could be 64kbps, 128kbps, 192kbps, 256kbps, 400kbps, or 600kbps, etc., and the second bitrate could be 128kbps, 192kbps, 256kbps, 400kbps, or 600kbps, etc. It should be noted that the specific values of the first and second bitrates are not limited in this embodiment of the invention, as long as the first bitrate is lower than the second bitrate. In the following text, the first bitrate can also be referred to as the low bitrate, and the second bitrate as the high bitrate.
[0188] Step 302: The audio transmitting device determines the final encoding method of the current audio frame based on the set bit rate and the final encoding method of the previous audio frame.
[0189] This application involves two types of encoding processing: low bitrate encoding processing and high bitrate encoding processing. Low bitrate encoding processing may include, for example, AAC, the default LC3 of next-generation Bluetooth, etc., while high bitrate encoding processing may include, for example, LHDC, LC3plus, etc.
[0190] Table 1
[0191]
[0192] Table 1 exemplifies how, when the frame lengths of low-bitrate and high-bitrate encoding are the same, and the total encoding / decoding latency of low-bitrate and high-bitrate encoding is the same, the audio transmitting device determines the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame. In Table 1, A represents the low-bitrate encoding method, B represents the high-bitrate encoding method, A→B indicates switching from low-bitrate to high-bitrate encoding, and B→A indicates switching from high-bitrate to low-bitrate encoding. Therefore, the final encoding method of the current audio frame can be determined using the following method:
[0193] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame was a low bitrate encoding method, the final encoding method of the current audio frame is determined to be a low bitrate encoding method; or,
[0194] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame was high bitrate encoding, the encoding method of the current audio frame is determined to switch from high bitrate encoding to low bitrate encoding; or,
[0195] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame was a switch from low bitrate encoding to high bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from high bitrate encoding to low bitrate encoding; or,
[0196] When the set bitrate is less than the set threshold, and the previous audio frame's final encoding method was a switch from high bitrate encoding to low bitrate encoding, the current audio frame's final encoding method is determined to be low bitrate encoding; or,
[0197] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame was low bitrate encoding, the final encoding method of the current audio frame is determined to switch from low bitrate encoding to high bitrate encoding; or,
[0198] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame was a high bitrate encoding method, the final encoding method of the current audio frame is determined to be a high bitrate encoding method; or,
[0199] When the set bitrate is greater than the set threshold, and the previous audio frame's final encoding method was a switch from low bitrate encoding to high bitrate encoding, the current audio frame's final encoding method is determined to be high bitrate encoding; or,
[0200] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is a switch from high bitrate encoding to low bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from low bitrate encoding to high bitrate encoding.
[0201] The threshold value mentioned above is related to the number of channels in the audio frame. For example, when the audio frame has only one channel, the threshold can be set to 150kbps; when the audio frame has two channels, the threshold can be set to 300kbps.
[0202] Table 2
[0203]
[0204] Table 2 illustrates, for example, the final encoding method of the current audio frame determined by the audio transmitting device based on the set bitrate and the final encoding method of the previous audio frame when the frame lengths of low-bitrate encoding and high-bitrate encoding are different. In Table 2, A represents the low-bitrate encoding method, B represents the high-bitrate encoding method, A→B indicates switching from low-bitrate encoding to high-bitrate encoding, and B→A indicates switching from high-bitrate encoding to low-bitrate encoding.
[0205] In the case shown in Table 2, a switching frame is added. That is, regardless of whether the previous audio frame uses encoding method A or B, as long as the next audio frame is determined to use encoding method A→B or B→A, then D consecutive audio frames starting from that frame are directly determined as switching frames. The value of D can be obtained using the following method:
[0206] (1) Number of switching frames from A to B
[0207] D = ((max(total delay of low bitrate encoding / decoding, total delay of high bitrate encoding / decoding) + low bitrate to high bitrate overlap length + processing frame length - 1) / processing frame length)
[0208] (2) Number of switching frames from B to A
[0209] D = ((max(total delay of low bitrate encoding / decoding, total delay of high bitrate encoding / decoding) + high bitrate to low bitrate overlap length + processing frame length - 1) / processing frame length)
[0210] Wherein, the processing frame length = max(the frame length processed by low bitrate encoding, the frame length processed by high bitrate encoding), the low bitrate to high bitrate overlap length = processing frame length - total delay of low bitrate encoding and decoding % processing frame length, the high bitrate to low bitrate overlap length = processing frame length - total delay of high bitrate encoding and decoding % processing frame length, and % represents the modulo operation.
[0211] Therefore, the final encoding method of the current audio frame can be determined by the following method:
[0212] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame was a low bitrate encoding method, the final encoding method of the current audio frame is determined to be a low bitrate encoding method; or,
[0213] When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is high bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from high bitrate encoding to low bitrate encoding. A first counter is started, with an initial value of a first set value. The first counter terminates when its value reaches 0. The purpose of starting the first counter is to track the processing of switching frames. It is started when processing the first switching frame, and its initial value is set to the number of calculated switching frames (the first set value). After processing each switching frame, the first counter is decremented by 1. When the first counter's value is 0, it indicates that all switching frames have been encoded, and the first counter is terminated. A first counter value of the first set value indicates that the current processing is the first switching frame; a first counter value of 1 indicates that the current processing is the last switching frame; a first counter value less than the first set value but greater than 1 indicates that the current processing is an intermediate switching frame; or...
[0214] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame was a high bitrate encoding method, the final encoding method of the current audio frame is determined to be a high bitrate encoding method; or,
[0215] When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is low bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from low bitrate encoding to high bitrate encoding. A second counter is then started, with its initial value being the first set value. The second counter terminates when its value reaches 0. Similarly, the purpose of starting the second counter is to track the processing of switching frames. This second counter is started when processing the first switching frame, and its initial value is set to the number of switching frames obtained (the first set value). After processing each switching frame, the second counter is decremented by 1. When the value of the second counter is 0, it indicates that all switching frames have been encoded, and the second counter is then terminated. A value of the second counter equal to the first set value indicates that the current processing is the first switching frame; a value of the second counter equal to 1 indicates that the current processing is the last switching frame; a value of the second counter less than the first set value but greater than 1 indicates that the current processing is an intermediate switching frame; or...
[0216] When the previous audio frame's final encoding method was a high-bitrate to low-bitrate switching encoding, and the first counter is active (i.e., the first counter's value is greater than 0), the first counter's value is decremented by 1. If the first counter is still active, the current audio frame's final encoding method is determined to be a high-bitrate to low-bitrate switching encoding. Alternatively, if the first counter terminates (i.e., the first counter's value is 0), the current audio frame's final encoding method is determined to be a low-bitrate encoding.
[0217] When the final encoding method of the previous audio frame is a low bitrate encoding to high bitrate encoding switching encoding method, and the second counter is in the started state (that is, the value of the second counter is greater than 0), the value of the second counter is decremented by 1; if the second counter is still in the started state, it is determined that the final encoding method of the current audio frame is a low bitrate encoding to high bitrate encoding switching encoding method; or, if the second counter is terminated (that is, the value of the second counter is 0), it is determined that the final encoding method of the current audio frame is a high bitrate encoding method.
[0218] Similarly, the value of the threshold mentioned above is related to the number of channels in the audio frame. For example, when the audio frame has a mono channel, the threshold can be set to 165kbps, and when the audio frame has a stereo channel, the threshold can be set to 330kbps.
[0219] The first setting mentioned above is the number of switching frames, D.
[0220] Step 303: The audio transmitting device encodes the current audio frame according to the final encoding method of the current audio frame.
[0221] Based on the final encoding method of the current audio frame determined in step 302, the audio transmitting device encodes the current audio frame, and therefore the following situations are possible:
[0222] 1. The frame length of low-bitrate encoding is the same as that of high-bitrate encoding, and the total encoding / decoding latency of low-bitrate encoding is the same as that of high-bitrate encoding.
[0223] (1) The final encoding method of the current audio frame is low bitrate encoding.
[0224] The audio transmitting device performs low-bitrate encoding on the current audio frame.
[0225] In one possible implementation, the audio transmitting device can first determine whether the low bitrate encoding process supports the sampling rate of the current audio frame. If the low bitrate encoding process supports the sampling rate of the current audio frame, the current audio frame can be directly encoded using the low bitrate encoding process. Alternatively, if the low bitrate encoding process does not support the sampling rate of the current audio frame, the current audio frame can be downsampled or upsampled first, and then the downsampled or upsampled current audio frame can be encoded using the low bitrate encoding process. For example, since low bitrate encoding does not support sampling rates of 88.2kHz and 96kHz, audio transmitting devices can use QMF for downsampling, dividing the frequency band corresponding to 88.2kHz (0~44.1kHz) into two sub-bands, 0~22.05kHz and 22.05~44.1kHz, and selecting the lower sub-band 0~22.05kHz for low bitrate encoding; and dividing the frequency band corresponding to 96kHz (0~48kHz) into two sub-bands, 0~24kHz and 24~48kHz, and selecting the lower sub-band 0~24kHz for low bitrate encoding.
[0226] (2) The final encoding method of the current audio frame is high bitrate encoding.
[0227] The audio transmitting device performs high-bitrate encoding on the current audio frame.
[0228] In one possible implementation, the audio transmitting device can first determine whether the high bitrate encoding process supports the sampling rate of the current audio frame. If the high bitrate encoding process supports the sampling rate of the current audio frame, the current audio frame can be directly encoded using the high bitrate encoding process. Alternatively, if the high bitrate encoding process does not support the sampling rate of the current audio frame, the current audio frame can be downsampled or upsampled first, and then the downsampled or upsampled current audio frame can be encoded using the high bitrate encoding process.
[0229] (3) The final encoding method of the current audio frame is either switching from low bitrate encoding to high bitrate encoding or switching from high bitrate encoding to low bitrate encoding.
[0230] The audio transmitting device can perform low-bitrate encoding and high-bitrate encoding on the current audio frame. Similarly, the audio transmitting device can first determine whether the high-bitrate and low-bitrate encoding processes support the sampling rate of the current audio frame, as described above; this will not be elaborated further here.
[0231] 2. The frame lengths of low-bitrate encoding and high-bitrate encoding are different, or the frame lengths of low-bitrate encoding and high-bitrate encoding are the same, but the total encoding and decoding latency is different.
[0232] (1) The final encoding method of the current audio frame is low bitrate encoding.
[0233] The audio transmitting device can first determine whether the low bitrate encoding process supports the sampling rate of the current audio frame. If the low bitrate encoding process supports the sampling rate of the current audio frame, it can directly perform low bitrate encoding processing on the current audio frame; or, if the low bitrate encoding process does not support the sampling rate of the current audio frame, it can first perform downsampling or upsampling processing on the current audio frame, and then perform low bitrate encoding processing on the downsampled or upsampled current audio frame.
[0234] (2) The final encoding method of the current audio frame is high bitrate encoding.
[0235] The audio transmitting device can first determine whether the high bitrate encoding process supports the sampling rate of the current audio frame. If the high bitrate encoding process supports the sampling rate of the current audio frame, it can directly perform high bitrate encoding on the current audio frame. Alternatively, if the high bitrate encoding process does not support the sampling rate of the current audio frame, it can first perform downsampling or upsampling on the current audio frame, and then perform high bitrate encoding on the downsampled or upsampled current audio frame.
[0236] (3) The final encoding method of the current audio frame is a switching encoding method from low bitrate encoding to high bitrate encoding.
[0237] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0238] As described above, the function of the second counter is to track the processing status of switching frames. When the second counter is active, it indicates that the currently processed frame is still a switching frame. At this time, if the value of the second counter is greater than 1 (indicating that the currently processed frame is still a switching frame but not the last frame in the switching frame sequence), low-bitrate encoding is performed on the current audio frame; otherwise, high-bitrate encoding is performed. Alternatively, if the value of the second counter is equal to 1 (indicating that the currently processed frame is the last frame in the switching frame sequence), high-bitrate encoding is performed on the current audio frame.
[0239] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0240] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0241] As described above, the function of the second counter is to track the processing status of switching frames. When the second counter is active, it indicates that the currently processed frame is still a switching frame. When the value of the second counter equals the first set value (indicating that the currently processed frame is the first frame in the switching frame), the current audio frame is encoded at a low bitrate; or it is encoded at a high bitrate. Alternatively, when the value of the second counter is less than the first set value (indicating that the currently processed frame is still a switching frame but not the first frame in the switching frame), the current audio frame is encoded at a high bitrate.
[0242] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0243] (4) The final encoding method of the current audio frame is a switch from high bitrate encoding to low bitrate encoding.
[0244] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0245] As described above, the function of the first counter is to track the processing status of switching frames. When the first counter is in the active state, it indicates that the currently processed frame is still a switching frame. At this time, when the value of the first counter is equal to the first set value (indicating that the currently processed frame is the first frame in the switching frame), the current audio frame is processed by low bitrate encoding; or by high bitrate encoding. Alternatively, when the value of the first counter is less than the first set value (indicating that the currently processed frame is still a switching frame but not the first frame in the switching frame), the current audio frame is processed by low bitrate encoding.
[0246] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0247] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0248] As described above, the function of the first counter is to track the processing status of switching frames. When the first counter is active, it indicates that the currently processed frame is still a switching frame. At this time, if the value of the first counter is greater than 1 (indicating that the currently processed frame is still a switching frame but not the last frame in the switching frame sequence), low-bitrate encoding is performed on the current audio frame; otherwise, high-bitrate encoding is performed. Alternatively, if the value of the first counter is equal to 1 (indicating that the currently processed frame is the last frame in the switching frame sequence), low-bitrate encoding is performed on the current audio frame.
[0249] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0250] In one possible implementation, the audio transmitting device can determine a first bitrate corresponding to low bitrate encoding processing and a second bitrate corresponding to high bitrate encoding processing based on the set bitrate of the previous audio frame and the set bitrate of the current audio frame, and the sum of the first bitrate and the second bitrate is the set bitrate.
[0251] (1) The final encoding method of the current audio frame is a switch from high bitrate encoding to low bitrate encoding, which can be:
[0252] A. If the set bitrate brp of the previous audio frame satisfies: stereo: 600kbps < brp ≤ 990kbps, mono: 300kbps < brp ≤ 495kbps, and the set bitrate brf of the current audio frame satisfies: stereo: brf < 300kbps, mono: brf < 150kbps, then the bitrate allocation of the current audio frame is: the first bitrate is brf, and the second bitrate is brp - brf.
[0253] B. If the set bitrate brip of the previous audio frame satisfies: stereo: 364kbps < brip ≤ 600kbps, mono: 182kbps < brip ≤ 300kbps, and the set bitrate brip of the current audio frame satisfies: stereo: brip < 300kbps, mono: brip < 150kbps, then the bitrate allocation of the current audio frame is: the first bitrate for stereo is brip - 300kbps, the first bitrate for mono is brip - 150kbps, the second bitrate for stereo is 300kbps, and the second bitrate for mono is 150kbps.
[0254] C. If the set bitrate brip of the previous audio frame satisfies: stereo: 300kbps≤brp≤364kbps, mono: 150kbps≤brp≤182kbps, and the set bitrate brip of the current audio frame satisfies: stereo: brip<300kbps, mono: brip<150kbps, then the bitrate allocation of the current audio frame is: the first bitrate is 64kbps for stereo, the second bitrate is 32kbps for mono, the third bitrate is 300kbps for stereo, and the fourth bitrate is 150kbps for mono.
[0255] (2) The final encoding method of the current audio frame is a switch from low bitrate encoding to high bitrate encoding. Possible encoding methods include:
[0256] A. If the set bitrate brip of the previous audio frame satisfies: stereo: 64kbps≤brp<300kbps, mono: 32kbps≤brp<150kbps, and the set bitrate brip of the current audio frame satisfies: stereo: 600kbps<brf≤990kbps, mono: 300kbps<brf≤495kbps, then the bitrate allocation for the current audio frame is: the first bitrate is brip, and the second bitrate is brip-brp.
[0257] B. If the bitrate (brp) of the previous audio frame satisfies the following conditions: stereo: 364kbps < brf ≤ 600kbps, mono: 182kbps < brf ≤ 300kbps, then the bitrate allocation for the current audio frame is as follows: the first bitrate for stereo is brf-300kbps, the second bitrate for mono is brf-150kbps, the third bitrate for stereo is 300kbps, and the fourth bitrate for mono is 150kbps.
[0258] C. If the bitrate (brp) of the previous audio frame satisfies the following conditions: stereo: 300kbps≤brf≤364kbps, mono: 150kbps≤brf≤182kbps, then the bitrate allocation of the current audio frame is as follows: the first bitrate is 64kbps for stereo, the second bitrate is 32kbps for mono, the third bitrate is 300kbps for stereo, and the fourth bitrate is 150kbps for mono.
[0259] D. If the set bitrate brip of the previous audio frame satisfies: stereo: 600kbps < brip ≤ 990kbps, mono: 300kbps < brip ≤ 495kbps, and the set bitrate brip of the current audio frame satisfies: stereo: 600kbps < brip ≤ 990kbps, mono: 300kbps < brip ≤ 495kbps, then the bitrate allocation of the current audio frame is: the first bitrate and the second bitrate are consistent with the allocation of the previous audio frame.
[0260] E. If the set bitrate bpr of the previous audio frame satisfies: stereo: 364kbps≤brp≤600kbps, mono: 182kbps≤brp≤300kbps, and the set bitrate bref of the current audio frame satisfies: stereo: 600kbps<brf≤990kbps, mono: 300kbps<brf≤495kbps, then the bitrate allocation of the current audio frame is: the first bitrate is 299kbps for stereo, the second bitrate is 149kbps for mono, the third bitrate is brf-299kbps for stereo, and the fourth bitrate is brf-149kbps for mono.
[0261] The encoded bitstream information corresponding to the current audio frame includes header information, a low-bitrate encoded bitstream, and / or a high-bitrate encoded bitstream. The header information includes the final encoding method, sampling rate, number of channels, frame length, and length of the low-bitrate encoded bitstream for the current audio frame. If the audio transmitting device only performs low-bitrate encoding on the current audio frame, the bitstream information will only contain the low-bitrate encoded bitstream; if the audio transmitting device only performs high-bitrate encoding on the current audio frame, the bitstream information will only contain the high-bitrate encoded bitstream; if the audio transmitting device performs both low-bitrate and high-bitrate encoding on the current audio frame, the bitstream information will contain both low-bitrate and high-bitrate encoded bitstreams. Figure 4 The following is an exemplary format diagram of the bitstream information in this application, such as... Figure 4As shown, the bitstream information includes a header, a low-bitrate encoded bitstream, and a high-bitrate encoded bitstream. The header contains the final encoding method (2 bits), sampling rate (2 bits), number of channels (1 bit), frame length (1 bit), and the length of the low-bitrate encoded bitstream (10 bits), indicating that the header is 2 bytes long. If the bitstream contains a low-bitrate encoded bitstream, its length is the actual length, and actual data is written into it. If the bitstream does not contain a low-bitrate encoded bitstream, its length is 0, and it is either empty or contains default data. If the bitstream contains a high-bitrate encoded bitstream, actual data is written into it; otherwise, it is either empty or contains default data.
[0262] Step 304: The audio transmitting device sends the bitstream information to the audio receiving device.
[0263] Audio transmitting devices can send bitstream information to audio receiving devices via communication methods such as Bluetooth connections.
[0264] Step 305: The audio receiving device parses the bitstream information to obtain the decoding method and the encoded bitstream.
[0265] The encoded bitstream includes low-bitrate encoded bitstreams and / or high-bitrate encoded bitstreams, and the decoding methods include low-bitrate decoding, high-bitrate decoding, switching from low-bitrate decoding to high-bitrate decoding, or switching from high-bitrate decoding to low-bitrate decoding. For example... Figure 4 As shown, the actual content of the encoded bitstream is related to the final encoding method of the audio frame by the audio transmitting device. Therefore, after parsing the bitstream information, the audio receiving device can obtain two pieces of information: one is the decoding method to be used, and the other is the content of the encoded bitstream. When the decoding method is a low bitrate decoding method, the encoded bitstream only contains the low bitrate encoded bitstream; when the decoding method is a high bitrate decoding method, the encoded bitstream only contains the high bitrate encoded bitstream; when the decoding method switches from low bitrate decoding to high bitrate decoding or from high bitrate decoding to low bitrate decoding, the encoded bitstream contains both the low bitrate encoded bitstream and / or the high bitrate encoded bitstream.
[0266] Step 306: The audio receiving device decodes the encoded bitstream according to the decoding method to obtain the target audio frame.
[0267] Corresponding to the encoding end, the encoding method used by the audio transmitting device to encode the audio frame must be matched by the corresponding decoding method used at the decoding end to decode the encoded bitstream. Therefore, the following decoding methods exist:
[0268] 1. The frame length of low-bitrate encoding is the same as that of high-bitrate encoding, and the total encoding / decoding latency of low-bitrate encoding is the same as that of high-bitrate encoding.
[0269] (1) The decoding method is low bit rate decoding method.
[0270] Audio receiving devices perform low-bitrate decoding on low-bitrate encoded streams.
[0271] In one possible implementation, the audio receiving device can first determine whether the low-bitrate decoding process supports the sampling rate corresponding to the low-bitrate encoded stream. If the low-bitrate decoding process supports the sampling rate, it can directly perform low-bitrate decoding on the low-bitrate encoded stream. Alternatively, if the low-bitrate decoding process does not support the sampling rate, it can first perform low-bitrate decoding on the low-bitrate encoded stream, and then perform upsampling or downsampling on the decoded data to obtain the target audio frame. It should be noted that the upsampling or downsampling performed at the encoding and decoding ends are corresponding; that is, if the encoding end uses downsampling, the decoding end can use upsampling, and vice versa. For example, in the above description, at the encoding end, the audio transmitting device downsamples the audio frame and then encodes the low-frequency subband. Correspondingly, at the decoding end, after decoding the low-bitrate encoded stream, the audio receiving device, lacking data in the high-frequency subband, upsamples by padding with zeros to obtain the target audio frame.
[0272] (2) The decoding method is high bitrate decoding.
[0273] Audio receiving devices perform high-bitrate decoding on high-bitrate encoded streams.
[0274] In one possible implementation, the audio receiving device can first determine whether the high bitrate decoding process supports the sampling rate corresponding to the high bitrate encoded bitstream. If the high bitrate decoding process supports the sampling rate, the high bitrate encoded bitstream can be directly decoded at a high bitrate. Alternatively, if the high bitrate decoding process does not support the sampling rate, the high bitrate encoded bitstream can be decoded at a high bitrate first, and then the decoded data can be upsampled or downsampled to obtain the target audio frame.
[0275] (3) The decoding method is a switch from low bitrate decoding to high bitrate decoding.
[0276] The audio receiving device performs low-bitrate decoding on the low-bitrate encoded bitstream to obtain second data, and performs high-bitrate decoding on the high-bitrate encoded bitstream to obtain first data. After obtaining the second and first data, the audio receiving device can perform smoothing processing on the back end of the second data and the front end of the first data to ensure a smooth switch between low and high bitrates. The smoothed data length is N sample data points, that is, the weighted average of the last N sample data points of the second data and the first N sample data points of the first data is used to obtain N sample smoothed data points. The target audio frame is obtained based on the other data of the second data points excluding the last N sample data points and the N sample smoothed data points. Figure 5a This is an exemplary schematic diagram illustrating the data smoothing process described in this application, such as... Figure 5a As shown, the sample data between the two dashed lines represents the N sample data points that need to be smoothed. The diagonal lines within the N sample data points of the second data represent the weight changes of the second data, and the diagonal lines within the N sample data points of the first data represent the weight changes of the first data. Since the decoding mode is switched from low bitrate decoding to high bitrate decoding, the second data points processed by low bitrate decoding come first, followed by the first data points processed by high bitrate decoding. Furthermore, the data of the target audio frame includes the first part of the second data and the smoothed N sample data points. Assuming the last N sample data points of the second data are represented as ai, i = 1, 2, 3…, N, the first N sample data points of the first data are represented as bi, i = 1, 2, 3…, N, and the N smoothed sample data points are represented as ci, i = 1, 2, 3…, N, they can be obtained through the following calculations:
[0277]
[0278] c1 = a1
[0279] cN = bN
[0280] Similarly, the audio receiving device can first determine whether the high and low bit rate decoding processes support the sampling rate as described above, which will not be repeated here.
[0281] (4) The decoding method is to switch from high bitrate decoding to low bitrate decoding.
[0282] The audio receiving device performs high-bitrate decoding on the high-bitrate encoded stream to obtain first data, and low-bitrate decoding on the low-bitrate encoded stream to obtain second data. After obtaining the first and second data, the audio receiving device can perform smoothing processing on the back end data of the first data and the front end data of the second data to ensure smooth switching between high and low bitrates. The smoothed data length is N sample data points, that is, the weighted average of the last N sample data points of the first data and the first N sample data points of the second data is used to obtain N sample smoothed data points. The target audio frame is obtained based on the other data of the first data points excluding the last N sample data points and the N sample smoothed data points. Figure 5b This is an exemplary schematic diagram illustrating the data smoothing process described in this application, such as... Figure 5b As shown, the sample data between the two dashed lines represents the N sample data points that need to be smoothed. The diagonal lines within the N sample data points of the first data point represent the weight changes of the first data point, and the diagonal lines within the N sample data points of the second data point represent the weight changes of the second data point. Since the decoding mode is switched from high bitrate decoding to low bitrate decoding, the first data point processed by high bitrate decoding comes first, followed by the second data point processed by low bitrate decoding. Furthermore, the data of the target audio frame includes the first part of the first data point and the smoothed N sample data points. The calculation method for the N sample data points can be referred to the description above, and will not be repeated here.
[0283] Similarly, the audio receiving device can first determine whether the high and low bit rate decoding processes support the sampling rate as described above, which will not be repeated here.
[0284] 2. Low bitrate encoding and high bitrate encoding have different frame lengths.
[0285] (1) The decoding method is low bit rate decoding method.
[0286] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0287] Audio receiving devices perform low-bitrate decoding on low-bitrate encoded streams.
[0288] In one possible implementation, the audio receiving device can first determine whether the low bitrate decoding process supports the sampling rate corresponding to the low bitrate encoded bitstream. If the low bitrate decoding process supports the sampling rate, the low bitrate encoded bitstream can be directly decoded at a low bitrate. Alternatively, if the low bitrate decoding process does not support the sampling rate, the low bitrate encoded bitstream can be decoded at a low bitrate first, and then the decoded data can be upsampled or downsampled to obtain the target audio frame.
[0289] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0290] The audio receiving device performs low-bitrate decoding on the low-bitrate encoded bitstream to obtain the second data. Since the frame length of the low-bitrate decoding process is shorter than the frame length of the high-bitrate decoding process, to align the audio frames obtained from the low-bitrate and high-bitrate decoding processes, the audio receiving device can, after obtaining the second data, overflow M sample data points from the head of the second data queue corresponding to the low-bitrate decoding process and place the second data points at the tail of the second data queue. Then, it extracts M sample data points from the head of the second data queue to obtain the target audio frame. This second data queue follows a first-in, first-out (FIFO) principle. M is associated with the frame length of the high-bitrate decoding process; for example, M = processing frame length × number of channels, where the processing frame length is the same as the frame length of the high-bitrate decoding process. Figure 6 This is an exemplary schematic diagram of the data queue in this application, such as... Figure 6 As shown, assuming the length of the second data queue is n+M, following the first-in-first-out (FIFO) principle, M sample data overflows from the head of the queue, leaving M empty positions at the tail of the second data queue. The second data is then placed at the tail of the second data queue, and the target audio frame is obtained by extracting M sample data from the head of the second data queue. For example, the frame length corresponding to high-bitrate decoding is greater than that corresponding to low-bitrate decoding, and the former is four times the latter. The length A of the first data queue corresponding to high-bitrate decoding is equal to the frame length × the number of channels, and the length B of the second data queue corresponding to low-bitrate decoding is equal to the frame length × the number of channels + (total delay of high-bitrate encoding / decoding - total delay of low-bitrate encoding / decoding) × the number of channels.
[0291] Similarly, the audio receiving device can first determine whether the low bit rate decoding process supports the sampling rate as described above, which will not be repeated here.
[0292] (2) The decoding method is high bitrate decoding.
[0293] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0294] The audio receiving device performs high-bitrate decoding on the high-bitrate encoded stream to obtain the first data. Since the frame length of the low-bitrate encoded stream is longer than that of the high-bitrate encoded stream, to align the audio frames obtained from the low-bitrate and high-bitrate decoding processes, the audio receiving device, after obtaining the first data, can overflow M sample data points from the head of the first data queue corresponding to the high-bitrate decoding process and place the first data points at the tail of the first data queue. Then, it can extract M sample data points from the head of the first data queue to obtain the target audio frame. This first data queue follows a first-in, first-out (FIFO) principle. M is associated with the frame length of the low-bitrate decoding process.
[0295] Similarly, the audio receiving device can first determine whether the high bitrate decoding process supports the sampling rate as described above, which will not be repeated here.
[0296] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0297] Audio receiving devices perform high-bitrate decoding on high-bitrate encoded streams.
[0298] In one possible implementation, the audio receiving device can first determine whether the high bitrate decoding process supports the sampling rate corresponding to the high bitrate encoded bitstream. If the high bitrate decoding process supports the sampling rate, the high bitrate encoded bitstream can be directly decoded at a high bitrate. Alternatively, if the high bitrate decoding process does not support the sampling rate, the high bitrate encoded bitstream can be decoded at a high bitrate first, and then the decoded data can be upsampled or downsampled to obtain the target audio frame.
[0299] (3) The decoding method is a switch from low bitrate decoding to high bitrate decoding.
[0300] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0301] When the decoding method of the previous audio frame is not a switch from low bitrate decoding to high bitrate decoding, the first data queue corresponding to the high bitrate decoding process is set to all zeros. The first data queue follows the first-in-first-out principle. The low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data. The high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data. M sample data points overflow from the head of the first data queue and the first data points are placed at the tail of the first data queue. M is associated with the frame length of the low bitrate decoding process. M sample data points are extracted from the head of the first data queue to obtain the third data. The last N sample data points of the second data points and the first N sample data points of the third data points are weighted and averaged to obtain N sample smooth data points. The target audio frame is obtained based on the other data points of the second data points excluding the last N sample data points and the N sample smooth data points.
[0302] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0303] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0304] When the decoding method of the previous audio frame is not a switch from low bitrate decoding to high bitrate decoding, the low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data; M sample data points overflow from the head of the second data queue corresponding to the low bitrate decoding processing, and the second data points are placed at the tail of the second data queue. The second data queue follows the first-in-first-out principle, and M is associated with the frame length of the high bitrate decoding processing; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data; the last N sample data points of the fourth data points are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points. Alternatively, when the decoding method of the previous audio frame is switching from low bitrate decoding to high bitrate decoding, M sample data points overflow from the head of the second data queue; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data; the last N sample data points of the fourth data and the first N sample data points of the first data are weighted and averaged to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points.
[0305] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0306] (4) The decoding method is to switch from high bitrate decoding to low bitrate decoding.
[0307] A. The frame length processed by low bitrate encoding is greater than the frame length processed by high bitrate encoding.
[0308] When the decoding method of the previous audio frame is not a switch from high bitrate decoding to low bitrate decoding, the high bitrate encoded bitstream is processed by high bitrate decoding to obtain the first data; M sample data points overflow from the head of the first data queue corresponding to the high bitrate decoding processing, and the first data points are placed at the tail of the first data queue. The first data queue follows the first-in-first-out principle, and M is associated with the frame length of the low bitrate decoding processing; M sample data points are extracted from the head of the first data queue to obtain the third data; the low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data points to obtain N sample smooth data points; the target audio frame is obtained based on the other data points of the third data points excluding the last N sample data points and the N sample smooth data points. Alternatively, when the decoding method of the previous audio frame is switching from high bitrate decoding to low bitrate decoding, M sample data points are overflowed from the head of the first data queue; M sample data points are extracted from the head of the first data queue to obtain the third data; the low bitrate encoded bitstream is processed by low bitrate decoding to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the third data points excluding the last N sample data points and the N sample smooth data points.
[0309] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0310] B. The frame length processed by low bitrate encoding is shorter than the frame length processed by high bitrate encoding.
[0311] When the decoding method of the previous audio frame is not a switch from high bitrate decoding to low bitrate decoding, the second data queue corresponding to the low bitrate decoding processing is set to all 0s. The second data queue follows the first-in-first-out principle. High bitrate decoding processing is performed on the high bitrate encoded bitstream to obtain the first data. Low bitrate decoding processing is performed on the low bitrate encoded bitstream to obtain the second data. M sample data points overflow from the head of the second data queue and the second data points are placed at the tail of the second data queue. M is associated with the frame length of the high bitrate decoding processing. M sample data points are extracted from the head of the second data queue to obtain the fourth data. The last N sample data points of the first data points and the first N sample data points of the fourth data points are weighted and averaged to obtain N sample smooth data points. The target audio frame is obtained based on the other data of the first data points excluding the last N sample data points and the N sample smooth data points.
[0312] Audio transmitting devices can refer to the above description to first determine whether the high and low bitrate encoding processes support the sampling rate of the current audio frame, which will not be elaborated here.
[0313] This application determines the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame. Accordingly, it sets the corresponding bitrates for low-bitrate and high-bitrate encoding processing on audio frames where high and low bitrate switching occurs. The encoding end sends the bitstream information to the decoding end. The decoding end parses the bitstream information to obtain the decoding method and then decodes the bitstream data. In particular, it performs smoothing processing on the decoded data at both high and low bitrates on audio frames where high and low bitrate switching occurs, achieving seamless integration of low-bitrate and high-bitrate encoding / decoding processing. This maximizes audio quality while adhering to Bluetooth channel data transmission size limitations, improves Bluetooth channel anti-interference capabilities, and provides users with a more optimized audio experience.
[0314] The following describes the audio encoding and decoding method provided in this application in further detail using several specific embodiments.
[0315] Example 1
[0316] Low bitrate encoding and decoding supports 64–300 kbps, while high bitrate encoding and decoding supports 300–990 kbps. Both support bit depths of 16-bit, 24-bit, 32-bit floating-point, or 32-bit fixed-point. Both support mono and stereo audio signals. The low bitrate encoding and decoding supports sampling rates of 44.1 kHz and 48 kHz, but does not support sampling rates of 88.2 kHz and 96 kHz.
[0317] Low-bitrate and high-bitrate encoding / decoding processes have the same frame length and total encoding / decoding latency, but there is partial overlap between adjacent audio frames. Therefore, a parallel fusion strategy is adopted, meaning that when switching between low-bitrate and high-bitrate encoding / decoding, both processes run simultaneously to ensure the continuity of the audio stream. For ease of explanation, let's define low-bitrate encoding / decoding as A and high-bitrate encoding / decoding as B.
[0318] This embodiment can refer to Table 1 to determine the final encoding method of the current audio frame, which will not be repeated here. For audio frames A and B running simultaneously, the sampling rates of A and B can be determined using the above method, which will not be repeated here.
[0319] The encoding and decoding processes for A and / or B can be referred to Figure 3 The embodiments shown are not described in detail here.
[0320] For sampling rates 88.2kHz and 96kHz that are not supported by A, the encoder can use QMF for downsampling. The frequency band corresponding to 88.2kHz (0–44.1kHz) is divided into two sub-bands: 0–22.05kHz and 22.05–44.1kHz. The lower sub-band (0–22.05kHz) is selected for low-bit-rate encoding. Similarly, the frequency band corresponding to 96kHz (0–48kHz) is divided into two sub-bands: 0–24kHz and 24–48kHz. The lower sub-band (0–24kHz) is selected for low-bit-rate encoding. The decoder can use QMF to pad the higher sub-bands of the decoded data (22.05kHz–44.1kHz for 88.2kHz and 24kHz–48kHz for 96kHz) with zeros to achieve upsampling, ensuring the upsampled data matches the original audio's sampling rate.
[0321] Example 2
[0322] Low bitrate encoding and decoding supports 64–300 kbps, while high bitrate encoding and decoding supports 300–990 kbps. Both support bit depths of 16-bit, 24-bit, 32-bit floating-point, or 32-bit fixed-point. Both support mono and stereo audio signals. The sampling rates supported by both low bitrate and high bitrate encoding and decoding include 44.1 kHz, 48 kHz, 88.2 kHz, and 96 kHz.
[0323] For ease of explanation, let's define low-bitrate encoding / decoding as A and high-bitrate encoding / decoding as B. The frame lengths of low-bitrate and high-bitrate encoding / decoding are different; for example, A has a frame length of 1024 samples, while B has a frame length of 256 samples. The total encoding / decoding latency of A and B is also different; for example, A has a latency of 2048 samples, while B has a latency of 11 samples when the sampling rate is greater than or equal to 88.2kHz, and a latency of 5 samples when the sampling rate is lower than 88.2kHz. Therefore, a parallel fusion strategy is adopted, meaning that when switching between low-bitrate and high-bitrate encoding / decoding, both encoding processes run simultaneously to ensure the continuity of the audio stream.
[0324] This embodiment can refer to Table 2 to determine the final encoding method of the current audio frame, which will not be repeated here. For audio frames A and B running simultaneously, the sampling rates of A and B can be determined using the above method, which will not be repeated here.
[0325] Figure 7 This is an exemplary schematic diagram illustrating the encoding and decoding processing of audio frames in this application, as shown below. Figure 7As shown, the number of switching frames is set to 3, the audio frames are mono, and the final encoding order of each audio frame in the frame sequence is determined to be (A)(A)(A)(A→B)(A→B)(A→B)(B)(B)(B)(B→A)(B→A)(B→A)(A).
[0326] A processes one audio frame (1024 sample data points), while B needs to process four audio frames (256 sample data points) and combine them into 1024 sample data points.
[0327] At the encoding end, following the above sequence, A encodes three audio frames consecutively. The next three switching frames (A→B) are as follows: In the first switching frame, A and B run simultaneously, with B encoding only the latter half of the audio frame; in the second switching frame, A and B still run simultaneously, but A sets all encoded data to 0, and B encodes the entire frame; in the third switching frame, A stops, and B encodes the entire frame. B then encodes three audio frames consecutively. The next three switching frames (B→A) are also as follows: In the first switching frame, A and B run simultaneously, with B encoding only the first half of the audio frame; in the second and third switching frames, A encodes the entire frame, and B stops. Finally, A encodes one audio frame.
[0328] At the decoding end, following the above sequence, A decodes three audio frames consecutively. In the next three switching frames (A→B), in the first switching frame, the first data queue corresponding to B is set to all zeros. On this switching frame, A and B run simultaneously, with B only decoding the latter half of the audio frame. 1024 sample data points overflow from the head of the first data queue, and the first data decoded by B is placed at the tail of the first data queue. 1024 sample data points are extracted from the head of the first data queue and smoothed with the second data decoded by A to obtain the audio frame. In the second and third switching frames, A and B still run simultaneously, decoding the entire frame. In both the second and third switching frames, 1024 sample data points overflow from the head of the first data queue, and the first data decoded by B is placed at the tail of the first data queue. 1024 sample data points are extracted from the head of the first data queue and smoothed with the second data decoded by A to obtain the audio frame. B then decodes three audio frames consecutively. Next, there are three more switching frames (B→A). In the first switching frame, A and B run simultaneously, with B only decoding the first half of the audio frame. 1024 samples are overflowed from the head of the first data queue corresponding to B, and the first data decoded by B is placed at the tail of the first data queue. 1024 samples are extracted from the head of the first data queue and smoothed with the second data decoded by A to obtain the audio frame. In the second and third switching frames, A decodes the entire frame, and B stops running. In both the second and third switching frames, 1024 samples are overflowed from the head of the first data queue. 1024 samples are extracted from the head of the first data queue and smoothed with the second data decoded by A to obtain the audio frame. Then A decodes one audio frame.
[0329] Figure 8 This is a schematic diagram of the structure of an embodiment of the audio encoding device of this application, as shown below. Figure 8 As shown, this device can be applied to the audio transmission device in the above embodiments. The encoding device in this embodiment may include: an obtaining module 801, a determining module 802, and an encoding module 803. Wherein,
[0330] The obtaining module 801 is used to obtain the set bitrate of the current audio frame to be encoded and the final encoding method of the previous audio frame. The final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding method to the second bitrate encoding method, or a switching encoding method from the second bitrate encoding method to the first bitrate encoding method, wherein the first bitrate is lower than the second bitrate. The determining module 802 is used to determine the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame. The encoding module 803 is used to encode the current audio frame according to the final encoding method of the current audio frame.
[0331] In one possible implementation, when the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the determining module 802 is specifically used to determine that the final encoding mode of the current audio frame is the first bitrate encoding mode when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the first bitrate encoding mode; or, when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the first bitrate encoding mode, the determining module 802 is used to determine that the final encoding mode of the current audio frame is the first bitrate encoding mode; or, when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the first bitrate encoding mode, the determining module 802 is used to determine that the final encoding mode of the current audio frame is the first bitrate encoding mode. When the encoding method is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the second bitrate encoding method to the first bitrate encoding method; or, when the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is a switch from the first bitrate encoding method to the second bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the second bitrate encoding method to the first bitrate encoding method; or, when the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is a switch from the second bitrate encoding method to the first bitrate encoding method. When switching encoding methods, the final encoding method of the current audio frame is determined to be the first bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the first bitrate encoding method to the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method. When the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding; wherein, the value of the set threshold is related to the number of channels of the audio frame.
[0332] In one possible implementation, when the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are not the same, the determining module 802 is specifically used to determine that the final encoding method of the current audio frame is the first bitrate encoding method when the set bitrate is less than the set threshold and the final encoding method of the previous audio frame is the first bitrate encoding method; or, when the set bitrate is less than the set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, determine that the final encoding method of the current audio frame is the second bitrate encoding method switching to the first bitrate encoding method. The encoding method is changed, and a first counter is started. The initial value of the first counter is a first set value, and the first counter terminates when its value reaches 0; or, when the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the first bitrate encoding method to the second bitrate encoding method. The system activates a second counter, with an initial value of a first set value, and terminates when the value of the second counter is 0. Alternatively, if the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, and the value of the first counter is greater than 0, the value of the first counter is decremented by 1. If the value of the first counter is still greater than 0, the final encoding method of the current audio frame is determined to be a switch from second bitrate encoding to first bitrate encoding. Alternatively, if the value of the first counter is 0, the final encoding method of the current audio frame is determined to be first bitrate encoding. Alternatively, if the final encoding method of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding, and the value of the second counter is greater than 0, the value of the second counter is decremented by 1. If the value of the second counter is still greater than 0, the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding. Alternatively, if the value of the second counter is 0, the final encoding method of the current audio frame is determined to be second bitrate encoding. The set threshold value is related to the number of channels in the audio frame.
[0333] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from first bitrate encoding to second bitrate encoding or a switching encoding method from second bitrate encoding to first bitrate encoding, the encoding module 803 is specifically used to perform first bitrate encoding processing on the current audio frame and perform second bitrate encoding processing on the current audio frame.
[0334] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the encoding module 803 is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the first counter is equal to the first set value; to perform second bitrate encoding processing on the current audio frame; or, when the value of the first counter is less than the first set value, to perform first bitrate encoding processing on the current audio frame.
[0335] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the encoding module 803 is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the second counter is greater than 1; and to perform second bitrate encoding processing on the current audio frame; or, when the value of the second counter is equal to 1, to perform second bitrate encoding processing on the current audio frame.
[0336] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the encoding module 803 is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the first counter is greater than 1; to perform second bitrate encoding processing on the current audio frame; or, when the value of the first counter is equal to 1, to perform first bitrate encoding processing on the current audio frame.
[0337] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the encoding module 803 is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the second counter is equal to the first set value; and to perform second bitrate encoding processing on the current audio frame; or, when the value of the second counter is less than the first set value, to perform second bitrate encoding processing on the current audio frame.
[0338] In one possible implementation, the encoding module 803 is specifically configured to perform the first bitrate encoding process on the current audio frame when the first bitrate encoding process supports the sampling rate of the current audio frame; or, when the first bitrate encoding process does not support the sampling rate of the current audio frame, to perform downsampling or upsampling processing on the current audio frame to obtain a downsampled or upsampled current audio frame, and to perform the first bitrate encoding process on the downsampled or upsampled current audio frame, wherein the first bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
[0339] In one possible implementation, the encoding module 803 is specifically configured to perform the second bitrate encoding process on the current audio frame when the second bitrate encoding process supports the sampling rate of the current audio frame; or, when the second bitrate encoding process does not support the sampling rate of the current audio frame, to perform downsampling or upsampling processing on the current audio frame to obtain a downsampled or upsampled current audio frame, and to perform the second bitrate encoding process on the downsampled or upsampled current audio frame, wherein the second bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
[0340] In one possible implementation, when the final encoding method of the current audio frame is a switching encoding method from a first bitrate encoding to a second bitrate encoding or a switching encoding method from a second bitrate encoding to a first bitrate encoding, the determining module 802 is further configured to determine the first bitrate corresponding to the first bitrate encoding process and the second bitrate corresponding to the second bitrate encoding process based on the set bitrate of the previous audio frame and the set bitrate of the current audio frame, wherein the sum of the first bitrate and the second bitrate is the set bitrate of the current audio frame; the encoding module 803 is specifically configured to perform the first bitrate encoding process on the current audio frame using the first bitrate; and perform the second bitrate encoding process on the current audio frame using the second bitrate.
[0341] In one possible implementation, the bitstream information corresponding to the encoded current audio frame includes packet header information, a first bitrate encoded bitstream, and / or a second bitrate encoded bitstream, wherein the packet header information includes the final encoding method, sampling rate, number of channels, frame length, and length of the first bitrate encoded bitstream of the current audio frame.
[0342] The apparatus of this embodiment can be used to perform Figure 3 The technical solutions of the method embodiments shown are similar in principle and in effect, and will not be described again here.
[0343] Figure 9 This is a schematic diagram of the structure of an embodiment of the audio decoding device of this application, as shown below. Figure 9As shown, this device can be applied to the audio receiving device in the above embodiments. The decoding device in this embodiment may include: an acquisition module 901, a parsing module 902, and a decoding module 903. Wherein,
[0344] A module 901 is used to obtain bitstream information; a parsing module 902 is used to parse the bitstream information to obtain a decoding method and an encoded bitstream, wherein the encoded bitstream includes a first bitrate encoded bitstream and / or a second bitrate encoded bitstream, and the decoding method includes a first bitrate decoding method, a second bitrate decoding method, a switching decoding method from first bitrate decoding to second bitrate decoding, or a switching decoding method from second bitrate decoding to first bitrate decoding. When the decoding method is the first bitrate decoding method, the encoded bitstream includes the first bitrate encoded bitstream; when the decoding method is the second bitrate decoding method, the encoded bitstream includes the second bitrate encoded bitstream; when the decoding method is a switching decoding method from first bitrate decoding to second bitrate decoding or a switching decoding method from second bitrate decoding to first bitrate decoding, the encoded bitstream includes both the first bitrate encoded bitstream and the second bitrate encoded bitstream; a decoding module 903 is used to decode the encoded bitstream according to the decoding method to obtain a target audio frame.
[0345] In one possible implementation, when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, or when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain the target audio frame.
[0346] In one possible implementation, when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; overflow M sample data points from the head of the second data queue corresponding to the first bitrate decoding process, and put the second data into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding process; and extract M sample data points from the head of the second data queue to obtain the target audio frame.
[0347] In one possible implementation, when the decoding method is a second bitrate decoding method, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, or when the decoding method is a second bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain the target audio frame.
[0348] In one possible implementation, when the decoding method is a second bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; overflow M sample data points from the head of the first data queue corresponding to the second bitrate decoding process, and put the first data into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; and extract M sample data points from the head of the first data queue to obtain the target audio frame.
[0349] In one possible implementation, when the decoding method is a switching from a first bitrate decoding to a second bitrate decoding, and the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the decoding module 903 is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; perform a weighted average of the last N sample data of the second data and the first N sample data of the first data to obtain N sample smooth data, where N is a second set value; and obtain the target audio frame based on the other data of the second data excluding the last N sample data and the N sample smooth data.
[0350] In one possible implementation, when the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to: set the first data queue corresponding to the second bitrate decoding process to all zeros when the decoding method of the previous audio frame is not a switch from first bitrate decoding to second bitrate decoding; the first data queue follows a first-in-first-out principle; decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain the second data; and decode the second bitrate decoder according to the second bitrate decoding method. The method involves decoding the second bitrate encoded bitstream to obtain first data; overflowing M sample data points from the head of the first data queue and placing the first data points at the tail of the first data queue, where M is associated with the frame length of the first bitrate decoding process; extracting M sample data points from the head of the first data queue to obtain third data; performing a weighted average of the last N sample data points of the second data and the first N sample data points of the third data to obtain N sample smoothing data points; and obtaining the target audio frame based on the other data of the second data points excluding the last N sample data points and the N sample smoothing data points.
[0351] In one possible implementation, when the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to: When the decoding method of the previous audio frame is not a switch from first bitrate decoding to second bitrate decoding, decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; overflow M sample data points from the head of the second data queue corresponding to the first bitrate decoding process, and place the second data into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding process; extract M sample data points from the head of the second data queue to obtain fourth data; decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; and process the first bitrate encoded stream according to the second bitrate decoding method to obtain the second data. The last N sample data points of the fourth data are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points; or, when the decoding method of the previous audio frame is a switching decoding method from the first bitrate decoding to the second bitrate decoding, M sample data points overflow from the head of the second data queue; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; the last N sample data points of the fourth data points are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points.
[0352] In one possible implementation, when the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the decoding module 903 is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; perform a weighted average of the last N sample data of the first data and the first N sample data of the second data to obtain N sample smooth data, where N is a second set value; and obtain the target audio frame based on the other data of the first data excluding the last N sample data and the N sample smooth data.
[0353] In one possible implementation, when the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to: When the decoding method of the previous audio frame is not a switch from second bitrate decoding to first bitrate decoding, decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; overflow M sample data from the head of the first data queue corresponding to the second bitrate decoding process, and place the first data into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; extract M sample data from the head of the first data queue to obtain third data; decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; and... The last N sample data points of the third data are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the third data points excluding the last N sample data points and the N sample smooth data points; or, when the decoding method of the previous audio frame is a switch from the second bitrate decoding to the first bitrate decoding, M sample data points overflow from the head of the first data queue; M sample data points are extracted from the head of the first data queue to obtain the third data; the first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the third data points excluding the last N sample data points and the N sample smooth data points.
[0354] In one possible implementation, when the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module 903 is specifically used to: set the second data queue corresponding to the first bitrate decoding process to all zeros when the decoding method of the previous audio frame is not a switch from second bitrate decoding to first bitrate decoding; the second data queue follows a first-in-first-out principle; decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain the first data; and decode the second bitrate encoded bitstream according to the first bitrate decoding method. The method involves decoding the first bitrate encoded bitstream to obtain second data; overflowing M sample data points from the head of the second data queue and placing the second data points at the tail of the second data queue, where M is associated with the frame length of the second bitrate decoding process; extracting M sample data points from the head of the second data queue to obtain fourth data; performing a weighted average of the last N sample data points of the first data and the first N sample data points of the fourth data to obtain N sample smoothed data points; and obtaining the target audio frame based on the other data of the first data points excluding the last N sample data points and the N sample smoothed data points.
[0355] In one possible implementation, the decoding module 903 is specifically used to determine whether the first bitrate decoding process supports the sampling rate corresponding to the first bitrate encoded bitstream; if the first bitrate decoding process supports the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process; or, if the first bitrate decoding process does not support the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process to obtain fifth data, and the fifth data is subjected to upsampling or downsampling processing.
[0356] In one possible implementation, the decoding module 903 is specifically used to determine whether the second bitrate decoding process supports the sampling rate corresponding to the second bitrate encoded bitstream; if the second bitrate decoding process supports the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process; or, if the second bitrate decoding process does not support the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process to obtain the sixth data, and the sixth data is subjected to upsampling or downsampling processing.
[0357] The apparatus of this embodiment can be used to perform Figure 3 The technical solutions of the method embodiments shown are similar in principle and in effect, and will not be described again here.
[0358] In implementation, each step of the above method embodiments can be completed by integrated logic circuits in the processor hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this application can be directly implemented by a hardware encoding processor, or implemented by a combination of hardware and software modules in the encoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0359] The memory mentioned in the above embodiments can be volatile memory or non-volatile memory, or may include both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0360] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0361] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0362] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0363] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0364] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0365] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0366] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An audio encoding method, characterized in that, include: The set bitrate of the current audio frame to be encoded and the final encoding method of the previous audio frame are obtained. The final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding method to the second bitrate encoding method, or a switching encoding method from the second bitrate encoding method to the first bitrate encoding method, wherein the first bitrate is lower than the second bitrate. The final encoding method of the current audio frame is determined based on the set bit rate and the final encoding method of the previous audio frame; The current audio frame is encoded according to the final encoding method of the current audio frame.
2. The method according to claim 1, characterized in that: When the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, determining the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame includes: When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be the first bitrate encoding method; or, When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to switch from the second bitrate encoding method to the first bitrate encoding method; or, When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is a switch from the first bitrate encoding to the second bitrate encoding, then the final encoding method of the current audio frame is determined to be a switch from the second bitrate encoding to the first bitrate encoding; or, When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is switching from the second bitrate encoding to the first bitrate encoding, the final encoding method of the current audio frame is determined to be the first bitrate encoding method; or, When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the first bitrate encoding method to the second bitrate encoding method; or, When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is a switch from the first bitrate encoding to the second bitrate encoding, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is a switching encoding method from the second bitrate encoding to the first bitrate encoding, it is determined that the final encoding method of the current audio frame is a switching encoding method from the first bitrate encoding to the second bitrate encoding. The value of the set threshold is related to the number of audio channels in the audio frame; or When the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are different, determining the final encoding method of the current audio frame based on the set bitrate and the final encoding method of the previous audio frame includes: When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be the first bitrate encoding method; or, When the set bitrate is less than the set threshold, and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method, and the encoding method is switched to the first bitrate encoding method. A first counter is started, with an initial value of a first set value, and the first counter terminates when its value is 0; or... When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, When the set bitrate is greater than the set threshold, and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switch from the first bitrate encoding to the second bitrate encoding, and a second counter is started. The initial value of the second counter is a first set value, and the second counter terminates when its value is 0; or, When the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, and the value of the first counter is greater than 0, the value of the first counter is decremented by 1; if the value of the first counter is still greater than 0, then the final encoding method of the current audio frame is determined to be a switch from second bitrate encoding to first bitrate encoding; or, if the value of the first counter is 0, then the final encoding method of the current audio frame is determined to be the first bitrate encoding; or... When the final encoding method of the previous audio frame is a switch from the first bitrate encoding to the second bitrate encoding, and the value of the second counter is greater than 0, the value of the second counter is decremented by 1; if the value of the second counter is still greater than 0, then the final encoding method of the current audio frame is determined to be a switch from the first bitrate encoding to the second bitrate encoding; or, if the value of the second counter is 0, then the final encoding method of the current audio frame is determined to be the second bitrate encoding. The value of the set threshold is related to the number of audio channels in the audio frame; or When the final encoding method of the current audio frame is a switching encoding method from the first bitrate encoding to the second bitrate encoding or a switching encoding method from the second bitrate encoding to the first bitrate encoding, the step of encoding the current audio frame according to the final encoding method of the current audio frame includes: Perform first bitrate encoding processing on the current audio frame; and The current audio frame is then subjected to a second bitrate encoding process.
3. The method according to claim 2, characterized in that, When the final encoding method of the current audio frame is a switch from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the step of encoding the current audio frame according to the final encoding method of the current audio frame includes: When the value of the first counter is equal to the first set value, the current audio frame is subjected to first bitrate encoding processing; the current audio frame is subjected to second bitrate encoding processing. or, When the value of the first counter is less than the first set value, the current audio frame is subjected to first bitrate encoding processing; or When the final encoding method of the current audio frame is a switch from a first bitrate encoding to a second bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the step of encoding the current audio frame according to the final encoding method of the current audio frame includes: When the value of the second counter is greater than 1, the current audio frame is subjected to first bitrate encoding processing; the current audio frame is subjected to second bitrate encoding processing. or, When the value of the second counter is equal to 1, the current audio frame is subjected to second bitrate encoding processing; or When the final encoding method of the current audio frame is a switch from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the step of encoding the current audio frame according to the final encoding method of the current audio frame includes: When the value of the first counter is greater than 1, the current audio frame is subjected to first bitrate encoding processing; the current audio frame is subjected to second bitrate encoding processing. or, When the value of the first counter is equal to 1, the current audio frame is subjected to first bitrate encoding processing; or When the final encoding method of the current audio frame is a switch from a first bitrate encoding to a second bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the step of encoding the current audio frame according to the final encoding method of the current audio frame includes: When the value of the second counter is equal to the first set value, the current audio frame is subjected to first bitrate encoding processing; the current audio frame is subjected to second bitrate encoding processing. or, When the value of the second counter is less than the first set value, the current audio frame is subjected to second bitrate encoding processing.
4. The method according to claim 3, characterized in that, The first bitrate encoding process for the current audio frame includes: When the first bitrate encoding process supports the sampling rate of the current audio frame, the current audio frame undergoes the first bitrate encoding process; or, When the first bitrate encoding process does not support the sampling rate of the current audio frame, the current audio frame is downsampled or upsampled to obtain the downsampled or upsampled current audio frame, and the first bitrate encoding process is performed on the downsampled or upsampled current audio frame, wherein the first bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame. or The second bitrate encoding process for the current audio frame includes: When the second bitrate encoding process supports the sampling rate of the current audio frame, the current audio frame undergoes the second bitrate encoding process; or, When the second bitrate encoding process does not support the sampling rate of the current audio frame, the current audio frame is downsampled or upsampled to obtain the downsampled or upsampled current audio frame, and the second bitrate encoding process is performed on the downsampled or upsampled current audio frame, wherein the second bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
5. The method according to any one of claims 1-4, characterized in that, When the final encoding method of the current audio frame is a switching encoding method from the first bitrate encoding to the second bitrate encoding or a switching encoding method from the second bitrate encoding to the first bitrate encoding, before encoding the current audio frame according to the final encoding method of the current audio frame, the method further includes: The first bitrate corresponding to the first bitrate encoding process and the second bitrate corresponding to the second bitrate encoding process are determined based on the set bitrate of the previous audio frame and the set bitrate of the current audio frame. The sum of the first bitrate and the second bitrate is the set bitrate of the current audio frame. Encoding the current audio frame according to the final encoding method of the current audio frame includes: The current audio frame is encoded using the first bitrate. The current audio frame is encoded using the second bitrate.
6. The method according to any one of claims 1-4, characterized in that, The encoded bitstream information corresponding to the current audio frame includes packet header information, a first bitrate encoded bitstream, and / or a second bitrate encoded bitstream. The packet header information includes the final encoding method, sampling rate, number of channels, frame length, and length of the first bitrate encoded bitstream of the current audio frame.
7. An audio decoding method, characterized in that, include: The bitstream information is obtained by encoding the current audio frame according to the final encoding method of the current audio frame to be encoded. The final encoding method of the current audio frame is determined according to the set bitrate of the current audio frame and the final encoding method of the previous audio frame. The final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding method to the second bitrate encoding method, or a switching encoding method from the second bitrate encoding method to the first bitrate encoding method, wherein the first bitrate is lower than the second bitrate. The bitstream information is parsed to obtain the decoding method and the encoded bitstream. The encoded bitstream includes a first bitrate encoded bitstream and / or a second bitrate encoded bitstream. The decoding method includes a first bitrate decoding method, a second bitrate decoding method, a switching decoding method from first bitrate decoding to second bitrate decoding, or a switching decoding method from second bitrate decoding to first bitrate decoding. When the decoding method is the first bitrate decoding method, the encoded bitstream includes the first bitrate encoded bitstream. When the decoding method is the second bitrate decoding method, the encoded bitstream includes the second bitrate encoded bitstream. When the decoding method is a switching decoding method from first bitrate decoding to second bitrate decoding or a switching decoding method from second bitrate decoding to first bitrate decoding, the encoded bitstream includes both the first bitrate encoded bitstream and the second bitrate encoded bitstream. The decoding method corresponds to the final encoding method of the current audio frame. The encoded bitstream is decoded according to the decoding method to obtain the target audio frame.
8. The method according to claim 7, characterized in that, When the decoding method is a first bitrate decoding method, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, or when the decoding method is a first bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: The first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the target audio frame; or When the decoding method is a first bitrate decoding method, and the frame length processed by the first bitrate decoding is less than the frame length processed by the second bitrate decoding, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: The first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; M sample data points overflow from the head of the second data queue corresponding to the first bitrate decoding process, and the second data points are put into the second data queue in a first-in-first-out (FIFO) manner. M is associated with the frame length of the second bitrate decoding process. Extract M sample data points from the head of the second data queue to obtain the target audio frame; or When the decoding method is the second bitrate decoding method, and the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, or when the decoding method is the second bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: The second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the target audio frame; or When the decoding method is the second bitrate decoding method, and the frame length processed by the first bitrate decoding method is greater than the frame length processed by the second bitrate decoding method, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: The second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; M sample data points overflow from the head of the first data queue corresponding to the second bitrate decoding process, and the first data points are put into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process. Extract M sample data points from the head of the first data queue to obtain the target audio frame; or When the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: The first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; The second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; The last N sample data points of the second data are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points, where N is a second set value; The target audio frame is obtained based on the second data excluding the last N sample data and the N sample smoothing data; or When the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length processed by the first bitrate decoding is greater than the frame length processed by the second bitrate decoding, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: When the decoding method of the previous audio frame is not the switching decoding method from the first bitrate decoding to the second bitrate decoding, the first data queue corresponding to the second bitrate decoding processing is set to all 0s. The first data queue follows the first-in-first-out principle. The first bitrate encoded stream is decoded according to the first bitrate decoding method to obtain second data; the second bitrate encoded stream is decoded according to the second bitrate decoding method to obtain first data; M sample data points overflow from the head of the first data queue and the first data points are placed at the tail of the first data queue, where M is associated with the frame length of the first bitrate decoding process; M sample data points are extracted from the head of the first data queue to obtain third data; the last N sample data points of the second data points are weighted and averaged with the first N sample data points of the third data points to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the second data points excluding the last N sample data points and the N sample smooth data points. or When the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length processed by the first bitrate decoding is less than the frame length processed by the second bitrate decoding, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: When the decoding method of the previous audio frame is not a switch from the first bitrate decoding to the second bitrate decoding, the first bitrate encoded stream is decoded according to the first bitrate decoding method to obtain the second data; M sample data points overflow from the head of the second data queue corresponding to the first bitrate decoding process, and the second data points are placed into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding process; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the second bitrate encoded stream is decoded according to the second bitrate decoding method to obtain the first data; the last N sample data points of the fourth data points are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points. or, When the decoding method of the previous audio frame is a switch from the first bitrate decoding to the second bitrate decoding, M sample data points are overflowed from the head of the second data queue; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; the last N sample data points of the fourth data points are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points. or When the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: The second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; The first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; The last N sample data points of the first data point are weighted and averaged with the first N sample data points of the second data point to obtain N sample smooth data points, where N is a second set value; The target audio frame is obtained based on the first data excluding the last N sample data and the N sample smoothing data; or When the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length processed by first bitrate decoding is greater than the frame length processed by second bitrate decoding, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: When the decoding method of the previous audio frame is not a switch from the second bitrate decoding to the first bitrate decoding, the second bitrate encoded stream is decoded according to the second bitrate decoding method to obtain first data; M sample data overflows from the head of the first data queue corresponding to the second bitrate decoding process, and the first data is placed into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; M sample data is extracted from the head of the first data queue to obtain third data; the first bitrate encoded stream is decoded according to the first bitrate decoding method to obtain second data; the last N sample data of the third data and the first N sample data of the second data are weighted and averaged to obtain N sample smoothed data; the target audio frame is obtained based on the other data of the third data excluding the last N sample data and the N sample smoothed data. or, When the decoding method of the previous audio frame is a switch from the second bitrate decoding to the first bitrate decoding, M sample data points are overflowed from the head of the first data queue; M sample data points are extracted from the head of the first data queue to obtain the third data; the first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; the last N sample data points of the third data points are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the third data points excluding the last N sample data points and the N sample smooth data points. or When the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length processed by the first bitrate decoding is less than the frame length processed by the second bitrate decoding, the step of decoding the encoded bitstream according to the decoding method to obtain the target audio frame includes: When the decoding method of the previous audio frame is not the switching decoding method from the second bitrate decoding to the first bitrate decoding, the second data queue corresponding to the first bitrate decoding processing is set to all 0s. The second data queue follows the first-in-first-out principle. The second bitrate encoded stream is decoded according to the second bitrate decoding method to obtain first data; the first bitrate encoded stream is decoded according to the first bitrate decoding method to obtain second data; M sample data points overflow from the head of the second data queue and the second data points are placed at the tail of the second data queue, where M is associated with the frame length of the second bitrate decoding process; M sample data points are extracted from the head of the second data queue to obtain fourth data; the last N sample data points of the first data points are weighted and averaged with the first N sample data points of the fourth data points to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the first data points excluding the last N sample data points and the N sample smooth data points.
9. The method according to claim 8, characterized in that, The first rate decoding process for the first rate encoded bitstream includes: Determine whether the first bitrate decoding process supports the sampling rate corresponding to the first bitrate encoded bitstream; If the first bitrate decoding process supports the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process; or, If the first bitrate decoding process does not support the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process to obtain the fifth data, and the fifth data is subjected to upsampling or downsampling processing.
10. The method according to claim 8, characterized in that, The second rate decoding process for the second rate encoded bitstream includes: Determine whether the second bitrate decoding process supports the sampling rate corresponding to the second bitrate encoded bitstream; If the second rate decoding process supports the sampling rate, then the second rate encoded bitstream is subjected to the second rate decoding process; or, If the second bitrate decoding process does not support the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process to obtain the sixth data, and the sixth data is subjected to upsampling or downsampling processing.
11. An audio encoding device, characterized in that, include: The acquisition module is used to acquire the set bitrate of the current audio frame to be encoded and the final encoding method of the previous audio frame. The final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding to the second bitrate encoding, or a switching encoding method from the second bitrate encoding to the first bitrate encoding, wherein the first bitrate is lower than the second bitrate. The determining module is used to determine the final encoding method of the current audio frame based on the set bit rate and the final encoding method of the previous audio frame; The encoding module is used to encode the current audio frame according to the final encoding method of the current audio frame.
12. The apparatus according to claim 11, characterized in that, When the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the determining module is specifically configured to: determine that the final encoding mode of the current audio frame is the first bitrate encoding mode when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the first bitrate encoding mode; or, determine that the final encoding mode of the current audio frame is a switching encoding mode from second bitrate encoding to first bitrate encoding when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is the second bitrate encoding mode; or, determine that the final encoding mode of the current audio frame is a switching encoding mode from second bitrate encoding to first bitrate encoding when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is a switching encoding mode from first bitrate encoding to second bitrate encoding; or, determine that the final encoding mode of the current audio frame is a switching encoding mode from second bitrate encoding to first bitrate encoding when the set bitrate is less than the set threshold and the final encoding mode of the previous audio frame is a switching encoding mode from second bitrate encoding to first bitrate encoding. The final encoding method of the current audio frame is determined to be a first bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the first bitrate encoding method, the final encoding method of the current audio frame is determined to be a switching encoding method from the first bitrate encoding to the second bitrate encoding; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, when the set bitrate is greater than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, the final encoding method of the current audio frame is determined to be the second bitrate encoding method. If the bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding, then the final encoding method of the current audio frame is determined to be the second bitrate encoding method; or, if the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, then the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding; wherein, the value of the set threshold is related to the number of channels in the audio frame; or When the frame lengths of the first bitrate encoding process and the second bitrate encoding process are not the same, the determining module is specifically configured to: when the set bitrate is less than a set threshold and the final encoding method of the previous audio frame is the first bitrate encoding method, determine that the final encoding method of the current audio frame is the first bitrate encoding method; or, when the set bitrate is less than a set threshold and the final encoding method of the previous audio frame is the second bitrate encoding method, determine that the final encoding method of the current audio frame is the second bitrate encoding method, switch the encoding method from the second bitrate encoding to the first bitrate encoding, and initiate the first bitrate encoding process. A counter, the first counter being initialized to a first set value, and terminating when the value is 0; or, when the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is the second bitrate encoding method, determining that the final encoding method of the current audio frame is the second bitrate encoding method; or, when the set bitrate is greater than a set threshold, and the final encoding method of the previous audio frame is the first bitrate encoding method, determining that the final encoding method of the current audio frame is a switch from the first bitrate encoding to the second bitrate encoding, and starting the second counter. The second counter is initialized to a first set value and terminates when its value is 0; or, when the final encoding method of the previous audio frame is a switch from second bitrate encoding to first bitrate encoding, and the value of the first counter is greater than 0, the value of the first counter is decremented by 1; if the value of the first counter is still greater than 0, then the final encoding method of the current audio frame is determined to be a switch from second bitrate encoding to first bitrate encoding; or, if the value of the first counter is 0, then the final encoding method of the current audio frame is determined to be first bitrate encoding; or, when the final encoding method of the previous audio frame is a switch from first bitrate encoding to second bitrate encoding, and the value of the second counter is greater than 0, the value of the second counter is decremented by 1; if the value of the second counter is still greater than 0, then the final encoding method of the current audio frame is determined to be a switch from first bitrate encoding to second bitrate encoding; or, if the value of the second counter is 0, then the final encoding method of the current audio frame is determined to be second bitrate encoding; wherein, the value of the set threshold is related to the number of channels of the audio frame; or When the final encoding method of the current audio frame is a switching encoding method from the first bitrate encoding to the second bitrate encoding or a switching encoding method from the second bitrate encoding to the first bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame; and to perform second bitrate encoding processing on the current audio frame.
13. The apparatus according to claim 12, characterized in that, When the final encoding method of the current audio frame is a switch from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform first bitrate encoding processing on the current audio frame when the value of the first counter is equal to the first set value; to perform second bitrate encoding processing on the current audio frame; or, when the value of the first counter is less than the first set value, to perform first bitrate encoding processing on the current audio frame. or When the final encoding method of the current audio frame is switching from the first bitrate encoding to the second bitrate encoding, and the frame length processed by the first bitrate encoding is greater than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform the first bitrate encoding processing on the current audio frame when the value of the second counter is greater than 1. The current audio frame is subjected to a second bitrate encoding process; or, when the value of the second counter is equal to 1, the current audio frame is subjected to a second bitrate encoding process. or When the final encoding method of the current audio frame is switching from the second bitrate encoding to the first bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform the first bitrate encoding processing on the current audio frame when the value of the first counter is greater than 1. The current audio frame is subjected to a second bitrate encoding process; or, when the value of the first counter is equal to 1, the current audio frame is subjected to a first bitrate encoding process. or When the final encoding method of the current audio frame is switching from the first bitrate encoding to the second bitrate encoding, and the frame length processed by the first bitrate encoding is less than the frame length processed by the second bitrate encoding, the encoding module is specifically used to perform the first bitrate encoding processing on the current audio frame when the value of the second counter is equal to the first set value. The current audio frame is subjected to a second bitrate encoding process; or, when the value of the second counter is less than the first set value, the current audio frame is subjected to a second bitrate encoding process.
14. The apparatus according to claim 13, characterized in that, The encoding module is specifically configured to perform the first bitrate encoding process on the current audio frame when the first bitrate encoding process supports the sampling rate of the current audio frame; or, when the first bitrate encoding process does not support the sampling rate of the current audio frame, to perform downsampling or upsampling processing on the current audio frame to obtain a downsampled or upsampled current audio frame, and to perform the first bitrate encoding process on the downsampled or upsampled current audio frame, wherein the first bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame; or The encoding module is specifically configured to perform the second bitrate encoding process on the current audio frame when the second bitrate encoding process supports the sampling rate of the current audio frame; or, when the second bitrate encoding process does not support the sampling rate of the current audio frame, to perform downsampling or upsampling processing on the current audio frame to obtain a downsampled or upsampled current audio frame, and to perform the second bitrate encoding process on the downsampled or upsampled current audio frame, wherein the second bitrate encoding process supports the sampling rate of the downsampled or upsampled current audio frame.
15. The apparatus according to any one of claims 11-14, characterized in that, When the final encoding method of the current audio frame is a switching encoding method from the first bitrate encoding to the second bitrate encoding or a switching encoding method from the second bitrate encoding to the first bitrate encoding, the determining module is further configured to determine the first bitrate corresponding to the first bitrate encoding process and the second bitrate corresponding to the second bitrate encoding process based on the set bitrate of the previous audio frame and the set bitrate of the current audio frame, wherein the sum of the first bitrate and the second bitrate is the set bitrate of the current audio frame; The encoding module is specifically configured to encode the current audio frame at the first bitrate and encode it at the second bitrate.
16. The apparatus according to any one of claims 11-14, characterized in that, The encoded bitstream information corresponding to the current audio frame includes packet header information, a first bitrate encoded bitstream, and / or a second bitrate encoded bitstream. The packet header information includes the final encoding method, sampling rate, number of channels, frame length, and length of the first bitrate encoded bitstream of the current audio frame.
17. An audio decoding device, characterized in that, include: The acquisition module is used to acquire bitstream information, which is obtained by encoding the current audio frame according to the final encoding method of the current audio frame to be encoded. The final encoding method of the current audio frame is determined according to the set bitrate of the current audio frame and the final encoding method of the previous audio frame. The final encoding method includes a first bitrate encoding method, a second bitrate encoding method, a switching encoding method from the first bitrate encoding method to the second bitrate encoding method, or a switching encoding method from the second bitrate encoding method to the first bitrate encoding method, wherein the first bitrate is lower than the second bitrate. A parsing module is used to parse the bitstream information to obtain the decoding method and the encoded bitstream. The encoded bitstream includes a first bitrate encoded bitstream and / or a second bitrate encoded bitstream. The decoding method includes a first bitrate decoding method, a second bitrate decoding method, a switching decoding method from first bitrate decoding to second bitrate decoding, or a switching decoding method from second bitrate decoding to first bitrate decoding. When the decoding method is the first bitrate decoding method, the encoded bitstream includes the first bitrate encoded bitstream. When the decoding method is the second bitrate decoding method, the encoded bitstream includes the second bitrate encoded bitstream. When the decoding method is a switching decoding method from first bitrate decoding to second bitrate decoding or a switching decoding method from second bitrate decoding to first bitrate decoding, the encoded bitstream includes both the first bitrate encoded bitstream and the second bitrate encoded bitstream. The decoding method corresponds to the final encoding method of the current audio frame. The decoding module is used to decode the encoded bitstream according to the decoding method to obtain the target audio frame.
18. The apparatus according to claim 17, characterized in that, When the decoding method is the first bitrate decoding method, and the frame length of the first bitrate encoding process is the same as the frame length of the second bitrate encoding process, and the total encoding and decoding latency of the first bitrate encoding process is the same as the total encoding and decoding latency of the second bitrate encoding process, or when the decoding method is the first bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain the target audio frame; or When the decoding method is a first bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; overflow M sample data points from the head of the second data queue corresponding to the first bitrate decoding process, and put the second data into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding process; and extract M sample data points from the head of the second data queue to obtain the target audio frame. or When the decoding method is the second bitrate decoding method, and the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding and decoding latency of the first bitrate encoding process is the same as the total encoding and decoding latency of the second bitrate encoding process, or when the decoding method is the second bitrate decoding method, and the frame length of the first bitrate decoding process is less than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain the target audio frame; or When the decoding method is the second bitrate decoding method, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; overflow M sample data points from the head of the first data queue corresponding to the second bitrate decoding process, and put the first data into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; and extract M sample data points from the head of the first data queue to obtain the target audio frame. or When the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate encoding process and the frame length of the second bitrate encoding process are the same, and the total encoding / decoding latency of the first bitrate encoding process is the same as the total encoding / decoding latency of the second bitrate encoding process, the decoding module is specifically used to decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; and to decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data. The last N sample data points of the second data are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points, where N is a second set value; the target audio frame is obtained based on the other data of the second data points excluding the last N sample data points and the N sample smooth data points. or When the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to: set the first data queue corresponding to the second bitrate decoding process to all zeros when the decoding method of the previous audio frame is not a switch from first bitrate decoding to second bitrate decoding; the first data queue follows a first-in-first-out principle; decode the first bitrate encoded bitstream according to the first bitrate decoding method to obtain second data; decode the second bitrate encoded bitstream according to the second bitrate decoding method to obtain first data; overflow M sample data from the head of the first data queue and place the first data at the tail of the first data queue, where M is associated with the frame length of the first bitrate decoding process; and extract M sample data from the head of the first data queue to obtain third data. The last N sample data points of the second data are weighted and averaged with the first N sample data points of the third data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the second data points excluding the last N sample data points and the N sample smooth data points. or When the decoding method is a switch from first bitrate decoding to second bitrate decoding, and the frame length processed by the first bitrate decoding is less than the frame length processed by the second bitrate decoding, the decoding module is specifically used to: decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data when the decoding method of the previous audio frame is not a switch from first bitrate decoding to second bitrate decoding; overflow M sample data from the head of the second data queue corresponding to the first bitrate decoding processing, and put the second data into the second data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the second bitrate decoding processing; extract M sample data from the head of the second data queue to obtain fourth data; and decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data. The last N sample data points of the fourth data are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points; or, when the decoding method of the previous audio frame is a switching decoding method from the first bitrate decoding to the second bitrate decoding, M sample data points are overflowed from the head of the second data queue; M sample data points are extracted from the head of the second data queue to obtain the fourth data; the second bitrate encoded bitstream is decoded according to the second bitrate decoding method to obtain the first data; The last N sample data points of the fourth data are weighted and averaged with the first N sample data points of the first data to obtain N sample smooth data points; the target audio frame is obtained based on the other data of the fourth data points excluding the last N sample data points and the N sample smooth data points. or When the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate encoding process is the same as that of the second bitrate encoding process, and the total encoding / decoding latency of the first bitrate encoding process is the same as that of the second bitrate encoding process, the decoding module is specifically used to decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; perform a weighted average of the last N sample data of the first data and the first N sample data of the second data to obtain N sample smooth data, where N is a second set value; and obtain the target audio frame based on the other data of the first data excluding the last N sample data and the N sample smooth data. or When the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate decoding process is greater than the frame length of the second bitrate decoding process, the decoding module is specifically used to: When the decoding method of the previous audio frame is not a switch from second bitrate decoding to first bitrate decoding, decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; overflow M sample data from the head of the first data queue corresponding to the second bitrate decoding process, and place the first data into the first data queue in a first-in-first-out (FIFO) manner, where M is associated with the frame length of the first bitrate decoding process; extract M sample data from the head of the first data queue to obtain third data; decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; and process the last N sample data of the third data... The first data is obtained by weighting the first N sample data points of the second data with the second data to obtain N sample smooth data points; the target audio frame is obtained based on the third data (excluding the last N sample data points) and the N sample smooth data points; or, when the decoding method of the previous audio frame is a switch from the second bitrate decoding to the first bitrate decoding, M sample data points are overflowed from the head of the first data queue; M sample data points are extracted from the head of the first data queue to obtain the third data; the first bitrate encoded bitstream is decoded according to the first bitrate decoding method to obtain the second data; the last N sample data points of the third data are weighted and averaged with the first N sample data points of the second data to obtain N sample smooth data points; the target audio frame is obtained based on the third data (excluding the last N sample data points) and the N sample smooth data points. or When the decoding method is a switch from second bitrate decoding to first bitrate decoding, and the frame length of the first bitrate decoding is less than the frame length of the second bitrate decoding, the decoding module is specifically used to: set the second data queue corresponding to the first bitrate decoding to all zeros when the decoding method of the previous audio frame is not a switch from second bitrate decoding to first bitrate decoding; the second data queue follows a first-in-first-out principle; decode the second bitrate encoded stream according to the second bitrate decoding method to obtain first data; decode the first bitrate encoded stream according to the first bitrate decoding method to obtain second data; overflow M sample data from the head of the second data queue and place the second data at the tail of the second data queue, where M is associated with the frame length of the second bitrate decoding; extract M sample data from the head of the second data queue to obtain fourth data; perform a weighted average of the last N sample data of the first data and the first N sample data of the fourth data to obtain N sample smoothed data; and obtain the target audio frame based on the other data of the first data excluding the last N sample data and the N sample smoothed data.
19. The apparatus according to claim 18, characterized in that, The decoding module is specifically used to determine whether the first bitrate decoding process supports the sampling rate corresponding to the first bitrate encoded bitstream; if the first bitrate decoding process supports the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process; or, if the first bitrate decoding process does not support the sampling rate, then the first bitrate encoded bitstream is subjected to the first bitrate decoding process to obtain the fifth data, and the fifth data is subjected to upsampling or downsampling processing.
20. The apparatus according to claim 18, characterized in that, The decoding module is specifically used to determine whether the second bitrate decoding process supports the sampling rate corresponding to the second bitrate encoded bitstream; if the second bitrate decoding process supports the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process; or, if the second bitrate decoding process does not support the sampling rate, then the second bitrate encoded bitstream is subjected to the second bitrate decoding process to obtain the sixth data, and the sixth data is subjected to upsampling or downsampling processing.
21. An audio encoding device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.
22. An audio decoding device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 7-10.
23. A computer-readable storage medium, characterized in that, It includes a computer program that, when executed on a computer, causes the computer to perform the method of any one of claims 1-10.
24. A computer-readable storage medium, characterized in that, This includes the bitstream information obtained according to the audio encoding method as described in any one of claims 1-6.
25. A computer-readable storage medium, characterized in that, This includes audio frames obtained according to the audio decoding method according to any one of claims 7-10.