Image coding, decoding method and apparatus
The fallback mode in image encoding and decoding adjusts code lengths to match buffer limits, preventing bitstream overflow and underflow, ensuring stable image transmission.
Patent Information
- Authority / Receiving Office
- JP Β· JP
- Patent Type
- Patents
- Current Assignee / Owner
- HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
- Filing Date
- 2023-06-06
- Publication Date
- 2026-07-29
AI Technical Summary
Existing video encoding techniques face issues with bitstream overflow and underflow due to variable-bitrate data, which is unsuitable for real-time transmission on fixed-bitrate channels, leading to loss of image information.
Implementing a fallback mode in image encoding and decoding processes to adjust the code length of blocks based on the maximum or minimum allowed bitstream length in the buffer, ensuring the code length is within buffer limits to prevent overflow or underflow.
Prevents bitstream overflow and underflow, maintaining stable image information transmission by adjusting code lengths to match buffer capacity, thereby ensuring consistent image quality.
Smart Images

Figure 0007897344000001 
Figure 0007897344000002 
Figure 0007897344000003
Abstract
Description
[Technical Field]
[0001] Embodiments of the present invention relate to the field of video coding and decoding, and more particularly to image coding, decoding methods and apparatus. [Background technology]
[0002] Video encoding techniques, also known as video compression techniques, are used to reduce the data bandwidth of video signals. Here, video is a sequence of images, consisting of consecutive image frames. Due to the afterimage effect of the human eye, when a sequence of frames is played back at a constant speed, what the human eye sees is a continuous video. Encoding and decoding video involves encoding and decoding the image of each frame of the video. Taking a single frame as an example, on the encoding side, an image encoder encodes the image, obtains a bitstream corresponding to the image, and sends the bitstream to the decoding side. On the decoding side, an image decoder analyzes the bitstream and reconstructs the image.
[0003] In the image encoding and decoding process, common video compression techniques employ variable-length encoding to improve compression efficiency. In variable-length encoding, the bitstream obtained after a video sequence has been compressed and encoded has a variable bitrate, making it unsuitable for real-time transmission on a fixed-bitrate channel. Therefore, typically, variable-bitrate data generated by an encoder is output to a buffer with a specific memory space, and then output from the buffer at a fixed bitrate. The size of the buffer's memory space is constant. If the bitstream data input to the buffer is too large, and the data that needs to be temporarily stored in the buffer exceeds the size of that memory space, a bitstream "overflow" occurs, resulting in the loss of subsequent image information. Conversely, if the bitstream data input to the buffer is too small, and there is a "shortage" of data that can be temporarily stored in the buffer, and the buffer cannot meet its fixed output bitrate, a bitstream "underflow" occurs.
[0004] Therefore, how to avoid bitstream "overflow" or "underflow" in image encoding and decoding processes is a problem that needs to be solved. [Overview of the project]
[0005] Embodiments of the present invention provide an image encoding and decoding method and apparatus that can be used to prevent bitstream overflow.
[0006] To achieve the above objective, the embodiments of the present invention employ the following technical solutions.
[0007] In a first embodiment, an embodiment of the present invention provides an image decoding method performed by a decoding side, comprising the steps of: determining whether a fallback mode is used for an image block corresponding to a block to be decoded, based on the bitstream 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 bitstream length that is permitted to be cached in a bitstream buffer; if the fallback mode is used for an image block corresponding to the block to be decoded, obtaining a first fixed code length, wherein the first fixed code length is the code length of one subblock to be decoded, and the block to be decoded includes one or more subblocks to be decoded; and analyzing the bitstream based on the first fixed code length to decode the block to be decoded.
[0008] In a second embodiment, an embodiment of the present invention provides an image encoding method performed by an encoding side, comprising: a step of obtaining the maximum code length of a block to be encoded, wherein the maximum code length is the maximum bitstream length that is permitted to be cached in a bitstream buffer; a step of pre-encoding 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 a plurality of prediction modes of the encoding side, and the first code length is the length of the bitstream obtained after encoding the block to be encoded; and a step of encoding the block to be encoded in a fallback mode if 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.
[0009] In a third embodiment, an embodiment of the present invention provides an image decoding method performed by a decoding side, comprising the steps of: determining whether a fallback mode is used when encoding an image block corresponding to a block to be decoded, based on the bitstream 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 bitstream length that is permitted to be cached in a bitstream buffer; if a fallback mode is used when encoding an image block corresponding to the block to be decoded, obtaining a first fixed code length based on the bitstream, wherein the first fixed code length is the code length of one subblock to be decoded, and the block to be decoded includes one or more subblocks to be decoded; and analyzing the bitstream based on the first fixed code length to decode the block to be decoded.
[0010] In a fourth embodiment, an embodiment of the present invention provides an image coding method applied to an encoding side, comprising: a step of obtaining the minimum code length of a block to be coded, wherein the minimum code length is the minimum bitstream length that is permitted to be cached in a bitstream buffer; a step of pre-coding the block to be coded based on a first mode to obtain a first code length of the block to be coded, wherein the first mode is one of a plurality of prediction modes of the encoding side, and the first code length is the length of the bitstream obtained after coding the block to be coded; and a step of coding the block to be coded in a fallback mode if the first code length is less than or equal to the minimum code length, wherein the code length obtained by coding the block to be coded based on the fallback mode is greater than or equal to the minimum code length.
[0011] In a fifth embodiment, an embodiment of the present invention provides an image decoding method applied to a decoding side, comprising the steps of: analyzing the bitstream of a block to be decoded to determine whether or not a skip residual mode is used; determining a second mode of the block to be decoded if the skip residual mode is used, wherein the second mode is one of a plurality of prediction modes of the decoding side; determining a predicted value of the block to be decoded based on the second mode; and determining the predicted value of the block to be decoded as the reconstructed value of the block to be decoded.
[0012] In a sixth aspect, an embodiment of the present invention is an image encoding method applied to an encoding side, including: a step of obtaining a maximum code length of a block to be encoded, where the maximum code length is the maximum bitstream length that is allowed to be cached in a bitstream buffer; a step of 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 a plurality of prediction modes on the encoding side, and the first code length is the length of a bitstream obtained after encoding the block to be encoded; and a step of encoding the block to be encoded in a second mode based on a skip residual mode when the first code length is greater than or equal to the maximum code length, where the code length obtained by encoding the block to be encoded in the second mode based on the skip residual mode is less than or equal to the maximum code length, and the second mode is one of a plurality of prediction modes on the encoding side. An image encoding method is provided.
[0013] In a seventh embodiment, an embodiment of the present invention is an image decoding method applied to a decoding side, comprising the steps of determining whether a fallback mode is used during decoding for an image block corresponding to a block to be decoded, based on the bitstream 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 bitstream length that is permitted to be cached in a bitstream buffer; and, if the fallback mode is used during decoding for an image block corresponding to the block to be decoded, obtaining a first fixed code length, wherein the first fixed code length is one subblock to be decoded The present invention provides an image decoding method comprising the steps of: a first fixed code length being the code length of a block, wherein the block to be decoded includes one or more subblocks to be decoded, the first fixed code length being the target bit-per-pixel of the block to be decoded, and the target bit-per-pixel being used to indicate the code length required when decoding each pixel of the block to be decoded at a target compression ratio; dividing the block to be decoded into a plurality of subblocks to be decoded based on the code length of the block to be decoded and the first fixed code length; and decoding the block to be decoded by analyzing the bitstream of each subblock to be decoded of the block to be decoded based on the first fixed code length. <0000ββββββββββββββββββββββββββββIt includes each module for implementing any one of the decoding methods. The decoding device can implement the operations in the examples of the related method. The operations may be implemented by hardware or may be implemented by hardware executing the corresponding software. The hardware or software includes one or more modules corresponding to the above operations.
[0020] The 10 In an aspect, the present invention provides an image encoding device. The encoding device may be a video encoder or a device including a video encoder. The encoding device may implement each module for implementing any one of the encoding methods in the second aspect, the fourth aspect , the Aspect 6 , or the eighth aspect It includes each module for implementing any one of the encoding methods. The encoding device can implement the operations in the examples of the related method. The operations may be implemented by hardware or may be implemented by hardware executing the corresponding software. The hardware or software includes one or more modules corresponding to the above operations.
[0021] The 11 In an aspect, the present invention provides an electronic device including a processor and a memory. The memory is used to store computer instructions, and the processor calls and executes the computer instructions from the memory to implement the method described in any one of the first aspect to the 8 aspect. For example, the electronic device may be a video encoder or a device including a video encoder. In another example, the electronic device may be a video decoder or a device including a video decoder.
[0022] The 12 In an aspect, the present invention provides a computer-readable storage medium storing a computer program or instructions. When the computer program or instructions are executed by a computing device or a processor, the method described in any one of the first aspect to the 8A computer-readable storage medium is provided, which is operated according to one of the methods described in any one of the embodiments.
[0023] 1 3 In some embodiments, the present invention relates to a computer program product including instructions, which, when executed on a computing device or processor, causes the computing device or processor to execute the instructions, in the first to third embodiments. 8 The present invention provides a computer program product that enables the implementation of the method described in any one of the embodiments.
[0024] 1 4 In an embodiment, the present invention is a chip including memory and a processor, wherein the memory is used to store computer instructions, and the processor calls and executes the computer instructions from the memory, and in the first embodiment to the 8 A chip is provided which is used to carry out the method according to any one of the embodiments.
[0025] 1 5 In its embodiment, the present invention is an image coding system including an encoding side and a decoding side, wherein the decoding side is a first embodiment, a third embodiment , the 5 aspects , or the seventh aspect The encoding side provides an image coding system used to implement the corresponding decoding method provided in the image coding system, and the encoding side provides an image coding system used to implement the corresponding encoding method.
[0026] The present invention may be further combined to provide more implementations based on the implementations provided in each of the above embodiments. Alternatively, any possible implementation of any of the above embodiments may be applied to other embodiments to obtain new embodiments, provided that they do not conflict. For example, the first embodiment, the third embodiment, etc. , the 5 aspects , and the seventh aspect Any of the image decoding methods provided may be combined in pairs in a non-consistent manner, or in three different ways, thereby obtaining a new image decoding method.
[0027] According to the image encoding / decoding method and apparatus provided by the present invention, if it is determined that a bitstream overflow will occur, a fallback mode can be used to encode the block to be encoded, thereby preventing the bitstream overflow from occurring and preventing the loss of image information in the block to be encoded. [Brief explanation of the drawing]
[0028] [Figure 1] This is a schematic architecture diagram of the encoding and decoding system 1 to which an embodiment of the present invention is applied. [Figure 2] This is a schematic block diagram of an example encoder 100 for implementing the method of the embodiment of the present invention. [Figure 3] This is a schematic diagram illustrating the correspondence between an image, a parallel encoding unit, an independent encoding unit, and an encoding unit, as provided in an embodiment of the present invention. [Figure 4] This is a schematic block diagram of an example of a decoder 200 for implementing the method of the embodiment of the present invention. [Figure 5] This is a schematic flowchart of the image encoding method provided in the embodiment of the present invention. [Figure 6] This is a schematic diagram of the subblock to be encoded, provided in the embodiment of the present invention. [Figure 7] This is a schematic flowchart of another image encoding method provided in an embodiment of the present invention. [Figure 8] This is a schematic diagram of the block to be encoded, provided in an embodiment of the present invention. [Figure 9] This is a schematic diagram of another block to be encoded, provided by an embodiment of the present invention. [Figure 10] This is a schematic flowchart of the image decoding method provided in the embodiment of the present invention. [Figure 11] This is a logic flowchart of an image decoding method provided in an embodiment of the present invention. [Figure 12] This is a schematic flowchart of the image encoding method provided in the embodiment of the present invention. [Figure 13] This is a schematic flowchart of another image decoding method provided in an embodiment of the present invention. [Figure 14] This is a schematic flowchart of another image encoding method provided in an embodiment of the present invention. [Figure 15] This is a schematic flowchart of another image decoding method provided in an embodiment of the present invention. [Figure 16] This is a schematic diagram of the encoding device 1600 provided in an embodiment of the present invention. [Figure 17] This is a schematic diagram of the decoding device 1700 provided in an embodiment of the present invention. [Figure 18] This is a schematic diagram of another encoding device 1800 provided in an embodiment of the present invention. [Figure 19] This is a schematic diagram of another decoding device 1900 provided in an embodiment of the present invention. [Figure 20] This is a schematic diagram of another encoding device 2000 provided in an embodiment of the present invention. [Figure 21] This is a schematic diagram of another decoding device 2100 provided in an embodiment of the present invention. [Figure 22] This is a schematic diagram of the electronic device 2200 provided by an embodiment of the present invention. [Modes for carrying out the invention]
[0029] The technical concepts in the embodiments of the present invention will be described clearly and completely below with reference to the drawings of the embodiments of the present invention, and it is clear that the embodiments described are only a subset of the embodiments of the present invention, not all embodiments. All other embodiments that can be obtained by those skilled in the art without creative effort based on the embodiments of the present invention are all within the scope of the protection of the present invention.
[0030] In the description of this invention, unless otherwise specified, " / " means "or," for example, A / B can represent A or B. In this specification, "and / or" is used to describe the relationship between related objects and indicates that there may be three types of relationships, for example, A and / or B can represent the three cases of A existing alone, A and B existing together, or B existing alone. "At least one" means one or more, and "multiple" means two or more. Terms such as "first," "second," etc., do not limit the number or order of execution and do not necessarily limit them to being different.
[0031] In this invention, terms such as "exemplary" or "for example" are used to indicate an example, illustration, or explanation. Any embodiment or technical proposal described as "exemplary" or "for example" in this invention should not be construed as being preferable or advantageous to other embodiments or technical proposals. Strictly speaking, the use of terms such as "exemplary" or "for example" is intended to illustrate the relevant concepts in a concrete manner.
[0032] The following describes the system architecture to which the embodiments of the present invention are applied.
[0033] Referring to Figure 1, Figure 1 shows a schematic architecture diagram of an encoding and decoding system 1 to which an embodiment of the present invention is applied. As shown in Figure 1, the encoding and decoding system 1 may include an encoding side 10 and a decoding side 20. Here, the encoding side 10 generates encoded video data. Therefore, the encoding side 10 may be called a video encoding device. The decoding side 20 can decode the encoded video data generated by the encoding side 10. Therefore, the decoding side 20 may be called a video decoding device.
[0034] The specific forms of the encoding side 10 and the decoding side 20 may include a variety of devices, such as desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, mobile phones such as "smartphones," televisions, cameras, display devices, digital media players, video game consoles, in-car computers, or similar devices.
[0035] Optionally, the encoding side 10 and decoding side 20 in Figure 1 may be two separate devices. Alternatively, the encoding side 10 and decoding side 20 may be the same device; that is, the encoding side 10 or its corresponding function and the decoding side 20 or its corresponding function may be integrated into the same device.
[0036] The encoding side 10 and the decoding side 20 are able to communicate with each other. For example, the decoding side 20 may receive encoded video data from the encoding side 10 via link 30. Link 30 may include one or more media or devices that can transmit the encoded video data from the encoding side 10 to the decoding side 20. In one example, link 30 may include one or more communication media that enable the encoding side 10 to directly transmit the encoded video data to the decoding side 20 in real time. In this example, the encoding side 10 may modulate the encoded video data according to a communication standard (e.g., a wireless communication protocol) and transmit the modulated video data to the decoding side 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 a router, switch, base station, or another device that facilitates communication from the encoding side 10 to the decoding side 20.
[0037] Optionally, the encoding side 10 may output the encoded video data from the output interface 140 to an internal or external storage device. The storage device may include one of several distributed or locally accessible data storage media, such as a hard disk drive, Blu-ray disc, digital video disc (DVD), compact disc read-only memory (CD-ROM), flash memory, volatile or non-volatile memory, or any other suitable digital storage medium for storing the encoded video data.
[0038] As shown in Figure 1, the encoding side 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 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 any combination of the above sources of video data. The encoder 100 can encode the video data from the video source 120. In some examples, the encoding side 10 transmits the encoded video data directly to the decoding side 20 via the output interface 140. In other examples, the encoded video data may be stored in a storage device for the decoding side 20 to access for decoding and / or playback.
[0039] As shown in Figure 1, the decoding side 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 modem. The input interface 240 may receive encoded video data via link 30 and / or from a storage device. The display device 220 may be integrated with the decoding side 20 or provided outside of the decoding side 20. Generally, the display device 220 displays the decoded video data. The display device 220 may include various display devices, such as a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display, or other types of display devices.
[0040] Optionally, the encoding side 10 may further include a bitstream buffer (not shown in Figure 1) which is used to receive the bitstream data generated by encoding and to output bitstream data at a fixed bitrate. The size of the bitstream data generated after different blocks to be encoded can vary significantly depending on the nature of the blocks to be encoded. Therefore, the bitstream obtained after a video sequence has been compressed and encoded has a changed rate and is not suitable for real-time transmission on a fixed bitrate channel. The bitstream buffer can slow down rate changes in the compressed video. The larger the memory space of the bitstream buffer, the more it can withstand bitrate fluctuations.
[0041] Optionally, the decoding side 20 may include another buffer for receiving fixed-bitrate bitstream data and outputting it from the buffer to the bitstream analysis unit 201 of the decoder 200.
[0042] In the example of the present invention, the encoding side and the decoding side can always record the state of the bitstream buffer throughout the entire encoding / decoding process, and therefore, when encoding / decoding an image block, the encoding side and the decoding side can both obtain the maximum bitstream length that is allowed to be cached in the bitstream buffer. Regarding the process by which the encoding side and the decoding side record the state of the bitstream buffer, optionally, if only the encoding side includes a bitstream buffer, the encoding side and the decoding side may always record the state of the encoding side bitstream buffer; if only the decoding side includes a bitstream buffer, the case of the encoding side bitstream buffer may be referred to; if both the encoding side and the decoding side include bitstream buffers, the encoding side and the decoding side may simultaneously record the state of the encoding side bitstream buffer; simultaneously record the state of the decoding side bitstream buffer; the encoding side and the decoding side may each record the state of their respective bitstream buffers; or both the encoding side and the decoding side may simultaneously record the states of two bitstream buffers. The present invention is not limited to the process of recording the state of the bitstream buffer, as long as the maximum bitstream length that is permitted to be cached in the bitstream buffer of the encoding and / or decoding side can be obtained when the encoding and decoding side encode / decode an image block.
[0043] Although not shown in Figure 1, in some embodiments, the encoder 100 and decoder 200 may be integrated with an audio encoder and decoder, respectively, 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 separate data streams.
[0044] The encoding and decoding system 1 shown in Figure 1 is merely an example, and it should be understood that the technology of the present invention is applicable to video coding configurations (e.g., video encoding or video decoding) that do not necessarily require any data communication between the encoding device and the decoding device. In other examples, data may be retrieved from local memory or streamed over a network. The video encoding device can encode the data and store it in memory, and / or the video decoding device can read the data from memory and decode it. In many examples, encoding and / or decoding may be performed by devices that simply encode the data into memory and / or retrieve it from memory and decode it, without communicating with each other.
[0045] The specific structures of the encoder 100 and decoder 200 in Figure 1 will be briefly described below with reference to the drawings.
[0046] Referring to Figure 2, Figure 2 shows a schematic block diagram of an example encoder 100 for implementing the method of the embodiment of the present invention. As shown in Figure 2, the encoder 100 includes a prediction processing unit 101, a residual calculation unit 102, a residual conversion unit 103, a quantization unit 104, an encoding processing unit 105, an inverse quantization unit 106, an inverse residual conversion unit 107, a reconstruction unit 108, and a filter unit 109.
[0047] In one example, the input to encoder 100 is an image block of the image to be encoded (i.e., a block or encoding unit to be encoded).
[0048] In another example, if the input to encoder 100 is an image to be encoded, encoder 100 may further include a splitting unit (not shown in Figure 2) for dividing the image to be encoded into multiple image blocks. Encoder 100 is used to encode the multiple image blocks of the image to be encoded block by block to complete the encoding of the image to be encoded. For example, encoder 100 completes the encoding of the image to be encoded by performing the encoding process for each image block.
[0049] For example, a method for dividing an image to be encoded into multiple image blocks may include the following steps:
[0050] In step 11, the image of one frame is divided into one or more non-overlapping parallel coding units. Each parallel coding unit is independent of the others and can be coded and decoded completely in parallel / independently.
[0051] In step 12, for each parallel coding unit, the coding side may further divide it into one or more independent coding units that do not overlap with each other, and each independent coding unit does not have to be dependent on one another, but may share some header information of the parallel coding unit.
[0052] In step 13, for each independent coding unit, the coding side may further divide it into one or more non-overlapping coding units. When dividing an independent coding unit into multiple non-overlapping coding units, the division method may be horizontal equal division, vertical equal division, or horizontal-vertical equal division, etc. Of course, the specific implementation is not limited to these. Each coding unit within an independent coding unit may depend on each other, that is, they may refer to each other in the process of performing prediction processing.
[0053] The width of the coding unit is w_cu, and its height is h_cu, optionally the width being greater than the height (except for some edge regions where the width may be less than or equal to the height). Typically, the coding unit may be a fixed w_cu Γ h_cu, where both w_cu and h_cu are 2 to the power of N (where N is greater than or equal to 0), for example, 16 Γ 4, 8 Γ 4, 16 Γ 2, 8 Γ 2, 4 Γ 2, 8 Γ 1, 4 Γ 1, etc.
[0054] The encoding unit may contain three components: luminance Y, chromaticity Cb, and chromaticity Cr (or three components: red R, green G, and blue B, or luminance Y, chromaticity U, and chromaticity V), or it may contain only one of these components. If it contains three components, the sizes of these components may be exactly the same or different, specifically related to the image input format.
[0055] Figure 3 is a schematic diagram illustrating the correspondence between an image, parallel coding units, independent coding units, and coding units. In Figure 3, one image is divided into parallel coding unit 1 and parallel coding unit 2 according to a 3:1 ratio, and one independent coding unit contains four coding units as an example.
[0056] Optionally, the partitioning unit divides the image to be encoded into multiple image blocks, which may be further divided into smaller blocks, such as image blocks based on a quadtree or binary tree structure. This partitioning may also include division into slices, tiles, or other larger units. The slice may be divided into multiple image blocks (or into sets of image blocks called tiles).
[0057] The prediction processing unit 101 is used to receive or acquire the original value of the block to be encoded and the reconstructed image data, predict the block to be encoded based on the relevant data in the reconstructed image data, and obtain the predicted block to be encoded.
[0058] Optionally, the prediction processing unit 101 may include an inter-frame predictor and an intra-frame predictor. The inter-frame predictor may determine an inter-frame prediction mode for encoding the block to be encoded, predict motion information, e.g., motion vectors (MV), for one or more subblocks within the current image block based on the determined inter-frame prediction mode, and use the motion information (e.g., motion vectors) for one or more subblocks within the current image block to obtain or generate a predicted block for the current image block. The intra-frame predictor may determine an intra-frame prediction mode for encoding the block to be encoded.
[0059] Intra-frame prediction is a method of reducing spatial redundancy in video by using the spatial correlation of the video to make predictions using the coding block (CB) of the current block. For example, in-frame prediction can specify multiple prediction modes, each corresponding to one texture direction (except DC mode). For instance, if the image texture is horizontal, the horizontal prediction mode can better predict image information.
[0060] Interframe prediction involves predicting the pixels of the current image using pixels from neighboring encoded images, based on the temporal correlations in the video, as video sequences contain strong temporal correlations. This effectively reduces the temporal redundancy of the video. The interframe prediction portion of video encoding standards uses block-based motion compensation techniques, the main principle of which is to find one optimal matching block in the previous encoded image for each pixel block in the current image. This process is called motion estimation (ME).
[0061] Furthermore, in interframe prediction mode, the motion vector can represent the relative displacement between the current encoded block and the optimal matching block in the reference image. Each divided block has a corresponding motion vector transmitted to the decoding side, and if the motion vector of each block is encoded and transmitted independently, a considerable number of bits are consumed, especially when the blocks are divided into small sizes. To reduce the number of bits required to encode the motion vector, the spatial correlation between adjacent image blocks is used to predict the motion vector of the block to be encoded now based on the motion vectors of adjacent encoded blocks, and the prediction difference is encoded. This effectively reduces the number of bits required to represent the motion vector. In the process of encoding the motion vector of the current block, the motion vector of the current block is first predicted using the motion vectors of adjacent encoded blocks, and then the difference between the predicted value of the motion vector (MVP) and the actual estimated value of the motion vector (motion vector difference, MVD) is encoded, thereby effectively reducing the number of bits required to encode the MV.
[0062] The residual calculation unit 102 is used to obtain the residual block by calculating the residual value between the original value of the block to be encoded and the predicted block of the block to be encoded. For example, for each pixel, the pixel value of the predicted block is subtracted from the original pixel value of the block to be encoded.
[0063] In one example, the residual transformation unit 103 is used to determine residual coefficients based on the residual block. Optionally, the process may include performing a transformation on the residual block, such as a discrete cosine transform (DCT) or a discrete sine transform (DST), to obtain transformation coefficients in the transformation domain, which may be called transformation residual coefficients or residual coefficients, and which can represent the residual block in the transformation domain. Of course, the process by which the encoder 100 encodes the block to be encoded does not necessarily include a residual transformation step.
[0064] The quantization unit 104 is used to obtain quantized residual coefficients (or quantized residual values) by applying scalar quantization or vector quantization to quantize the conversion coefficients or residual values. The quantization process can reduce the bit depth for some or all of the conversion coefficients. For example, p-bit conversion coefficients may be truncated to q-bit conversion coefficients during quantization, where p is greater than q. The degree of quantization can be changed by adjusting the quantization parameter (QP). For example, in the case of scalar quantization, finer or coarser quantization can be achieved by applying different scales. Smaller quantization steps correspond to finer quantization, and larger quantization steps correspond to coarser quantization. The appropriate quantization step may be indicated by the QP.
[0065] In the image encoding process, to achieve image compression, quantization is typically performed on the residual block of the block to be encoded, or on the residual coefficient block obtained by performing a specific process on the residual block, so that the quantized residual block or residual coefficient block can be encoded with fewer bits. To understand this, the residual block is a residual value block obtained based on the original pixel block and the predicted block of the block to be encoded, and the residual coefficient block is a coefficient block obtained by performing a specific process and transformation on the residual block.
[0066] For example, taking the encoder 100 as an example of quantizing the residual block, the encoder 100 may divide each residual value in the residual block of the block to be encoded by a quantization coefficient in order to reduce the residual value in the residual block. In this way, the quantized and reduced residual values ββcan be encoded with fewer bits than the unquantized residual values, thereby achieving compressed encoding of the image.
[0067] The encoding unit 105 is used to encode the quantized residual coefficients (or quantized residual values) and output encoded image data (i.e., the encoding result of the block to be encoded) in the form of an encoded bitstream. The encoded bitstream may then be transmitted to a decoder, or stored for later transmission to a decoder or for use in retrieval. The encoding unit 105 may also be used to encode syntax elements of the block to be encoded, for example, by encoding the prediction mode used for the block to be encoded into a bitstream.
[0068] In one example, one possible method for the encoding processing unit 105 to encode the residual coefficients is the semi-fixed length encoding method. First, define the maximum value of the absolute value of the residuals within one residual block (RB) as the modified maximum (mm). Determine the number of encoding bits for the residual coefficients within the RB (the number of encoding bits for the residual coefficients within the same RB is the same). For example, if the fixed length code encoding length (CL) of the current RB is 2 and the current residual coefficient is 1, 2 bits are required to encode the residual coefficient 1, which is represented as 01. If the CL of the current RB is 7, the range of residuals that can be represented is [-2 6 , -2 6 -1] or [-2 6 +1, -2 6 . The determination of CL is to find the minimum M value that satisfies the condition that all the residuals of the current sub-block are within the range of [-2 (M-1) , 2 (M-1) . If there are two boundary values, -2 (M-1) and 2 (M-1) , existing simultaneously within this range, it is necessary to increase the value M corresponding to CL by 1, that is, M + 1 bits are required to encode all the residuals of the current RB. If only one of the two boundary values, -2 (M-1) and 2 (M-1) , exists, it is necessary to encode one Trailing bit to determine whether the boundary value is -2 (M-1) or 2 (M-1) . If neither -2 (M-1) nor 2 (M-1) exists for all the residuals, there is no need to encode the Trailing bit.
[0069] Of course, other residual coefficient encoding methods, such as the exponential Golomb encoding method, the Golomb-Rice encoding method, the truncated unary encoding method, the run-length encoding method, the method of directly encoding the original residual value, etc., may also be used.
[0070] In some special cases, the original value may be encoded directly instead of the residual value.
[0071] The inverse quantization unit 106 is used to inverse quantize the quantized residual coefficient (or quantized residual value) to obtain the inverse quantized residual coefficient (inverse quantized residual value), and this inverse quantization is the reverse application of the quantization unit 104, for example, by applying an inverse quantization scheme corresponding to the quantization scheme applied by the quantization unit 104, based on or using the same quantization steps as the quantization unit 104.
[0072] The residual inverse transform unit 107 is used to obtain a reconstructed residual block by inversely transforming the inversely quantized residual coefficients. Optionally, the inverse transform may include an inverse discrete cosine transform (IDCT) or an inverse discrete sine transform (IDST). In this way, the inverse transformed value obtained by inversely transforming the inversely quantized residual coefficients is a reconstructed residual value in the pixel region (or sample region). That is, after the inversely quantized residual coefficient block is inversely transformed by the residual inverse transform unit 107, the resulting block is a reconstructed residual block. Of course, if the encoder 100 does not include the residual transform unit 103, the inverse transform step may be omitted.
[0073] The reconstruction unit 108 is used to obtain a reconstructed block in the sample region by adding the reconstructed residual block to the prediction block, and the reconstruction unit 108 may be an adder. 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 may be used in a subsequent step to predict other image blocks to be encoded.
[0074] The filter unit 109 (or "filter") is used to filter the reconstruction blocks and obtain filtered blocks in order to perform pixel transformation smoothly or to improve image quality.
[0075] In one example, the encoding process performed by the encoder 100 may include the following steps:
[0076] In step 21, the prediction processing unit 101 determines the prediction mode, predicts the blocks to be encoded based on the determined prediction mode and the reconstructed blocks of the encoded image blocks, and obtains the predicted blocks to be encoded.
[0077] Here, the reconstructed block of the encoded image block is obtained by the inverse quantization unit 106, the residual inverse transform unit 107, and the reconstruction unit 108 sequentially processing the quantized residual coefficient block of the encoded image block.
[0078] In step 22, the residual calculation unit 102 obtains the residual block of the block to be encoded based on the original pixel values ββof the predicted block and the block to be encoded.
[0079] In step 23, the residual conversion unit 103 converts the residual block to obtain a residual coefficient block.
[0080] In step 24, the quantization unit 104 quantizes the residual coefficient block to obtain a quantized residual coefficient block.
[0081] In step 25, the encoding unit 105 encodes the quantized residual coefficient block and the associated syntax elements (e.g., prediction mode, encoding mode, etc.) to obtain a bitstream of the block to be encoded.
[0082] Referring to Figure 4, Figure 4 shows a schematic block diagram of an example decoder 200 for implementing the method of an embodiment of the present invention. The decoder 200 is used, for example, to receive image data encoded by the encoder 100 (i.e., an encoded bitstream, including, for example, an encoded bitstream of an image block and associated syntax elements) and to obtain a decoded image block.
[0083] As shown in Figure 4, the decoder 200 includes a bitstream analysis unit 201, an inverse quantization unit 202, an inverse residual 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 a decoding process that is approximately the reverse of the encoding process described for the encoder 100 in Figure 2.
[0084] The bitstream analysis unit 201 is used to decode the encoded bitstream to obtain quantized residual coefficients (or quantized residual values) and / or decoded parameters (decoded encoded parameters, e.g., the decoded parameters may include one or more of the inter-frame prediction parameters, intra-frame prediction parameters, filter parameters, and / or other syntax elements performed by the encoding side). The bitstream analysis unit 201 is further used to transfer the decoded parameters to the prediction processing unit 204 so that the prediction processing unit 204 can perform a prediction process based on the decoded parameters.
[0085] 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 the quantized residual coefficient or quantized residual value that has been decoded and output by the bitstream analysis unit 201.
[0086] Here, inverse quantization is the reverse process of quantization, which involves mapping quantized values ββ(e.g., coefficients or residual values) to a reconstructed signal in the input signal space, where the reconstructed signal is an approximation of the input signal. To reconstruct image blocks from a compressed and encoded bitstream, the inverse quantization unit 202 of the decoder 200 may inverse quantization of quantized residual blocks or residual coefficient blocks analyzed from the bitstream, thereby reconstructing unquantized residual blocks or residual coefficient blocks corresponding to the image blocks, thereby allowing the decoder 200 to reconstruct the image blocks based on the reconstructed residual blocks or residual coefficient blocks to obtain reconstructed image blocks.
[0087] As an example, the decoder 200 may analyze the quantized residual block of the block to be decoded from the bitstream. The decoder 200 may then dequantize the residual block via the dequantization unit 202. Specifically, the dequantization unit 202 may multiply each residual value in the analyzed residual block by a quantization coefficient to reconstruct the residual values ββin the unquantized residual block corresponding to the block to be decoded, thereby obtaining a reconstructed residual block. Here, the quantization coefficient is the quantization coefficient used when the encoding device quantizes the residual block of the block to be decoded when encoding the block to be decoded. In this way, the decoder 200 can reconstruct the block to be decoded based on the reconstructed residual block after dequantization, and obtain a reconstructed block of the block to be decoded.
[0088] 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., inverse DCT, inverse integer transform, or a conceptually similar inverse transform process) on the inversely quantized residual coefficients to obtain the reconstructed residual value. The block obtained by the inverse transform is the residual block in the pixel region of the reconstructed block to be decoded.
[0089] The function of the reconfiguration unit 205 (for example, an adder) may be the same as the function of the reconfiguration unit 108 of the encoder 100.
[0090] The prediction processing unit 204 is used to receive or acquire encoded image data (e.g., the prediction mode of the current image block) and reconstructed image data. The prediction processing unit 204 may further receive or acquire, for example, relevant parameters of the prediction mode and / or information about the selected prediction mode (i.e., the above-mentioned decoding parameters) from the bitstream analysis unit 201, and predict the current image block based on the relevant data and decoding parameters in the reconstructed image data to obtain the predicted block of the current image block.
[0091] The reconstruction unit 205 is used to obtain a reconstructed block of the image to be decoded in the sample region by adding the reconstructed residual block to the prediction block, for example, by adding the residual value in the reconstructed residual block to the predicted value in the prediction block.
[0092] The filter unit 206 is used to filter the reconstructed blocks to obtain filtered blocks, which are decoded image blocks.
[0093] Specifically, in the embodiments of the present invention, the decoder 200 is used to carry out the decoding method described in the embodiments described later.
[0094] In the encoder 100 and decoder 200 of the embodiment of the present invention, the processing result of a certain process may be further processed before being output to the next process. For example, after processes such as interpolation filtering, motion vector derivation, or filtering, operations such as clipping or shifting may be performed on the processing result of the corresponding process.
[0095] In one example, the decoding process performed by the decoder 200 may include the following steps:
[0096] In step 31, the bitstream analysis unit 201 analyzes the prediction mode and the residual coding mode.
[0097] In step 32, the bitstream analysis unit 201 analyzes quantization-related values ββ(e.g., near values ββor QP values) based on the prediction mode and residual coding mode.
[0098] In step 33, the inverse quantization unit 202 inversely quantizes the residual coefficients based on the prediction mode and quantization-related values.
[0099] In step 34, the prediction processing unit 204 obtains the predicted value for each pixel of the current image block based on the prediction mode.
[0100] In step 35, the residual inverse transform unit 203 inverse transforms the residual coefficients to reconstruct the residual values ββof each pixel in the current image block.
[0101] In step 36, the reconstruction unit 205 obtains the reconstructed value based on the predicted and residual values ββof each pixel in the current image block.
[0102] Figures 1 to 4 are merely examples of embodiments of the present invention, and in some examples, the encoder 100, decoder 200, and encoding and decoding system 1 may include more or fewer components or units.
[0103] The following image encoding and decoding methods provided by embodiments of the present invention will be described below with reference to the drawings.
[0104] Figure 5 is a schematic flowchart of the image encoding method provided by the present invention. Optionally, the image encoding method may be applied to the encoding and decoding system 1 shown in Figure 1, and the image encoding method may be performed by the encoding side 10, specifically by the encoder 100 included in the encoding side 10, and as shown in Figure 5, the image encoding method provided by an embodiment of the present invention includes the following steps.
[0105] In S101, the encoding side obtains the maximum code length of the block to be encoded.
[0106] Here, the block to be encoded may include encoding units. Typically, the encoding side can encode image frames in the video to be encoded in units of encoding units.
[0107] Furthermore, the above-mentioned maximum code length is used to indicate the maximum code length that can be encoded for the block to be encoded. Note that, in order to prevent bitstream overflow, the maximum code length may be determined based on the size of the memory space of the encoding side's bitstream buffer in the encoding and decoding system 1 shown in Figure 1. Therefore, the maximum code length is the current maximum bitstream length that the encoding side is allowed to cache in its memory space for caching encoded bitstreams.
[0108] Optionally, the maximum code length is the sum of the length of the bitstream that can be stored in the remaining memory space and the length of the bitstream that the memory space outputs per unit time.
[0109] Optionally, the above maximum code length is less than the sum of the length of the bitstream that can be stored in the remaining memory space and the length of the bitstream that the memory space outputs per unit time.
[0110] For example, the maximum code length may be the sum of the length of the bitstream that can be stored in the remaining memory space and the length of the bitstream that the memory space outputs per unit time, minus the header information of the block to be encoded. The header information is data of a specific length at the beginning of the bitstream of each block to be encoded, and this data may be used to indicate the image parameters of the current block to be encoded. For example, the image parameters include one or more of the image complexity, prediction mode, target bit-per-pixel, and texture complexity of the current block to be encoded.
[0111] Furthermore, the bitstream buffer receives the bitstream of the current block encoded by the encoder and simultaneously outputs a certain amount of bitstream to the channel; that is, when the bitstream buffer receives the bitstream of the current block, a certain amount of bitstream flows out. In other words, the bitstream input to the bitstream buffer may occupy the memory space that the outgoing bitstream occupied before it flowed out. Therefore, the maximum code length may be the sum of the code length flowing out of the bitstream buffer per unit time and the code length that can be stored in the remaining space of the bitstream buffer.
[0112] Furthermore, the code length flowing out of the bitstream buffer per unit time may be determined based on the channel bandwidth through which the encoding side transmits the encoded bitstream.
[0113] In S102, the encoding side pre-encodes the block to be encoded based on the first mode to obtain a first code length for the block to be encoded.
[0114] The first mode may be a pre-configured prediction mode on the encoding side.
[0115] Optionally, the pre-configured prediction mode on the encoding side may include point-by-point prediction mode, in-frame prediction mode, block copy mode, original value mode, etc.
[0116] Here, the in-frame prediction mode is a prediction mode in which the reconstructed pixel values ββof the adjacent blocks surrounding the block to be predicted are used as the predicted values. The block copy prediction mode is a prediction mode in which the reconstructed pixel values ββof the surrounding coded (decoded) blocks (which are not necessarily adjacent) are used as the predicted values. During reconstruction, the original value mode is a reconstructed value mode that directly decodes a fixed bit width, i.e., a prediction mode without reference. The point-by-point prediction mode is a prediction mode in which the reconstructed pixel values ββof the adjacent pixels surrounding the pixel to be predicted are used as the predicted values ββof the pixel to be predicted.
[0117] Here, the point-by-point prediction mode may include one or more combinations of prediction methods such as vertical prediction, horizontal prediction, vertical average prediction, and horizontal average prediction.
[0118] Vertical prediction uses the reconstructed values ββof pixels above the pixel to be predicted (which may be adjacent pixels above or pixels that are not adjacent but are close in distance) to obtain the predicted value (PointPredData) of the pixel to be predicted. Horizontal prediction uses the reconstructed values ββof pixels to the left of the pixel to be predicted (which may be adjacent pixels to the left or pixels that are not adjacent but are close in distance) to obtain the predicted value of the pixel to be predicted. Vertical mean prediction uses the reconstructed values ββof pixels above and below the pixel to be predicted to obtain the predicted value of the pixel to be predicted. Horizontal mean prediction uses the reconstructed values ββof pixels on both the left and right sides of the pixel to be predicted to obtain the predicted value of the pixel to be predicted.
[0119] Specifically, the encoding side may predict the blocks to be encoded using each of the pre-set different prediction modes described above, and then determine the first mode based on the encoding performance after predicting the blocks to be encoded using the different prediction modes. Encoding performance may be the compression ratio, encoding efficiency, or encoding loss rate, etc.
[0120] For example, the encoding side may predict the blocks to be encoded using each of the different prediction modes, and after obtaining predicted blocks based on the different prediction modes, the encoding side may perform steps 22 to 25 described above to obtain the bitstreams of the blocks to be encoded in the different prediction modes. For example, the encoding side may determine the time it takes to obtain the bitstreams of the blocks to be encoded in the different prediction modes and determine the prediction mode with the shortest time as the first mode. That is, the encoding side may determine the prediction mode with the highest encoding efficiency as the first mode.
[0121] Therefore, the first code length may be the bitstream length of the block to be encoded based on the first mode, obtained by the encoding side predicting the block to be encoded in the first mode and then performing steps 22 to 25 described above after obtaining the predicted block.
[0122] In S103, if the first code length is greater than or equal to the maximum code length, the encoding side encodes the block to be encoded in fallback mode, and the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length.
[0123] Here, the blocks to be encoded in fallback mode are encoded, that is, the blocks to be encoded using a fixed code length encoding scheme based on a predetermined target code length, and the code length obtained by encoding the blocks to be encoded is the target code length. The target code length is smaller than the maximum code length.
[0124] Furthermore, the size of the bitstream buffer's memory space is constant. If the bitstream data input to the bitstream buffer is too large, and the data that needs to be temporarily stored in the bitstream buffer exceeds the size of that memory space, a bitstream "overflow" occurs. In this way, the excess data is lost, and therefore, the image information within the video image frame to be encoded is lost, making it impossible to completely decode the image frame based on the bitstream data output by the bitstream buffer.
[0125] If the first code length is greater than or equal to the maximum code length, that is, if the bitstream of the block to be encoded obtained based on the first mode is transmitted via a bitstream buffer, a bitstream "overflow" occurs in the bitstream buffer. To prevent a bitstream "overflow," the encoding side may encode the block to be encoded in fallback mode such that the code length obtained by encoding the block to be encoded is smaller than the maximum code length.
[0126] In some embodiments, if the current block to be encoded is encoded in fallback mode, the target code length of the block to be encoded is fixed, and therefore the complexity information in the header information of the block to be encoded does not need to be updated. This complexity information may be used to calculate the quantization parameters of the block to be encoded.
[0127] In some embodiments, the encoding side may select a MidPoint Prediction Fallback mode (MPPF mode) to predict the blocks to be encoded, obtain the predicted blocks, and then encode the blocks based on a fixed code length encoding scheme to obtain the bitstream of the blocks to be encoded.
[0128] Here, based on the midpoint prediction fallback mode, the encoding side may first divide the block to be encoded into multiple 2x2 pixel sub-image blocks, and it is necessary to calculate one midpoint for each 2x2 sub-image block, and the method for calculating the midpoint is as shown in equation (1) below. middle = 1 << (bitDepth - 1) Equation (1)
[0129] Here, bitDepth is the image bit width of the color component channel of the subblock to be encoded, and 1<< indicates a 1-bit left shift.
[0130] Furthermore, the encoding side may determine the mean value of the subblocks to be encoded.
[0131] In one case, if the current subblock cannot obtain a reconstructed image of the surrounding area, the mean value is the middle value mentioned above.
[0132] In other cases, the mean value is the average of the reconstructed values ββof the 2x1 pixel subblocks in the row prior to the subblock in question. If the reconstructed value of the 2x1 pixel subblock in the row prior to the subblock cannot be obtained, the average of the reconstructed values ββof the 2x2 subblock that was reconstructed immediately before the subblock in question is taken.
[0133] Furthermore, the encoding side may determine a bias value to limit the mean value of the subblock. The encoding side may clamp the mean using the bias value and the middle value to limit the mean value to a range of values ββconsisting 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 subblock to be encoded.
[0134] The bias value may be determined based on the following equation (2). bias=1<<(mppStepSize[k]-1) Equation (2)
[0135] Here, mppStepSize is used to specify the quantization step in the quantization process of one component of the block to be encoded, [k] is used to specify the k-th component of the block to be encoded, and 1<< represents a left shift of 1 bit.
[0136] Alternatively, based on the MPPF Mode, the residual value of the 2x2 pixel subblock may be calculated based on the order of pixel A in the upper left corner, pixel B in the upper right corner, pixel C in the lower left corner, and pixel D in the lower right corner, as shown in Figure 6.
[0137] Optionally, in the process of reconstructing the subblock to be encoded, the reconstructed values ββof each pixel may be determined sequentially in the order of pixel A in the upper left corner, pixel B in the upper right corner, pixel C in the lower left corner, and pixel D in the lower right corner.
[0138] In some embodiments, the block to be encoded may include one or more components.
[0139] Optionally, the block to be encoded may contain only the luminance component. Alternatively, the block to be encoded may contain three components, for example, luminance Y, chromaticity Cb, and chromaticity Cr (or three components of red R, green G, and blue B, or three components of luminance Y, chromaticity U, and chromaticity V). Alternatively, in addition to the above three components, the block to be encoded may also contain an Ξ± component, i.e., the block to be encoded may contain a total of four components. Here, the Ξ± component is the pixel transparency component. When the value of component Ξ± is 0, the pixel corresponding to the block to be encoded is transparent, and the image bit width of the Ξ± component is different from the other three components.
[0140] In some embodiments, the encoding side may determine the maximum code length that can be encoded for each component and, based on the determined maximum code length, decide whether or not to use a fallback mode for each component.
[0141] Optionally, the block to be encoded may include three components: a first chromaticity component, a second chromaticity component, and a luminance component. For example, the first chromaticity component, the second chromaticity component, and the luminance component may each consist of three components: luminance Y, chromaticity Cb, and chromaticity Cr, or luminance Y, chromaticity U, and chromaticity V.
[0142] Therefore, the encoding side may decide whether or not each of the three componentsβthe first chromaticity component, the second chromaticity component, and the luminance componentβneeds to be encoded in fallback mode.
[0143] In some embodiments, the encoding side may determine a first maximum chromaticity code length, a second maximum chromaticity code length, and a maximum luminance code length based on the maximum code length, according to a predetermined ratio.
[0144] The first maximum chromaticity code length is the maximum code length that can be encoded for the first chromaticity component of the block to be encoded. The second maximum chromaticity code length is the maximum code length that can be encoded for the second chromaticity component of the block to be encoded. The maximum luminance code length is the maximum code length that can be encoded for the luminance component of the block to be encoded. Note that the sum of the first maximum chromaticity code length, the second maximum chromaticity code length, and the maximum luminance code length is less than or equal to the maximum code length that can be encoded for the block to be encoded.
[0145] Here, the sum of the first maximum chromaticity code length, the second maximum chromaticity code length, and the maximum luminance code length may be the maximum code length of the block to be encoded or the code length that flows out of memory space per unit time.
[0146] Furthermore, since the code length flowing out of the bitstream buffer per unit time is smaller than the maximum code length mentioned above, the sum of the first maximum chromaticity code length, the second maximum chromaticity code length, and the maximum luminance code length may be the code length flowing out of memory space per unit time. Also, by determining the first maximum chromaticity code length, the second maximum chromaticity code length, and the maximum luminance code length based on the code length flowing out of memory space per unit time, the code length of the block to be encoded becomes smaller, the compression ratio increases, and the memory occupied by the bitstream buffer becomes smaller.
[0147] Optionally, the preset ratio of the first maximum chromaticity code length: second maximum chromaticity code length: maximum luminance code length may be 1:1:1, 2:1:1, or 4:1:1.
[0148] In some embodiments, if a block to be encoded contains multiple components and the multiple components of the block to be encoded share a fallback mode (sharing means that either any of the components use a fallback mode, or none of the components use a fallback mode), the encoder may decide whether or not to use a fallback mode for one of the components, and if it does use a fallback mode for one of the components, it will also use a fallback mode for the other components. Alternatively, if some of the multiple components of the block to be encoded share a fallback mode, the encoder may decide whether or not to use a fallback mode for one of those components, and whether or not to use a fallback mode for the other components excluding that component. Alternatively, if none of the multiple components of the block to be encoded share a fallback mode, the encoder may decide whether or not to use a fallback mode for each component individually.
[0149] Optionally, the encoding side may decide whether or not to encode the first chromaticity component, the second chromaticity component, and the luminance component in fallback mode based on one or more of the first maximum chromaticity code length, the second maximum chromaticity code length, and the maximum luminance code length. Several possible implementations are shown below.
[0150] Implementation method 1: The encoding side decides whether or not to encode the first chromaticity component, the second chromaticity component, and the luminance component in fallback mode based on one of the first maximum chromaticity code length, the second maximum chromaticity code length, and the maximum luminance code length.
[0151] Optionally, the encoding side may first decide whether or not to encode one of the first chromaticity component, the second chromaticity component, and the luminance component in fallback mode. If it decides to use fallback mode for that component, it may also decide to encode the other two components in fallback mode.
[0152] For example, the encoding side may first decide whether or not to encode the first chromaticity component in fallback mode based on the first maximum chromaticity code length, and if it decides to encode the first chromaticity component in fallback mode, it may also decide to encode the second chromaticity component and the luminance component in fallback mode.
[0153] Similarly, the encoding side may first decide whether or not to encode the second chromaticity component in fallback mode based on the second maximum chromaticity code length, or it may decide whether or not to encode the luminance component in fallback mode based on the maximum luminance code length.
[0154] Optionally, the process by which the encoding side determines whether to encode the first chromaticity component in fallback mode based on a first maximum chromaticity code length may specifically include the encoding side pre-encoding the first chromaticity component based on a first mode to obtain a first chromaticity code length for the first chromaticity component. Next, if the first chromaticity code length is greater than or equal to the first maximum chromaticity code length, it is decided to encode the first chromaticity component in fallback mode.
[0155] Similarly, the process by which the encoding side determines whether to encode the second chromaticity component in fallback mode based on the second maximum chromaticity code length may specifically include the encoding side pre-encoding the second chromaticity component based on the first mode to obtain the second chromaticity code length of the second chromaticity component. Next, if the second chromaticity code length is greater than or equal to the second maximum chromaticity code length, it is decided to encode the second chromaticity component in fallback mode.
[0156] Similarly, the process by which the encoding side determines whether to encode the luminance component in fallback mode based on the maximum luminance code length may specifically include the encoding side pre-encoding the luminance component based on a first mode to obtain the luminance code length of the luminance component. Next, if the luminance code length is greater than or equal to the maximum luminance code length, it is decided to encode the luminance component in fallback mode.
[0157] Here, the process of pre-coding the first chromaticity component, the second chromaticity component, or the luminance component based on the first mode may be described in the relevant explanation of pre-coding based on the first mode in step S102, and is therefore omitted here.
[0158] Implementation method 2: The encoding side determines whether to encode the first chromaticity component and the second chromaticity component in fallback mode based on the first maximum chromaticity code length or the second maximum chromaticity code length, and determines whether to encode the luminance component in fallback mode based on the maximum luminance code length.
[0159] Optionally, with respect to the first and second chromaticity components, the encoding side may first decide whether or not to encode the first chromaticity component in fallback mode, and if it decides to use fallback mode for the first chromaticity component, it may also decide to encode the second chromaticity component in fallback mode. Alternatively, the encoding side may first decide whether or not to encode the second chromaticity component in fallback mode, and if it decides to use fallback mode for the second chromaticity component, it may also decide to encode the first chromaticity component in fallback mode.
[0160] Here, the process by which the encoding side determines whether or not to encode the first chromaticity component in fallback mode based on the first maximum chromaticity code length, and the process by which the encoding side determines whether or not to encode the second chromaticity component in fallback mode based on the second maximum chromaticity code length, may be specifically described in the relevant explanation in the above implementation method 1.
[0161] In one possible implementation, the encoding side may decide whether or not to encode the luminance component in fallback mode based on the maximum luminance code length. For the process by which the encoding side decides whether or not to encode the luminance component in fallback mode based on the maximum luminance code length, refer to the relevant explanation in Implementation 1 above.
[0162] In another possible implementation, when the encoding side decides to encode the first and second chromaticity components in fallback mode for the luminance component, the encoding side may determine the code length for encoding the first and second chromaticity components in fallback mode, and then pre-encode the luminance component based on the first mode to obtain the luminance code length for the luminance component. Next, if the sum of the luminance code length and the code lengths for encoding the first and second chromaticity components in fallback mode is greater than or equal to the maximum code length of the block to be encoded, the encoding side decides to encode the luminance component in fallback mode.
[0163] Implementation method 3: The encoding side determines whether or not to encode the first chromaticity component in fallback mode based on the first maximum chromaticity code length, whether or not to encode the second chromaticity component in fallback mode based on the second maximum chromaticity code length, and whether or not to encode the luminance component in fallback mode based on the maximum luminance code length.
[0164] Here, the processes by which the encoding side determines whether or not to encode the first chromaticity component in fallback mode based on the first maximum chromaticity code length, the processes by which the encoding side determines whether or not to encode the second chromaticity component in fallback mode based on the second maximum chromaticity code length, and the processes by which the encoding side determines whether or not to encode the luminance component in fallback mode based on the maximum luminance code length may be specifically described in the relevant explanations in the above implementation method 1.
[0165] In some embodiments, if the block to be encoded contains three components: a first chromaticity component, a second chromaticity component, and a luminance component, the encoding side may divide the target code length of the block to be encoded into three subcode lengths according to the predetermined ratio, with one component corresponding to one subcode length. Next, based on the subcode length of each component, the components corresponding to each subcode length are encoded in fallback mode.
[0166] Optionally, for blocks to be encoded in a YCoCg image, the ratio of Y component:Co component:Cg component may be 2:1:1. For blocks to be encoded in a YUV444 image, the ratio of Y component:U component:V component may be 2:1:1. For blocks to be encoded in a YUV422 image, the ratio of Y component:U component:V component may be 2:1:1. For blocks to be encoded in a YUV420 image, the ratio of Y component:U component:V component may be 4:1:1. For blocks to be encoded in a YUV400 image, the block to be encoded contains only the luminance component Y.
[0167] Optionally, for a block to be encoded in an RGB image, the encoding side may divide the target code length of the block to be encoded into three subcode lengths based on the fact that the ratio of R component:G component:B component is 1:1:1, with each component corresponding to one subcode length.
[0168] In the encoding process, for RGB format image blocks, since the human eye is sensitive to image brightness, the image block is usually converted to a YCoCg format image block before encoding in order to improve the image effect as seen by the human eye. However, if the encoding side determines that any of the components of the converted YCoCg format image block need to use a fallback mode in the encoding process, it indicates that the code length required to encode the converted YCoCg format image block is long, and the encoding side may encode the RGB format image block. In some embodiments, since the subcode length of the component for which the fallback mode is selected is determined, there is no need to update the quantization parameters in the header information of the current component, and there is no need to update information that indicates the bitstream of the component, such as the complexity of the current component.
[0169] In some embodiments, if the first code length is less than the maximum code length, the encoding side may encode the original pixel values ββof the block to be encoded in original value mode. Optionally, the encoding side may encode the quantized and transformed values ββof the original pixel values ββof the block to be encoded using original value mode. In this way, the encoding side can improve the effectiveness of reconstructing the image of the block to be encoded by encoding the block to be encoded in original value mode.
[0170] In some embodiments, if the first code length is less than the maximum code length, the encoding side may encode the blocks to be encoded in residual coding mode.
[0171] In one example, the codeword for original value mode and the codeword for fallback mode are the same, where the codeword for original value mode is a number that indicates original value mode, and the codeword for fallback mode is a number that indicates fallback mode.
[0172] In another example, the codeword for fallback mode is unique. Note that in this case, the codeword for original value mode and the codeword for fallback mode are different.
[0173] In some embodiments, the above fallback mode may be used when no overflow occurs in the block to be encoded (i.e., the encoding side also uses the fallback mode when the first code length is smaller than the maximum code length), and this case will be described below.
[0174] Optionally, the encoder may encode blocks to be encoded with a code length value greater than the target code length if the memory occupied in the bitstream buffer is less than or equal to a first threshold of the total memory of the bitstream buffer. For example, the first threshold may be 30% of the total memory of the bitstream buffer, and therefore the encoder may encode blocks to be encoded with a target code length value greater than the target code length, for example, 1.5 times the target code length. Optionally, the encoder may encode blocks to be encoded with a code length value smaller than the target code length if the memory occupied in the bitstream buffer is greater than or equal to a second threshold of the total memory of the bitstream buffer. For example, the second threshold may be 85% of the total memory of the bitstream buffer, and therefore the encoder may encode blocks to be encoded with a target code length value smaller than the target code length, for example, 0.5 times the target code length. The encoder may encode blocks to be encoded with the target code length if the memory occupied in the bitstream buffer is less than the second threshold of the total memory of the bitstream buffer and greater than the first threshold.
[0175] In response to this, if the decryption side does not experience an overflow in the bitstream buffer, when decoding in fallback mode, the decryption side may determine the code length of the block to be decoded based on the amount of memory occupied in the bitstream buffer when encoding the block to be decoded.
[0176] As mentioned above, both the encoding and decoding sides record the state of the bitstream buffer. The encoding side updates the state of the bitstream buffer after encoding a block to be decoded, and the decoding side similarly updates the state of the bitstream buffer after analyzing this block to be decoded. The update of the bitstream buffer state is related to the target compression ratio and the size of the bitstream of the encoded / decoded block, and the target compression ratio is written to the image header bitstream. Therefore, if the encoding and decoding sides use the same update method when updating the state of the bitstream buffer, it can be guaranteed that the states of the encoded / decoded bitstream buffers will match.
[0177] Therefore, if both the encoding and decoding sides include bitstream buffers, the decoding / encoding sides may know the memory occupancy status of the bitstream buffers during encoding / decoding by recording the state of each other's bitstream buffers. If only the encoding side or only the decoding side includes bitstream buffers, the encoding side may know the memory occupancy status of the bitstream buffers during decoding by recording the state of the decoding side's bitstream buffers. Similarly, the decoding side may know the memory occupancy status of the bitstream buffers during encoding by recording the state of the encoding side's bitstream buffers.
[0178] The image encoding method provided in the embodiment of the present invention has at least the following beneficial effects. The method first pre-encodes the block to be encoded, compares the bitstream length obtained by pre-encoding with the maximum code length that can be occupied by the block to be encoded, and determines whether or not a bitstream overflow will occur based on the comparison result. Next, if it is determined that a bitstream overflow will occur, the block to be encoded is encoded in fallback mode to prevent the loss of image information of the block to be encoded.
[0179] In some embodiments, as shown in Figure 7, the process by which the encoding side encodes blocks to be encoded based on a fixed code length encoding scheme based on a fallback mode may be implemented as follows:
[0180] In S201, the encoding side divides the block to be encoded into one or more subblocks to be encoded.
[0181] As an option, in the process of encoding blocks to be encoded based on the fallback mode, each subblock to be encoded in the block to be encoded is usually determined and encoded using a fixed code length encoding scheme.
[0182] As an option, the fixed code length and the number of subblocks to be encoded in the block to be encoded satisfy the following equation (3). subblock num Γfixed len β¦fixed bit Formula (3)
[0183] Here, subblock num This is the number of subblocks to be encoded within the block to be encoded. len It has a fixed code length. bit This is the target code length of the block to be encoded.
[0184] Optionally, the target code length of the block to be encoded may be determined based on the target bits per pixel (BPP) of the block to be encoded.
[0185] Here, the target bit-per-pixel is used to indicate the code length required when encoding each pixel of the block to be encoded at the target compression ratio. The target bit-per-pixel may be determined based on the target compression ratio of the block to be encoded.
[0186] Optionally, the encoding side may obtain the target bit-by-bit pixel of the block to be encoded and determine the target code length of the block to be encoded as the product of the target bit-by-bit pixel and the number of pixels in the block to be encoded, based on the target bit-by-bit pixel and the number of pixels in the block to be encoded.
[0187] Optionally, the target code length may be less than the product of the target bit per pixel and the number of pixels in the block to be encoded.
[0188] For example, the target code length may be the product of the target bit per pixel and the number of pixels in the block to be encoded, minus the encoding cost required to encode the fallback mode. Here, the result of the encoding cost analysis is used to indicate that the encoding mode is the fallback mode. For example, the result of the encoding cost analysis may be the fallback mode identifier (fallback mode codeword).
[0189] In some embodiments, if the block to be encoded contains multiple components, the encoding side 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.
[0190] For example, if, based on the relevant explanation in step S103 above, the block to be encoded may include three components: a first chromaticity component, a second chromaticity component, and a luminance component, the encoding side may divide the target code length of the block to be encoded into three subcode lengths according to a predetermined ratio, with one component corresponding to one subcode length. Next, the encoding side may divide each component into one or more sub-encoded blocks based on the subcode length corresponding to each component.
[0191] Taking the example that the predetermined ratio of Y component:Co component:Cg component is 2:1:1, the subcode length of the Co component may be determined based on the following equation (4). Subcode length of Co component = [(Target code length / 2) - 3 Γ coding cost of fallback mode] / 2 Equation (4)
[0192] The ratio of the subcode length of the Cg component to the subcode length of the Co component relative to the target code length is the same, and the subcode length of the Cg component may also be determined based on equation (4).
[0193] Furthermore, the subcode length of the Y component may be obtained by subtracting the subcode lengths of the Co component and the Cg component from the target code length.
[0194] In some other embodiments, if the block to be encoded contains multiple components, the encoding side may first divide the block to be encoded into one or more sub-encoded blocks, and then, for each sub-encoded block, further divide the sub-encoded block into sub-blocks for each component according to the ratio between each component.
[0195] Below, we will explain the process of dividing a block to be encoded into one or more sub-encoded blocks as an example.
[0196] In one possible implementation, the encoding side divides the block to be encoded into one or more subblocks of a predetermined size.
[0197] Here, the pre-set size of the subblock to be encoded may be 2x1 pixels, 2x2 pixels, or the like.
[0198] Specifically, the encoding side may determine the number of subblocks to be encoded in the block to be encoded based on the size of the subblocks to be encoded, and may divide the block to be encoded into one or more subblocks to be encoded based on the number of subblocks to be encoded.
[0199] As an example, the block to be encoded includes two rows of pixels A1-A16 and B1-B16, as shown in Figure 8. If the size of one subblock to be encoded is 2x2 pixels, the encoding side may determine that the number of subblocks to be encoded is 8. For example, the subblocks to be encoded may be an image block consisting of A1, A2, B1, B2, an image block consisting of A3, A4, B3, B4, and so on.
[0200] Optionally, after the encoding side determines the number of subblocks to be encoded, a first fixed code length for encoding the subblocks to be encoded may be determined based on equation (3) above.
[0201] In another possible implementation, the encoding side divides the block to be encoded with a predetermined first fixed code length into one or more subblocks to be encoded.
[0202] Optionally, the first fixed code length may be a preset code length value for encoding the subblock to be encoded.
[0203] Optionally, if the subblock to be encoded contains only one pixel, the first fixed code length may be the target bit-per-pixel value described above.
[0204] Specifically, the encoding side may determine the number of subblocks to be encoded in the block to be encoded based on the target code length of the block to be encoded and a first fixed code length for encoding the subblocks to be encoded, based on the above formula (3). Next, based on the number of subblocks to be encoded, the block to be encoded is divided into one or more subblocks to be encoded.
[0205] Optionally, according to equation (3) above, the number of subblocks to be encoded may be an integer value obtained by dividing the target code length of the block to be encoded by the first fixed code length and truncating the result.
[0206] For example, 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 number of subblocks to be encoded is 5, which is obtained by truncating 23 / 4. If the number of subblocks is odd, 16x2 is divided into 5 subblocks to be encoded, with sizes of 3x2 pixels, 3x2 pixels, 3x2 pixels, 3x2 pixels, and 4x2 pixels, respectively.
[0207] If the size of the block to be encoded is 16 Γ 2 pixels, the first fixed code length is 4, and the target code length of the block to be encoded is 25, then according to equation (3) above, the number of subblocks to be encoded is 6, obtained by truncating 25 / 4. If the number of subblocks is even, one 16 Γ 2 image block may first be divided into two 16 Γ 1 pixel image blocks, and then each 16 Γ 1 pixel image block may be divided into a 5 Γ 1 pixel image block, a 5 Γ 1 pixel image block, and a 6 Γ 1 pixel image block.
[0208] Furthermore, since the predicted values ββof the subblocks to be encoded may be determined based on the reconfigured pixels of the previous row, if the subblock to be encoded contains pixels from two rows, the encoding side may control the number of divisions of the subblock to be encoded to be even in order to ensure that each subblock to be encoded is related to the pixels of the first row of the block to be encoded. In this way, since the predicted values ββof the pixels of the first row may be determined based on the reconfigured pixels of the previous row, the predicted values ββof the pixels of the second row of the subblock to be encoded may be determined based on the reconfigured pixels of the first row. Furthermore, if the subblock to be encoded contains pixels from Z rows, the encoding side may control the number of divisions of the subblock to be encoded to be an integer multiple of Z in order to ensure that each encoded subblock is related to the pixels of the first row of the block to be encoded.
[0209] Optionally, the first fixed code length is a non-negative integer. For example, if the first fixed code length is the target bit per pixel, and the block to be encoded is a 16x2 pixel image block, the encoder divides it into two 16x1 pixel subblocks to be encoded. In one example, if the target bit per pixel is 3, the first fixed code length of both 16x1 pixel image blocks is 3. In another example, if the target bit per pixel is 2.5, the encoder may decide that the first fixed code length of the first subblock to be encoded is 3, and the first fixed code length of the second subblock is 2.
[0210] In S202, the encoding side encodes multiple subblocks to be encoded using a fixed code length encoding scheme based on the first fixed code length.
[0211] Here, the bitstream length obtained by encoding each of the multiple subblocks to be encoded is the first fixed code length.
[0212] For any subblock to be encoded, the encoding side determines the original value and predicted value of the pixels in that subblock.
[0213] In some embodiments, the encoding side may determine the average of the reconstructed values ββof pixels in the previous row adjacent to the subblock to be encoded as the predicted value of the subblock to be encoded.
[0214] Optionally, the predicted value of the subblock to be encoded may be determined based on the following equation (5). Predicted value = (Sum of reconstruction values ββof each reference pixel + 0.5 Γ S) / S Equation (5)
[0215] Here, S is the number of reference pixels, and S is a positive integer.
[0216] Furthermore, the purpose of adding 0.5 Γ S to the sum of the reconstructed values ββof each reference pixel in the process of calculating the predicted values ββis to round the average value of the reconstructed values.
[0217] For example, as shown in Figure 9(a), the current encoding block has a size of 16 Γ 2 pixels and includes two rows of pixels A1 to A16 and B1 to B16, with the reconstructed pixels of the previous row including C0 to C16. If the subblock to be encoded is an image block consisting of A1, A2, A3, B1, B2, B3, then the reference pixels of the previous row corresponding to the subblock to be encoded are C1, C2, C3, and therefore the predicted value of the subblock to be encoded is (reconstructed value of C1 + reconstructed value of C2 + reconstructed value of C3 + 1.5) / 3.
[0218] Optionally, if the reconstructed values ββof the pixels in the row preceding the subblock to be encoded cannot be obtained, the encoding side may fill the pixels in the row preceding the subblock to be encoded with the reconstructed pixels of the previous column. Exemplaryly, as shown in Figure 9(b), the encoding side fills all the pixels in the previous row with the reconstructed values ββof pixel A0 in the previous column, and therefore, if the subblock to be encoded is an image block consisting of A1, A2, A3, B1, B2, B3, the reference pixels in the row preceding the subblock to be encoded are the reconstructed values ββof the three A0s, and the encoding side may determine the predicted values ββof the subblock to be encoded based on these three reconstructed A0s.
[0219] Alternatively, as shown in Figure 9(c), the encoding side may fill all pixels in the previous row with the reconstructed value of pixel B0 in the previous column. Similarly, if the subblock to be encoded is an image block consisting of A1, A2, A3, B1, B2, and B3, the reference pixels in the previous row corresponding to the subblock to be encoded are the reconstructed values ββof the three B0s, and the encoding side may determine the predicted value of the subblock to be encoded based on these three reconstructed B0s.
[0220] Alternatively, as shown in Figure 9(d), the encoding side alternately fills all pixels in the previous row with the reconstructed values ββof pixels A0 and B0 of the previous column.
[0221] Furthermore, the encoding side may determine the average of the reconstructed values ββafter filling of the previous row adjacent to the subblock to be encoded as the predicted value of the subblock to be encoded.
[0222] In some other embodiments, the encoding side may determine the average of the reconstructed values ββof pixels in the previous column adjacent to the subblock to be encoded as the predicted value of the subblock to be encoded.
[0223] For example, as shown in Figure 9(a), the current encoding block has a size of 16 Γ 2 pixels and includes two rows of pixels A1 to A16 and B1 to B16, and the reconstructed pixels in the previous column include C0, A0, and B0. If the subblock to be encoded is an image block consisting of A1, A2, A3, B1, B2, and B3, then the reference pixels in the previous column corresponding to the subblock to be encoded are A0 and B0, and therefore the predicted value of the subblock to be encoded is (reconstructed value of A0 + reconstructed value of B0 + 1) / 2.
[0224] Here, the method for determining the predicted value of the subblock to be encoded is merely an example, and the encoding side may determine the predicted value of the subblock to be encoded using any of the prediction modes described in step S102, or any other possible prediction mode. Optionally, the encoding side may determine the predicted value of the subblock to be encoded using a pre-set prediction mode.
[0225] In one possible implementation, the encoding side quantizes the residual value of the subblock to be encoded, encodes the quantized residual value, and obtains the bitstream of the subblock to be encoded. Here, the residual value is the difference between the original value and the predicted value of the subblock to be encoded.
[0226] Optionally, a transformation process may be performed on the residual values ββof the subblocks to be encoded before quantizing them.
[0227] Furthermore, the subblock to be encoded may be reconstructed so that it can be used as a reference for the predicted values ββof other subblocks to be encoded. When reconstructing the subblock to be encoded, the encoding side may inversely quantize the residual values ββto obtain inversely quantized residual values, and reconstruct the subblock to be encoded based on the inversely quantized residual values ββand predicted values.
[0228] In another possible implementation, the encoder may quantize the high-order bit value of the image bit width of the subblock to be encoded, and then encode the high-order bit value of the quantized image bit width. Here, the high-order bit value of the image bit width is the first N bits of the binary number corresponding to the image bit width, where N is a positive integer. For example, N may be any number such as 4 or 5. Optionally, the high-order bit value may be a value indicating the color of the subblock to be encoded.
[0229] Furthermore, the subblock to be encoded may be reconstructed so that it can be used as a reference for the predicted values ββof other subblocks to be encoded. When reconstructing the subblock to be encoded, the encoding side may analyze the bitstream of the image block corresponding to the subblock to be encoded to obtain the upper bit value of the image bit width corresponding to the subblock to be encoded, dequantize the upper bit value of the image bit width to obtain the upper bit value of the dequantized image bit width, and reconstruct the subblock to be encoded by combining it with the lower bit value of the predicted value.
[0230] The lower bits of the predicted value are used to indicate the value of the last M bits of the binary number corresponding to the predicted value, where M is a positive integer. For example, M may be any possible number such as 4 or 5. Optionally, the lower bits may also be a value indicating the texture in the predicted value, where the sum of N and M is the image bit width of the subblock to be decoded, and N is the first fixed code length.
[0231] As an example of the lower bit value of the predicted value, if the image bit width (code length of the original value) is 8 and the first fixed code length N of the subblock to be encoded is 4, then both M and N are 4. If the predicted value of the subblock to be encoded is 127 and the binary code is 01111111, then the lower bit value of the last M bits (the last 4 bits) is 1111, i.e., 15, and therefore the decimal number corresponding to the last 4 bits of the predicted value is 15.
[0232] In another possible implementation, the encoder may quantize the lower bits of the image bit width of the subblock to be encoded, and then encode the lower bits of the quantized image bit width, where the lower bits of the image bit width are the last N bits of the binary number corresponding to the image bit width, where N is a positive integer. Optionally, the lower bits may also be a value indicating the texture of the subblock to be encoded.
[0233] Furthermore, the subblock to be encoded may be reconstructed so that it can be used as a reference for the predicted values ββof other subblocks to be encoded. When reconstructing the subblock to be encoded, the encoding side may analyze the bitstream of the image block corresponding to the subblock to be encoded to obtain the lower bit value of the image bit width corresponding to the subblock to be encoded, dequantize the lower bit value of the image bit width to obtain the lower bit value of the dequantized image bit width, and reconstruct the subblock to be encoded by combining this with a value obtained by padding the upper bit value of the predicted value with zeros.
[0234] The upper bits of the predicted value are 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 upper bits may also be a value indicating the color in the predicted value. Here, the sum of N and M is the image bit width of the subblock to be encoded, where N is the first fixed code length.
[0235] As an example of the upper bit value of the predicted value, if the image bit width (code length of the original value) is 8 and the first fixed code length N of the subblock to be encoded is 4, then both M and N are 4. If the predicted value of the subblock to be encoded is 127 and the corresponding binary code is 01111111, then the upper bit value of the first M bits (the first 4 bits) is 0111, and the binary code obtained by adding zeros to the following 8-M bits is 01110000, which means the decimal number corresponding to the upper bit value with zeros added is 112.
[0236] Optionally, for each subblock to be encoded, if the coefficient value of the subblock to be encoded (e.g., residual value, original value, etc.) lies at the boundary of the representable range of the first fixed code length, a suffix may be added during the transmission process of the bitstream of the subblock to indicate the coefficient value of the subblock to be encoded. For example, if the first fixed code length of the subblock to be encoded is 3, and the coefficient value range representable by 3 bits of binary data is [0,7], then if the current coefficient value is in the range [1,8], the encoder may add a suffix 0 to the bitstream of the subblock to be encoded. Here, the suffix may be determined according to a pre-configured suffix setting rule. Exemplary pre-configured suffix setting rules may include possible rules such as suffix 0 indicating a negative number, suffix 1 indicating an integer, and suffix 0 indicating that the representable coefficient value range increases by one to the right (for example, the range [0,7] increases by one to the right to become [1,8]). Based on this embodiment, first, the block to be encoded may be divided into a plurality of subblocks to be encoded, and each subblock to be encoded may be encoded with a first fixed code length based on a fixed code length encoding scheme. This makes the bitstream after the block to be encoded has been encoded smaller than the maximum code length that can be cached by the bitstream buffer, thereby preventing bitstream overflow.
[0237] In some embodiments, the present invention further provides an image decoding method, which corresponds to the encoding method shown in Figure 5, and as shown in Figure 10, which is a schematic flowchart of the image decoding method provided by the present invention, which may be performed by a decoder 200 or by a decoding side (for example, a decoding side 20 shown in Figure 1) that supports the functions of the decoder 200, and here, the case in which the decoder 200 performs the decoding method will be described as an example, and the image decoding method includes the following steps.
[0238] In S301, the decoding side determines whether or not a fallback mode is used for the image block corresponding to the block to be decoded, based on the bitstream of the block to be decoded.
[0239] Here, the code length obtained when an 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. For further explanation regarding the maximum code length, please refer to the relevant explanation in step S101 above, and the explanation will be omitted here.
[0240] Optionally, based on the bitstream of the block to be decoded, the decoder may analyze the complexity information of the block to be decoded from the header information of the block to be decoded and determine the quantization step of the block to be decoded. Alternatively, the decoder may analyze the quantization step of the block to be decoded from the header information of the block to be decoded. Alternatively, the decoder may determine the quantization step of the block to be decoded based on the target bit-by-bit pixel.
[0241] In some embodiments, the block to be decoded may contain one or more components.
[0242] Optionally, the block to be decoded may contain only the luminance component. Alternatively, the block to be decoded may contain three components, for example, luminance Y, chromaticity Cb, and chromaticity Cr (or three components of red R, green G, and blue B, or three components of luminance Y, chromaticity U, and chromaticity V). Alternatively, in addition to the above three components, the block to be decoded may also contain an Ξ± component, i.e., the block to be decoded may contain a total of four components. Here, the Ξ± component is the pixel transparency component. When the value of component Ξ± is 0, the pixel corresponding to the block to be decoded is transparent, and the image bit width of the Ξ± component is different from the other three components.
[0243] In some embodiments, if the block to be decoded contains multiple components and the multiple components of the block to be decoded share a fallback mode (sharing a fallback mode means that either the fallback mode is used for any of the multiple components or none of the multiple components use a fallback mode), the decoder may decide only whether or not to use a fallback mode for one of the components, and if a fallback mode is used for one of the components, then a fallback mode will also be used for the other components. Alternatively, if some of the multiple components of the block to be decoded share a fallback mode, the decoder may decide only whether or not to use a fallback mode for one of those components, and whether or not to use a fallback mode for the other components excluding that component. Alternatively, if none of the multiple components of the block to be decoded share a fallback mode, the decoder may decide whether or not to use a fallback mode for each component individually.
[0244] Specifically, the bitstream of the block to be decoded may include an identifier to indicate the sharing status of the fallback mode. Therefore, the decoder may determine which components share the fallback mode based on the identifier and decide whether or not the fallback mode is used for each component.
[0245] For example, if the block to be decoded includes a first chromaticity component, a second chromaticity component, and a luminance component, the decoder may decide whether or not a fallback mode is used for encoding the first chromaticity component, the second chromaticity component, and the luminance component, respectively.
[0246] For example, in accordance with implementation method 1 in step S103 above, if implementation method 1 determines whether or not to use a fallback mode for each component when encoding the block to be decoded, the decoding side may analyze the bitstream of one of the components, either the first chromaticity component, the second chromaticity component, or the luminance component, and determine whether or not a fallback mode is used when encoding the first chromaticity component, the second chromaticity component, and the luminance component.
[0247] Specifically, if the decoding side analyzes the bitstream of one of the componentsβthe first chromaticity component, the second chromaticity component, or the luminance componentβand determines that a fallback mode is used for that component during encoding, the decoding side may also determine that a fallback mode is used for any of the first chromaticity component, the second chromaticity component, and the luminance component during encoding, and does not need to determine whether or not a fallback mode is used for the other components based on the bitstreams of the other components.
[0248] In another example, corresponding to implementation method 2 in step S103 above, if implementation method 2 determines whether or not to use a fallback mode for each component when encoding the block to be decoded, the decoding side may determine whether or not to use a fallback mode for the first chromaticity component and the second chromaticity component during encoding by analyzing the bitstream of the first chromaticity component or the second chromaticity component.
[0249] Specifically, if the decoding side analyzes the bitstream of either the first or second chromaticity component and determines that a fallback mode should be used for that component during encoding, the decoding side may also determine that a fallback mode should be used for both the first and second chromaticity components during encoding. Furthermore, the decoding side must analyze the bitstream of the luminance component and determine that a fallback mode should be used for the luminance component during encoding.
[0250] In another example, corresponding to implementation method 3 in step S103 above, if implementation method 3 determines whether or not to use a fallback mode for each component when encoding the block to be decoded, the decoding side analyzes the bitstreams of the first chromaticity component, the second chromaticity component, and the luminance component to determine whether or not a fallback mode is used for encoding the first chromaticity component, the second chromaticity component, and the luminance component, respectively.
[0251] In some embodiments, the codeword for original value mode and the codeword for fallback mode are the same. For example, if both the codeword for original value mode and fallback mode are the first codeword, the decoder may analyze the bitstream of the block to be decoded to obtain the first codeword, and then determine whether fallback mode or original value mode is used for the block to be decoded.
[0252] Furthermore, the decryption side may decide whether or not to use a fallback mode for the block to be decrypted, based on the size of the memory space occupied in the bitstream buffer.
[0253] If the decoding side determines that the memory space occupied in the bitstream buffer when encoding the image block to be decoded is greater than a first preset memory value, i.e., an overflow will occur, the decoding side decides that the fallback mode will be used for the image block corresponding to the block to be decoded. Otherwise, the decoding side decides that the original value mode will be used for the image block corresponding to the block to be decoded.
[0254] The size of the first pre-set memory value may be determined based on the actual memory capacity of the bitstream buffer, and is not limited thereto.
[0255] Optionally, the decoding side may determine that the bitstream length of the block to be encoded is the sum of the image bit widths of all components multiplied by the number of pixels, and the decoding side may analyze the bitstream of the block to be decoded and reconstruct the image block of the block to be decoded based on the original value mode.
[0256] In some embodiments, before performing step S302 below, the decoder may determine the prediction mode used for the image block corresponding to the block to be decoded if a fallback mode is used for the image block corresponding to the block to be decoded. Here, the prediction mode may be any of the prediction modes described in step S102, or any other possible prediction mode.
[0257] In one implementation, if the block to be decoded contains one component, the decoder may analyze the bitstream of the block to be decoded to determine the prediction mode for that block. Alternatively, the decoder may determine a pre-configured prediction mode as the prediction mode for the block to be decoded, wherein the pre-configured prediction mode is the same as the pre-configured prediction mode used by the encoding side in the prediction process.
[0258] In another implementation, if the block to be decoded contains multiple components, the same prediction mode may be used for multiple components of the block to be decoded. Therefore, the decoder may determine the prediction mode for only one component, and this prediction mode is the prediction mode for all components of the block to be decoded. Alternatively, the same prediction mode may be used for some of the multiple components of the block to be decoded. In this case, the decoder may determine the prediction mode for only one of those components, and the prediction modes for the other components excluding that component. Alternatively, the decoder may determine the prediction mode for each component individually.
[0259] Here, the process by which the decoding side determines the prediction mode of one component may be described in detail in the other implementation described above, and will be omitted here.
[0260] In S302, the decoding side obtains a first fixed code length if the fallback mode is used for the image block corresponding to the block to be decoded.
[0261] Here, the first fixed code length is the code length of one subblock to be decoded, and one block to be decoded may contain one or more subblocks to be decoded.
[0262] Optionally, the first fixed code length may be a preset code length value, or the target bit-per-pixel value when encoding the block to be decoded. The target bit-per-pixel value is used to indicate the code length required when the encoding side encodes each pixel of the block to be encoded at the target compression ratio.
[0263] In some embodiments, the decryption side may divide the block to be decrypted into a plurality of subblocks to be decrypted based on the code length of the block to be decrypted and a first fixed code length.
[0264] Here, the number of subblocks to be decrypted may be determined based on the following equation (6).
[0265] The number of sub - blocks to be decoded in the above - mentioned fixed symbol length and the block to be decoded satisfies the following formula (6). The number of sub - blocks to be decoded Γ the first fixed symbol length = the symbol length of the block to be decoded Formula (6)
[0266] Next, the decoding side may divide the block to be decoded into a plurality of sub - blocks to be decoded based on the calculated number of sub - blocks to be decoded.
[0267] In some embodiments, the decoding side may divide the block to be decoded into a plurality of sub - blocks to be decoded based on a preset size.
[0268] Here, for the process of the decoding side dividing the block to be decoded into a plurality of sub - blocks to be decoded, reference may be made to the related description of step S201 above, and the description is omitted here.
[0269] In some embodiments, when the block to be decoded includes a plurality of components, the decoding side may first divide the block to be decoded into a plurality of components, and then divide each component into one or more sub - blocks to be decoded.
[0270] Exemplarily, the block to be decoded includes three components: a first chrominance component, a second chrominance component, and a luminance component. The decoding side may divide the symbol length of the block to be decoded into three sub - symbol lengths according to a preset ratio, and one component corresponds to one sub - symbol length. Next, based on the sub - symbol length of each component, for each component, according to the above - possible implementation method, the component may be divided into one or more sub - blocks to be decoded.
[0271] Optionally, for blocks to be decoded in a YCoCg image, the pre-set ratio of Y component:Co component:Cg component may be 2:1:1. For blocks to be decoded in a YUV444 image, the pre-set ratio of Y component:U component:V component may be 2:1:1. For blocks to be decoded in a YUV422 image, the pre-set ratio of Y component:U component:V component may be 2:1:1. For blocks to be decoded in a YUV420 image, the pre-set ratio of Y component:U component:V component may be 4:1:1. For blocks to be decoded in a YUV400 image, the block to be decoded contains only the luminance component Y.
[0272] Optionally, for blocks to be decoded in an RGB image, the decoder may divide the total code length of the block to be decoded into three subcode lengths based on the pre-set ratio of R component:G component:B component being 1:1:1, with each component corresponding to one subcode length.
[0273] In the image encoding and decoding process, for RGB format image blocks, since the human eye is sensitive to image brightness, it is common practice to convert RGB format image blocks to YCoCg format image blocks before encoding and decoding in order to improve the image effect as seen by the human eye. However, if the image block corresponding to the acquired block to be decoded is in RGB format, the encoding side may determine that the code length required to encode the converted YCoCg format image block is long, and the decoding side may directly decode the bitstreams of each RGB component to obtain an RGB format image block.
[0274] Next, the decoding side may determine the first fixed code length of each component based on the number of subblocks to be decoded and the subcode length of each component. For a specific process, please refer to step S201 above, and the explanation will be omitted here.
[0275] In some other embodiments, if the block to be decoded contains multiple components, the decoder may first divide the block to be decoded into one or more sub-decoded blocks, and then, for each sub-decoded block, further divide it into sub-blocks for each component according to the ratio between each component.
[0276] Optionally, based on the relevant explanation in step S103 above, the fallback mode may be used when no overflow has occurred in the block to be encoded. In this case, the decoder may determine that the code length value of the block to be decoded is a code length value greater than the target code length, provided that the memory occupied in the bitstream buffer is less than or equal to a first threshold of the total memory of the bitstream buffer. For example, the first threshold may be 30% of the total memory of the bitstream buffer. Thus, the decoder may determine that the code length value of the block to be decoded is 1.5 times the target code length. Optionally, the decoder may determine that the code length value of the block to be decoded is a code length value less than the target code length, provided that the memory occupied in the bitstream buffer is greater than or equal to a second threshold of the total memory of the bitstream buffer. For example, the second threshold may be 85% of the total memory of the bitstream buffer. Thus, the decoder may determine that the code length value of the block to be decoded is 0.5 times the target code length. The decoding side may determine that the target code length is the code length value of the block to be decoded if the memory occupied in the bitstream buffer is less than a second threshold of the total memory of the bitstream buffer and greater than a first threshold.
[0277] Optionally, information regarding whether or not an overflow will occur may be added to the bitstream of the block to be decoded. Therefore, the decoder may determine whether or not an overflow will occur when encoding the image block based on the bitstream of the block to be decoded.
[0278] Optionally, the decoder may determine the first fixed code length based on the quantization step of the block to be decoded, which is determined based on the header information of the block to be decoded, or based on the target bit-by-bit pixel, or determined by other similar methods.
[0279] In S303, the decoding side analyzes the bitstream of the block to be decoded based on the first fixed code length and decodes the block to be decoded.
[0280] In one possible implementation, the decoding side may obtain a first fixed code length and, based on the first fixed code length, analyze the original pixel values ββof the image block corresponding to each subblock to be decoded.
[0281] Optionally, if the encoding side quantizes the original pixel values ββof the image block, the decoding side may dequantize the values ββanalyzed from the bitstream based on the acquired quantization step.
[0282] Optionally, if the encoding side transforms the original pixel values ββof the image block before quantization, the decoding side may dequantize the values ββanalyzed from the bitstream and then further dequantize the dequantized values.
[0283] In one example, the decoding side may analyze the bitstream of the image block corresponding to the subblock to be decoded to obtain the upper bit value of the reconstructed pixel value corresponding to the subblock to be decoded, dequantize the upper bit value of the reconstructed pixel value to obtain the upper bit value of the dequantized reconstructed pixel value, and reconstruct the subblock to be decoded by combining it with the lower bit value of the predicted value.
[0284] Here, the upper bit values ββof the reconstructed pixel values ββand the lower bit values ββof the predicted values ββmay be explained in the relevant section of step S202 above, and the explanation is omitted here.
[0285] In another example, the decoding side may analyze the bit stream of the image block corresponding to the sub-block to be decoded, obtain the lower bit value of the reconstructed pixel value corresponding to the sub-block to be decoded, inverse quantize the lower bit value of the reconstructed pixel value to obtain the lower bit value of the inverse quantized reconstructed pixel value, and combine it with the value obtained by supplementing zeros to the upper bit value of the predicted value to reconstruct the sub-block to be decoded.
[0286] Here, the lower bit value of the reconstructed pixel value and the upper bit value of the predicted value may refer to the related description in step S202 above, and the description is omitted here.
[0287] In another possible implementation, the decoding side may obtain a fixed code length and analyze the residual value of each sub-block to be decoded based on the fixed code length. For any sub-block to be decoded, obtain the predicted value of the sub-block to be decoded.
[0288] Next, based on the predicted value and the residual value of the sub-block to be decoded, reconstruct the image block of the block to be decoded.
[0289] Optionally, when the encoding side quantizes the residual value of the image block, the decoding side may inverse quantize the value analyzed from the bit stream based on the obtained quantization step.
[0290] Optionally, when the encoding side converts the original pixel value of the image block before quantization, the decoding side may inverse quantize the value analyzed from the bit stream and then further inverse transform the inverse quantized value.
[0291] Optionally, for each subblock to be decoded, if the coefficient value of the subblock to be decoded (e.g., residual value, original value, etc.), analyzed based on the first fixed code length, falls on the boundary of the representable range of the first fixed code length, a suffix indicating the coefficient value of the subblock to be decoded may be included in the transmission process of the bitstream of the subblock. For example, if the first fixed code length of the subblock to be decoded is 3, the coefficient value range representable by 3 bits of binary data is [0,7], so if the bitstream of the subblock includes a suffix of 0, it can indicate that the current coefficient value is in the range [1,8]. The suffix may be analyzed according to a pre-configured suffix setting rule. The pre-configured suffix setting rule on the decoding side is the same as the pre-configured suffix setting rule on the encoding side.
[0292] Based on the above embodiment, if the encoding side uses fallback mode, the decoding side may decode the blocks to be decoded in fallback mode, thereby preventing bitstream overflow. This prevents the loss of image information in the blocks to be decoded.
[0293] In some embodiments, the image decoding process provided by the present invention may be specifically represented as a logic flowchart as shown in Figure 11. As shown in Figure 11, the decoding process may include the following steps.
[0294] In S1, the decryption side analyzes the header information of the block to be decrypted and determines the quantization step of the block to be decrypted.
[0295] In S2, the decryption side analyzes the codeword that indicates the prediction mode in the first decryption component of the block to be decrypted, and determines whether or not it is the first codeword.
[0296] Here, the first decoded component is one of several components of the block to be decoded. Also, if the codeword for indicating the original value mode and the codeword for indicating the fallback mode are the same, and both are the first codeword, the decoder may, after analyzing the bitstream of the block to be decoded and obtaining the first codeword, decide that either the fallback mode or the original value mode will be used for the block to be decoded.
[0297] If the decoding side determines that the codeword for indicating the prediction mode in the first decoded component is the first codeword, it performs the following step S3.
[0298] Otherwise, if the decoding side determines that the codeword for indicating the prediction mode in the first decoded component is not the first codeword, it performs the following step S13.
[0299] In S3, the decoding side determines whether or not the original value mode is used for the first decoded component, based on the state of the bitstream buffer.
[0300] Referring to the relevant explanation in step S301 above, the decryption side may decide whether to use fallback mode or original value mode for the block to be decrypted based on the size of the memory space occupied in the bitstream buffer, but the explanation is omitted here.
[0301] If the decoding side determines that the original value mode is to be used for the first decoded component, it performs the following step S4.
[0302] Otherwise, if the decryption side determines that the original value mode is not used for the first decrypted component, it performs the following step S6.
[0303] In S4, the decoding side determines the first fixed code length as the image bit width of the image block indicated by the first decoded component, and decodes the first decoded component based on the original value mode.
[0304] Here, the process for determining the first fixed code length may be explained by referring to step S302 above, and will not be explained here.
[0305] In S5, the decryption side decrypts the other components of the block to be decrypted based on the original value mode.
[0306] In S6, the decoding side decides that the fallback mode will be used for the first decoded component and decides whether or not the fallback mode will be used for the other components.
[0307] For any component in which fallback mode is used, the decoder performs step S7.
[0308] For any component in which the fallback mode is not used, the decoding side decodes the component by performing the following step S13.
[0309] In S7, the decoding side determines the prediction mode to be used for the component.
[0310] Here, the prediction modes used for each component of the block to be decoded may be the same or different, and the specific process may be explained in the relevant description in step S301 above, which will be omitted here.
[0311] In S8, the decoding side analyzes the relative position information of the predicted block in the prediction mode based on the prediction mode used for the component, and determines the predicted value of the component.
[0312] In S9, the decoding side determines the total code length assigned to the component, divides the component into multiple subblocks to be decoded, and determines the fixed code length of each subblock to be decoded.
[0313] The decoding side may determine the fixed code length of each subblock to be decoded based on the quantization step of the block to be decoded. Alternatively, the decoding side may determine the fixed code length of each subblock to be decoded by analyzing the bitstream of each subblock to be decoded.
[0314] In S10, the residual value of each component is analyzed based on the fixed code length of the subblock to be decoded.
[0315] In S11, the residual value is inversely quantized based on the quantization step of the component.
[0316] In S12, the reconstructed value of the component is determined based on the predicted value of the component and the inversely quantized residual value.
[0317] In S13, the prediction mode for the component is determined, other information about the component is successfully analyzed, and the reconstruction of the component is completed.
[0318] When the decryption side performs step S13, it may refer to the decryption process described in steps 31 to 36 above, but this will not be explained here.
[0319] In some embodiments, the present invention further provides an image encoding method as shown in Figure 12, which may be performed by an encoder 100 or by an encoding side (for example, an encoding side 10 shown in Figure 1) that supports the functions of the encoder 100, and here, the case in which the encoding side performs the encoding method is described as an example, and the image encoding method includes the following steps.
[0320] In S401, the encoding side obtains the minimum code length of the block to be encoded.
[0321] Here, the minimum code length is the minimum bitstream length currently allowed to be cached in the memory space used by the encoder to cache the encoded bitstream.
[0322] The blocks to be encoded may also be called encoding units. Typically, when encoding image frames in a video to be encoded, the encoding unit is used as the unit.
[0323] Furthermore, the minimum code length is used to indicate the minimum code length that can be encoded for the block to be encoded. Note that, in order to prevent bitstream underflow, the minimum code length may be determined based on the size of the memory space of the encoding buffer.
[0324] Optionally, the sum of the difference between the bitstream length stored in memory and the code length output by memory per unit time, plus the minimum code length, is greater than or equal to the code length output by memory per unit time.
[0325] The bitstream buffer receives the bitstream of the current block encoded by the encoder, and at the same time, a certain amount of bitstream flows out. If the bitstream in the current bitstream buffer is empty, or if the bitstream length in the current bitstream buffer is smaller than the code length that flows out of the buffer per unit time, bitstream "underflow" occurs, and the bitstream cannot be transmitted normally. The minimum code length may be the code length that guarantees the normal transmission of the bitstream in the bitstream buffer.
[0326] In S402, the encoding side pre-encodes the block to be encoded based on the first mode to obtain a first code length for the block to be encoded.
[0327] The first mode may be one of several prediction modes on the encoding side, and the first code length is the length of the bitstream obtained after encoding the block to be encoded.
[0328] Here, a detailed explanation of step S402 may be provided by referring to the related explanation in step S102 above, and the explanation will be omitted here.
[0329] In S403, if the first code length is less than or equal to the minimum code length, the encoding side encodes the blocks to be encoded in fallback mode, and the code length obtained by encoding the blocks to be encoded based on the fallback mode is greater than or equal to the minimum code length.
[0330] Here, a detailed explanation of step S403 may be provided by referring to the related explanation in step S103 above, and the explanation will be omitted here.
[0331] The image encoding method provided by an embodiment of the present invention has at least the following beneficial effects. The method first pre-encodes the block to be encoded, compares the bitstream length obtained by pre-encoding with the minimum code length that can be occupied by the block to be encoded, and determines whether or not bitstream underflow will occur based on the comparison result. Next, if it is determined that bitstream underflow may occur, the method encodes the block to be encoded in fallback mode to ensure that the bitstream in the bitstream buffer is transmitted normally.
[0332] In some embodiments, the present invention further provides an image decoding method as shown in Figure 13, which corresponds to the encoding method shown in Figure 12, and which may be performed by a decoder 200 or by a decoding side (for example, a decoding side 20 shown in Figure 1) that supports the functions of the decoder 200. Here, we will describe the case in which the decoder 200 performs the decoding method, and the image decoding method includes the following steps.
[0333] In S501, the decoding side determines, based on the bitstream of the block to be decoded, whether or not a fallback mode is used during encoding for the image block corresponding to the block to be decoded.
[0334] Here, the code length obtained when an 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 bitstream length that is allowed to be cached in the memory space for caching encoded bitstreams when the image block corresponding to the block to be decoded is encoded.
[0335] Here, the specific implementation of step S501 may be explained by referring to the related explanation of step S301 above, and the explanation is omitted here.
[0336] In S502, the decoding side obtains a first fixed code length based on the bitstream if a fallback mode is used during encoding for the image block corresponding to the block to be decoded.
[0337] The first fixed code length is the code length of one subblock to be decoded, and one block to be decoded may contain multiple subblocks to be decoded.
[0338] Here, the specific implementation of step S502 may be explained by referring to the related explanation in step S302 above, and the explanation is omitted here.
[0339] In S503, the decoding side analyzes the bitstream based on the first fixed code length and decodes the block to be decoded.
[0340] Here, the specific implementation of step S503 may be explained by referring to the related explanation in step S303 above, and the explanation is omitted here.
[0341] In some embodiments, the present invention further provides an image encoding method as shown in Figure 14, which may be performed by an encoder 100 or by an encoding side (for example, an encoding side 10 shown in Figure 1) that supports the functions of the encoder 100, and here, the case in which the encoding side performs the encoding method is described as an example, and the image encoding method includes the following steps.
[0342] In S601, the encoding side obtains the maximum code length of the block to be encoded.
[0343] Here, the maximum code length is the maximum bitstream length currently allowed to be cached in the memory space used by the encoder to cache the encoded bitstream.
[0344] Here, the specific implementation of step S601 may be explained by referring to the related explanation in step S101 above, and the explanation is omitted here.
[0345] In S602, the encoding side pre-encodes the block to be encoded based on the first mode to obtain a first code length for the block to be encoded.
[0346] Here, the first mode is one of several prediction modes on the encoding side, and the first code length is the length of the bitstream obtained after encoding the block to be encoded.
[0347] Here, the specific implementation of step S602 may be explained by referring to the related explanation in step S102 above, and the explanation is omitted here.
[0348] In S603, if the first code length is greater than or equal to the maximum code length, the encoding side encodes the blocks to be encoded in the second mode based on the skip residual mode.
[0349] Here, based on the skip residual mode, the code length obtained by encoding the block to be encoded in the second mode is less than or equal to the maximum code length, and the second mode may be one of several prediction modes on the encoding side.
[0350] Furthermore, in skip residual mode, there is no need to encode (decode) the residual coefficients. In this case, the residual value of a pixel in the current image block is considered to be 0, meaning that the reconstructed value of each pixel is equal to the predicted value of that pixel. Therefore, the encoding side only needs to encode information indicating the second mode. For example, the identifier of the second mode is encoded to obtain a bitstream of the block to be encoded with the identifier of the second mode appended.
[0351] Furthermore, for pixels with large residual values, the encoding and decoding processes become distorted when using the skip residual mode. Therefore, in practice, the encoding side does not select the skip residual mode when the residual value is large. However, if the first code length is greater than or equal to the maximum code length, the encoding side uses the skip residual mode, i.e., forced skip residual encoding mode, regardless of the magnitude of the residual value, in order to prevent bitstream overflow.
[0352] Optionally, the second mode may be a target mode. Here, the target mode may be the optimal prediction mode, in which case encoding the blocks to be encoded based on the target mode can maintain better encoding performance.
[0353] In another possible implementation, the second mode may be the same as the first mode. Optionally, the second mode may be a pre-configured prediction mode.
[0354] To make it easier to understand, the encoding side may pre-set a second mode that has better encoding performance based on the skip residual mode. If the first code length is greater than or equal to the maximum code length, the blocks to be encoded are encoded using the pre-set second mode, regardless of which prediction mode is optimal.
[0355] Optionally, the encoding side may encode the blocks to be encoded using multiple prediction modes, such as the point-by-point prediction mode, in-frame prediction mode, block copy mode, and original value mode, based on the skip residual mode, and determine the optimal prediction mode based on the skip residual mode.
[0356] To make it clear, when encoding in skip residual mode based on this encoding method, it is possible to prevent bitstream overflow.
[0357] In some embodiments, the present invention further provides an image decoding method as shown in Figure 15, which corresponds to the encoding method shown in Figure 14, and which may be performed by a decoder 200 or by a decoding side (for example, a decoding side 20 shown in Figure 1) that supports the functions of the decoder 200, and here, the case in which the decoder 200 performs the decoding method is described as an example, and the image decoding method includes the following steps.
[0358] In S701, the decryption side analyzes the bitstream of the block to be decrypted and obtains a second mode of instruction information to predict which block to decrypt.
[0359] Here, the second mode may be any one of a plurality of prediction modes, and the description of the second mode in the image coding method described above may be referred to. The instruction information for the second mode may be an identifier for the second mode.
[0360] In S702, the decryption side determines the predicted values ββof the blocks to be decrypted based on the second mode.
[0361] Here, the specific process by which the decryption side determines the predicted values ββof the blocks to be decrypted may be determined based on the second mode.
[0362] For example, the second mode is the vertical mean prediction mode. Therefore, the decoding side may obtain the predicted value of the pixel to be predicted using the reconstructed values ββof the pixels above and below the pixel to be predicted. These will not be listed here.
[0363] In S703, the decryption side determines the predicted value of the block to be decrypted as the reconstructed value of the block to be decrypted.
[0364] In some embodiments, the present invention further provides another method for determining the predicted value of an image block, which is described below.
[0365] The encoding side may first obtain the reconstructed pixels around the block to be encoded, including several possible cases:
[0366] Case 1: The encoding side cannot obtain the reconfigured pixels of the row preceding the block to be encoded, nor can it obtain the reconfigured pixels of the column preceding the block to be encoded.
[0367] In this case, the encoding side may determine the predicted value of the block to be encoded based on the prediction mode in Huffman Table 1. The prediction modes in Huffman Table 1 include point-by-point prediction mode, original value mode, and fallback mode. If the reconfigured pixels of the row preceding the block to be encoded cannot be obtained, or if the reconfigured pixels of the column preceding the block to be encoded cannot be obtained, the encoding side may determine the predicted value of the block to be encoded based on the point-by-point prediction mode, original value mode, or fallback mode.
[0368] Here, Huffman coding is an entropy coding algorithm for lossless data compression. The Huffman table is a code table that generates codewords based on probability. If the coding side provides n prediction modes, the Huffman table can generate coded codewords corresponding to each of these n prediction modes based on the selection probability of each prediction mode. Codewords for prediction modes with a high selection probability are short, and codewords for prediction modes with a low selection probability are long, thus reducing the average bitrate after coding. Note that Huffman table 1 includes the data symbols before coding for point-by-point prediction mode, original value mode, or fallback mode, and the coded codewords corresponding to each mode.
[0369] Case 2: The encoding side can obtain the reconfigured pixels of the row before the block to be encoded, but cannot obtain the reconfigured pixels of the column before the block to be encoded.
[0370] The encoding side may use the reconfigured pixels of the previous row as reference pixels and determine the predicted values ββof the blocks to be encoded based on the prediction mode in Huffman Table 2. Here, the prediction modes in Huffman Table 2 include point-by-point prediction mode, original value mode, fallback mode, and other in-frame prediction modes that can use the previous row as reference pixels, as well as the encoded codewords corresponding to each mode.
[0371] Case 3: The encoding side can obtain the reconfigured pixels of the column preceding the block to be encoded, but cannot obtain the reconfigured pixels of the row preceding the block to be encoded.
[0372] The encoding side may use the reconfigured pixels of the previous column as reference pixels and determine the predicted values ββof the blocks to be encoded based on the prediction mode in Huffman Table 3. Here, the prediction modes in Huffman Table 3 include the prediction mode that uses the previous column as reference pixels, among point-by-point prediction mode, block prediction mode, original value mode, fallback mode, and in-frame prediction mode, and the encoded codeword corresponding to each mode.
[0373] Case 4: The encoding side can obtain the reconfigured pixels of the previous column and the reconfigured pixels of the previous row of the block to be encoded.
[0374] The encoding side may use the reconfigured pixels of the previous column and / or row as reference pixels and determine the predicted values ββof the blocks to be encoded based on the prediction modes in Huffman Table 4. Here, the prediction modes in Huffman Table 4 may include all possible prediction modes. For an enumeration and description of these prediction modes, refer to the relevant description in step S102 above, and the description is omitted here.
[0375] In response, when the decoding side determines the predicted value of the block to be decoded, it may first obtain the reconstructed pixels surrounding the block to be decoded, and similarly, there are four possible cases corresponding to the encoding side.
[0376] Specifically, in the case of Case 1, if the decryption side cannot obtain the reconfigured pixels of the row preceding the block to be decrypted, and cannot obtain the reconfigured pixels of the column preceding the block to be decrypted, the decryption side may query Huffman Table 1 based on a codeword indicating the prediction mode in the block to be decrypted to determine the prediction mode and then determine the predicted value of the block to be decrypted. In the case of Case 2, if the decryption side can obtain the reconfigured pixels of the row preceding the block to be decrypted, but cannot obtain the reconfigured pixels of the column preceding the block to be decrypted, the decryption side may query Huffman Table 2 based on a codeword indicating the prediction mode in the block to be decrypted to determine the prediction mode and then determine the predicted value of the block to be decrypted. In the case of Case 3, if the decryption side can obtain the reconfigured pixels of the column preceding the block to be decrypted, but cannot obtain the reconfigured pixels of the row preceding the block to be decrypted, the decryption side may query Huffman Table 3 based on a codeword indicating the prediction mode in the block to be decrypted to determine the prediction mode and then determine the predicted value of the block to be decrypted. In the case corresponding to Case 4, if the decryption side can obtain the reconfigured pixels of the column and row before the block to be decrypted, the decryption side may query the Huffman table 3 based on a codeword indicating the prediction mode in the block to be decrypted to determine the prediction mode and determine the predicted value of the block to be decrypted.
[0377] In some embodiments, semi-fixed-length coding schemes for coding the subblocks to be coded in each of the above embodiments are further provided. As long as it does not conflict with the above embodiments, semi-fixed-length coding schemes may be used in the methods provided.
[0378] Here, a semi-fixed-length coding scheme means that for one or more subblocks to be coded from a block to be coded, the coding side can code each subblock based on a different code length. For a subblock to be coded that contains multiple pixels, the coding side may code each pixel with a single fixed code length and place the codeword coded with that fixed code length as a prefix in the bitstream of the subblock to be coded.
[0379] In response, the decoding side may analyze the prefix of each subblock to be decoded and analyze the fixed code length of each subblock to be decoded, and for one subblock to be decoded, the decoding side may decode each pixel based on the fixed code length value obtained by analyzing the subblock to be decoded.
[0380] The following describes the encoding and decoding devices provided by embodiments of the present invention.
[0381] In one example, any of the decoding devices provided in the embodiments of the present invention may be the decoding side 20 or decoder 200 in Figure 1. In another example, any of the encoding devices provided below may be the encoding side 10 or encoder 100 in Figure 1. Further explanation of these is omitted below.
[0382] Figure 16 is a schematic diagram of an image encoding device 1600 provided by the present invention, and any embodiment of the above encoding method can be performed by the encoding device 1600. The image encoding device 1600 includes an acquisition module 1601, a processing module 1602, and an encoding module 1603. The acquisition module 1601 is used to acquire the maximum code length of the block to be encoded, the maximum code length being the current maximum bitstream length that can be cached in the memory space for the encoding side to cache encoded bitstreams. The processing module 1602 is used to obtain a first code length of the block to be encoded by pre-encoding the block to be encoded based on a first mode, the first mode being one of a plurality of prediction modes of the encoding side, and the first code length being the length of the bitstream obtained after encoding the block to be encoded. The encoding module 1603 is used to encode the block to be encoded in fallback mode if the first code length is greater than or equal to the maximum code length, and the code length obtained by encoding the block to be encoded based on fallback mode is less than or equal to the maximum code length.
[0383] For a more detailed explanation of the acquisition module 1601, the processing module 1602, and the encoding module 1603, a more detailed explanation of their respective technical features, and an explanation of their beneficial effects, please refer to the corresponding examples of the methods described above. The explanation is omitted here.
[0384] Figure 17 is a schematic diagram of an image decoding device 1700 provided by the present invention, and any embodiment of the above decoding method can be performed by the decoding device 1700. The image decoding device 1700 includes a decision module 1701 and an analysis module 1702. The decision module 1701 is used to determine whether or not a fallback mode is used for the image block corresponding to the block to be decoded, based on the bitstream of the block to be decoded. The decision module 1701 is further used to obtain a first fixed code length if a fallback mode is used for the image block corresponding to the block to be decoded. The analysis module 1702 is used to decode the block to be decoded by analyzing the bitstream of the block to be decoded based on the first fixed code length.
[0385] For a more detailed explanation of the decision module 1701 and the analysis module 1702 described above, a more detailed explanation of their respective technical features, and an explanation of their beneficial effects, please refer to the corresponding examples of the methods described above. The explanation is omitted here.
[0386] Figure 18 is a schematic diagram of an image encoding device 1800 provided by the present invention, and any embodiment of the above encoding method can be performed by the encoding device 1800. The image encoding device 1800 includes an acquisition module 1801, a processing module 1802, and an encoding module 1803. The acquisition module 1801 is used to acquire the minimum code length of a block to be encoded, the minimum code length being the minimum bitstream length currently allowed to be cached in the memory space for the encoding side to cache encoded bitstreams. The processing module 1802 is used to obtain a first code length of a block to be encoded by pre-encoding the block to be encoded based on a first mode, the first mode being one of a plurality of prediction modes of the encoding side, and the first code length being the length of the bitstream obtained after encoding the block to be encoded. The encoding module 1803 is used to encode the block to be encoded in fallback mode if the first code length is less than or equal to the minimum code length, and the code length obtained by encoding the block to be encoded based on fallback mode is greater than or equal to the minimum code length.
[0387] For a more detailed explanation of the acquisition module 1801, the processing module 1802, and the encoding module 1803, a more detailed explanation of their respective technical features, and an explanation of their beneficial effects, please refer to the corresponding examples of the methods described above. The explanation is omitted here.
[0388] Figure 19 is a schematic diagram of an image decoding device 1900 provided by the present invention, and any embodiment of the above decoding method can be performed by the decoding device 1900. The image decoding device 1900 includes a decision module 1901 and an analysis module 1902. The decision module 1901 is used to determine, based on the bitstream of the block to be decoded, whether or not a fallback mode is used when encoding the image block corresponding to the block to be decoded, and 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 bitstream length that is allowed to be cached in the memory space for caching the encoded bitstream when the image block is encoded. The decision module 1901 is further used to obtain a first fixed code length based on the bitstream when a fallback mode is used when encoding the image block corresponding to the block to be decoded, and the first fixed code length is the code length of one subblock to be decoded, and one block to be decoded may include multiple subblocks to be decoded. The analysis module 1902 is used to analyze the bitstream of the block to be decoded based on a first fixed code length and to decode the block to be decoded.
[0389] For a more detailed explanation of the decision module 1901 and the analysis module 1902 described above, a more detailed explanation of their respective technical features, and an explanation of their beneficial effects, please refer to the corresponding examples of the methods described above. The explanation is omitted here.
[0390] Figure 20 is a schematic diagram of an image encoding device 2000 provided by the present invention, and any embodiment of the above encoding method can be performed 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 acquire the maximum code length of the block to be encoded, the maximum code length being the maximum bitstream length currently allowed to be cached in the memory space for the encoding side to cache the encoded bitstream. The processing module 2002 is used 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, the first mode being one of a plurality of prediction modes of the encoding side, and the first code length being the length of the bitstream obtained after encoding the block to be encoded. The encoding module 2003 is used to encode blocks to be encoded in the second mode based on the skip residual mode when the first code length is greater than or equal to the maximum code length, and the code length obtained by encoding the blocks to be encoded in the second mode based on the skip residual mode is less than or equal to the maximum code length, and the second mode is one of several prediction modes on the encoding side.
[0391] For a more detailed explanation of the acquisition module 2001, the processing module 2002, and the encoding module 2003, a more detailed explanation of their respective technical features, and an explanation of their beneficial effects, please refer to the corresponding examples of the methods described above.
[0392] Figure 21 is a schematic diagram of an image decoding device 2100 provided by the present invention, and any embodiment of the above decoding method can be performed by the decoding device 2100. The image decoding device 2100 includes an analysis module 2101, a prediction module 2102, and a reconstruction module 2103. The analysis module 2101 is used to analyze the bitstream of the block to be decoded and to obtain a second mode identifier 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.
[0393] For a more detailed explanation of the analysis module 2101, the prediction module 2102, and the reconstruction module 2103, a more detailed explanation of their respective technical features, and an explanation of their beneficial effects, please refer to the corresponding examples of the methods described above. The explanation is omitted here.
[0394] The present invention further provides an electronic device 2200 for performing an embodiment of any of the above-described image encoding / decoding methods. As shown in Figure 22, Figure 22 is a schematic diagram of the electronic device 2200 provided by the present invention, which includes a processor 2201 and a communication interface 2202. The processor 2201 and the communication interface 2202 are coupled to each other. To understand this, the communication interface 2202 may be a transceiver or an input / output interface.
[0395] In one example, the electronic device 2200 may further include a memory 2203 for storing instructions to be executed by the processor 2201, or for storing input data necessary for the processor 2201 to execute the instructions, or for storing data generated after the processor 2201 has executed the instructions.
[0396] In embodiments of the present invention, the specific connection medium between the communication interface 2202, processor 2201, and memory 2203 is not limited. In embodiments of the present invention, in Figure 22, the communication interface 2202, processor 2201, and memory 2203 are connected via a bus 2204, which is shown as a thick line in Figure 22. The connection methods between other components are illustrative and not limited to these. The bus may include an address bus, a data bus, a control bus, etc. For simplicity of representation, only one thick line is shown in Figure 22, but this does not mean that there is only one bus or only one type of bus.
[0397] Memory 2203 may 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 embodiments of the present invention, and the processor 2201 executes various functional applications and data processing by executing the software programs and modules stored in memory 2203, thereby implementing any of the image decoding method or image encoding method provided above. The communication interface 2202 may be used for signaling and data communication with other devices. In the present invention, the electronic device 2200 may have a plurality of communication interfaces 2202.
[0398] To make it clear, the processor in the embodiments of the present invention may be a central processing unit (CPU), a neural processing unit (NPU), or a graphics processing unit (GPU), or it may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or another programmable logic device, a transistor logic device, a hardware component, or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0399] The steps of the method in embodiments of the present invention may be implemented by hardware, or by a processor executing software instructions. The software instructions may consist of corresponding software modules, which may be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, removable 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 and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and storage medium may be located within an ASIC, which may be located within a network device or terminal device. Of course, the processor and storage medium may also exist as independent components within the network device or terminal device.
[0400] Embodiments of the present invention further provide an encoding and decoding system including an encoding side and a decoding side, wherein the encoding side may be used to perform any of the image encoding methods provided above, and the decoding side may be used to perform a corresponding image decoding method.
[0401] In the embodiments described above, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer programs or instructions are loaded on a computer and executed, all or part of the processes or functions described in the embodiments of the present invention are executed. The computer may be a general-purpose computer, a dedicated computer, a computer network, a network device, user equipment, or other programmable device. The computer programs or instructions 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 programs or instructions may be transmitted by wire or wirelessly from one website, computer, server, or data center to another website, computer, server, or data center. The computer-readable storage medium may be any available medium accessible by a computer, or a data storage device such as a server or data center that integrates one or more available media. The aforementioned usable media may be magnetic media such as floppy disks, hard disks, or magnetic tapes, optical media such as digital video discs (DVDs), or semiconductor media such as solid state drives (SSDs).
[0402] In each embodiment of the present invention, unless otherwise specified and logically contradictory, the terminology and / or descriptions between different embodiments are consistent and can be referenced to one another, and the technical features of different embodiments can be combined according to their internal logical relationships to form new embodiments.
[0403] To ensure clarity, the various numerical numbers related to the embodiments of the present invention are provided solely for illustrative purposes and are not intended to limit the scope of the embodiments. The magnitude of the numbers for each process described above does not indicate the execution order; the execution order of each process should be determined by its function and internal logic.
Claims
1. An image decoding method performed by the decoding side, A step of determining whether a fallback mode is used during decoding for an image block corresponding to a block to be decoded, based on the bitstream 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 bitstream length that is allowed to be cached in the bitstream buffer. When the fallback mode is used during decoding for an image block corresponding to the block to be decoded, the step of obtaining a first fixed code length, wherein the first fixed code length is the code length of one subblock to be decoded, and the block to be decoded includes one or more subblocks to be decoded. The process includes the step of analyzing the bitstream based on the first fixed code length and decoding the block to be decoded, The method further includes the step of reconstructing the image block of the block to be decoded based on the original value mode, where the codeword for indicating the prediction mode in the bitstream of the block to be decoded is a first codeword, and if a fallback mode is not used during decoding for the image block corresponding to the block to be decoded, the first codeword is used to indicate the fallback mode or the original value mode, and whether to adopt the fallback mode or the original value mode is determined based on the size of the memory space occupied in the bitstream buffer. An image decoding method characterized by the following:
2. The block to be decoded includes one or more components, and the decoding side determines whether the fallback mode is used for each of the one or more components. The method according to feature 1.
3. The block to be decoded includes a first chromaticity component, a second chromaticity component, and a luminance component, and the step of determining whether a fallback mode is used during decoding for the image block corresponding to the block to be decoded, based on the bitstream of the block to be decoded, is: The process includes the step of analyzing the bitstream of any of the first chromaticity component, the second chromaticity component, or the luminance component to determine whether the fallback mode is used for the first chromaticity component, the second chromaticity component, and the luminance component. The method according to feature 1.
4. The sum of the code length of the first chromaticity component, the code length of the second chromaticity component, and the code length of the luminance component is the code length of the block to be decoded, and the code length of the luminance component is greater than the code length of the first chromaticity component or the code length of the second chromaticity component. The method according to feature 3.
5. The step of analyzing the bitstream and decoding the block to be decoded based on the first fixed code length is: The steps include: analyzing the bitstream of each subblock to be decoded in the block to be decoded based on the first fixed code length to obtain the residual value of each subblock to be decoded; The process includes the step of reconstructing each subblock to be decoded based on the predicted value and residual value of each subblock to be decoded to obtain a reconstructed block of each subblock to be decoded. The method according to feature 1.
6. An image encoding method performed by the encoding side, A step of obtaining the maximum code length of a block to be encoded, wherein the maximum code length is the maximum bitstream length that is allowed to be cached in the bitstream buffer. A step of obtaining a first code length of the block to be encoded by pre-encoding the block to be encoded based on a first mode, wherein the first mode is one of a plurality of prediction modes on the encoding side, and the first code length is the length of the bitstream obtained after encoding the block to be encoded. The method includes the step of encoding the block to be encoded in fallback mode if 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, The first codeword is a codeword used to indicate the prediction mode in the bitstream transmitted to the decoding side, and the first codeword is used to indicate the fallback mode or the original value mode, and whether to adopt the fallback mode or the original value mode is determined by the decoding side based on the size of the memory space occupied in the bitstream buffer. An image encoding method characterized by the following.
7. An image decoding method performed by the decoding side, A step of determining whether a fallback mode is used when decoding an image block corresponding to a block to be decoded, based on the bitstream of the block to be decoded, wherein the code length obtained when the image block is decoded 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 bitstream length that is allowed to be cached in the bitstream buffer. Steps include: obtaining a first fixed code length based on the bitstream when a fallback mode is used during decoding for an image block corresponding to the block to be decoded, wherein the first fixed code length is the code length of one subblock to be decoded, and the block to be decoded includes one or more subblocks to be decoded; The process includes the step of analyzing the bitstream based on the first fixed code length and decoding the block to be decoded, The method further includes the step of reconstructing the image block of the block to be decoded based on the original value mode, where the codeword for indicating the prediction mode in the bitstream of the block to be decoded is a first codeword, and if a fallback mode is not used during decoding for the image block corresponding to the block to be decoded, the first codeword is used to indicate the fallback mode or the original value mode, and whether to adopt the fallback mode or the original value mode is determined based on the size of the memory space occupied in the bitstream buffer. An image decoding method characterized by the following:
8. Based on the bitstream of the block to be decoded, it is determined whether or not a fallback mode is used during decoding for the image block corresponding to the block to be decoded. A decision module for obtaining a first fixed code length based on the bitstream, wherein when a fallback mode is used during decoding for an image block corresponding to the block to be decoded, the code length obtained when the image block is decoded based on the fallback mode is less than or equal to the maximum code length of the block to be decoded, the maximum code length is the maximum bitstream length that is allowed to be cached in the bitstream buffer, the first fixed code length is the code length of one subblock to be decoded, and the block to be decoded includes one or more subblocks to be decoded. Includes an analysis module for analyzing the bitstream and decoding the block to be decoded based on the first fixed code length, The method further includes the step of reconstructing the image block of the block to be decoded based on the original value mode, where the codeword for indicating the prediction mode in the bitstream of the block to be decoded is a first codeword, and if a fallback mode is not used during decoding for the image block corresponding to the block to be decoded, the first codeword is used to indicate the fallback mode or the original value mode, and whether to adopt the fallback mode or the original value mode is determined based on the size of the memory space occupied in the bitstream buffer. An image decoding device characterized by the following features.
9. An acquisition module for obtaining the maximum code length of a block to be encoded, wherein the maximum code length is the maximum bitstream length that is allowed to be cached in a bitstream buffer; A processing module for obtaining a first code length of a block to be encoded by pre-encoding the block to be encoded based on a first mode, wherein the first mode is one of a plurality of prediction modes on the encoding side, and the first code length is the length of the bitstream obtained after encoding the block to be encoded. The encoding module includes, when the first code length is greater than or equal to the maximum code length, an encoding module for encoding the block to be encoded in 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, The first codeword is a codeword used to indicate the prediction mode in the bitstream transmitted to the decoding side, and the first codeword is used to indicate the fallback mode or the original value mode, and whether to adopt the fallback mode or the original value mode is determined by the decoding side based on the size of the memory space occupied in the bitstream buffer. An image coding device characterized by the following:
10. Based on the bitstream of the block to be decoded, it is determined whether or not a fallback mode is used during decoding for the image block corresponding to the block to be decoded. When a fallback mode is used during decoding for an image block corresponding to the block to be decoded, a decision module for obtaining a first fixed code length based on the bitstream, wherein the code length obtained when the image block is decoded based on the fallback mode is greater than or equal to the minimum code length of the block to be decoded, the minimum code length is the minimum bitstream length that is allowed to be cached in the bitstream buffer, the first fixed code length is the code length of one subblock to be decoded, and the block to be decoded includes one or more subblocks to be decoded, Includes an analysis module for analyzing the bitstream and decoding the block to be decoded based on the first fixed code length, The method further includes the step of reconstructing the image block of the block to be decoded based on the original value mode, where the codeword for indicating the prediction mode in the bitstream of the block to be decoded is a first codeword, and if a fallback mode is not used during decoding for the image block corresponding to the block to be decoded, the first codeword is used to indicate the fallback mode or the original value mode, and whether to adopt the fallback mode or the original value mode is determined based on the size of the memory space occupied in the bitstream buffer. An image decoding device characterized by the following features.
11. An electronic device comprising a processor and 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 and to carry out the method according to any one of claims 1 to 6. An electronic device characterized by the following features.
12. A computer-readable storage medium in which a computer program or instruction is stored, wherein when the computer program or instruction is executed by an electronic device, the method according to any one of claims 1 to 6 is performed. A computer-readable storage medium characterized by the following features.
13. An electronic device comprising a processor and 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 and to carry out the method according to claim 7. An electronic device characterized by the following features.
14. A computer-readable storage medium in which a computer program or instruction is stored, wherein when the computer program or instruction is executed by an electronic device, the method according to claim 7 is performed. A computer-readable storage medium characterized by the following features.