Image encoding and decoding method and device
Through precoding and fallback mode processing at the encoding and decoding ends, the problem of code stream overflow during the video encoding and decoding process is solved, ensuring stable transmission of the code stream and the integrity of image information.
Patent Information
- Application Number
- CN202310503347.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-06
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2042-06-06
AI Technical Summary
During the video encoding and decoding process, the variable rate characteristics of the code stream lead to code stream overflow problems, resulting in the loss of image information or failure to transmit normally.
By using precoding and fallback modes at the encoding end and decoding end respectively, based on the comparison results of the code stream length and the buffer storage space, it is determined whether to use the fallback mode to avoid code stream overflow and ensure that the code stream is on the fixed code rate channel stable transmission.
It effectively avoids code stream overflow and underflow, ensures the integrity of image information and the stability of transmission, and improves the reliability of the video encoding and decoding process.
Smart Images

Figure CN116489360B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of video coding and decoding, and in particular to an image coding and decoding method and device. Background Art
[0002] Video coding technology is also called video compression technology. Video compression technology is used to reduce the data bandwidth of video signals. Among them, video is a continuous sequence of images, which is composed of continuous image frames. One frame is an image. Due to the visual persistence effect of the human eye, when the frame sequence is played at a certain rate, what the human eye can see is a continuous video. Encoding and decoding a video means encoding and decoding each frame of the video. Taking a frame of image as an example, at the encoding end, the image encoder encodes the image, obtains the code stream corresponding to the image and transmits the code stream to the decoding end; at the decoding end, the image decoder parses the code stream to reconstruct the image.
[0003] In the process of image encoding and decoding, in order to improve the compression efficiency, common video compression technologies all use variable length coding. The code stream obtained after a video sequence is compressed and encoded is variable rate, which is not suitable for real-time transmission in a fixed bit rate channel. Therefore, the variable bit rate data generated by the encoder is usually output to a buffer with a certain storage space, and then output from the buffer at a fixed bit rate. It should be understood that the size of the buffer's storage space is certain. If the code stream data input to the buffer is too large, resulting in the data that needs to be temporarily stored in the buffer exceeding the size of its storage space, the code stream will "overflow", resulting in subsequent image information loss. In addition, if the code stream data input to the buffer is too small, resulting in "insufficient" data temporarily stored in the buffer, and unable to meet the fixed output bit rate of the buffer, the code stream will "underflow".
[0004] Therefore, how to avoid the occurrence of "overflow" or "underflow" of code stream during the image encoding and decoding process is an urgent problem to be solved. Summary of the invention
[0005] The embodiments of the present application provide an image encoding and decoding method and device, which can be used to avoid code stream overflow.
[0006] To achieve the above objectives, the present application embodiment adopts the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides an image encoding method, which is executed by an encoding end, and the method includes: obtaining a maximum code length of a block to be encoded, the maximum code length being the maximum code stream length allowed to be cached when a code stream buffer caches the encoded code stream of the block to be encoded; pre-encoding the block to be encoded based on a first mode to obtain a first code length of the block to be encoded, the first mode being one of multiple prediction modes of the encoding end; the first code length is the length of the code stream obtained after encoding the block to be encoded; when the first code length is greater than or equal to the maximum code length, encoding the block to be encoded in a fallback mode, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than or equal to the maximum code length.
[0008] Based on the above image coding method, the block to be coded can be pre-coded first, and the code stream length obtained based on the pre-coding can be compared with the maximum code length allowed by the block to be coded, and according to the comparison result, it can be determined whether the code stream overflow will occur. Then, when it is determined that the code stream overflow will occur, the block to be coded is coded in a fallback mode to avoid the loss of image information of the block to be coded.
[0009] In a possible implementation, the maximum code length is the sum of the length of the code stream that can be accommodated in the code stream buffer and the length of the code stream transmitted by the storage space in a unit time. The storage space is the storage space of the code stream buffer.
[0010] In another possible implementation, the block to be encoded may include a first chroma component, a second chroma component, and a luminance component. In the above case, when the first code length is greater than or equal to the maximum code length, the fallback mode is used to encode the block to be encoded, including: when the first code length is greater than or equal to the maximum code length, according to the maximum code length, according to a preset ratio, determine the first chroma maximum code length, the second chroma maximum code length, and the luminance maximum code length, wherein the sum of the first chroma maximum code length, the second chroma maximum code length, and the third chroma maximum code length is the maximum code length or the code length flowing out of the storage space per unit time; according to one or more of the first chroma maximum code length, the second chroma maximum code length, and the luminance maximum code length, determine whether the first chroma component, the second chroma component, and the luminance component are encoded using the fallback mode.
[0011] In another possible implementation, the above-mentioned determining whether the first chroma component, the second chroma component and the luminance component are encoded in the fallback mode according to one or more of the first chroma maximum code length, the first chroma maximum code length and the luminance maximum code length includes: determining whether the first chroma component, the second chroma component and the luminance component are encoded in the fallback mode according to any one of the first chroma maximum code length, the second chroma maximum code length and the luminance maximum code length; or, determining whether the first chroma component and the second chroma component are encoded in the fallback mode according to the first chroma maximum code length or the second chroma maximum code length; and determining whether the luminance component is encoded in the fallback mode according to the luminance maximum code length; or, determining whether the first chroma component is encoded in the fallback mode according to the first chroma maximum code length, determining whether the second chroma component is encoded in the fallback mode according to the second chroma maximum code length, and, determining whether the luminance component is encoded in the fallback mode according to the luminance maximum code length.
[0012] In another possible implementation, the above-mentioned determining whether to use the fallback mode to encode the first chroma component based on the first chroma maximum code length includes: pre-encoding the first chroma component based on the first mode to obtain the first chroma code length of the first chroma component; when the first chroma code length is greater than or equal to the first chroma maximum code length, determining to use the fallback mode to encode the first chroma code length.
[0013] In another possible implementation, the sum of the code length of the first chrominance component, the code length of the second chrominance component and the code length of the luminance component is the code length of the block to be encoded; the code length of the luminance component is greater than the code length of the first chrominance component or the code length of the second chrominance component.
[0014] Optionally, the preset ratio is 1:1:1, 2:1:1 or 4:1:1.
[0015] In another possible implementation, the above-mentioned encoding of the block to be encoded using the fallback mode includes: obtaining a target pixel depth, where the target pixel depth is used to indicate the code length required when encoding each pixel of the block to be encoded at a target compression rate; determining a target code length of the block to be encoded based on the target pixel depth, where the target code length is the length of the code stream obtained by encoding the block to be encoded based on the fallback mode, and the target code length is less than or equal to the maximum code length; based on the target code length, encoding the block to be encoded using a fixed code length encoding method.
[0016] In another possible implementation, the above-mentioned encoding of the block to be encoded by using a fixed code length encoding method based on the target code length includes: dividing the block to be encoded into multiple sub-blocks to be encoded; determining a first fixed code length based on the target code length and the number of the multiple sub-blocks to be encoded; encoding the multiple sub-blocks to be encoded by using a fixed code length encoding method based on the first fixed code length; wherein the length of a code stream obtained by encoding each of the multiple sub-blocks to be encoded is the first fixed code length.
[0017] In yet another possible implementation, the step of dividing the block to be encoded into a plurality of sub-blocks to be encoded includes: dividing the block to be encoded into a plurality of sub-blocks to be encoded with a preset size.
[0018] In another possible implementation, the above-mentioned encoding of the block to be encoded by using a fixed code length encoding method based on the target code length includes: dividing the block to be encoded into multiple sub-blocks to be encoded according to the target code length and a first fixed code length; wherein the first fixed code length is a code length of a preset length; based on the first fixed code length, encoding the multiple sub-blocks to be encoded by using a fixed code length encoding method; wherein the length of a code stream obtained by encoding each of the multiple sub-blocks to be encoded is the first fixed code length.
[0019] In another possible implementation, for any sub-block to be encoded among the multiple sub-blocks to be encoded, the above-mentioned encoding of the multiple sub-blocks to be encoded using a fixed code length encoding method based on the first fixed code length includes: determining a residual value of any sub-block to be encoded; and encoding a residual block of any sub-block to be encoded using a fixed code length encoding method based on the first fixed code length.
[0020] In another possible implementation, for any sub-block to be encoded among the multiple sub-blocks to be encoded, the above-mentioned encoding method based on the first fixed code length and using the fixed code length encoding method for the multiple sub-blocks to be encoded includes: based on the first fixed code length, using the fixed code length encoding method to encode the high-order value of the image bit width of any sub-block to be encoded, the high-order value of the image bit width is used to indicate the value of the first N bits of the binary number corresponding to the image bit width, N is a positive integer; or, based on the first fixed code length, using the fixed code length encoding method to encode the low-order value of the image bit width, the low-order value of the image bit width is used to indicate the value of the last N bits of the binary number corresponding to the image bit width, N is a positive integer, wherein N is the above-mentioned first fixed code length.
[0021] In a second aspect, an embodiment of the present application provides an image encoding method, which is executed by a decoding end, and the method includes: based on the code stream of the block to be decoded, determining whether the image block corresponding to the block to be decoded adopts a fallback mode, wherein the code length of the image block to be decoded is less than or equal to the maximum code length of the block to be decoded, and the maximum code length is the maximum code stream length allowed to be cached in the code stream buffer; when the image block corresponding to the block to be decoded adopts the fallback mode, obtaining a first fixed code length, the first fixed code length is the code length of a sub-block to be decoded, and the block to be decoded includes one or more sub-blocks to be decoded; parsing the code stream based on the first fixed code length to decode the block to be decoded.
[0022] In a possible implementation, the maximum code length is the sum of the length of the code stream that can be accommodated in the code stream buffer and the length of the code stream transmitted by the code stream buffer within a unit time.
[0023] In another possible implementation, the block to be decoded includes one or more components, and the decoding end determines whether the one or more components adopt the fallback mode respectively.
[0024] In another possible implementation, the block to be decoded includes a first chroma component, a second chroma component and a luminance component, and based on the bitstream of the block to be decoded, determining whether an image block corresponding to the block to be decoded adopts a fallback mode during encoding includes: parsing the bitstream of any one of the first chroma component, the second chroma component or the luminance component, and determining whether the first chroma component, the second chroma component and the luminance component adopt the fallback mode; or, parsing the bitstream of the first chroma component or the second chroma component, and determining whether the first chroma component and the second chroma component adopt the fallback mode; or, parsing the bitstream of the first chroma component, the second chroma component and the luminance component, and respectively determining whether the first chroma component, the second chroma component and the luminance component adopt the fallback mode.
[0025] In another possible implementation, the sum of the code length of the first chrominance component, the code length of the second chrominance component and the code length of the luminance component of the block to be decoded is the code length of the block to be decoded; the code length of the luminance component is greater than the code length of the first chrominance component or the code length of the second chrominance component.
[0026] In another possible implementation, the first fixed code length is a preset code length value or a target pixel depth of the block to be decoded, and the target pixel depth is used to indicate the code length required for decoding each pixel of the block to be decoded at a target compression rate.
[0027] In another possible implementation, the parsing of the code stream based on the first fixed code length to decode the block to be decoded includes: dividing the block to be decoded into multiple sub-blocks to be decoded according to the code length of the block to be decoded and the first fixed code length; parsing the code stream of each sub-block to be decoded of the block to be decoded based on the first fixed code length to decode the block to be decoded.
[0028] In yet another possible implementation, the obtaining of the first fixed code length includes: dividing the to-be-decoded block into a plurality of to-be-decoded sub-blocks; and determining the first fixed code length based on the code length of the to-be-decoded block and the number of the plurality of to-be-decoded sub-blocks.
[0029] In yet another possible implementation, the above-mentioned dividing the block to be decoded into a plurality of sub-blocks to be decoded includes: dividing the block to be decoded into a plurality of sub-blocks to be decoded with a preset size.
[0030] In another possible implementation, the above-mentioned parsing of the code stream of each sub-block to be decoded based on the first fixed code length to decode the block to be decoded includes: parsing the code stream of each sub-block to be decoded of the block to be decoded based on the first fixed code length to obtain the high-order value of the image bit width corresponding to each sub-block to be decoded, the high-order value of the image bit width is used to indicate the first N-bit value of the binary number corresponding to the image bit width, N is a positive integer; reconstructing each sub-block to be decoded according to the low-order value of the predicted value of each sub-block to be decoded and the high-order value of the image bit width corresponding to each sub-block to be decoded, so as to obtain a reconstructed block of each sub-block to be decoded; the low-order value of the predicted value is used to indicate the last M-bit value of the binary number corresponding to the predicted value, M is a positive integer; wherein the sum of N and M is the image bit width of the sub-block to be decoded, and N is the first fixed code length.
[0031] In another possible implementation, parsing the code stream based on the first fixed code length to decode the block to be decoded includes: parsing the code stream of each sub-block to be decoded of the block to be decoded based on the first fixed code length to obtain the low-order value of the image bit width corresponding to each sub-block to be decoded, the low-order value of the image bit width is used to indicate the last N-bit value of the binary number corresponding to the image bit width, N is a positive integer; reconstructing each sub-block to be decoded according to the high-order value of the predicted value of each sub-block to be decoded and the low-order value of the image bit width corresponding to each sub-block to be decoded, so as to obtain a reconstructed block of each sub-block to be decoded; the high-order value of the predicted value is used to indicate the first M-bit value of the binary number corresponding to the predicted value, M is a positive integer; wherein the sum of N and M is the image bit width of the sub-block to be decoded, and N is the first fixed code length.
[0032] In another possible implementation, parsing the code stream based on the first fixed code length to decode the block to be decoded includes: parsing the code stream of each sub-block to be decoded of the block to be decoded based on the first fixed code length to obtain a residual value of each sub-block to be decoded; and reconstructing each sub-block to be decoded according to the predicted value and the residual value of each sub-block to be decoded to obtain a reconstructed block of each sub-block to be decoded.
[0033] In another possible implementation, the method further includes: when the codeword used to indicate the prediction mode in the code stream of the block to be decoded is a first codeword, and the image block corresponding to the block to be decoded does not adopt the fallback mode, reconstructing the image block of the block to be decoded based on the original value mode, wherein the first codeword is used to indicate the fallback mode or the original value mode.
[0034] In a third aspect, an embodiment of the present application provides an image encoding method, which is executed by an encoding end, and the method includes: obtaining a minimum code length of a block to be encoded, the minimum code length being the minimum code stream length allowed to be cached in a code stream buffer; pre-encoding the block to be encoded based on a first mode to obtain a first code length of the block to be encoded, the first mode being one of multiple prediction modes of the encoding end; the first code length is the length of the code stream obtained after encoding the block to be encoded; when the first code length is less than or equal to the minimum code length, encoding the block to be encoded in a fallback mode, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is greater than or equal to the minimum code length.
[0035] It can be understood that using the fallback mode to decode the block to be decoded can avoid the situation of code stream overflow, thereby avoiding the loss of image information of the block to be decoded.
[0036] In a possible implementation, the sum of the difference between the code stream length stored in the storage space and the code length output by the storage space in unit time and the minimum code length is greater than or equal to the code length output by the storage space in unit time.
[0037] In a fourth aspect, an embodiment of the present application provides an image decoding method, which is applied to a decoding end, and the method includes: based on a code stream of a block to be decoded, determining whether an image block corresponding to the block to be decoded adopts a fallback mode when encoding, wherein a code length obtained when the image block is encoded based on the fallback mode is greater than or equal to a minimum code length of the block to be decoded, and the minimum code length is a minimum code stream length allowed to be cached in a code stream buffer; when the image block corresponding to the block to be decoded adopts a fallback mode when encoding, obtaining a first fixed code length based on the code stream, the first fixed code length is a code length of a sub-block to be decoded, and the block to be decoded includes multiple sub-blocks to be decoded; parsing the code stream based on the first fixed code length to decode the block to be decoded.
[0038] The image decoding method provided by the fourth aspect and any possible implementation thereof corresponds to the image encoding method provided by the third aspect and any possible implementation thereof. Therefore, the beneficial effects of the technical solution provided by the fourth aspect and any possible implementation thereof can be referred to the description of the beneficial effects of the corresponding method in the third aspect and will not be repeated here.
[0039] In a fifth aspect, an embodiment of the present application provides an image encoding method, which is applied to an encoding end, and the method includes: obtaining a maximum code length of a block to be encoded, the maximum code length being the maximum code stream length allowed to be cached in a code stream buffer; pre-encoding the block to be encoded based on a first mode to obtain a first code length of the block to be encoded, the first mode being one of multiple prediction modes of the encoding end; the first code length is the length of the code stream obtained after encoding the block to be encoded; when the first code length is greater than or equal to the maximum code length, based on skipping the residual coding mode, encoding the block to be encoded using a target mode, wherein the code length obtained by encoding the block to be encoded based on the residual coding mode is less than or equal to the maximum code length, and the target mode is one of the multiple prediction modes of the encoding end.
[0040] In a possible implementation, the above-mentioned encoding of the block to be encoded using the target mode based on the skip residual coding mode includes: encoding an identifier of the target mode to obtain a code stream of the block to be encoded.
[0041] In another possible implementation, the target mode is the first mode; or, the target mode is a preset prediction mode.
[0042] In another possible implementation, before the above-mentioned method is based on skipping residual coding mode and adopting the target mode to encode the coding block, the method also includes: pre-encoding the coding block based on each prediction mode of multiple prediction modes of the encoding end, and determining the prediction mode with the best pre-encoding coding performance as the target mode, and the coding performance includes compression rate, coding efficiency or coding loss rate.
[0043] In a sixth aspect, an embodiment of the present application provides an image decoding method, which is applied to a decoding end, and includes: parsing a code stream of a block to be decoded, determining whether to use a forced residual skip mode; when using a forced residual skip mode, determining a target mode of the block to be decoded, the target mode being one of multiple prediction modes of the decoding end; determining a prediction value of the block to be decoded based on the target mode; and determining the prediction value of the block to be decoded as a reconstructed value of the block to be decoded. .
[0044] The image decoding method provided by the sixth aspect and any possible implementation thereof corresponds to the image encoding method provided by the fifth aspect and any possible implementation thereof. Therefore, the beneficial effects of the technical solution provided by the sixth aspect and any possible implementation thereof can be referred to the description of the beneficial effects of the corresponding method in the fifth aspect and will not be repeated here.
[0045] In a seventh aspect, the present application provides an image encoding device. The encoding device may be a video encoder or a device including a video encoder. The encoding device includes various modules for implementing the method in any possible implementation of the first aspect, the third aspect, or the fifth aspect. The encoding device has the function of implementing the behavior in the above-mentioned related method instance. The function can be implemented by hardware, or by hardware executing corresponding software implementation. The hardware or software includes one or more modules corresponding to the above-mentioned functions. The beneficial effects thereof can be found in the description of the corresponding method, which will not be repeated here.
[0046] In an eighth aspect, the present application provides an image decoding device. The decoding device may be a video decoder or a device including a video decoder. The decoding device includes modules for implementing the method in any possible implementation of the second aspect, the fourth aspect, or the sixth aspect. The decoding device has the function of implementing the behavior in the above-mentioned related method instance. The function may be implemented by hardware, or by hardware executing corresponding software implementation. The hardware or software includes one or more modules corresponding to the above-mentioned function. The beneficial effects thereof can be found in the description of the corresponding method, which will not be repeated here.
[0047] In a ninth aspect, the present application provides an electronic device comprising a processor and a memory, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement a method of any one of the implementation methods in the first to sixth aspects.
[0048] For example, the electronic device may refer to a video encoder, or a device including a video encoder.
[0049] For another example, the electronic device may refer to a video decoder, or a device including a video decoder.
[0050] In the tenth aspect, the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions are executed by a computing device or a storage system where the computing device is located, a method of implementing any one of the first to sixth aspects is implemented.
[0051] In the eleventh aspect, the present application provides a computer program product, which includes instructions. When the computer program product runs on a computing device or a processor, the computing device or the processor executes the instructions to implement a method of any one of the implementation methods of the first to sixth aspects.
[0052] In the twelfth aspect, the present application provides a chip including a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement the method of any one of the implementation modes in the first to sixth aspects.
[0053] In a thirteenth aspect, the present application provides an image decoding system, which includes an encoding end and a decoding end, the decoding end is used to implement the corresponding decoding method provided in the first, third or fifth aspect, and the encoding end is used to implement the corresponding encoding method.
[0054] Based on the implementations provided in the above aspects, the present application can be further combined to provide more implementations. In other words, any possible implementation of any of the above aspects can be applied to other aspects without conflict, thereby obtaining a new embodiment. For example, any image encoding method provided in the first, third and fifth aspects can be combined in pairs or in three aspects without conflict, thereby obtaining a new image decoding method. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A schematic diagram of the architecture of a coding and decoding system 1 used in an embodiment of the present application;
[0056] Figure 2 is a schematic block diagram of an example of an encoder 100 for implementing the method according to an embodiment of the present application;
[0057] Figure 3 A schematic diagram of a corresponding relationship between an image, a parallel coding unit, an independent coding unit, and a coding unit provided in an embodiment of the present application;
[0058] Figure 4 is a schematic block diagram of an example of a decoder 200 for implementing the method according to an embodiment of the present application;
[0059] Figure 5 A schematic diagram of a flow chart of an image encoding method provided in an embodiment of the present application;
[0060] Figure 6 A schematic diagram of a sub-block to be encoded provided in an embodiment of the present application;
[0061] Figure 7 A schematic diagram of a flow chart of another image encoding method provided in an embodiment of the present application;
[0062] Figure 8 A schematic diagram of a block to be encoded provided in an embodiment of the present application;
[0063] Fig. 9 A schematic diagram of another block to be encoded provided in an embodiment of the present application;
[0064] Fig.10 A flowchart of an image decoding method provided in an embodiment of the present application;
[0065] Fig.11 A logic flow chart of an image decoding method provided in an embodiment of the present application;
[0066] Fig.12 A schematic diagram of a flow chart of an image encoding method provided in an embodiment of the present application;
[0067] Fig.13 A schematic diagram of a flow chart of another image decoding method provided in an embodiment of the present application;
[0068] Fig.14 A schematic diagram of a flow chart of another image encoding method provided in an embodiment of the present application;
[0069] Fig.15 A schematic diagram of a flow chart of another image decoding method provided in an embodiment of the present application;
[0070] Fig.16 A schematic diagram of the structure of an encoding device 1600 provided in an embodiment of the present application;
[0071] Fig.17 A schematic diagram of the structure of a decoding device 1700 provided in an embodiment of the present application;
[0072] Fig.18 A schematic diagram of the structure of another encoding device 1800 provided in an embodiment of the present application;
[0073] Fig.19 A schematic diagram of the structure of another decoding device 1900 provided in an embodiment of the present application;
[0074] Fig. 20 A schematic diagram of the structure of another encoding device 2000 provided in an embodiment of the present application;
[0075] Fig.21 A schematic diagram of the structure of another decoding device 1900 provided in an embodiment of the present application;
[0076] Fig. 22 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0078] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "plurality" means two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different.
[0079] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0080] The following describes the system architecture used in the embodiments of the present application.
[0081] See also Figure 1 , Figure 1 FIG. 1 shows a schematic diagram of the architecture of the encoding and decoding system 1 used in the embodiment of the present application. Figure 1 As shown, the coding and decoding system 1 may include an encoding end 10 and a decoding end 20. The encoding end 10 generates encoded video data. Therefore, the encoding end 10 may be referred to as a video encoding device. The decoding end 20 may decode the encoded video data generated by the encoding end 10. Therefore, the decoding end 20 may be referred to as a video decoding device.
[0082] The specific forms of the encoding end 10 and the decoding end 20 can be various devices, including desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, telephone handsets such as so-called "smart" phones, televisions, cameras, display devices, digital media players, video game consoles, car computers, or the like.
[0083] Optional, Figure 1 The encoding end 10 and the decoding end 20 in the embodiment may be two separate devices. Alternatively, the encoding end 10 and the decoding end 20 may be the same device, that is, the encoding end 10 or the corresponding functions and the decoding end 20 or the corresponding functions may be integrated on the same device.
[0084] The encoding end 10 and the decoding end 20 may communicate with each other. For example, the decoding end 20 may receive the encoded video data from the encoding end 10 via the link 30. The link 30 may include one or more media or devices capable of moving the encoded video data from the encoding end 10 to the decoding end 20. In one example, the link 30 may include one or more communication media that enable the encoding end 10 to transmit the encoded video data directly to the decoding end 20 in real time. In this example, the encoding end 10 may modulate the encoded video data according to a communication standard (e.g., a wireless communication protocol), and may transmit the modulated video data to the decoding end 20. The one or more communication media may include wireless and / or wired communication media, such as a radio frequency (RF) spectrum or one or more physical transmission lines. The one or more communication media may form part of a packet-based network, such as a local area network, a wide area network, or a global network (e.g., the Internet). The one or more communication media may include routers, switches, base stations, or other devices that facilitate communication from the encoding end 10 to the decoding end 20.
[0085] Optionally, the encoder 10 can output the encoded data from the output interface 140 to a built-in or external storage device. The storage device may include any of a variety of distributed or locally accessed data storage media, such as a hard disk drive, a Blu-ray disc, a digital video disc (DVD), a compact disc read-only memory (CD-ROM), a flash memory, a volatile or non-volatile memory, or any other suitable digital storage medium for storing encoded video data.
[0086] like Figure 1 As shown, the encoding end 10 includes a video source 120, an encoder 100, and an output interface 140. In some examples, the output interface 140 may include a modulator / demodulator (modem) and / or a transmitter. The video source 120 may include a video capture device (e.g., a camera), a video archive containing previously captured video data, a video feed interface for receiving video data from a video content provider, and / or a computer graphics system for generating video data, or a combination of such sources of video data. The encoder 100 may encode the video data from the video source 120. In some examples, the encoding end 10 transmits the encoded video data directly to the decoding end 20 via the output interface 140. In other examples, the encoded video data may also be stored on a storage device for later access by the decoding end 20 for decoding and / or playback.
[0087] like Figure 1As shown, the decoding end 20 includes an input interface 240, a decoder 200 and a display device 220. In some examples, the input interface 240 includes a receiver and / or a modem. The input interface 240 can receive the encoded video data via the link 30 and / or from a storage device. The display device 220 can be integrated with the decoding end 20 or can be outside the decoding end 20. In general, the display device 220 displays the decoded video data. The display device 220 may include a variety of display devices, for example, a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display or other types of display devices.
[0088] Optionally, the encoding end 10 further includes a code stream buffer ( Figure 1 The bitstream buffer is used to receive the bitstream data generated by encoding and output the bitstream data with a fixed bitrate. The size of the bitstream data generated after encoding different blocks to be encoded can vary greatly based on the properties of the blocks to be encoded. Therefore, the bitstream obtained after a video sequence is compressed and encoded is of variable rate and is not suitable for real-time transmission in a fixed bitrate channel. The bitstream buffer can be used to smooth the rate changes in the compressed video. The larger the storage space of the bitstream buffer, the more it can withstand the fluctuation of the bitrate.
[0089] Optionally, the decoding end 20 may also include another buffer, which may be used to receive the bitstream data of a fixed bitrate and output the bitstream data from the buffer to the bitstream parsing unit 201 of the decoder 200 .
[0090] although Figure 1 Not shown, but in some aspects, encoder 100 and decoder 200 may each be integrated with an audio encoder and decoder, and may include appropriate multiplexer-demultiplexer units or other hardware and software to handle the encoding of both audio and video in a common data stream or in separate data streams.
[0091] It should be understood that Figure 1 The illustrated codec system 1 is only an example, and the techniques of the present application may be applicable to video coding arrangements (e.g., video encoding or video decoding) that do not necessarily include any data communication between the encoding device and the decoding device. In other examples, data is retrieved from a local memory, streamed over a network, and the like. A video encoding device may encode data and store the data to a memory, and / or a video decoding device may retrieve data from a memory and decode the data. In many examples, encoding and decoding are performed by devices that do not communicate with each other but only encode data to a memory and / or retrieve data from a memory and decode data.
[0092] Below is a description of the drawings. Figure 1 The specific structures of the encoder 100 and decoder 200 are briefly introduced.
[0093] See also Figure 2 , Figure 2 1 is a schematic block diagram of an example of an encoder 100 for implementing the method of the embodiment of the present application. Figure 2 As shown, the encoder 100 includes a prediction processing unit 101, a residual calculation unit 102, a residual transformation unit 103, a quantization unit 104, an encoding unit 105, an inverse quantization unit (also called an inverse quantization unit) 106, a residual inverse transformation unit 107, a reconstruction unit (or called a reconstruction unit) 108 and a filter unit 109.
[0094] In one example, the input of the encoder 100 is an image block of an image to be encoded (ie, a block to be encoded or a coding unit).
[0095] In another example, the input of the encoder 100 is an image to be encoded, and the encoder 100 may further include a segmentation unit ( Figure 2 The encoder 100 is used to encode the multiple image blocks of the image to be encoded block by block, thereby completing the encoding of the image to be encoded. For example, the encoder 100 performs an encoding process on each image block, thereby completing the encoding of the image to be encoded.
[0096] Exemplarily, a method for dividing a to-be-encoded image into a plurality of image blocks may include:
[0097] Step 11: Divide a frame of image into one or more non-overlapping parallel coding units. The parallel coding units have no dependency relationship and can be encoded and decoded in parallel / independently.
[0098] Step 12: For each parallel coding unit, the encoding end may divide it into one or more independent coding units that do not overlap each other. The independent coding units may not depend on each other, but may share some header information of the parallel coding unit.
[0099] Step 13: For each independent coding unit, the encoding end may further divide it into one or more non-overlapping coding units. If the independent coding unit is divided into multiple non-overlapping coding units, the division method may be horizontal equal division, vertical equal division, or horizontal and vertical equal division. Of course, the specific implementation is not shown here. The coding units in the independent coding unit may be interdependent, that is, they may refer to each other during the process of executing the prediction step.
[0100] The width of the coding unit is w_cu, and the height is h_cu. Optionally, the width is greater than the height (unless it is an edge area). Usually, the coding unit can be a fixed w_cu×h_cu, where w_cu and h_cu are both 2N powers (N is greater than or equal to 0), such as 16×4, 8×4, 16×2, 8×2, 4×2, 8×1, 4×1, etc.
[0101] The coding unit may include three components: luminance Y, chrominance Cb, and chrominance Cr (or three components: red R, green G, and blue B, or three components: luminance Y, chrominance U, and chrominance V), or only one of them. If three components are included, the sizes of the components may be exactly the same or different, depending on the image input format.
[0102] like Figure 3 , which is a schematic diagram of the correspondence between an image, a parallel coding unit, an independent coding unit, and a coding unit. Figure 3 In the description, an example is taken in which an image is divided into parallel coding unit 1 and parallel coding unit 2 according to 3:1, and an independent coding unit includes 4 coding units.
[0103] Optionally, the segmentation unit divides the image to be encoded into a plurality of image blocks, which may be further segmented into smaller blocks, such as image block segmentation based on a quadtree structure or a binary tree structure. In addition, the segmentation may also include segmentation into slices, tiles or other larger units. The slice may be divided into a plurality of image blocks (or may be divided into a set of image blocks called tiles).
[0104] The prediction processing unit 101 is used to receive or obtain the original value of the block to be encoded and the reconstructed image data, and predict the block to be encoded based on the relevant data in the reconstructed image data to obtain a predicted block of the block to be encoded.
[0105] Optionally, the prediction processing unit 101 may include an inter-frame predictor and an intra-frame predictor. The inter-frame predictor may be used to determine the inter-frame prediction mode used to encode the block to be encoded, and based on the determined inter-frame prediction mode, predict the motion information of one or more sub-blocks in the current image block, such as a motion vector (MV), and use the motion information of one or more sub-blocks in the current image block (such as a motion vector) to obtain or generate a prediction block of the current image block. The intra-frame predictor may determine the intra-frame prediction mode used to encode the block to be encoded.
[0106] Among them, intra-frame prediction refers to using the correlation of the video spatial domain to predict using the coded block (codingblock, CB) of the current block to achieve the purpose of removing video spatial redundancy. Exemplarily, intra-frame prediction specifies multiple prediction modes, each of which corresponds to a texture direction (except DC mode). For example, if the image texture is arranged horizontally, the horizontal prediction mode can better predict the image information.
[0107] Inter-frame prediction refers to the use of adjacent coded image pixels to predict the pixels of the current image based on the correlation of the video time domain. Since the video sequence contains strong temporal correlation, it can effectively remove the temporal redundancy of the video. The inter-frame prediction part of the video coding standard uses block-based motion compensation technology. The main principle is to find a best matching block in the previously coded image for each pixel block of the current image. This process is called motion estimation (ME).
[0108] In addition, in the inter-frame prediction mode, a motion vector can be used to represent the relative displacement between the current coding block and the best matching block in its reference image. Each divided block has a corresponding motion vector transmitted to the decoding end. If the motion vector of each block is independently encoded and transmitted, especially when it is divided into small-sized blocks, it will consume a considerable number of bits. In order to reduce the number of bits used to encode the motion vector, the spatial correlation between adjacent image blocks is used to predict the motion vector of the current block to be encoded based on the motion vector of the adjacent encoded block, and then the prediction difference is encoded. In this way, the number of bits representing the motion vector can be effectively reduced. In the process of encoding the motion vector of the current block, the motion vector of the adjacent encoded block is first used to predict the motion vector of the current block, and then the difference (motion vector difference, MVD) between the predicted value of the motion vector (motion vector prediction, MVP) and the true estimate of the motion vector is encoded, thereby effectively reducing the number of encoding bits of the MV.
[0109] The residual calculation unit 102 is used to calculate the residual value between the original value of the block to be encoded and the predicted block of the block to be encoded to obtain the residual block. For example, by subtracting the pixel value of the predicted block from the original pixel value of the block to be encoded pixel by pixel.
[0110] In one example, the residual transform unit 103 is used to determine the residual coefficient based on the residual block. Optionally, in this process, it can include: transforming the residual block, such as discrete cosine transform (DCT) or discrete sine transform (DST), to obtain transform coefficients in the transform domain, and the transform coefficients can also be called transform residual coefficients or residual coefficients, and the residual coefficients can represent the residual block in the transform domain. Of course, the encoder 100 may not include the step of residual transform in the process of encoding the block to be encoded.
[0111] The quantization unit 104 is used to quantize the transform coefficients or residual values by applying scalar quantization or vector quantization to obtain quantized residual coefficients (or quantized residual values). The quantization process can reduce the bit depth associated with some or all of the residual coefficients. For example, a p-bit transform coefficient can be rounded down to a q-bit transform coefficient during quantization, where p is greater than q. The degree of quantization can be modified by adjusting a quantization parameter (QP). For example, for scalar quantization, different scales can be applied to achieve finer or coarser quantization. A smaller quantization step size corresponds to finer quantization, while a larger quantization step size corresponds to coarser quantization. The appropriate quantization step size can be indicated by the QP.
[0112] Among them, in the image encoding process, in order to achieve image compression, the residual block of the block to be encoded is usually quantized, or the residual coefficient block obtained after a certain processing of the residual block is quantized, so that the quantized residual block or residual coefficient block can be encoded with fewer bits. It can be understood that the residual block is a residual value block obtained based on the original pixel block and the prediction block of the block to be encoded, and the residual coefficient block is a coefficient block obtained after a certain processing and transformation of the residual block.
[0113] As an example, taking the encoder 100 quantizing the residual block as an example, the encoder 100 can divide each residual value in the residual block of the to-be-encoded block by a quantization coefficient to reduce the residual value in the residual block. In this way, compared with the residual value that has not been quantized, the residual value that has been reduced after quantization can be encoded with fewer bits, thus achieving compression encoding of the image.
[0114] The encoding unit 105 is used to encode the above-mentioned quantized residual coefficients (or quantized residual values), and output the encoded image data (i.e., the encoding result of the current block to be encoded) in the form of an encoded bit stream (or code stream), and then the encoded bit stream can be transmitted to the decoder, or stored and subsequently transmitted to the decoder or used for retrieval. The encoding unit 105 can also be used to encode the syntax elements of the block to be encoded, such as encoding the prediction mode adopted by the block to be encoded into the code stream, etc.
[0115] In one example, the coding unit 105 encodes the residual coefficient, and a feasible method is: semi-fixed length coding. First, the maximum value of the absolute value of the residual in a residual block (RB) is defined as modifiedmaximum(mm). Determine the number of coding bits for the residual coefficient in the RB (the number of coding bits for the residual coefficient in the same RB is consistent). For example, if the CL of the current RB is 2 and the current residual coefficient is 1, then 2 bits are required to encode the residual coefficient 1, which is expressed as 01. If the CL of the previous RB is 7, it means encoding an 8-bit residual coefficient and a 1-bit sign bit. The determination of CL is to find the minimum M value that satisfies that all residuals of the current sub-block are within the range of [-2^(M-1), 2^(M-1)]. If both -2^(M-1) and 2^(M-1) exist, M should be increased by 1, that is, M+1 bits are required to encode all residuals of the current RB; if only one of the two boundary values of -2^(M-1) and 2^(M-1) exists, a Trailing bit needs to be encoded to determine whether the boundary value is -2^(M-1) or 2^(M-1); if all residuals do not exist in either -2^(M-1) or 2^(M-1), there is no need to encode the Trailing bit.
[0116] Of course, other residual coefficient encoding methods may also be used, such as an exponential Golomb encoding method, a Golomb-Rice encoding method, a truncated unary code encoding method, a run-length encoding method, directly encoding the original residual value, and the like.
[0117] In addition, for some special cases, the original value can be directly encoded instead of the residual value.
[0118] The inverse quantization unit 106 is used to inverse quantize the above-mentioned quantized residual coefficient (or quantized residual value) to obtain an inverse quantized residual coefficient (inverse quantized residual value). The inverse quantization is the reverse application of the above-mentioned quantization unit 104, for example, based on or using the same quantization step size as the quantization unit 104, applying an inverse quantization scheme of the quantization scheme applied by the quantization unit 104.
[0119] The residual inverse transform unit 107 is used to inverse transform (or inverse transform) the above-mentioned inverse quantized residual coefficients to obtain a reconstructed residual block. Optionally, the inverse transform may include an inverse discrete cosine transform (discrete cosine transform, DCT) or an inverse discrete sine transform (discrete sine transform, DST). In this way, the inverse transform value obtained after the inverse transform (or inverse transform) of the above-mentioned inverse quantized residual coefficients is the residual value reconstructed in the pixel domain (or sample domain). That is, after the inverse quantized residual coefficient block is inversely transformed by the residual inverse transform unit 107, the block obtained is the reconstructed residual block. Of course, when the above-mentioned residual change unit 103 is not included in the encoder 100, the encoder 100 may also not include the inverse transform step.
[0120] The reconstruction unit 108 is used to add the reconstructed residual block to the prediction block to obtain a reconstructed block in the sample domain. The reconstruction unit 108 can be a summer. For example, the reconstruction unit 108 adds the residual value in the reconstructed residual block to the prediction value of the corresponding pixel in the prediction block to obtain the reconstructed value of the corresponding pixel. The reconstructed block output by the reconstruction unit 108 can be subsequently used to predict other image blocks to be encoded.
[0121] The filter unit 109 (or simply “filter”) is used to filter the reconstructed block to obtain a filtered block, so as to smoothly perform pixel conversion or improve image quality.
[0122] In one example, an encoding process implemented by the encoder 100 may include the following steps:
[0123] Step 21: The prediction processing unit 101 determines a prediction mode, and predicts the block to be encoded based on the determined prediction mode and the reconstructed block of the encoded image block to obtain a prediction block of the block to be encoded.
[0124] The reconstructed block of the encoded image block is obtained after the inverse quantization unit 106, the residual inverse transformation unit 107 and the reconstruction unit 108 sequentially process the quantized residual coefficient block of the encoded image block.
[0125] Step 22: The residual calculation unit 102 obtains a residual block of the block to be encoded based on the original pixel values of the prediction block and the block to be encoded;
[0126] Step 23: The residual transform unit 103 transforms the residual block to obtain a residual coefficient block.
[0127] Step 24: The quantization unit 104 quantizes the residual coefficient block to obtain a quantized residual coefficient block.
[0128] Step 25: The encoding unit 105 encodes the quantized residual coefficient block and encodes related syntax elements (such as prediction mode, encoding mode) to obtain a code stream of the block to be encoded.
[0129] See also Figure 4 , Figure 4 A schematic block diagram of an example of a decoder 200 for implementing the method of an embodiment of the present application is shown. The decoder 200 is used to receive image data (i.e., an encoded bit stream, e.g., an encoded bit stream including an image block and associated syntax elements) encoded by the encoder 200 to obtain a decoded image block.
[0130] like Figure 4 As shown, the decoder 200 includes a code stream parsing unit 201, a dequantization unit 202, a residual inverse transform unit 203, a prediction processing unit 204, a reconstruction unit 205, and a filter unit 206. In some examples, the decoder 200 may perform substantially the same Figure 2 The encoding process described by encoder 100 is the inverse of the decoding process.
[0131] The code stream parsing unit 201 is used to decode the encoded bit stream to obtain quantized residual coefficients (or quantized residual values) and / or decoding parameters (for example, the decoding parameters may include any one or all of the inter-frame prediction parameters, intra-frame prediction parameters, filter parameters and / or other syntax elements performed by the encoding side). The code stream parsing unit 201 is also used to forward the above-mentioned decoding parameters to the prediction processing unit 204, so that the prediction processing unit 204 performs a prediction process according to the decoding parameters.
[0132] The function of the inverse quantization unit 202 may be the same as that of the inverse quantization unit 106 of the encoder 100 , and is used to inverse quantize (ie, inverse quantize) the quantized residual coefficients decoded and output by the bitstream parsing unit 201 .
[0133] Among them, inverse quantization is the reverse process of quantization, and inverse quantization refers to mapping the quantized coefficients into a reconstructed signal in the input signal space, and the reconstructed signal is an approximation of the input signal. In order to reconstruct the image block from the compressed and encoded bitstream, the inverse quantization unit 202 of the decoder 200 can inverse quantize the residual block or residual coefficient block parsed from the bitstream, so as to reconstruct the unquantized residual block or residual coefficient block corresponding to the image block, and then, the decoder 200 reconstructs the image block according to the reconstructed residual block or residual coefficient block, so as to obtain the reconstructed block of the image.
[0134] As an example, taking the residual block after the decoder 200 parses the to-be-decoded block from the bitstream and quantizes it as an example, the decoder 200 can dequantize the residual block through the dequantization unit 202. Specifically, the encoding end can multiply each residual value in the parsed residual block by a quantization coefficient to reconstruct the residual value in the unquantized residual block corresponding to the to-be-decoded block, thereby obtaining a reconstructed residual block. Among them, the quantization coefficient is the quantization coefficient when the encoding device quantizes the residual block of the to-be-decoded block when encoding the to-be-decoded block. In this way, the decoder 200 can realize the reconstruction of the to-be-decoded block based on the residual block reconstructed after dequantization, and obtain the reconstructed block of the to-be-decoded block.
[0135] The function of the residual inverse transform unit 203 may be the same as that of the residual inverse transform unit 107 of the encoder 100, and is used to perform an inverse transform (e.g., an inverse DCT, an inverse integer transform, or a conceptually similar inverse transform process) on the above-mentioned dequantized residual coefficients to obtain a reconstructed residual value. The block obtained by the inverse transform is the residual block of the reconstructed block to be decoded in the pixel domain.
[0136] The function of the reconstruction unit 205 (eg, a summer) may be the same as that of the reconstruction unit 108 of the encoder 100 .
[0137] The prediction processing unit 204 is used to receive or obtain the encoded image data (for example, the encoded bit stream of the current image block) and the reconstructed image data. The prediction processing unit 204 can also receive or obtain relevant parameters of the prediction mode and / or information about the selected prediction mode (that is, the above-mentioned decoding parameters) from, for example, the bit stream parsing unit 202, and predict the current image block based on the relevant data and decoding parameters in the reconstructed image data to obtain a prediction block of the current image block.
[0138] The reconstruction unit 205 is used to add the reconstructed residual block to the prediction block to obtain a reconstructed block of the image to be decoded in the sample domain, for example, adding the residual value in the reconstructed residual block to the prediction value in the prediction block.
[0139] The filter unit 206 is configured to filter the reconstructed block to obtain a filtered block, where the filtered block is a decoded image block.
[0140] Specifically, in the embodiment of the present application, the decoder 200 is used to implement the decoding method described in the embodiments below.
[0141] It should be understood that in the encoder 100 and decoder 200 of the embodiment of the present application, the processing result of a certain link can also be output to the next link after further processing. For example, after the interpolation filtering, motion vector derivation or filtering links, the processing results of the corresponding links are further subjected to operations such as Clip or shift.
[0142] In an example, a decoding process implemented by the decoder 200 may include the following steps:
[0143] Step 31: The code stream parsing unit 201 parses the prediction mode and the residual coding mode;
[0144] Step 32: The code stream parsing unit 201 parses quantization related values (such as near values, or QP values, etc.) based on the prediction mode and the residual coding mode;
[0145] Step 33: The inverse quantization unit 202 analyzes the residual coefficients based on the prediction mode and the quantization correlation value;
[0146] Step 34: The prediction processing unit 204 obtains the prediction value of each pixel of the current image block based on the prediction mode;
[0147] Step 35: The residual value decoding unit 203 inversely transforms the residual coefficients to reconstruct the residual values of each pixel of the current image block;
[0148] Step 36: The reconstruction unit 205 obtains the reconstructed value of each pixel in the current coding unit based on the predicted value and residual value of each pixel.
[0149] Figure 1 to Figure 4 These are merely examples provided for the embodiments of the present application. In some examples, the encoder 100, the decoder 200, and the encoding and decoding system 1 may include more or fewer components or units, and the present application does not limit this.
[0150] The following image encoding and decoding method provided in the embodiment of the present application is described in conjunction with the accompanying drawings.
[0151] Figure 5 The following is a flow chart of an image encoding method provided by the present application. Optionally, the image encoding method can be applied to Figure 1 In the coding and decoding system 1 shown, the image coding method can be executed by the coding end 10. Specifically, the coding method can be executed by the encoder 100 included in the coding end 10. Figure 5 As shown, the image encoding method provided in the embodiment of the present application includes the following steps:
[0152] S101. The encoding end obtains the maximum code length of the block to be encoded.
[0153] The block to be encoded may be referred to as an encoding unit. Generally, when encoding an image frame in a video to be encoded, the encoding end encodes the image frame in the encoding unit.
[0154] In addition, the above maximum code length is used to indicate the maximum code length that can be encoded for the block to be encoded. It should be understood that in order to prevent the code stream from overflowing, the maximum code length can be based on Figure 1The size of the storage space of the code stream buffer at the decoding end in the coding and decoding system shown is determined. Therefore, the maximum code length is the maximum code stream length currently allowed to be cached by the storage space used by the coding end to cache the encoded code stream.
[0155] Optionally, the maximum code length is the sum of the length of the code stream that can be accommodated in the remaining space of the storage space and the length of the code stream output by the storage space in a unit time.
[0156] Optionally, the maximum code length is a code length value that is smaller than the sum of the length of the code stream that can be accommodated in the remaining space of the storage space and the length of the code stream output by the storage space in a unit time.
[0157] Exemplarily, the maximum code length may be the sum of the length of the code stream that can be accommodated in the remaining space of the storage space and the length of the code stream output by the storage space in a unit time minus the header information of the block to be encoded. The header information is data of a certain length at the front end of the code stream of each block to be encoded, and the data may be used to indicate the image parameters of the current block to be encoded. Exemplarily, the image parameters include one or more of the image complexity, prediction mode, target pixel depth, and texture complexity of the current block to be encoded.
[0158] It should be noted that, since the code stream buffer outputs a certain amount of code stream to the channel while receiving the code stream of the current block encoded by the encoder, that is, when the code stream buffer receives the code stream of the current block, it also flows out a certain amount of code stream. In other words, the code stream input to the code stream buffer can also occupy the storage space occupied by the outgoing code stream. Therefore, the maximum code length can be the sum of the code length flowing out of the code stream buffer in a unit time and the code length that can be accommodated in the current remaining space of the code stream buffer.
[0159] In addition, the length of the code flowing out of the code stream buffer within a unit time can be determined according to the width of the channel through which the encoding end transmits the code stream after encoding.
[0160] S102: The encoding end pre-encodes the block to be encoded based on the first mode to obtain a first code length of the block to be encoded.
[0161] The first mode may be a prediction mode preset by the encoding end.
[0162] Optionally, the prediction mode preset by the encoding end may include a point-by-point prediction mode, an intra-frame prediction mode, a block copy mode, an original value mode, and the like.
[0163] Among them, the intra-frame prediction mode is a prediction mode that uses the reconstructed values of pixels in the neighboring blocks around the block to be predicted as the prediction value. The block copy prediction mode is a prediction mode that uses the reconstructed values of pixels in the surrounding encoded (decoded) blocks (not necessarily adjacent) as the prediction value. During reconstruction, the original value mode is a reconstructed value mode that directly decodes a fixed bit width, that is, a prediction mode without reference. The point-by-point prediction mode refers to a prediction mode that uses the reconstructed values of the neighboring pixels around the pixel to be predicted as the prediction value of the pixel to be predicted.
[0164] The point-by-point prediction mode may include a combination of one or more prediction modes such as vertical prediction, horizontal prediction, vertical mean prediction and horizontal mean prediction.
[0165] Vertical prediction is to obtain the predicted value (PointPredData) of the pixel to be predicted by using the reconstructed value of the pixel on the upper side of the pixel to be predicted (either the adjacent upper side or the non-adjacent but closer upper side). Horizontal prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed value of the pixel on the left side of the pixel to be predicted (either the adjacent left side or the non-adjacent but closer left side). Vertical mean prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed values of the pixels above and below the pixel to be predicted. Horizontal mean prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed values of the pixels on the left and right sides of the pixel to be predicted.
[0166] Specifically, the encoder can predict the blocks to be encoded respectively by using the above preset different prediction modes, and determine the first mode based on the encoding performance after predicting the blocks to be encoded by the different prediction modes. The encoding performance can be compression rate, encoding efficiency or encoding loss rate, etc.
[0167] Exemplarily, the encoder can predict the blocks to be encoded respectively by using different prediction modes, and after obtaining the prediction blocks based on the different prediction modes, the encoder performs steps 22 to 25 described above to obtain the bitstreams of the blocks to be encoded under the different prediction modes. The encoder determines the time to obtain the bitstreams of the blocks to be encoded under the different prediction modes, and determines the prediction mode with the shortest time as the first mode. That is, the encoder can determine the prediction mode with the highest encoding efficiency as the first mode.
[0168] Therefore, the first code length is the length of the code stream based on the block to be encoded in the first mode obtained by the encoder by predicting the block to be encoded by adopting the first mode and executing steps 22 to 25 described above after obtaining the predicted block.
[0169] S103. When the first code length is greater than or equal to the maximum code length, the encoding end adopts a fallback mode to encode the block to be encoded, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length.
[0170] The fallback mode is used to encode the block to be coded, that is, based on a predetermined target code length, a fixed code length encoding method is used to encode the block to be coded, and the code length obtained by encoding the block to be coded is the target code length. The target code length is less than the maximum code length.
[0171] It should be noted that the storage space of the code stream buffer is of a certain size. If the code stream data input to the code stream buffer is too large, resulting in the data that needs to be temporarily stored in the code stream buffer exceeding the size of its storage space, the code stream will "overflow". This will cause the excess data to be lost, and thus the image information in the image frame of the video to be encoded will be lost, and the image frame cannot be completely parsed based on the code stream data output by the code stream buffer.
[0172] If the first code length is greater than or equal to the above maximum code length, that is, when the code stream of the block to be encoded obtained based on the first mode is transmitted through the code stream buffer, the code stream buffer will have a code stream "overflow". Therefore, in order to avoid the code stream "overflow", the encoder can use the fallback mode to encode the block to be encoded so that the code length obtained by encoding the block to be encoded is less than the maximum code length.
[0173] In some embodiments, if the current block to be encoded is encoded in a fallback mode, since the target code length of the block to be encoded is fixed, the complexity information in the header information of the block to be encoded is not updated. The complexity information can be used to calculate the quantization parameter of the block to be encoded.
[0174] In some embodiments, the encoding end may select the midpoint prediction fallback mode (MPPF Mode) to predict the block to be encoded, and after obtaining the predicted block, encode the block to be encoded based on a fixed code length encoding method to obtain a code stream of the block to be encoded.
[0175] According to the midpoint prediction fallback mode, the encoder can first divide the block to be encoded into multiple 2x2 pixel sub-image blocks, and each 2x2 sub-image block needs to calculate a median. The calculation method of the median middle is as follows: Formula (1).
[0176] middle=1<<(bitDepth–1) formula (1)
[0177] Among them, bitDepth is the bit depth of the code stream transmission channel of the current sub-block to be decoded, and 1<< means shifting left by one bit.
[0178] Furthermore, the encoding end may determine the mean of the sub-block to be encoded.
[0179] In one case, if the current sub-block cannot obtain the surrounding reconstructed image, the mean value is the above-mentioned middle value.
[0180] In another case, the mean value is the mean of the sub-block reconstruction values of the previous row of 2x1 pixels of the sub-block. If the sub-block reconstruction value of the previous row of 2x1 pixels cannot be obtained, the mean of the previous reconstructed 2x2 sub-block reconstructed image of the sub-block is taken.
[0181] Then, the encoder can determine the bias value of the sub-block, and the bias value is used to limit the value of the mean value. The encoder can use the bias value and the middle value to clamp the mean value to limit the mean value to the value range composed of the bias value and the middle value. Thus, the mean value adjusted by the bias value and the middle value is determined as the predicted value of the current 2x2 pixel point to be encoded sub-block.
[0182] The bias value can be determined according to the following formula (2).
[0183] bias=1<<(mppStepSize[k]–1) Formula (2)
[0184] Among them, mppStepSize is used to indicate the quantization step size in the quantization process of a component of the block to be encoded, [k] is used to indicate the [k]th component of the block to be encoded, and 1<< indicates a left shift by one bit.
[0185] In addition, based on MPPF Mode, such as Figure 6 As shown, the residual value of the 2x2 pixel sub-block can be calculated based on the order of the upper left pixel A, the upper right pixel B, the lower left pixel C, and the lower right pixel D.
[0186] Optionally, in the process of reconstructing the sub-block to be encoded, the reconstruction value of each pixel point may be determined in sequence according to the order of the upper left pixel point A, the upper right pixel point B, the lower left pixel point C, and the lower right pixel point D.
[0187] In some embodiments, a block to be encoded may include one or more components.
[0188] Optionally, the block to be encoded may include only the brightness component. Alternatively, the block to be encoded may include three components, such as brightness Y, chroma Cb, and chroma Cr (or red R, green G, and blue B, or brightness Y, chroma U, and chroma V). Alternatively, on the basis of the above three components, the block to be encoded may also include an α component, that is, the block to be encoded includes a total of four components. Among them, the α component is the pixel transparency component. When the component α value is 0, the pixel corresponding to the coding block is transparent, and the image bit width of the α component is different from the other three components.
[0189] In some embodiments, the encoding end may determine the maximum code length that can be encoded for each component, and then determine whether each component adopts the fallback mode according to the determined maximum code length.
[0190] Optionally, if the block to be encoded includes three components, namely, a first chrominance component, a second chrominance component, and a luminance component, the first chrominance component, the second chrominance component, and the luminance component may be three components, namely, luminance Y, chrominance Cb, and chrominance Cr, or three components, namely, luminance Y, chrominance U, and chrominance V.
[0191] Thus, the encoding end can specifically determine whether each of the three components, namely, the first chrominance component, the second chrominance component and the luminance component, needs to be encoded in the fallback mode.
[0192] In some embodiments, the encoding end may determine the first chroma maximum code length, the second chroma maximum code length, and the luminance maximum code length according to the maximum code length and a preset ratio.
[0193] Among them, the first chroma maximum code length is the maximum code length that can be encoded for the first chroma component of the block to be encoded. The second chroma maximum code length is the maximum code length that can be encoded for the second chroma component of the block to be encoded. The luminance maximum code length is the maximum code length that can be encoded for the luminance component of the block to be encoded. It should be understood that the sum of the first chroma maximum code length, the second chroma maximum code length and the luminance component should not exceed the maximum code length that can be encoded for the block to be encoded.
[0194] Among them, the sum of the first chromaticity maximum code length, the second chromaticity maximum code length and the third chromaticity maximum code length is the maximum code length or the code length flowing out of the storage space in unit time.
[0195] It should be noted that the code length flowing out of the code stream buffer in a unit time is less than the above-mentioned maximum code length. Therefore, the sum of the first chroma maximum code length, the second chroma maximum code length and the brightness maximum code length can be the code length flowing out of the storage space in a unit time. In addition, the first chroma maximum code length, the second chroma maximum code length and the brightness maximum code length are determined according to the code length flowing out of the storage space in a unit time, so that the encoding code length of the block to be encoded can be smaller, the compression rate is higher, and the memory occupied by it in the code stream buffer is smaller.
[0196] Optionally, a preset ratio of the first chroma maximum code length: the second chroma maximum code length: the luminance maximum code length may be 1:1:1, 2:1:1 or 4:1:1.
[0197] In some embodiments, if the block to be encoded includes multiple components, the multiple components of the block to be encoded share a fallback mode (sharing means that the multiple components all adopt the fallback mode or none of them adopt the fallback mode), so that the encoder can only determine whether one of the components adopts the fallback mode. When one of the components adopts the fallback mode, the other components also adopt the fallback mode. Alternatively, some of the multiple components of the block to be encoded share the fallback mode, then the encoder can only determine whether one of the components adopts the fallback mode, and whether the other components except the part adopt the fallback mode. Alternatively, the multiple components of the block to be encoded do not share the fallback mode, so that the encoder can determine whether each component adopts the fallback mode separately.
[0198] Optionally, the encoding end may determine whether to use the fallback mode to encode the first chroma component, the second chroma component, and the luminance component according to one or more of the first chroma maximum code length, the second chroma maximum code length, and the luminance maximum code length. Several possible implementations are shown below:
[0199] Implementation method 1: The encoding end determines whether to use the fallback mode to encode the first chroma component, the second chroma component and the luminance component according to any one of the first chroma maximum code length, the second chroma maximum code length and the luminance maximum code length.
[0200] Optionally, the encoding end may first determine whether any one of the first chroma component, the second chroma component and the luminance component is encoded in the fallback mode, and then, when determining that the component is encoded in the fallback mode, determine that the other two components are also encoded in the fallback mode.
[0201] Exemplarily, the encoding end may first determine whether the first chroma component is encoded in the fallback mode according to the first chroma maximum code length, and then, when determining that the first chroma component is encoded in the fallback mode, further determine that the second chroma component and the luminance component are also encoded in the fallback mode.
[0202] Similarly, the encoding end may first determine whether the second chroma component is encoded in the fallback mode according to the second chroma maximum code length, or determine whether the luminance component is encoded in the fallback mode according to the luminance maximum code length, which will not be listed one by one.
[0203] Optionally, the process in which the encoder determines whether to use the fallback mode to encode the first chroma component according to the first chroma maximum code length may specifically include: the encoder pre-encodes the first chroma component based on the first mode to obtain a first chroma code length of the first chroma component. Furthermore, when the first chroma code length is greater than or equal to the first chroma maximum code length, it is determined to use the fallback mode to encode the first chroma component.
[0204] Similarly, the process in which the encoder determines whether to use the fallback mode to encode the second chroma component according to the second chroma maximum code length may specifically include: the encoder pre-encodes the second chroma component based on the first mode to obtain the second chroma code length of the second chroma component. Furthermore, when the second chroma code length is greater than or equal to the second chroma maximum code length, it is determined to use the fallback mode to encode the second chroma component.
[0205] Similarly, the process of determining whether the luminance component is encoded in the fallback mode according to the maximum luminance code length by the encoder may specifically include: the encoder pre-encodes the luminance component based on the first mode to obtain the luminance code length of the luminance component. Further, when the luminance code length is greater than or equal to the maximum luminance code length, it is determined to encode the luminance component in the fallback mode.
[0206] The process of pre-encoding the first chrominance component, the second chrominance component or the luminance component based on the first mode may refer to the relevant description of pre-encoding based on the first mode in step S102, which will not be repeated here.
[0207] Implementation method 2: The encoding end determines whether the first chroma component and the second chroma component are encoded in a fallback mode according to the first chroma maximum code length or the second chroma maximum code length, and determines whether the luminance component is encoded in a fallback mode according to the luminance maximum code length.
[0208] Optionally, for the first chroma component and the second chroma component, the encoding end may first determine whether the first chroma component is encoded in the fallback mode, and then when it is determined that the first chroma component is encoded in the fallback mode, determine that the second chroma component is also encoded in the fallback mode. Alternatively, the encoding end may first determine whether the second chroma component is encoded in the fallback mode, and then when it is determined that the second chroma component is encoded in the fallback mode, determine that the first chroma component is also encoded in the fallback mode.
[0209] Among them, the process in which the encoding end determines whether the first chroma component is encoded in the fallback mode according to the first chroma maximum code length, and the encoding end determines whether the second chroma component is encoded in the fallback mode according to the second chroma maximum code length can specifically refer to the relevant description in the above-mentioned implementation method 1.
[0210] In a possible implementation, for the luminance component, the encoder may determine whether the luminance component is encoded in the fallback mode according to the maximum luminance code length. The process of determining whether the luminance component is encoded in the fallback mode according to the maximum luminance code length may refer to the relevant description in the above implementation 1 for details.
[0211] In another possible implementation, for the luminance component, when the encoding end determines whether the first chrominance component and the second chrominance component are encoded in the fallback mode, the encoding end may determine the code length of the first chrominance component and the second chrominance component encoded in the fallback mode, and pre-encode the luminance component based on the first mode to obtain the luminance code length of the luminance component. Further, when the sum of the luminance code length and the code length of the first chrominance component and the second chrominance component encoded in the fallback mode is greater than or equal to the maximum code length of the block to be encoded, the encoding end determines that the luminance component is encoded in the fallback mode.
[0212] Implementation method 3: The encoding end determines whether the first chroma component is encoded in the fallback mode according to the first chroma maximum code length, determines whether the second chroma component is encoded in the fallback mode according to the second chroma maximum code length, and determines whether the luminance component is encoded in the fallback mode according to the luminance maximum code length.
[0213] Among them, the process in which the encoding end determines whether the first chroma component is encoded in the fallback mode according to the first chroma maximum code length, the encoding end determines whether the second chroma component is encoded in the fallback mode according to the second chroma maximum code length, and the encoding end determines whether the luminance component is encoded in the fallback mode according to the luminance maximum code length can be specifically referred to the relevant description in the above-mentioned implementation method 1.
[0214] In some embodiments, when the block to be encoded includes three components, namely, a first chroma component, a second chroma component, and a luminance component, the encoding end may divide the target code length of the block to be encoded into three sub-code lengths according to the preset ratio, wherein one component corresponds to one sub-code length. Then, based on the sub-code lengths of each component, the fallback mode is used to encode the components corresponding to each sub-code length.
[0215] Optionally, for a block to be encoded in a YCoCg image, the Y component: Co component: Cg component may be 2:1:1. For a block to be encoded in a YUV444 image, the Y component: U component: V component may be 2:1:1. For a block to be encoded in a YUV422 image, the Y component: U component: V component may be 2:1:1. For a block to be encoded in a YUV420 image, the Y component: U component: V component may be 4:1:1. For a block to be encoded in a YUV400 image, the block to be encoded includes only a luminance component.
[0216] Optionally, for a block to be encoded in an RGB image, the encoder may divide the target code length of the block to be encoded into three sub-code lengths according to a 1:1:1 ratio of R component: G component: B component, with one component corresponding to one sub-code length.
[0217] It should be noted that, during the encoding process, for image blocks in RGB format, since the human eye is more sensitive to image brightness, in order to improve the image effect viewed by the human eye, the image blocks in RGB format are usually converted into YCoCg format image blocks before encoding. However, if the encoding end determines that each component of the converted YCoCg format image block needs to adopt a fallback mode during the encoding process, indicating that the code length required for encoding the converted YCoCg format image block is longer, the encoding end can encode the image block in RGB format. In some embodiments, for the component that selects the fallback mode, since the sub-code length of the component is determined, there is no need to not update the quantization parameter in the header information of the current component, and there is no need to update the complexity of the current component and other information used for the code stream of the indicating component.
[0218] In some embodiments, when the first code length is less than the maximum code length, the encoding end may use the original value mode to encode the original pixel value of the block to be encoded. Optionally, the encoding end may use the original value mode to encode the quantized and transformed value of the original pixel value of the block to be encoded. In this way, the encoding end can improve the effect of reconstructing the image of the block to be encoded by encoding the block to be encoded in the original value mode.
[0219] In some embodiments, when the first code length is less than the maximum code length, the encoding end may also adopt the residual coding mode to encode the block to be encoded.
[0220] In one example, the codeword of the original value mode and the codeword of the fallback mode are the same, wherein the codeword of the original value mode is reference data used to indicate the original value mode, and the codeword of the fallback mode is reference data used to indicate the fallback mode.
[0221] In another example, the codeword of the fallback mode is unique. It should be understood that the codeword of the original mode and the codeword of the fallback mode are different.
[0222] In some embodiments, the above fallback mode may also be used when the to-be-encoded block does not overflow (that is, the encoder uses the fallback mode for the second time when the first code length is less than the maximum code length). This situation is described below:
[0223] Optionally, when the occupied memory in the code stream buffer is less than or equal to the first threshold of the total memory of the code stream buffer, the encoding end may use other code length values greater than the target code length to encode the block to be encoded. Exemplarily, the first threshold may be 30% of the total memory of the code stream buffer. Thus, the encoding end may use a code length value greater than 1.5 times the target code length to encode the block to be encoded. Optionally, when the occupied memory in the code stream buffer is greater than or equal to the second threshold of the total memory of the code stream buffer, the encoding end may use other code length values less than the target code length to encode the block to be encoded. Exemplarily, the second threshold may be 85% of the total memory of the code stream buffer. Thus, the encoding end may use a code length value greater than 0.5 times the target code length to encode the block to be encoded. The encoding end may also use the target code length to encode the block to be encoded when the occupied memory in the code stream buffer is less than the second threshold of the total memory of the code stream buffer but greater than the first threshold.
[0224] Accordingly, when the decoding end uses the fallback mode for encoding when the code stream buffer does not overflow, the decoding end can determine the code length of the block to be decoded based on the size of the memory occupied by the encoded block in the code stream buffer. The image encoding method provided by the embodiment of the present application has at least the following beneficial effects: the method can first pre-encode the block to be encoded, compare the code stream length obtained based on the pre-encoding with the maximum code length allowed to be occupied by the block to be encoded, and determine whether a code stream overflow will occur based on the comparison result. Furthermore, when it is determined that a code stream overflow will occur, the fallback mode is used to encode the block to be encoded to avoid the loss of image information of the block to be encoded.
[0225] In some embodiments, Figure 7 As shown, the process of encoding the coding block by the encoder according to the fallback mode and based on the fixed code length coding method can be specifically implemented as the following steps:
[0226] S201: The encoding end divides a block to be encoded into one or more sub-blocks to be encoded.
[0227] Optionally, in the process of encoding the block to be encoded based on the fallback mode, a fixed code length encoding method is usually used to determine each sub-block to be encoded of the block to be encoded for encoding.
[0228] Optionally, the fixed code length and the number of sub-blocks to be encoded in the block to be encoded satisfy the following formula (3):
[0229] subblock num × fixed len ≤ fixed bit Formula (3)
[0230] Among them, subblock numis the number of sub-blocks to be encoded in the block to be encoded. fixed len is a fixed code length. bit is the target code length of the block to be encoded.
[0231] Optionally, the target code length of the block to be encoded may be determined according to a target pixel depth (bits perpixel, BPP) of the block to be encoded.
[0232] The target pixel depth is used to indicate the code length required when encoding each pixel of the block to be encoded at a target compression rate. The target pixel depth can be determined according to the target compression ratio of the block to be encoded.
[0233] Optionally, the encoding end may obtain a target pixel depth of the block to be encoded, and then, based on the target pixel depth and the number of pixels of the block to be encoded, determine the target code length of the block to be encoded by multiplying the target pixel depth by the number of pixels of the block to be encoded.
[0234] Optionally, the target code length may also be smaller than the product of the target pixel depth and the number of pixels of the to-be-encoded block.
[0235] Exemplarily, the target code length may be the product of the target pixel depth and the number of pixels of the block to be encoded minus the encoding cost required for the encoding fallback mode. The parsed result of the encoding cost is used to indicate that the encoding mode is the fallback mode. For example, the parsed result of the encoding cost may be an identifier of the fallback mode (codeword of the fallback mode), etc.
[0236] In some embodiments, when the block to be encoded includes multiple components, the encoding end may first divide the block to be encoded into multiple components, and then divide each component into one or more sub-blocks to be encoded.
[0237] Exemplarily, according to the relevant description in the above step S103, when the block to be encoded may include three components, namely, a first chroma component, a second chroma component, and a luminance component, the encoding end may divide the target code length of the block to be encoded into three sub-code lengths according to a preset ratio, wherein one component corresponds to one sub-code length. Furthermore, the encoding end may divide the component into one or more sub-coding blocks based on the sub-code length corresponding to each component.
[0238] Taking the preset ratio of Y component: Co component: Cg component as 2:1:1 as an example, the subcode length of the Co component can be determined according to the following formula (4):
[0239]
[0240] The subcode length of the Cg component and the subcode length of the Co component account for the same proportion in the target code length. The subcode length of the Cg component can also be determined according to formula (4).
[0241] Furthermore, the subcode length of the Y component can be the target code length minus the subcode length of the Co component and the subcode length of the Cg component.
[0242] In some other embodiments, when the block to be encoded includes multiple components, the encoding end may first divide the block to be encoded into one or more sub-coding blocks, and then, for each sub-coding block, further divide the sub-coding block into sub-blocks of each component according to the ratio of each component.
[0243] The following takes the division of a block to be coded into one or more sub-coding blocks as an example to illustrate the division process of the sub-coding blocks:
[0244] In a possible implementation manner, the encoding end divides the block to be encoded into one or more sub-blocks to be encoded according to a preset size.
[0245] The fixed size of the sub-block to be encoded may be 2x1 pixels, 2x2 pixels, or the like.
[0246] Specifically, the encoding end may determine the number of sub-blocks to be encoded in the block to be encoded according to the size of the sub-block to be encoded; and divide the block to be encoded into one or more sub-blocks to be encoded based on the number of sub-blocks to be encoded.
[0247] For example, the block to be encoded is Figure 8 As shown, it includes two rows of pixels A1 to A16 and B1 to B16. If the size of a sub-block to be encoded is 2x2 pixels, the encoder can determine that the number of sub-blocks to be encoded is 8. For example, the sub-block to be encoded can be an image block composed of A1, A2, B1 and B2, an image block composed of A3, A4, B3 and B4, etc.
[0248] Optionally, after determining the number of sub-blocks to be encoded, the encoding end may determine a first fixed code length for encoding the sub-blocks to be encoded based on the above formula (3).
[0249] In another possible implementation manner, the encoding end divides the to-be-encoded block into one or more to-be-encoded sub-blocks with a preset first fixed code length.
[0250] Optionally, the first fixed code length may be a preset code length value used to encode the sub-block to be encoded.
[0251] Optionally, when the sub-block to be encoded includes only one pixel, the first fixed code length may be the above target pixel depth.
[0252] Specifically, the encoding end may determine the number of sub-blocks to be encoded of the block to be encoded based on the above formula (3) according to the target code length of the block to be encoded and the first fixed code length used to encode the sub-block to be encoded. Further, based on the number of sub-blocks to be encoded, the block to be encoded is divided into one or more sub-blocks to be encoded.
[0253] Optionally, according to the above formula (3), the number of sub-blocks to be encoded can be obtained by dividing the target code length of the block to be encoded by the first fixed code length and then rounding down to an integer value.
[0254] For example, if the size of the block to be encoded is 16x2 pixels, the first fixed code length is 4, and the target code length of the block to be encoded is 23. The first fixed code length is 23 / 4, which is rounded down to an integer value of 5, and the number of sub-blocks is an odd number, then 16x2 is divided into 5 sub-blocks to be encoded, and the sizes of the sub-blocks to be encoded are 3x2 pixels, 3x2 pixels, 3x2 pixels, 3x2 pixels, and 4x2 pixels, respectively.
[0255] If the size of the block to be encoded is 16x2 pixels, the first fixed code length is 4, and the target code length of the block to be encoded is 25. Therefore, according to the above formula (3), the number of sub-blocks to be encoded is 6, which is an integer value obtained by rounding down 25 / 4. If the number of sub-blocks is an even number, the 16x2 image block can be first divided into two 16x1 pixel image blocks, and each 16x1 pixel image block can be divided into 5x1 pixel, 5x1 pixel image blocks, and 6x1 pixel image blocks.
[0256] It should be noted that, since the predicted value of the sub-block to be encoded can be determined by the reconstructed pixel points in the previous row,
[0257] Therefore, when the sub-block to be encoded includes two rows of pixels, the encoding end can control the number of divisions of the sub-block to be encoded to be an even number to ensure that each encoding sub-block includes the first row of pixels of the encoding block. In this way, the prediction value of the first row of pixels can be determined based on the reconstructed pixels of the previous row, so that the prediction value of the second row of pixels of the sub-block to be encoded can be determined based on the reconstructed pixels of the first row. It should be understood that if the sub-block to be encoded includes Z rows of pixels, the encoding end can control the number of divisions of the sub-block to be encoded to be an integer multiple of Z to ensure that each encoding sub-block includes the first row of pixels of the encoding block.
[0258] Optionally, the first fixed code length is a non-negative integer. Taking the first fixed code length as the target pixel depth as an example, if the block to be encoded is a 16x2 pixel image block, the encoder divides it into 2 16x1 pixel image blocks of sub-blocks to be encoded. In one example, if the target pixel depth is 3, the first fixed code lengths of the two 16x1 pixel image blocks are both 3. In another example, if the target pixel depth is 2.5, the encoder can determine that the first fixed code length of the first sub-block to be encoded is 3, and the first fixed code length of the second sub-block is 2.
[0259] S202: The encoding end encodes a plurality of to-be-encoded sub-blocks by adopting a fixed code length encoding method based on a first fixed code length.
[0260] The length of a code stream obtained by encoding each of the multiple sub-blocks to be encoded is a first fixed code length.
[0261] For any sub-block to be encoded, the encoding end determines the original value and the predicted value of the pixel point of the sub-block to be encoded.
[0262] In some embodiments, the encoding end may determine an average value of reconstructed values of a previous row of pixels adjacent to the sub-block to be encoded as the predicted value of the sub-block to be encoded.
[0263] Optionally, the predicted value of a pixel in the to-be-encoded sub-block may be determined according to the following formula (5):
[0264] Prediction value = (sum of the reconstructed values of each reference pixel + 0.5 × S) / S Formula (5)
[0265] Wherein, S is the number of reference pixels and S is a positive integer.
[0266] It should be noted that, in the process of calculating the prediction value, the sum of the reconstructed values of each reference pixel point is added with 0.5×S in order to round off the average value of the reconstructed value.
[0267] For example, if the current coding block is Fig. 9 As shown in (a), the size of the block to be encoded is 16x2 pixels, including two rows of pixels A1 to A16 and B1 to B16, and the reconstructed pixels in the previous row include C0 to C16. If the sub-block to be encoded is an image block composed of A1, A2, A3, B1, B2 and B3, the pixels corresponding to the previous row of reference of the sub-block to be encoded are C1, C2 and C3, so the predicted value of the sub-block to be encoded is (reconstructed value of C1 + reconstructed value of C2 + reconstructed value of C3 + 1.5) / 3.
[0268] Optionally, if the reconstructed values of the previous row of pixels of the sub-block to be encoded are not available, the encoder may fill the previous row of pixels of the sub-block to be encoded with the reconstructed pixels of the previous column. Fig. 9 As shown in (b), the encoder uses the reconstructed value of the pixel point A0 in the previous column to fill all the pixels in the previous row. Therefore, if the sub-block to be encoded is an image block composed of A1, A2, A3, B1, B2 and B3, the pixel points of the reference in the previous row corresponding to the sub-block to be encoded are three reconstructed values of A0. Then, the encoder can determine the predicted value of the sub-block to be encoded based on the three reconstructed values of A0.
[0269] Or, if Fig. 9 As shown in (c) in the figure, the encoder uses the reconstructed value of the pixel B0 in the previous column to fill all the pixels in the previous row. Similarly, if the sub-block to be encoded is an image block composed of A1, A2, A3, B1, B2 and B3, the pixel points of the reference in the previous row corresponding to the sub-block to be encoded are three reconstructed values of B0. Then, the encoder can determine the predicted value of the sub-block to be encoded based on the three reconstructed values of A0.
[0270] Or, if Fig. 9 As shown in (d) in FIG. 1 , the encoder uses the reconstructed values of the pixels A0 and B0 in the previous column to alternately fill all the pixels in the previous row.
[0271] Furthermore, the encoding end may determine an average value of the reconstructed value after filling the previous row adjacent to the sub-block to be encoded, and determine it as the predicted value of the sub-block to be encoded.
[0272] In some other embodiments, the encoding end may determine an average value of reconstructed values of a previous column of pixels adjacent to the sub-block to be encoded as the predicted value of the sub-block to be encoded.
[0273] For example, if the current coding block is Figure 8 As shown in (a), the size of the block to be encoded is 16x2 pixels, including two rows of pixels A1 to A16 and B1 to B16, and the reconstructed pixels in the previous row include C0, A0, and B0. If the sub-block to be encoded is an image block composed of A1, A2, A3, B1, B2, and B3, the pixels corresponding to the previous column of reference of the sub-block to be encoded are A0 and B0, so the predicted value of the sub-block to be encoded is (reconstructed value of A0 + reconstructed value of B0 + 1) / 2.
[0274] The above method of determining the prediction value of the sub-block to be encoded is only exemplary, and the encoding end may also use any prediction mode as described in step S102, or other possible prediction modes to determine the prediction value of the sub-block to be encoded. Optionally, the encoding end may use one of the preset prediction modes to determine the prediction value of the sub-block to be encoded.
[0275] In a possible implementation, the encoding end quantizes the residual value of the sub-block to be encoded, and encodes the quantized residual value to obtain a bit stream of the sub-block to be encoded, wherein the residual value is the difference between the original value and the predicted value of the sub-block to be encoded.
[0276] Optionally, before quantizing the residual value of the sub-block to be encoded, the residual value may be transformed.
[0277] Furthermore, in order to make the sub-block to be encoded serve as a prediction value of other sub-blocks to be encoded, the sub-block to be encoded can be reconstructed. When reconstructing the sub-block to be encoded, the encoding end can dequantize the residual value to obtain the dequantized residual value, and reconstruct the sub-block to be encoded based on the dequantized residual value and the prediction value.
[0278] In another possible implementation, the encoding end may quantize the high-order value of the bit width of the sub-block to be encoded, and encode the high-order value of the quantized bit width of the image. The value of the first N bits of the binary number corresponding to the image bit width is used to indicate that N is a positive integer. Exemplarily, N may be 4, 5, or other possible numbers. Optionally, the high-order value may be a value used to indicate the color of the sub-block to be encoded.
[0279] Furthermore, in order to make the sub-block to be encoded serve as a prediction value of other sub-blocks to be encoded, the sub-block to be encoded can be reconstructed. When reconstructing the sub-block to be encoded, the encoding end parses the code stream of the image block corresponding to the sub-block to be encoded, obtains the high-bit value of the image bit width corresponding to the sub-block to be encoded, and then dequantizes the high-bit value of the image bit width to obtain the high-bit value of the dequantized image bit width, and combines it with the low-bit value of the prediction value to reconstruct the sub-block to be encoded.
[0280] The low-order value of the predicted value is used to indicate the last M-digit value of the binary number corresponding to the predicted value, where M is a positive integer. Exemplarily, M can be a possible number such as 4 or 5. Optionally, the low-order value can be a value used to refer to the texture of the sub-block to be encoded. The sum of N and M is the image bit width of the sub-block to be decoded, and N is the first fixed code length.
[0281] As an example of the low-order value of the prediction value, if the image bit width (code length of the original value) is 8, and the fixed code length of the sub-block to be encoded is 4, then both M and N are 4. If the prediction value of the sub-block to be encoded is 127, the binary code is 01111111, and the last four bits, i.e., the low-order value, are 1111, i.e., 15, i.e., the last 4 bits of the prediction value are 15.
[0282] In another possible implementation, the encoding end may quantize the low-order value of the bit width of the sub-block to be encoded, and encode the low-order value of the quantized image bit width. The value of the last N bits of the binary number corresponding to the image bit width is used to indicate that N is a positive integer. Optionally, the low-order value may be a value for indicating the texture of the sub-block to be encoded.
[0283] Furthermore, in order to make the sub-block to be encoded serve as a prediction value for other sub-blocks to be encoded, the sub-block to be encoded can be reconstructed. When reconstructing the sub-block to be encoded, the encoding end parses the code stream of the image block corresponding to the sub-block to be encoded, obtains the low-bit value of the image bit width corresponding to the sub-block to be encoded, and then dequantizes the low-bit value of the image bit width to obtain the low-bit value of the dequantized image bit width, and combines it with the high-bit value of the prediction value to reconstruct the sub-block to be encoded.
[0284] The high-order value of the predicted value is used to indicate the value of the first M bits of the binary number corresponding to the predicted value, where M is a positive integer. Optionally, the high-order value may be a numerical value used to indicate the color of the sub-block to be encoded. The sum of N and M is the image bit width of the sub-block to be decoded, where N is the first fixed code length.
[0285] As an example of the high-order value of the prediction value, if the image bit width (code length of the original value) is 8, and the fixed code length of the sub-block to be encoded is 4, then both M and N are 4. If the prediction value of the sub-block to be encoded is 127, the binary code is 01111111, and the first four bits are 0111. After zero padding, the binary code is 01110000, that is, the first 4 bits of the prediction value, that is, the high-order value, is 112.
[0286] Optionally, for each sub-block to be encoded, if the coefficient value (such as a residual value, an original value, etc.) of the sub-block to be encoded is on the boundary of the range that can be expressed by the first fixed-length code, a suffix can be added to the code stream of the sub-block during transmission to indicate the coefficient value of the sub-block to be encoded of the sub-block. For example, if the first fixed code length of the sub-block to be encoded is 3, since the range of coefficient values that can be represented by 3-bit binary data is [0,7], thus, if the current coefficient value is between the range [1,8], the encoding end can add a suffix 0 to the code stream of the sub-block to be encoded. Among them, the suffix can be determined by a preset suffix setting rule. Exemplary. The preset suffix setting rule may include a suffix 0 indicating a negative number, a suffix 1 indicating an integer, a suffix 0 indicating that the range of representable coefficient values increases by one position to the right, such as the above-mentioned range [1,8], and other possible rules. Based on this embodiment, the block to be encoded can be first divided into multiple sub-blocks to be encoded, and based on a fixed code length encoding method, each sub-block to be encoded is encoded with a first fixed code length, so that the encoded code stream of the block to be encoded can be smaller than the maximum code length that can be cached in the code stream buffer, so as to avoid code stream overflow.
[0287] In some embodiments, the present application also provides an image decoding method. Figure 5 The encoding method shown corresponds to Fig.10 As shown, Fig.10 The flowchart of an image decoding method provided by the present application is shown in FIG. 1 . The image decoding method can be executed by the decoder 200 or by a decoding end (such as a decoder) supporting the function of the decoder 200. Figure 1 The decoding end 20 shown in the figure is executed, and the decoding method implemented by the decoder 200 is taken as an example for description. The image decoding method includes the following steps:
[0288] S301: The decoding end determines whether the image block corresponding to the block to be decoded adopts the fallback mode based on the code stream of the block to be decoded.
[0289] Among them, the code length obtained when the image block is encoded based on the fallback mode is less than or equal to the maximum code length of the block to be decoded, and the maximum code length is the maximum code stream length allowed to be cached in the storage space (code stream buffer) used to cache the encoded code stream when encoding the image block to be decoded.
[0290] For the explanation of the maximum code length, please refer to the description in the above step S101, which will not be repeated here.
[0291] Optionally, based on the code stream of the block to be decoded, the decoder can also parse the complexity information of the block to be encoded in the header information of the block to be encoded, and then determine the quantization step size of the block to be encoded. Alternatively, the decoder can also parse the quantization step size of the block to be encoded in the header information of the block to be encoded. Alternatively, the decoder can determine the quantization step size of the block to be decoded according to the target pixel depth.
[0292] In some embodiments, a block to be decoded may include one or more components.
[0293] Optionally, the block to be decoded may include only the luminance component. Alternatively, the block to be decoded may include three components, such as luminance Y, chrominance Cb, and chrominance Cr (or red R, green G, and blue B, or luminance Y, chrominance U, and chrominance V). Alternatively, on the basis of the above three components, the block to be decoded may also include an α component, that is, the block to be decoded includes a total of four components. Among them, the α component is the pixel transparency component. When the component α value is 0, the pixel corresponding to the decoded block is transparent, and the image bit width of the α component is different from the other three components.
[0294] In some embodiments, if the block to be decoded includes multiple components, the multiple components of the block to be decoded share a fallback mode (the shared fallback mode means that the multiple components all adopt the fallback mode or none of them adopt the fallback mode), so that the decoding end can only determine whether one of the components adopts the fallback mode. When one of the components adopts the fallback mode, the other components also adopt the fallback mode. Alternatively, some of the multiple components of the block to be decoded share the fallback mode, then the decoding end can only determine whether one of the components adopts the fallback mode, and whether the other components except the part adopt the fallback mode. Alternatively, the multiple components of the block to be decoded do not share the fallback mode, so that the decoding end can determine whether each component adopts the fallback mode separately.
[0295] Specifically, the code stream of the block to be decoded may include an identifier for indicating the shared fallback mode. Thus, the decoding end may determine the components of the shared fallback mode according to the identifier, and further determine whether each component adopts the fallback mode.
[0296] Exemplarily, if the block to be decoded includes a first chroma component, a second chroma component, and a luminance component, the decoding end may respectively determine whether the first chroma component, the second chroma component, and the luminance component adopt a fallback mode during encoding.
[0297] In one example, corresponding to implementation method 1 in the above step S103, when the block to be decoded adopts the above implementation method 1 to select whether to adopt the fallback mode during encoding, the decoding end can parse the code stream of any component of the first chroma component, the second chroma component or the luminance component, and determine whether the fallback mode is adopted when encoding the first chroma component, the second chroma component and the luminance component.
[0298] Specifically, when the decoding end parses the bitstream of any one of the first chroma component, the second chroma component or the luminance component and determines that the component adopts the fallback mode during encoding, the decoding end can determine that the first chroma component, the second chroma component and the luminance component all adopt the fallback mode during encoding, and there is no need to determine again whether to adopt the fallback mode based on the bitstreams of other components.
[0299] In another example, corresponding to implementation method 2 in the above step S103, when the block to be decoded adopts the above implementation method 2 to select whether to adopt the fallback mode during encoding, the decoding end can parse the code stream of the first chroma component or the second chroma component to determine whether the fallback mode is adopted during encoding of the first chroma component and the second chroma component.
[0300] Specifically, when the decoding end parses the bitstream of any one of the first chroma component and the second chroma component or the luminance component and determines that the component adopts the fallback mode when encoding, the decoding end can determine that the first chroma component and the second chroma component and the luminance component adopt the fallback mode when encoding. In addition, the decoding end also needs to parse the bitstream of the luminance component and determine that the luminance component adopts the fallback mode when encoding.
[0301] In another example, corresponding to the implementation method 3 in the above step S103, when the block to be decoded adopts the above implementation method 3 to select whether to adopt the fallback mode during encoding, the decoding end parses the code streams of the first chroma component, the second chroma component and the luminance component, and respectively determines whether the fallback mode is adopted when encoding the first chroma component, the second chroma component and the luminance component.
[0302] In some embodiments, the codeword of the original value mode and the codeword of the fallback mode are the same. For example, the codewords of the original value mode and the fallback mode are both the first codeword. When the decoding end parses the code stream of the block to be decoded and obtains the first codeword, the decoding end can determine whether the block to be decoded adopts the fallback mode or the original value mode.
[0303] Furthermore, the decoding end can determine whether the block to be decoded adopts the fallback mode according to the size of the occupied memory space in the code stream buffer.
[0304] When the decoding end determines that the occupied memory space in the code stream buffer is greater than the first preset memory value when encoding the image block to be decoded, and is about to overflow, the decoding end determines that the image block corresponding to the image block to be decoded adopts the fallback mode. Otherwise, the decoding end determines that the image block corresponding to the image block to be decoded adopts the original value mode.
[0305] The size of the first preset memory value can be determined according to the actual memory size of the code stream buffer, and is not specifically limited.
[0306] Optionally, the decoding end determines that the code stream length of the block to be encoded is the sum of the image bit width of all components multiplied by the number of pixels, and the decoding end can parse the code stream of the block to be decoded and reconstruct the image block of the block to be decoded based on the original value mode.
[0307] In some embodiments, before executing the following step S302, the decoding end may also determine the prediction mode used by the image block corresponding to the to-be-decoded block when the image block corresponding to the to-be-decoded block adopts the fallback mode. The prediction mode may be any prediction mode as described in step S102, or other possible prediction modes.
[0308] In one implementation, when the block to be decoded includes a component, the decoding end may parse the code stream of the block to be decoded to determine the prediction mode of the block to be decoded. Alternatively, the decoding end may determine a preset prediction mode as the prediction mode of the block to be decoded, and it should be understood that the preset prediction mode is the same as the preset prediction mode used by the encoding end in the prediction process.
[0309] In another implementation, when the block to be decoded includes multiple components, the multiple components of the block to be decoded may use the same prediction mode, so that the decoding end may determine only the prediction mode of one of the components, and the prediction mode is the prediction mode of all components of the block to be decoded. Alternatively, some of the multiple components of the block to be decoded may use the same prediction mode, and the decoding end may determine only the prediction mode of one of the components, and the prediction modes of the other components except the components. Alternatively, the decoding end may determine the prediction mode of each component separately.
[0310] The process of determining the prediction mode of a component at the decoding end may refer to the detailed description in the above-mentioned other implementation manner, which will not be repeated here.
[0311] S302: When the image block corresponding to the to-be-decoded block adopts the fallback mode, the decoding end obtains a first fixed code length.
[0312] The first fixed code length is the code length of a sub-block to be decoded, and the block to be decoded includes multiple sub-blocks to be decoded.
[0313] Optionally, the first fixed code length is a preset code length value or a target pixel depth of the block to be encoded, wherein the target pixel depth is used to indicate the code length required when encoding each pixel point of the block to be encoded at a target compression rate.
[0314] In some embodiments, the decoding end may divide the block to be decoded into a plurality of sub-blocks to be decoded according to the code length of the block to be decoded and the first fixed code length.
[0315] The number of sub-blocks to be decoded can be determined according to the following formula (6):
[0316] The above fixed code length and the number of sub-blocks to be encoded in the block to be encoded satisfy the following formula (6):
[0317] The number of sub-blocks to be decoded × the first fixed code length = the code length of the block to be decoded Formula (6)
[0318] Furthermore, the decoding end may divide the block to be decoded into a plurality of sub-blocks to be decoded according to the calculated number of sub-blocks to be encoded.
[0319] In some embodiments, the decoding end may divide the block to be decoded into a plurality of sub-blocks to be decoded based on a preset size.
[0320] The process of dividing the to-be-decoded block into a plurality of to-be-decoded sub-blocks at the decoding end may refer to the relevant description of the above-mentioned step S201, which will not be described in detail.
[0321] In some embodiments, when the block to be decoded includes multiple components, the decoding end may first divide the block to be decoded into multiple components, and then divide each component into one or more sub-blocks to be decoded.
[0322] Exemplarily, the block to be decoded includes three components: a first chrominance component, a second chrominance component, and a luminance component. The decoding end may divide the code length of the block to be decoded into three sub-code lengths according to a preset ratio, and one component corresponds to one sub-code length. Further, based on the sub-code lengths of each component, the component corresponding to each sub-code length is divided into one or more sub-blocks to be decoded according to the above possible implementation methods.
[0323] Optionally, for a block to be decoded in a YCoCg image, the preset ratio of the Y component: the Co component: the Cg component may be 2:1:1. For a block to be decoded in a YUV444 image, the preset ratio of the Y component: the U component: the V component may be 2:1:1. For a block to be decoded in a YUV422 image, the preset ratio of the Y component: the U component: the V component may be 2:1:1. For a block to be decoded in a YUV420 image, the preset ratio of the Y component: the U component: the V component may be 4:1:1. For a block to be decoded in a YUV400 image, the block to be decoded includes only a luminance component.
[0324] Optionally, for the block to be decoded in the RGB image, the decoding end may divide the total code length of the block to be decoded into three sub-code lengths according to a preset ratio of R component:G component:B component of 1:1:1, with one component corresponding to one sub-code length.
[0325] It should be noted that in the image encoding and decoding process, for RGB format image blocks, since the human eye is more sensitive to image brightness, in order to improve the image effect seen by the human eye, the RGB format image blocks are usually converted into YCoCg format image blocks before encoding and decoding. However, if the image block corresponding to the block to be decoded is in RGB format, it means that the encoding end determines that the code length required for encoding the converted YCoCg format image block is longer, then the decoding end can directly decode the code stream of each RGB component to obtain the image block in RGB format.
[0326] Furthermore, the decoding end can determine the first fixed code length of each component according to the number of sub-blocks to be decoded and the sub-code length in each component. The specific process can refer to the above step S201, which will not be described in detail here.
[0327] In some other embodiments, when the block to be decoded includes multiple components, the decoding end may first divide the block to be decoded into one or more sub-decoding blocks, and then, for each sub-decoding block, further divide the sub-decoding block into sub-blocks of each component according to the ratio of each component.
[0328] Optionally, based on the relevant description in the above step S103, the fallback mode can also be used when the block to be encoded does not overflow. Correspondingly, in this case, the decoding end can determine that the code length value of the block to be decoded is other code length values greater than the target code length when the occupied memory in the code stream buffer is less than or equal to the first threshold of the total memory of the code stream buffer. Exemplarily, the first threshold may be 30% of the total memory of the code stream buffer. Thus, the decoding end can determine that the code length of 1.5 times the target code length is the code length value of the block to be decoded. Optionally, the decoding end can determine that the code length value of the block to be decoded is other code length values less than the target code length when the occupied memory in the code stream buffer is greater than or equal to the second threshold of the total memory of the code stream buffer. Exemplarily, the second threshold may be 85% of the total memory of the code stream buffer. Thus, the decoding end can determine that the code length of 0.5 times the target code length is the code length value of the block to be decoded. The decoding end can also determine that the target code length is the code length value of the block to be decoded when the occupied memory in the code stream buffer is less than the second threshold of the total memory of the code stream buffer and greater than the first threshold.
[0329] Optionally, the information on whether overflow occurs may be carried in the code stream of the block to be decoded, so that the decoding end may determine whether overflow will occur when encoding the image block based on the code stream of the block to be decoded.
[0330] Optionally, the decoding end may determine the first fixed code length according to the quantization step length analyzed above.
[0331] S303: The decoding end parses the code stream of the block to be encoded based on the first fixed code length to decode the block to be decoded.
[0332] In a possible implementation manner, the decoding end may obtain a first fixed code length, and parse original pixel values of image blocks corresponding to each to-be-decoded sub-block based on the first fixed code length.
[0333] Optionally, when the encoding end quantizes the original pixel value of the image block, the decoding end may dequantize the value parsed from the bitstream based on the acquired quantization step size.
[0334] Optionally, before quantization, if the encoder transforms the original pixel values of the image block, the decoder may further inversely transform the inversely quantized values after inversely quantizing the values parsed from the bitstream.
[0335] In one example, the decoding end parses the code stream of the image block corresponding to the sub-block to be decoded, obtains the high-order value of the original pixel value corresponding to the sub-block to be decoded, and then can dequantize the high-order value of the original pixel value to obtain the high-order value of the dequantized original pixel value, and combine it with the low-order value of the predicted value to reconstruct the decoded sub-block.
[0336] Among them, the high-order value of the original pixel value and the low-order value of the predicted value can refer to the relevant description in the above step S202, which will not be repeated here.
[0337] In another example, the decoding end parses the code stream of the image block corresponding to the sub-block to be decoded, obtains the low-order value of the original pixel value corresponding to the sub-block to be decoded, and then can dequantize the low-order value of the original pixel value to obtain the high-order value of the dequantized original pixel value, and combine it with the high-order value of the predicted value to reconstruct the decoded sub-block.
[0338] Among them, the low-order value of the original pixel value and the high-order value of the predicted value can refer to the relevant description in the above step S202, which will not be repeated here.
[0339] In another possible implementation, the decoding end may obtain a fixed code length, and based on the fixed code length, parse the residual value of each sub-block to be decoded, and obtain the predicted value of any sub-block to be decoded.
[0340] Furthermore, the image block of the block to be decoded is reconstructed according to the prediction value and the residual value of the sub-block to be decoded.
[0341] Optionally, when the encoding end quantizes the residual value of the image block, the decoding end may dequantize the value parsed from the bitstream based on the acquired quantization step size.
[0342] Optionally, before quantization, if the encoder transforms the original pixel values of the image block, the decoder may further inversely transform the inversely quantized values after inversely quantizing the values parsed from the bitstream.
[0343] Optionally, for each sub-block to be decoded, if the coefficient value (such as residual value, original value, etc.) of the sub-block to be decoded parsed based on the first fixed code length is on the boundary of the expressible range of the first fixed code length, then the code stream of the sub-block also includes a suffix during the transmission process, and the suffix is used to indicate the coefficient value of the sub-block to be decoded of the sub-block. For example, if the first fixed code length of the sub-block to be decoded is 3, since the range of coefficient values that can be represented by 3-bit binary data is [0,7], if the code stream of the sub-block also includes a suffix 0, it means that the current coefficient value is between the range [1,8]. It should be understood that the suffix can be parsed according to the preset suffix setting rules. In addition, the preset suffix setting rules of the decoding end are the same as the preset suffix setting rules of the encoding end.
[0344] Based on the above embodiment, when the fallback mode is adopted in the encoding segment, the decoding end can adopt the fallback mode to decode the block to be decoded, which can avoid the code stream overflow and thus avoid the loss of image information of the block to be decoded.
[0345] In some embodiments, the image decoding process provided by the present application can also be specifically described as follows: Fig.11 The logical flow chart shown in Figure 1 is as follows. Fig.11 As shown, the decoding process includes the following steps:
[0346] S1. The decoding end parses the header information of the block to be decoded and determines the quantization step size of the block to be decoded.
[0347] S2. The decoding end parses the code stream used to indicate the mode information in the first decoding component of the block to be decoded, and determines whether it is the first codeword.
[0348] The first decoding component is any one of the multiple components of the block to be decoded. In addition, the codeword used to indicate the original value mode and the codeword of the fallback mode are the same, both of which are the above-mentioned first codeword. When the decoding end parses the code stream of the block to be decoded and obtains the first codeword, the decoding end can determine whether the block to be decoded adopts the fallback mode or the original value mode.
[0349] When the decoding end determines that the mode information used for indicating in the first decoded component is the first codeword, the following step S3 is performed.
[0350] Otherwise, when the decoding end determines that the mode information used for indicating in the first decoding component is not the first codeword, referring to the above steps 31 to 36, the decoding end performs the decoding process, which will not be described in detail.
[0351] S3. The decoding end determines whether the first decoding component adopts the original value mode according to the state of the code stream buffer.
[0352] Here, referring to the relevant description in the above step S301, the decoding end can determine whether the to-be-decoded block adopts the fallback mode or the original value mode based on the size of the occupied memory space in the bitstream buffer, and the specific process will not be repeated here.
[0353] When the decoding end determines that the first decoded component adopts the original value mode, the following step S4 is performed.
[0354] Otherwise, when the decoding end determines that the first decoded component does not adopt the original value mode, the following step S6 is performed.
[0355] S4. The decoding end determines the first fixed code length as the image bit width of the image block indicated by the first decoding component, and decodes the first decoding component based on the original value mode.
[0356] The process of determining the first fixed code length refers to the above step S302 and will not be described in detail.
[0357] S5. The decoding end decodes other components of the block to be decoded based on the original value mode.
[0358] S6. The decoding end determines that the first decoding component adopts the fallback mode, and determines whether other components adopt the fallback mode.
[0359] For any component using the fallback mode, the decoding end executes step S7.
[0360] For the component that does not adopt the fallback mode, refer to the above steps 31 to 36, the decoding end executes the decoding process to decode the component, which will not be repeated.
[0361] S7. The decoding end determines the prediction mode adopted by the component.
[0362] The prediction modes adopted by the components of the to-be-decoded block may be the same or different. The specific process may refer to the relevant description in the above step S301 and will not be described again here.
[0363] S8. The decoding end determines the prediction mode adopted by the component, and parses the relative position information of the prediction block under the prediction mode, and then determines the prediction value of the component.
[0364] S9, the decoding end determines the total code length allocated to the component, divides the component into a plurality of sub-blocks to be decoded, and determines a fixed code length of each decoding sub-block of the component.
[0365] The decoding end may determine the fixed code length of each sub-block to be decoded according to the quantization step length of the block to be decoded. Alternatively, the decoding end may parse the code stream of each sub-block to be decoded to determine the fixed code length of each sub-block to be decoded.
[0366] S10, parsing the residual value of the component according to the fixed code length of each sub-block to be decoded.
[0367] S11. Dequantize the residual value according to the quantization step size of the component.
[0368] S12. Determine a reconstructed value of the component according to the predicted value of the component and the residual value after inverse quantization.
[0369] In some embodiments, the present application also provides an image encoding method, such as Fig.12 As shown, the image encoding method can be executed by the encoder 100, or by an encoding end (such as Figure 1 The encoding end 10) shown in the figure is executed. Here, the encoding method implemented by the encoding end is taken as an example for description. The image encoding method includes the following steps:
[0370] S401: The encoding end obtains the minimum code length of the block to be encoded.
[0371] The minimum code length is the minimum code stream length that is currently allowed to be cached by the storage space used by the encoder to cache the encoded code stream.
[0372] The block to be encoded may be referred to as an encoding unit. Generally, when encoding an image frame in a video to be encoded, the encoding end encodes the image frame in the encoding unit.
[0373] In addition, the above minimum code length is used to indicate the minimum code length that can be encoded for the block to be encoded. It should be understood that in order to prevent the code stream from underflowing, the minimum code length can be based on the following Figure 1 The storage space of the code buffer 40 is shown to be sized.
[0374] Optionally, the sum of a difference between a code stream length stored in the storage space and a code length output by the storage space in a unit time and the minimum code length is greater than or equal to the code length output by the storage space in a unit time.
[0375] It should be noted that, since the code stream buffer receives the code stream of the current block encoded by the encoder, it also flows out a certain amount of code stream. If the code stream in the current code stream buffer is empty, or the length of the code stream in the current code stream buffer is less than the code length flowing out of the buffer in a unit time, the code stream will "underflow", resulting in the code stream being unable to be transmitted normally. The minimum code length can be the code length that ensures the normal transmission of the code stream in the code stream buffer.
[0376] S402: The encoding end pre-encodes the block to be encoded based on the first mode to obtain a first code length of the block to be encoded.
[0377] The first mode is one of multiple prediction modes at the encoding end, and the first code length is the length of a code stream obtained after encoding the block to be encoded.
[0378] The specific description of step S402 can refer to the relevant description of the above step S102, which will not be repeated here.
[0379] S403: When the first code length is less than or equal to the minimum code length, the encoding end uses the fallback mode to encode the block to be encoded, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is greater than or equal to the minimum code length.
[0380] The specific description of step S403 may refer to the relevant description in the above step S103, which will not be repeated here.
[0381] The image encoding method provided by the embodiment of the present application has at least the following beneficial effects: the method can first pre-encode the block to be encoded, compare the code stream length obtained based on the pre-encoding with the minimum code length allowed to be occupied by the block to be encoded, and determine whether the code stream will underflow based on the comparison result. Furthermore, when it is determined that the code stream may underflow, the fallback mode is used to encode the block to be encoded to ensure the normal transmission of the code stream in the code stream buffer.
[0382] In some embodiments, the present application also provides an image decoding method. Fig.12 The encoding method shown corresponds to Fig.13 As shown, the image decoding method can be executed by the decoder 200, or by a decoding end (such as Figure 1 The decoding end 20 shown in the figure is executed, and the decoding method implemented by the decoder 200 is taken as an example for description. The image decoding method includes the following steps:
[0383] S501: The decoding end determines whether a fallback mode is used when encoding an image block corresponding to the block to be decoded based on a code stream of the block to be decoded.
[0384] The code length obtained when the image block is encoded based on the fallback mode is greater than or equal to the minimum code length of the block to be decoded, and the minimum code length is the minimum code stream length allowed to be cached in the storage space used to cache the encoded code stream when encoding the image block to be decoded.
[0385] The specific implementation of step S501 may refer to the related description of step S301 above, which will not be repeated here.
[0386] S502: When an image block corresponding to a to-be-decoded block adopts a fallback mode during encoding, the decoding end obtains a first fixed code length based on a code stream.
[0387] The first fixed code length is the code length of a sub-block to be decoded, and the block to be decoded includes multiple sub-blocks to be decoded.
[0388] The specific implementation of step S502 may refer to the related description of step S302, which will not be repeated here.
[0389] S503: The decoding end parses the code stream based on the first fixed code length to decode the to-be-decoded block.
[0390] The specific implementation of step S503 may refer to the relevant description of the above step S303, which will not be repeated here.
[0391] In some embodiments, the present application also provides an image encoding method, such as Fig.14As shown, the image encoding method can be executed by the encoder 100, or by an encoding end (such as Figure 1 The encoding end 10) shown in the figure is executed. Here, the encoding method implemented by the encoding end is taken as an example for description. The image encoding method includes the following steps:
[0392] S601: The encoding end obtains the maximum code length of the block to be encoded.
[0393] The maximum code length is the maximum code stream length currently allowed to be cached by the storage space used by the encoder to cache the encoded code stream.
[0394] The specific implementation of step S601 may refer to the relevant description of step S101 above, which will not be repeated here.
[0395] S602: The encoding end pre-encodes the block to be encoded based on the first mode to obtain a first code length of the block to be encoded.
[0396] The first mode is one of multiple prediction modes at the encoding end, and the first code length is the length of a code stream obtained after encoding the block to be encoded.
[0397] The specific implementation of step 6502 may refer to the relevant description of step S102 above, which will not be repeated here.
[0398] S603: When the first code length is greater than or equal to the maximum code length, the encoder adopts the second mode to encode the block to be encoded based on the forced skip residual coding mode.
[0399] The code length obtained by encoding the block to be encoded based on the residual coding mode is less than or equal to the maximum code length, and the second mode (ie, the target mode) is one of multiple prediction modes at the encoding end.
[0400] Furthermore, in the skip residual coding mode, there is no need to encode (decode) the residual coefficients, and the residual values of the pixels in the current image block are regarded as 0, that is, the reconstructed value of each pixel is equal to the predicted value of the pixel. Thus, the encoder only needs to encode the information indicating the second mode.
[0401] It should be noted that for pixels with large residual values, the encoding and decoding process will be distorted based on the skip residual mode. Therefore, in actual situations, when the residual value is large, the encoder will not choose the skip residual mode. However, when the first code length is greater than or equal to the maximum code length, in order to avoid code stream overflow, the encoder adopts the skip residual coding mode regardless of the size of the residual value, that is, the forced skip residual coding mode.
[0402] Optionally, the second mode is the target prediction mode. Since the target prediction mode is the best prediction mode, encoding the block to be encoded based on the target can maintain better encoding performance.
[0403] Optionally, the second mode is a preset prediction mode.
[0404] It is understandable that the encoding end can preset a prediction mode with better encoding performance based on the skip residual encoding mode. When the third code length is greater than or equal to the maximum code length, no matter what the target prediction mode is, the second mode is used to encode the block to be encoded.
[0405] Optionally, the encoding end can adopt the above-mentioned point-by-point prediction mode, intra-frame prediction mode, block copy mode and original value mode based on the residual skip mode to encode the coding block to determine the best prediction mode based on the skip residual coding mode.
[0406] It can be understood that based on this encoding method, when the skip residual coding mode is used for encoding, the code stream overflow can be avoided.
[0407] In some embodiments, the present application also provides an image decoding method. Fig.14 The encoding method shown corresponds to Fig.15 As shown, the image decoding method can be executed by the decoder 200, or by a decoding end (such as Figure 1 The decoding end 20 shown in the figure is executed, and the decoding method implemented by the decoder 200 is taken as an example for description. The image decoding method includes the following steps:
[0408] S701: The decoding end parses a code stream of a block to be decoded, and obtains an identifier of a second mode for predicting the block to be decoded.
[0409] The second mode may be any one of multiple prediction modes.
[0410] S702: The decoding end determines a prediction value of a block to be decoded based on the second mode.
[0411] The specific process of determining the prediction value of the block to be decoded by the decoding end is based on the second mode.
[0412] For example, if the second mode is vertical mean prediction, the decoder can use the reconstructed values of the pixels above and below the pixel to be predicted to obtain the predicted value of the pixel to be predicted. This will not be listed one by one.
[0413] S703: The decoding end determines the predicted value of the block to be decoded as the reconstructed value of the block to be decoded.
[0414] In some embodiments, the present application also provides another method for determining the prediction value of an image block, which is described below:
[0415] The encoder can first obtain the reconstructed pixels around the block to be encoded, which may include the following situations:
[0416] Scenario 1: The encoder cannot obtain the reconstructed pixel points of the previous row of the block to be encoded, and cannot obtain the reconstructed pixel points of the previous column of the block to be encoded.
[0417] At this time, the encoder can determine the prediction value of the block to be encoded based on the prediction mode in Huffman Table 1. The prediction mode in Huffman Table 1 includes a point-by-point prediction mode, an original value mode, and a fallback mode. It should be understood that when the reconstructed pixel points of the previous row of the block to be encoded cannot be obtained, and the reconstructed pixel points of the previous column of the block to be encoded cannot be obtained, the encoder can determine the prediction value of the block to be encoded based on the point-by-point prediction mode, the original value mode, or the fallback mode.
[0418] Among them, Huffman coding is an entropy coding (weight coding) algorithm for lossless data compression. The Huffman table is a code table generated based on probability. If the encoding end provides n prediction modes and the encoded codewords of each prediction mode in these n prediction modes. Among them, the Huffman table also includes the probability of selection of each prediction mode in these n prediction modes statistically experimentally, and then, the mode with a larger probability is selected, and its codeword is shorter. The mode with a smaller probability is selected, and its codeword is longer, so that the average bit rate after encoding can be smaller. It should be understood that Huffman Table 1 includes data symbols before encoding in point-by-point prediction mode, original value mode or fallback mode and the encoded codewords corresponding to each mode.
[0419] Scenario 2: The encoder can obtain the reconstructed pixel points of the previous row of the block to be encoded, but cannot obtain the reconstructed pixel points of the previous column of the block to be encoded.
[0420] The encoder can use the reconstructed pixels in the previous row as reference pixels and determine the prediction value of the block to be encoded based on the prediction mode in Huffman Table 2. The prediction modes in Huffman Table 2 include point-by-point prediction mode, original value mode, fallback mode, and other intra-frame prediction modes that can use the previous row as reference pixels and the encoded codewords corresponding to each mode.
[0421] Scenario 3: the encoder can obtain the previous column of reconstructed pixels of the block to be encoded, but cannot obtain the previous row of reconstructed pixels of the block to be encoded.
[0422] The encoder can use the previous column of reconstructed pixels as reference pixels and determine the prediction value of the block to be encoded based on the prediction mode in Huffman Table 3. The prediction modes in Huffman Table 3 include point-by-point prediction mode, block prediction mode, original value mode, fallback mode, and prediction mode using the previous column as reference pixels in intra-frame prediction mode, and the encoded codeword corresponding to each mode.
[0423] Case 4: the encoder can obtain the previous column of reconstructed pixels and the previous row of reconstructed pixels of the block to be encoded.
[0424] The encoding end may use the reconstructed pixel point of the previous column and / or previous row as a reference pixel, and determine the prediction value of the block to be encoded based on the prediction mode in Huffman table 4. The prediction mode in Huffman table 4 may include all possible prediction modes. The enumeration and description of the prediction mode may refer to the relevant description in the above step S102, and will not be repeated here.
[0425] Correspondingly, when determining the prediction value of the block to be decoded, the decoding end may first obtain the reconstructed pixel points around the block to be decoded, and there are also four possible situations corresponding to the above encoding end.
[0426] Specifically, in the case corresponding to situation 1, when the decoding end cannot obtain the previous row of reconstructed pixels of the block to be decoded, and cannot obtain the previous column of reconstructed pixels of the block to be decoded, the decoding end can look up Table 1 based on the codeword used to indicate the prediction mode in the block to be decoded, determine the prediction mode, and further determine the prediction value of the block to be decoded. In the case corresponding to situation 2, the decoding end can obtain the previous row of reconstructed pixels of the block to be decoded, and cannot obtain the previous column of reconstructed pixels of the block to be decoded, the decoding end can look up Table 2 based on the codeword used to indicate the prediction mode in the block to be decoded, determine the prediction mode, and further determine the prediction value of the block to be decoded. In the case corresponding to situation 3, the decoding end can obtain the previous column of reconstructed pixels of the block to be decoded, and cannot obtain the previous row of reconstructed pixels of the block to be decoded, the decoding end can look up Table 3 based on the codeword used to indicate the prediction mode in the block to be decoded, determine the prediction mode, and further determine the prediction value of the block to be decoded. In a situation corresponding to situation 4, when the decoding end can obtain the previous column of reconstructed pixels and the previous row of reconstructed pixels of the block to be decoded, the decoding end can look up Table 4 based on the codeword used to indicate the prediction mode in the block to be decoded, determine the prediction mode, and further determine the prediction value of the block to be decoded.
[0427] In some embodiments, when encoding the sub-block to be encoded in the above embodiments, a semi-fixed length encoding method is also provided. Under the premise of no conflict, the methods provided in the above embodiments can also adopt the semi-fixed length encoding method.
[0428] Among them, the semi-fixed-length coding method means that for one or more sub-blocks to be coded of a block to be coded, the coding end can encode each sub-block to be coded based on different code lengths. For a sub-block to be coded containing multiple pixels, the coding end can use a fixed code length to encode each pixel, and deploy the codeword encoded by the fixed code length in the code stream prefix of the sub-block to be coded.
[0429] Accordingly, the decoding end can parse the prefix of each sub-block to be encoded, and parse out each fixed code length of each sub-block to be decoded. For a sub-block to be decoded, the decoding end can decode each pixel point based on the fixed code length value parsed from the sub-block to be decoded.
[0430] The following describes the encoding device and decoding device provided by the embodiments of the present application.
[0431] In one example, any decoding device provided in the embodiments of the present application may be Figure 1 In another example, any of the following encoding devices may be Figure 1 The encoding end 20 or the encoder 200 in the embodiment is described uniformly here and will not be described in detail below.
[0432] Fig.16 The present application provides a structural schematic diagram of an image encoding device 1600, and any of the above encoding method embodiments can be executed by the encoding device 1600. The image encoding device 1600 includes an acquisition module 1601, a processing module 1602, and an encoding module 1603. Among them, the acquisition module 1601 is used to obtain the maximum code length of the block to be encoded, and the maximum code length is the maximum code stream length currently allowed to be cached by the storage space used by the encoding end to cache the encoded code stream. The processing module 1602 is used to pre-encode the block to be encoded based on the first mode to obtain the first code length of the block to be encoded, the first mode is one of the multiple prediction modes of the encoding end, and the first code length is the length of the code stream obtained after the block to be encoded is encoded. The encoding module 1603 is used to encode the block to be encoded in a fallback mode when the first code length is greater than or equal to the maximum code length, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than or equal to the maximum code length.
[0433] For a more detailed description of the acquisition module 1601, the processing module 1602 and the encoding module 1603, as well as a more detailed description of each technical feature therein and a description of the beneficial effects, etc., please refer to the corresponding method embodiment section above and will not be repeated here.
[0434] Fig.17The present application provides a structural schematic diagram of an image decoding device 1700, and any of the above decoding method embodiments can be executed by the decoding device 1700. The image decoding module 1700 includes a determination module 1701 and a parsing module 1702. Among them, the determination module 1701 is used to determine whether the image block corresponding to the block to be decoded adopts a fallback mode based on the code stream of the block to be decoded and the code stream of the block to be decoded. The determination module 1701 is also used to obtain a first fixed code length when the image block corresponding to the block to be decoded adopts a fallback mode. The parsing module 1702 is used to parse the code stream of the block to be encoded based on the first fixed code length to decode the block to be decoded.
[0435] For a more detailed description of the above-mentioned determination module 1701 and analysis module 1702, as well as a more detailed description of each technical feature therein, and a description of the beneficial effects, etc., please refer to the above-mentioned corresponding method embodiment part, which will not be repeated here.
[0436] Fig.18 The present application provides a structural schematic diagram of an image encoding device 1800, and any of the above encoding method embodiments can be executed by the encoding device 1800. The image encoding device 1800 includes an acquisition module 1801, a processing module 1802, and an encoding module 1803. Among them, the acquisition module 1801 is used to obtain the minimum code length of the block to be encoded, and the minimum code length is the minimum code stream length currently allowed to be cached by the storage space used by the encoding end to cache the encoded code stream. The processing module 1802 is used to pre-encode the block to be encoded based on the first mode to obtain the first code length of the block to be encoded, and the first mode is one of the multiple prediction modes of the encoding end; the first code length is the length of the code stream obtained after the block to be encoded is encoded. The encoding module 1803 is used to encode the block to be encoded in a fallback mode when the first code length is less than or equal to the minimum code length, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is greater than or equal to the minimum code length.
[0437] For a more detailed description of the acquisition module 1801, the processing module 1802 and the encoding module 1803, as well as a more detailed description of the technical features therein and a description of the beneficial effects, etc., please refer to the corresponding method embodiment section above and will not be repeated here.
[0438] Fig.19The present application provides a structural schematic diagram of an image decoding device 1900, and any of the above decoding method embodiments can be executed by the decoding device 1900. The image decoding module 1900 includes a determination module 1901 and a parsing module 1902. The determination module 1901 is used to determine whether the image block corresponding to the block to be decoded adopts a fallback mode when encoding based on the code stream of the block to be decoded, wherein the code length obtained when the image block is encoded based on the fallback mode is greater than or equal to the minimum code length of the block to be decoded, and the minimum code length is the minimum code stream length allowed to be cached when encoding the image block to be decoded by the storage space used to cache the encoded code stream. The determination module 1901 is also used to obtain a first fixed code length based on the code stream when the image block corresponding to the block to be decoded adopts the fallback mode when encoding, and the first fixed code length is the code length of a sub-block to be decoded, and the block to be decoded includes multiple sub-blocks to be decoded. The parsing module 1902 is used to parse the code stream based on the first fixed code length to decode the block to be decoded.
[0439] For a more detailed description of the above-mentioned determination module 1901 and analysis module 1902, as well as a more detailed description of each technical feature therein, and a description of the beneficial effects, etc., please refer to the above-mentioned corresponding method embodiment part, which will not be repeated here.
[0440] Fig. 20 The present invention provides a schematic diagram of the structure of an image encoding device 2000, and any of the above encoding method embodiments can be executed by the encoding device 2000. The image encoding device 2000 includes an acquisition module 2001, a processing module 2002, and an encoding module 2003. The acquisition module 2001 is used to obtain the maximum code length of the block to be encoded, and the maximum code length is the maximum code stream length currently allowed to be cached by the storage space used by the encoding end to cache the encoded code stream. The processing module 2002 is used to pre-encode the block to be encoded based on the first mode to obtain the first code length of the block to be encoded, and the first mode is one of the multiple prediction modes of the encoding end; the first code length is the length of the code stream obtained after the block to be encoded is encoded. The encoding module 2003 is used to encode the block to be encoded using the second mode based on the skip residual coding mode when the first code length is greater than or equal to the maximum code length, wherein the code length obtained by encoding the block to be encoded based on the residual coding mode is less than or equal to the maximum code length, and the second mode is one of the multiple prediction modes of the encoding end.
[0441] For a more detailed description of the acquisition module 2001, the processing module 2002 and the encoding module 2003, as well as a more detailed description of the technical features therein and a description of the beneficial effects, etc., please refer to the corresponding method embodiment section above and will not be repeated here.
[0442] Fig.21The present application provides a structural schematic diagram of an image decoding device 2100, and any of the above decoding method embodiments can be executed by the decoding device 2100. The image decoding module 2100 includes a parsing module 2101, a prediction module 2102, and a reconstruction module 2103. The parsing module 2101 is used to parse the code stream of the block to be decoded and obtain an identifier of the second mode for predicting the block to be decoded. The prediction module 2102 is used to determine the predicted value of the block to be decoded based on the second mode. The reconstruction module 2103 is used to determine the predicted value of the block to be decoded as the reconstructed value of the block to be decoded.
[0443] For a more detailed description of the above-mentioned analysis module 2101, prediction module 2102 and reconstruction module 2103, as well as a more detailed description of each technical feature therein, and a description of the beneficial effects, etc., please refer to the above-mentioned corresponding method embodiment part, which will not be repeated here.
[0444] The present application also provides an electronic device for executing any of the above-mentioned image encoding / decoding methods. Fig. 22 As shown, Fig. 22 This is a schematic diagram of the structure of an electronic device provided by the present application, where the electronic device 2200 includes a processor 2201 and a communication interface 2202. The processor 2201 and the communication interface 2202 are coupled to each other. It can be understood that the communication interface 2202 can be a transceiver or an input-output interface.
[0445] In one example, the electronic device 2200 may further include a memory 2203 for storing instructions executed by the processor 2201 or storing input data required for the processor 2201 to run instructions or storing data generated after the processor 2201 runs instructions.
[0446] The specific connection medium between the communication interface 2202, the processor 2201 and the memory 2203 is not limited in the embodiment of the present application. Fig. 22 The communication interface 2202, the processor 2201 and the memory 2203 are connected via a bus 2204. Fig. 22 The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 22 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0447] The memory 2203 can be used to store software programs and modules, such as program instructions / modules corresponding to the image decoding method or image encoding method provided in the embodiment of the present application. The processor 2201 executes the software programs and modules stored in the memory 2203 to perform various functional applications and data processing to implement any of the image decoding methods or image encoding methods provided above. The communication interface 2202 can be used to communicate signaling or data with other devices. In the present application, the electronic device 2200 can have multiple communication interfaces 2202.
[0448] It is understandable that the processor in the embodiments of the present application may be a central processing unit (CPU), a neural processing unit (NPU) or a graphic processing unit (GPU), or may be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. A general-purpose processor may be a microprocessor or any conventional processor.
[0449] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a network device or a terminal device. Of course, the processor and the storage medium can also be present in a network device or a terminal device as discrete components.
[0450] An embodiment of the present application also provides a coding and decoding system, including a coding end and a decoding end, wherein the coding end can be used to execute any one of the image coding methods provided above, and the decoding end is used to execute the corresponding image decoding method.
[0451] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is executed in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable device. The computer program or instruction may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instruction may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, for example, a floppy disk, a hard disk, a tape; it may also be an optical medium, for example, a digital video disc (DVD); it may also be a semiconductor medium, for example, a solid state drive (SSD).
[0452] In the various embodiments of the present application, unless otherwise specified or provided for in any logical conflict, the terms and / or descriptions between the different embodiments are consistent and may be referenced to each other, and the technical features in the different embodiments may be combined to form new embodiments according to their inherent logical relationships.
[0453] It is understood that the various numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. The size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic.
Claims
1. An image decoding method, characterized in that: Applied to a decoding end, the method comprises: Determining, based on a code stream of a block to be decoded, whether a fallback mode is adopted when decoding an image block corresponding to the block to be decoded, wherein a code length of the block to be decoded is less than or equal to a maximum code length of the block to be decoded, and the maximum code length is a maximum code stream length allowed to be cached in a code stream buffer; When the image block corresponding to the to-be-decoded block adopts the fallback mode during decoding, a first fixed code length is obtained, where the first fixed code length is the code length of a to-be-decoded sub-block, and the to-be-decoded block includes one or more to-be-decoded sub-blocks; wherein the first fixed code length is the target pixel depth of the to-be-decoded block, and the target pixel depth is used to indicate the code length required for decoding each pixel point of the to-be-decoded block at a target compression rate; According to the code length of the block to be decoded and the first fixed code length, the block to be decoded is divided into a plurality of sub-blocks to be decoded; and based on the first fixed code length, a code stream of each sub-block to be decoded of the block to be decoded is parsed to decode the block to be decoded.
2. The method according to claim 1, characterized in that The block to be decoded includes a first chrominance component, a second chrominance component, and a luminance component, and determining whether an image block corresponding to the block to be decoded adopts a fallback mode during decoding based on a code stream of the block to be decoded includes: The luminance component is parsed to determine whether the fallback mode is adopted when decoding the first chrominance component, the second chrominance component, and the luminance component.
3. The method according to claim 2, characterized in that The sum of the code length of the first chrominance component, the code length of the second chrominance component and the code length of the luminance component is the code length of the block to be decoded; the code length of the luminance component is greater than or equal to the code length of the first chrominance component, or the code length of the luminance component is greater than or equal to the code length of the second chrominance component.
4. The method according to claim 1, characterized in that: The parsing the code stream of each to-be-decoded sub-block of the to-be-decoded block based on the first fixed code length to decode the to-be-decoded block includes: Parsing a code stream of each to-be-decoded sub-block of the to-be-decoded block based on the first fixed code length to obtain a residual value of each to-be-decoded sub-block; Each sub-block to be decoded is reconstructed according to the predicted value of each sub-block to be decoded and the residual value to obtain a reconstructed block of each sub-block to be decoded.
5. The method according to claim 1, characterized in that The method further comprises: When the codeword used to indicate the prediction mode in the code stream of the block to be decoded is a first codeword, and the image block corresponding to the block to be decoded does not adopt the fallback mode during decoding, the image block of the block to be decoded is reconstructed based on the original value mode, wherein the first codeword is used to indicate the fallback mode or the original value mode.
6. An image encoding method, characterized in that: Applied to the encoding end, the method includes: Obtaining a maximum code length of a block to be encoded, where the maximum code length is a maximum code stream length allowed to be cached in a code stream buffer; Pre-encoding the block to be encoded based on a first mode to obtain a first code length of the block to be encoded, where the first mode is one of multiple prediction modes of the encoding end; the first code length is the length of a code stream obtained after encoding the block to be encoded; In a case where the first code length is greater than or equal to the maximum code length, a fallback mode is adopted to encode the block to be encoded based on a fixed code length, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than or equal to the maximum code length; the fixed code length is a target pixel depth of the block to be encoded, and the target pixel depth is used to indicate the code length required for encoding each pixel point of the block to be encoded at a target compression rate.
7. An image decoding device, characterized in that: Applied to a decoding end, the device comprises: A determination module, configured to determine whether a fallback mode is adopted when decoding an image block corresponding to the block to be decoded based on a code stream of the block to be decoded, wherein the code length of the block to be decoded is less than or equal to the maximum code length of the block to be decoded, and the maximum code length is the maximum code stream length allowed to be cached in the code stream buffer; The determination module is further configured to obtain a first fixed code length when a fallback mode is adopted during decoding of an image block corresponding to the block to be decoded, wherein the first fixed code length is a code length of a sub-block to be decoded, and the block to be decoded includes one or more sub-blocks to be decoded; wherein the first fixed code length is a target pixel depth of the block to be decoded, and the target pixel depth is used to indicate a code length required for decoding each pixel of the block to be decoded at a target compression rate; A parsing module is used to divide the block to be decoded into multiple sub-blocks to be decoded according to the code length of the block to be decoded and the first fixed code length; and parse the code stream of each sub-block to be decoded of the block to be decoded based on the first fixed code length to decode the block to be decoded.
8. An image encoding device, characterized in that Applied to the encoding end, the device includes: An acquisition module, used for acquiring a maximum code length of a block to be encoded, wherein the maximum code length is a maximum code stream length allowed to be cached in a code stream buffer; a processing module, configured to pre-encode the block to be encoded based on a first mode to obtain a first code length of the block to be encoded, wherein the first mode is one of multiple prediction modes of the encoding end; the first code length is the length of a code stream obtained after encoding the block to be encoded; A coding module, used for, when the first code length is greater than or equal to the maximum code length, adopting a fallback mode to encode the block to be encoded based on a fixed code length, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than or equal to the maximum code length; the fixed code length is a target pixel depth of the block to be encoded, and the target pixel depth is used to indicate the code length required for encoding each pixel point of the block to be encoded at a target compression rate.
9. An electronic device, characterized in that: The system comprises a processor and a memory, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program or instruction. When the computer program or instruction is executed by an electronic device, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Encoder, decoder, encoding method and decoding method, and recording medium
CN101765010A
Substream multiplexing for display stream compression
CN110603812A
Video encoding and decoding method, video encoder and video decoder
CN111277828A
