Image encoding and decoding method and device

By adopting fallback mode and fixed code length technology in the image encoding and decoding process, the problem of code stream overflow is solved and the integrity of the image information and the stability of the encoding and decoding process are ensured.

CN116074539BActive Publication Date: 2024-10-29HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210894255.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-27
Publication Date
2024-10-29
Estimated Expiration
2042-07-27

AI Technical Summary

Technical Problem

During the image encoding and decoding process, it is difficult to effectively control the code rate generated by the encoder with existing technology, resulting in code stream overflow, which in turn leads to loss of image information.

Method used

By adopting fallback mode at the decoding end and encoding end, the fixed code length of the block to be decoded or the block to be encoded is determined based on the remaining storage space of the code stream buffer to avoid code stream overflow. The specific method includes parsing the code stream of the block to be decoded at the decoding end. If the code stream exceeds the set overflow line, determine the fixed code length of each component and decode based on the code length; at the encoding end, if the code stream of the block to be decoded is If the code length exceeds the maximum code length, the fallback mode is used for encoding to ensure that the code stream is within the allowed storage space.

Benefits of technology

It effectively avoids code stream overflow and underflow, ensures the integrity of image information, and improves the stability and effect of the image encoding and decoding process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116074539B_ABST
    Figure CN116074539B_ABST
Patent Text Reader

Abstract

The present application provides an image encoding and decoding method and device, which relates to the field of video encoding and decoding and can be used to avoid code stream overflow. The specific method includes: parsing the code stream of the block to be decoded, if the code stream of the block to be decoded includes a first code word, then determining whether the image block corresponding to the block to be decoded adopts a fallback mode; if the image block corresponding to the block to be decoded adopts a fallback mode, and the code length stored in the code stream buffer exceeds the set overflow line, then according to the excess code length of the code stream buffer, determine the fixed code length of each component of the block to be decoded, wherein the block to be decoded includes one or more components, for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required for parsing a single pixel of the first component, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the set overflow line; based on the fixed code length of each component, parse the pixel points of each component to decode the block to be decoded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of video coding and decoding, and in particular to an image coding and decoding method and device. Background Art

[0002] Video coding technology is also called video compression technology. Video compression technology is used to reduce the data bandwidth of video signals. Among them, video is a continuous sequence of images, which is composed of continuous image frames. One frame is an image. Due to the visual persistence effect of the human eye, when the frame sequence is played at a certain rate, what the human eye can see is a continuous video. Encoding and decoding a video means encoding and decoding each frame of the video. Taking a frame of image as an example, at the encoding end, the image encoder encodes the image, obtains the code stream corresponding to the image and transmits the code stream to the decoding end; at the decoding end, the image decoder parses the code stream to reconstruct the image.

[0003] Among them, in the process of image encoding and decoding, in order to improve the compression efficiency, common video compression technologies all use variable length coding. The bit stream obtained after a video sequence is compressed and encoded is variable rate, which is not suitable for real-time transmission in a fixed bit rate channel. Therefore, the variable bit rate data generated by the encoder is usually output to a buffer with a certain storage space, and then output from the buffer at a fixed bit rate. It should be understood that the size of the storage space of the buffer is certain. If the bit stream data input to the buffer is too large, resulting in the data that needs to be temporarily stored in the buffer exceeding the size of its storage space, the bit stream will "overflow", resulting in the loss of subsequent image information.

[0004] Therefore, how to control the bit rate generated by the encoder based on the remaining storage space of the buffer during the image encoding and decoding process is a problem that needs to be solved urgently. Summary of the invention

[0005] The embodiments of the present application provide an image encoding and decoding method and device, which can be used to avoid code stream overflow.

[0006] In order to achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0007] In a first aspect, an embodiment of the present application provides an image encoding method, which is executed by a decoding end, and the method includes: parsing a code stream of a block to be decoded, and if the code stream of the block to be decoded includes a first code word, determining whether an image block corresponding to the block to be decoded adopts a fallback mode, wherein the code length of the block to be decoded is less than the maximum code length of the block to be decoded, and the maximum code length is the maximum code stream length of the block to be decoded that is allowed to be cached in the code stream buffer determined based on a set overflow line of the code stream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by the code stream in the code stream buffer, and the first code word is used to indicate the fallback mode or the original value mode ; If the image block corresponding to the block to be decoded adopts the fallback mode, and the code length stored in the code stream buffer exceeds the set overflow line, the fixed code length of each component of the block to be decoded is determined according to the excess code length of the code stream buffer, wherein the block to be decoded includes one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required for parsing a single pixel of the first component, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the set overflow line; Based on the fixed code length of each component, the pixel points of each component are parsed to decode the block to be decoded. .

[0008] The image encoding method provided by the embodiment of the present application has at least the following beneficial effects: the method can first pre-encode the block to be encoded, compare the code stream length obtained based on the pre-encoding with the code length allowed to be occupied by the block to be encoded, and determine whether the code stream overflow will occur based on the comparison result. Furthermore, when it is determined that the code stream overflow will occur, the fallback mode is used to encode the block to be encoded to avoid the loss of image information of the block to be encoded.

[0009] In a possible implementation, the block to be decoded includes a chrominance component and a luminance component, and a fixed code length of each component is determined according to an excess code length of a code stream buffer, including: obtaining a target total code length of the block to be decoded and an image format of the block to be decoded, the target total code length being a total code length required for decoding the block to be decoded; and determining a fixed code length of the luminance component and a fixed code length of the chrominance component according to the target total code length of the block to be decoded, the image format, and the excess code length.

[0010] In another possible implementation, the above-mentioned determining the fixed code length of the luminance component and the fixed code length of the chrominance component according to the target total code length of the block to be decoded, the image format, and the excess code length includes: obtaining the code length of the header information of the block to be decoded; determining the fixed code length of the luminance component and the fixed code length of the chrominance component according to the target total code length of the block to be decoded, the image format, the excess code length, and the code length of the header information.

[0011] In another possible implementation, the fixed code length of the luminance component is greater than or equal to the fixed code length of the chrominance component.

[0012] It is understandable that since the human eye is more sensitive to image brightness, a larger code length is usually allocated to the chrominance component in the image block, that is, a larger fixed code length is allocated to the chrominance component in the image block. Therefore, based on the image encoding and decoding process, the image effect viewed by the human eye can be improved.

[0013] In another possible implementation, the above-mentioned analysis of the pixel points of each component based on the fixed code length of each component includes: determining the residual value of the first component of the block to be decoded based on the first fixed code length, the first component is one of the one or more components of the block to be decoded, and the first fixed code length is the code length required for parsing a single pixel point of the first component; obtaining the prediction mode of the block to be decoded in the fallback mode, predicting the image block corresponding to the block to be decoded according to the prediction mode, and obtaining the prediction value of the block to be decoded; determining the quantization parameter of the block to be decoded, and dequantizing the residual value of the block to be decoded according to the quantization parameter; reconstructing the block to be decoded according to the residual value and the prediction value after dequantization of the block to be decoded, and obtaining a reconstructed block of the image block.

[0014] In another possible implementation, the above-mentioned obtaining of the prediction mode of the block to be decoded in the fallback mode includes: the prediction mode of the block to be decoded is the prediction mode corresponding to the fallback mode; or, the prediction mode of the block to be decoded is one of multiple prediction modes of the decoding end.

[0015] In another possible implementation, the above-mentioned determination of the target quantization parameter of the block to be decoded includes: deriving the initial quantization parameter of the block to be decoded according to the complexity information of the image block corresponding to the block to be decoded and the set overflow line of the code stream buffer; determining the target quantization parameter of the block to be decoded according to the initial quantization parameter and the quantization parameter adjustment value, the quantization parameter adjustment value is a value determined based on the set overflow line, and the value range of the target quantization parameter is between zero and a preset maximum value of the quantization parameter at the decoding end, wherein the quantization parameter is greater than or equal to the initial quantization parameter.

[0016] In another possible implementation, the method further includes: if the code length of the image block corresponding to the block to be decoded encoded based on the original value mode is greater than or equal to the maximum code length of the block to be decoded, determining that the image block corresponding to the block to be decoded adopts the fallback mode.

[0017] In another possible implementation, the sum of the code lengths of all components of the block to be decoded is the target code length of the block to be decoded minus the code length of header information of the block to be decoded and the excess code length of the code stream buffer.

[0018] In a second aspect, an embodiment of the present application provides an image coding method, which is executed by a coding end, and includes: obtaining a maximum code length of a block to be coded, the maximum code length being the maximum code stream length of a block to be decoded that is allowed to be cached in a code stream buffer determined based on a set overflow line of the code stream buffer, and setting the overflow line to indicate the maximum storage space allowed to be occupied by a code stream in the code stream buffer; pre-coding the block to be coded to obtain a first code length of the block to be coded, the first code length being the length of a code stream obtained after the block to be coded is pre-coded; if the first code length is greater than or equal to the maximum code length, encoding the block to be coded in a fallback mode, wherein the code length obtained by encoding the block to be coded based on the fallback mode is less than the maximum code length, and the code stream obtained by encoding the block to be coded based on the fallback mode includes a first code word, and the first code word is used to indicate a fallback mode or an original value mode. .

[0019] Based on the above embodiment, when the fallback mode is adopted in the encoding segment, the decoding end can adopt the fallback mode to decode the block to be decoded, and can avoid the overflow or underflow of the code stream based on the remaining memory of the code stream buffer, thereby avoiding the loss of image information of the block to be decoded.

[0020] In a possible implementation, the above-mentioned encoding of the block to be encoded in the fallback mode includes: if the code length stored in the code stream buffer exceeds the set overflow line, determining the fixed code length of each component of the block to be encoded according to the excess code length of the code stream buffer; wherein the block to be encoded includes one or more components, for the second component of the block to be encoded, the fixed code length of the second component is used to indicate the code length required for encoding a single pixel of the second component, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer that exceeds the current set overflow line; encoding the block to be encoded according to the fixed code length of each component.

[0021] In another possible implementation, if the fallback mode is used to encode the block to be encoded, the coding control parameters corresponding to the previous encoded block of the block to be encoded are determined as the coding control parameters of the block to be encoded, and the coding control parameters are used to derive the coding information of the next image block to be encoded of the block to be encoded.

[0022] In a third aspect, the present application provides an image decoding device. The decoding device may be a video decoder or a device including a video decoder. The decoding device includes various modules for implementing the method in any possible implementation of the first aspect. The decoding device has the function of implementing the behavior in the above-mentioned related method instance. The function may be implemented by hardware, or by hardware executing corresponding software implementation. The hardware or software includes one or more modules corresponding to the above-mentioned function. The beneficial effects thereof can be found in the description of the corresponding method, which will not be repeated here.

[0023] In a fourth aspect, the present application provides an image encoding device. The encoding device may be a video encoder or a device including a video encoder. The encoding device includes various modules for implementing the method in any possible implementation of the second aspect. The encoding device has the function of implementing the behavior in the above-mentioned related method instance. The function may be implemented by hardware, or by hardware executing corresponding software implementation. The hardware or software includes one or more modules corresponding to the above-mentioned functions. The beneficial effects thereof can be found in the description of the corresponding method, which will not be repeated here.

[0024] In a fifth aspect, the present application provides an electronic device comprising a processor and a memory, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement a method of any one of the implementation modes in the first to second aspects.

[0025] For example, the electronic device may refer to a video encoder, or a device including a video encoder.

[0026] For another example, the electronic device may refer to a video decoder, or a device including a video decoder.

[0027] In a sixth aspect, the present application provides a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is executed by a computing device or a storage system where the computing device is located, a method of implementing any one of the first to second aspects is implemented.

[0028] In a seventh aspect, the present application provides a computer program product, which includes instructions. When the computer program product runs on a computing device or a processor, the computing device or the processor executes the instructions to implement a method of any one of the implementation modes of the first to second aspects.

[0029] In an eighth aspect, the present application provides a chip comprising a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement a method of any one of the implementation modes in the first to second aspects.

[0030] In a ninth aspect, the present application provides an image decoding system, which includes an encoding end and a decoding end, the decoding end is used to implement the corresponding decoding method provided in the first aspect, and the encoding end is used to implement the corresponding encoding method.

[0031] Based on the implementations provided in the above aspects, the present application can be further combined to provide more implementations. In other words, any possible implementation of any of the above aspects can be applied to other aspects without conflict, thereby obtaining a new embodiment. For example, any image encoding method provided in the first aspect can be combined in pairs or in three aspects without conflict, thereby obtaining a new image decoding method. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A schematic diagram of the architecture of a coding and decoding system 1 used in an embodiment of the present application;

[0033] Figure 2 is a schematic block diagram of an example of an encoder 100 for implementing the method according to an embodiment of the present application;

[0034] Figure 3 A schematic diagram of a corresponding relationship between an image, a parallel coding unit, an independent coding unit, and a coding unit provided in an embodiment of the present application;

[0035] Figure 4 is a schematic block diagram of an example of a decoder 200 for implementing the method according to an embodiment of the present application;

[0036] Figure 5 A schematic diagram of a flow chart of an image encoding method provided in an embodiment of the present application;

[0037] Figure 6 A schematic diagram of a sub-block to be encoded provided in an embodiment of the present application;

[0038] Figure 7 A flowchart of an image decoding method provided in an embodiment of the present application;

[0039] Figure 8 A schematic diagram of a flow chart of another image decoding method provided in an embodiment of the present application;

[0040] Fig. 9 A schematic diagram of the structure of a decoding device 900 provided in an embodiment of the present application;

[0041] Fig.10 A schematic diagram of the structure of another encoding device 1000 provided in an embodiment of the present application;

[0042] Fig.11 A schematic diagram of the structure of an electronic device 1100 provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0044] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "plurality" means two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different.

[0045] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0046] The following describes the system architecture used in the embodiments of the present application.

[0047] See also Figure 1 , Figure 1 FIG. 1 shows a schematic diagram of the architecture of the encoding and decoding system 1 used in the embodiment of the present application. Figure 1 As shown, the coding and decoding system 1 may include an encoding end 10 and a decoding end 20. The encoding end 10 generates encoded video data. Therefore, the encoding end 10 may be referred to as a video encoding device. The decoding end 20 may decode the encoded video data generated by the encoding end 10. Therefore, the decoding end 20 may be referred to as a video decoding device.

[0048] The specific forms of the encoding end 10 and the decoding end 20 can be various devices, including desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, telephone handsets such as so-called "smart" phones, televisions, cameras, display devices, digital media players, video game consoles, car computers, or the like.

[0049] Optional, Figure 1The encoding end 10 and the decoding end 20 in the embodiment may be two separate devices. Alternatively, the encoding end 10 and the decoding end 20 may be the same device, that is, the encoding end 10 or the corresponding functions and the decoding end 20 or the corresponding functions may be integrated on the same device.

[0050] The encoding end 10 and the decoding end 20 may communicate with each other. For example, the decoding end 20 may receive the encoded video data from the encoding end 10 via the link 30. The link 30 may include one or more media or devices capable of moving the encoded video data from the encoding end 10 to the decoding end 20. In one example, the link 30 may include one or more communication media that enable the encoding end 10 to transmit the encoded video data directly to the decoding end 20 in real time. In this example, the encoding end 10 may modulate the encoded video data according to a communication standard (e.g., a wireless communication protocol), and may transmit the modulated video data to the decoding end 20. The one or more communication media may include wireless and / or wired communication media, such as a radio frequency (RF) spectrum or one or more physical transmission lines. The one or more communication media may form part of a packet-based network, such as a local area network, a wide area network, or a global network (e.g., the Internet). The one or more communication media may include routers, switches, base stations, or other devices that facilitate communication from the encoding end 10 to the decoding end 20.

[0051] Optionally, the encoder 10 can output the encoded data from the output interface 140 to a built-in or external storage device. The storage device can include any of a variety of distributed or locally accessed data storage media, such as a hard disk drive, a Blu-ray disc, a digital video disc (DVD), a compact disc read-only memory (CD-ROM), a flash memory, a volatile or non-volatile memory, or any other suitable digital storage medium for storing encoded video data.

[0052] like Figure 1As shown, the encoding end 10 includes a video source 120, an encoder 100, and an output interface 140. In some examples, the output interface 140 may include a modulator / demodulator (modem) and / or a transmitter. The video source 120 may include a video capture device (e.g., a camera), a video archive containing previously captured video data, a video feed interface for receiving video data from a video content provider, and / or a computer graphics system for generating video data, or a combination of such sources of video data. The encoder 100 may encode the video data from the video source 120. In some examples, the encoding end 10 transmits the encoded video data directly to the decoding end 20 via the output interface 140. In other examples, the encoded video data may also be stored on a storage device for later access by the decoding end 20 for decoding and / or playback.

[0053] like Figure 1 As shown, the decoding end 20 includes an input interface 240, a decoder 200 and a display device 220. In some examples, the input interface 240 includes a receiver and / or a modem. The input interface 240 can receive the encoded video data via the link 30 and / or from the storage device. The display device 220 can be integrated with the decoding end 20 or can be outside the decoding end 20. In general, the display device 220 displays the decoded video data. The display device 220 may include a variety of display devices, for example, a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display or other types of display devices.

[0054] Optionally, the encoding end 10 further includes a code stream buffer ( Figure 1 (not shown in the figure), the code stream buffer is used to receive the code stream data generated by encoding and output the code stream data with a fixed bit rate. The size of the code stream data generated after encoding different blocks to be encoded can vary greatly based on the properties of the blocks to be encoded. Therefore, the code stream obtained after a video sequence is compressed and encoded is of variable rate and is not suitable for real-time transmission in a fixed bit rate channel. The code stream buffer can be used to smooth the rate changes in the compressed video. Among them, the larger the storage space of the code stream buffer, the more it can withstand the fluctuation of the bit rate.

[0055] Optionally, the decoding end 20 may also include another buffer, which may be used to receive the bitstream data of a fixed bitrate and output the bitstream data from the buffer to the bitstream parsing unit 201 of the decoder 200 .

[0056] although Figure 1Not shown, but in some aspects, encoder 100 and decoder 200 may each be integrated with an audio encoder and decoder, and may include appropriate multiplexer-demultiplexer units or other hardware and software to handle the encoding of both audio and video in a common data stream or in separate data streams.

[0057] It should be understood that Figure 1 The illustrated codec system 1 is only an example, and the techniques of the present application may be applicable to video coding arrangements (e.g., video encoding or video decoding) that do not necessarily include any data communication between the encoding device and the decoding device. In other instances, data is retrieved from a local memory, streamed over a network, and the like. A video encoding device may encode data and store the data to a memory, and / or a video decoding device may retrieve data from a memory and decode the data. In many instances, encoding and decoding are performed by devices that do not communicate with each other but only encode data to a memory and / or retrieve data from a memory and decode data.

[0058] Below is a description of the drawings. Figure 1 The specific structures of the encoder 100 and decoder 200 are briefly introduced.

[0059] See also Figure 2 , Figure 2 1 is a schematic block diagram of an example of an encoder 100 for implementing the method of the embodiment of the present application. Figure 2 As shown, the encoder 100 includes a prediction processing unit 101, a residual calculation unit 102, a residual transformation unit 103, a quantization unit 104, an encoding unit 105, an inverse quantization unit (also called an inverse quantization unit) 106, a residual inverse transformation unit 107, a reconstruction unit (or called a reconstruction unit) 108 and a filter unit 109.

[0060] In one example, the input of the encoder 100 is an image block of an image to be encoded (ie, a block to be encoded or a coding unit).

[0061] In another example, the input of the encoder 100 is an image to be encoded, and the encoder 100 may further include a segmentation unit ( Figure 2 The encoder 100 is used to encode the multiple image blocks of the image to be encoded block by block, thereby completing the encoding of the image to be encoded. For example, the encoder 100 performs an encoding process on each image block, thereby completing the encoding of the image to be encoded.

[0062] Exemplarily, a method for dividing a to-be-encoded image into a plurality of image blocks may include:

[0063] Step 11: Divide a frame of image into one or more non-overlapping slices. A slice includes multiple coding units. There is no dependency between the slices and they can be encoded and decoded in parallel / independently.

[0064] Step 12: For each slice, the encoding end may divide it into one or more independent coding units that do not overlap each other. The independent coding units may not depend on each other, but may share some header information of the parallel coding unit.

[0065] Step 13: For each independent coding unit, the encoding end may further divide it into one or more non-overlapping coding units. If the independent coding unit is divided into multiple non-overlapping coding units, the division method may be horizontal equal division, vertical equal division, or horizontal and vertical equal division. Of course, the specific implementation is not shown here. The coding units in the independent coding unit may be interdependent, that is, they may refer to each other during the process of executing the prediction step.

[0066] The width of the coding unit is w_cu and the height is h_cu. Optionally, the width is greater than the height (unless it is an edge area). Usually, the coding unit can be a fixed w_cu×h_cu, where w_cu and h_cu are both 2N powers (N is greater than or equal to 0), such as 16×4, 8×4, 16×2, 8×2, 4×2, 8×1, 4×1, etc.

[0067] The coding unit can include three components: luminance Y, chrominance Cb, and chrominance Cr (or three components: red R, green G, and blue B, or three components: luminance Y, chrominance U, and chrominance V), or only one of them. If it includes three components, the sizes of the components can be exactly the same or different, which is related to the image input format.

[0068] like Figure 3 , which is a schematic diagram of the correspondence between an image, a parallel coding unit, an independent coding unit, and a coding unit. Figure 3 In the description, an example is taken in which an image is divided into parallel coding unit 1 and parallel coding unit 2 according to 3:1, and an independent coding unit includes 4 coding units.

[0069] Optionally, the segmentation unit divides the image to be encoded into a plurality of image blocks, which may be further segmented into smaller blocks, such as image block segmentation based on a quadtree structure or a binary tree structure. In addition, the segmentation may also include segmentation into tiles, slices, or other larger units. The strip may be divided into a plurality of image blocks (or may be divided into a set of image blocks called slices).

[0070] The prediction processing unit 101 is used to receive or obtain the original value of the block to be encoded and the reconstructed image data, and predict the block to be encoded based on the relevant data in the reconstructed image data to obtain a predicted block of the block to be encoded.

[0071] Optionally, the prediction processing unit 101 may include an inter-frame predictor and an intra-frame predictor. The inter-frame predictor may be used to determine the inter-frame prediction mode used to encode the block to be encoded, and based on the determined inter-frame prediction mode, predict the motion information of one or more sub-blocks in the current image block, such as a motion vector (MV), and use the motion information of one or more sub-blocks in the current image block (such as a motion vector) to obtain or generate a prediction block of the current image block. The intra-frame predictor may determine the intra-frame prediction mode used to encode the block to be encoded.

[0072] Intra-frame prediction refers to using the correlation in the video spatial domain to predict the coded blocks of the current block to remove the spatial redundancy of the video. For example, intra-frame prediction specifies multiple prediction modes, each of which corresponds to a texture direction (except the DC mode). For example, if the image texture is arranged horizontally, the horizontal prediction mode can better predict the image information.

[0073] Inter-frame prediction refers to the use of adjacent coded image pixels to predict the pixels of the current image based on the correlation of the video time domain. Since the video sequence contains strong temporal correlation, it can effectively remove the temporal redundancy of the video. The inter-frame prediction part of the video coding standard uses block-based motion compensation technology. The main principle is to find a best matching block in the previously coded image for each pixel block of the current image. This process is called motion estimation (ME).

[0074] In addition, in the inter-frame prediction mode, a motion vector can be used to represent the relative displacement between the current coding block and the best matching block in its reference image. Each divided block has a corresponding motion vector transmitted to the decoding end. If the motion vector of each block is independently encoded and transmitted, especially when it is divided into small-sized blocks, it will consume a considerable number of bits. In order to reduce the number of bits used to encode the motion vector, the spatial correlation between adjacent image blocks is used to predict the motion vector of the current block to be encoded based on the motion vector of the adjacent encoded block, and then the prediction difference is encoded. In this way, the number of bits representing the motion vector can be effectively reduced. In the process of encoding the motion vector of the current block, the motion vector of the adjacent encoded block is first used to predict the motion vector of the current block, and then the difference (motion vector difference, MVD) between the predicted value of the motion vector (motion vector prediction, MVP) and the true estimate of the motion vector is encoded, thereby effectively reducing the number of encoding bits of the MV.

[0075] The residual calculation unit 102 is used to calculate the residual value between the original value of the block to be encoded and the predicted block of the block to be encoded to obtain the residual block. For example, by subtracting the pixel value of the predicted block from the original pixel value of the block to be encoded pixel by pixel.

[0076] In one example, the residual transform unit 103 is used to determine the residual coefficient based on the residual block. Optionally, in this process, it can include: transforming the residual block, such as discrete cosine transform (DCT) or discrete sine transform (DST), to obtain transform coefficients in the transform domain, and the transform coefficients can also be called transform residual coefficients or residual coefficients, and the residual coefficients can represent the residual block in the transform domain. Of course, the encoder 100 may not include the residual transform step in the process of encoding the block to be encoded.

[0077] The quantization unit 104 is used to quantize the transform coefficients or residual values ​​by applying scalar quantization or vector quantization to obtain quantized residual coefficients (or quantized residual values). The quantization process can reduce the bit depth associated with some or all of the residual coefficients. For example, a p-bit transform coefficient can be rounded down to a q-bit transform coefficient during quantization, where p is greater than q. The degree of quantization can be modified by adjusting a quantization parameter (QP). For example, for scalar quantization, different scales can be applied to achieve finer or coarser quantization. A smaller quantization step size corresponds to finer quantization, while a larger quantization step size corresponds to coarser quantization. The appropriate quantization step size can be indicated by the QP.

[0078] Among them, in the image encoding process, in order to achieve image compression, the residual block of the block to be encoded is usually quantized, or the residual coefficient block obtained after a certain processing of the residual block is quantized, so that the quantized residual block or residual coefficient block can be encoded with fewer bits. It can be understood that the residual block is a residual value block obtained based on the original pixel block and the prediction block of the block to be encoded, and the residual coefficient block is a coefficient block obtained after a certain processing and transformation of the residual block.

[0079] As an example, taking the encoder 100 quantizing the residual block as an example, the encoder 100 can divide each residual value in the residual block of the to-be-encoded block by a quantization coefficient to reduce the residual value in the residual block. In this way, compared with the residual value that has not been quantized, the residual value that has been reduced after quantization can be encoded with fewer bits, thus achieving compression encoding of the image.

[0080] The encoding unit 105 is used to encode the above-mentioned quantized residual coefficients (or quantized residual values), and output the encoded image data (i.e., the encoding result of the current block to be encoded) in the form of an encoded bit stream (or code stream), and then the encoded bit stream can be transmitted to the decoder, or stored and subsequently transmitted to the decoder or used for retrieval. The encoding unit 105 can also be used to encode the syntax elements of the block to be encoded, such as encoding the prediction mode adopted by the block to be encoded into the code stream, etc.

[0081] In one example, the coding unit 105 encodes the residual coefficient, and a feasible method is: semi-fixed length coding. First, the maximum absolute value of the residual in a residual block (RB) is defined as modifiedmaximum (mm). Determine the number of coding bits for the residual coefficient in the RB (the number of coding bits for the residual coefficient in the same RB is consistent). For example, if the CL of the current RB is 2 and the current residual coefficient is 1, then 2 bits are required to encode the residual coefficient 1, which is expressed as 01. If the CL of the previous RB is 7, it means encoding an 8-bit residual coefficient and a 1-bit sign bit. The determination of CL is to find the minimum M value that satisfies that all residuals of the current sub-block are within the range of [-2^(M-1), 2^(M-1)]. If both -2^(M-1) and 2^(M-1) exist, M should be increased by 1, that is, M+1 bits are required to encode all residuals of the current RB; if only one of the two boundary values ​​​​of -2^(M-1) and 2^(M-1) exists, a Trailing bit needs to be encoded to determine whether the boundary value is -2^(M-1) or 2^(M-1); if all residuals do not exist in either -2^(M-1) or 2^(M-1), there is no need to encode the Trailing bit.

[0082] Of course, other residual coefficient encoding methods may also be used, such as an exponential Golomb encoding method, a Golomb-Rice encoding method, a truncated unary code encoding method, a run-length encoding method, directly encoding the original residual value, and the like.

[0083] In addition, for some special cases, the original value can be directly encoded instead of the residual value.

[0084] The inverse quantization unit 106 is used to inverse quantize the above-mentioned quantized residual coefficient (or quantized residual value) to obtain an inverse quantized residual coefficient (inverse quantized residual value). The inverse quantization is the reverse application of the above-mentioned quantization unit 104, for example, based on or using the same quantization step size as the quantization unit 104, applying an inverse quantization scheme of the quantization scheme applied by the quantization unit 104.

[0085] The residual inverse transform unit 107 is used to inverse transform (or inverse transform) the above-mentioned inverse quantized residual coefficients to obtain a reconstructed residual block. Optionally, the inverse transform may include an inverse discrete cosine transform (discrete cosine transform, DCT) or an inverse discrete sine transform (discrete sine transform, DST). In this way, the inverse transform value obtained after the inverse transform (or inverse transform) of the above-mentioned inverse quantized residual coefficients is the residual value reconstructed in the pixel domain (or sample domain). That is, after the inverse quantized residual coefficient block is inversely transformed by the residual inverse transform unit 107, the block obtained is the reconstructed residual block. Of course, when the above-mentioned residual change unit 103 is not included in the encoder 100, the encoder 100 may also not include the inverse transform step.

[0086] The reconstruction unit 108 is used to add the reconstructed residual block to the prediction block to obtain a reconstructed block in the sample domain. The reconstruction unit 108 can be a summer. For example, the reconstruction unit 108 adds the residual value in the reconstructed residual block to the prediction value of the corresponding pixel in the prediction block to obtain the reconstructed value of the corresponding pixel. The reconstructed block output by the reconstruction unit 108 can be subsequently used to predict other image blocks to be encoded.

[0087] The filter unit 109 (or simply “filter”) is used to filter the reconstructed block to obtain a filtered block, so as to smoothly perform pixel conversion or improve image quality.

[0088] In one example, an encoding process implemented by the encoder 100 may include the following steps:

[0089] Step 21: The prediction processing unit 101 determines a prediction mode, and predicts the block to be encoded based on the determined prediction mode and the reconstructed block of the encoded image block to obtain a prediction block of the block to be encoded.

[0090] The reconstructed block of the encoded image block is obtained after the inverse quantization unit 106, the residual inverse transformation unit 107 and the reconstruction unit 108 sequentially process the quantized residual coefficient block of the encoded image block.

[0091] Step 22: The residual calculation unit 102 obtains a residual block of the block to be encoded based on the original pixel values ​​of the prediction block and the block to be encoded;

[0092] Step 23: The residual transform unit 103 transforms the residual block to obtain a residual coefficient block.

[0093] Step 24: The quantization unit 104 quantizes the residual coefficient block to obtain a quantized residual coefficient block.

[0094] Step 25: The encoding unit 105 encodes the quantized residual coefficient block and the related syntax elements (such as prediction mode, encoding mode) to obtain a code stream of the block to be encoded.

[0095] See also Figure 4 , Figure 4 A schematic block diagram of an example of a decoder 200 for implementing the method of an embodiment of the present application is shown. The decoder 200 is used to receive image data (i.e., an encoded bit stream, for example, including an encoded bit stream of an image block and associated syntax elements) encoded by the encoder 100 to obtain a decoded image block.

[0096] like Figure 4 As shown, the decoder 200 includes a code stream parsing unit 201, a dequantization unit 202, a residual inverse transform unit 203, a prediction processing unit 204, a reconstruction unit 205, and a filter unit 206. In some examples, the decoder 200 may perform substantially the same Figure 2 The encoding process described by encoder 100 is the inverse of the decoding process.

[0097] The code stream parsing unit 201 is used to decode the encoded bit stream to obtain quantized residual coefficients (or quantized residual values) and / or decoding parameters (for example, the decoding parameters may include any one or all of the inter-frame prediction parameters, intra-frame prediction parameters, filter parameters and / or other syntax elements performed by the encoding side). The code stream parsing unit 201 is also used to forward the above-mentioned decoding parameters to the prediction processing unit 204, so that the prediction processing unit 204 performs a prediction process according to the decoding parameters.

[0098] 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 inversely quantize (ie, inversely quantize) the quantized residual coefficients decoded and output by the bitstream parsing unit 201 .

[0099] Among them, inverse quantization is the reverse process of quantization, and inverse quantization refers to mapping the quantized coefficients into a reconstructed signal in the input signal space, and the reconstructed signal is an approximation of the input signal. In order to reconstruct the image block from the compressed and encoded bitstream, the inverse quantization unit 202 of the decoder 200 can inverse quantize the residual block or residual coefficient block parsed from the bitstream, so as to reconstruct the unquantized residual block or residual coefficient block corresponding to the image block, and then, the decoder 200 reconstructs the image block according to the reconstructed residual block or residual coefficient block, so as to obtain the reconstructed block of the image.

[0100] As an example, taking the residual block after the decoder 200 parses the to-be-decoded block from the bitstream and quantizes it as an example, the decoder 200 can dequantize the residual block through the dequantization unit 202. Specifically, the encoding end can multiply each residual value in the parsed residual block by a quantization coefficient to reconstruct the residual value in the unquantized residual block corresponding to the to-be-decoded block, thereby obtaining a reconstructed residual block. Among them, the quantization coefficient is the quantization coefficient when the encoding device quantizes the residual block of the to-be-decoded block when encoding the to-be-decoded block. In this way, the decoder 200 can realize the reconstruction of the to-be-decoded block based on the residual block reconstructed after dequantization, and obtain the reconstructed block of the to-be-decoded block.

[0101] The function of the residual inverse transform unit 203 may be the same as that of the residual inverse transform unit 107 of the encoder 100, and is used to perform an inverse transform (e.g., an inverse DCT, an inverse integer transform, or a conceptually similar inverse transform process) on the above-mentioned dequantized residual coefficients to obtain a reconstructed residual value. The block obtained by the inverse transform is the residual block of the reconstructed block to be decoded in the pixel domain.

[0102] The function of the reconstruction unit 205 (eg, a summer) may be the same as that of the reconstruction unit 108 of the encoder 100 .

[0103] The prediction processing unit 204 is used to receive or obtain the encoded image data (for example, the encoded bit stream of the current image block) and the reconstructed image data. The prediction processing unit 204 can also receive or obtain relevant parameters of the prediction mode and / or information about the selected prediction mode (that is, the above-mentioned decoding parameters) from, for example, the bit stream parsing unit 201, and predict the current image block based on the relevant data and decoding parameters in the reconstructed image data to obtain a prediction block of the current image block.

[0104] The reconstruction unit 205 is used to add the reconstructed residual block to the prediction block to obtain a reconstructed block of the image to be decoded in the sample domain, for example, adding the residual value in the reconstructed residual block to the prediction value in the prediction block.

[0105] The filter unit 206 is configured to filter the reconstructed block to obtain a filtered block, where the filtered block is a decoded image block.

[0106] Specifically, in the embodiment of the present application, the decoder 200 is used to implement the decoding method described in the embodiments below.

[0107] It should be understood that in the encoder 100 and decoder 200 of the embodiment of the present application, the processing result of a certain link can also be output to the next link after further processing. For example, after the interpolation filtering, motion vector derivation or filtering links, the processing results of the corresponding links are further subjected to operations such as Clip or shift.

[0108] In an example, a decoding process implemented by the decoder 200 may include the following steps:

[0109] Step 31: The code stream parsing unit 201 parses the prediction mode and the residual coding mode;

[0110] Step 32: the code stream parsing unit 201 parses quantization related values ​​(such as near values, or QP values, etc.) based on the prediction mode and the residual coding mode;

[0111] Step 33: The inverse quantization unit 202 analyzes the residual coefficients based on the prediction mode and the quantization correlation value;

[0112] Step 34: The prediction processing unit 204 obtains the prediction value of each pixel of the current image block based on the prediction mode;

[0113] Step 35: The residual inverse transform unit 203 performs an inverse transform on the residual coefficients to reconstruct the residual values ​​of each pixel of the current image block;

[0114] Step 36: The reconstruction unit 205 obtains the reconstructed value of each pixel in the current coding unit based on the predicted value and residual value of each pixel.

[0115] Figure 1~Figure 4 These are merely examples provided for the embodiments of the present application. In some examples, the encoder 100, the decoder 200, and the encoding and decoding system 1 may include more or fewer components or units, and the present application does not limit this.

[0116] The following image encoding and decoding method provided in the embodiment of the present application is described in conjunction with the accompanying drawings.

[0117] Figure 5 The following is a flow chart of an image encoding method provided by the present application. Optionally, the image encoding method can be applied to Figure 1 In the coding and decoding system 1 shown, the image coding method can be executed by the coding end 10. Specifically, the coding method can be executed by the encoder 100 included in the coding end 10. Figure 5 As shown, the image encoding method provided in the embodiment of the present application includes the following steps:

[0118] S101. The encoding end obtains the maximum code length of the block to be encoded.

[0119] It is understandable that the video to be encoded may include one or more image frames. An image frame includes one or more image blocks. In an embodiment of the present application, the current block to be encoded corresponds to an image block of the image to be processed (the image to be processed is any one of the one or more image frames), and the block to be encoded may be a coding unit (CU).

[0120] Optionally, a block to be encoded may include multiple components. The component may be a luminance component or a brightness component.

[0121] For example, for an image block corresponding to a to-be-decoded block with a size of 16×2, if the image format of the image block is YUV444, the image block includes a luminance component with a size of 16×2 and two chrominance components with a size of 16×2.

[0122] For another example, for an image block corresponding to a to-be-decoded block with a size of 16×2, if the image format of the image block is YUV422, the image block includes a luminance component with a size of 16×2 and two chrominance components with a size of 8×2.

[0123] The maximum code length is the maximum code stream length of the block to be encoded that is allowed to be cached in the code stream buffer, determined based on the set overflow line of the code stream buffer. The set overflow line is used to indicate the maximum storage space allowed to be occupied by the code stream in the code stream buffer.

[0124] It should be understood that in order to prevent the code stream from overflowing, the maximum code length can be based on Figure 1 The actual storage space size of the code stream buffer of the decoding end in the coding and decoding system shown is determined. The decoding end can determine the storage space in the current code stream buffer that is allowed to cache the encoded code stream according to the actual storage space size of the code stream buffer and the above-set overflow line. Furthermore, the decoding end can determine the size of the space occupied by the code stream stored in the current code stream buffer, and determine the space size obtained by subtracting the space size occupied by the currently stored code stream from the storage space in the current code stream buffer that is allowed to cache the encoded code stream as the remaining space of the above storage space.

[0125] Therefore, the maximum code length is the maximum code stream length currently allowed to be cached by the storage space used by the encoder to cache the encoded code stream. The above maximum code length is the sum of the length of the code stream that can be accommodated in the remaining space of the storage space and the length of the code stream output by the storage space per unit time.

[0126] In some embodiments, the encoder can control the overflow line of the code stream buffer so that the space allowed to store the encoded code stream is less than or equal to the total storage space size of the code stream buffer. Thus, the encoder can determine the above code length range according to the current overflow line of the code stream buffer.

[0127] It should be noted that, during the encoding process of the image, the encoder can lower the set overflow line of the code stream buffer to half, one third or other possible sizes of the total storage space size of the code stream buffer. Exemplarily, for a "slice", after the encoder completes encoding of the "slice", in order to output the encoded code stream of the "slice" from the code stream buffer as quickly as possible, the actual space size allowed to accommodate the encoded code stream in the code stream buffer can be reduced, thereby reducing the code stream of the "slice" stored in the code stream buffer after the encoder completes encoding of the "slice". In addition, when the set overflow line is lowered, the space occupied by the code stream already stored in the current code stream buffer may exceed the set overflow line. At this time, the encoder can determine the fixed code length to be encoded based on the size of the space occupied by the part exceeding the set overflow line as a determining factor.

[0128] S102: The encoding end pre-encodes the block to be encoded to obtain a first code length of the block to be encoded.

[0129] The first code length is the length of the code stream obtained after encoding the block to be encoded.

[0130] In addition, the encoding end may pre-encode the block to be encoded based on the original value mode.

[0131] The original value mode is a mode for directly encoding the original value of the image block corresponding to the block to be encoded.

[0132] Optionally, the encoding end may adopt the original value mode to encode the original pixel values ​​of the encoding block after quantization and transformation. In this way, the encoding end can improve the effect of reconstructing the image of the encoding block by adopting the original value mode to encode the encoding block.

[0133] In the near-lossless compression encoding method, the encoder can use the original value mode to encode the image to be encoded. Among them, near-lossless compression refers to a compression technology between lossless compression and lossy compression. The purpose of near-lossless compression is to obtain higher image compression quality under a certain compression multiple.

[0134] Optionally, the encoding end may pre-encode the block to be encoded based on a prediction mode preset by the encoding end, such as a point-by-point prediction mode, an intra-frame prediction mode, and a block copy mode.

[0135] Intra-frame prediction mode is a prediction mode that uses the reconstructed values ​​of pixels in the neighboring blocks around the block to be predicted as the prediction value. Block copy prediction mode is a prediction mode that uses the reconstructed values ​​of pixels in the surrounding coded (decoded) blocks (not necessarily adjacent) as the prediction value. During reconstruction, point-by-point prediction mode refers to a prediction mode that uses the reconstructed values ​​of the neighboring pixels around the pixel to be predicted as the prediction value of the pixel to be predicted.

[0136] The point-by-point prediction mode may include one or more combinations of prediction modes such as vertical prediction, horizontal prediction, vertical mean prediction and horizontal mean prediction.

[0137] Vertical prediction is to obtain the predicted value (PointPredData) of the pixel to be predicted by using the reconstructed value of the pixel on the upper side of the pixel to be predicted (either the adjacent upper side or the non-adjacent but closer upper side). Horizontal prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed value of the pixel on the left side of the pixel to be predicted (either the adjacent left side or the non-adjacent but closer left side). Vertical mean prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed values ​​of the pixels above and below the pixel to be predicted. Horizontal mean prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed values ​​of the pixels on the left and right sides of the pixel to be predicted.

[0138] S103: If the first code length is greater than or equal to the maximum code length, the encoding end uses a fallback mode to encode the block to be encoded.

[0139] The code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length.

[0140] The fallback mode is used to encode the block to be coded, that is, based on a predetermined target code length, a fixed code length coding method is used to encode the block to be coded, and the total code length required to encode the block to be coded is the target code length. The target code length is less than the maximum code length.

[0141] It should be understood that if the first code length is less than or equal to the maximum code length, the encoding end does not need to adopt the fallback mode to encode the block to be encoded.

[0142] It should be noted that the storage space of the code stream buffer is of a certain size. If the code stream data input to the code stream buffer is too large, resulting in the data that needs to be temporarily stored in the code stream buffer exceeding the size of its storage space, the code stream will "overflow". This will cause the excess data to be lost, and thus the image information in the image frame of the video to be encoded will be lost, and the image frame cannot be completely parsed based on the code stream data output by the code stream buffer.

[0143] Therefore, the encoding end needs to control the target code length within the above maximum code length.

[0144] In some embodiments, the codeword of the original value mode and the codeword of the fallback mode are the same. For example, the codewords of the original value mode and the fallback mode are both the first codeword, and when the encoder encodes the fallback mode, the first codeword can be used to indicate the fallback mode or the original value mode.

[0145] In some embodiments, the encoding end may select the midpoint prediction fallback mode (MPPF Mode) to predict the block to be encoded, and after obtaining the predicted block, encode the block to be encoded based on a fixed code length encoding method to obtain a code stream of the block to be encoded.

[0146] According to the midpoint prediction fallback mode, the encoder can first divide the block to be encoded into multiple sub-image blocks of 2x2 pixels. A median needs to be calculated for each 2x2 sub-image block. The calculation method of the median is as follows: Formula (1).

[0147] Formula (1)

[0148] in, is the bit depth of the code stream transmission channel of the current sub-block to be decoded, 1<< means shifting left by one bit.

[0149] Furthermore, the encoding end may determine the mean of the sub-block to be encoded.

[0150] In one case, if the current sub-block cannot obtain the surrounding reconstructed image, the mean value is the above-mentioned middle value.

[0151] In another case, the mean value is the mean of the sub-block reconstruction values ​​of the previous row of 2x1 pixels of the sub-block. If the sub-block reconstruction value of the previous row of 2x1 pixels cannot be obtained, the mean of the previous reconstructed 2x2 sub-block reconstructed image of the sub-block is taken.

[0152] Then, the encoder can determine the bias value of the sub-block, and the bias value is used to limit the value of the mean value. The encoder can use the bias value and the middle value to clamp the mean value to limit the mean value to the value range composed of the bias value and the middle value. Thus, the mean value adjusted by the bias value and the middle value is determined as the predicted value of the current 2x2 pixel point to be encoded sub-block.

[0153] The bias value can be determined according to the following formula (2).

[0154] Formula (2)

[0155] in, It is used to indicate the quantization step size in the quantization process of a component of the block to be encoded. Used to indicate the first Component, 1<< means shift left one bit.

[0156] In addition, based on MPPF Mode, such as Figure 6 As shown, the residual value of the 2x2 pixel sub-block can be calculated based on the order of the upper left pixel A, the upper right pixel B, the lower left pixel C, and the lower right pixel D.

[0157] Optionally, in the process of reconstructing the sub-block to be encoded, the reconstruction value of each pixel point may be determined in sequence according to the order of the upper left pixel point A, the upper right pixel point B, the lower left pixel point C, and the lower right pixel point D.

[0158] In some embodiments, the encoding end may use a residual coding mode to encode the block to be encoded.

[0159] Optionally, the encoder may use the prediction mode corresponding to the fallback mode to predict the block to be coded. Alternatively, the encoder may use any prediction mode among the prediction modes preset by the encoder to predict the block to be coded.

[0160] Among them, the prediction mode preset by the encoding end may include a point-by-point prediction mode, an intra-frame prediction mode, a block copy mode, etc.

[0161] Optionally, the encoder may determine the prediction mode corresponding to the fallback mode as a fixed one of the prediction modes preset by the encoder. Alternatively, the encoder may select any one of the preset prediction modes as the prediction mode used when predicting the current block to be encoded during the encoding process.

[0162] Therefore, for all blocks to be encoded using the fallback mode, the encoder uses the fixed prediction mode for prediction.

[0163] Optionally, the fallback mode provided in the embodiment of the present application may include a first fallback mode and a second fallback mode. Among them, the first fallback mode, that is, when the fallback mode is used to encode the coding block, a fixed prediction mode is directly used to predict the coding block, such as a vertical mean prediction mode. In addition, the second fallback mode, that is, does not have a fixed prediction mode. When the second fallback mode is used to encode the coding block, any prediction mode preset by the encoding end can be selected to predict the coding block. In addition, the second fallback mode may not have a prediction mode. When the second fallback mode is used to encode the coding block, the original value is directly quantized and dequantized to obtain a reconstructed value.

[0164] Thus, after obtaining the prediction block of the block to be encoded, the encoding end can perform steps 22 to 25 described above, obtain the residual block of the block to be encoded based on the original pixel values ​​of the prediction block and the block to be encoded, and transform the residual block to obtain a residual coefficient block. Then, the residual coefficient block is quantized to obtain a quantized residual coefficient block. Finally, the quantized residual coefficient block is encoded to obtain a code stream of the block to be encoded.

[0165] In some embodiments, the encoding end may first determine a quantization parameter QP value of the block to be encoded, and then perform quantization processing on the residual value.

[0166] Optionally, the encoder can derive the initial quantization parameter of the block to be encoded based on the complexity information of the image block corresponding to the block to be encoded and the remaining space of the code stream buffer. Furthermore, the encoder can determine the quantization parameter of the block to be encoded based on the initial quantization parameter and the quantization parameter adjustment value, and the value range of the target quantization parameter is between zero and the preset maximum value of the quantization parameter of the encoder. Exemplarily, the quantization parameter of the block to be decoded can be the sum of the initial quantization parameter and the quantization parameter adjustment value.

[0167] The larger the remaining capacity of the code stream buffer is, the larger the quantization parameter adjustment value is. The value of the quantization parameter adjustment value can be a positive integer such as 4 or 8.

[0168] Furthermore, the encoding end may also determine a fixed code length for each component of the block to be encoded.

[0169] The block to be coded includes one or more components. The block to be coded may include three components of brightness Y, chrominance Cb, and chrominance Cr (or three components of red R, green G, and blue B, or three components of brightness Y, chrominance U, and chrominance V), or may only include one of the components. If it includes three components, the sizes of the components may be exactly the same or different, which is related to the image input format.

[0170] For example, if the image format of the block to be encoded is YUV400, the block to be encoded only includes the luminance component, and the encoder only needs to determine the fixed code length of the luminance component. Alternatively, if the image format of the block to be encoded is YUV420, the block to be encoded includes three components: luminance Y, chrominance U, and chrominance V. The encoder needs to determine the fixed code length of the luminance component, the fixed code length of the first chrominance component, and the fixed code length of the second chrominance component.

[0171] In one example, the encoder can obtain the target total code length of the block to be encoded and the image format of the block to be encoded, the target total code length is the total code length required for encoding each pixel of the block to be encoded based on the target pixel depth (bits per pixel, BPP), and the image format of the block to be encoded is used to indicate the code length ratio between the chrominance component and the luminance component. Furthermore, the encoder can determine the fixed code length of the luminance component and the fixed code length of the chrominance component of the block to be encoded based on the target total code length of the block to be encoded and the code length ratio.

[0172] The target BPP is used to indicate the code length required to encode each pixel of the block to be encoded at the target compression rate. The target pixel depth can be determined according to the target compression ratio of the block to be encoded, and the target BPP can also be regarded as the average code length required to encode each pixel of the block to be encoded. The target BPP is obtained by parsing the code stream in the image header information.

[0173] The target pixel depth is also used to indicate the code length required when encoding each pixel of the block to be encoded at the target compression rate. The target pixel depth can be determined according to the target compression ratio of the block to be encoded.

[0174] Example 1: If the target BPP of the block to be encoded is 8, that is, the target total code length of the block to be encoded is (8bit×the number of pixels in the block to be encoded), and if the image format is YUV400, the block to be encoded includes only one component, the brightness component, and the total code length of the brightness component can be (8 bit×the number of pixels in the block to be encoded), that is, the fixed code length of the brightness component (the code length of one brightness pixel) is 8 bits. The encoder can encode the block to be encoded in a fixed code length encoding method based on the total code length of the block to be decoded determined above. Among them, if the block to be encoded is a 16x2 image block, the target total code length of the block to be encoded is 256 bits.

[0175] Example 2: If the current target BPP is 8, that is, the target total code length of the block to be encoded is (8 bit × the number of pixels in the block to be encoded), and the image format is YUV444, then the block to be encoded includes three components: luminance Y, chrominance U, and chrominance V. It should be understood that at this time, the target total code length cannot be evenly distributed to the three components of luminance Y, chrominance U, and chrominance V. Based on the image format of YUV444, the code length ratio of Y component: U component: V component can be 2:1:1. Thus, the encoder can determine that the total code length of the Y component is (4 bit × the number of pixels in the block to be encoded), and the total code length of the U component and the V component are both (2 bit × the number of pixels in the block to be encoded). Thus, the encoder can encode the Y component of the block to be encoded in a fixed code length encoding method based on the code length of (4bit × the number of pixels in the block to be encoded). And based on the code length of (2 bits × the number of pixels of the block to be encoded), the U component and the V component of the block to be encoded are encoded in a fixed code length encoding method.

[0176] In addition, since the image format is YUV444, the number of pixels in each chrominance (U or V) component is the same as the number of pixels in the luminance (Y) component, so the encoder can use 4 bits (that is, the fixed code length of luminance is 4 bits) as the fixed code length to encode each pixel in the luminance (Y) component. In addition, the encoder can use 2 bits (that is, the fixed code length of chrominance is 2 bits) as the fixed code length to encode each pixel in the chrominance (U or V) component.

[0177] Example 3: If the current target BPP is 8, that is, the target total code length of the block to be encoded is (8 bit×the number of pixels in the block to be encoded), and the image format is YUV422, then the block to be encoded includes three components: luminance Y, chrominance U, and chrominance V. It should be understood that at this time, it is impossible to evenly distribute (8 bit×the number of pixels in the block to be encoded) to the three components of luminance Y, chrominance U, and chrominance V. Based on the image format of YUV422, the code length ratio of Y component: U component: V component can be 2:1:1. Thus, the encoder can determine that the total code length of the Y component is (4 bit×the number of pixels in the block to be encoded), and the total code length of the U component and the V component are both (2 bit×the number of pixels in the block to be encoded). Thus, the encoder can encode the Y component of the block to be encoded based on the code length of 4bit×the number of pixels in the block to be encoded, that is, with a fixed-length code with a fixed code length of 4. And based on the code length of (2 bit×the number of pixels of the block to be encoded), for example, 2 bit×2×16, i.e., 64 bits, the U component and the V component of the block to be encoded are encoded in an encoding method with a fixed code length of (64 / the number of pixels of the block to be encoded).

[0178] In addition, since the image format is YUV422, the number of pixels in each chrominance (U or V) component is half the number of pixels in the luminance (Y) component, so the encoder can use 4 bits (that is, the fixed code length of the luminance component is 4 bits) as the fixed code length to encode each pixel in the luminance (Y) component. In addition, the encoder can also use 4 bits (that is, the fixed code length of the chrominance component is 4 bits) as the fixed code length to encode each pixel in the chrominance (U or V) component.

[0179] In another example, the encoder can obtain the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required for encoding the header information of the block to be encoded. Furthermore, the encoder can determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be encoded according to the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required for encoding the header information of the block to be encoded.

[0180] For the encoded bitstream of each image block, the header information is data of a certain length at the front end of the bitstream, and the data can be used to indicate the image parameters of the current image block. Exemplarily, the image parameters include one or more of the bit depth, target pixel depth, quantization parameter, and texture complexity of the current image block.

[0181] For example, if the current target BPP is 8, that is, the target total code length of the block to be encoded is (8 bits × the number of pixels in the block to be encoded), the code length required for the encoding header information is (2 bits × the number of pixels in the block to be encoded), and if the image format is YUV400, the block to be encoded includes only one component, the brightness component, and the total code length of the brightness component can be (6 bits × the number of pixels in the block to be encoded), so the fixed code length of the brightness component is 6 bits. The encoding end can encode the block to be encoded in a fixed code length encoding method based on (4 bits × the number of pixels in the block to be encoded), such as 4 bits × 2 × 16, that is, 128 bits.

[0182] It should be noted that in the image encoding and decoding process, since the human eye is more sensitive to image brightness, a code length is usually assigned to the chrominance (Y) component in the image block, so that the sum of the fixed code lengths of all pixels on the brightness component is greater than or equal to the sum of the fixed code lengths of all pixels on the chrominance component. Therefore, based on this image encoding and decoding process, the image effect viewed by the human eye can be improved.

[0183] In another example, the encoder can obtain the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required for encoding the header information of the block to be encoded. Further, the encoder can determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be encoded according to the remaining capacity of the code stream buffer, the target BPP of the block to be encoded, the code length ratio, and the code length required for encoding the header information of the block to be encoded.

[0184] Optionally, the sum of the code lengths of all components of the block to be encoded is the target code length of the block to be encoded minus the code length of header information of the block to be encoded and the excess code length of the code stream buffer.

[0185] The target code length is the code length of the block to be encoded based on the target BPP, the change in the overflow line is set to be smaller than the difference between the fixed code length of the block to be encoded and the code length of the header information of the block to be encoded, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the current set overflow line.

[0186] Exemplarily, if the target BPP is 8, the target code length of the block to be encoded is (8bit×number of pixels of the block to be encoded), if the header information needs to occupy (2bit×number of pixels of the block to be encoded), at this time the state of the code stream buffer is greater than the current set overflow line, then the code length occupied by the part greater than the overflow line is set to overflow_bpp, then at this time the sum of the code lengths of all components of the block to be encoded is the target total code length of the block to be encoded (that is, 8bit×number of pixels of the block to be encoded) minus the code length occupied by the encoding header information (for example, 2bit×number of pixels of the block to be encoded), and then minus overflow_bpp (for example, 1bit×number of pixels of the block to be encoded). Thus, at this time the sum of the code lengths of all components of the block to be encoded is 5bit×number of pixels of the block to be encoded. Furthermore, the encoder can determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be encoded according to the image format of the block to be decoded and 5bit×number of pixels of the block to be encoded.

[0187] In some embodiments, if the overflow line needs to be adjusted, the size of the overflow line is set to satisfy the following formula (3):

[0188] Formula (3)

[0189] Wherein, delta_bit=overflow_bpp×block_size, block_size is the coding block size. target_bpp indicates the target BPP. cu_header_bpp indicates the code length used when encoding the header information of the block to be coded, and cu_header_bpp is less than or equal to target_bpp. In addition, overflow_bpp indicates that the stored code length in the code stream buffer exceeds the code length of the current set overflow line.

[0190] In some embodiments, if the block to be encoded includes multiple components, the multiple components of the block to be encoded share a fallback mode (sharing means that the multiple components all adopt the fallback mode or none of them adopt the fallback mode), so that the encoder can only determine whether one of the components adopts the fallback mode. When one of the components adopts the fallback mode, the other components also adopt the fallback mode. Alternatively, some of the multiple components of the block to be encoded share the fallback mode, then the encoder can only determine whether one of the components adopts the fallback mode, and whether the other components except the part adopt the fallback mode. Alternatively, the multiple components of the block to be encoded do not share the fallback mode, so that the encoder can determine whether each component adopts the fallback mode separately.

[0191] In some embodiments, if the current block to be encoded is encoded in a fallback mode, the current coding parameters are not updated, that is, the coding parameters corresponding to the previous encoded block of the block to be encoded are determined as the coding parameters of the block to be encoded. The coding parameters are used to derive the encoding information of the next block to be encoded, such as parameters such as the quantization step size.

[0192] It should be noted that, during the encoding and decoding process, for each image block corresponding to the block to be encoded, after the encoding of the current image block is completed, the code control will update the code control parameters according to the complexity of the current image block and the code length required for encoding, and the updated code control parameters are used to derive the information of the next image block to be encoded, such as the quantization step length, etc. However, if the image block is encoded based on the fallback mode, since the code length of the block to be encoded is fixed, the code length required for encoding cannot correctly reflect the current image content. Therefore, if the fallback mode is selected in the current coding unit, the code control parameters will not be updated.

[0193] Optionally, for a block to be encoded having multiple components, if one of the components in the current block to be encoded is encoded in a fallback mode, the current coding control parameters are not updated.

[0194] The image encoding method provided by the embodiment of the present application has at least the following beneficial effects: the method can first pre-encode the block to be encoded, compare the code stream length obtained based on the pre-encoding with the code length allowed to be occupied by the block to be encoded, and determine whether the code stream overflow or underflow will occur based on the comparison result. Furthermore, when it is determined that the code stream overflow or underflow will occur, the fallback mode is used to encode the block to be encoded to avoid the loss of image information of the block to be encoded.

[0195] In some embodiments, the present application also provides an image decoding method. Figure 5 The encoding method shown corresponds to Figure 7 As shown, Figure 7 1 is a flow chart of an image decoding method provided by the present application. The image decoding method can be executed by the decoder 200 or by a decoding end (such as Figure 1 The decoding method implemented by the decoder 200 is described as an example. The image decoding method includes the following steps:

[0196] S201: The decoding end parses a code stream of a block to be decoded, and if the code stream of the block to be decoded includes a first code word, determines whether an image block corresponding to the block to be decoded adopts a fallback mode.

[0197] The codeword used to indicate the coding mode in the code stream of the block to be decoded is the first codeword, and the first codeword is used to indicate the fallback mode or the original value mode.

[0198] In some embodiments, the end to be decoded may determine whether the image block corresponding to the block to be decoded adopts the fallback mode according to whether the code length for encoding the block to be decoded based on the original value mode overflows.

[0199] Optionally, if the code length of the image block corresponding to the block to be decoded is encoded based on the original value mode and is greater than or equal to the maximum code length of the block to be decoded, the decoding end may determine that the image block corresponding to the block to be decoded adopts the fallback mode.

[0200] Among them, the code stream of the block to be decoded can be a code stream received by the decoding end from the encoding end, or a code stream obtained from other devices, such as a code stream obtained from a storage device, which is not limited in this embodiment of the present application.

[0201] The code length of the block to be decoded is less than the maximum code length of the block to be decoded, the maximum code length is the maximum code stream length of the block to be decoded that is allowed to be cached in the code stream buffer, which is determined based on the set overflow line of the code stream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by the code stream in the code stream buffer.

[0202] It should be noted that the maximum code length of the code stream allowed to be cached in the code stream buffer is the maximum code stream length allowed to be cached in the code stream buffer when the encoder encodes the block to be decoded. The decoder can parse the code stream of the block to be decoded to directly determine the maximum code length, or the decoder can also parse the code stream of the block to be decoded to determine the remaining memory state of the code stream buffer when the encoder encodes the image block corresponding to the block to be decoded. Then, based on the remaining memory state of the code stream buffer, the decoder can determine the above maximum code length.

[0203] For the explanation of the maximum code length, please refer to the description in the above step S101, which will not be repeated here.

[0204] In some embodiments, the codeword of the original value mode and the codeword of the fallback mode are the same. For example, the codewords of the original value mode and the fallback mode are both the first codeword. When the decoding end parses the code stream of the block to be decoded and obtains the first codeword, the decoding end can determine whether the block to be decoded adopts the fallback mode or the original value mode.

[0205] Furthermore, the decoding end can determine whether the block to be decoded adopts the fallback mode according to the size of the occupied memory space in the code stream buffer.

[0206] When the decoding end determines that the occupied memory space in the code stream buffer is greater than the first preset memory value when encoding the image block to be decoded, and is about to overflow, the decoding end determines that the image block corresponding to the image block to be decoded adopts the fallback mode. Otherwise, the decoding end determines that the image block corresponding to the image block to be decoded adopts the original value mode.

[0207] The size of the first preset memory value can be determined according to the actual memory size of the code stream buffer, and is not specifically limited.

[0208] Optionally, the decoding end determines that the code stream length of the block to be encoded is the sum of the image bit width of all components multiplied by the number of pixels, and the decoding end can parse the code stream of the block to be decoded and reconstruct the image block of the block to be decoded based on the original value mode.

[0209] In some embodiments, a block to be decoded may include one or more components.

[0210] Optionally, the block to be decoded may include only the brightness component. Alternatively, the block to be decoded may include three components, such as brightness Y, chroma Cb, and chroma Cr (or red R, green G, and blue B, or brightness Y, chroma U, and chroma V). Alternatively, on the basis of the above three components, the block to be decoded may also include an α component, that is, the block to be decoded includes a total of four components. Among them, the α component is the pixel transparency component. When the component α value is 0, the pixel corresponding to the decoded block is transparent, and the image bit width of the α component is different from the other three components.

[0211] In some embodiments, if the block to be decoded includes multiple components, the multiple components of the block to be decoded share a fallback mode (the shared fallback mode means that the multiple components all adopt the fallback mode or none of them adopt the fallback mode), so that the decoding end can only determine whether one of the components adopts the fallback mode. In the case where one of the components adopts the fallback mode, the other components also adopt the fallback mode. Alternatively, some of the multiple components of the block to be decoded share the fallback mode, then the decoding end can only determine whether one of the components adopts the fallback mode, and whether the other components except the part adopt the fallback mode. Alternatively, the multiple components of the block to be decoded do not share the fallback mode, so that the decoding end can determine whether each component adopts the fallback mode separately.

[0212] Specifically, the code stream of the block to be decoded may include an identifier for indicating the shared fallback mode. Thus, the decoding end may determine the components of the shared fallback mode according to the identifier, and further determine whether each component adopts the fallback mode.

[0213] S202: When the image block corresponding to the to-be-decoded block adopts the fallback mode and the code length stored in the code stream buffer exceeds the set overflow line, the decoding end determines the fixed code length of each component of the to-be-decoded block according to the excess code length of the code stream buffer.

[0214] The block to be decoded includes one or more components. For the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required for parsing a single pixel of the first component, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the current set overflow line.

[0215] In some embodiments, the decoding end can determine the fixed code length of each component of the block to be decoded based on one or more of the target BPP of the block to be decoded, the image format of the block to be decoded, the code length of the header information of the block to be decoded, and the remaining memory of the code stream buffer when encoding the image block to be decoded.

[0216] The target pixel depth is also used to indicate the code length required to decode each pixel of the block to be decoded at the target compression rate. The target pixel depth can be determined according to the target compression ratio of the block to be decoded. It can be understood that the target pixel depth is the average code length required to decode each pixel of the block to be decoded. In addition, the image format of the block to be decoded can also be used to indicate the code length ratio between the chrominance component and the luminance component. For example, if the image format is YUV444, the code length ratio of the Y component: U component: V component in the image block to be decoded can be 2:1:1.

[0217] Optionally, the decoding end may parse the code stream of the block to be decoded to obtain the BPP of each component of the block to be decoded, or the decoding end may determine the BPP of each component of the block to be decoded according to the following possible implementation methods. It should be understood that the way in which the decoding end determines the fixed code length of each component of the block to be decoded is the same as the way in which the encoding end determines the fixed code length of each component when encoding the code stream of the image block corresponding to the block to be decoded.

[0218] In one implementation, the decoding end may obtain the target BPP of the block to be decoded and the image format of the block to be decoded, and determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be decoded according to the target BPP of the block to be decoded and the code length ratio.

[0219] It should be noted that the way in which the decoding end determines the fixed code length of each component corresponds to that of the encoding end. If the encoding end determines the fixed code length of each component of an image block based on the target BPP of the image block and the image format of the block to be decoded, then when decoding the encoded bitstream of the image block, the decoding end also determines the fixed code length of each component of the image block based on the target BPP of the image block and the image format of the block to be decoded.

[0220] Example 1: If the target BPP of the block to be decoded is 8, the target total code length of the block to be decoded is 8 bits × the number of pixels of the block to be encoded, and if the image format is YUV400, the block to be decoded includes only one component, the brightness component, and the total code length of the brightness component can be 8 bits × the number of pixels of the block to be encoded, that is, the fixed code length of the brightness component (the code length of one brightness pixel) is 8 bits. The decoding end can decode the block to be decoded in a fixed code length decoding method based on the code length of 8 bits × the number of pixels of the block to be encoded. Among them, if the block to be decoded is a 16x2 image block, the code length of the block to be decoded is 256 bits.

[0221] Example 2: If the current target BPP is 8, the target code length of the block to be decoded is 8bit×the number of pixels of the block to be encoded, and the image format is YUV444, then the block to be decoded includes three components: luminance Y, chrominance U, and chrominance V. It should be understood that at this time, 8bit×the number of pixels of the block to be encoded cannot be evenly distributed to the three components of luminance Y, chrominance U, and chrominance V. Based on the image format of YUV444, the code length ratio of Y component: U component: V component can be 2:1:1. Thus, the decoder can determine that the total code length of the Y component is 4bit×the number of pixels of the block to be encoded, and the total code length of the U component and the V component are both 2bit×the number of pixels of the block to be encoded. Thus, the decoder can decode the Y component of the block to be decoded in a fixed code length decoding method based on the code length of 4bit×the number of pixels of the block to be encoded. And decode the U component and V component of the block to be decoded in a fixed code length decoding method based on the code length of 2bit×the number of pixels of the block to be encoded.

[0222] In addition, since the image format is YUV444, the number of pixels in each chrominance (U or V) component is the same as the number of pixels in the luminance (Y) component, so the decoder can use 4 bits (that is, the fixed code length of the luminance component is 4 bits) as the fixed code length to decode each pixel in the luminance (Y) component. In addition, the decoder can use 2 bits (that is, the fixed code length of the chrominance component is 2 bits) as the fixed code length to decode each pixel in the chrominance (U or V) component.

[0223] Example 3: If the current target BPP is 8, the target code length of the block to be decoded is 8bit×the number of pixels of the block to be encoded, and the image format is YUV422, then the block to be decoded includes three components: luminance Y, chrominance U, and chrominance V. It should be understood that at this time, 8bit×the number of pixels of the block to be encoded cannot be evenly distributed to the fixed code lengths of the three components of luminance Y, chrominance U, and chrominance V. Based on the image format of YUV422, the code length ratio of Y component: U component: V component can be 2:1:1. Thus, the decoding end can determine that the total code length of the Y component is 4bit×the number of pixels of the block to be encoded, and the total code lengths of the U component and the V component are both 2bit×the number of pixels of the block to be encoded. Thus, the decoding end can decode the Y component of the block to be decoded in a fixed code length decoding method based on the code length of 4bit×the number of pixels of the block to be encoded. Based on a code length of 2 bits×the number of pixels of the block to be encoded, the U component and the V component of the block to be decoded are decoded in a fixed code length decoding manner.

[0224] In addition, since the image format is YUV422, the number of pixels in each chrominance (U or V) component is half the number of pixels in the luminance (Y) component, so the decoder can use 4 bits (that is, the fixed code length of the luminance component is 4 bits) as the fixed code length to decode each pixel in the luminance (Y) component. In addition, the decoder can also use 4 bits (that is, the fixed code length of the chrominance component is 4 bits) as the fixed code length to decode each pixel in the chrominance (U or V) component.

[0225] In another implementation, the decoding end may obtain the target BPP of the block to be decoded, the image format of the block to be decoded, and the code length required for decoding the header information of the block to be decoded. Further, the decoding end may determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be decoded according to the target BPP of the block to be decoded, the image format of the block to be decoded, and the code length required for decoding the header information of the block to be decoded.

[0226] Exemplarily, if the current target BPP is 8, the target code length of the block to be encoded is 8 bits × the number of pixels of the block to be encoded, the code length required for the encoding header information is 2 bits × the number of pixels of the block to be encoded, and if the image format is YUV400, the block to be encoded includes only one component, the brightness component, and the total code length of the brightness component can be 6 bits × the number of pixels of the block to be encoded, so that the fixed code length of the brightness component is 6 bits. The encoder can encode the block to be encoded in a fixed code length encoding method based on the code length of 6 bits × the number of pixels of the block to be encoded. In another example, the decoder can obtain the target BPP of the block to be decoded, the image format of the block to be decoded, and the code length required for decoding the header information of the block to be decoded. Furthermore, the decoder can determine the fixed code length of the chrominance component and the fixed code length of the brightness component of the block to be decoded according to the remaining capacity of the code stream buffer, the target BPP of the block to be decoded, the code length ratio, and the code length required for decoding the header information of the block to be decoded.

[0227] Optionally, the sum of the code lengths of all components of the block to be decoded is the target code length of the block to be decoded minus the code length of header information of the block to be decoded and the excess code length of the code stream buffer.

[0228] The target code length is the code length of the block to be decoded determined based on the target BPP, the change in the overflow line is set to be less than or equal to the difference between the fixed code length of the block to be decoded and the code length of the header information of the block to be decoded, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the current set overflow line.

[0229] Exemplarily, if the target BPP is 8, the target code length of the block to be decoded is 8bit×the number of pixels of the block to be encoded, if the header information needs to occupy 2bit×the number of pixels of the block to be encoded, at this time, the state of the code stream buffer is greater than the current set overflow line, then the code length occupied by the part greater than the overflow line is set to overflow_bpp, then at this time, the sum of the code lengths of all components of the block to be decoded is the target code length of the block to be decoded (that is, 8bit×the number of pixels of the block to be encoded) minus the code length occupied by the decoding header information (for example, 2bit×the number of pixels of the block to be encoded), and then minus overflow_bpp (for example, 1bit×the number of pixels of the block to be encoded). Thus, at this time, the sum of the code lengths of all components of the block to be decoded is 5bit×the number of pixels of the block to be encoded. Furthermore, the decoding end can determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be decoded according to the image format of the block to be decoded and 5bit×the number of pixels of the block to be encoded.

[0230] S203: The decoding end parses the pixel points of each component in the to-be-decoded block based on the fixed code length of each component to decode the to-be-decoded block.

[0231] In some embodiments, Figure 8 As shown, the above step S203 can be specifically implemented as the following steps S2031 to S2034:

[0232] S2031. The decoding end determines a residual value of each component of the block to be decoded based on a fixed code length of each component.

[0233] Exemplarily, the decoding end may determine the residual value of each pixel in each component of the block to be decoded based on the fixed code length of each component of the block to be decoded determined in step S202.

[0234] S2032. The decoding end obtains a prediction mode of the block to be decoded in the fallback mode, predicts an image block corresponding to the block to be decoded according to the prediction mode, and obtains a prediction value of the block to be decoded.

[0235] Optionally, the decoding end may use the prediction mode corresponding to the fallback mode to predict the block to be decoded, that is, the first fallback mode mentioned above. Alternatively, the decoding end may use any prediction mode in the prediction mode preset by the decoding end to predict the block to be decoded, that is, the second fallback mode mentioned above. It should be understood that the decoding end may determine the prediction mode corresponding to the fallback mode as a fixed one of the prediction modes preset by the decoding end. Thus, for all blocks to be decoded that are decoded using the fallback mode, the decoding end uses the fixed prediction mode for prediction.

[0236] The prediction mode preset in the decoding end is the same as the prediction mode preset in the encoding end. For the introduction of the specific prediction mode, reference may be made to the relevant description in the above step S103, which will not be repeated here.

[0237] In one implementation, when the block to be decoded includes a component, the decoder can parse the code stream of the block to be decoded to determine the prediction mode of the block to be decoded. Alternatively, the decoder can determine a preset prediction mode as the prediction mode of the block to be decoded, and it should be understood that the preset prediction mode is the same as the prediction mode used by the encoder in the prediction process.

[0238] In another implementation, when the block to be decoded includes multiple components, the multiple components of the block to be decoded may use the same prediction mode, so that the decoding end may determine only the prediction mode of one of the components, and the prediction mode is the prediction mode of all components of the block to be decoded. Alternatively, some of the multiple components of the block to be decoded may use the same prediction mode, and the decoding end may determine only the prediction mode of one of the components, and the prediction modes of the other components except the components. Alternatively, the decoding end may determine the prediction mode of each component separately.

[0239] S2033: The decoding end determines a quantization parameter of the block to be decoded, and dequantizes the residual value of the block to be decoded according to the quantization parameter.

[0240] Optionally, the decoder may first determine an initial quantization parameter of the block to be decoded, and then adjust the initial quantization parameter based on the quantization parameter adjustment value to determine the quantization parameter of the block to be decoded. The target quantization parameter has a value range between zero and a preset maximum value of the quantization parameter of the encoder.

[0241] Exemplarily, the quantization parameter of the block to be decoded may be the sum of the initial quantization parameter and the quantization parameter adjustment value. It should be understood that the decoding end determines the quantization parameter in the same manner as the block to be decoded determines the quantization parameter of the image block.

[0242] The larger the remaining capacity of the code stream buffer is, the larger the quantization parameter adjustment value is. The value of the quantization parameter adjustment value can be a positive integer such as 4 or 8.

[0243] The decoding end determines the original quantization parameter in at least the following ways:

[0244] In one implementation, the header information of the block to be decoded includes a quantization parameter when a quantization operation is performed on an image block corresponding to the block to be decoded, so that the decoding end can parse the header information of the block to be decoded and determine an initial quantization parameter of the block to be decoded.

[0245] In another implementation manner, the decoding end may derive the initial quantization parameter of the block to be encoded according to the complexity information of the image block corresponding to the block to be encoded and the remaining space of the code stream buffer.

[0246] Furthermore, the decoding end can determine the quantization step size Qstep according to the QP value by at least one of formula derivation or table lookup, and three possible implementation methods are provided below. Then, for the selected quantizer combination, the Qstep of the block to be decoded is used to perform inverse quantization on each pixel of the block to be decoded.

[0247] Method 1: , where a and b are preset parameters, for example, a is 2 and b is 1.

[0248] Method 2: , where T is an integer related to QP, for example, T = (QP-6) / 4.

[0249] Method 3: , where octave is the level of QP, that is, when the QP value increases by octave, the Qstep value doubles. Usually octave is selected as 6 or 8. offset An integer offset value.

[0250] Optionally, the conventional scalar quantization method in H.265 described below may be used to implement quantization and inverse quantization.

[0251] Quantification:

[0252] Dequantization:

[0253] in, l is the level value obtained after quantization, c is the residual coefficient to be quantized (the residual coefficient may be the residual coefficient of the transform domain, i.e. the transformed residual coefficient; or the residual coefficient may be the residual coefficient of the pixel domain, i.e. the residual value), Qstep is the quantization step size, f is a parameter that controls rounding, , sign represents the symbolic function, floor represents the floor function; c' is the dequantized value.

[0254] It can be understood that the larger the QP value and the larger the Qstep value, the coarser the quantization, the greater the image distortion caused by quantization, and the smaller the bit rate of coefficient encoding.

[0255] Represents the quantization dead zone, parameter f It is related to the length of the quantization dead zone.f The smaller it is, the longer the quantization dead zone is, and the closer the quantized horizontal value is to zero. f =0.5, the above quantization and dequantization formulas are equivalent to rounding, and the quantization distortion is minimal. f When <0.5, f The smaller the value, the greater the quantization distortion and the lower the bit rate of coefficient encoding. In H.265, for I frames, select f =1 / 3, for B / P frames, select f =1 / 6.

[0256] For example, the quantization or dequantization formula of the uniform quantizer can refer to the above quantization and dequantization formulas, and the parameters f There are the following methods:

[0257] Method 1: f Take it as 0.5 or other fixed value.

[0258] Method 2: f It can be adaptively determined according to the QP value, prediction mode, and whether to perform transformation.

[0259] S2034: The decoding end reconstructs the block to be decoded according to the residual value and the prediction value after the inverse quantization of the block to be decoded, to obtain a reconstructed block of the image block.

[0260] Based on the above embodiment, when the fallback mode is adopted in the encoding segment, the decoding end can adopt the fallback mode to decode the block to be decoded, and can avoid the overflow or underflow of the code stream based on the remaining memory of the code stream buffer, thereby avoiding the loss of image information of the block to be decoded.

[0261] In some embodiments, the image decoding process provided by the present application can also be specifically described as follows:

[0262] The first step is to first determine whether the block to be decoded satisfies condition 1. If condition 1 is satisfied, the block to be decoded is decoded in a fallback mode.

[0263] The above condition 1 specifically means that the total code length obtained by encoding all components of the to-be-decoded block in the original value mode exceeds the code length that can be currently accommodated by the code stream buffer. The code length that can currently be accommodated by the code stream buffer can be determined by subtracting the memory capacity occupied by the code length that has been stored in the current code stream buffer from the memory capacity indicated by the current set overflow line.

[0264] That is, if the current code stream buffer state cannot satisfy the original value mode for encoding all components at the same time, the block to be decoded is parsed based on the fallback mode, and the original value mode is turned off.

[0265] Optionally, the decoder can first obtain the stored code length (CurrBits) in the current code stream buffer. Then, the decoder can determine that the image size of a block to be decoded is 16 in width (CbWidth) and 16 in height (CbHeight). Determine the code length required to encode the block to be encoded using the original value mode (FallbackFlag = 0). Specifically, the image format (image_format) and image size (cbChromaSize) of each component of the block to be decoded are parsed to obtain the code length (modeBits) required for encoding each component using the original value mode.

[0266] Furthermore, the decoder can calculate the total code length required to encode the block to be encoded using the original value mode (BitDepth[0] × cbLumaSize + BitDepth[1]× cbChromaSize × 2 – (TargetBpp<<1) ). And determine whether the total code length meets condition 1. If condition 1 is met, the block to be decoded is decoded in fallback mode. Finally, the decoder can locate the decoding block (CuPosX[0], CuPosY[0]). Thus, the next image block is parsed.

[0267] In the second step, the decoding end can determine the complexity and encoding mode of the block to be decoded.

[0268] Optionally, the decoding end may parse the complexity (complexity_level_flag) of a component of the to-be-decoded block with a fixed code length of 1 bit (u(1)) or 3 bits.

[0269] Furthermore, the decoding end may also parse the encoding mode of the block to be decoded.

[0270] The decoder can first determine the prediction mode, and then determine the encoding mode of the block to be decoded based on the prediction mode. If the fallback mode (allowfallback) is currently allowed and is in the original value mode, the prediction mode of the current block to be decoded is first assigned to the block prediction mode (IBC_MODE), that is, the prediction mode corresponding to the first fallback mode. Thus, the decoder parses the coordinates of the prediction block corresponding to the current block to be decoded in the search area (abs_bvd_minus1[blkIdx]) with a fixed code length of 5 bits (u(5)).

[0271] The third step is to derive a fixed-length code at the decoding end and use the fixed-length code to parse each quantized coefficient value.

[0272] If it is the first fallback mode, the coefficient value is represented by the quantized residual value. If it is the second fallback mode, there is no prediction mode at this time, and the coefficient value is represented by the quantized original value.

[0273] Finally, after inverse quantization, if it is the first fallback mode, the predicted value plus the residual value is used to obtain the reconstructed value, and if it is the second fallback mode, the inverse quantized value is used as the reconstructed value.

[0274] The above process can be specifically implemented as the following text description process:

[0275] coding_unit_data_substream0 (cuIdxX, cuIdxY) {

[0276] BitsRecord = CurrBits

[0277] CbWidth[0] = 16

[0278] CbHeight[0] = 2

[0279] FallbackFlag = 0

[0280] cbLumaSize = CbWidth[0] × CbHeight[0]

[0281] if (image_format == '001'){ / * YUV400 * /

[0282] cbChromaSize = 0

[0283] modeBits = 8

[0284] } else if (image_format == '001') { / * YUV420 * /

[0285] cbChromaSize = cbLumaSize>>2

[0286] modeBits = 15

[0287] } else if (image_format == '010') { / * YUV422 * /

[0288] cbChromaSize = cbLumaSize>>1

[0289] modeBits = 15

[0290] } else {

[0291] cbChromaSize = cbLumaSize

[0292] modeBits = 21

[0293] }

[0294] allowfallback = modeBits + (BitDepth[0] × cbLumaSize + BitDepth[1]×cbChromaSize × 2 – (TargetBpp<<1))>= MaxBufferSize – (CurrBits – OutBits)

[0295] CuPosX[0] = cuIdxX<<4

[0296] CuPosY[0] = cuIdxY<<1

[0297] CurrBlocks++

[0298] complexity_level_flag[0] u(1)

[0299] if (ComplexityLevelFlag[0] = 0) {

[0300] delta_level[0] u(2)

[0301] if (delta_level[0]>= PrevComplexityLevel) {

[0302] ComplexityLevel[0] = DeltaLevel[0]+ 1

[0303] } else {

[0304] ComplexityLevel[0] = DeltaLevel[0]

[0305] }

[0306] } else {

[0307] ComplexityLevel[0] = PrevComplexityLevel

[0308] }

[0309] PrevComplexityLevel = ComplexityLevel[0]

[0310] pred_mode[0] ae(v)

[0311] if (PredMode[0] == ORG_MODE&&allowfallback) {

[0312] FallbackFlag = 1 u(1)

[0313] fallback_type

[0314] PredMode[0] == FallbackType == 1 'ORG_MODE' : 'IBC_MODE'

[0315] }

[0316] if (PredMode[0] == 'IBC_MODE') {

[0317] for (blkIdx=0; blkIdx<8; blkIdx++) {

[0318] abs_bvd_minus1[blkIdx] u(5)

[0319] }

[0320] }

[0321] if (PredMode[0] != POINT_MODE_1&&PredMode[0] != POINT_MODE_1&&PredMode[0] != ORG_MODE&&!LosslessFlag&&!FallbackFlag) {

[0322] resi_skip[0] u(1)

[0323] }

[0324] if (ResiSkip[0] != 1) {

[0325] coeff_data(BitDepth[0], 0)

[0326] }

[0327] } In the above text description, the method for determining the type binary variable of the fallback mode. If the value is '1', it means that the fallback mode adopted by the current coding unit is the original value truncation mode, and if the value is '0', it means that the fallback mode adopted by the current coding unit is the residual truncation mode. The value of FallbackType is equal to the value of fallback_type.

[0328] In some embodiments, the decoding end obtains binary data of a fixed-length code representing a block to be decoded in a code stream, and processes the binary data using a debinarization method to obtain specific data of the BPP.

[0329] The decoder first determines the binary data of the fixed-length code (org_data):

[0330] If the fallback mode flag value (FallbackFlag) is equal to 0, that is, the fallback mode is not used during encoding, the bit depth (BitDepth[component]) value of the current channel is used as the code length (len) of the fixed-length code, and the value of org_data is equal to the value of "synElVal" in Table 1.

[0331] Otherwise, the decoding end uses the value of the fixed-length code as the code length len, and the value of org_data is equal to the value of synElVal (refer to Table 1 below).

[0332] The specific derivation of fixed-length codes is as follows:

[0333] 1) The decoder first calculates the value of the target BPP (adjTargetBpp) after adjusting the overflow line:

[0334] If (BitsRecord–((target BPPTargetBpp<<1)×(next block to be decoded (CurrBlocks)–1))) is greater than the maximum set overflow line (MaxBufferSize), adjTargetBpp is equal to (((Target_bpp<<1)–(BitsRecord–((TargetBpp<<1)×(CurrBlocks–1))–MaxBufferSize))>>5);

[0335] Otherwise, adjTargetBpp is equal to (Target_bpp>>4).

[0336] Where (Target_bpp>>4) refers to the target BPP.

[0337] 2) The decoder determines the code length of the fixed-length code on each component according to adjTargetBpp:

[0338] If the image format is equal to YUV400, the fixed-length code is equal to (adjTargetBpp-2).

[0339] Otherwise, determine whether the current component is equal to the brightness component.

[0340] If it is equal to the luminance component, the fixed-length code is equal to (adjTargetBpp-2) / 3+(adjTargetBpp-2) / 3.

[0341] otherwise,

[0342] If the image format is equal to YUV420, the fixed-length code is equal to (adjTargetBpp-2) / 3<<2.

[0343] Otherwise, if the image format is equal to YUV422, the fixed-length code is equal to (adjTargetBpp-2) / 3<<1.

[0344] Otherwise, the fixed-length code is equal to (adjTargetBpp-2) / 3.

[0345] Table 1

[0346]

[0347] The following describes the encoding device and decoding device provided by the embodiments of the present application.

[0348] In one example, any decoding device provided in the embodiments of the present application may be Figure 1 In another example, any of the following encoding devices may be Figure 1 The encoding end 20 or the encoder 200 in the embodiment is described uniformly here and will not be described in detail below.

[0349] Fig. 9 The present application provides a structural schematic diagram of an image encoding device 900, and any of the above encoding method embodiments can be executed by the encoding device 900. The image encoding device 900 includes a determination module 901 and an encoding module 902. The determination module 901 is used to obtain the maximum code length of the block to be encoded, and the maximum code length is the maximum code stream length of the block to be encoded that is allowed to be cached in the code stream buffer determined based on the set overflow line of the code stream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by the code stream in the code stream buffer. The encoding module 902 is used to pre-encode the block to be encoded to obtain a first code length of the block to be encoded, and the first code length is the length of the code stream obtained after encoding the block to be encoded. The encoding module 903 is further configured to, if the first code length is greater than or equal to the maximum code length, use a fallback mode to encode the block to be encoded, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length, and the code stream obtained by encoding the block to be encoded based on the fallback mode includes a first code word, and the first code word is used to indicate the fallback mode or the original value mode. .

[0350] For a more detailed description of the above-mentioned determination module 901, processing module 902 and encoding module 903, as well as a more detailed description of each technical feature therein, and a description of the beneficial effects, etc., please refer to the above-mentioned corresponding method embodiment part, which will not be repeated here.

[0351] Fig.10 The present application provides a structural schematic diagram of an image decoding device 1000, and any of the above decoding method embodiments can be executed by the decoding device 1000. The image decoding module 1000 includes a parsing module 1001 and a determining module 1002. The parsing module 1001 is used to parse the code stream of the block to be decoded, and if the code stream of the block to be decoded includes a first code word, determine whether the image block corresponding to the block to be decoded adopts a fallback mode, wherein the code length of the block to be decoded is less than the maximum code length of the block to be decoded, and the maximum code length is the maximum code stream length of the block to be decoded that is allowed to be cached in the code stream buffer determined based on the set overflow line of the code stream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by the code stream in the code stream buffer, and the first code word is used to indicate the fallback mode or the original value mode. The determination module 1002 determines the fixed code length of each component of the block to be decoded according to the excess code length of the code stream buffer when the image block corresponding to the block to be decoded adopts the fallback mode and the code length stored in the code stream buffer exceeds the set overflow line, wherein the block to be decoded includes one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required for parsing a single pixel of the first component, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the current set overflow line. The parsing module 1001 is also used to parse the pixel points of each component based on the fixed code length of each component to decode the block to be decoded.

[0352] For a more detailed description of the above-mentioned analysis module 1001 and determination module 1002, as well as a more detailed description of each technical feature therein, and a description of the beneficial effects, etc., please refer to the above-mentioned corresponding method embodiment part, which will not be repeated here.

[0353] The present application also provides an electronic device for executing any of the above-mentioned image encoding / decoding methods. Fig.11 As shown, Fig.11 This is a schematic diagram of the structure of an electronic device provided by the present application, where the electronic device 1100 includes a processor 1101 and a communication interface 1102. The processor 1101 and the communication interface 1102 are coupled to each other. It can be understood that the communication interface 1102 can be a transceiver or an input-output interface.

[0354] In one example, the electronic device 1100 may further include a memory 1103 for storing instructions executed by the processor 1101 or storing input data required for the processor 1101 to run instructions or storing data generated after the processor 1101 runs instructions.

[0355] The specific connection medium between the communication interface 1102, the processor 1101 and the memory 1103 is not limited in the embodiment of the present application. Fig.11 The communication interface 1102, the processor 1101 and the memory 1103 are connected via a bus 1104. Fig.11 The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.11 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0356] The memory 1103 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 the embodiment of the present application. The processor 1101 executes the software programs and modules stored in the memory 1103 to perform various functional applications and data processing to implement any of the image decoding methods or image encoding methods provided above. The communication interface 1102 may be used to communicate signaling or data with other devices. In the present application, the electronic device 1100 may have multiple communication interfaces 1102.

[0357] It is understandable that the processor in the embodiments of the present application may be a central processing unit (CPU), a neural processing unit (NPU) or a graphic processing unit (GPU), or may be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.

[0358] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a network device or a terminal device. Of course, the processor and the storage medium can also be present in a network device or a terminal device as discrete components.

[0359] An embodiment of the present application also provides a coding and decoding system, including a coding end and a decoding end, wherein the coding end can be used to execute any one of the image coding methods provided above, and the decoding end is used to execute the corresponding image decoding method.

[0360] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is executed in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable device. The computer program or instruction may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instruction may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, for example, a floppy disk, a hard disk, a tape; it may also be an optical medium, for example, a digital video disc (DVD); it may also be a semiconductor medium, for example, a solid state drive (SSD).

[0361] In the various embodiments of the present application, unless otherwise specified or provided for in any logical conflict, the terms and / or descriptions between the different embodiments are consistent and may be referenced to each other, and the technical features in the different embodiments may be combined to form new embodiments according to their inherent logical relationships.

[0362] It is understood that the various numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. The size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic.

Claims

1. An image decoding method, characterized in that: Applied to a decoding end, the method comprises: Parsing a code stream of a block to be decoded, and if the code stream of the block to be decoded includes a first code word, determining whether a fallback mode is adopted when decoding an image block corresponding to the block to be decoded, wherein the code length of the block to be decoded is less than the maximum code length of the block to be decoded, the maximum code length is a maximum code stream length of the block to be decoded that is allowed to be cached in a code stream buffer determined based on a set overflow line of the code stream buffer, the set overflow line is used to indicate a maximum storage space allowed to be occupied by the code stream in the code stream buffer, and the first code word is used to indicate the fallback mode or the original value mode; If the image block corresponding to the to-be-decoded block adopts the fallback mode during decoding, and the code length stored in the code stream buffer exceeds the set overflow line, then determine the fixed code length of each component of the to-be-decoded block according to the excess code length of the code stream buffer, wherein the to-be-decoded block includes one or more components, and for a first component of the to-be-decoded block, the fixed code length of the first component is used to indicate the code length required for parsing a single pixel of the first component, and the excess code length of the code stream buffer is the code length of the stored code length in the code stream buffer exceeding the set overflow line; Based on the fixed code length of each component, the pixel points of each component are parsed to decode the block to be decoded.

2. The method according to claim 1, characterized in that The determining whether the image block corresponding to the to-be-decoded block adopts the fallback mode during decoding includes: If the code length of the image block corresponding to the block to be decoded encoded based on the original value mode is greater than or equal to the maximum code length of the block to be decoded, it is determined that the image block corresponding to the block to be decoded adopts the fallback mode during decoding.

3. The method according to claim 1, characterized in that The parsing of the pixel points of each component based on the fixed code length of each component includes: Determining a residual value of each component of the to-be-decoded block based on a fixed code length of each component; Acquire a prediction mode of the block to be decoded in the fallback mode, predict an image block corresponding to the block to be decoded according to the prediction mode, and obtain a prediction value of the block to be decoded; Determining a quantization parameter of the block to be decoded, and dequantizing a residual value of the block to be decoded according to the quantization parameter; The block to be decoded is reconstructed according to the residual value after inverse quantization of the block to be decoded and the predicted value to obtain a reconstructed block of the image block.

4. The method according to claim 3, characterized in that The obtaining the prediction mode of the block to be decoded in the fallback mode includes: The prediction mode of the block to be decoded is the prediction mode corresponding to the fallback mode; or, the prediction mode of the block to be decoded is one of multiple prediction modes of a decoding end.

5. The method according to any one of claims 1 to 4, characterized in that The sum of the code lengths of all components of the block to be decoded is the target code length of the block to be decoded minus the code length of the header information of the block to be decoded and the excess code length of the code stream buffer.

6. An image encoding method, characterized in that: The method comprises: Acquire a maximum code length of a block to be encoded, where the maximum code length is a maximum code stream length of the block to be encoded that is allowed to be cached in a code stream buffer determined based on a set overflow line of the code stream buffer, where the set overflow line is used to indicate a maximum storage space allowed to be occupied by a code stream in the code stream buffer; Pre-encoding the block to be encoded to obtain a first code length of the block to be encoded, where the first code length is the length of a code stream obtained after pre-encoding the block to be encoded; If the first code length is greater than or equal to the maximum code length, the block to be encoded is encoded in a fallback mode, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length, and the code stream obtained by encoding the block to be encoded based on the fallback mode includes a first codeword, and the first codeword is used to indicate the fallback mode or the original value mode.

7. An image decoding device, characterized in that: The device is applied to a decoding end, and comprises: A parsing module, parsing a code stream of a block to be decoded, and if the code stream of the block to be decoded includes a first code word, determining whether a fallback mode is adopted when decoding an image block corresponding to the block to be decoded, wherein the code length of the block to be decoded is less than the maximum code length of the block to be decoded, the maximum code length is a maximum code stream length of the block to be decoded that is allowed to be cached in a code stream buffer determined based on a set overflow line of the code stream buffer, the set overflow line is used to indicate a maximum storage space allowed to be occupied by the code stream in the code stream buffer, and the first code word is used to indicate the fallback mode or the original value mode; a determination module, configured to determine, when a fallback mode is adopted during decoding of an image block corresponding to the block to be decoded and the code length stored in the code stream buffer exceeds the set overflow line, a fixed code length of each component of the block to be decoded according to the excess code length of the code stream buffer, wherein the block to be decoded includes one or more components, and for a first component of the block to be decoded, the fixed code length of the first component is used to indicate a code length required for parsing a single pixel of the first component, and the excess code length of the code stream buffer is a code length of the code length stored in the code stream buffer exceeding the set overflow line; The parsing module is further used to parse the pixel points of each component based on the fixed code length of each component to decode the block to be decoded.

8. An image encoding device, characterized in that The device uses an encoding end, and the device includes: a determination module, configured to obtain a maximum code length of a block to be encoded, wherein the maximum code length is a maximum code stream length of the block to be encoded that is allowed to be cached in a code stream buffer determined based on a set overflow line of the code stream buffer, wherein the set overflow line is used to indicate a maximum storage space allowed to be occupied by a code stream in the code stream buffer; An encoding module, configured to pre-encode the block to be encoded to obtain a first code length of the block to be encoded, where the first code length is the length of a code stream obtained after encoding the block to be encoded; The encoding module is further used to, if the first code length is greater than or equal to the maximum code length, encode the block to be encoded in a fallback mode, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length, and the code stream obtained by encoding the block to be encoded based on the fallback mode includes a first code word, and the first code word is used to indicate the fallback mode or the original value mode.

9. An electronic device, characterized in that: The system comprises a processor and a memory, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement the method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program or instruction. When the computer program or instruction is executed by an electronic device, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method, medium, and system visually compressing image data

    CN101193301A

  • Rate-constrained fallback mode for display stream compression

    CN107409219A