Image decoding method, encoding method and apparatus
The image decoding and encoding methods address the challenge of buffer overflow by using a fallback mode to adjust code lengths, ensuring stable bitstream management and preserving image information.
Patent Information
- Application Number
- JP2025504535
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-07-27
- Filing Date
- 2023-07-25
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-07-25
AI Technical Summary
Existing video encoding technologies face challenges in controlling the bit rate generated by the encoder based on the remaining storage space of the buffer, leading to potential overflow and loss of image information due to variable-bitrate data not being suitable for real-time fixed-bitrate channels.
An image decoding method that analyzes a bitstream block to determine if it uses a fallback mode, and if the code length exceeds the set overflow line, it adjusts the code length for each component of the block to avoid overflow or underflow, while an image encoding method pre-encodes blocks and uses a fallback mode when necessary to maintain the bitstream within the buffer limits.
The method effectively prevents bitstream overflow or underflow, ensuring that image information is not lost during decoding by dynamically adjusting the encoding process based on buffer capacity.
Smart Images

Figure 2025525018000001_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of video encoding and decoding, and in particular, to an image decoding method, an encoding method, and an apparatus.
Background Art
[0002] Video encoding technology, also called video compression technology, is used to reduce the data bandwidth of video signals. Here, video is a continuous image sequence composed of continuous image frames, and one frame of image is one image. Due to the afterimage effect in the human eye's vision, when the frame sequence is played back at a certain rate, what the human eye sees is continuous video. Encoding and decoding video means encoding and decoding the images of each frame of the video. Taking one frame of image as an example, on the encoding side, an image encoder encodes the image, obtains a bitstream corresponding to the image, and transmits the bitstream to the decoding side. On the decoding side, an image decoder analyzes the bitstream and reconstructs the image.
[0003] In the process of image encoding and decoding, in order to improve the compression efficiency, general video compression technology adopts variable-length coding. The bitstream obtained after a video sequence is compressed and encoded has a variable rate and is not suitable for transmission in a real-time fixed-bitrate channel. Therefore, usually, the variable-bitrate data generated by the encoder is output to a buffer with a specific storage space and then output from the buffer at a constant bitrate. The size of the buffer's storage space is fixed. If the bitstream data input to the buffer is too large and the data that needs to be temporarily stored in the buffer exceeds the size of its storage space, it should be understood that "overflow" of the bitstream will occur and subsequent image information will be lost.
[0004] Therefore, in the process of image encoding and decoding, how to control the bit rate generated by the encoder based on the remaining storage space of the buffer has become an urgent issue.
Summary of the Invention
[0005] Embodiments of the present invention provide an image decoding method, an encoding method, and an apparatus for avoiding overflow of a bitstream.
[0006] To achieve the above object, the embodiments of the present invention adopt the following technical solutions.
[0007] According to a first aspect, an embodiment of the present invention provides an image decoding method executed by a decoding side. The method includes analyzing a bitstream of a block to be decoded, and when a first codeword is included in the bitstream of the block to be decoded, determining whether an image block corresponding to the block to be decoded uses a fallback mode. The code length of the block to be decoded is smaller than the maximum code length of the block to be decoded, the maximum code length is determined based on a set overflow line of a bitstream buffer, the set overflow line is used to indicate a maximum storage space that is allowed to be occupied by the bitstream in the bitstream buffer, and the first codeword is a fallback mode or SampleA step used to indicate a mode, and when an image block corresponding to a block to be decoded uses a fallback mode and the code length stored in the bitstream buffer exceeds a set overflow line, based on the excess code length of the bitstream buffer, determining a fixed code length for each component of the block to be decoded, where 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 when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is the code length by which the code length stored in the bitstream buffer exceeds the set overflow line; a step of analyzing pixel points of each component based on the fixed code length of each component and decoding the block to be decoded.
[0008] The image decoding method provided in an embodiment of the present invention has at least the following beneficial effects. When the encoding side uses a fallback mode, the decoding side can decode the block to be decoded using the fallback mode, and based on the remaining memory of the bitstream buffer, it can avoid the occurrence of bitstream overflow or underflow. Thereby, it avoids the loss of image information of the block to be decoded.
[0009] According to a second aspect, an embodiment of the present invention provides an image encoding method executed by an encoding side, the method comprising: obtaining a maximum code length of a block to be encoded, wherein the maximum code length is determined based on a set overflow line of a bitstream buffer, and the set overflow line is used to indicate a maximum storage space that is allowed to be occupied by a bitstream in the bitstream buffer; pre-encoding the block to be encoded to obtain a first code length of the block to be encoded, wherein the first code length is the length of the bitstream obtained after the block to be encoded is pre-encoded; and when the first code length is greater than or equal to the maximum code length, encoding the block to be encoded using 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, the bitstream 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 Sample a mode.
[0010] Based on the above embodiment, the method first pre-encodes the block to be encoded, compares the length of the bitstream obtained by the pre-encoding with the code length allowed to be occupied by the block to be encoded, and based on the comparison result, determines whether an overflow or underflow of the bitstream occurs. Thereby, when it is determined that an overflow or underflow of the bitstream occurs, the block to be encoded is encoded using a fallback mode so that the image information of the block to be encoded is not lost.
[0011] According to a third aspect, the present invention provides an image decoding apparatus. The decoding apparatus may be a video decoder or a device including a video decoder. The decoding apparatus includes each module configured to implement the method in any one of the possible embodiments of the first aspect. The decoding apparatus has a function of realizing the operations in the embodiments of the related method. The function may be realized by hardware or may be realized by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. For the beneficial effects, refer to the description of the corresponding method.
[0012] According to a fourth aspect, the present invention provides an image encoding apparatus. The encoding apparatus may be a video encoder or a device including a video encoder. The encoding apparatus includes each module configured to implement the method in any one of the possible embodiments of the second aspect. The encoding apparatus has a function of realizing the operations in the embodiments of the related method. The function may be realized by hardware or may be realized by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. For the beneficial effects, refer to the description of the corresponding method.
[0013] The 5 aspect provides a computer-readable storage medium storing a computer program or instructions, and when the computer program or instructions are executed by a computing device or a storage system in which the computing device is disposed, the method in any one of the embodiments of the first aspect and the second aspect is implemented.
[0014] Based on the embodiments provided in each of the above aspects, the present invention may be further combined to provide more embodiments. In other words, any one of the possible embodiments of any one of the above aspects may be applied to other aspects to obtain a new embodiment as long as there is no contradiction. For example, any image decoding method provided in the first aspect above can be combined in pairs or in three aspects as long as there is no contradiction, thereby obtaining a new image decoding method.
Brief Description of the Drawings
[0015]
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Figure 11
Best Mode for Carrying Out the Invention
[0016] Hereinafter, with reference to the drawings in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative labor belong to the protection scope of the present invention.
[0017] In the description of the present invention, unless otherwise specified, " / " represents the meaning of "or". For example, A / B can represent A or B. The term "and / or" in this specification is only used to explain the relevant relationship of the relevant object, indicating that there may be three types of relationships. For example, A and / or B can indicate three situations: A exists alone, A and B exist simultaneously, and B exists alone. Also, "at least one" means one or more, and "a plurality of" means two or more. Words such as "first" and "second" do not limit the quantity or execution order, and words such as "first" and "second" do not necessarily limit that they are different.
[0018] In the present invention, terms such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the present invention should not be construed as being more preferable or advantageous than other embodiments or design solutions. Specifically speaking, the use of terms such as "exemplary" or "for example" is intended to specifically present the relevant concept.
[0019] Hereinafter, the system architecture to which the embodiments of the present invention are applied will be described.
[0020] FIG. 1 is a schematic architecture diagram of an encoding / decoding system 1 to which an embodiment of the present invention is applied. As shown in FIG. 1, the encoding / decoding system 1 may include an encoding side 10 and a decoding side 20. The encoding side 10 generates encoded video data. Therefore, the encoding side 10 may be called an encoding device. The decoding side 20 may decode the encoded video data generated by the encoding side 10. Therefore, the decoding side 20 may be called a decoding device.
[0021] Specific forms of the encoding side 10 and the decoding side 20 may be various devices including a desktop computer, a mobile computing device, a notebook (e.g., laptop) computer, a tablet computer, a set-top box, a telephone handset such as a so-called "smart" phone, a television, a camera, a display device, a digital media player, a video game console, an in-vehicle computer, or the like.
[0022] Optionally, the encoding side 10 and the decoding side 20 in FIG. 1 may be two separate devices. Alternatively, the encoding side 10 and the decoding side 20 may be the same device, that is, the encoding side 10 or the corresponding function, and the decoding side 20 or the corresponding function may be integrated into the same device.
[0023] Communication can be performed between the encoding side 10 and the decoding side 20. For example, the decoding side 20 may receive the encoded video data from the encoding side 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 side 10 to the decoding side 20. In one example, the link 30 may include one or more communication media that enable the encoding side 10 to directly transmit the encoded video data to the decoding side 20 in real time. In this example, the encoding side 10 may modulate the encoded video data according to a communication standard (e.g., a wireless communication protocol) and transmit the modulated video data to the decoding side 20. The one or more communication media may include wireless and / or wired communication media such as the 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 (LAN), a wide area network (WAN), or a global network (e.g., the Internet). The one or more communication media may include a router, a switch, a base station, or any other device that facilitates communication from the encoding side 10 to the decoding side 20.
[0024] Optionally, the encoding side 10 may output the encoded data from the output interface 140 to a built-in or external storage device. The storage device may include any one of a plurality of distributed or locally accessible 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 the encoded video data.
[0025] As shown in FIG. 1, the encoding side 10 includes a video source 120, an encoder 100, and an output interface 140. In some examples, the output interface 140 may include a modulator / demodulator (modem) and / or 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-in interface for receiving video data from a video content provider, and / or a computer graphics system for generating video data, or a combination of these sources of video data. The encoder 100 can encode the video data from the video source 120. In some examples, the encoding side 10 directly transmits the encoded video data to the decoding side 20 via the output interface 140. In other examples, the encoded video data may be stored in a storage device for the decoding side 20 to access for decoding and / or playback.
[0026] As shown in FIG. 1, the decoding side 20 includes an input interface 240, a decoder 200, and a display device 220. In some examples, the input interface 240 includes a receiver and / or a modem. The input interface 240 can receive the encoded video data via the link 30 and / or from a storage device. The display device 220 may be integrated with the decoding side 20 or external to the decoding side 20. Generally, the display device 220 displays the decoded video data. The display device 220 may include various display devices such as a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display, or other types of display devices.
[0027] Optionally, the encoding side 10 further includes a bitstream buffer (not shown in FIG. 1), and the bitstream buffer is configured to receive the bitstream data generated by encoding and output fixed-bitrate bitstream data. The size of the bitstream data generated after different blocks to be encoded are encoded can generally vary greatly based on the nature of the blocks to be encoded. Therefore, the bitstream obtained after a video sequence is compression-encoded has a variable rate and is not suitable for transmission in a real-time fixed-bitrate channel. The bitstream buffer can smooth the rate changes in the compressed video. The larger the storage space of the bitstream buffer, the more it can withstand fluctuations in the bitrate.
[0028] Optionally, the decoding side 20 may include another buffer. This buffer is configured to receive fixed-bitrate bitstream data and output it from the buffer to the bitstream analysis unit 201 of the decoder 200.
[0029] Although not shown in FIG. 1, in some embodiments, the encoder 100 and the decoder 200 may be integrated with an audio encoder and decoder, respectively, and may include a suitable multiplexer-demultiplexer unit or other hardware and software to process the encoding of both audio and video in a common data stream or individual data streams.
[0030] The encoding / decoding system 1 shown in FIG. 1 is merely an example, and it should be understood that the technology of the present invention is applicable to video encoding / decoding settings (e.g., video encoding and video decoding) that do not necessarily include data communication between the encoding device and the decoding device. In other examples, the data may be retrieved from local memory and streamed over a network. The video encoding device may encode the data and store it in memory, and / or the video decoding device may read the data from memory and decode it. In many examples, encoding and decoding are performed by devices that do not communicate with each other and that encode data into memory and / or retrieve data from memory and decode it.
[0031] Hereinafter, with reference to the drawings, the specific structures of the encoder 100 and the decoder 200 in FIG. 1 will be briefly described.
[0032] FIG. 2 is a schematic block diagram of an example of an encoder 100 for implementing the method according to an embodiment of the present invention. As shown in FIG. 2, 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 106, a residual inverse transformation unit 107, a reconstruction unit 108, and a filter unit 109.
[0033] In one example, the input to the encoder 100 is an image block of the image to be encoded (i.e., the block to be encoded or the encoding unit).
[0034] In another example, when the input to the encoder 100 is an image to be encoded, the encoder 100 may further include a splitting unit (not shown in FIG. 2). The splitting unit is configured to split the image to be encoded into a plurality of image blocks. The encoder 100 is configured to encode the plurality of image blocks of the image to be encoded block-by-block to complete the encoding of the image to be encoded. For example, the encoder 100 completes the encoding of the image to be encoded by performing encoding processing on each image block.
[0035] For example, a method of dividing an image to be encoded into a plurality of image blocks may include the following steps 11 to 13.
[0036] In step 11, an image of one frame is divided into one or more slices that do not overlap with each other. A plurality of encoding units are included in one slice, there is no dependency between each slice, and they can be encoded and decoded in parallel / independently.
[0037] In step 12, for each slice, the encoding side may divide it into one or more independent encoding units that do not overlap with each other. The independent encoding units may not depend on each other, but some header information of the parallel encoding units may be shared.
[0038] In step 13, for each independent encoding unit, the encoding side may divide it into one or more encoding units that do not overlap with each other. When dividing an independent encoding unit into a plurality of encoding units that do not overlap with each other, the division method may be a horizontal equal division method, a vertical equal division method, or a horizontal and vertical equal division method. Of course, the specific implementation method is not limited to this. Each encoding unit within the independent encoding unit may depend on each other, that is, they may refer to each other during the process of executing the prediction step.
[0039] The width of the encoding unit is w_cu, the height is h_cu, and optionally, the width is larger than the height (except for the edge region). Usually, the encoding unit may be a fixed w_cu×h_cu, and both w_cu and h_cu are powers of 2 (N is 0 or more). For example, the size of the encoding unit may be 16×4, 8×4, 16×2, 8×2, 4×2, 8×1, 4×1, etc.
[0040] The symbolization unit may include three components of luminance Y, chrominance Cb, and chrominance Cr (or three components of red R, green G, and blue B, or three components of luminance Y, chrominance U, and chrominance V), or may include only any one of the components. When the symbolization unit includes three components, the sizes of the three components may be exactly the same or different, specifically related to the input format of the image.
[0041] Figure 3 is a schematic diagram of the correspondence relationship between an image, a parallel encoding unit, an independent encoding unit, and an encoding unit. In Figure 3, taking the example that one image is divided into parallel encoding unit 1 and parallel encoding unit 2 according to 3:1, and one independent encoding unit includes four encoding units for explanation.
[0042] Optionally, the splitting unit splits the image to be encoded into a plurality of image blocks, and these image blocks may be further split into smaller blocks, such as image block splitting based on a quadtree structure or a binary tree structure. Also, this splitting may include splitting into tiles, slices, or other large units. A tile may be split into a plurality of image blocks (or may be split into a set of image blocks called slices).
[0043] The prediction processing unit 101 is configured to receive or acquire the original value of the block to be encoded and the reconstructed image data, predict the block to be encoded based on the relevant data in the reconstructed image data, and obtain the predicted block of the block to be encoded.
[0044] Optionally, the prediction processing unit 101 may include an inter predictor and an intra predictor. The inter predictor determines an inter prediction mode for encoding the block to be encoded, and based on the determined inter prediction mode, predicts motion information, such as a motion vector (MV), of one or more sub-blocks within the current image block, and uses the motion information (e.g., motion vector) of one or more sub-blocks within the current image block to obtain or generate a prediction block of the current image block. The intra predictor may determine an intra prediction mode for encoding the block to be encoded.
[0045] Here, intra prediction refers to predicting using an encoded block of the current image block by utilizing the correlation in the video spatial region in order to achieve the purpose of removing redundancy in the video spatial region. For example, intra prediction defines a plurality of prediction modes, and each prediction mode corresponds to one texture direction (excluding the DC mode). For example, when the image texture is horizontal, the horizontal prediction mode can better predict the image information.
[0046] Inter prediction refers to predicting pixels of the current image using pixels of a neighboring encoded image because the video sequence contains strong temporal correlation in order to effectively remove redundancy in the video temporal region based on the correlation in the video temporal region. All parts of the inter prediction in the video coding standard adopt a block-based motion compensation technique. The main principle is to find the optimal matching block in the previous encoded image for each pixel block of the current image. This process is called motion estimation (ME).
[0047] Also, in the inter-prediction mode, the motion vector can be used to represent the relative displacement between the current block to be encoded and the optimal matching block in the reference image. For each of the divided blocks, since the corresponding motion vector is transmitted to the decoding side, when encoding and transmitting independently for the motion vector of each block, especially when divided into blocks of a particularly small size, a considerably large number of bits need to be consumed. To reduce the number of bits for encoding the motion vector, by utilizing the spatial correlation between adjacent image blocks, the motion vector of the current block to be encoded is predicted based on the motion vectors of adjacent encoded blocks, and the prediction difference is encoded. Thereby, the number of bits representing the motion vector can be effectively reduced. In the process of encoding the motion vector of the current block to be encoded, first, the motion vector of the current block to be encoded is predicted using the motion vectors of adjacent encoded blocks, and then, the difference value (motion vector difference, MVD) between the predicted value of the motion vector (motion vector prediction, MVP) and the actual estimated value of the motion vector is encoded, whereby the number of encoded bits of the MV is effectively reduced.
[0048] The residual calculation unit 102 is configured 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, and obtain the residual block. For example, for each pixel, the pixel value of the predicted block is subtracted from the original pixel value of the block to be encoded.
[0049] In one example, the residual transform unit 103 is configured to determine a residual coefficient based on a residual block. Optionally, this process may include performing a transform such as a discrete cosine transform (DCT) or a discrete sine transform (DST) on the residual block to obtain a transform coefficient in the transform domain. The transform coefficient may be referred to as a transform residual coefficient or a residual coefficient. The residual coefficient can represent the residual block in the transform domain. Of course, in the process of encoding the block to be encoded by the encoder 100, the step of residual transform may not be included.
[0050] The quantization unit 104 is configured to quantize the transform coefficient or the residual value by applying scalar quantization or vector quantization to obtain a quantized residual coefficient (or a quantized residual value). The quantization process can reduce the bit depth regarding a part or all of the residual coefficients. For example, at quantization, a p-bit transform coefficient may be truncated to a q-bit transform coefficient, where p is greater than q. The degree of quantization can be changed by adjusting a quantization parameter (QP). For example, for scalar quantization, different scales can be applied to achieve finer quantization or coarser quantization. A smaller quantization step corresponds to finer quantization, and a larger quantization step corresponds to coarser quantization. An appropriate quantization step may be indicated by the QP.
[0051] Here, in the image encoding process, in order to achieve compression of an image, generally, quantization is performed on the residual block of the block to be encoded, or quantization is performed on the residual coefficient block obtained by subjecting the residual block to specific processing, so that the quantized residual block or residual coefficient block can be encoded with fewer bits. 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 it can be understood that the residual coefficient block is a coefficient block obtained by performing specific processing and conversion on the residual block.
[0052] As an example, when the encoder 100 quantizes the residual block, the encoder 100 may divide each residual value in the residual block of the block to be encoded by a quantization coefficient to reduce the residual values in the residual block. In this way, the residual values reduced after quantization can be encoded with fewer bits compared to the non - quantized residual values, thereby realizing compression encoding of the image.
[0053] The encoding unit 105 encodes the above - mentioned quantized residual coefficients (or quantized residual values), outputs the encoded image data (i.e., the encoding result of the currently block to be encoded) in the form of an encoded bit stream (or a bit stream), and then is configured to transmit the encoded bit stream to the decoder or store it for subsequent transmission or retrieval to the decoder. The encoding unit 105 may be further configured to encode the syntax elements of the block to be encoded. For example, it encodes the prediction mode used by the block to be encoded into the bit stream.
[0054] In one example, a realizable method for the encoding unit 105 to encode the residual coefficients is the semi-fixed length encoding method. First, the maximum absolute value of the residuals within one residual block (RB) is defined as the modified maximum (mm). The number of encoding bits for the residual coefficients within the RB is determined (the number of encoding bits for the residual coefficients within the same RB is the same). For example, when the code length CL of the current RB is 2 and the current residual coefficient is 1, 2 bits are required to encode the residual coefficient 1, which is represented as 01. When the CL of the current RB is 9 it indicates encoding an 8-bit residual coefficient and a 1-bit sign bit. The determination of CL is to find the minimum value of M that satisfies the condition that all the residuals of the current sub-block are within the range of [-2^(M - 1), 2^(M - 1)]. If both of the two boundary values of -2^(M - 1) and 2^(M - 1) exist simultaneously, M needs to be increased by 1, that is, M + 1 bits are required to encode all the residuals of the current RB. If only one of the two boundary values of -2^(M - 1) and 2^(M - 1) exists, it is necessary to encode one Trailing bit to determine whether the boundary value is -2^(M - 1) or 2^(M - 1). If neither -2^(M - 1) nor 2^(M - 1) exists for all the residuals, there is no need to encode the Trailing bit.
[0055] Of course, other residual coefficient encoding methods, such as the exponential Golomb encoding method, the Golomb - Rice encoding method, the Truncated Unary (TU) encoding method, the Run Length Encoding (RLE) method, the direct encoding method for the original residual values, etc., may also be adopted.
[0056] Also, in some special cases, instead of the residual values, the original values may be directly encoded.
[0057] The inverse quantization unit 106 is configured to inverse-quantize the above-mentioned quantized residual coefficients (or quantized residual values) to obtain inverse-quantized residual coefficients (residual values after inverse quantization). This inverse quantization is the inverse application of the above-mentioned quantization unit 104. For example, based on the same quantization step as that of the quantization unit 104, or using the same quantization step as that of the quantization unit 104, the inverse quantization method of the quantization method applied by the quantization unit 104 is applied.
[0058] The residual inverse transform unit 107 is configured to perform an inverse transform on the above-mentioned inverse-quantized residual coefficients to obtain a reconstructed residual block. Optionally, the inverse transform may include an inverse discrete cosine transform (DCT) or an inverse discrete sine transform (DST). Thus, the inverse transform value obtained by performing an inverse transform on the above-mentioned inverse-quantized residual coefficients is a residual value reconstructed in the pixel domain (or called the sample domain). That is, after the inverse-quantized residual coefficient block is inverse-transformed by the residual inverse transform unit 107, the obtained block is a reconstructed residual block. Of course, when the above-mentioned residual transform unit 103 is not included in the encoder 100, the encoder 100 may not include an inverse transform step.
[0059] The reconstruction unit 108 is configured to add the reconstructed residual block to the prediction block to obtain a reconstructed block in the sample domain. The reconstruction unit 108 may be an adder. For example, the reconstruction unit 108 adds the residual value in the reconstructed residual block to the predicted value of the corresponding pixel in the prediction block to obtain the reconstructed value of the corresponding pixel. The reconstructed block output by the reconstruction unit 108 may then be used to predict other image blocks to be encoded.
[0060] The filter unit 109 (or abbreviated as "filter") is configured to filter the reconstructed block to obtain a filtered block in order to perform pixel conversion smoothly or to improve the quality of the image.
[0061] In one example, the encoding process performed by the encoder 100 may include the following steps 21 to 25.
[0062] In step 21, the prediction processing unit 101 determines a prediction mode, predicts a block to be encoded based on the determined prediction mode and the reconstruction block of the encoded image block, and obtains a prediction block of the block to be encoded.
[0063] Here, the reconstruction block of the encoded image block is obtained by the inverse quantization unit 106, the residual inverse transformation unit 107, and the reconstruction unit 108 sequentially processing the quantized residual coefficient block of the encoded image block.
[0064] In step 22, the residual calculation unit 102 obtains a residual block of the block to be encoded based on the prediction block and the original pixel values of the block to be encoded.
[0065] In step 23, the residual transformation unit 103 transforms the residual block to obtain a residual coefficient block.
[0066] In step 24, the quantization unit 104 quantizes the residual coefficient block to obtain a quantized residual coefficient block.
[0067] In step 25, the encoding unit 105 encodes the quantized residual coefficient block, encodes related syntax elements (for example, prediction mode, encoding mode), and obtains a bitstream of the block to be encoded.
[0068] FIG. 4 is a schematic block diagram of an example of a decoder 200 for implementing the method according to an embodiment of the present invention. The decoder 200 is configured to receive, for example, image data encoded by the encoder 100 (i.e., an encoded bitstream, for example, an encoded bitstream of an image block and related syntax elements) and obtain a decoded image block.
[0069] As shown in FIG. 4, the decoder 200 includes a bitstream analysis unit 201, an inverse quantization unit 202, a residual inverse transformation unit 203, a prediction processing unit 204, a reconstruction unit 205, and a filter unit 206. In some examples, the decoder 200 may perform a decoding process that is substantially the reverse of the encoding process described for the encoder 100 of FIG. 2.
[0070] The bitstream analysis unit 201 performs decoding on the encoded bitstream and is configured 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-prediction parameters, intra-prediction parameters, filter parameters, and / or other syntax elements executed on the encoding side). The bitstream analysis unit 201 is further configured to transfer the above decoding parameters to the prediction processing unit 204 so that the prediction processing unit 204 performs a prediction process based on the decoding parameters.
[0071] The function of the inverse quantization unit 202 may be the same as the function of the inverse quantization unit 106 of the encoder 100. The inverse quantization unit 202 is configured to inverse-quantize the quantized residual coefficients decoded and output by the bitstream analysis unit 201.
[0072] Here, inverse quantization is the inverse process of quantization. Inverse quantization refers to mapping the coefficients after quantization to a reconstructed signal in the input signal space, and the reconstructed signal is an approximation of the input signal. To reconstruct an image block from the bitstream after compression encoding, the inverse quantization unit 202 of the decoder 200 can inverse quantize the residual block or residual coefficient block analyzed from the bitstream to reconstruct an unquantized residual block or residual coefficient block corresponding to the image block. Thereby, the decoder 200 can reconstruct the image block based on the reconstructed residual block or residual coefficient block to obtain a reconstructed block of the image.
[0073] As an example, the case where the decoder 200 analyzes the quantized residual block of the block to be decoded from the bitstream will be described. The decoder 200 may inverse quantize the residual block by the inverse quantization unit 202. Specifically, the inverse quantization unit 202 may multiply each residual value in the analyzed residual block by a quantization coefficient to reconstruct the residual value in the unquantized residual block corresponding to the block to be decoded, and may obtain the reconstructed residual block. Here, the quantization coefficient is the quantization coefficient when the encoder quantizes the residual block of the block to be decoded when encoding the block to be decoded. In this way, the decoder 200 can realize the reconstruction of the block to be decoded based on the reconstructed residual block after inverse quantization and obtain the reconstructed block of the block to be decoded. As can be understood by those skilled in the art, the block to be encoded is the image block to be processed on the encoding side, and the block to be decoded is the image block to be processed on the decoding side.
[0074] The function of the residual inverse transformation unit 203 may be the same as that of the residual inverse transformation unit 107 of the encoder 100. The residual inverse transformation unit 203 is configured to perform an inverse transformation (for example, inverse DCT, inverse integer transformation, or a conceptually similar inverse transformation process) on the above-mentioned inverse quantized residual coefficients to obtain a reconstructed residual value. The block obtained by the inverse transformation is the residual block of the reconstructed block to be decoded in the pixel domain.
[0075] The function of the reconstruction unit 205 (for example, an adder) may be the same as that of the reconstruction unit 108 of the encoder 100.
[0076] The prediction processing unit 204 is configured to receive or acquire 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 may further receive or acquire, for example, the related parameters of the prediction mode and / or the information regarding the selected prediction mode (i.e., the above-mentioned decoding parameters) from the bit stream analysis unit 201, and predict the current image block based on the related data and the decoding parameters in the reconstructed image data to obtain the predicted block of the current image block.
[0077] The reconstruction unit 205 is configured to add the reconstructed residual block to the predicted block to obtain the reconstructed block of the image to be decoded in the sample area. For example, the residual value in the reconstructed residual block and the predicted value in the predicted block are added.
[0078] The filter unit 206 is configured to filter the reconstructed block to obtain the filtered block. The filtered block is the decoded image block.
[0079] Specifically, in the embodiment of the present invention, the decoder 200 is configured to execute the decoding method described in the following embodiments.
[0080] In addition, in the encoder 100 and the decoder 200 in the embodiment of the present invention, the processing result of a certain process may be further processed before being output to the next process. For example, after processes such as interpolation filtering, motion vector derivation, or filtering, further processes such as Clip or shift are performed on the processing result of the corresponding process.
[0081] In one example, the decoding process performed by decoder 200 may include the following steps 31 to 36.
[0082] In step 31, bit stream analysis unit 201 analyzes the prediction mode and the residual coding mode.
[0083] In step 32, bit stream analysis unit 201 analyzes quantization correlation values (for example, near value, QP value, etc.) based on the prediction mode and the residual coding mode.
[0084] In step 33, inverse quantization unit 202 analyzes the residual coefficients based on the prediction mode and the quantization correlation values.
[0085] In step 34, prediction processing unit 204 obtains the predicted value of each pixel of the current image block based on the prediction mode.
[0086] In step 35, residual inverse transform unit 203 inverse-transforms the residual coefficients to reconstruct the residual value of each pixel of the current image block.
[0087] In step 36, reconstruction unit 205 obtains the reconstructed value based on the predicted value and the residual value of each pixel of the current coding unit.
[0088] Figures 1 to 4 are merely examples provided by an embodiment of the present invention. In some examples, encoder 100, decoder 200, and encoding / decoding system 1 may include more or fewer components or units, and the present invention is not limited thereto.
[0089] Hereinafter, the following image encoding / decoding method according to an embodiment of the present invention will be described with reference to the drawings.
[0090] FIG. 5 is a schematic flowchart of an image encoding method according to the present invention. Optionally, the image encoding method may be applied to the encoding / decoding system 1 shown in FIG. 1, and the image encoding method may be executed by the encoding side 10. Specifically, the encoding method may be executed by an encoder 100 included in the encoding side 10. As shown in FIG. 5, the image encoding method provided in the embodiment of the present invention includes the following steps S101 to S103.
[0091] In S101, the encoding side obtains the maximum code length of the block to be encoded.
[0092] It can be understood that the video to be encoded may include one or more image frames. One image frame includes one or more image blocks. In the embodiment of the present invention, the current block to be encoded corresponds to one image block of the image to be processed (the image to be processed is any one of one or more image frames), and the block to be encoded may be a coding unit (CU).
[0093] Optionally, one block to be encoded may include a plurality of components. The component may be a luminance component or a chrominance component.
[0094] For example, for an image block corresponding to a block to be encoded with a size of 16×2, if the image format of the image block is YUV444, the image block includes one luminance component with a size of 16×2 and two chrominance components with a size of 16×2.
[0095] In another example, for an image block corresponding to a block to be encoded with a size of 16×2, if the image format of the image block is YUV422, the image block includes one luminance component with a size of 16×2 and two chrominance components with a size of 8×2.
[0096] Here, the maximum code length is the maximum length of the bitstream of the block to be encoded that is allowed to be buffered in the bitstream buffer, determined based on the set overflow line of the bitstream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by the bitstream in the bitstream buffer.
[0097] To prevent overflow of the bitstream, it should be understood that the maximum code length can be determined based on the actual storage space size of the bitstream buffer on the encoding side in the encoding / decoding system shown in FIG. 1. Both the encoding side and the decoding side may determine the storage space allowed to buffer the encoded bitstream in the current bitstream buffer based on the actual storage space size of the bitstream buffer and the above set overflow line. Thereby, the encoding side and the decoding side determine the space size occupied by the bitstream stored in the current bitstream buffer, and determine the space size obtained by subtracting the space size occupied by the currently stored bitstream from the storage space allowed to buffer the encoded bitstream in the current bitstream buffer as the remaining space of the above storage space.
[0098] Therefore, the maximum code length is the maximum length of the bitstream that is currently allowed to be buffered in the storage space used by the encoding side to buffer the encoded bitstream. The maximum code length is the sum of the length that can accommodate the bitstream in the remaining space of the storage space and the length of the bitstream output by the storage space per unit time.
[0099] In some embodiments, the encoding side can control the set overflow line of the bitstream buffer so that the space allowed for buffering the encoded bitstream is equal to or less than the total storage space size of the bitstream buffer. Thereby, the encoding side may determine the range of the code length based on the current set overflow line of the bitstream buffer.
[0100] In addition, during the process of encoding an image, the encoding side may adjust the set overflow line of the bitstream buffer to 1 / 2, 1 / 3, or other possible sizes of the total storage space size of the bitstream buffer. For example, for one "slice", after the encoding of the "slice" is completed by the encoding side, in order to output the encoded bitstream of the "slice" from the bitstream buffer as soon as possible, the size of the actual space allowed to accommodate the encoded bitstream in the bitstream buffer may be reduced. Thereby, after the encoding of the "slice" is completed by the encoding side, the bitstream of the "slice" stored in the bitstream buffer can be reduced. Also, when adjusting the set overflow line, the space occupied by the bitstream stored in the current bitstream buffer may exceed the set overflow line. In this case, the encoding side may determine the fixed code length for encoding the block to be encoded using the space size occupied by the portion exceeding the set overflow line as a determining factor.
[0101] In S102, the encoding side pre-encodes the block to be encoded and obtains the first code length of the block to be encoded.
[0102] The first code length is the length of the bitstream obtained after the block to be encoded is encoded.
[0103] Also, the encoding side may pre-encode the block to be encoded based on the original value mode (also referred to as the sample mode) as well.
[0104] The original value mode is a mode in which the original value of an image block corresponding to a block to be encoded is directly encoded.
[0105] Optionally, the encoding side may use the original value mode to encode the value obtained by quantizing and transforming the original pixel value of the block to be encoded. In this way, the encoding side can improve the effect of reconstructing the image of the block to be encoded by encoding the block to be encoded using the original value mode.
[0106] In the encoding method of near-lossless compression, the encoding side can encode the image to be encoded using the original value mode. Here, near-lossless compression refers to a compression technology between lossless compression and irreversible compression, and the purpose of near-lossless compression is to obtain high image compression quality at a certain compression ratio.
[0107] Optionally, the encoding side may pre-encode the block to be encoded based on a preset prediction mode on the encoding side, such as the point-by-point prediction mode, the intra prediction mode, the block copy mode, etc.
[0108] The intra prediction mode is a prediction mode that uses the reconstructed value of the pixels in the adjacent blocks around the block to be predicted as the predicted value. The block copy prediction mode is a prediction mode that uses the reconstructed value of the pixels in the surrounding encoded (decoded) blocks (not necessarily adjacent) as the predicted value. At the time of reconstruction, the point-by-point prediction mode is a prediction mode that uses the reconstructed value of the adjacent pixels around the pixel to be predicted as the predicted value of the pixel to be predicted.
[0109] The point-by-point prediction mode may include one or a combination of multiple prediction methods such as vertical prediction, horizontal prediction, vertical average prediction, and horizontal average prediction.
[0110] Vertical prediction is to obtain the predicted value (PointPredData) of the pixel to be predicted by using the reconstructed value of the pixel above the pixel to be predicted (which may be the adjacent upper pixel or the upper pixel that is not adjacent but close in distance). Horizontal prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed value of the pixel to the left of the pixel to be predicted (which may be the adjacent left pixel or the left pixel that is not adjacent but close in distance). Vertical average 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 average prediction is to obtain the predicted value of the pixel to be predicted by using the reconstructed values of the pixels on both the left and right sides of the pixel to be predicted.
[0111] In S103, when the first code length is greater than or equal to the maximum code length, the encoding side encodes the block to be encoded using the fallback mode.
[0112] Here, the code length obtained by encoding the block to be encoded based on the fallback mode is smaller than the maximum code length.
[0113] Here, encoding the block to be encoded using the fallback mode means encoding the block to be encoded using a fixed - length encoding method based on a pre - determined target code length. The total code length required to encode the block to be encoded is the target code length. The target code length is smaller than the maximum code length.
[0114] When the first code length is the maximum code length smaller it should be understood that the encoding side does not need to encode the block to be encoded using the fallback mode.
[0115] Note that the size of the storage space of the bitstream buffer is constant. When the bitstream data input to the bitstream buffer is too large and the data that needs to be temporarily stored in the bitstream buffer exceeds the size of the storage space, "overflow" of the bitstream occurs. As a result, the data in the exceeded part is lost, so that the image information in the image frame of the video to be encoded is lost, and the image frame cannot be completely analyzed based on the bitstream data output from the bitstream buffer.
[0116] Therefore, the encoding side needs to control the target code length within the above maximum code length.
[0117] In some embodiments, the codeword in the original value mode and the codeword in the fallback mode are the same. For example, when the codewords in both the original value mode and the fallback mode are the first codeword, when the encoding side encodes in the fallback mode, the first codeword can be adopted, and the first codeword is used to indicate the fallback mode or the original value mode.
[0118] In some embodiments, the encoding side may select the midpoint prediction fallback mode (MPPF Mode) to predict the block to be encoded, obtain the predicted block, and then encode the block to be encoded based on the fixed-length encoding method to obtain the bitstream of the block to be encoded.
[0119] Here, based on the midpoint prediction fallback mode, the encoding side can first divide the block to be encoded into a plurality of sub-image blocks of 2×2 pixel points. For each 2×2 sub-image block, it is necessary to calculate one intermediate value, and the intermediate value middle is calculated as shown in the following formula (1).
Equation
[0120] Here, bitDepth is the bit depth of the bitstream transmission channel of the sub-block to be currently encoded, and 1<< represents a left shift of 1 bit.
[0121] Furthermore, the encoding side may determine the mean value mean of the sub-block to be encoded.
[0122] In one case, when the current sub-block cannot obtain the surrounding reconstructed image, the mean value is the above middle value.
[0123] In another case, the mean value is the average value of the reconstruction values of the 2×1 pixel point sub-blocks in the previous row of the sub-block. When the reconstruction values of the 2×1 pixel point sub-blocks in the previous row cannot be obtained, the average value of the reconstructed image of the previous 2×2 sub-block reconstructed by the sub-block is taken.
[0124] Furthermore, the encoding side may determine the bias value of the sub-block. The bias value is used to limit the mean value. The encoding side may use the bias value and the middle value to clamp the mean to limit the mean value within the range of values consisting of the bias value and the middle value. Thereby, the mean value adjusted by the bias value and the middle value is determined as the predicted value of the sub-block to be encoded of the current 2×2 pixel points.
[0125] Here, the bias value may be determined according to the following formula (2).
Equation
[0126] Here, mppStepSize is used to indicate the quantization step in the quantization process of one component of the block to be encoded, [k] indicates the [k] - th component of the block to be encoded, and 1 << indicates a left shift by 1 bit.
[0127] Also, based on the MPPF Mode, as shown in FIG. 6, the residual value of the 2×2 pixel sub - block may be calculated based on the order of the pixel points A at the upper - left corner, B at the upper - right corner, C at the lower - left corner, and D at the lower - right corner.
[0128] Optionally, in the process of reconstructing the sub - block to be encoded, the reconstructed value of each pixel point may be sequentially determined according to the order of the above - mentioned pixel points A at the upper - left corner, B at the upper - right corner, C at the lower - left corner, and D at the lower - right corner.
[0129] In some embodiments, the encoding side may encode the block to be encoded using the residual encoding mode.
[0130] Optionally, the encoding side may predict the block to be encoded using the prediction mode corresponding to the fallback mode. Alternatively, the encoding side may predict the block to be encoded using any one of the preset prediction modes on the encoding side.
[0131] Here, the preset prediction modes on the encoding side may include the point - by - point prediction mode, the intra - prediction mode, the block - copy mode, etc.
[0132] Optionally, the encoding side may determine the prediction mode corresponding to the fallback mode as one fixed one of the above - mentioned preset prediction modes on the encoding side. Alternatively, the encoding side may select any one of the above - mentioned preset prediction modes as the prediction mode used when predicting the currently - to - be - encoded block in the encoding process.
[0133] Accordingly, for all blocks to be encoded using the fallback mode, the encoding side performs prediction in the fixed prediction mode.
[0134] Optionally, the fallback mode provided in the embodiments of the present invention may include a first fallback mode and a second fallback mode. Here, when encoding a block to be encoded using the first fallback mode, the encoding side predicts the block to be encoded using one fixed prediction mode, for example, the vertical average prediction mode. Also, the second fallback mode does not have a fixed prediction mode. When encoding a block to be encoded using the second fallback mode, any one of the preset prediction modes on the encoding side may be selected to predict the block to be encoded. Also, the second fallback mode may not have a prediction mode. When encoding a block to be encoded using the second fallback mode, the original value is directly inverse quantized to obtain a reconstructed value.
[0135] Accordingly, after obtaining the prediction block of the block to be encoded, the encoding side executes the aforementioned steps 22 to 25 to obtain the residual block of the block to be encoded based on the prediction block and the original pixel values of the block to be encoded, and the residual block may be transformed to obtain a residual coefficient block. Further, the residual coefficient block is quantized to obtain a quantized residual coefficient block. Finally, the quantized residual coefficient block is encoded to obtain the bitstream of the block to be encoded.
[0136] In some embodiments, the encoding side may first determine the quantization parameter QP value of the block to be encoded and quantize the residual value.
[0137] Optionally, the encoding side may derive an initial quantization parameter for 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 in the bitstream buffer. Further, the encoding side may determine a target quantization parameter for the block to be encoded based on the initial quantization parameter and the quantization parameter adjustment value. The range of the value of the target quantization parameter is between zero and a preset maximum value of the quantization parameter on the encoding side. For example, the target quantization parameter of the block to be encoded may be the sum of the initial quantization parameter and the quantization parameter adjustment value.
[0138] Here, the larger the remaining capacity of the bitstream buffer, the larger the quantization parameter adjustment value. The quantization parameter adjustment value may be a positive integer such as 4 or 8, for example.
[0139] Furthermore, the encoding side may determine the fixed code length of each component of the block to be encoded.
[0140] The block to be encoded includes one or more components. The block to be encoded may include three components of luminance Y, chrominance Cb, and chrominance Cr (or three components of red R, green G, and blue B, or three components of luminance Y, chrominance U, and chrominance V), or may include only one of the components. When the block to be encoded includes three components, the sizes of the three components may be exactly the same or different, specifically related to the input format of the image.
[0141] For example, when the image format of the block to be encoded is YUV400, the block to be encoded includes only the luminance component, and the encoding side only needs to determine the fixed code length of the luminance component. Alternatively, when the image format of the block to be encoded is YUV420, the block to be encoded includes three components of luminance Y, chrominance U, and chrominance V, and the encoding side 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.
[0142] In one example, the encoding side may 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 when encoding each pixel point of the block to be encoded, determined based on bits per pixel (BPP). 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. Thereby, the encoding side may 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 and the code length ratio of the block to be encoded.
[0143] Here, the target BPP is used to indicate the code length required when encoding each pixel point of the block to be encoded at the target compression rate. The target BPP may be determined based on the target compression ratio of the block to be encoded, and the target BPP may be regarded as the average code length required when encoding each pixel point of the block to be encoded. The target BPP is analyzed from the image header information in the bit stream.
[0144] Here, the target BPP is also used to indicate the code length required when encoding each pixel point of the block to be encoded at the target compression rate. The target BPP may be determined based on the target compression ratio of the block to be encoded.
[0145] Example 1: When the target BPP of the block to be coded is 8, that is, the target total code length of the block to be coded is (8 bits × the number of pixel points of the block to be coded), and the image format is YUV400, the block to be coded includes only the luminance component, and the total code length of the luminance component may be (8 bits × the number of pixel points of the block to be coded), that is, the fixed code length (code length of one luminance pixel point) of the luminance component is 8 bits. The coding side may code the block to be coded in a fixed code length coding method based on the determined total code length of the block to be coded. Here, when the block to be coded is a 16×2 image block, the target total code length of the block to be coded is 256 bits.
[0146] Example 2: When the current target BPP is 8, that is, the target total code length of the block to be coded is (8 bits × the number of pixel points of the block to be coded), and the image format is YUV444, the block to be coded includes three components: luminance Y, chrominance U, and chrominance V. In this case, it should be understood that the target total code length cannot be evenly allocated to the three components of luminance Y, chrominance U, and chrominance V. Based on the fact that the image format is YUV444, the code length ratio of the Y component:U component:V component may be 2:1:1. Thus, the coding side may determine that the total code length of the Y component is (4 bits × the number of pixel points of the block to be coded), and the total code lengths of both the U component and the V component are (2 bits × the number of pixel points of the block to be coded). Therefore, the coding side may code the Y component of the block to be coded in a fixed code length coding method based on the code length of (4 bits × the number of pixel points of the block to be coded), and code the U component and the V component of the block to be coded in a fixed code length coding method based on the code length of (2 bits × the number of pixel points of the block to be coded).
[0147] Also, based on the fact that 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. Therefore, the encoding side may encode each pixel point in the luminance Y component with 4 bits (i.e., the fixed code length of luminance is 4 bits) as the fixed code length. Also, the encoding side may encode each pixel point in the chrominance U or V component with 2 bits (i.e., the fixed code length of chrominance is 2 bits) as the fixed code length.
[0148] Example 3: When 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 pixel points of the block to be encoded), and the image format is YUV422, the block to be encoded includes three components: luminance Y, chrominance U, and chrominance V. In this case, it should be understood that (8 bits × the number of pixel points of the block to be encoded) cannot be evenly allocated to the three components of luminance Y, chrominance U, and chrominance V. Based on the fact that the image format is YUV422, the code length ratio of the Y component:U component:V component may be 2:1:1. Accordingly, the encoding side may determine that the total code length of the Y component is (4 bits × the number of pixel points of the block to be encoded), and the total code lengths of both the U component and the V component are (2 bits × the number of pixel points of the block to be encoded). Therefore, the encoding side encodes the Y component of the block to be encoded based on the code length of 4 bits × the number of pixel points of the block to be encoded, that is, with a fixed-length code having a fixed code length of 4, and encodes the U component and the V component of the block to be encoded with an encoding method having a fixed code length of (64 / the number of pixel points of the block to be encoded) based on the code length of (2 bits × the number of pixel points of the block to be encoded), for example, 2 bits × 16 × 2, that is, 64 bits.
[0149] Also, based on the fact that the image format is YUV422, since the number of pixels in each chrominance U or V component is half the number of pixels in the luminance Y component, the encoding side may encode each pixel point in the luminance Y component with 4 bits (i.e., the fixed code length of the luminance component is 4 bits) as the fixed code length. Also, similarly, the encoding side may encode each pixel point in the chrominance U or V component with 4 bits (i.e., the fixed code length of the chrominance component is 4 bits) as the fixed code length.
[0150] In another example, the encoding side may obtain the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required to encode the header information of the block to be encoded. Further, the encoding side may determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be encoded based on the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required to encode the header information of the block to be encoded.
[0151] Regarding the encoded bitstream of each image block, the header information is data having a specific length at the beginning of the bitstream, and this data can be used to indicate the image parameters of the current image block. For example, the image parameters may include one or more of the bit depth, target BPP, quantization parameter, and texture complexity of the current image block.
[0152] For example, when the current target BPP is 8, that is, the total target code length of the block to be encoded is (8 bits × the number of pixel points of the block to be encoded), the code length required to encode the header information is (2 bits × the number of pixel points of the block to be encoded), and the image format is YUV400, the block to be encoded may include only the luminance component, and the total code length of the luminance component may be (6 bits × the number of pixel points of the block to be encoded). Therefore, the fixed code length of the luminance component is capped at 6 bits. In one example, the encoding side may encode the block to be encoded in a fixed code length encoding method based on (4 bits × the number of pixel points of the block to be encoded), for example, 4 bits × 16 × 2, that is, 128 bits of code length.
[0153] Note that in the image encoding and decoding process, since the human eye is more sensitive to image luminance, usually, in order to preferentially allocate the code length to the luminance Y component in the image block, the sum of the fixed code lengths of all pixels in the luminance component is greater than or equal to the sum of the fixed code lengths of all pixels in the chrominance component. Thereby, based on the process of the image encoding and decoding, the image effect seen by the human eye can be improved.
[0154] In another example, the encoding side may obtain the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required to encode the header information of the block to be encoded. Further, the encoding side may determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be encoded based on the remaining capacity of the bitstream buffer, the target BPP of the block to be encoded, the code length ratio, and the code length required to encode the header information of the block to be encoded.
[0155] Optionally, the sum of the code lengths of all components of the block to be encoded is the code length obtained by subtracting the code length of the header information of the block to be encoded and the excess code length of the bitstream buffer from the target code length of the block to be encoded.
[0156] Here, the target code length is the code length of the block to be encoded determined based on the target BPP. The change amount of the set overflow line is 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. The excess code length of the bitstream buffer is the code length where the code length stored in the bitstream buffer exceeds the current set overflow line.
[0157] Exemplarily, when the target BPP is 8, the target code length of the block to be encoded is (8 bits × the number of pixel points of the block to be encoded), and the header information needs to occupy (2 bits × the number of pixel points of the block to be encoded). At this time, when the state of the bitstream buffer is larger than the current set overflow line, the code length occupied by the part larger than the overflow line is set as overflow_bpp. 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 (i.e., 8 bits × the number of pixel points of the block to be encoded) minus the code length occupied for encoding the header information (for example, 2 bits × the number of pixel points of the block to be encoded) and overflow_bpp (for example, 1 bit × the number of pixel points of the block to be encoded). Therefore, in this case, the sum of the code lengths of all components of the block to be encoded is 5 bits × the number of pixel points of the block to be encoded. Furthermore, the encoding side may determine the fixed code length of the chrominance component and the fixed code length of the luminance component of the block to be encoded based on the image format of the block to be encoded and 5 bits × the number of pixel points of the block to be encoded.
[0158] In some embodiments, when it is necessary to adjust the set overflow line, the size of the set overflow line satisfies the following formula (3).
Equation
[0159] Here, delta_bit = overflow_bpp × block_size, where block_size is the size of the coding block. target_bpp indicates the target BPP. cu_header_bpp indicates the code length used to code the header information of the block to be coded, and cu_header_bpp is less than or equal to target_bpp. Also, overflow_bpp indicates the code length where the code length stored in the bitstream buffer exceeds the current set overflow line.
[0160] In some embodiments, when the block to be coded contains multiple components, the multiple components of the block to be coded share a fallback mode (sharing means that all of the multiple components use the fallback mode or none of them use the fallback mode). Thus, the coding side may determine whether only one of the components uses the fallback mode. If one of the components uses the fallback mode, the other components also use the fallback mode. Or, when some of the multiple components of the block to be coded share the fallback mode, the coding side may determine whether only one of the some components uses the fallback mode, and may also determine whether the components other than the some components use the fallback mode. Or, when none of the multiple components of the block to be coded share the fallback mode, the coding side may determine whether each component uses the fallback mode respectively.
[0161] In some embodiments, when the current block to be coded is coded using the fallback mode, the current bit rate control parameter is not updated, that is, the bit rate control parameter corresponding to the previously coded block of the block to be coded is determined as the bit rate control parameter of the block to be coded. Here, the bit rate control parameter is used to derive the coding information of the next block to be coded, such as a parameter such as the quantization step.
[0162] In the encoding and decoding processes, for the image block corresponding to each block to be encoded, after the encoding of the current image block is completed, the bit rate control on the encoding side and the decoding side updates the bit rate control parameters based on information such as the complexity of the current image block and the code length required for encoding. The updated bit rate control parameters are used to derive information about the next image block to be encoded, such as the quantization step. However, when encoding the image block based on the fallback mode, since the code length of the block to be encoded is fixed, the code length required for its encoding cannot accurately reflect the current image content. Therefore, when the fallback mode is selected for the current image block, the bit rate control parameters are not updated.
[0163] Optionally, for a block to be encoded having multiple components, if one of the components of the current block to be encoded is encoded using the fallback mode, the current bit rate control parameters are not updated.
[0164] The image encoding method provided in the embodiments of the present invention has at least the following beneficial effects. The method first pre-encodes the block to be encoded, compares the length of the bit stream obtained by the pre-encoding with the allowable code length occupied by the block to be encoded, and based on the comparison result, can determine whether an overflow or underflow of the bit stream occurs. Thereby, if it is determined that an overflow or underflow of the bit stream occurs, the block to be encoded is encoded using the fallback mode so that the image information of the block to be encoded is not lost.
[0165] In some embodiments, the present invention further provides an image decoding method. The decoding method corresponds to the encoding method shown in FIG. 5. FIG. 7 is a schematic flowchart of the image decoding method according to the present invention. The image decoding method may be executed by a decoder 200, or may be executed by a decoding side (e.g., the decoding side 20 shown in FIG. 1) that supports the functions of the decoder 200. Here, the case where the decoding side implements the decoding method will be described as an example. The image decoding method includes the following steps S201 to S203.
[0166] In S201, the decoding side analyzes the bitstream of the block to be decoded. If the first codeword is included in the bitstream of the block to be decoded, it determines whether the image block corresponding to the block to be decoded uses the fallback mode.
[0167] In the bitstream of the block to be decoded, the codeword for indicating the encoding mode is the first codeword, and the first codeword is used to indicate the fallback mode or the original value mode.
[0168] In some embodiments, the decoding side may determine whether the image block corresponding to the block to be decoded uses the fallback mode based on whether the code length for encoding the block to be decoded based on the original value mode overflows.
[0169] Optionally, if the code length encoded based on the original value mode of the image block corresponding to the block to be decoded is greater than or equal to the maximum code length of the block to be decoded, the decoding side may determine that the image block corresponding to the block to be decoded uses the fallback mode.
[0170] Here, the bit stream of the block to be decoded may be the bit stream received from the encoding side by the decoding side, or may be a bit stream obtained from another device, such as the bit stream obtained from a memory device, and the embodiments of the present invention are not limited thereto.
[0171] Here, the code length of the block to be decoded is smaller than the maximum code length of the block to be decoded. The maximum code length is the maximum length of the bit stream of the block to be decoded that is allowed to be buffered in the bit stream buffer, determined based on the set overflow line of the bit stream buffer. The set overflow line is used to indicate the maximum storage space allowed to be occupied by the bit stream in the bit stream buffer.
[0172] Note that the maximum code length of the bit stream allowed to be buffered in the above bit stream buffer is the maximum length of the bit stream allowed to be buffered in the bit stream buffer when the encoding side encodes the block to be decoded. The decoding side may directly determine the maximum code length by analyzing the bit stream of the block to be decoded. Alternatively, the decoding side may analyze the bit stream of the block to be decoded to determine the remaining memory state of the bit stream buffer when the encoding side encodes the image block corresponding to the block to be decoded. Further, the decoding side may determine the above maximum code length based on the remaining memory state of the bit stream buffer.
[0173] For the description regarding the maximum code length, refer to the related description in step S101 above.
[0174] In some embodiments, the codewords in the original value mode and the fallback mode are the same. For example, if the codewords in both the original value mode and the fallback mode are the first codeword, when the decoder analyzes the bitstream of the block to be decoded and obtains the first codeword, the decoder may determine that the block to be decoded uses the fallback mode or the original value mode.
[0175] Furthermore, the decoder may determine whether the block to be decoded uses the fallback mode based on the size of the occupied memory space in the bitstream buffer.
[0176] If the decoder determines that the occupied memory space in the bitstream buffer is larger than a first preset memory value when the image block to be decoded is encoded, that is, when there is an overflow, the decoder determines that the image block corresponding to the block to be decoded uses the fallback mode. Otherwise, the decoder determines that the image block corresponding to the block to be decoded uses the original value mode.
[0177] The size of the first preset memory value is not particularly limited and may be determined based on the actual memory size of the bitstream buffer.
[0178] Optionally, when the decoder determines that the length of the bitstream of the block to be decoded is the sum of the products of the image bit widths and the number of pixels of all components, the decoder may analyze the bitstream of the block to be decoded and reconstruct the image block of the block to be decoded based on the original value mode.
[0179] In some embodiments, the block to be decoded may include one or more components.
[0180] Optionally, the block to be decoded may contain only the luminance component. Alternatively, the block to be decoded may contain three components, for example, the three components of luminance Y, chrominance Cb, and chrominance Cr (or the three components of red R, green G, and blue B, or the three components of luminance Y, chrominance U, and chrominance V). Alternatively, in addition to the above three components, the block to be decoded may further include an α component, that is, the block to be decoded contains a total of four components. Here, the α component is a pixel transparency component. When the value of the α component is 0, the pixel corresponding to the decoded block is transparent, and the image bit width of the α component is different from that of the other three components.
[0181] In some embodiments, when the block to be decoded contains multiple components, the multiple components of the block to be decoded share a fallback mode (sharing a fallback mode means that all of the multiple components either use the fallback mode or none of them use the fallback mode). Thereby, the decoding side may determine whether only one of the components uses the fallback mode. If one of the components uses the fallback mode, the other components also use the fallback mode. Alternatively, when some of the multiple components of the block to be decoded share a fallback mode, the decoding side may determine whether only one of the some components uses the fallback mode and may also determine whether the components other than the some components use the fallback mode. Alternatively, when none of the multiple components of the block to be decoded share a fallback mode, the decoding side may determine whether each component uses the fallback mode respectively.
[0182] Specifically, the bitstream of the block to be decoded may include an identifier for indicating a situation of sharing the above fallback mode. Thereby, the decoding side may determine the components sharing the fallback mode based on the identifier and may also determine whether each component uses the fallback mode.
[0183] In S202, when the image block corresponding to the block to be decoded on the decoding side uses the fallback mode and the code length stored in the bitstream buffer exceeds the set overflow line, the fixed code length of each component of the block to be decoded is determined based on the excess code length of the bitstream buffer.
[0184] Here, 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 when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is the code length by which the code length stored in the bitstream buffer exceeds the current set overflow line.
[0185] In some embodiments, the decoding side may 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 bitstream buffer when encoding the image block to be decoded.
[0186] Here, the target BPP is further used to indicate the code length required when decoding each pixel point of the block to be decoded at the target compression ratio. The target BPP may be determined based on the target compression ratio of the block to be decoded, and the target BPP may be understood as the average code length required when decoding each pixel point of the block to be decoded. Further, the image format of the block to be decoded may be used to indicate the code length ratio between the chrominance component and the luminance component. For example, when the image format is YUV444, the code length ratio of the Y component:U component:V component in the image block to be decoded may be 2:1:1.
[0187] Optionally, on the decoding side, the bitstream of the block to be decoded may be analyzed to obtain the BPP of each component of the block to be decoded, or the decoding side may determine the BPP of each component of the block to be decoded according to the following possible embodiments. It should be understood that the method for the decoding side to determine the fixed code length of each component of the block to be decoded is the same as the method for the encoding side to determine the fixed code length of each component when encoding the bitstream of the image block corresponding to the block to be decoded.
[0188] In one embodiment, the decoding side 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 based on the target BPP of the block to be decoded and the code length ratio.
[0189] Note that the method for the decoding side to determine the fixed code length of each component corresponds to the encoding side. When the encoding side 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 image block, correspondingly, when decoding the encoded bitstream of the image block, the decoding side 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 image block in the same way.
[0190] Example 1: When the target BPP of the block to be decoded is 8, the total target code length of the block to be decoded is 8 bits × the number of pixel points of the block to be decoded, and the image format is YUV400, the block to be decoded may include only the luminance component, and the total code length of the luminance component may be 8 bits × the number of pixel points of the block to be decoded, that is, the fixed code length (the code length of one luminance pixel point) of the luminance component is 8 bits. The decoding side may decode the block to be decoded in a fixed code length decoding method based on the code length of 8 bits × the number of pixel points of the block to be decoded. Here, when the block to be decoded is a 16×2 image block, the code length of the block to be decoded is 256 bits.
[0191] Example 2: When the current target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixel points of the block to be decoded, and the image format is YUV444, the block to be decoded includes three components: luminance Y, chrominance U, and chrominance V. In this case, it should be understood that 8 bits × the number of pixel points of the block to be decoded cannot be evenly allocated to the three components of luminance Y, chrominance U, and chrominance V. Based on the fact that the image format is YUV444, the code length ratio of the Y component:U component:V component may be 2:1:1. Thereby, the decoding side may determine that the total code length of the Y component is 4 bits × the number of pixel points of the block to be decoded, and the total code lengths of the U component and the V component are both 2 bits × the number of pixel points of the block to be decoded. Therefore, the decoding side may decode the Y component of the block to be decoded in a fixed code length decoding method based on the code length of 4 bits × the number of pixel points of the block to be decoded, and decode the U component and the V component of the block to be decoded in a fixed code length decoding method based on the code length of 2 bits × the number of pixel points of the block to be decoded.
[0192] Also, based on the fact that the image format is YUV444, since the number of pixels in each chrominance U or V component is the same as the number of pixels in the luminance Y component, the decoding side may decode each pixel point in the luminance Y component with 4 bits (i.e., the fixed code length of the luminance component is 4 bits) as the fixed code length. Also, the decoding side may decode each pixel point in the chrominance U or V component with 2 bits (i.e., the fixed code length of the chrominance component is 2 bits) as the fixed code length.
[0193] Example 3: When the current target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixel points of the block to be decoded, and the image format is YUV422, the block to be decoded includes three components: luminance Y, chrominance U, and chrominance V. In this case, it should be understood that 8 bits × the number of pixel points of the block to be decoded cannot be evenly allocated to the fixed code lengths of the three components of luminance Y, chrominance U, and chrominance V. Based on the fact that the image format is YUV422, the code length ratio of the Y component:U component:V component may be 2:1:1. Thereby, the decoding side may determine that the total code length of the Y component is 4 bits × the number of pixel points of the block to be decoded, and the total code lengths of both the U component and the V component are 2 bits × the number of pixel points of the block to be decoded. Therefore, the decoding side may decode the Y component of the block to be decoded in a fixed code length decoding method based on the code length of 4 bits × the number of pixel points of the block to be decoded, and decode the U component and the V component of the block to be decoded in a fixed code length decoding method based on the code length of 2 bits × the number of pixel points of the block to be decoded.
[0194] Also, based on the fact that the image format is YUV422, since the number of pixels in each chrominance U or V component is half of the number of pixels in the luminance Y component, the decoding side may decode each pixel point in the luminance Y component with 4 bits (i.e., the fixed code length of the luminance component is 4 bits) as the fixed code length. Similarly, the decoding side may also decode each pixel point in the chrominance U or V component with 4 bits (i.e., the fixed code length of the chrominance component is 4 bits) as the fixed code length.
[0195] In another embodiment, the decoding side may obtain the code length required to decode the target BPP of the block to be decoded, the image format of the block to be decoded, and the header information of the block to be decoded. Further, the decoding side 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 based on the code length required to decode the target BPP of the block to be decoded, the image format of the block to be decoded, and the header information of the block to be decoded.
[0196] For example, when the current target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixel points of the block to be decoded, the code length required to decode the header information is 2 bits × the number of pixel points of the block to be decoded, and the image format is YUV400, the block to be decoded may include only the luminance component, and the total code length of the luminance component may be 6 bits × the number of pixel points of the block to be decoded. Therefore, the fixed code length of the luminance component is 6 bits. The decoding side may decode the block to be decoded in a fixed code length decoding method based on the code length of 6 bits × the number of pixel points of the block to be decoded. In another example, the decoding side 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 to decode the header information of the block to be decoded. Further, the decoding side 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 based on the remaining capacity of the bit stream buffer, the target BPP of the block to be decoded, the code length ratio, and the code length required to decode the header information of the block to be decoded.
[0197] Optionally, the sum of the code lengths of all components of the block to be decoded is the code length obtained by subtracting the code length of the header information of the block to be decoded and the excess code length of the bit stream buffer from the target code length of the block to be decoded.
[0198] Here, the target code length is the code length of the block to be decoded determined based on the target BPP, the change amount of the set overflow line is not more than 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 bit stream buffer is the code length by which the code length stored in the bit stream buffer exceeds the current set overflow line.
[0199] Exemplarily, when the target BPP is 8, the target code length of the block to be decoded is 8 bits multiplied by the number of pixel points of the block to be decoded, and the header information needs to occupy 2 bits multiplied by the number of pixel points of the block to be decoded. At this time, if the state of the bitstream buffer is larger than the current set overflow line, the code length occupied by the part larger than the overflow line is set as overflow_bpp. 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, 8 bits multiplied by the number of pixel points of the block to be decoded), minus the code length occupied for decoding the header information (for example, 2 bits multiplied by the number of pixel points of the block to be decoded) and overflow_bpp (for example, 1 bit multiplied by the number of pixel points of the block to be decoded). Therefore, in this case, the sum of the code lengths of all components of the block to be decoded is 5 bits multiplied by the number of pixel points of the block to be decoded. Further, the decoding side 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 based on the image format of the block to be decoded and 5 bits multiplied by the number of pixel points of the block to be decoded.
[0200] In S203, the decoding side analyzes the pixel points of each component in the block to be decoded based on the fixed code length of each component, and decodes the block to be decoded.
[0201] In some embodiments, as shown in FIG. 8, the above step S203 may be specifically implemented by the following steps S2031 to S2034.
[0202] In S2031, the decoding side determines the residual value of each component of the block to be decoded based on the fixed code length of each component.
[0203] Exemplarily, the decoding side may respectively determine the residual value of each pixel point of each component in the block to be decoded based on the fixed code length of each component of the block to be decoded determined in the above step S202.
[0204] In S2032, the decoding side obtains the prediction mode of the block to be decoded in the fallback mode, predicts the image block corresponding to the block to be decoded based on the prediction mode, and obtains the predicted value of the block to be decoded.
[0205] Optionally, the decoding side may predict the block to be decoded using the prediction mode corresponding to the fallback mode, that is, the first fallback mode above. Alternatively, the decoding side may predict the block to be decoded using any one of the pre-set prediction modes on the decoding side, that is, the second fallback mode above. It should be understood that the decoding side may determine the prediction mode corresponding to the fallback mode as one fixed mode among the pre-set prediction modes on the decoding side. Thereby, for all blocks to be decoded that are decoded using the fallback mode, the decoding side performs prediction using the fixed prediction mode.
[0206] The pre-set prediction mode on the decoding side is the same as the pre-set prediction mode on the encoding side. For the description of the specific prediction mode, reference can be made to the relevant description in step S103 above, and the description is omitted here.
[0207] In one embodiment, when the block to be decoded contains one component, the decoding side may analyze the bitstream of the block to be decoded to determine the prediction mode of the block to be decoded. Alternatively, the decoding side may determine the pre-set prediction mode as the prediction mode of the block to be decoded. It should be understood that the pre-set prediction mode is the same as the prediction mode used by the encoding side in the prediction process.
[0208] In another embodiment, when the block to be decoded includes a plurality of components, the plurality of components of the block to be decoded may use the same prediction mode. Thus, the decoding side may determine only the prediction mode of one component, and the prediction mode is the prediction mode of all components of the block to be decoded. Alternatively, some of the plurality of components of the block to be decoded may use the same prediction mode. In this case, the decoding side may determine the prediction mode of one of the some components and the prediction mode of the components other than the some components. Alternatively, the decoding side may determine the prediction mode of each component respectively.
[0209] In S2033, the decoding side determines the quantization parameter of the block to be decoded, and inverse-quantizes the residual value of the block to be decoded based on the quantization parameter.
[0210] Optionally, the decoding side may first determine the 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 target quantization parameter of the block to be decoded. The range of the value of the target quantization parameter is between zero and the preset maximum value of the quantization parameter on the encoding side.
[0211] For example, the target 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 method by which the decoding side determines the target quantization parameter is the same as the method by which the encoding side determines the target quantization parameter of the image block described above.
[0212] Here, the larger the remaining capacity of the bitstream buffer, the larger the quantization parameter adjustment value. The quantization parameter adjustment value may be a positive integer such as 4 or 8, for example.
[0213] The method by which the decoding side determines the original quantization parameter includes at least some of the following embodiments.
[0214] In one embodiment, the header information of the block to be decoded includes the quantization parameter when performing quantization processing on the image block corresponding to the block to be decoded. Thereby, the decoding side may analyze the header information of the block to be decoded to determine the initial quantization parameter of the block to be decoded.
[0215] In another embodiment, the decoding side may derive the initial quantization parameter of the block to be decoded based on the complexity information of the image block corresponding to the block to be encoded and the remaining space of the bitstream buffer.
[0216] Furthermore, the decoding side can determine the quantization step Qstep by at least one of mathematical formula derivation or table lookup based on the QP value, and provides the following three possible implementation methods. Next, for the selected combination of quantizers, inverse quantization is performed on each pixel point of the block to be decoded using the Qstep of the block to be decoded.
[0217] Method 1:
Number
[0218] Method 2:
Number
[0219] Method 3:
Number
[0220] Optionally, quantization and inverse quantization may be realized using the following conventional scalar quantization method in H.265. Quantization:
Number
Number
[0221] However, l is the level value obtained after quantization, c is the residual coefficient to be quantized (the residual coefficient may be the residual coefficient in the transform domain, i.e., the transformed residual coefficient, or the residual coefficient in the pixel domain, i.e., the residual value), Qstep is the quantization step, f is a parameter for controlling rounding, f ∈ [0, 1), sign represents the sign function, floor represents the floor function, and c’ is the value after inverse quantization.
[0222] It can be understood that the larger the QP value, the larger the Qstep value, the coarser the quantization, the larger the image distortion due to quantization, and the smaller the bit rate of coefficient coding.
[0223] [0, 1 - f) represents the quantization dead zone. The parameter f is related to the length of the quantization dead zone. The smaller f is, the longer the quantization dead zone becomes, and the closer the level value after quantization approaches the zero point. When f = 0.5, the above quantization and inverse quantization formulas correspond to rounding, and the quantization distortion is minimized. When f < 0.5, the smaller f is, the larger the quantization distortion becomes, and the smaller the bit rate of coefficient coding. In H.265, for I frames, f = 1 / 3 is selected, and for B / P frames, f = 1 / 6 is selected.
[0224] Exemplarily, the quantization or inverse quantization formula of the uniform quantizer can refer to the above quantization and inverse quantization formulas, and the parameter f can be taken in the following way.
[0225] Method 1: f takes a value of 0.5 or other fixed value.
[0226] Method 2: f is adaptively determined based on the QP value, prediction mode, and whether to perform transformation.
[0227] In S2034, the decoding side reconstructs the block to be decoded based on the residual value and predicted value after inverse quantization of the block to be decoded, and obtains the reconstructed block of the image block.
[0228] Based on the above embodiments, when the encoding side uses the fallback mode, the decoding side can decode the block to be decoded using the fallback mode, and based on the remaining memory of the bitstream buffer, can avoid the occurrence of bitstream overflow or underflow. Thereby, it is avoided that the image information of the block to be decoded is lost.
[0229] In some embodiments, the image decoding process provided in the present invention may specifically include the following steps.
[0230] In step 1, it is determined whether the block to be decoded satisfies condition 1. If condition 1 is satisfied, the block to be decoded is decoded using the fallback mode.
[0231] Specifically, the above condition 1 is that the total code length obtained by encoding all components of the block to be decoded in the original value mode exceeds the currently available code length of the bitstream buffer. Here, the currently available code length of the bitstream buffer can be determined by subtracting the memory capacity occupied by the code length stored in the current bitstream buffer from the memory capacity indicated by the current set overflow line.
[0232] That is, when the current bitstream buffer state cannot simultaneously satisfy encoding in the original value mode for all components, analyze the blocks to be decoded based on the fallback mode and turn off the original value mode.
[0233] Optionally, the decoding side may first obtain the code length (CurrBits) stored in the current bitstream buffer. Further, the decoding side may determine that the image size of one block to be decoded is, for example, the width (CbWidth) is 16 and the height (CbHeight) is 2. Determine the code length required to encode the block to be decoded in the original value mode (FallbackFlag = 0). Specifically, analyze the image format (image_format) and image size (cbChromaSize) of each component of the block to be decoded, and obtain the code length (modeBits) required to encode each component in the original value mode.
[0234] Furthermore, the decoding side may calculate the total code length (BitDepth[0]×cbLumaSize + BitDepth[1]×cbChromaSize×2-(TargetBpp<<1)) required to encode the block to be decoded in the original value mode. Then, determine whether the total code length satisfies Condition 1. If it satisfies Condition 1, decode the block to be decoded in the fallback mode. Finally, the decoding side may position the decoded block (CuPosX[0], CuPosY[0]). Thereby, analyze the next image block.
[0235] In Step 2, the decoding side may analyze the complexity and encoding mode of the block to be decoded.
[0236] Optionally, the decoding side may analyze the complexity (complexity_level_flag) of one component of the block to be decoded with a fixed code length of 1 bit (u(1)) or 3 bits.
[0237] Furthermore, the decoding side may analyze the coding mode of the block to be decoded.
[0238] The decoding side may first determine the prediction mode, and based on the prediction mode, determine the decoding mode of the block to be decoded. Currently, when the fallback mode is allowed (allowfallback) and it is the original value mode, first, for the prediction mode of the current block to be decoded, the block prediction mode (IBC_MODE), that is, the prediction mode corresponding to the first fallback mode, is assigned. Thereby, the decoding side analyzes the coordinates (abs_bvd_minus1[blkIdx]) in the search area of the prediction block corresponding to the current block to be decoded with a fixed code length of 5 bits (u(5)).
[0239] In step 3, the decoding side derives one fixed - length code length and analyzes each quantized coefficient value using the fixed - length code.
[0240] In the case of the first fallback mode, the coefficient value represents the quantized residual value. In the case of the second fallback mode, there is no prediction mode at this time, and the coefficient value represents the quantized original value.
[0241] Finally, inverse quantization is performed. In the case of the first fallback mode, the residual value is added to the predicted value to obtain the reconstructed value. In the case of the second fallback mode, the value after inverse quantization is used as the reconstructed value.
[0242] The above process may be specifically realized as the following text description. coding_unit_data_substream0 (cuIdxX, cuIdxY) { BitsRecord = CurrBits CbWidth[0] = 16 CbHeight[0] = 2 FallbackFlag = 0 cbLumaSize = CbWidth[0] × CbHeight[0] if (image_format == ‘001’){ / * YUV400 * / cbChromaSize = 0 modeBits = 8 } else if (image_format == ‘001’) { / * YUV420 * / cbChromaSize = cbLumaSize >> 2 modeBits = 15 } else if (image_format == ‘010’) { / * YUV422 * / cbChromaSize = cbLumaSize >> 1 modeBits = 15 } else { cbChromaSize = cbLumaSize modeBits = 21 } allowfallback = modeBits + (BitDepth[0] × cbLumaSize + BitDepth[1] × cbChromaSize × 2 - (TargetBpp << 1)) >= MaxBufferSize - (CurrBits - OutBits) CuPosX[0] = cuIdxX << 4 CuPosY[0] = cuIdxY << 1 CurrBlocks++ complexity_level_flag[0] u(1) if (ComplexityLevelFlag[0] == 0) { delta_level[0] u(2) if (delta_level[0] >= PrevComplexityLevel) { ComplexityLevel[0] = DeltaLevel[0] + 1 } else { ComplexityLevel[0] = DeltaLevel[0] } } else { ComplexityLevel[0] = PrevComplexityLevel } PrevComplexityLevel = ComplexityLevel[0] pred_mode[0] ae(v) if (PredMode[0] == ORG_MODE && allowfallback) { FallbackFlag = 1 u(1) fallback_type PredMode[0] == FallbackType == 1 ‘ORG_MODE’ : ‘IBC_MODE’ } if (PredMode[0] == ‘IBC_MODE’) { for (blkIdx=0; blkIdx<8; blkIdx++) { abs_bvd_minus1[blkIdx] u(5) } } if (PredMode[0] != POINT_MODE_1 && PredMode[0] != POINT_MODE_1 && PredMode[0] != ORG_MODE &&!LosslessFlag &&!FallbackFlag) { resi_skip[0] u(1) } if (ResiSkip[0] != 1) { coeff_data(BitDepth[0], 0) }
[0243] Here, in the above text description, the type of the fallback mode is determined using the method of binary variables. When the value is "1", it indicates that the fallback mode used by the current coding unit is the original value truncated mode, and when the value is "0", it indicates that the fallback mode used by the current coding unit is the residual truncated mode. The value of FallbackType is equal to the value of fallback_type.
[0244] In some embodiments, the decoding side obtains binary data representing the fixed-length code of the block to be decoded in the bitstream, and processes the binary data using the inverse binarization method to obtain the specific data of BPP.
[0245] The decoding side first determines the binary data (org_data) of the fixed-length code.
[0246] When the fallback mode identification value (FallbackFlag) is equal to 0, that is, when the fallback mode is not used during encoding, the value of the bit depth (BitDepth[component]) 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.
[0247] Otherwise, the decoding side 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 (see Table 1 below).
[0248] The specific derivation of the fixed-length code is as follows.
[0249] 1) The decoding side first calculates the value of the target BPP (adjTargetBpp) after adjusting the overflow line.
[0250] If (BitsRecord - ((TargetBpp << 1) × (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).
[0251] Otherwise, adjTargetBpp is equal to (Target_bpp >> 4).
[0252] Here, (Target_bpp >> 4) refers to the target BPP.
[0253] 2) The decoding side determines the code length of the fixed - length code for each component based on adjTargetBpp.
[0254] When the image format is YUV400, the fixed - length code is (adjTargetBpp - 2).
[0255] Otherwise, it is determined whether the current component is equal to the luminance component.
[0256] When it is equal to the luminance component, the fixed - length code is equal to (adjTargetBpp - 2) / 3+(adjTargetBpp - 2) / 3.
[0257] If not, when the image format is YUV420, the fixed - length code is (adjTargetBpp - 2) / 3 << 2.
[0258] If not, when the image format is YUV422, the fixed - length code is (adjTargetBpp - 2) / 3 << 1.
[0259] If not, the fixed - length code is (adjTargetBpp - 2) / 3.
Table 1
[0260] Hereinafter, an encoding device and a decoding device according to embodiments of the present invention will be described. The encoding device may be a video encoder or a device including a video encoder. The encoding device includes each module configured to implement an image encoding method in any one of possible embodiments. The encoding device has a function of realizing the operations in the embodiments of the related method. The function may be realized by hardware or may be realized by the hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above function. For the beneficial effects, please refer to the description of the corresponding method. The decoding device may be a video decoder or a device including a video decoder. The decoding device includes each module configured to implement an image decoding method in any one of possible embodiments. The decoding device has a function of realizing the operations in the embodiments of the related method. The function may be realized by hardware or may be realized by the hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above function. For the beneficial effects, please refer to the description of the corresponding method.
[0261] In one example, any encoding device according to an embodiment of the present invention may be the encoding side 10 or the encoder 100 in FIG. 1. In another example, any decoding device provided below may be the decoding side 20 or the decoder 200 in FIG. 1. Hereinafter, the description thereof will be omitted.
[0262] FIG. 9 is a schematic structural diagram of an image encoding device 900 according to the present invention. Any one of the embodiments of the above-described encoding method 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 configured to obtain the maximum code length of the block to be encoded. The maximum code length is the maximum length of the bit stream of the block to be encoded that is allowed to be buffered in the bit stream buffer, determined based on the set overflow line of the bit stream buffer. The set overflow line is used to indicate the maximum storage space allowed to be occupied by the bit stream in the bit stream buffer. The encoding module 902 is configured to pre-encode the block to be encoded to obtain a first code length of the block to be encoded. The first code length is the length of the bit stream obtained after the block to be encoded is encoded. The encoding module 902 is further configured to, when the first code length is greater than or equal to the maximum code length, encode the block to be encoded using a fallback mode, and the code length obtained by encoding the block to be encoded based on the fallback mode is smaller than the maximum code length, and a first code word is included in the bit stream obtained by encoding the block to be encoded based on the fallback mode, and the first code word is used to indicate the fallback mode or the original value mode.
[0263] For a more detailed description of the above decision module 901 and encoding module 902, as well as a more detailed description of each of their technical features and an explanation of the beneficial effects, reference can be made to the corresponding method embodiment parts above, and the description is omitted here.
[0264] FIG. 10 is a schematic structural diagram of an image decoding apparatus 1000 according to the present invention. Any one of the above-described embodiments of the decoding method can be executed by the decoding apparatus 1000. The image decoding apparatus 1000 includes an analysis module 1001 and a determination module 1002. The analysis module 1001 analyzes the bit stream of the block to be decoded, and is configured to determine whether the image block corresponding to the block to be decoded uses the fallback mode when the first code word is included in the bit stream of the block to be decoded. The code length of the block to be decoded is smaller than the maximum code length of the block to be decoded, and the maximum code length is the maximum length of the bit stream of the block to be decoded that is allowed to be buffered in the bit stream buffer determined based on the set overflow line of the bit stream buffer. The set overflow line is used to indicate the maximum storage space allowed to be occupied by the bit stream in the bit stream buffer, and the first code word is used to indicate the fallback mode or the original value mode. The determination module 1002 is configured to determine the fixed code length of each component of the block to be decoded based on the excess code length of the bit stream buffer when the image block corresponding to the block to be decoded uses the fallback mode and the code length stored in the bit stream buffer exceeds the set overflow line. 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 when analyzing a single pixel point of the first component, and the excess code length of the bit stream buffer is the code length by which the code length stored in the bit stream buffer exceeds the current set overflow line. The analysis module 1001 is further configured to analyze the pixel points of each component based on the fixed code length of each component to decode the block to be decoded.
[0265] For more detailed descriptions of the above analysis module 1001 and determination module 1002, as well as more detailed descriptions of their respective technical features and descriptions of beneficial effects, reference can be made to the corresponding method embodiment parts above, and the description is omitted here.
[0266] The present invention including a processor and a memory, the memory being configured to store computer instructions, and the processor being configured to call and execute the computer instructions from the memory to executes an example of any of the above image encoding / decoding methods configured as and further provides an electronic device. For example, the electronic device may be a video encoder or a device including a video encoder. In another example, the electronic device may be a video decoder or a device including a video decoder. FIG. 11 is a schematic structural diagram of an electronic device according to the present invention. As shown in FIG. 11, 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. Note that the communication interface 1102 may be a transceiver or an input / output interface.
[0267] In one example, the electronic device 1100 may further include a memory 1103 configured to store instructions executed by the processor 1101, store input data required for the processor 1101 to execute instructions, or store data generated after the processor 1101 executes instructions.
[0268] In an embodiment of the present invention, the specific connection medium between the communication interface 1102, the processor 1101, and the memory 1103 is not limited. In an embodiment of the present invention, in FIG. 11, the communication interface 1102, the processor 1101, and the memory 1103 are connected via a bus 1104, and the bus is shown as a thick line in FIG. 11. The connection manner between other components is only an exemplary description and is not limited. The bus can be classified into an address bus, a data bus, a control bus, etc. For ease of expression, in FIG. 11, only one thick line is shown, but it does not mean that there is only one bus or only one type of bus.
[0269] The memory 1103 may be used to store software programs and modules such as program instructions / modules corresponding to the image decoding method or the image encoding method provided by the embodiments of the present invention. The processor 1101 may execute the software programs and modules stored in the memory 1103 to perform various functional applications and data processing, whereby any of the image decoding methods or image encoding methods provided above is implemented. The communication interface 1102 may be used for signaling and data communication with other devices. In the present invention, the electronic device 1100 may have a plurality of communication interfaces 1102.
[0270] As can be understood, the processor in the embodiments of the present invention may be a central processing unit (CPU), a neural processing unit (NPU), or a graphic processing unit (GPU), and may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), 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.
[0271] The steps of the method in the embodiments of the present invention may be implemented by hardware or may be implemented by a processor executing software instructions. The software instructions may be composed of corresponding software modules, and the software modules may be stored in a random access memory (RAM), flash memory, read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), register, hard disk, removable hard disk, CD-ROM, or any other form of storage medium well-known in the art. The present invention provides a computer-readable storage medium storing a computer program or instructions, and when the computer program or instructions are executed by a computing device or a storage system in which the computing device is disposed, an image decoding method or an image encoding method in any one of the embodiments is implemented. An exemplary storage medium is coupled to the processor such that the processor can read information from and write information to the storage medium. Of course, the storage medium may be a component of the processor. The processor and the storage medium may be disposed within an ASIC. Further, the ASIC may be disposed within a network device or a terminal device. Of course, the processor and the storage medium may exist within a network device or a terminal device as independent components.
[0272] The present invention provides a computer program product including instructions, and when the computer program product is executed on a computing device or a processor, causes the computing device or the processor to execute the instructions to implement the method in any one of the embodiments.
[0273] The present invention provides a chip including a memory and a processor, the memory being configured to store computer instructions, and the processor being configured to call and execute the computer instructions from the memory to implement the method in any one of the embodiments.
[0274] The embodiments of the present invention further provide an encoding / decoding system including an encoding side and a decoding side. The encoding side may be configured to execute any one of the foregoing image encoding methods, and the decoding side is configured to execute a corresponding image decoding method.
[0275] In the above embodiments, all or part of them may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of it may be implemented in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are executed. The computer may be a general-purpose computer, a dedicated computer, a computer network, a network device, a user device, or other programmable devices. The computer program or instructions may be stored in a computer-readable storage medium, or may be transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer program or instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire or wirelessly. The computer-readable storage medium may be any available medium accessible by a computer, or a data storage device such as a server or a data center that integrates one or more available media. The available medium may be a magnetic medium such as a floppy disk, a hard disk, or a magnetic tape, an optical medium such as a digital video disc (DVD), or a semiconductor medium such as a solid state drive (SSD).
[0276] In each embodiment of the present invention, if there is no special explanation or logical contradiction, the terms and / or explanations between different embodiments are consistent and can be cited from each other, and the technical features in different embodiments can be combined according to their internal logical relationships to form new embodiments.
[0277] As can be understood, the various numerical numbers related to the embodiments of the present invention are merely attached for convenience of explanation and are not intended to limit the scope of the embodiments of the present invention. The magnitude of the numbers of the above processes does not mean the execution order, and the execution order of each process should be determined by its function and internal logic.
Claims
1. An image decoding method applied to the decoding side, comprising: analyzing a bitstream of a block to be decoded, and when the bitstream of the block to be decoded includes a first codeword, determining whether an image block corresponding to the block to be decoded uses a fallback mode, wherein a code length of the block to be decoded is smaller than a maximum code length of the block to be decoded, the maximum code length is determined based on a set overflow line of a bitstream buffer, the set overflow line is used to indicate a maximum storage space allowed to be occupied by a bitstream in the bitstream buffer, and the first codeword is used to indicate the fallback mode or an original value mode; when the image block corresponding to the block to be decoded uses the fallback mode and a code length stored in the bitstream buffer exceeds the set overflow line, determining a fixed code length of each component of the block to be decoded based on an excess code length of the bitstream buffer, wherein the block to be decoded includes one or more components, 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 when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is a code length by which the code length stored in the bitstream buffer exceeds the set overflow line; analyzing pixel points of each component based on the fixed code length of each component to decode the block to be decoded. An image decoding method, characterized in that.
2. Determining whether the image block corresponding to the block to be decoded uses the fallback mode includes: when a code length encoded based on an original value mode of the image block corresponding to the block to be decoded 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 uses the fallback mode. The image decoding method according to claim 1, characterized in that.
3. Determining whether the image block corresponding to the block to be decoded uses the fallback mode includes: When the code length encoded based on the original value mode of the image block corresponding to the block to be decoded is smaller than the maximum code length of the block to be decoded, determining that the image block corresponding to the block to be decoded uses the original value mode, including The image decoding method according to claim 1, characterized in that
4. Based on the excess code length of the bit stream buffer, determining the fixed code length of each component of the block to be decoded is Based on the excess code length of the bit stream buffer, the target total code length of the block to be decoded, and the image format of the block to be decoded, determining the fixed code length of the luminance component and the fixed code length of the chrominance component of the block to be decoded, including The fixed code length of the luminance component is used to indicate the code length required when analyzing a single pixel point of the luminance component, and the fixed code length of the chrominance component is used to indicate the code length required when analyzing a single pixel point of the chrominance component, The target total code length is the total code length required when decoding the block to be decoded. The image decoding method according to claim 1, characterized in that
5. Based on the excess code length of the bit stream buffer, the target total code length of the block to be decoded, and the image format of the block to be decoded, determining the fixed code length of the luminance component and the fixed code length of the chrominance component of the block to be decoded is Obtaining the code length of the header information of the block to be decoded; Based on 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, determining the fixed code length of the luminance component and the fixed code length of the chrominance component, including The image decoding method according to claim 4, characterized in that
6. The sum of the fixed code lengths of all pixels in the luminance component is greater than or equal to the sum of the fixed code lengths of all pixels in the chrominance component. The image decoding method according to claim 4 or 5, characterized in that
7. The sum of the fixed code length of the luminance component and the fixed code length of the chrominance component is less than or equal to the code length obtained by subtracting the code length of the header information of the block to be decoded and the excess code length of the bit stream buffer from the target total code length of the block to be decoded. The image decoding method according to claim 5, characterized in that
8. analyzing pixel points of each of the components based on a fixed code length of each of the components, analyzing pixel points of the luminance component based on a fixed code length of the luminance component, and analyzing pixel points of the chrominance component based on a fixed code length of the chrominance component; 2. The image decoding method according to claim 1.
9. analyzing the pixel points of the luminance component based on a fixed code length of the luminance component, determining a residual value of a luminance component of the block to be decoded based on a fixed code length of the luminance component; Obtaining a prediction mode of the block to be decoded in the fallback mode, predicting an image block corresponding to the block to be decoded based on the prediction mode, and obtaining a predicted value of the block to be decoded; determining a quantization parameter for the block to be decoded, and inverse-quantizing a residual value of a luminance component of the block to be decoded based on the quantization parameter; reconstructing the block to be decoded based on the residual value after inverse quantization of the luminance component of the block to be decoded and the predicted value to obtain a luminance reconstructed block of the image block.
9. The image decoding method according to claim 8.
10. analyzing the pixel points of the chrominance components based on a fixed code length of the chrominance components, determining residual values of the chrominance components of the block to be decoded based on a fixed code length of the chrominance components; Obtaining a prediction mode of the block to be decoded in the fallback mode, predicting an image block corresponding to the block to be decoded based on the prediction mode, and obtaining a predicted value of the block to be decoded; determining a quantization parameter for the block to be decoded, and inverse-quantizing residual values of chrominance components of the block to be decoded based on the quantization parameter; reconstructing the block to be decoded based on the residual value after inverse quantization of the chrominance component of the block to be decoded and the predicted value to obtain a chrominance reconstructed block of the image block; 9. The image decoding method according to claim 8.
11. Obtaining a prediction mode of the block to be decoded in the fallback mode includes: a prediction mode of the block to be decoded corresponds to the fallback mode; Or, The prediction mode of the block to be decoded is one of a plurality of prediction modes on the decoding side, and includes An image decoding method according to claim 9 or 10, characterized in that
12. An image encoding method applied to the encoding side, comprising A step of obtaining the maximum code length of the block to be encoded, wherein the maximum code length is determined based on the set overflow line of the bit stream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by the bit stream in the bit stream buffer, step; A step of pre-encoding the block to be encoded to obtain a first code length of the block to be encoded, wherein the first code length is the length of the bit stream obtained after the block to be encoded is pre-encoded, step; When the first code length is greater than or equal to the maximum code length, a step of encoding the block to be encoded using a fallback mode, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is smaller than the maximum code length, and the bit 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, step; An image encoding method characterized by
13. When the code length stored in the bit stream buffer exceeds the set overflow line, a step of determining a fixed code length of the luminance component and a fixed code length of the chrominance component of the block to be encoded based on the excess code length of the bit stream buffer, wherein the fixed code length of the luminance component is used to indicate the code length required when encoding a single pixel point of the luminance component, and the fixed code length of the chrominance component is used to indicate the code length required when encoding a single pixel point of the chrominance component, and the excess code length of the bit stream buffer is the code length by which the code length stored in the bit stream buffer exceeds the set overflow line, step; A step of encoding the block to be encoded based on the fixed code length of the luminance component and the fixed code length of the chrominance component, further comprising The image encoding method according to claim 12, characterized in that...
14. An image decoding apparatus applied to the decoding side, which analyzes the bit stream of the block to be decoded, and when the first codeword is included in the bit stream of the block to be decoded, is configured to determine whether the image block corresponding to the block to be decoded uses the fallback mode. The code length of the block to be decoded is smaller than the maximum code length of the block to be decoded, and the maximum code length is determined based on the set overflow line of the bit stream buffer. The set overflow line is used to indicate the maximum storage space that is allowed to be occupied by the bit stream in the bit stream buffer. The first codeword is used to indicate the fallback mode or the original value mode. An analysis module; When the image block corresponding to the block to be decoded uses the fallback mode and the code length stored in the bit stream buffer exceeds the set overflow line, a determination module configured to determine the fixed code length of each component of the block to be decoded based on the excess code length of the bit stream buffer. 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 when analyzing a single pixel point of the first component. The excess code length of the bit stream buffer is the code length by which the code length stored in the bit stream buffer exceeds the set overflow line. The determination module includes: The analysis module is further configured to analyze the pixel points of each component based on the fixed code length of each component and decode the block to be decoded. An image decoding apparatus, characterized in that...
15. The analysis module is further configured to: When the code length encoded based on the original value mode of the image block corresponding to the block to be decoded is equal to or greater than the maximum code length of the block to be decoded, determine that the image block corresponding to the block to be decoded uses the fallback mode. The image decoding apparatus according to claim 14, characterized in that...
16. The analysis module further is configured to determine that the image block corresponding to the block to be decoded uses the original value mode when the code length encoded based on the original value mode of the image block corresponding to the block to be decoded is smaller than the maximum code length of the block to be decoded. The image decoding apparatus according to claim 14, characterized in that. **Claim 17** The determination module further is configured to determine the fixed code length of the luminance component and the fixed code length of the chrominance component of the block to be decoded based on the excess code length of the bitstream buffer, the target total code length of the block to be decoded, and the image format of the block to be decoded. The fixed code length of the luminance component is used to indicate the code length required when analyzing a single pixel point of the luminance component, and the fixed code length of the chrominance component is used to indicate the code length required when analyzing a single pixel point of the chrominance component. The target total code length is the total code length required when decoding the block to be decoded. The image decoding apparatus according to claim 14, characterized in that. **Claim 18** The determination module further obtains the code length of the header information of the block to be decoded. is configured to determine the fixed code length of the luminance component and the fixed code length of the chrominance component based on 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. The image decoding apparatus according to claim 17, characterized in that. **Claim 19** The sum of the fixed code lengths of all pixels in the luminance component is greater than or equal to the sum of the fixed code lengths of all pixels in the chrominance component. The image decoding apparatus according to claim 17 or 18, characterized in that. **Claim 20** The sum of the fixed code length of the luminance component and the fixed code length of the chrominance component is less than or equal to the code length obtained by subtracting the code length of the header information of the block to be decoded and the excess code length of the bitstream buffer from the target total code length of the block to be decoded. The image decoding apparatus according to claim 18, characterized in that. **Claim 21** The analysis module further is configured to analyze the pixel points of the luminance component based on the fixed code length of the luminance component and analyze the pixel points of the chrominance component based on the fixed code length of the chrominance component. The image decoding apparatus according to claim 14, characterized in that. **Claim 22** The analysis module further determines a residual value of a luminance component of the block to be decoded based on the fixed code length of the luminance component, acquires a prediction mode of the block to be decoded in the fallback mode, predicts an image block corresponding to the block to be decoded based on the prediction mode, acquires a predicted value of the block to be decoded, determines a quantization parameter of the block to be decoded, and inverse-quantizes the residual value of the luminance component of the block to be decoded based on the quantization parameter, is configured to reconstruct the block to be decoded based on the inverse-quantized residual value of the luminance component of the block to be decoded and the predicted value to obtain a luminance reconstruction block of the image block. The image decoding apparatus according to claim 21, characterized in that.
23. The analysis module further determines a residual value of a chrominance component of the block to be decoded based on the fixed code length of the chrominance component, acquires a prediction mode of the block to be decoded in the fallback mode, predicts an image block corresponding to the block to be decoded based on the prediction mode, acquires a predicted value of the block to be decoded, determines a quantization parameter of the block to be decoded, and inverse-quantizes the residual value of the chrominance component of the block to be decoded based on the quantization parameter, is configured to reconstruct the block to be decoded based on the inverse-quantized residual value of the chrominance component of the block to be decoded and the predicted value to obtain a chrominance reconstruction block of the image block. The image decoding apparatus according to claim 21, characterized in that.
24. Obtaining the prediction mode of the block to be decoded in the fallback mode means that the prediction mode of the block to be decoded is a prediction mode corresponding to the fallback mode, or the prediction mode of the block to be decoded is one of a plurality of prediction modes on the decoding side, including. The image decoding apparatus according to claim 21, characterized in that.
25. An image encoding apparatus applied to the encoding side, A determination module configured to obtain the maximum code length of the block to be coded, wherein the maximum code length is determined based on a set overflow line of a bit stream buffer, and the set overflow line is used to indicate the maximum storage space allowed to be occupied by a bit stream in the bit stream buffer. The determination module, An encoding module configured to pre-encode the block to be coded to obtain a first code length of the block to be coded, wherein the first code length is the length of the bit stream obtained after the block to be coded is pre-encoded. The encoding module, including When the first code length is greater than or equal to the maximum code length, the encoding module is further configured to code the block to be coded using a fallback mode, and the code length obtained by coding the block to be coded based on the fallback mode is less than the maximum code length. A first code word is included in the bit stream obtained by coding the block to be coded based on the fallback mode, and the first code word is used to indicate the fallback mode or the original value mode. An image coding apparatus characterized by the above.
26. The encoding module further When the code length stored in the bit stream buffer exceeds the set overflow line, based on the excess code length of the bit stream buffer, determine the fixed code length of the luminance component and the fixed code length of the chrominance component of the block to be coded. Based on the fixed code length of the luminance component and the fixed code length of the chrominance component, it is configured to code the block to be coded. The fixed code length of the luminance component is used to indicate the code length required when coding a single pixel point of the luminance component, and the fixed code length of the chrominance component is used to indicate the code length required when coding a single pixel point of the chrominance component. The excess code length of the bit stream buffer is the code length by which the code length stored in the bit stream buffer exceeds the set overflow line. The image coding apparatus according to claim 25, characterized by the above.
27. A memory configured to store computer instructions, and a processor configured to call and execute the computer instructions from the memory to implement the method according to any one of claims 1 to 13. An electronic device characterized by the above. **Claim 28** A computer-readable storage medium storing a computer program or instructions, wherein when the computer program or instructions are executed by an electronic device, the method according to any one of claims 1 to 13 is implemented. A computer-readable storage medium characterized by the above.
Citation Information
Patent Citations
Variable length coding controlling system
JP1993068243A
Picture processor
JP1994152984A
Rate constrained fallback mode for display stream compression
JP2018516491A