Encoding method, decoding method, encoder, decoder, storage medium, and bitstream
By determining the set of candidate prediction modes based on the template region gradient information of the current block during video encoding and decoding, and selecting the intra-frame prediction mode based on the cost, the problem of improving the accuracy of intra-frame prediction is solved, thereby improving the performance of video encoding and decoding.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2025-01-14
- Publication Date
- 2026-07-23
AI Technical Summary
How to improve the accuracy of intra-frame prediction to enhance video encoding and decoding performance.
The first candidate prediction mode set is determined based on the gradient information of the first template region of the current block, and the intra-frame prediction mode is determined based on the cost of the prediction mode, thereby determining the prediction value and reconstruction value of the current block.
This improves the accuracy of intra-frame prediction, thereby enhancing the performance of video encoding and decoding.
Smart Images

Figure CN2025072337_23072026_PF_FP_ABST
Abstract
Description
Encoding / decoding methods, codecs, storage media, and bitstreams Technical Field
[0001] This application relates to the field of video encoding and decoding, and more particularly to an encoding and decoding method, an encoder and decoder, a storage medium, and a bitstream. Background Technology
[0002] Intra-frame prediction technology is widely used in video encoding and decoding. Improving the accuracy of intra-frame prediction, thereby enhancing encoding and decoding performance, is a problem that needs to be solved. Summary of the Invention
[0003] This application provides an encoding / decoding method, an encoding / decoding method, a storage medium, and a bitstream. The various aspects involved in this application are described below.
[0004] In a first aspect, a decoding method is provided, applied to a decoder, comprising: determining a first candidate prediction mode set based on gradient information of a first template region of a current block; determining at least one intra-prediction mode based on the cost of the prediction modes in the first candidate prediction mode set; determining a prediction value of the current block based on the at least one intra-prediction mode; and determining a reconstructed value of the current block based on the prediction value of the current block.
[0005] In a second aspect, an encoding method is provided, applied to an encoder, comprising: determining a first candidate prediction mode set based on gradient information of a first template region of the current block; determining at least one intra-prediction mode based on the cost of the prediction modes in the first candidate prediction mode set; determining a prediction value of the current block based on the at least one intra-prediction mode; and determining a residual value of the current block based on the prediction value of the current block.
[0006] Thirdly, a decoder is provided, comprising: a first determining unit, configured to determine a first candidate prediction mode set based on gradient information of a first template region of a current block; a second determining unit, configured to determine at least one intra-prediction mode based on the cost of the prediction modes in the first candidate prediction mode set; a third determining unit, configured to determine the prediction value of the current block based on the at least one intra-prediction mode; and a fourth determining unit, configured to determine the reconstruction value of the current block based on the prediction value of the current block.
[0007] Fourthly, an encoder is provided, comprising: a first determining unit, configured to determine a first candidate prediction mode set based on gradient information of a first template region of a current block; a second determining unit, configured to determine at least one intra-prediction mode based on the cost of the prediction modes in the first candidate prediction mode set; a third determining unit, configured to determine a prediction value of the current block based on the at least one intra-prediction mode; and a fourth determining unit, configured to determine a residual value of the current block based on the prediction value of the current block.
[0008] Fifthly, a decoder is provided, the decoder comprising: a memory for storing a computer program; and a processor for executing the method as described in the first aspect when running the computer program.
[0009] In a sixth aspect, an encoder is provided, the encoder comprising: a memory for storing a computer program; and a processor for executing the method as described in the second aspect when running the computer program.
[0010] In a seventh aspect, a non-volatile computer-readable storage medium is provided for storing a bit stream, the bit stream being generated by an encoding method using an encoder, or the bit stream being decoded by a decoding method using a decoder, wherein the decoding method is as described in the first aspect and the encoding method is as described in the second aspect.
[0011] Eighthly, a bitstream is provided, the bitstream comprising a bitstream generated by the method described in the second aspect.
[0012] A ninth aspect provides a computer-readable storage medium storing a computer program that, when executed, implements the method described in the first aspect or the method described in the second aspect.
[0013] In a tenth aspect, a computer program product is provided, comprising a computer program that, when executed, implements the method as described in the first or second aspect. Attached Figure Description
[0014] Figure 1 is a structural example diagram of a video encoder applicable to embodiments of this application.
[0015] Figure 2 is a structural example diagram of a video decoder applicable to embodiments of this application.
[0016] Figure 3 shows an example of the spatial adjacent positions of the current block.
[0017] Figure 4 shows an example of non-adjacent positions in the current block.
[0018] Figure 5A is an example diagram of the template area of the current block.
[0019] Figure 5B is another example of the template area of the current block.
[0020] Figure 5C is another example of the template region of the current block.
[0021] Figure 6 is a flowchart illustrating the decoding method provided in an embodiment of this application.
[0022] Figure 7 is an example diagram of the template area of the current block provided in an embodiment of this application.
[0023] Figure 8A is another example diagram of the template area of the current block provided in an embodiment of this application.
[0024] Figure 8B is another example diagram of the template area of the current block provided in the embodiments of this application.
[0025] Figure 9A is another example diagram of the template area of the current block provided in the embodiments of this application.
[0026] Figure 9B is another example diagram of the template area of the current block provided in the embodiments of this application.
[0027] Figure 10 is an example diagram of the MPDIP prediction method.
[0028] Figure 11 is a flowchart illustrating the encoding method provided in an embodiment of this application.
[0029] Figure 12 is a schematic diagram of the structure of a decoder provided in one embodiment of this application.
[0030] Figure 13 is a schematic diagram of the structure of a decoder provided in another embodiment of this application.
[0031] Figure 14 is a schematic diagram of the encoder provided in one embodiment of this application.
[0032] Figure 15 is a schematic diagram of the encoder provided in another embodiment of this application. Detailed Implementation
[0033] Video encoding and decoding framework
[0034] Figure 1 is a schematic block diagram of a video encoder involved in an embodiment of this application.
[0035] It should be understood that the video encoder 100 can be used for lossy compression of images or lossless compression of images. The lossless compression can be visually lossless compression or mathematically lossless compression.
[0036] This video encoder 100 can be applied to image data in luminance / chrominance (YCbCr, YUV) format. For example, the YUV ratio can be 4:2:0, 4:2:2, or 4:4:4, where Y represents luminance (Luma), Cb (U) represents blue chrominance, Cr (V) represents red chrominance, and U and V represent chrominance (Chroma) used to describe color and saturation. For example, in color format, 4:2:0 means that there are 4 luminance components and 2 chrominance components (YYYYCbCr) for every 4 samples; 4:2:2 means that there are 4 luminance components and 4 chrominance components (YYYYCbCrCbCr) for every 4 samples; and 4:4:4 means that all samples are displayed (YYYYCbCrCbCrCbCrCbCr).
[0037] For example, the video encoder 100 reads video data and, for each image (or sub-image or frame) in the video data, divides an image into several coding tree units (CTUs). In some examples, CTUs may be called "tree blocks," "largest coding unit" (LCU), or "coding tree block" (CTB). Each CTU can be associated with a sample block of equal size within the image. Each sample can correspond to one luminance (or luma) sample and two chrominance (or chroma) samples. Therefore, each CTU can be associated with one luminance sample block and two chrominance sample blocks. A CTU can be a square block (or, the shape of the CTU is square). The size of a CTU is, for example, 256×256, 128×128, 64×64, 32×32, etc. A CTU can be further divided into several coding units (CUs) for encoding. CUs can be rectangular blocks or square blocks. The CU can be further divided into prediction units (PUs) and transform units (TUs), thus separating encoding, prediction, and transformation for more flexible processing. In one example, the CTU is divided into CUs using a quadtree structure, and the CUs are further divided into TUs and PUs using a quadtree structure. In some embodiments, the division of the prediction unit and the transform unit can be different.
[0038] It's important to note that video codec standards (such as VVC and HEVC) allow encoders to determine the size and partitioning of CUs and / or PUs based on the video content. For example, regions with simple textures or motion may tend to use larger blocks, while regions with complex textures or motion may tend to use smaller blocks. The deeper the block partitioning, the more complex and closer the blocks can be to the actual texture or motion, but correspondingly, the overhead for representing these partitions is also greater.
[0039] The video encoder and decoder support various PU sizes. Assuming a specific CU size of 2N×2N, the video encoder and decoder can support PU sizes of 2N×2N or N×N for intra-frame prediction, and also support symmetric PUs of 2N×2N, 2N×N, N×2N, N×N, or similar sizes for inter-frame prediction. The video encoder and decoder can also support asymmetric PUs of 2N×nU, 2N×nD, nL×2N, and nR×2N for inter-frame prediction.
[0040] In some embodiments, as shown in FIG1, the video encoder 100 may include: a prediction unit 110, a residual unit 120, a transform / quantization unit 130, an inverse transform / quantization unit 140, a reconstruction unit 150, a loop filtering unit 160, a decoded image buffer 170, and an entropy coding unit 180. It should be noted that the video encoder 100 may include more, fewer, or different functional components.
[0041] In some embodiments, the prediction unit 110 includes an inter-frame prediction unit 111 and an intra-frame prediction unit 112. Because there is a strong correlation between adjacent samples in an image of a video, intra-frame prediction is used in video encoding and decoding techniques to eliminate spatial redundancy between adjacent samples. Because there is a strong similarity between adjacent images in a video, inter-frame prediction is used in video encoding and decoding techniques to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency.
[0042] Inter-frame prediction unit 111 can be used for inter-frame prediction, which can include motion estimation and motion compensation. Referring to image information from different images, inter-frame prediction uses motion information to find reference blocks in the reference images and generates prediction blocks based on these reference blocks to eliminate temporal redundancy. The motion information includes a list of reference images containing the reference image, the reference image index, and motion vectors. Motion vectors can be whole-sample or multi-sample. If the motion vectors are multi-sample, interpolation filtering needs to be used in the reference images to create the required multi-sample blocks. Here, the whole-sample or multi-sample block in the reference image found based on the motion vector is called a reference block. Some techniques directly use the reference block as the prediction block, while others process the reference block further to generate the prediction block. Processing the reference block further to generate the prediction block can also be understood as using the reference block as the prediction block and then processing it to generate a new prediction block.
[0043] Intra-frame prediction unit 112 refers only to information from the same image to predict sample information within the current code image block, thereby eliminating spatial redundancy.
[0044] Intra-frame prediction has multiple prediction modes. Taking the international digital video coding standards H-series as an example, the H.264 / AVC standard has 8 angular prediction modes and 1 non-angular prediction mode, while H.265 / HEVC extends this to 33 angular prediction modes and 2 non-angular prediction modes. HEVC uses Planar, DC, and 33 angular modes for a total of 35 intra-frame prediction modes. VVC uses Planar, DC, and 65 angular modes for a total of 67 intra-frame prediction modes.
[0045] It should be noted that with the increase in angle modes, intra-frame prediction will be more accurate and better meet the needs of the development of high-definition and ultra-high-definition digital video.
[0046] The residual unit 120 can generate a residual block of the CU based on the sample block of the CU and the prediction block of the PU of the CU. For example, the residual unit 120 can generate a residual block of the CU such that each sample in the residual block has a value equal to the difference between the sample in the sample block of the CU and the corresponding sample in the prediction block of the PU of the CU.
[0047] Transform / quantization unit 130 can quantize transform coefficients. Transform / quantization unit 130 can quantize transform coefficients associated with the TU of the CU based on the quantization parameter (QP) value associated with the CU. Video encoder 100 can adjust the degree of quantization applied to the transform coefficients associated with the CU by adjusting the QP value associated with the CU.
[0048] The inverse transform / quantization unit 140 can apply inverse quantization and inverse transform to the quantized transform coefficients to reconstruct the residual block from the quantized transform coefficients.
[0049] The reconstruction unit 150 can add samples of the reconstructed residual block to corresponding samples of one or more prediction blocks generated by the prediction unit 110 to produce a reconstructed image block associated with the TU. By reconstructing the sample blocks of each TU of the CU in this way, the video encoder 100 can reconstruct the sample blocks of the CU.
[0050] The loop filtering unit 160 is used to process the samples after inverse transform and inverse quantization to compensate for distorted information and provide a better reference for subsequent encoded samples. For example, it can perform deblocking filtering to reduce the block effect of sample blocks associated with the CU.
[0051] In some embodiments, the loop filtering unit 160 includes a deblocking filtering unit and a sample adaptive compensation / adaptive loop filtering (SAO / ALF) unit, wherein the deblocking filtering unit is used to remove block effects and the SAO / ALF unit is used to remove ringing effects.
[0052] The decoded image buffer 170 can store reconstructed sample blocks. The inter-frame prediction unit 111 can use a reference image containing the reconstructed sample blocks to perform inter-frame prediction on PUs in other images. In addition, the intra-frame prediction unit 112 can use the reconstructed sample blocks in the decoded image buffer 170 to perform intra-frame prediction on other PUs in the same image as the CU.
[0053] The entropy coding unit 180 can receive quantized transform coefficients from the transform / quantization unit 130. The entropy coding unit 180 can perform one or more entropy coding operations on the quantized transform coefficients to produce entropy-coded data.
[0054] Figure 2 is a schematic block diagram of a video decoder involved in an embodiment of this application.
[0055] As shown in Figure 2, the video decoder 200 includes: an entropy decoding unit 210, a prediction unit 220, an inverse quantization / transformation unit 230, a reconstruction unit 240, a loop filtering unit 250, and a decoded image buffer 260. It should be noted that the video decoder 200 may contain more, fewer, or different functional components.
[0056] Video decoder 200 can receive a bitstream. Entropy decoding unit 210 can parse the bitstream to extract syntax elements. As part of parsing the bitstream, entropy decoding unit 210 can parse the entropy-encoded syntax elements in the bitstream. Prediction unit 220, dequantization / transform unit 230, reconstruction unit 240, and loop filtering unit 250 can decode video data based on the syntax elements extracted from the bitstream, i.e., generate decoded video data.
[0057] In some embodiments, the prediction unit 220 includes an intra-frame prediction unit 222 and an inter-frame prediction unit 221.
[0058] Intra-prediction unit 222 can perform intra-prediction to generate prediction blocks for the PU. Intra-prediction unit 222 can use an intra-prediction mode to generate prediction blocks for the PU based on sample blocks of spatially adjacent PUs. Intra-prediction unit 222 can also determine the intra-prediction mode of the PU based on one or more syntax elements parsed from the bitstream.
[0059] Inter-frame prediction unit 221 can construct a first reference image list (list 0) and a second reference image list (list 1) based on the syntax elements parsed from the bitstream. Furthermore, if the PU uses inter-frame prediction coding, entropy decoding unit 210 can parse the motion information of the PU. Inter-frame prediction unit 221 can determine one or more reference blocks of the PU based on the motion information of the PU. Inter-frame prediction unit 221 can generate prediction blocks for the PU based on one or more reference blocks of the PU.
[0060] The dequantization / transformation unit 230 reversibly quantizes (i.e., dequantizes) the transform coefficients associated with the TU. The dequantization / transformation unit 230 can use the QP value associated with the CU of the TU to determine the degree of quantization.
[0061] After the inverse quantization transform coefficients, the inverse quantization / transformation unit 230 can apply one or more inverse transforms to the inverse quantization transform coefficients to generate a residual block associated with the TU.
[0062] The reconstruction unit 240 uses the residual block associated with the TU of the CU and the prediction block of the PU of the CU to reconstruct the sample block of the CU. For example, the reconstruction unit 240 can add the samples of the residual block to the corresponding samples of the prediction block to reconstruct the sample block of the CU, thereby obtaining the reconstructed image block.
[0063] The loop filter unit 250 can perform deblocking filtering operations to reduce the block effect of sample blocks associated with the CU.
[0064] The video decoder 200 can store the reconstructed image of the CU in the decoded image buffer 260. The video decoder 200 can use the reconstructed image in the decoded image buffer 260 as a reference image for subsequent prediction, or transmit the reconstructed image to a display device for presentation.
[0065] The basic process of video encoding and decoding is as follows: At the encoding end, an image is divided into blocks. For the current block, prediction unit 110 uses intra-frame prediction or inter-frame prediction to generate a prediction block for the current block. Residual unit 120 can calculate a residual block based on the prediction block and the original block of the current block, that is, the difference between the prediction block and the original block of the current block. This residual block can also be called residual information. This residual block is transformed and quantized by transform / quantization unit 130, which can remove information that is not sensitive to the human eye to eliminate visual redundancy. Optionally, the residual block before transformation and quantization by transform / quantization unit 130 can be called a temporal residual block, and the temporal residual block after transformation and quantization by transform / quantization unit 130 can be called a frequency residual block or a frequency domain residual block. Entropy coding unit 180 receives the quantized change coefficients output by transform / quantization unit 130, and can entropy code the quantized change coefficients to output a bitstream. For example, entropy coding unit 180 can eliminate character redundancy based on the target context model and the probability information of the binary bitstream.
[0066] At the decoding end, the entropy decoding unit 210 can parse the bitstream to obtain the prediction information and quantization coefficient matrix of the current block. The prediction unit 220 uses intra-frame prediction or inter-frame prediction to generate the prediction block of the current block based on the prediction information. The dequantization / transform unit 230 uses the quantization coefficient matrix obtained from the bitstream to perform dequantization and inverse transform on the quantization coefficient matrix to obtain the residual block. The reconstruction unit 240 adds the prediction block and the residual block to obtain the reconstructed block. The reconstructed blocks form the reconstructed image. The loop filtering unit 250 performs loop filtering on the reconstructed image based on the image or based on the blocks to obtain the decoded image. The encoding end also needs similar operations to the decoding end to obtain the decoded image. This decoded image can also be called the reconstructed image, which can be used as a reference image for inter-frame prediction of subsequent images.
[0067] It should be noted that the block partitioning information determined at the encoding end, as well as mode information or parameter information such as prediction, transform, quantization, entropy coding, and loop filtering, are carried in the bitstream when necessary. The decoding end determines the same block partitioning information, prediction, transform, quantization, entropy coding, and loop filtering mode information or parameter information as the encoding end by parsing the bitstream and analyzing existing information, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end.
[0068] In some embodiments, the current block may be referred to as the current coding unit (CU), the current prediction unit (PU), or the current transform unit (TU), etc. The prediction block may also be referred to as the predicted image block or the image prediction block, and the reconstructed image block may also be referred to as the reconstruction block or the image reconstruction block.
[0069] In some embodiments, images can be divided into slices or similar components to facilitate parallel processing. Slices within the same image can be processed in parallel, meaning there is no data dependency between different slices within the same image.
[0070] It should be noted that the term "frame" as used in this application can generally be understood as a frame or an image, or in other words, the term "frame" as used in this application can also be replaced with an image or a slice, etc.
[0071] The above describes the basic flow of a video codec under a block-based hybrid coding framework. With the development of technology, some modules or steps of this framework or flow may be optimized. This application is applicable to the basic flow of a video codec under this block-based hybrid coding framework, but is not limited to this framework and flow.
[0072] In the codec framework, before encoding or decoding the current block, a list of most probable modes (MPMs) for the current block is first constructed. The MPM list consists of two parts: the primary most probable mode (PMPM) and the secondary most probable mode (SMPM). The MPM list contains multiple candidate intra-prediction modes; PMPM contains 6 candidate modes, and SMPM contains 16 candidate modes, for a total of 22 candidate intra-prediction modes. The following section describes how the MPM list is constructed.
[0073] The first step is to select the Planar mode as the first candidate intra-prediction mode in the MPM list.
[0074] The second step is to add the intra-prediction modes of adjacent blocks to the MPM list. For example, Figure 3 shows a schematic diagram of adjacent blocks of the current block. As shown in Figure 3, the current block is a codec block with a width of W and a height of H. The method for determining the adjacent blocks of the current block includes: taking the top-left corner coordinates (x, y) of the current block as the origin, first determine the five adjacent positions: left (x-1, y+H-1), top (x+W-1, y-1), top-left (x-1, y-1), top-right (x+W, y-1), and bottom-left (x-1, y+H). Then, based on the codec blocks where these five adjacent positions are located, determine the left adjacent block, top adjacent block, bottom-left adjacent block, top-right adjacent block, and top-left adjacent block.
[0075] The third step is to add the intra-prediction mode derived by decoder-side intra-mode derivation (DIMD) of the current block to the MPM list.
[0076] The fourth step is to add the intra-prediction modes of the non-adjacent blocks of the current block to the MPM list. For example, Figure 4 shows a schematic diagram of non-adjacent blocks of the current block. As shown in Figure 4, the large block containing the numbers is a codec block of the same size as the current block. The position indicated by the number is used to determine the location of the codec block. Accordingly, the intra-prediction modes of the determined codec blocks are added to the MPM list in ascending order of the numbers.
[0077] The above four steps construct a maximum of M non-repeating candidate intra-prediction modes. It should be understood that if the current block meets the MPM ranking conditions, then M equals 8; if the current block does not meet the MPM ranking conditions, then M equals 22. It should be understood that the specific value of M may change with technological advancements, and this embodiment is not limited to this. The MPM ranking conditions include the following:
[0078] (1) If the size of the current block is less than or equal to the first threshold (e.g., 128) and the slice corresponding to the current block is an intra-predicted slice, then the condition for sorting the MPM list of the current block is met; if the slice corresponding to the current block is an inter-predicted slice, and the size of the current block is less than or equal to the second threshold (1024), then the condition for sorting the MPM list is also met. Otherwise, the current block does not meet the condition for sorting the MPM.
[0079] (2) Further, if the MPM list of the current block meets the sorting conditions, and the number of candidates in the MPM list (excluding the first candidate pattern, i.e., the Planar pattern) is greater than or equal to 6, then template sorting is required for the candidate patterns in the current MPM list. Finally, the candidate patterns in the MPM list will be updated according to the sum of absolute differences (SAD) Cost of the template regions. It should be noted that the first candidate pattern is not sorted when sorting the candidate patterns in the MPM list.
[0080] As mentioned earlier, the MPM list consists of two parts: PMPM and SMPM. The intra-prediction modes obtained using the method described above are first used to construct the PMPM list, but the number of these intra-prediction modes may be insufficient to construct the SMPM list. In this case, the intra-prediction modes in the SMPM list can be generated by adding a certain offset value (such as 1, 2, 3, 4) to the intra-prediction modes in the MPM list.
[0081] If the sum of the PMPM and SMPM lists still does not meet the requirement of 22 intra-prediction modes, some default intra-prediction modes will be added. For example, the following intra-prediction mode can be added: {DC_IDX,VER_IDX,HOR_IDX,VER_IDX-4,VER_IDX+4,14,22,42,58,10,26,38,62,6,30,34,66,2,48,52,16}.
[0082] The above steps complete the construction of the MPM list. After the MPM list is constructed (containing 22 intra-prediction modes), the other 45 intra-prediction modes not included in the MPM list are added to the Non-MPM candidate list. The order of addition is to iterate through the 0-66 intra-prediction modes sequentially, adding those not included in the MPM list to the Non-MPM list.
[0083] After completing the MPM list and Non-MPM list, the intra-prediction mode of the current block can be encoded in the following manner, for example:
[0084] First, determine the index of the intra-prediction mode of the current block in the MPM list. Check if the intra-prediction mode of the current block is in the MPM list. If it is, then `mpmFlag` needs to be encoded as true. Second, check if the intra-prediction mode is in the PMPM list. If it is, then `firstMPMFlag` needs to be further encoded as true, and the corresponding prediction mode in Table 1 needs to be determined based on the intra-prediction mode of the current block, using the corresponding bins to represent the mode. For example, if the intra-prediction mode of the current block is a mode in the MPM list, then `mpmFlag` is 1; if the mode is also in the PMPM, then `firstMPMFlag` is also 1; if the mode corresponds to prediction mode 4 in Table 1, then 11110 will be used to encode this intra-prediction mode.
[0085] Table 1
[0086] If the prediction pattern is not in the PMPM list, then firstMPMFlag needs to be encoded as false and secondMPMFlag needs to be encoded as true. For prediction pattern -6, the encoding method shown in Table 2 can be used.
[0087] Table 2
[0088] It should be noted that xx represents the four cases: 00, 01, 10, and 11. For example, when the prediction mode is 0, Bin is 000; when the prediction mode is 1, Bin is 001; when the prediction mode is 2, Bin is 010; and when the prediction mode is 3, Bin is 011.
[0089] Furthermore, if the intra-prediction mode is not in the MPM list, it is in the Non-MPM list. In this case, MPMFlag needs to be encoded as false first, and then fixed-point coding is applied to the intra-prediction mode.
[0090] Next, we will introduce the decoding method of the intra-prediction mode for the current block.
[0091] First, determine if the intra-prediction mode of the current block is in the MPM list, i.e., decode MPMFlag. If MPMFlag is true, it means the intra-prediction mode of the current block is in the MPM list; otherwise, the intra-prediction mode of the current block is in the Non-MPM list. If MPMFlag is true, further determine if the intra-prediction mode of the current block is in the PMPM list, i.e., decode firstMPMFlag. If firstMPMFlag is true, it means the prediction mode of the current block is in the PMPM list. Then, parse the bins corresponding to the prediction mode using the method shown in Table 3. For example, if the parsed bins are 11110, the corresponding prediction mode is 4, which is the intra-prediction mode of the current block.
[0092] Table 3
[0093] Otherwise, if firstMPMFlag is false, it means that the intra-prediction mode of the current block is in the SMPM list. The following parsing method is used to obtain the prediction mode of the current block. Finally, the prediction mode in Table 4 is added by 6 to obtain the intra-prediction mode of the current block.
[0094] Table 4
[0095] For example, if the parsed Bin is 1001, the corresponding number is 4+1=5, which means that the prediction pattern of the current block is 5+6=11.
[0096] Otherwise, the intra-prediction mode is in the Non-MPM list. Fixed-point decoding is used to obtain the intra-prediction mode of the current block.
[0097] The previous article introduced template sorting for the MPM list. The following article will provide a detailed introduction to the template sorting method for the PMPM list.
[0098] The PMPM list sorting conditions are the same as the MPM sorting conditions described above: if the size of the current block is less than or equal to the lower first threshold (e.g., 128) and the slice corresponding to the current block is an intra-predicted slice, then the conditions for sorting the MPM list of the current block are met; if the slice corresponding to the current block is an inter-predicted slice, and the size of the current block is less than or equal to the second threshold (1024), then the conditions for sorting the MPM list are also met. Otherwise, the current block does not meet the conditions for MPM sorting.
[0099] When the PMPM list sorting conditions are met, the SAD Cost of each prediction mode is obtained using the reconstructed samples and predicted samples of the template region. Finally, the candidate intra-prediction modes in the PMPM are sorted in ascending order of SAD Cost. Figure 5A shows a schematic diagram of the left template of the current block. Figure 5B shows a schematic diagram of the upper template of the current block. Figure 5C shows a schematic diagram of the upper and left templates of the current block. When calculating the mode SAD cost, the reconstructed samples of the reference region are first used as the reference samples of the template region. Then, the candidate intra-prediction modes in the PMPM list are used to perform intra-prediction on the samples of the template region to obtain the sample prediction value of the template region. Finally, the SAD cost of the template region corresponding to each candidate intra-prediction mode is calculated using the sample prediction value and the reconstructed value of the template region.
[0100] The preceding text provided a detailed introduction to the intra-frame prediction modes offered by relevant technologies. With the advancement of technology, how to further improve the prediction performance of intra-frame prediction modes, thereby enhancing encoding and decoding efficiency, is a problem that needs to be solved.
[0101] The decoding method provided in the embodiments of this application will be described in detail below with reference to Figure 6.
[0102] Figure 6 is a schematic flowchart of the decoding method provided in an embodiment of this application. The method shown in Figure 6 can be applied to a decoder.
[0103] Referring to Figure 6, in step S610, a first candidate prediction mode set (or first candidate prediction mode list) is determined based on the gradient information of the first template region of the current block (or the gradient information of the reconstructed samples in the first template region). This current block can be called the current coding block or the current decoding block. The current block can be a luma block or a chroma block.
[0104] The first template region of the current block can be a fixed template region. Alternatively, the size of the first template region can be related to the size of the current block. For example, if the size of the current block (e.g., the product of width and height) is less than a threshold of 1 (e.g., 256), then the width of the first template region is 'a' (a could be, for example, 3, i.e., 3 samples); and / or, if the size of the current block is greater than a threshold of 1 (e.g., 256), then the width of the first template region is 'b' (b could be, for example, 4, i.e., 4 samples). Figure 7 provides an example. In the example in Figure 7, the size of the current block is greater than 256, and the template width of the first template region is 4.
[0105] This application does not specifically limit the number of intra-frame prediction modes included in the first candidate prediction mode set. For example, the first candidate prediction mode set may include 8 intra-frame prediction modes.
[0106] Step S610, which mentions determining the first candidate prediction mode set based on the gradient information of the first template region of the current block, may include, for example, determining a gradient histogram based on the gradient information of the first template region of the current block; and determining the first candidate prediction mode set based on the gradient histogram. The derivation process of the gradient histogram can be implemented with reference to the DIMD mode. Therefore, in some implementations, step S610 can also be expressed as: determining the first candidate prediction mode set based on the DIMD mode.
[0107] In some implementations, the ranking of prediction modes in the first candidate prediction mode set can be determined based on the cost of the prediction mode. The cost mentioned here can refer to the template matching cost (which can be determined, for example, using TIMD patterns). In one implementation, a template region of the current block (hereinafter referred to as the second template region, which may be different from the first template region mentioned above) can be predicted based on the prediction modes in the first candidate prediction mode set to determine the predicted value of the second template region; then, the template matching cost of each prediction mode in the first candidate prediction mode set can be determined based on the difference between the reconstructed value and the predicted value of the second template region. After obtaining the template matching cost of each prediction mode in the first candidate prediction mode set, the prediction modes in the first candidate prediction mode set can be ranked based on their template matching costs.
[0108] Referring again to Figure 6, in step S620, at least one intra-frame prediction mode is determined based on the cost of the prediction modes in the first candidate prediction mode set. As mentioned above, the cost of the prediction modes in the first candidate prediction mode set can refer to the template matching cost (the template matching cost can be determined, for example, using TIMD modes). That is, the template region of the current block (hereinafter referred to as the second template region, which may be different from the first template region mentioned above) can be predicted based on the prediction modes in the first candidate prediction mode set to determine the predicted value of the second template region; then, the template matching cost of each prediction mode in the first candidate prediction mode set can be determined based on the difference between the reconstructed value and the predicted value of the second template region. After obtaining the template matching cost of each prediction mode in the first candidate prediction mode set, the at least one intra-frame prediction mode can be determined based on the template matching cost of each prediction mode in the first candidate prediction mode set.
[0109] In one implementation, the at least one intra-prediction mode may include the intra-prediction mode with the lowest cost from the first set of candidate prediction modes. For example, the at least one intra-prediction mode may include only one intra-prediction mode, and this intra-prediction mode is the intra-prediction mode with the lowest cost from the first set of candidate prediction modes. Of course, in other implementations, the at least one intra-prediction mode may also include multiple intra-prediction modes with the lowest and second lowest costs.
[0110] Referring again to Figure 6, in step S630, the predicted value of the current block is determined based on the at least one intra-prediction mode. For example, if the at least one intra-prediction mode includes one intra-prediction mode (such as the intra-prediction mode with the lowest cost mentioned above), the predicted value of the current block can be determined based on that intra-prediction mode. Alternatively, if the at least one intra-prediction mode includes multiple intra-prediction modes, the predicted value of the current block can be determined by weighted summation of the predicted values of the multiple intra-prediction modes.
[0111] In step S640, the reconstructed value of the current block is determined based on the predicted value of the current block. For example, the bitstream can be parsed to determine the residual value of the current block. Then, the reconstructed value of the current block can be determined based on the predicted value and the residual value of the current block. The reconstructed value of the current block can, for example, be equal to the sum of the predicted value and the residual value of the current block.
[0112] As mentioned earlier, the ranking of prediction modes in the first candidate prediction mode set can be determined based on the cost of the prediction mode. This application does not specifically limit the method for determining the cost of the prediction mode. Several possible implementation methods are given below.
[0113] Implementation Method 1
[0114] In implementation method one, the cost of the prediction modes in the first candidate prediction mode set can be determined based on the MPDIP mode. For example, assuming the first candidate prediction mode set includes the first intra-frame prediction mode, the order of the first intra-frame prediction modes in the first candidate prediction mode set can be determined based on the cost of the first intra-frame prediction mode, and the cost of the first intra-frame prediction mode can be determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0115] In one implementation, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: the cost of the first intra-frame prediction mode is determined based on the predicted value and reconstructed value of the second template region of the current block, and the predicted value of the second template region is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0116] For example, the second template region includes the upper template region shown in Figure 8A and the left template region shown in Figure 8B. Based on the MPDIP mode corresponding to the first intra-frame prediction mode, the SAD cost of the upper template region and the left template region of the current block can be calculated using the reference samples corresponding to the upper template region (i.e., the upper reference row and the left reference row in Figure 8A) and the reference samples corresponding to the left template region (i.e., the upper reference row and the left reference row in Figure 8B), respectively.
[0117] Assume the current block has a width of w and a height of h, with the top-left corner (x, y) of the current block as the origin. In the current ECM encoding, the template width for MPM sorting is 1. That is, the upper template region is the reconstructed sample of the upper reference row of the current block, with a width of w equal to the width of the current block, a height of 1, and its top-left corner coordinates (x, y-1). The left template region is the reconstructed sample of the left reference column of the current block, with a width of 1, a height of h equal to the height of the current block, and its top-left corner coordinates (x-1, y).
[0118] The left reference sample of the numMRLLeft column and the top reference sample of the numMRLTop row can be determined based on the size of the current block. For example, in the examples of Figures 8A and 8B, numMRLLeft = 2 and numMRLTop = 2. Therefore, for the top reference row sample of the upper template region, its top-left corner is (x-2, y-1-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2. For the top reference row sample of the left template region, its top-left corner is (x-1-2, y-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the left template region is (x-1-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2.
[0119] After determining the reference samples for the upper and left template regions of the current block, the predicted sample values Pred for the upper and left template regions of the current block can be determined using the reference samples and the preset matrix.
[0120] Then, the reconstructed sample values Recon and predicted values Pred of the upper and left template regions can be used to calculate the SAD cost corresponding to the intra-frame prediction mode.
[0121] for(int i = 0; i <w;++i);
[0122] for(int j = 0; j <h;++j);
[0123] cost+=abs(pred[i][j]-Recon[i][j]);
[0124] Where w is the width of the prediction block Pred and the reconstruction block Recon, and h is the height of the prediction block Pred and the reconstruction block Recon. The calculation method for abs(*) is as follows:
[0125] It should be noted that in some implementations, whether the cost of the first intra-frame prediction mode is determined based on the first intra-frame prediction mode itself or based on the MPDIP mode corresponding to the first intra-frame prediction mode can be determined based on certain conditions (hereinafter referred to as the first condition, which can also be called the MPDIP template activation condition). That is, if the first condition is met, the cost of the first intra-frame prediction mode can be determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0126] The first condition may include one or more of the following: the second template region of the current block includes an upper template region and a left template region; the block corresponding to the current block being shifted up one row has reconstructed upper and left reference samples; the block corresponding to the current block being shifted left one column has reconstructed upper and left reference samples; and the current block supports intra-frame prediction based on MPDIP mode. "The second template region of the current block includes an upper template region and a left template region" can be understood as the template type of the current block having both a left and upper template, i.e., Left_Above_Templete.
[0127] Furthermore, in some implementations, if the first condition is not met, the cost of the first intra-prediction mode can be determined based on the traditional intra-prediction method.
[0128] Implementation Method Two
[0129] Assuming the first candidate prediction mode set includes the first intra-frame prediction modes, the cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the third template region of the current block. The third template region includes the left template region and the top template region, and the predicted value of the third template region is determined based on the reference samples of the third template region. The reference samples of the third template region include the neighboring samples of the current block. Selecting the neighboring samples of the current block as the reference samples of the third template region can improve the accuracy of the calculated cost value.
[0130] For example, the predicted value of the left template region in the third template region is determined based on the upper reference sample and the left reference sample of the left template region, wherein the upper reference sample includes the neighboring samples of the current block.
[0131] For example, the predicted value of the upper template region in the third template region is determined based on the upper reference sample and the left reference sample of the upper template region, and the left reference sample includes the neighboring samples of the current block.
[0132] As a more concrete example, if the third template region of the current block includes both the upper template region and the left template region, the SAD cost of the third template region can be calculated using reference samples as shown in Figures 9A and 9B. For instance, assuming the current block has a width of w and a height of h, with the origin at the top-left corner (x, y), and the width of the third template region is 1, then for the upper reference row sample of the upper template region, its top-left corner is (x, y-2), its width is the width of the current block w * 8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height of the current block h * 8 (consistent with the height of the template region in the existing ECM method), and its width is 1. For the upper reference row sample of the left template, its top-left corner is (x-2, y-1), its width is the width of the current block w * 8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column is located at (x-2, y), its height is h*8 (consistent with the height of the template region in the current block method), and its width is 1. After obtaining the reference samples of the upper and left template regions of the current block, the predicted sample values Pred of the upper and left template regions of the current block can be determined using the reference samples and the first intra-frame prediction mode (which can be a traditional intra-frame prediction mode). Then, the SAD cost corresponding to the first intra-frame prediction mode is calculated using the reconstructed sample values Recon and the predicted values Pred of the upper and left template regions.
[0133] Implementation Method 3
[0134] Besides the third template region mentioned in Implementation Method 2, in some implementations, the cost of the intra-frame prediction mode can also be determined based on the predicted and reconstructed values of the fourth template region of the current block. This fourth template region can include a left template region and an upper template region, and the predicted value of the fourth template region is determined based on reference samples of the fourth template region. The reference samples of the fourth template region are all non-adjacent samples of the current block. Taking Figure 5C as an example, the upper template region and the left template region in Figure 5C can be understood as the aforementioned fourth template region. As can be seen from Figure 5C, the reference samples of the fourth template region (including the upper reference sample and the left reference sample) are all not adjacent to the current block (separated by the fourth template region).
[0135] The preceding text provided a detailed introduction to the first candidate prediction mode set. The mode for intra-frame prediction based on the aforementioned first candidate prediction mode set can be referred to as the most dominant intra-frame prediction (MDIP) mode. That is, if the current block uses the MDIP mode for prediction, the steps shown in Figure 6 can be executed. Correspondingly, the first candidate prediction mode set can be called the candidate mode list corresponding to the MDIP mode.
[0136] In addition to determining the first candidate prediction mode set, some implementations may also determine a second candidate prediction mode set (or a second candidate prediction mode list). This second candidate prediction mode set may include the MPM set and / or non-MPM set of the current block. The MPM set of the current block may, for example, include the PMPM set and the SMPM set. The methods for determining the second candidate prediction mode set are illustrated in detail below.
[0137] In some implementations, a second set of candidate prediction modes for the current block can be determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived from DIMD modes.
[0138] In some implementations, the second candidate prediction mode set does not include the second intra-frame prediction mode. The second intra-frame prediction mode mentioned here can include at least one intra-frame prediction mode mentioned in step S620, that is, an intra-frame prediction mode determined based on the cost of the prediction modes in the first candidate prediction mode set. For example, the at least one intra-frame prediction mode includes one intra-frame prediction mode that is the intra-frame prediction mode with the lowest cost in the first candidate prediction mode set. In other words, if the second candidate prediction mode set includes at least one intra-frame prediction mode mentioned in step S620, then that at least one intra-frame prediction mode can be removed from the second candidate prediction mode set. This is done because the at least one intra-frame prediction mode has already been considered when constructing the first candidate prediction mode set; removing it from the second candidate prediction mode set avoids redundancy in prediction modes, thereby improving decoding efficiency.
[0139] In some implementations, the second intra-prediction mode may include a third intra-prediction mode. This third intra-prediction mode is an intra-prediction mode from the third candidate prediction mode set (e.g., it may include all intra-prediction modes), and the gradient magnitude corresponding to the third intra-prediction mode is less than or equal to the gradient magnitudes corresponding to other intra-prediction modes in the third candidate prediction mode set besides the third intra-prediction mode. The gradient magnitudes corresponding to the intra-prediction modes in the third candidate prediction mode set are determined based on the gradient information of the first template region. For example, the gradient magnitudes of all intra-prediction modes (the gradient magnitudes mentioned in various embodiments of this application may also be called HoG values) can be determined based on the gradient information of the first template region of the current block; then, the 20 intra-prediction modes with the smallest gradient magnitudes are selected as the aforementioned third intra-prediction modes. In other words, the 20 intra-prediction modes with the smallest gradient magnitudes can be removed from the second candidate prediction mode set, thus removing redundant prediction modes, reducing decoding complexity, and having minimal impact on decoding performance.
[0140] For example, if the second intra-prediction mode includes a planar mode, then the second candidate prediction mode set does not include planar modes. For instance, assuming that at least one intra-prediction mode determined in step S620 is the intra-prediction mode with the lowest cost in the first candidate prediction mode set, and that intra-prediction mode with the lowest cost is a planar mode, if the second candidate prediction mode set includes a planar mode, then that planar mode can be removed from the second candidate prediction mode set. Alternatively, assuming that the 20 intra-prediction modes with the lowest gradient magnitude determined based on the gradient information of the first template region of the current block include a planar mode, if the second candidate prediction mode set includes a planar mode, then that planar mode can be removed from the second candidate prediction mode set. Alternatively, if the intra-prediction mode with the lowest cost determined in step S620, and the 20 intra-prediction modes with the lowest gradient magnitude determined based on the gradient information of the first template region of the current block, include a planar mode, then if the second candidate prediction mode set includes a planar mode, then that planar mode can be removed from the second candidate prediction mode set.
[0141] The preceding section discussed the case where the second intra-prediction mode includes planar modes. If the second intra-prediction mode does not include planar modes, then the second candidate prediction mode set (such as the PMPM set) may include planar modes. Furthermore, if the second condition is satisfied, the ordering of intra-prediction modes in the PMPM set is determined based on the costs of multiple intra-prediction modes, including planar modes. In other words, planar modes can participate in the ordering of prediction modes in the PMPM set.
[0142] The second condition may include one or more of the following: the product of the width and height of the current block is less than or equal to a first threshold (e.g., 128), and the prediction mode of the slice corresponding to the current block is intra-frame prediction mode; and / or, the product of the width and height of the current block is less than or equal to a second threshold (1024), and the prediction mode of the slice corresponding to the current block is inter-frame prediction mode.
[0143] If the planar mode is excluded from the PMPM set after sorting, then in some implementations, the planar mode can be added to the SMPM set of the current block. For example, the first intra-prediction mode in the SMPM set of the current block is the planar mode, that is, the planar mode is placed at the beginning of the SMPM set.
[0144] Of course, in some implementations, if the second intra-prediction mode does not include a planar mode and the second condition is not met, then the first intra-prediction mode in the PMPM set is a planar mode. Furthermore, this planar mode may not participate in the ordering of intra-prediction modes in the PMPM set.
[0145] As mentioned in step S610 above, the first template region of the current block (used to determine gradient information, thereby determining the first candidate mode set) may, in some implementations, include an upper template region and a left template region. The first candidate prediction mode set may include one or more of the following: a fourth intra-frame prediction mode determined based on the upper template region of the first template region; a fifth intra-frame prediction mode determined based on the left template region of the first template region; and a sixth intra-frame prediction mode determined based on both the upper and left template regions of the first template region. The number of intra-frame prediction modes included in the fourth intra-frame prediction mode may, for example, be less than or equal to 2. The number of intra-frame prediction modes included in the fifth intra-frame prediction mode may, for example, be less than or equal to 2, and the number of intra-frame prediction modes included in the sixth intra-frame prediction mode may, for example, be less than or equal to 4. As an example, the first candidate prediction mode set includes 8 prediction modes, where 2 prediction modes are determined based on the upper template region of the first template region, another 2 prediction modes are determined based on the left template region of the first template region, and the remaining 4 prediction modes are determined based on both the upper and left template regions of the first template region.
[0146] Step S610 mentioned above can be executed under certain conditions (hereinafter referred to as the third condition). That is, if the third condition is met, the first candidate prediction mode set is determined based on the gradient information of the first template region of the current block. Further, if the third condition is not met, the second candidate prediction mode set of the current block can be determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived based on the DIMD mode (that is, the second candidate prediction mode set (such as the MPM set) can be determined directly without determining the first candidate prediction mode set).
[0147] The embodiments of this application do not specifically limit the setting method of the above-mentioned third condition. The third condition may include, for example, the product of the width and height of the current block being less than or equal to a third threshold (such as 1024). As mentioned above, the prediction mode described in steps S610 to S640 can be called the MDIP mode, and correspondingly, the third condition can be called the activation condition of the MDIP mode.
[0148] Some of the preceding embodiments mentioned a second candidate prediction mode set. The prediction modes in this second candidate prediction mode set can be ordered based on their respective costs. The cost of the prediction modes in this second candidate prediction mode set can be a template cost determined based on a traditional intra-frame prediction mode, or it can be a template cost determined based on an MPDIP mode. For example, the second candidate prediction mode set includes a seventh intra-frame prediction mode, the order of which is determined based on the cost of the seventh intra-frame prediction mode, and the cost of the seventh intra-frame prediction mode is determined based on the MPDIP mode corresponding to the seventh intra-frame prediction mode.
[0149] The following example, using the second candidate prediction pattern set as the PMPM list, provides a more detailed illustration of how to sort the PMPM list based on the MPDIP pattern.
[0150] Step 1: The initial PMPM list can be obtained based on the existing PMPM list construction method of the ECM decoder.
[0151] Step 2 determines whether the current block meets the sorting conditions of the PMPM list (see previous text for PMPM list sorting conditions). If the sorting conditions are met, proceed to step 3; otherwise, proceed to step 6.
[0152] Step 3: Determine whether the current block meets the condition of sorting based on the MPDIP template and whether the prediction mode in the PMPM list has a corresponding MPDIP mode. If the current block meets the condition of sorting based on the MPDIP template and the prediction mode in the PMPM list has a corresponding MPDIP mode, proceed to step 4; otherwise, proceed to step 5.
[0153] [Corrected according to Rule 91 20.02.2025] Step 4: If the prediction mode in the PMPM list has a corresponding MPDIP mode, then calculate the SAD cost of the left template region and the upper template region of the current block respectively using the methods shown in Figures 8A and 8B.
[0154] For example, the template region of the current block includes the upper template region as shown in Figure 8A and the left template region as shown in Figure 8B. Based on the MPDIP mode corresponding to the prediction mode in the PMPM list, the SAD cost of the upper template region of the current block is calculated using the reference samples corresponding to the upper template region (the samples corresponding to the upper reference row and the left reference row in Figure 8A), and the SAD cost of the left template region of the current block is calculated using the reference samples corresponding to the left template region (the samples corresponding to the upper reference row and the left reference row in Figure 8B).
[0155] Assume the current block has a width of w and a height of h, with its top-left corner at coordinates (x, y) relative to the origin. In the current ECM encoding, the MPM sorting template has a width of 1. The upper template region is the reconstructed sample of the upper reference row of the current block, with a width of w and a height of 1, and its top-left corner at coordinates (x, y-1). The left template region is the reconstructed sample of the left reference column of the current block, with a width of 1 and a height of h, and its top-left corner at coordinates (x-1, y).
[0156] The left reference sample of the numMRLLeft column and the top reference sample of the numMRLTop row can be determined based on the size of the current block. For example, in the examples of Figures 8A and 8B, numMRLLeft = 2 and numMRLTop = 2. Therefore, for the top reference row sample of the upper template region, its top-left corner is (x-2, y-1-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2. For the top reference row sample of the left template region, its top-left corner is (x-1-2, y-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the left template region is (x-1-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2.
[0157] After determining the reference samples for the upper and left template regions of the current block, the predicted sample values Pred for the upper and left template regions of the current block can be determined using the reference samples and the preset matrix.
[0158] Then, the reconstructed sample values Recon and predicted values Pred of the upper and left template regions can be used to calculate the SAD cost corresponding to the intra-frame prediction mode.
[0159] for(int i = 0; i <w;++i);
[0160] for(int j = 0; j <h;++j);
[0161] cost+=abs(pred[i][j]-Recon[i][j]);
[0162] Where w is the width of the prediction block Pred and the reconstruction block Recon, and h is the height of the prediction block Pred and the reconstruction block Recon. The calculation method for abs(*) is as follows:
[0163] Otherwise, if the upper template region and the left template region of the current block do not exist simultaneously, the template region SAD cost is still calculated using the existing methods shown in Figures 5A to 5B.
[0164] Step 5: If the prediction patterns in the PMPM list do not have a corresponding MPDIP pattern, and both the upper and left template regions of the current block exist simultaneously, the SAD cost of the template regions can be calculated using the methods shown in Figures 9A and 9B. For example, assume the width of the current block is w, the height is h, the origin is at the top-left corner (x, y), and the width of the template region is 1. For the upper reference row sample of the upper template region, its top-left corner is (x, y-2), its width is the width of the current block w*8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height of the current block h*8 (consistent with the height of the template region in the existing ECM method), and its width is 1. For the upper reference row sample of the left template region, its top-left corner is (x-2, y-1), its width is the width of the current block w*8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column of the left template region is located at (x-2, y), with a height equal to the current block height h*8 (consistent with the height of the template region in the existing ECM method) and a width of 1. After obtaining the reference samples of the upper and left template regions of the current block, the predicted sample values Pred for the upper and left template regions can be calculated using the reference samples and the traditional angle prediction model. Finally, the reconstructed sample values Recon and the predicted values Pred for the upper and left template regions are used to calculate the SAD cost corresponding to the current prediction model.
[0165] Step 6: Use the predicted patterns in the PMPM list to build the SMPM until the number of candidate patterns in the MPM reaches 22.
[0166] Step 7: Construct a Non-MPM list based on the prediction patterns in the MPM list.
[0167] The MPDIP template startup conditions mentioned above may include the following conditions:
[0168] 1) The template type attribute of the current block is Left_Above_Templete (that is, the left template region and the top template region exist simultaneously);
[0169] 2) The upper reference sample and left reference sample of the corresponding block obtained by shifting the current block up one line exist and have been reconstructed;
[0170] 3) The upper reference sample and left reference sample of the corresponding block obtained by shifting the current block one column to the left exist and have been reconstructed;
[0171] 4) The current block size is a size supported by MPDIP mode;
[0172] If conditions 1) to 4) are met simultaneously, the startup conditions for the MPDIP template of the current block are satisfied; otherwise, the startup conditions for the MPDIP template of the current block are not satisfied.
[0173] In some implementations, the set of second candidate prediction modes mentioned in the preceding embodiments may include an eighth intra-frame prediction mode, which is determined based on a ninth intra-frame prediction mode. The eighth intra-frame prediction mode supports the MPDIP mode, while the ninth intra-frame prediction mode does not. For example, the eighth intra-frame prediction mode may be determined based on the prediction mode value and / or one or more offset values of the ninth intra-frame prediction mode.
[0174] The following example, using the second candidate prediction mode set including the PMPM list, SMPM list, and Non-MPM list, provides a more specific illustration of the above implementation method.
[0175] Step 1: Build the PMPM list for the current block.
[0176] For example, the PMPM list of the current block is constructed based on the prediction patterns of the spatially adjacent blocks of the current block, the DIMD pattern of the current block, and the prediction patterns of the spatially non-adjacent blocks of the current block.
[0177] Step 2: Determine whether the current block meets the conditions for intra-frame prediction based on MPDIP mode. These conditions could be, for example: the current block size is a size supported by MPDIP mode; or all upper reference row samples and left reference column samples of the current block have been reconstructed.
[0178] Step 3: If the current block meets the conditions for intra-frame prediction based on MPDIP mode, the initially obtained prediction mode can be rounded to its nearest MPDIP mode (or PDP mode) according to the size of the current block. If the prediction mode is not added to the PMPM list, it can be added to the PMPM list. Otherwise, it can be determined whether the original prediction mode can be added to the PMPM list. If the original prediction mode is not added to the PMPM list, it can be added to the PMPM list.
[0179] The specific execution process of step 3 is as follows:
[0180] (a) Assume the current candidate mode is predMode, and assume its nearest MPDIP intra-prediction mode is predPDPMode. If predMode is less than or equal to 1, directly determine whether the current mode should be added to the candidate mode list. If it is, skip it; otherwise, add the mode to the MPM list.
[0181] (b) If the width and height of the current block are both less than or equal to 16, the nearest MPDIP pattern to the current candidate pattern is calculated as follows:
[0182] i. If the prediction pattern is not added to the list, add the prediction pattern to the MPM list; otherwise, continue to step ii.
[0183] ii. If the most recent predPDPMode was not added to the MPM list in step i, a search will be performed within the range of ±1 for the offset of k. First, the search will be performed for -1, and then for +1. Specifically: if k is greater than 0, it will first be determined whether the prediction mode predPDPMode = 2 × (k - 1) + 2 is greater than or equal to 0 and less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list. If the fourth candidate intra-frame prediction mode is still not found, the offset value will be set to 1, and it will be determined whether the prediction mode predPDPMode = 2 × (k + 1) + 2 is less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list.
[0184] iii. Otherwise, determine whether the original prediction model can be added to the PMPM list. If the original prediction model is not added to the PMPM list, then add the original prediction model to the PMPM list.
[0185] (c) Otherwise, the nearest MPDIP pattern to the current candidate pattern is calculated as follows:
[0186] i. If the prediction pattern is not added to the list, add the prediction pattern to the MPM list; otherwise, continue to step ii.
[0187] ii. If the most recent predPDPMode was not added to the MPM list in step i, a search will be performed within the range of ±1 for the offset of k. First, the search will be performed for -1, and then for +1. Specifically: if k is greater than 0, it will first determine whether the prediction mode predPDPMode = 4 × (k - 1) + 2 is greater than or equal to 0 and less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list. If the fourth candidate intra-frame prediction mode is still not found, the offset value will be set to 1, and it will be determined whether the prediction mode predPDPMode = 4 × (k + 1) + 2 is less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list.
[0188] iii. Otherwise, determine whether the original prediction model can be added to the PMPM list. If the original prediction model is not added to the PMPM list, then add the original prediction model to the PMPM list.
[0189] Step 4: After completing the construction of the PMPM list, update the PMPM list according to whether the existing PMPM list in the ECM is sorted by template.
[0190] Step 5: After constructing the PMPM list, the SMPM is built based on the prediction patterns in the PMPM list with a certain fixed offset (currently offsets 1, 2, 3, 4). During this process, Scheme 3 from the PMPM list construction process is used to convert the initial candidate patterns into the most recent MPDIP patterns. If the number of candidate patterns in the SMPM is still less than 16, some default candidate patterns will be added to the SMPM until the number of candidate patterns in the SMPM reaches 16.
[0191] Step 6: After completing the construction of the MPM list, select from the 0-67 intra-frame prediction modes. The following process is used to construct the Non-MPM list:
[0192] (a) First, use scheme 3 in the PMPM list construction process to convert the initial candidate patterns into the most recent MPDIP patterns. If the converted MPDIP patterns are not added to the MPM list or the Non-MPM list, then add the converted MPDIP patterns to the Non-MPM list.
[0193] (b) Next, determine whether the current initial candidate pattern has been added to the MPM list and the Non-MPM list. If the initial candidate pattern has not been added to the MPM list and the Non-MPM list, then add the initial candidate pattern to the Non-MPM list.
[0194] (c) Construct the Non-MPM list in the above manner until the construction is complete, that is, the length of the candidate patterns in the Non-MPM list reaches 45.
[0195] It should be understood that if the prediction mode of the current block belongs to the second candidate prediction mode set, the bitstream can be decoded to determine a first index. This first index is used to determine the intra-prediction mode of the current block from the second candidate mode set. Then, the predicted value of the current block can be determined based on its intra-prediction mode. Next, the reconstructed value of the current block can be determined based on its predicted value and residual value. If the second candidate prediction modes include the PMPM set, the MPM set, and the Non-MPM set, the bitstream can also carry indication information indicating which of these sets the intra-prediction mode of the current block belongs to.
[0196] It should be noted that the PMPM set (or list) and SMPM set (or list) mentioned above can be two actual sets (or lists), or they can refer to two parts of a single set (or list).
[0197] The MPDIP mode mentioned in some of the previous embodiments. MPDIP mode is a matrix-based intra-frame prediction mode. The MPDIP mode is described below. Table 5 shows the prediction modes in traditional prediction modes that can be replaced by MPDIP mode.
[0198] Table 5
[0199] The startup conditions for MPDIP may include:
[0200] (1) The template type of the current block is Left_Above_Templete, which means that the samples of the left template and the upper template have been reconstructed;
[0201] (2) For blocks of different sizes, there will be different numbers of prediction modes. The MPDIP mode is used for intra-frame prediction, as shown in Table 5. If the width and height of the current block are both less than or equal to 16, and the intra-frame prediction mode is 0, 1, (2+2×k), then the mode satisfies MPDIP prediction; otherwise, if the intra-frame prediction mode is 0, 1, (2+4×k), then the mode satisfies MPDIP prediction.
[0202] (3) For blocks of different sizes, reference samples with different numbers of rows and columns must have been reconstructed. See Table 6 for details:
[0203] Table 6
[0204] (4) The current block size is the block size supported by MPDIP mode. Currently, the block size supported by MPDIP mode is:
[0205] 4×4,4×8,8×4,8×8,4×16,16×4,4×32,32×4,8×16,16×8,16×16,8×32,32×8,16×32,32×16,32×32.
[0206] When the current block meets the conditions (1) to (4) above, the MPDIP mode intra-frame prediction will be performed on the candidate mode of the current block.
[0207] The specific prediction method of the MPDIP mode is shown in Figure 10. When performing intra-frame prediction for the current block, if the intra-frame prediction mode can perform MPDIP intra-frame prediction, a reference sample will be obtained based on the position and size of the current block. Finally, the prediction information of the current block is obtained using the reference sample and a preset matrix vector. If the current block does not meet the conditions of the MPDIP mode, the traditional intra-frame angle prediction mode will be used to obtain the prediction information of the current block.
[0208] The decoding method provided by the embodiments of this application has been described in detail above with reference to Figure 6. The encoding method provided by the embodiments of this application has been described in detail below with reference to Figure 11.
[0209] Figure 11 is a flowchart illustrating the encoding method provided in an embodiment of this application. The method shown in Figure 11 can be applied to an encoder.
[0210] Referring to Figure 11, in step S1110, a first candidate prediction mode set is determined based on the gradient information of the first template region of the current block (or the gradient information of the reconstructed samples in the first template region). This current block can be called the current coding block or the current encoding block. The current block can be a luma block or a chroma block.
[0211] The first template region of the current block can be a fixed template region. Alternatively, the size of the first template region can be related to the size of the current block. For example, if the size of the current block (e.g., the product of width and height) is less than a threshold of 1 (e.g., 256), then the width of the first template region is 'a' (a could be, for example, 3, i.e., 3 samples); and / or, if the size of the current block is greater than a threshold of 1 (e.g., 256), then the width of the first template region is 'b' (b could be, for example, 4, i.e., 4 samples). Figure 7 provides an example. In the example in Figure 7, the size of the current block is greater than 256, and the template width of the first template region is 4.
[0212] This application does not specifically limit the number of intra-frame prediction modes included in the first candidate prediction mode set. For example, the first candidate prediction mode set may include 8 intra-frame prediction modes.
[0213] The step S1110, which mentions determining the first candidate prediction mode set based on the gradient information of the first template region of the current block, may include, for example, determining a gradient histogram based on the gradient information of the first template region of the current block; and determining the first candidate prediction mode set based on the gradient histogram. The derivation process of the gradient histogram can be implemented with reference to the DIMD mode. Therefore, in some implementations, step S1110 can also be expressed as: determining the first candidate prediction mode set based on the DIMD mode.
[0214] In some implementations, the ranking of prediction modes in the first candidate prediction mode set can be determined based on the cost of the prediction mode. The cost mentioned here can refer to the template matching cost (which can be determined, for example, using TIMD patterns). In one implementation, a template region of the current block (hereinafter referred to as the second template region, which may be different from the first template region mentioned above) can be predicted based on the prediction modes in the first candidate prediction mode set to determine the predicted value of the second template region; then, the template matching cost of each prediction mode in the first candidate prediction mode set can be determined based on the difference between the reconstructed value and the predicted value of the second template region. After obtaining the template matching cost of each prediction mode in the first candidate prediction mode set, the prediction modes in the first candidate prediction mode set can be ranked based on their template matching costs.
[0215] Referring again to Figure 11, in step S1120, at least one intra-frame prediction mode is determined based on the cost of the prediction modes in the first candidate prediction mode set. As mentioned above, the cost of the prediction modes in the first candidate prediction mode set can refer to the template matching cost (the template matching cost can be determined, for example, using TIMD modes). That is, the template region of the current block (hereinafter referred to as the second template region, which may be different from the first template region mentioned above) can be predicted based on the prediction modes in the first candidate prediction mode set to determine the predicted value of the second template region; then, the template matching cost of each prediction mode in the first candidate prediction mode set can be determined based on the difference between the reconstructed value and the predicted value of the second template region. After obtaining the template matching cost of each prediction mode in the first candidate prediction mode set, the at least one intra-frame prediction mode can be determined based on the template matching cost of each prediction mode in the first candidate prediction mode set.
[0216] In one implementation, the at least one intra-prediction mode may include the intra-prediction mode with the lowest cost from the first set of candidate prediction modes. For example, the at least one intra-prediction mode may include only one intra-prediction mode, and this intra-prediction mode is the intra-prediction mode with the lowest cost from the first set of candidate prediction modes. Of course, in other implementations, the at least one intra-prediction mode may also include multiple intra-prediction modes with the lowest and second lowest costs.
[0217] Referring again to Figure 11, in step S1130, the predicted value of the current block is determined based on the at least one intra-prediction mode. For example, if the at least one intra-prediction mode includes one intra-prediction mode (such as the intra-prediction mode with the lowest cost mentioned above), the predicted value of the current block can be determined based on that intra-prediction mode. Alternatively, if the at least one intra-prediction mode includes multiple intra-prediction modes, the predicted value of the current block can be determined by weighted summation of the predicted values of the multiple intra-prediction modes.
[0218] In step S1140, the residual value of the current block is determined based on the predicted value of the current block. For example, the residual value of the current block can be obtained by subtracting the original value and the predicted value of the current block.
[0219] As mentioned earlier, the ranking of prediction modes in the first candidate prediction mode set can be determined based on the cost of the prediction mode. This application does not specifically limit the method for determining the cost of the prediction mode. Several possible implementation methods are given below.
[0220] Implementation Method 1
[0221] In implementation method one, the cost of the prediction modes in the first candidate prediction mode set can be determined based on the MPDIP mode. For example, assuming the first candidate prediction mode set includes the first intra-frame prediction mode, the order of the first intra-frame prediction modes in the first candidate prediction mode set can be determined based on the cost of the first intra-frame prediction mode, and the cost of the first intra-frame prediction mode can be determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0222] In one implementation, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: the cost of the first intra-frame prediction mode is determined based on the predicted value and reconstructed value of the second template region of the current block, and the predicted value of the second template region is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0223] For example, the second template region includes the upper template region shown in Figure 8A and the left template region shown in Figure 8B. Based on the MPDIP mode corresponding to the first intra-frame prediction mode, the SAD cost of the upper template region and the left template region of the current block can be calculated using the reference samples corresponding to the upper template region (i.e., the upper reference row and the left reference row in Figure 8A) and the reference samples corresponding to the left template region (i.e., the upper reference row and the left reference row in Figure 8B), respectively.
[0224] Assume the current block has a width of w and a height of h, with the top-left corner (x, y) of the current block as the origin. In the current ECM encoding, the template width for MPM sorting is 1. That is, the upper template region is the reconstructed sample of the upper reference row of the current block, with a width of w equal to the width of the current block, a height of 1, and its top-left corner coordinates (x, y-1). The left template region is the reconstructed sample of the left reference column of the current block, with a width of 1, a height of h equal to the height of the current block, and its top-left corner coordinates (x-1, y).
[0225] The left reference sample of the numMRLLeft column and the top reference sample of the numMRLTop row can be determined based on the size of the current block. For example, in the examples of Figures 8A and 8B, numMRLLeft = 2 and numMRLTop = 2. Therefore, for the top reference row sample of the upper template region, its top-left corner is (x-2, y-1-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2. For the top reference row sample of the left template region, its top-left corner is (x-1-2, y-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the left template region is (x-1-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2.
[0226] After determining the reference samples for the upper and left template regions of the current block, the predicted sample values Pred for the upper and left template regions of the current block can be determined using the reference samples and the preset matrix.
[0227] Then, the reconstructed sample values Recon and predicted values Pred of the upper and left template regions can be used to calculate the SAD cost corresponding to the intra-frame prediction mode.
[0228] for(int i = 0; i <w;++i);
[0229] for(int j = 0; j <h;++j);
[0230] cost+=abs(pred[i][j]-Recon[i][j]);
[0231] Where w is the width of the prediction block Pred and the reconstruction block Recon, and h is the height of the prediction block Pred and the reconstruction block Recon. The calculation method for abs(*) is as follows:
[0232] It should be noted that in some implementations, whether the cost of the first intra-frame prediction mode is determined based on the first intra-frame prediction mode itself or based on the MPDIP mode corresponding to the first intra-frame prediction mode can be determined based on certain conditions (hereinafter referred to as the first condition, which can also be called the MPDIP template activation condition). That is, if the first condition is met, the cost of the first intra-frame prediction mode can be determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0233] The first condition may include one or more of the following: the second template region of the current block includes an upper template region and a left template region; the block corresponding to the current block being shifted up one row has reconstructed upper and left reference samples; the block corresponding to the current block being shifted left one column has reconstructed upper and left reference samples; and the current block supports intra-frame prediction based on MPDIP mode. "The second template region of the current block includes an upper template region and a left template region" can be understood as the template type of the current block having both a left and upper template, i.e., Left_Above_Templete.
[0234] Furthermore, in some implementations, if the first condition is not met, the cost of the first intra-prediction mode can be determined based on the traditional intra-prediction method.
[0235] Implementation Method Two
[0236] Assuming the first candidate prediction mode set includes the first intra-frame prediction modes, the cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the third template region of the current block. The third template region includes the left template region and the top template region, and the predicted value of the third template region is determined based on the reference samples of the third template region. The reference samples of the third template region include the neighboring samples of the current block. Selecting the neighboring samples of the current block as the reference samples of the third template region can improve the accuracy of the calculated cost value.
[0237] For example, the predicted value of the left template region in the third template region is determined based on the upper reference sample and the left reference sample of the left template region, wherein the upper reference sample includes the neighboring samples of the current block.
[0238] For example, the predicted value of the upper template region in the third template region is determined based on the upper reference sample and the left reference sample of the upper template region, and the left reference sample includes the neighboring samples of the current block.
[0239] As a more concrete example, if the third template region of the current block includes both the upper template region and the left template region, the SAD cost of the third template region can be calculated using reference samples as shown in Figures 9A and 9B. For instance, assuming the current block has a width of w and a height of h, with the origin at the top-left corner (x, y), and the width of the third template region is 1, then for the upper reference row sample of the upper template region, its top-left corner is (x, y-2), its width is the width of the current block w * 8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height of the current block h * 8 (consistent with the height of the template region in the existing ECM method), and its width is 1. For the upper reference row sample of the left template, its top-left corner is (x-2, y-1), its width is the width of the current block w * 8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column is located at (x-2, y), its height is h*8 (consistent with the height of the template region in the current block method), and its width is 1. After obtaining the reference samples of the upper and left template regions of the current block, the predicted sample values Pred of the upper and left template regions of the current block can be determined using the reference samples and the first intra-frame prediction mode (which can be a traditional intra-frame prediction mode). Then, the SAD cost corresponding to the first intra-frame prediction mode is calculated using the reconstructed sample values Recon and the predicted values Pred of the upper and left template regions.
[0240] Implementation Method 3
[0241] Besides the third template region mentioned in Implementation Method 2, in some implementations, the cost of the intra-frame prediction mode can also be determined based on the predicted and reconstructed values of the fourth template region of the current block. This fourth template region can include a left template region and an upper template region, and the predicted value of the fourth template region is determined based on reference samples of the fourth template region. The reference samples of the fourth template region are all non-adjacent samples of the current block. Taking Figure 5C as an example, the upper template region and the left template region in Figure 5C can be understood as the aforementioned fourth template region. As can be seen from Figure 5C, the reference samples of the fourth template region (including the upper reference sample and the left reference sample) are all not adjacent to the current block (separated by the fourth template region).
[0242] The first candidate prediction mode set is described in detail above. The mode of intra prediction based on the first candidate prediction mode set mentioned above can be referred to as the most dominant intra prediction (MDIP) mode, for example. That is, if the current block is predicted using the MDIP mode, the steps shown in FIG. 11 can be performed. Accordingly, the first candidate prediction mode set can be referred to as a candidate mode list corresponding to the MDIP mode.
[0243] In addition to determining the first candidate prediction mode set, in some implementations, a second candidate prediction mode set can also be determined. The second candidate prediction mode set can include the MPM set and / or the non-MPM set of the current block. The MPM set of the current block can include the PMPM set and the SMPM set, for example. The determination of the second candidate prediction mode set is described in detail below.
[0244] In some implementations, the second candidate prediction mode set of the current block can be determined according to one or more of the intra prediction mode of the spatial neighboring block of the current block, the intra prediction mode of the spatial non-neighboring block, and the intra prediction mode derived based on the DIMD mode.
[0245] In some implementations, the second candidate prediction mode set does not include the second intra prediction mode. The second intra prediction mode mentioned here can include the at least one intra prediction mode mentioned in step S1120, i.e., the intra prediction mode determined according to the cost of the prediction mode in the first candidate prediction mode set. For example, the at least one intra prediction mode includes one intra prediction mode, and the intra prediction mode is the intra prediction mode with the smallest cost in the first candidate prediction mode set. That is, if the second candidate prediction mode set includes the at least one intra prediction mode mentioned in step S1120, the at least one intra prediction mode can be removed from the second candidate prediction mode. The reason for this is that the at least one intra prediction mode has been considered when constructing the first candidate prediction mode set. Removing the at least one intra prediction mode from the second candidate prediction mode set can avoid redundancy of the prediction mode, thereby improving coding efficiency.
[0246] In some implementations, the second intra-prediction mode may include a third intra-prediction mode. This third intra-prediction mode is an intra-prediction mode from the third candidate prediction mode set (e.g., it may include all intra-prediction modes), and the gradient magnitude corresponding to the third intra-prediction mode is less than or equal to the gradient magnitudes corresponding to other intra-prediction modes in the third candidate prediction mode set besides the third intra-prediction mode. The gradient magnitudes corresponding to the intra-prediction modes in the third candidate prediction mode set are determined based on the gradient information of the first template region. For example, the gradient magnitudes of all intra-prediction modes (the gradient magnitudes mentioned in various embodiments of this application may also be called HoG values) can be determined based on the gradient information of the first template region of the current block; then, the 20 intra-prediction modes with the smallest gradient magnitudes are selected as the aforementioned third intra-prediction modes. In other words, the 20 intra-prediction modes with the smallest gradient magnitudes can be removed from the second candidate prediction mode set, thus removing redundant prediction modes, reducing coding complexity, and having minimal impact on coding performance.
[0247] For example, if the second intra-prediction mode includes a planar mode, then the second candidate prediction mode set does not include planar modes. For instance, assuming that at least one intra-prediction mode determined in step S1120 is the intra-prediction mode with the lowest cost in the first candidate prediction mode set, and that intra-prediction mode with the lowest cost is a planar mode, if the second candidate prediction mode set includes a planar mode, then that planar mode can be removed from the second candidate prediction mode set. Alternatively, assuming that the 20 intra-prediction modes with the lowest gradient magnitude determined based on the gradient information of the first template region of the current block include a planar mode, if the second candidate prediction mode set includes a planar mode, then that planar mode can be removed from the second candidate prediction mode set. Alternatively, if the intra-prediction mode with the lowest cost determined in step S1120, and the 20 intra-prediction modes with the lowest gradient magnitude determined based on the gradient information of the first template region of the current block include a planar mode, then if the second candidate prediction mode set includes a planar mode, then that planar mode can be removed from the second candidate prediction mode set.
[0248] The preceding section discussed the case where the second intra-prediction mode includes planar modes. If the second intra-prediction mode does not include planar modes, then the second candidate prediction mode set (such as the PMPM set) may include planar modes. Furthermore, if the second condition is satisfied, the ordering of intra-prediction modes in the PMPM set is determined based on the costs of multiple intra-prediction modes, including planar modes. In other words, planar modes can participate in the ordering of prediction modes in the PMPM set.
[0249] The second condition may include one or more of the following: the product of the width and height of the current block is less than or equal to a first threshold (e.g., 128), and the prediction mode of the slice corresponding to the current block is intra-frame prediction mode; and / or, the product of the width and height of the current block is less than or equal to a second threshold (1024), and the prediction mode of the slice corresponding to the current block is inter-frame prediction mode.
[0250] If the planar mode is excluded from the PMPM set after sorting, then in some implementations, the planar mode can be added to the SMPM set of the current block. For example, the first intra-prediction mode in the SMPM set of the current block is the planar mode, that is, the planar mode is placed at the beginning of the SMPM set.
[0251] Of course, in some implementations, if the second intra-prediction mode does not include a planar mode and the second condition is not met, then the first intra-prediction mode in the PMPM set is a planar mode. Furthermore, this planar mode may not participate in the ordering of intra-prediction modes in the PMPM set.
[0252] As mentioned in step S1110 above, the first template region of the current block (used to determine gradient information, thereby determining the first candidate mode set) may, in some implementations, include an upper template region and a left template region. The first candidate prediction mode set may include one or more of the following: a fourth intra-frame prediction mode determined based on the upper template region of the first template region; a fifth intra-frame prediction mode determined based on the left template region of the first template region; and a sixth intra-frame prediction mode determined based on both the upper and left template regions of the first template region. The number of intra-frame prediction modes included in the fourth intra-frame prediction mode may, for example, be less than or equal to 2. The number of intra-frame prediction modes included in the fifth intra-frame prediction mode may, for example, be less than or equal to 2, and the number of intra-frame prediction modes included in the sixth intra-frame prediction mode may, for example, be less than or equal to 4. As an example, the first candidate prediction mode set includes 8 prediction modes, where 2 prediction modes are determined based on the upper template region of the first template region, another 2 prediction modes are determined based on the left template region of the first template region, and the remaining 4 prediction modes are determined based on both the upper and left template regions of the first template region.
[0253] Step S1110 mentioned above can be executed under certain conditions (hereinafter referred to as the third condition). That is, if the third condition is met, the first candidate prediction mode set is determined based on the gradient information of the first template region of the current block. Further, if the third condition is not met, the second candidate prediction mode set of the current block can be determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived based on the DIMD mode (that is, the second candidate prediction mode set (such as the MPM set) can be determined directly without determining the first candidate prediction mode set).
[0254] This application embodiment does not specifically limit the setting method of the above-mentioned third condition. The third condition may include, for example, the product of the width and height of the current block being less than or equal to a third threshold (such as 1024). As mentioned above, the prediction mode described in steps S1110 to S1140 can be called the MDIP mode, and correspondingly, the third condition can be called the activation condition of the MDIP mode.
[0255] Some of the preceding embodiments mentioned a second candidate prediction mode set. The prediction modes in this second candidate prediction mode set can be ordered based on their respective costs. The cost of the prediction modes in this second candidate prediction mode set can be a template cost determined based on a traditional intra-frame prediction mode, or it can be a template cost determined based on an MPDIP mode. For example, the second candidate prediction mode set includes a seventh intra-frame prediction mode, the order of which is determined based on the cost of the seventh intra-frame prediction mode, and the cost of the seventh intra-frame prediction mode is determined based on the MPDIP mode corresponding to the seventh intra-frame prediction mode.
[0256] The following example, using the second candidate prediction pattern set as the PMPM list, provides a more detailed illustration of how to sort the PMPM list based on the MPDIP pattern.
[0257] Step 1: The initial PMPM list can be obtained based on the existing PMPM list construction method of the ECM encoder.
[0258] Step 2 determines whether the current block meets the sorting conditions of the PMPM list (see previous text for PMPM list sorting conditions). If the sorting conditions are met, proceed to step 3; otherwise, proceed to step 6.
[0259] Step 3: Determine whether the current block meets the condition of sorting based on the MPDIP template and whether the prediction mode in the PMPM list has a corresponding MPDIP mode. If the current block meets the condition of sorting based on the MPDIP template and the prediction mode in the PMPM list has a corresponding MPDIP mode, proceed to step 4; otherwise, proceed to step 5.
[0260] [Corrected according to Rule 91 20.02.2025] Step 4: If the prediction mode in the PMPM list has a corresponding MPDIP mode, then calculate the SAD cost of the left template region and the upper template region of the current block respectively using the methods shown in Figures 8A and 8B.
[0261] For example, the template region of the current block includes the upper template region as shown in Figure 8A and the left template region as shown in Figure 8B. Based on the MPDIP mode corresponding to the prediction mode in the PMPM list, the SAD cost of the upper template region of the current block is calculated using the reference samples corresponding to the upper template region (the samples corresponding to the upper reference row and the left reference row in Figure 8A), and the SAD cost of the left template region of the current block is calculated using the reference samples corresponding to the left template region (the samples corresponding to the upper reference row and the left reference row in Figure 8B).
[0262] Assume the current block has a width of w and a height of h, with its top-left corner at coordinates (x, y) relative to the origin. In the current ECM encoding, the MPM sorting template has a width of 1. The upper template region is the reconstructed sample of the upper reference row of the current block, with a width of w and a height of 1, and its top-left corner at coordinates (x, y-1). The left template region is the reconstructed sample of the left reference column of the current block, with a width of 1 and a height of h, and its top-left corner at coordinates (x-1, y).
[0263] The left reference sample of the numMRLLeft column and the top reference sample of the numMRLTop row can be determined based on the size of the current block. For example, in the examples of Figures 8A and 8B, numMRLLeft = 2 and numMRLTop = 2. Therefore, for the top reference row sample of the upper template region, its top-left corner is (x-2, y-1-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2. For the top reference row sample of the left template region, its top-left corner is (x-1-2, y-2), its width is the width w of the current block (the width of the short reference sample is w, and the width of the long reference sample is 2w), and its height is 2. The top-left corner of the left reference column of the left template region is (x-1-2, y), its height is the height h of the current block (the height of the short reference sample is h, and the height of the long reference sample is 2h), and its width is 2.
[0264] After determining the reference samples for the upper and left template regions of the current block, the predicted sample values Pred for the upper and left template regions of the current block can be determined using the reference samples and the preset matrix.
[0265] Then, the reconstructed sample values Recon and predicted values Pred of the upper and left template regions can be used to calculate the SAD cost corresponding to the intra-frame prediction mode.
[0266] for(int i = 0; i <w;++i);
[0267] for(int j = 0; j <h;++j);
[0268] cost+=abs(pred[i][j]-Recon[i][j]);
[0269] Where w is the width of the prediction block Pred and the reconstruction block Recon, and h is the height of the prediction block Pred and the reconstruction block Recon. The calculation method for abs(*) is as follows:
[0270] Otherwise, if the upper template region and the left template region of the current block do not exist simultaneously, the template region SAD cost is still calculated using the existing methods shown in Figures 5A to 5B.
[0271] Step 5: If the prediction patterns in the PMPM list do not have a corresponding MPDIP pattern, and both the upper and left template regions of the current block exist simultaneously, the SAD cost of the template regions can be calculated using the methods shown in Figures 9A and 9B. For example, assume the width of the current block is w, the height is h, the origin is at the top-left corner (x, y), and the width of the template region is 1. For the upper reference row sample of the upper template region, its top-left corner is (x, y-2), its width is the width of the current block w*8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column of the upper template region is (x-2, y), its height is the height of the current block h*8 (consistent with the height of the template region in the existing ECM method), and its width is 1. For the upper reference row sample of the left template region, its top-left corner is (x-2, y-1), its width is the width of the current block w*8 (consistent with the width of the template region in the existing ECM method), and its height is 1. The top-left corner of the left reference column of the left template region is located at (x-2, y), with a height equal to the current block height h*8 (consistent with the height of the template region in the existing ECM method) and a width of 1. After obtaining the reference samples of the upper and left template regions of the current block, the predicted sample values Pred for the upper and left template regions can be calculated using the reference samples and the traditional angle prediction model. Finally, the reconstructed sample values Recon and the predicted values Pred for the upper and left template regions are used to calculate the SAD cost corresponding to the current prediction model.
[0272] Step 6: Use the predicted patterns in the PMPM list to build the SMPM until the number of candidate patterns in the MPM reaches 22.
[0273] Step 7: Construct a Non-MPM list based on the prediction patterns in the MPM list.
[0274] The MPDIP template startup conditions mentioned above may include the following conditions:
[0275] 1) The template type attribute of the current block is Left_Above_Templete (that is, the left template region and the top template region exist simultaneously);
[0276] 2) The upper reference sample and left reference sample of the corresponding block obtained by shifting the current block up one line exist and have been reconstructed;
[0277] 3) The upper reference sample and left reference sample of the corresponding block obtained by shifting the current block one column to the left exist and have been reconstructed;
[0278] 4) The current block size is a size supported by MPDIP mode;
[0279] If conditions 1) to 4) are met simultaneously, the startup conditions for the MPDIP template of the current block are satisfied; otherwise, the startup conditions for the MPDIP template of the current block are not satisfied.
[0280] In some implementations, the set of second candidate prediction modes mentioned in the preceding embodiments may include an eighth intra-frame prediction mode, which is determined based on a ninth intra-frame prediction mode. The eighth intra-frame prediction mode supports the MPDIP mode, while the ninth intra-frame prediction mode does not. For example, the eighth intra-frame prediction mode may be determined based on the prediction mode value and / or one or more offset values of the ninth intra-frame prediction mode.
[0281] The following example, using the second candidate prediction mode set including the PMPM list, SMPM list, and Non-MPM list, provides a more specific illustration of the above implementation method.
[0282] Step 1: Build the PMPM list for the current block.
[0283] For example, the PMPM list of the current block is constructed based on the prediction patterns of the spatially adjacent blocks of the current block, the DIMD pattern of the current block, and the prediction patterns of the spatially non-adjacent blocks of the current block.
[0284] Step 2: Determine whether the current block meets the conditions for intra-frame prediction based on MPDIP mode. These conditions could be, for example: the current block size is a size supported by MPDIP mode; or all upper reference row samples and left reference column samples of the current block have been reconstructed.
[0285] Step 3: If the current block meets the conditions for intra-frame prediction based on MPDIP mode, the initially obtained prediction mode can be rounded to its nearest MPDIP mode (or PDP mode) according to the size of the current block. If the prediction mode is not added to the PMPM list, it can be added to the PMPM list. Otherwise, it can be determined whether the original prediction mode can be added to the PMPM list. If the original prediction mode is not added to the PMPM list, it can be added to the PMPM list.
[0286] The specific execution process of step 3 is as follows:
[0287] (a) Assume the current candidate mode is predMode, and assume its nearest MPDIP intra-prediction mode is predPDPMode. If predMode is less than or equal to 1, directly determine whether the current mode should be added to the candidate mode list. If it is, skip it; otherwise, add the mode to the MPM list.
[0288] (b) If the width and height of the current block are both less than or equal to 16, the nearest MPDIP pattern to the current candidate pattern is calculated as follows:
[0289] i. If the prediction pattern is not added to the list, add the prediction pattern to the MPM list; otherwise, continue to step ii.
[0290] ii. If the most recent predPDPMode was not added to the MPM list in step i, a search will be performed within the range of ±1 for the offset of k. First, the search will be performed for -1, and then for +1. Specifically: if k is greater than 0, it will first be determined whether the prediction mode predPDPMode = 2 × (k - 1) + 2 is greater than or equal to 0 and less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list. If the fourth candidate intra-frame prediction mode is still not found, the offset value will be set to 1, and it will be determined whether the prediction mode predPDPMode = 2 × (k + 1) + 2 is less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list.
[0291] iii. Otherwise, determine whether the original prediction model can be added to the PMPM list. If the original prediction model is not added to the PMPM list, then add the original prediction model to the PMPM list.
[0292] (c) Otherwise, the nearest MPDIP pattern to the current candidate pattern is calculated as follows:
[0293] i. If the prediction pattern is not added to the list, add the prediction pattern to the MPM list; otherwise, continue to step ii.
[0294] ii. If the most recent predPDPMode was not added to the MPM list in step i, a search will be performed within the range of ±1 for the offset of k. First, the search will be performed for -1, and then for +1. Specifically: if k is greater than 0, it will first determine whether the prediction mode predPDPMode = 4 × (k - 1) + 2 is greater than or equal to 0 and less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list. If the fourth candidate intra-frame prediction mode is still not found, the offset value will be set to 1, and it will be determined whether the prediction mode predPDPMode = 4 × (k + 1) + 2 is less than 67. If the prediction mode meets the above conditions and has not been added to the MPM list, then the prediction mode will be added to the MPM list.
[0295] iii. Otherwise, determine whether the original prediction model can be added to the PMPM list. If the original prediction model is not added to the PMPM list, then add the original prediction model to the PMPM list.
[0296] Step 4: After completing the construction of the PMPM list, update the PMPM list according to whether the existing PMPM list in the ECM is sorted by template.
[0297] Step 5: After constructing the PMPM list, the SMPM is built based on the prediction patterns in the PMPM list with a certain fixed offset (currently offsets 1, 2, 3, 4). During this process, Scheme 3 from the PMPM list construction process is used to convert the initial candidate patterns into the most recent MPDIP patterns. If the number of candidate patterns in the SMPM is still less than 16, some default candidate patterns will be added to the SMPM until the number of candidate patterns in the SMPM reaches 16.
[0298] Step 6: After completing the construction of the MPM list, select from the 0-67 intra-frame prediction modes. The following process is used to construct the Non-MPM list:
[0299] (a) First, use scheme 3 in the PMPM list construction process to convert the initial candidate patterns into the most recent MPDIP patterns. If the converted MPDIP patterns are not added to the MPM list or the Non-MPM list, then add the converted MPDIP patterns to the Non-MPM list.
[0300] (b) Next, determine whether the current initial candidate pattern has been added to the MPM list and the Non-MPM list. If the initial candidate pattern has not been added to the MPM list and the Non-MPM list, then add the initial candidate pattern to the Non-MPM list.
[0301] (c) Construct the Non-MPM list in the above manner until the construction is complete, that is, the length of the candidate patterns in the Non-MPM list reaches 45.
[0302] In some implementations, the predicted value of the current block can be determined based on the rate-distortion cost of the prediction modes in the second candidate prediction mode set. Furthermore, it can be determined which set (PMPM, SMPM, or Non-MPM) the predicted value of the current block belongs to. Additionally, after obtaining the residual value of the current block, it can be written into the bitstream.
[0303] It should be noted that the PMPM set (or list) and SMPM set (or list) mentioned above can be two actual sets (or lists), or they can refer to two parts of a single set (or list).
[0304] The MPDIP mode mentioned in some of the previous embodiments. MPDIP mode is a matrix-based intra-frame prediction mode. The MPDIP mode is described below. Table 7 shows the prediction modes in traditional prediction modes that can be replaced by MPDIP mode.
[0305] Table 7
[0306] The startup conditions for MPDIP may include:
[0307] (1) The template type of the current block is Left_Above_Templete, which means that the samples of the left template and the upper template have been reconstructed;
[0308] (2) For blocks of different sizes, there will be different numbers of prediction modes. The MPDIP mode is used for intra-frame prediction, as shown in Table 5. If the width and height of the current block are both less than or equal to 16, and the intra-frame prediction mode is 0, 1, (2+2×k), then the mode satisfies MPDIP prediction; otherwise, if the intra-frame prediction mode is 0, 1, (2+4×k), then the mode satisfies MPDIP prediction.
[0309] (3) For blocks of different sizes, reference samples with different numbers of rows and columns must have been reconstructed. See Table 8 for details:
[0310] Table 8
[0311] (4) The current block size is the block size supported by MPDIP mode. Currently, the block size supported by MPDIP mode is:
[0312] 4×4,4×8,8×4,8×8,4×16,16×4,4×32,32×4,8×16,16×8,16×16,8×32,32×8,16×32,32×16,32×32.
[0313] When the current block meets the conditions (1) to (4) above, the MPDIP mode intra-frame prediction will be performed on the candidate mode of the current block.
[0314] The specific prediction method of the MPDIP mode is shown in Figure 10. When performing intra-frame prediction for the current block, if the intra-frame prediction mode can perform MPDIP intra-frame prediction, a reference sample will be obtained based on the position and size of the current block. Finally, the prediction information of the current block is obtained using the reference sample and a preset matrix vector. If the current block does not meet the conditions of the MPDIP mode, the traditional intra-frame angle prediction mode will be used to obtain the prediction information of the current block.
[0315] The method embodiments of this application have been described in detail above with reference to Figures 1 to 11. The apparatus embodiments of this application will be described in detail below with reference to Figures 12 to 15. It should be understood that the descriptions of the method embodiments correspond to the descriptions of the apparatus embodiments; therefore, any parts not described in detail can be referred to the preceding method embodiments.
[0316] Figure 12 is a schematic diagram of the decoder structure provided in one embodiment of this application. The decoder 1200 in Figure 2 includes a first determining unit 1210, a second determining unit 1220, a third determining unit 1230, and a fourth determining unit 1240. The first determining unit 1210 is used to determine a first candidate prediction mode set based on the gradient information of the first template region of the current block; the second determining unit 1220 is used to determine at least one intra-prediction mode based on the cost of the prediction modes in the first candidate prediction mode set; the third determining unit 1230 is used to determine the prediction value of the current block based on the at least one intra-prediction mode; and the fourth determining unit 1240 is used to determine the reconstruction value of the current block based on the prediction value of the current block.
[0317] In some implementations, the first candidate prediction mode set includes a first intra-frame prediction mode, and the order of the first intra-frame prediction mode in the first candidate prediction mode set is determined based on the cost of the first intra-frame prediction mode.
[0318] In some implementations, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0319] In some implementations, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: the cost of the first intra-frame prediction mode is determined based on the predicted value and reconstructed value of the second template region of the current block, and the predicted value of the second template region is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0320] In some implementations, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: if the first condition is met, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0321] The first condition includes one or more of the following:
[0322] The second template region of the current block includes an upper template region and a left template region;
[0323] The block corresponding to the current block being moved up one row has reconstructed upper reference samples and left reference samples;
[0324] The block corresponding to the current block shifted one column to the left has reconstructed upper reference sample and left reference sample;
[0325] The current block supports intra-frame prediction based on MPDIP mode.
[0326] In some implementations, the cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the third template region of the current block, the third template region including the left template region and the upper template region, and the predicted value of the third template region is determined based on the reference samples of the third template region, the reference samples of the third template region including the neighboring samples of the current block.
[0327] In some implementations, the predicted value of the left template region is determined based on the upper reference sample and the left reference sample of the left template region, wherein the upper reference sample includes the neighboring samples of the current block; and / or, the predicted value of the upper template region is determined based on the upper reference sample and the left reference sample of the upper template region, wherein the left reference sample includes the neighboring samples of the current block.
[0328] In some implementations, the cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the fourth template region of the current block. The fourth template region includes a left template region and an upper template region. The predicted value of the fourth template region is determined based on the reference samples of the fourth template region, all of which are non-adjacent samples of the current block.
[0329] In some implementations, the at least one intra-prediction mode includes the intra-prediction mode with the lowest cost from the first set of candidate prediction modes.
[0330] In some implementations, the decoder further includes a fifth determining unit, configured to determine a second candidate prediction mode set for the current block based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived based on DIMD modes.
[0331] In some implementations, the second candidate prediction mode set includes the MPM set and / or non-MPM set of the current block.
[0332] In some implementations, the MPM set includes a PMPM set and a SMPM set.
[0333] In some implementations, the second candidate prediction mode set does not include a second intra-frame prediction mode, which includes one or more of the following:
[0334] The at least one intra-frame prediction mode;
[0335] The third intra-frame prediction mode is an intra-frame prediction mode in the third candidate prediction mode set, and the gradient magnitude corresponding to the third intra-frame prediction mode is less than or equal to the gradient magnitude corresponding to other intra-frame prediction modes in the third candidate prediction mode set besides the third intra-frame prediction mode. The gradient magnitude corresponding to the intra-frame prediction mode in the third candidate prediction mode set is determined based on the gradient information of the first template region.
[0336] In some implementations, the third intra-frame prediction mode includes 20 intra-frame prediction modes.
[0337] In some implementations, if the second intra-frame prediction mode includes a planar mode, then the second candidate prediction mode set does not include a planar mode.
[0338] In some implementations, the second candidate prediction mode set includes a PMPM set. If the second intra-prediction mode does not include planar modes and the second condition is met, the order of the intra-prediction modes in the PMPM set is determined based on the cost of multiple intra-prediction modes, including planar modes.
[0339] In some implementations, if the PMPM set does not include planar modes, then the first intra-prediction mode in the SMPM set of the current block is a planar mode.
[0340] In some implementations, if the second intra-prediction mode does not include a planar mode and the second condition is not met, then the first intra-prediction mode in the PMPM set is a planar mode.
[0341] In some implementations, the second condition includes one or more of the following: the product of the width and height of the current block is less than or equal to a first threshold, and the prediction mode of the slice corresponding to the current block is an intra-frame prediction mode; and / or, the product of the width and height of the current block is less than or equal to a second threshold, and the prediction mode of the slice corresponding to the current block is an inter-frame prediction mode.
[0342] In some implementations, the first template region includes an upper template region and a left template region, and the first candidate prediction mode set includes one or more of the following:
[0343] The fourth intra-frame prediction mode is determined based on the upper template region of the first template region;
[0344] The intra-frame prediction mode determined based on the left template region of the first template region;
[0345] The sixth frame intra-prediction mode is determined based on the upper template region and the left template region of the first template region.
[0346] In some implementations, the fourth intra-prediction mode contains less than or equal to 2 intra-prediction modes; and / or, the fifth intra-prediction mode contains less than or equal to 2 intra-prediction modes; and the sixth intra-prediction mode contains less than or equal to 4 intra-prediction modes.
[0347] In some implementations, the first determining module is used to: if the third condition is met, determine a first candidate prediction mode set based on the gradient information of the first template region of the current block; and / or, if the third condition is not met, determine a second candidate prediction mode set of the current block based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived based on DIMD modes.
[0348] In some implementations, the third condition includes: the product of the width and height of the current block is less than or equal to a third threshold.
[0349] In some implementations, the third threshold is 1024.
[0350] In some implementations, the second candidate prediction mode set includes a seventh intra-frame prediction mode, the order of the seventh intra-frame prediction mode in the second candidate prediction mode set is determined based on the cost of the seventh intra-frame prediction mode, and the cost of the seventh intra-frame prediction mode is determined based on the MPDIP mode corresponding to the seventh intra-frame prediction mode.
[0351] In some implementations, the second candidate prediction mode set includes an eighth intra-frame prediction mode, which is determined based on a ninth intra-frame prediction mode. The eighth intra-frame prediction mode supports the MPDIP mode, while the ninth intra-frame prediction mode does not support the MPDIP mode.
[0352] In some implementations, the eighth intra-frame prediction mode is determined based on the prediction mode value of the ninth intra-frame prediction mode and / or one or more offset values.
[0353] Understandably, in the embodiments of this application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular one. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional module.
[0354] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0355] Therefore, embodiments of this application provide a computer-readable storage medium for use with a decoder, wherein the computer-readable storage medium stores a computer program that, when executed by a processor, implements the decoding method described in the first embodiment.
[0356] Based on the composition of the decoder 1200 and the computer-readable storage medium described above, refer to Figure 13, which shows a schematic diagram of the specific hardware structure of the decoder 1300 provided in this embodiment of the application. As shown in Figure 13, the decoder 1300 may include: a communication interface 1310, a memory 1320, and a processor 1330; the various components are coupled together through a bus system 1340. It is understood that the bus system 1340 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 1340 also includes a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as bus system 1340 in Figure 13.
[0357] The communication interface 1310 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0358] Memory 1320 is used to store computer programs;
[0359] Processor 1330, when running the computer program, performs the following:
[0360] Determine the first block vector of the current block;
[0361] The first candidate prediction mode set is determined based on the gradient information of the first template region of the current block;
[0362] At least one intra-frame prediction mode is determined based on the cost of the prediction modes in the first candidate prediction mode set.
[0363] The predicted value of the current block is determined based on the at least one intra-frame prediction mode;
[0364] The reconstruction value of the current block is determined based on the predicted value of the current block.
[0365] It is understood that the memory 1320 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 1320 of the systems and methods described in this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0366] The processor 1330 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1330 or by instructions in software form. The processor 1330 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 1320. Processor 1330 reads the information in memory 1320 and completes the steps of the above method in conjunction with its hardware.
[0367] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0368] Alternatively, as another embodiment, the processor 1330 is also configured to execute the decoding method described in the foregoing embodiments when running the computer program.
[0369] Figure 14 is a schematic diagram of an encoder provided in one embodiment of this application. The encoder 1400 in Figure 14 includes a first determining unit 1410, a second determining unit 1420, a third determining unit 1430, and a fourth determining unit 1440. The first determining unit 1410 is used to determine a first candidate prediction mode set based on the gradient information of the first template region of the current block; the second determining unit 1420 is used to determine at least one intra-prediction mode based on the cost of the prediction modes in the first candidate prediction mode set; the third determining unit 1430 is used to determine the prediction value of the current block based on the at least one intra-prediction mode; and the fourth determining unit 1440 is used to determine the residual value of the current block based on the prediction value of the current block.
[0370] In some implementations, the first candidate prediction mode set includes a first intra-frame prediction mode, and the order of the first intra-frame prediction mode in the first candidate prediction mode set is determined based on the cost of the first intra-frame prediction mode.
[0371] In some implementations, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0372] In some implementations, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: the cost of the first intra-frame prediction mode is determined based on the predicted value and reconstructed value of the second template region of the current block, and the predicted value of the second template region is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0373] In some implementations, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: if the first condition is met, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
[0374] The first condition includes one or more of the following:
[0375] The second template region of the current block includes an upper template region and a left template region;
[0376] The block corresponding to the current block being moved up one row has reconstructed upper reference samples and left reference samples;
[0377] The block corresponding to the current block shifted one column to the left has reconstructed upper reference sample and left reference sample;
[0378] The current block supports intra-frame prediction based on MPDIP mode.
[0379] In some implementations, the cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the third template region of the current block, the third template region including the left template region and the upper template region, and the predicted value of the third template region is determined based on the reference samples of the third template region, the reference samples of the third template region including the neighboring samples of the current block.
[0380] In some implementations, the predicted value of the left template region is determined based on the upper reference sample and the left reference sample of the left template region, wherein the upper reference sample includes the neighboring samples of the current block; and / or, the predicted value of the upper template region is determined based on the upper reference sample and the left reference sample of the upper template region, wherein the left reference sample includes the neighboring samples of the current block.
[0381] In some implementations, the cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the fourth template region of the current block. The fourth template region includes a left template region and an upper template region. The predicted value of the fourth template region is determined based on the reference samples of the fourth template region, all of which are non-adjacent samples of the current block.
[0382] In some implementations, the at least one intra-prediction mode includes the intra-prediction mode with the lowest cost from the first set of candidate prediction modes.
[0383] In some implementations, the method further includes: a fifth determining unit, configured to determine a second candidate prediction mode set for the current block based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived based on DIMD modes.
[0384] In some implementations, the second candidate prediction mode set includes the MPM set and / or non-MPM set of the current block.
[0385] In some implementations, the MPM set includes a PMPM set and a SMPM set.
[0386] In some implementations, the second candidate prediction mode set does not include a second intra-frame prediction mode, which includes one or more of the following:
[0387] The at least one intra-frame prediction mode;
[0388] The third intra-frame prediction mode is an intra-frame prediction mode in the third candidate prediction mode set, and the gradient magnitude corresponding to the third intra-frame prediction mode is less than or equal to the gradient magnitude corresponding to other intra-frame prediction modes in the third candidate prediction mode set besides the third intra-frame prediction mode. The gradient magnitude corresponding to the intra-frame prediction mode in the third candidate prediction mode set is determined based on the gradient information of the first template region.
[0389] In some implementations, the third intra-frame prediction mode includes 20 intra-frame prediction modes.
[0390] In some implementations, if the second intra-frame prediction mode includes a planar mode, then the second candidate prediction mode set does not include a planar mode.
[0391] In some implementations, the second candidate prediction mode set includes a PMPM set. If the second intra-prediction mode does not include planar modes and the second condition is met, the order of the intra-prediction modes in the PMPM set is determined based on the cost of multiple intra-prediction modes, including planar modes.
[0392] In some implementations, if the PMPM set does not include planar modes, then the first intra-prediction mode in the SMPM set of the current block is a planar mode.
[0393] In some implementations, if the second intra-prediction mode does not include a planar mode and the second condition is not met, then the first intra-prediction mode in the PMPM set is a planar mode.
[0394] In some implementations, the second condition includes one or more of the following: the product of the width and height of the current block is less than or equal to a first threshold, and the prediction mode of the slice corresponding to the current block is an intra-frame prediction mode; and / or, the product of the width and height of the current block is less than or equal to a second threshold, and the prediction mode of the slice corresponding to the current block is an inter-frame prediction mode.
[0395] In some implementations, the first template region includes an upper template region and a left template region, and the first candidate prediction mode set includes one or more of the following: a fourth intra-frame prediction mode determined based on the upper template region of the first template region; a fifth intra-frame prediction mode determined based on the left template region of the first template region; and a sixth intra-frame prediction mode determined based on the upper template region and the left template region of the first template region.
[0396] In some implementations, the fourth intra-prediction mode contains less than or equal to 2 intra-prediction modes; and / or, the fifth intra-prediction mode contains less than or equal to 2 intra-prediction modes; and the sixth intra-prediction mode contains less than or equal to 4 intra-prediction modes.
[0397] In some implementations, the first determining unit is used to: if the third condition is satisfied, determine a first candidate prediction mode set based on the gradient information of the first template region of the current block; and / or, if the third condition is not satisfied, determine a second candidate prediction mode set of the current block based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived based on DIMD modes.
[0398] In some implementations, the third condition includes: the product of the width and height of the current block is less than or equal to a third threshold.
[0399] In some implementations, the third threshold is 1024.
[0400] In some implementations, the second candidate prediction mode set includes a seventh intra-frame prediction mode, the order of the seventh intra-frame prediction mode in the second candidate prediction mode set is determined based on the cost of the seventh intra-frame prediction mode, and the cost of the seventh intra-frame prediction mode is determined based on the MPDIP mode corresponding to the seventh intra-frame prediction mode.
[0401] In some implementations, the second candidate prediction mode set includes an eighth intra-frame prediction mode, which is determined based on a ninth intra-frame prediction mode. The eighth intra-frame prediction mode supports the MPDIP mode, while the ninth intra-frame prediction mode does not support the MPDIP mode.
[0402] In some implementations, the eighth intra-frame prediction mode is determined based on the prediction mode value of the ninth intra-frame prediction mode and / or one or more offset values.
[0403] In some implementations, the encoder further includes: a sixth determining unit, configured to determine the predicted value of the current block based on the rate-distortion cost of the predicted modes in the second candidate prediction mode set; and an encoding unit, configured to write the residual value of the current block into the bitstream.
[0404] Understandably, in the embodiments of this application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular one. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional module.
[0405] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0406] Therefore, embodiments of this application provide a computer-readable storage medium applied to an encoder, wherein the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the decoding method described in any of the foregoing embodiments.
[0407] Based on the composition of the encoder 1400 described above and the computer-readable storage medium, refer to Figure 15, which shows a schematic diagram of the specific hardware structure of the encoder 1500 provided in this embodiment of the application. As shown in Figure 15, the encoder 1500 may include: a communication interface 1510, a memory 1520, and a processor 1530; the various components are coupled together through a bus system 1540. It is understood that the bus system 1540 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 1540 also includes a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as bus system 1540 in Figure 15.
[0408] The communication interface 1510 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0409] Memory 1520 is used to store computer programs;
[0410] Processor 1530, when running the computer program, performs the following:
[0411] The first candidate prediction mode set is determined based on the gradient information of the first template region of the current block;
[0412] At least one intra-frame prediction mode is determined based on the cost of the prediction modes in the first candidate prediction mode set.
[0413] The predicted value of the current block is determined based on the at least one intra-frame prediction mode;
[0414] The residual value of the current block is determined based on the predicted value of the current block.
[0415] It is understood that the memory 1520 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 1520 of the systems and methods described in this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0416] The processor 1530 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1530 or by instructions in software form. The processor 1530 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 1520. Processor 1530 reads the information in memory 1520 and completes the steps of the above method in conjunction with its hardware.
[0417] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0418] Alternatively, as another embodiment, the processor 1530 is also configured to execute the encoding method in the foregoing embodiments when running the computer program.
[0419] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0420] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0421] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0422] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0423] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0424] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A decoding method, applied to a decoder, comprising: The first candidate prediction mode set is determined based on the gradient information of the first template region of the current block; At least one intra-frame prediction mode is determined based on the cost of the prediction modes in the first candidate prediction mode set. The predicted value of the current block is determined based on the at least one intra-frame prediction mode; The reconstruction value of the current block is determined based on the predicted value of the current block.
2. The method according to claim 1, wherein, The first candidate prediction mode set includes a first intra-frame prediction mode, and the order of the first intra-frame prediction mode in the first candidate prediction mode set is determined based on the cost of the first intra-frame prediction mode.
3. The method according to claim 2, wherein, The cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
4. The method according to claim 3, wherein, The cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: the cost of the first intra-frame prediction mode is determined based on the predicted value and the reconstructed value of the second template region of the current block, and the predicted value of the second template region is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
5. The method according to claim 3 or 4, wherein, The cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: if the first condition is met, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode. The first condition includes one or more of the following: The second template region of the current block includes an upper template region and a left template region; The block corresponding to the current block being moved up one row has reconstructed upper reference samples and left reference samples; The block corresponding to the current block shifted one column to the left has reconstructed upper reference sample and left reference sample; The current block supports intra-frame prediction based on MPDIP mode.
6. The method according to claim 2, wherein, The cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the third template region of the current block. The third template region includes a left template region and an upper template region. The predicted value of the third template region is determined based on the reference samples of the third template region, which include the neighboring samples of the current block.
7. The method according to claim 6, wherein: The predicted value of the left template region is determined based on the upper reference sample and the left reference sample of the left template region, wherein the upper reference sample includes the neighboring samples of the current block; And / or, The predicted value of the upper template region is determined based on the upper reference sample and the left reference sample of the upper template region, wherein the left reference sample includes the neighboring samples of the current block.
8. The method according to claim 2, wherein, The cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the fourth template region of the current block. The fourth template region includes a left template region and an upper template region. The predicted value of the fourth template region is determined based on the reference samples of the fourth template region. All reference samples of the fourth template region are non-adjacent samples of the current block.
9. The method according to any one of claims 1 to 8, wherein, The at least one intra-prediction mode includes the intra-prediction mode with the lowest cost from the first set of candidate prediction modes.
10. The method according to any one of claims 1 to 9, wherein, The method further includes: A second set of candidate prediction modes for the current block is determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived from DIMD modes.
11. The method according to claim 10, wherein, The second candidate prediction pattern set includes the MPM set and / or non-MPM set of the current block.
12. The method according to claim 11, wherein, The MPM set includes the PMPM set and the SMPM set.
13. The method according to any one of claims 10 to 12, wherein, The second candidate prediction mode set does not include the second intra-frame prediction mode, which includes one or more of the following: The at least one intra-frame prediction mode; The third intra-frame prediction mode is an intra-frame prediction mode in the third candidate prediction mode set, and the gradient magnitude corresponding to the third intra-frame prediction mode is less than or equal to the gradient magnitude corresponding to other intra-frame prediction modes in the third candidate prediction mode set besides the third intra-frame prediction mode. The gradient magnitude corresponding to the intra-frame prediction mode in the third candidate prediction mode set is determined based on the gradient information of the first template region.
14. The method according to claim 13, wherein, If the second intra-frame prediction mode includes a planar mode, then the second candidate prediction mode set does not include a planar mode.
15. The method according to claim 14, wherein, The second candidate prediction mode set includes the PMPM set. If the second intra-prediction mode does not include planar modes and the second condition is met, then the order of the intra-prediction modes in the PMPM set is determined based on the cost of multiple intra-prediction modes, including planar modes.
16. The method according to claim 15, wherein, If the PMPM set does not include planar modes, then the first intra-prediction mode in the SMPM set of the current block is a planar mode.
17. The method according to claim 15, wherein, If the second intra-prediction mode does not include a planar mode and the second condition is not met, then the first intra-prediction mode in the PMPM set is a planar mode.
18. The method according to any one of claims 15 to 17, characterized in that, The second condition includes one or more of the following: The product of the width and height of the current block is less than or equal to a first threshold, and the prediction mode of the slice corresponding to the current block is intra-frame prediction mode; and / or, The product of the width and height of the current block is less than or equal to the second threshold, and the prediction mode of the slice corresponding to the current block is the inter-frame prediction mode.
19. The method according to any one of claims 1 to 18, wherein, The first template region includes an upper template region and a left template region, and the first candidate prediction mode set includes one or more of the following: The fourth intra-frame prediction mode is determined based on the upper template region of the first template region; The intra-frame prediction mode determined based on the left template region of the first template region; The sixth frame intra-prediction mode is determined based on the upper template region and the left template region of the first template region.
20. The method according to any one of claims 1 to 19, wherein, The step of determining the first candidate prediction mode set based on the gradient information of the first template region of the current block includes: If the third condition is met, then a first candidate prediction mode set is determined based on the gradient information of the first template region of the current block; and / or, If the third condition is not met, then the second candidate prediction mode set for the current block is determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived from DIMD modes.
21. The method according to claim 20, wherein, The third condition includes: the product of the width and height of the current block is less than or equal to the third threshold.
22. The method according to claim 10, wherein, The second candidate prediction mode set includes a seventh intra-frame prediction mode. The order of the seventh intra-frame prediction mode in the second candidate prediction mode set is determined based on the cost of the seventh intra-frame prediction mode. The cost of the seventh intra-frame prediction mode is determined based on the MPDIP mode corresponding to the seventh intra-frame prediction mode.
23. The method according to claim 10, wherein, The second candidate prediction mode set includes an eighth intra-frame prediction mode, which is determined based on a ninth intra-frame prediction mode. The eighth intra-frame prediction mode supports MPDIP mode, while the ninth intra-frame prediction mode does not support MPDIP mode.
24. The method according to claim 23, wherein, The eighth intra-frame prediction mode is determined based on the prediction mode value of the ninth intra-frame prediction mode and / or one or more offset values.
25. The method according to claim 1, wherein, The method further includes: Determine the residual value of the current block; Determining the reconstructed value of the current block based on the predicted value of the current block includes: The reconstructed value of the current block is determined based on the predicted value of the current block and the residual value.
26. An encoding method, applied to an encoder, comprising: The first candidate prediction mode set is determined based on the gradient information of the first template region of the current block; At least one intra-frame prediction mode is determined based on the cost of the prediction modes in the first candidate prediction mode set. The predicted value of the current block is determined based on the at least one intra-frame prediction mode; The residual value of the current block is determined based on the predicted value of the current block.
27. The method according to claim 26, wherein, The first candidate prediction mode set includes a first intra-frame prediction mode, and the order of the first intra-frame prediction mode in the first candidate prediction mode set is determined based on the cost of the first intra-frame prediction mode.
28. The method according to claim 27, wherein, The cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
29. The method according to claim 28, wherein, The cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: the cost of the first intra-frame prediction mode is determined based on the predicted value and the reconstructed value of the second template region of the current block, and the predicted value of the second template region is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode.
30. The method according to claim 28 or 29, wherein, The cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode, including: if the first condition is met, the cost of the first intra-frame prediction mode is determined based on the MPDIP mode corresponding to the first intra-frame prediction mode. The first condition includes one or more of the following: The second template region of the current block includes an upper template region and a left template region; The block corresponding to the current block being moved up one row has reconstructed upper reference samples and left reference samples; The block corresponding to the current block shifted one column to the left has reconstructed upper reference sample and left reference sample; The current block supports intra-frame prediction based on MPDIP mode.
31. The method according to claim 27, wherein, The cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the third template region of the current block. The third template region includes a left template region and an upper template region. The predicted value of the third template region is determined based on the reference samples of the third template region, which include the neighboring samples of the current block.
32. The method according to claim 31, wherein: The predicted value of the left template region is determined based on the upper reference sample and the left reference sample of the left template region, wherein the upper reference sample includes the neighboring samples of the current block; And / or, The predicted value of the upper template region is determined based on the upper reference sample and the left reference sample of the upper template region, wherein the left reference sample includes the neighboring samples of the current block.
33. The method according to claim 27, wherein, The cost of the first intra-frame prediction mode is determined based on the predicted and reconstructed values of the fourth template region of the current block. The fourth template region includes a left template region and an upper template region. The predicted value of the fourth template region is determined based on the reference samples of the fourth template region. All reference samples of the fourth template region are non-adjacent samples of the current block.
34. The method according to any one of claims 26 to 33, wherein, The at least one intra-prediction mode includes the intra-prediction mode with the lowest cost from the first set of candidate prediction modes.
35. The method according to any one of claims 26 to 34, wherein, The method further includes: A second set of candidate prediction modes for the current block is determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived from DIMD modes.
36. The method according to claim 35, wherein, The second candidate prediction pattern set includes the MPM set and / or non-MPM set of the current block.
37. The method of claim 36, wherein, The MPM set includes the PMPM set and the SMPM set.
38. The method according to any one of claims 35 to 37, wherein, The second candidate prediction mode set does not include the second intra-frame prediction mode, which includes one or more of the following: The at least one intra-frame prediction mode; The third intra-frame prediction mode is an intra-frame prediction mode in the third candidate prediction mode set, and the gradient magnitude corresponding to the third intra-frame prediction mode is less than or equal to the gradient magnitude corresponding to other intra-frame prediction modes in the third candidate prediction mode set besides the third intra-frame prediction mode. The gradient magnitude corresponding to the intra-frame prediction mode in the third candidate prediction mode set is determined based on the gradient information of the first template region.
39. The method according to claim 38, wherein, If the second intra-frame prediction mode includes a planar mode, then the second candidate prediction mode set does not include a planar mode.
40. The method according to claim 39, wherein, The second candidate prediction mode set includes the PMPM set. If the second intra-prediction mode does not include planar modes and the second condition is met, then the order of the intra-prediction modes in the PMPM set is determined based on the cost of multiple intra-prediction modes, including planar modes.
41. The method according to claim 40, wherein, If the PMPM set does not include planar modes, then the first intra-prediction mode in the SMPM set of the current block is a planar mode.
42. The method according to claim 40, wherein, If the second intra-prediction mode does not include a planar mode and the second condition is not met, then the first intra-prediction mode in the PMPM set is a planar mode.
43. The method according to any one of claims 40 to 42, characterized in that, The second condition includes one or more of the following: The product of the width and height of the current block is less than or equal to a first threshold, and the prediction mode of the slice corresponding to the current block is intra-frame prediction mode; and / or, The product of the width and height of the current block is less than or equal to the second threshold, and the prediction mode of the slice corresponding to the current block is the inter-frame prediction mode.
44. The method according to any one of claims 26 to 43, wherein, The first template region includes an upper template region and a left template region, and the first candidate prediction mode set includes one or more of the following: The fourth intra-frame prediction mode is determined based on the upper template region of the first template region; The intra-frame prediction mode determined based on the left template region of the first template region; The sixth frame intra-prediction mode is determined based on the upper template region and the left template region of the first template region.
45. The method according to any one of claims 26 to 44, wherein, The step of determining the first candidate prediction mode set based on the gradient information of the first template region of the current block includes: If the third condition is met, then a first candidate prediction mode set is determined based on the gradient information of the first template region of the current block; and / or, If the third condition is not met, then the second candidate prediction mode set for the current block is determined based on one or more of the intra prediction modes of spatially adjacent blocks, intra prediction modes of spatially non-adjacent blocks, and intra prediction modes derived from DIMD modes.
46. The method according to claim 45, wherein, The third condition includes: the product of the width and height of the current block is less than or equal to the third threshold.
47. The method of claim 35, wherein, The second candidate prediction mode set includes a seventh intra-frame prediction mode. The order of the seventh intra-frame prediction mode in the second candidate prediction mode set is determined based on the cost of the seventh intra-frame prediction mode. The cost of the seventh intra-frame prediction mode is determined based on the MPDIP mode corresponding to the seventh intra-frame prediction mode.
48. The method according to claim 35, wherein, The second candidate prediction mode set includes an eighth intra-frame prediction mode, which is determined based on a ninth intra-frame prediction mode. The eighth intra-frame prediction mode supports MPDIP mode, while the ninth intra-frame prediction mode does not support MPDIP mode.
49. The method according to claim 48, wherein, The eighth intra-frame prediction mode is determined based on the prediction mode value of the ninth intra-frame prediction mode and / or one or more offset values.
50. The method of claim 35, wherein, The method further includes: The predicted value of the current block is determined based on the rate-distortion cost of the prediction modes in the second candidate prediction mode set. Write the residual value of the current block into the bitstream.
51. A decoder, comprising: The first determining unit is used to determine the first candidate prediction mode set based on the gradient information of the first template region of the current block; The second determining unit is used to determine at least one intra-frame prediction mode based on the cost of the prediction modes in the first candidate prediction mode set. The third determining unit is used to determine the prediction value of the current block according to the at least one intra-frame prediction mode; The fourth determining unit is used to determine the reconstruction value of the current block based on the predicted value of the current block.
52. An encoder, comprising: The first determining unit is used to determine the first candidate prediction mode set based on the gradient information of the first template region of the current block; The second determining unit is used to determine at least one intra-frame prediction mode based on the cost of the prediction modes in the first candidate prediction mode set. The third determining unit is used to determine the prediction value of the current block according to the at least one intra-frame prediction mode; The fourth determining unit is used to determine the residual value of the current block based on the predicted value of the current block.
53. A decoder, comprising: Memory, used to store computer programs; A processor, configured to perform the method as described in any one of claims 1 to 25 when running the computer program.
54. An encoder, comprising: Memory, used to store computer programs; A processor, configured to perform the method as described in any one of claims 26 to 50 when running the computer program.
55. A non-volatile computer-readable storage medium for storing a bitstream, said bitstream being generated by an encoding method using an encoder, or said bitstream being decoded by a decoding method using a decoder, wherein, The decoding method is the method as described in any one of claims 1 to 25, and the encoding method is the method as described in any one of claims 26 to 50.
56. A bitstream comprising a bitstream generated by the method of any one of claims 26 to 50.
57. A computer-readable storage medium, wherein, The computer-readable storage medium stores a computer program that, when executed, implements the method as described in any one of claims 1 to 25, or the method as described in any one of claims 26 to 50.