Encoding / decoding methods, bitstreams, encoders, decoders, and storage media

By selecting templates based on block size information, the method addresses inefficiencies in template-based prediction, reducing overhead and improving compression efficiency and performance in video codecs.

JP2026513796APending Publication Date: 2026-05-01GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
Filing Date
2023-04-03
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Template-based prediction technologies in video codecs face inefficiencies due to the use of templates that are not applicable in certain scenarios, leading to unnecessary overhead and interference, particularly when the width and height differences are large or when there are too few template pixels on one side.

Method used

Determine a first template for the current block based on its size information when using a pre-configured template-based prediction mode, selecting from candidate templates that fit the block's dimensions to reduce interference and improve compression efficiency.

Benefits of technology

This approach reduces unnecessary overhead and improves encoding/decoding performance by ensuring templates are appropriately matched to the block's size, enhancing compression efficiency and overall performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2026513796000001_ABST
    Figure 2026513796000001_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium. If the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, and the preset prediction mode includes a template-based prediction mode, which determines the predicted value corresponding to the current block based on the first template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of video codec, and particularly to encoding / decoding methods, bitstreams, encoders, decoders, and storage media.

Background Art

[0002] In the prediction processing process of a part of image information, prediction of an encoding block can be performed by using template matching technology or template analysis technology. Here, the prediction technology related to the use of templates can be collectively called template-based prediction technology.

[0003] In related technologies, template-based prediction technology includes, but is not limited to, inter-template matching, template matching of intra-block copy (IBC: Intra Block Copy), intra-template matching prediction (Intra TMP: Intra Template Matching Prediction), template-based intra mode derivation (TIMD: Template based intra mode derivation), decoder-side intra mode derivation (DIMD: Decoder-side Intra Mode Derivation), etc.

[0004] However, in the actual use process of template-based prediction technology, some templates may not be applicable in some scenes, such as when the difference between the width and height is large, or when the number of template pixels on one side is too small. The use of some templates may increase unnecessary overhead or increase interference due to unreasonable results.

Summary of the Invention

[0005] Embodiments of the present invention provide an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium that can reduce interference due to unnecessary overhead and unreasonable results, further improve compression efficiency, and enhance encoding / decoding performance.

[0006] The technical solution of the embodiment of this application can be realized as follows.

[0007] In the first aspect, embodiments of the present application provide a decoding method applicable to a decoder, the method being: If the prediction mode corresponding to the current block is a pre-configured prediction mode, then a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, wherein the pre-configured prediction mode includes a template-based prediction mode. This includes determining a predicted value corresponding to the current block based on the first template.

[0008] In a second aspect, an embodiment of the present application provides an encoding method applicable to an encoder, the method being: If the prediction mode corresponding to the current block is a pre-configured prediction mode, then a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, wherein the pre-configured prediction mode includes a template-based prediction mode. This includes determining a predicted value corresponding to the current block based on the first template.

[0009] In a third aspect, an embodiment of the present application provides a bitstream, the bitstream is generated by bit encoding based on information to be encoded, and the information to be encoded is It includes at least one of the following: prediction mode identification information, first template instruction information, second template instruction information, and prediction residual.

[0010] In a fourth aspect, an embodiment of the present application provides an encoder comprising a first determination unit, The first decision unit is configured to perform the following: when the prediction mode corresponding to the current block is a pre-configured prediction mode, determine a first template corresponding to the current block from at least one candidate template based on the size information of the current block, wherein the pre-configured prediction mode includes a template-based prediction mode; and determine a predicted value corresponding to the current block based on the first template.

[0011] In a fifth aspect, an embodiment of the present application provides an encoder comprising a first memory and a first processor, The first memory is configured to store a computer program that can be executed by the first processor. The first processor is configured to perform the method described in the second embodiment when executing the computer program.

[0012] In a sixth aspect, an embodiment of the present application provides a decoder comprising a second determination unit, The second decision unit is configured to perform the following: when the prediction mode corresponding to the current block is a pre-configured prediction mode, determine a first template corresponding to the current block from at least one candidate template based on the size information of the current block, wherein the pre-configured prediction mode includes a template-based prediction mode; and determine a predicted value corresponding to the current block based on the first template.

[0013] In the seventh aspect, an embodiment of the present application provides a decoder comprising a second memory and a second processor, The second memory is configured to store computer programs that can be executed by the second processor, The second processor is configured to perform the method described in the first embodiment when executing the computer program.

[0014] In the eighth aspect, an embodiment of the present application provides a computer-readable storage medium in which a computer program is stored, and when the computer program is executed, it implements the method according to the first aspect or the method according to the second aspect.

[0015] Embodiments of the present application provide an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium. When the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. The preset prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in embodiments of the present application, when performing prediction processing on the current block using a preset prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in the process of performing prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding / decoding performance. [Brief explanation of the drawing]

[0016] [Figure 1] This is a schematic diagram illustrating the basic process of a video codec. [Figure 2] This is a schematic diagram showing the positional relationship between the current block and the reference sample. [Figure 3] This is a schematic diagram illustrating the use of four reference rows / columns in an intra-prediction method. [Figure 4]It is a schematic diagram showing nine intra prediction modes for 4×4 blocks in H.264. [Figure 5] It is a schematic diagram showing 35 intra prediction modes used in HEVC. [Figure 6] It is a schematic diagram showing 67 intra modes used in VVC. [Figure 7] It is a schematic diagram showing the wide-angle mode. [Figure 8] It is a schematic diagram showing 66 prediction modes used in AVS3. [Figure 9] It is a schematic diagram showing screen content. [Figure 10] It is a schematic diagram showing inter prediction. [Figure 11] It is a schematic diagram showing intraTMP. [Figure 12] It is a schematic diagram showing MIP. [Figure 13] It is a schematic diagram showing TIMD. [Figure 14] It is a schematic diagram showing DIMD. [Figure 15] It is a schematic diagram showing the weights of different intra prediction modes. [Figure 16] It is the first schematic diagram showing the template type. [Figure 17] It is a block diagram showing the configuration of the encoder. [Figure 18] It is a block diagram showing the configuration of the decoder. [Figure 19] It is a schematic diagram showing the network architecture configuration of the codec system. [Figure 20] It is a schematic flowchart of the decoding method proposed in the embodiments of the present application. [Figure 21] It is the second schematic diagram showing the template type. [Figure 22] It is a schematic diagram showing the candidate template. [Figure 23] It is a schematic flowchart of the encoding method proposed in the embodiments of the present application. [Figure 24]This is a schematic diagram showing the configuration of an encoder. [Figure 25] This is a schematic diagram showing the hardware configuration of the encoder. [Figure 26] This is a schematic diagram showing the configuration of the decoder. [Figure 27] This is a schematic diagram showing the hardware configuration of the decoder.

[0017] [Figure 28] This is a schematic diagram showing the configuration of the codec system. [Modes for carrying out the invention]

[0018] To gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments will be described in detail below with reference to the drawings. The drawings are for reference only and are not intended to limit the embodiments of this application.

[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art. Terms used herein are solely for illustrative purposes of the embodiments of this application and are not intended to limit the application.

[0020] In the following description, the phrases "in some embodiments," "in some other embodiments," or "in one example" describe a subset of all possible embodiments. However, to the extent that it is clear, "some embodiments" may be the same subset or different subsets of all possible embodiments and can be combined with each other without contradiction. Furthermore, terms such as "first / second / third" in the embodiments of this application do not indicate a specific order, but rather distinguish similar or different subjects. To the extent that it is clear, "first / second / third," etc., can be changed in a specific order or sequence where appropriate, so the embodiments of this application described herein may be carried out in an order other than that illustrated or described herein.

[0021] Before describing the embodiments of this application in detail, we will first explain the nouns and terms used in the embodiments of this application. The explanations of the nouns and terms used in the embodiments of this application will apply to the following interpretations.

[0022] Coding Block (CB) Block matching (BM) Coding Unit (CU) Block vector (BV), Sum of Absolute Difference (SAD), Sum of Absolute Transformed Difference (SATD) Mean Squared Error (MSE), Sum of Squared Differences (SSD) Mean Absolute Deviation (MAD) Mean Square Differences (MSD), Normalized Correlation Coefficient (NCC) H.266 / Versatile Video Coding (VVC) VVC Test Model (VTM) Intra Template Matching Prediction (Intra TMP) Beyond VVC Reference Software Testing Platform (ECM: Enhanced Compression Model), Matrix-based intra-prediction (MIP) Template-based intra-mode derivation (TIMD), Decoder-side intra-mode derivation (DIMD).

[0023] To make it easier to understand, video images typically use a first, second, and third color component to represent an encoded block. Here, these three color components are the luminance component, the blue chromaticity component, and the red chromaticity component, respectively. Specifically, the luminance component is usually represented by the code Y, the blue chromaticity component by the code Cb or U, and the red chromaticity component by the code Cr or V. Thus, video images can be represented in YCbCr format or YUV format.

[0024] Most video encoding and decoding standards use a block-based hybrid encoding framework. Each image, subimage, or frame in video is divided into a square Largest Coding Unit (LCU) or Coding Tree Unit (CTU) of the same size (e.g., 128x128 or 64x64). Each Largest Coding Unit or Coding Tree Unit can be divided into rectangular Coding Units (CU) according to rules. Coding units can be divided into Prediction Units (PU) and / or Transform Units (TU), etc. The hybrid encoding framework includes modules such as prediction, transform, quantization, entropy coding, and in-loop filtering. The prediction module includes intra-prediction and inter-prediction. Inter-prediction includes motion estimation and motion compensation. Because there is a strong correlation between adjacent samples within a single frame of video, video encoding and decoding techniques use intra-prediction methods to remove spatial redundancy between adjacent samples. Similarly, because there is a strong similarity between adjacent frames in video, video encoding and decoding techniques use inter-prediction methods to remove temporal redundancy between adjacent frames, thereby improving the efficiency of encoding and decoding.

[0025] The basic process of the video codec is shown in Figure 1. On the encoding side, one frame of image 101 is divided into blocks, intra-prediction or inter-prediction is used on the current block to generate a predicted block of the current block, the predicted block is subtracted from the original block of the current block to obtain a residual block, transformation and quantization are performed on the residual block to obtain a quantization coefficient matrix, entropy coding is performed on the quantization coefficient matrix and output to a bitstream. On the decoding side (not shown), intra-prediction or inter-prediction is used on the current block to generate a predicted block of the current block, the bitstream is analyzed to obtain a quantization coefficient matrix, inverse quantization and inverse transformation are performed on the quantization coefficient matrix to obtain a residual block, and the predicted block and residual block are added to obtain a reconstructed block. The reconstructed block constitutes a reconstructed image, and intra-loop filtering is performed on the reconstructed image on an image basis or block basis to obtain a decoded image. On the encoding side, it is also necessary to perform the same operations as on the decoding side to obtain a decoded image. On the encoding side, the obtained decoded image is used as a reference frame for inter-prediction of subsequent frames. Block partitioning information, mode information such as prediction, transformation, quantization, entropy coding, and intra-loop filtering, or parameter information determined by the encoding side, must be included in the bitstream as needed. The decoding side analyzes the bitstream, based on existing information, to determine the same block partitioning information, mode information such as prediction, transformation, quantization, entropy coding, and intra-loop filtering, or parameter information as the encoding side, thereby ensuring that the decoded image obtained by the encoding side and the decoded image obtained by the decoding side are the same. The decoded image obtained by the encoding side is usually also called the reconstructed image. During prediction, the current block can be divided into prediction units, and during transformation, the current block can be divided into transformation units, and the division of the prediction units and transformation units may be different.

[0026] The above describes the basic processes of a video codec in a block-based hybrid encoding framework, and as technology advances, some modules or steps of the framework or process may be optimized. The encoding and decoding methods provided in the embodiments of this application are applicable to, but not limited to, the basic processes of a video codec in such a block-based hybrid encoding framework. As encoders and decoders evolve and new service scenarios emerge, it will be well known to those skilled in the art that the methods provided in the embodiments of this application are equally applicable to similar technical problems.

[0027] The current block may be the current coding unit (CU) or the current prediction unit (PU), etc.

[0028] To understand this, there is a strong spatial correlation between adjacent parts and adjacent samples within an image, and intra-prediction is a method of prediction that utilizes the spatial correlation between encoded or decoded samples around the current block and samples inside the current block. As shown in Figure 2, the white 4x4 block is the current block, and the gray samples in the leftmost column and topmost row of the current block are the reference samples of the current block. In intra-prediction, these reference samples are used to predict the current block. All of these reference samples may be available, i.e., all encoded or decoded, or some may be unavailable. For example, if the current block is at the far left of the entire frame, the reference samples to the left of the current block are unavailable. Or, if a portion of the lower left of the current block has not yet been encoded or decoded when encoding / decoding the current block, the reference samples in the lower left are also unavailable. If reference samples are unavailable, padding may or may not be performed using available reference samples or specific values ​​or methods.

[0029] Multiple Reference Line (MRL) intraprediction methods can improve coding efficiency by using more reference samples. Figure 3 shows an example using four reference rows / columns.

[0030] Intra prediction has multiple prediction modes, and as shown in Figure 4, there are nine modes for intra prediction of a 4x4 block in H.264. Here, in mode 0, the upper sample of the current block is copied vertically to the current block as the predicted value; in mode 1, the left reference sample is copied horizontally to the current block as the predicted value; in mode 2 (i.e., DC mode), the average of eight points A-D and I-L is used as the predicted value for all points; and in modes 3-8, the reference sample is copied at a specific angle to the corresponding position in the current block (hence modes 3-8 are also called angle prediction modes). Because some positions in the current block do not perfectly correspond to the reference samples, it may be necessary to use a weighted mean of the reference samples or an interpolated subsample (subpixel) of the reference samples.

[0031] In addition to these, there are modes such as Plane and Planar, and with technological advancements and block expansion, the number of angle prediction modes is also increasing. As shown in Figure 5, the intra-prediction modes used in HEVC include Planar, DC, and 33 angle modes, for a total of 35 prediction modes. As shown in Figure 6, the intra-modes used in VVC include Planar, DC, and 65 angle modes, for a total of 67 prediction modes. Of course, in addition to the 67 modes mentioned above, VVC also provides wide-angle modes for some rectangular blocks with large differences between length and width. For example, the modes shown by the dashed lines in Figure 7 are the two intervals, -14 to -1 and 67 to 80, and these modes replace some of the normal modes. As shown in Figure 8, AVS3 uses a total of 66 prediction modes, including DC, Plane, Bilinear, PCM, and 62 angle modes.

[0032] A video is composed of multiple images. To make a video appear smooth, each second of video contains tens to hundreds of frames. For example, 24 frames per second, 30 frames per second, 50 frames per second, 60 frames per second, 120 frames per second, etc. Therefore, there is very obvious temporal redundancy in video. In other words, there is a lot of temporal correlation in video. Interpretation uses this temporal correlation to improve compression efficiency. Interpretation often uses "motion" to utilize temporal correlation. A very simple "motion" model is that an object is at a certain position on the image corresponding to a certain time, and after a certain amount of time has passed, it has been translated to a different position on the image corresponding to that time. This is the most basic and commonly used translation motion in video encoding and decoding. Interpretation uses motion information to represent "motion". Basic motion information includes information from a reference frame (also called a reference picture) and information from a motion vector (MV). The codec determines the reference image based on the information in the reference image, and determines the coordinates of the reference block based on the motion vector information and the coordinates of the current block. The reference image uses the coordinates of the reference block to determine the reference block. Using the determined reference block as the prediction block is the most basic prediction method in interpretation.

[0033] Motion in video is not always such a simple movement; even motion considered as translation undergoes subtle changes over time, including slight deformations, brightness changes, and noise changes. To achieve better prediction effectiveness for the current block, multiple reference blocks can be used for prediction. For example, in commonly used bidirectional prediction, two reference blocks are used to predict the current block. One forward reference block and one backward reference block can be used as the two reference blocks. It is also acceptable for both reference blocks to be either forward or backward. So-called forward means that the time corresponding to the reference image is before the current frame, and backward means that the time corresponding to the reference image is after the current frame. Alternatively, forward means that the position of the reference image in the video is before the current frame, and backward means that the position of the reference image in the video is after the current frame. Alternatively, forward means that the POC (picture order count) of the reference image is smaller than the POC of the current frame, and backward means that the POC of the reference image is larger than the POC of the current frame. Future video encoding and decoding standards may support prediction with multiple reference blocks. A simple way to generate a prediction block using two reference blocks is to obtain the prediction block by averaging the pixel values ​​at corresponding positions in the two reference blocks. To obtain better prediction results, weighted averaging can also be used, such as BCW (Bi-prediction with CU-level weight) used in VVC. GPM (Geometric partitioning mode) in VVC can also be understood as a special type of bidirectional prediction. To use bidirectional prediction, of course, it is necessary to find two reference blocks, which requires information from two sets of reference images and motion vector information.

[0034] Motion in video includes not only simple translation but also zooming, rotation, distortion, and various complex movements. VVC uses affine to simulate some of these simple movements. The affine model in VVC uses two or three control points and, based on these control points, utilizes a linear model to derive the motion vector of each subblock within the current block. The reason only motion vectors and not motion information are given here is that they point to the same reference image. While normal translation finds one "entire block" by the reference image, affine can be understood as finding a pair of non-adjacent "subblocks" by the reference image. All of the above fall under the category of unidirectional prediction, but affine can also achieve bidirectional prediction or prediction of more "reference blocks". The reference block referred to herein consists of subblocks. In a concrete implementation, the unidirectional motion information in the data structure of affine motion information may include information for one reference image and information for two or three motion vectors. Alternatively, it may include information from 2-3 sets of reference images and motion vector information, but the information from these reference images is the same.

[0035] Intra-block copy (IBC) can significantly improve the compression efficiency of screen content coding, and therefore, IBC is used for screen content coding from HEVC to VVC. Unlike camera-captured content, screen content is computer-generated, free of noise, contains text and computer graphics, and has clear boundaries. Screen content contains a lot of overlapping content. For example, as shown in Figure 9, the content in the two boxes in the first row is overlapping, and the content in the box in the third row is overlapping with the content in the box in the fourth row.

[0036] As described above, in inter-prediction, a reference block on the reference image is used as the predicted block for the current block, and the reference image is not the current image. On the other hand, IBC finds a block from the encoded and decoded portion (called the reconstructed portion) of the current image to be used as the predicted block for the current block. IBC is also called intra-picture block compensation or current picture referencing (CPR) in some regions. In this embodiment, the name of IBC is not limited, and unless otherwise specified, all of the above names are equivalent or interchangeable.

[0037] IBC represents the positional difference between the current block and a reference block using a block vector (BV). The encoder uses a block matching method within the search range to determine the best matching block for the current block and encodes the BV. There are various methods for encoding the BV, which will not be detailed here. IBC can be considered as a type of intra-prediction method, or as a separate prediction method independent of intra-prediction and inter-prediction.

[0038] Template Matching (TM) is initially used for interblock prediction. This method utilizes the correlation between adjacent samples and uses a portion of the area surrounding the current block as a template. When encoding and decoding the current block, its left and above sides are already encoded according to the encoding order. Of course, in hardware decoder implementations, the left and above sides of the current block are not necessarily already encoded and decoded when decoding of the current block begins. Of course, what is being referred to here are interframe blocks. For example, in HEVC, when an inter-encoded block generates a prediction block, it does not require surrounding reconstruction samples, so the interblock prediction process can be performed in parallel. However, intra-encoded blocks require the reconstruction samples on the left and above as reference samples. Theoretically, the left and above sides of the current block are available, meaning that corresponding adjustments can be made in the hardware design. In contrast, the right and below sides of the current block are not available according to the encoding order of video standards (such as VVC).

[0039] As shown in Figure 10, the rectangular areas to the left and above the current block 1001 are set as templates. The height of the left template portion is generally the same as the height of the current block 1001, and the width of the upper template portion is generally the same as the width of the current block 1001, although they may be different. In the reference frame 1003 of the current frame 1002, the motion information or motion vector of the current block 1001 is determined by finding the optimal matching position of the template. Roughly speaking, this process starts a search within a certain range around a certain starting position in a given reference frame. Search rules such as the search range and search step length can be set in advance. Each time the block moves to a position, the degree of matching between the template corresponding to that position and the template around the current block is calculated. The so-called degree of matching can be evaluated using several distortion costs such as SAD (sum of absolute difference), SATD (sum of absolute transformed difference), or MSE (mean-square error), and a smaller value of SAD, SATD, or MSE indicates a higher degree of matching. Here, the transformation used for SATD may be the Hadamard transformation. The cost is calculated using the template prediction block corresponding to that position and the template reconstruction block around the current block. In addition to pixel-level position searching, sub-pixel position searching can be performed, and the motion information of the current block is determined based on the position with the highest degree of matching obtained through searching. By utilizing the correlation between adjacent samples, motion information that fits the template may also fit the current block. Of course, the template matching method is not necessarily applicable to all blocks, so several methods can be used to determine whether or not to use the above template matching method for the current block. For example, a control switch can be used for the current block to indicate whether or not to use the template matching method.One example of template matching technology is DMVD (decoder side motion vector derivation). Both the encoder and decoder use templates to perform searches, allowing them to derive motion information or discover better motion information based on existing motion information. This method eliminates the need to transmit specific motion vectors or differences between motion vectors, and ensures matching between encoding and decoding by having both the encoder and decoder perform searches using the same rules. While template matching methods can improve compression performance, they introduce a certain degree of decoder complexity because the decoder also needs to perform a "search."

[0040] Intra-template matching prediction (intraTMP) is also a type of prediction technique. As mentioned above, TM can reduce the encoding overhead of MV, that is, TM can reduce the encoding overhead of BV. As an example, there is no need to encode BV, and the matching block found by TM is directly used as the prediction block in intraTMP mode for the current block.

[0041] As an example of intraTMP, as shown in Figure 11, the inverted L-shaped region 111 in the upper left corner of the current block 110 is used as a template, and a search is performed within the search range 112, which is the reconstructed region. The region 112 shown includes the current CTU R1, the upper left CTU R2, the upper CTU R3, and the left CTU R4. This is just an example, and the search range will differ in actual applications. In the example shown in Figure 11, the optimal matching block 113 was found within R2.

[0042] As explained above, one of the key reasons why IBC significantly improves the compression efficiency of screen content encoding is that it can find many overlapping blocks within screen content, and that screen content typically has sharp boundaries, and in terms of color (luminance and chromaticity), large areas may be the same color (luminance and chromaticity). Content captured by a camera also has approximately overlapping blocks, and even considering the effects of noise, subtle changes in luminance, and perspective angle, it cannot be denied that overlapping textures exist in content captured by a camera.

[0043] Generally, intraTMP uses the best-matching block found through template matching as the final predicted block. In other words, in related technologies, when decoding the current block, there is a flag that determines whether the current block uses intraTMP or not. If intraTMP is used for the current block, the decoder uses the template matching method to find one best-matching block and uses the value of the best-matching block as the predicted value for the current block. As you can see, although templates have a strong correlation with the current block, templates are not inherently the current block, so the best-matching block found in the template (actually, the position of the current block corresponding to the best-matching block in the template) is not necessarily the best-matching block for the current block. However, since the decoder does not have the current block during the search, it has no choice but to use the best-matching block found in the template as the best-matching block found by intraTMP.

[0044] To further improve prediction accuracy, we can choose to employ the intra TMP multiple candidate method. Specifically, intra TMP can also build a candidate list using template matching, providing the encoder with more options compared to directly determining the best matching block found by template matching. In particular, finding a perfect matching block within content collected by a camera is difficult. Template matching selects a small number of candidates with a high degree of matching from a large number of possible BVs, and then the encoder decides which candidate to select. This method helps improve compression efficiency.

[0045] Matrix-weighted intra-prediction (MIP), also known as Matrix-weighted Intra Prediction, is a special intra-prediction mode. Figure 12 is a schematic diagram of MIP. As shown in Figure 12, to predict a block of width W and height H, MIP requires H reconstructed samples from the left column of the current block and W reconstructed samples from the upper row of the current block as input. MIP generates the predicted block in three steps: averaging of reference samples, matrix vector multiplication, and interpolation. Here, the core of MIP can be considered to be matrix multiplication. In other words, MIP can be thought of as a process that uses a matrix multiplication method to generate a predicted block using input samples (reference samples).

[0046] MIP provides multiple matrices, and differences in prediction methods are reflected in the differences in these matrices. Using different matrices will yield different results even with the same input samples. On the other hand, the processes of averaging and interpolating reference samples are designed to consider the trade-off between performance and complexity. For large blocks, averaging reference samples achieves an effect similar to downsampling, allowing the input to be adapted to a relatively small matrix. Interpolation, on the other hand, achieves the effect of upsampling. This eliminates the need to provide an MIP matrix for each block size, requiring only one or more matrices of specific sizes.

[0047] With increasing demands for compression performance and improvements in hardware capabilities, next-generation standards may feature more complex MIPs (Multi-Input Processors).

[0048] MIP is similar to planar, but is clearly more complex and flexible than planar.

[0049] Template-based intra-mode derivation (TIMD) uses templates to analyze and select intra-predictive modes. This "explores" intra-predictive modes in a different dimension, rather than using MV or BV in the "exploration" space used in inter- and IBC. Therefore, it does not require reconstruction samples other than templates around the current block and template reference samples.

[0050] Figure 13 is a schematic diagram illustrating TIMD, which uses the areas to the left and above the current block as a template, as shown in Figure 13. Excluding boundary conditions, the left and above areas of the current block can theoretically obtain reconstructed values ​​when encoding and decoding the current block. This is also the basis for many template matching methods. TIMD uses the illustrated template area as a template, and "Reference of the template" in the figure is a reference sample of the template. The decoder makes predictions on the template using a specific intra-prediction mode, compares the predicted value with the reconstructed value to obtain the cost of the intra-prediction mode in the template. Examples include SAD, SATD, and SSE. Because the template and the current block are adjacent, they are correlated, and therefore, the representation of one prediction mode in the template can be used to estimate the representation of that prediction mode in the current block. TIMD predicts several candidate intra-prediction modes on the template to obtain their costs, and the one or two intra-prediction modes with the lowest costs are used as the intra-predicted value for the current block.

[0051] Furthermore, if the cost difference between the two intra-prediction mode templates is not significant, the compression performance can be improved by weighting and averaging the predicted values ​​from the two intra-prediction modes. The weights of the predicted values ​​from the two prediction modes are related to the cost mentioned above; for example, the weights can be set to be inversely proportional to the cost.

[0052] In other words, TIMD can leverage the predictive effect in the template of intra-predictive modes to select intra-predictive modes and weight two intra-predictive modes according to their cost in the template. On the other hand, the two intra-predictive modes may be expanded to multiple modes in future technological advancements. The advantage of TIMD is that, currently, if a block selects an IMD mode, it does not need to specify which intra-predictive mode was used, as the decoder derives it itself through the process described above, thus saving some overhead.

[0053] Intra-mode derivation (DIMD) also derives a prediction mode using the block reconstruction samples to the left and above the current block, but instead of making predictions on the template, it analyzes the gradients of the reconstruction samples.

[0054] Figure 14 is a schematic diagram of DIMD, and as shown in Figure 14, DIMD analyzes the gradient of the dark points, adapts the intra-prediction mode based on that gradient, and analyzes all points that need to be checked, thereby obtaining a result similar to the histogram below. Of course, the so-called histogram is for illustrative purposes only, and in concrete implementations, it can be implemented in various simpler forms. The current DIMD selects the two highest intra-prediction modes in the histogram and adds the planar mode to them, weighting the predicted values ​​of a total of three intra-prediction modes. The weights are related to the results of the analysis.

[0055] As an example, Figure 15 is a schematic diagram showing the weights of different intra-prediction modes. As shown in Figure 15, DIMD selects the two intra-prediction modes with the highest values ​​in the histogram, for example, M1 and M2, and adds the planar mode to them. The weights ω1, ω2, and ω3 corresponding to these three intra-prediction modes can be referenced from the analysis results of the dark spots, and finally, weighted predictions can be made on the predicted values ​​of these three intra-prediction modes to obtain the predicted values.

[0056] In short, DIMD uses gradient analysis of reconstructed samples to select an intra-prediction mode, and further, it can add a planar to the two intra-prediction modes and weight them based on the analysis results. The advantage of DIMD is that if the block currently selects a DIMD mode, it does not need to specify which intra-prediction mode to use, as the decoder derives it itself through the process described above, thus saving some overhead. On the other hand, the two intra-prediction modes may be expanded to multiple modes in future technological advancements.

[0057] TIMD and DIMD share many similarities, and in past literature, their names are sometimes even used in reverse. Both support weighting of predictions for two or more intra-prediction modes. On the other hand, while DIMD does not perform predictions on the template, it does use the template domain, and for convenience, as will be discussed later, DIMD can also be classified as a template-based prediction technique.

[0058] In the execution of intra TMP, Figure 16 is a first schematic diagram showing the template type. As shown in Figure 16, the template currently used by intra TMP in ECM is an inverted L-shaped template that includes left-side adjacent reconstructed samples, upper-side adjacent reconstructed samples, and upper-left adjacent reconstructed samples. Some templates using other template matching techniques do not use upper-left adjacent samples.

[0059] In addition to complete templates, partial templates can also be used, as shown in Figure 16 with its upper and left-side templates. For convenience of explanation, complete templates (inverted L-type or T+L-type) are collectively referred to as TL templates, the upper template as the T template, and the left-side template as the L template. Multiple different templates can provide more options. Template matching involves using a template to estimate the current block, assuming that blocks with a high degree of template matching also have a high degree of matching in the current block. However, video content, especially images captured by cameras, is diverse. If we assume that the texture changes left-right near the left edge of the current block, using only the T template may be more appropriate than using the TL template. Similarly, if the texture changes up-down near the top edge of the current block, using only the L template may be more appropriate than using the TL template. Thus, techniques that utilize template analysis can also provide more options by using multiple different templates.

[0060] Of course, you can add reconstruction samples to the upper right, lower left, etc., to the template. For example, the T template is extended a certain distance to the right in addition to the illustrated portion, and the L template is extended a certain distance downwards in addition to the illustrated portion. Alternatively, you can add upper right templates, lower left templates, etc., in addition to the T and L templates.

[0061] Furthermore, technologies that require the use of templates, such as template matching techniques and techniques that utilize template analysis, can be collectively referred to as template-based prediction techniques. Template-based prediction techniques include, but are not limited to, inter-template matching (inter-template matching prediction), IBC template matching, intra TMP, TIMD, DIMD, etc.

[0062] For example, intra TMP can determine BV by performing template matching using TL templates, T templates, and L templates. Inter-template matching technology can determine MV by performing template matching using TL templates, T templates, and L templates. TIMD can derive intra prediction modes using TL templates, T templates, and L templates, and DIMD can derive intra prediction modes using TL templates, T templates, and L templates.

[0063] As is understandable, in general template-based prediction techniques, some templates are not applicable to all scenarios. For example, while T-templates and L-templates offer more options, they are not applicable to all situations. Considering cases where the difference between width and height is large, or where there are too few template pixels on one side, limiting the use of T-templates and / or L-templates can reduce unnecessary overhead and minimize interference from irrational results.

[0064] Embodiments of the present application provide an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium. When the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. The preset prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in embodiments of the present application, when performing prediction processing on the current block using a preset prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in the process of performing prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding / decoding performance.

[0065] Each embodiment of this application will be described in detail below with reference to the drawings.

[0066] Referring to Figure 17, Figure 17 is a block diagram showing the configuration of an encoder provided in an embodiment of the present invention. As shown in Figure 17, the encoder (specifically, the "video encoder") 100 may include a transform and quantization unit 101, an intra-estimation unit 102, an intra-prediction unit 103, a motion compensation unit 104, a motion estimation unit 105, an inverse transform and inverse quantization unit 106, a filter control analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoding image buffer unit 110, where the filtering unit 108 can implement deblocking filtering and sample adaptive offset (SAO) filtering, and the encoding unit 109 can implement header information encoding and context-based adaptive binary arithmetic coding (CABAC). For the input original video signal, a video coding block is obtained by dividing the coding tree block (CTU). Next, the video coding block is transformed by the transformation and quantization unit 101 using residual pixel information obtained through intra-prediction or inter-prediction. This transformation includes transforming the residual information from the pixel region to the transformation region and quantizing the resulting transformation coefficients in order to further reduce the bitrate. The intra-estimation unit 102 and the intra-prediction unit 103 are configured to perform intra-prediction on the video coding block, and explicitly, the intra-estimation unit 102 and the intra-prediction unit 103 are configured to determine the intra-prediction mode used to encode the video coding block.The motion compensation unit 104 and the motion estimation unit 105 are configured to perform interpredictive coding of received video coding blocks for one or more blocks in one or more reference frames to provide time prediction information, the motion estimation performed by the motion estimation unit 105 is a process that generates motion vectors which can estimate the motion of the video coding blocks, the motion compensation unit 104 then performs motion compensation based on the motion vectors determined by the motion estimation unit 105 and determines an intraprediction mode, the intraprediction unit 103 is further configured to provide selected intraprediction data to the coding unit 109, and the motion estimation unit 105 also transmits the computationally determined motion vector data to the coding unit 109. Furthermore, the inverse transform and inverse quantization unit 106 is for reconstructing the video coding block and is configured to reconstruct the residual block in the pixel region. This reconstructed residual block is then subjected to blocking effect artifacts by the filter control analysis unit 107 and the filtering unit 108. This reconstructed residual block is then added to one prediction block in the frame of the decoding image buffer unit 110 to generate a reconstructed video coding block. The coding unit 109 is configured to encode various coding parameters and quantized transformation coefficients. In the CABAC-based coding algorithm, contextual content can be based on adjacent coding blocks and may be used to encode information indicating a determined intra-prediction mode and output a bitstream of this video signal. The decoding image buffer unit 110 is configured to store the reconstructed video coding block for prediction reference. As video image coding progresses, new reconstructed video coding blocks are continuously generated and these reconstructed video coding blocks are stored in the decoding image buffer unit 110.

[0067] Referring to Figure 18, Figure 18 is a block diagram showing the configuration of the decoder provided in an embodiment of the present invention. As shown in Figure 18, the decoder (specifically, the "video decoder") 200 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra prediction unit 203, a motion compensation unit 204, a filtering unit 205, and a decoded image buffer unit 206, where the decoding unit 201 can perform header information decoding and CABAC decoding, and the filtering unit 205 can perform deblocking filtering and SAO filtering. The input video signal undergoes the encoding process shown in Figure 15 and then outputs a bitstream of the video signal. This bitstream is input to the decoder 200, which first passes through the decoding unit 201 to obtain decoded conversion coefficients. These conversion coefficients are processed by the inverse transform and inverse quantization unit 202 to generate residual blocks in the pixel region. The intra-prediction unit 203 may be configured to generate prediction data for the current video decoding block based on a determined intra-prediction mode and data from previously decoded blocks from the current frame or picture. The motion compensation unit 204 determines prediction information for the video decoding block by analyzing motion vectors and other relevant syntactic elements, and uses this prediction information to generate prediction blocks for the video decoding block being decoded. The residual blocks from the inverse transform and inverse quantization unit 202 and the corresponding prediction blocks generated by the intra-prediction unit 203 or the motion compensation unit 204 are summed to form a decoded video block. This decoded video signal then passes through the filtering unit 205 to remove blocking effect artifacts, thereby improving video quality. Next, the decoded video blocks are stored in the decoded image buffer unit 206, which is configured to store a reference image for subsequent intra-prediction or motion compensation and to output a video signal, i.e., the restored original video signal is obtained.

[0068] Furthermore, embodiments of the present application further provide a network architecture for a codec system including an encoder and a decoder, where Figure 19 is a schematic diagram showing the network architecture configuration of the codec system provided in embodiments of the present application. As shown in Figure 19, the network architecture includes one or more electronic devices 13 to 1N and a communication network 01, where the electronic devices 13 to 1N can perform video interaction via the communication network 01. The electronic devices may, in the course of implementation, be devices having video encoding and decoding functions. For example, the electronic devices may include smartphones, tablet computers, personal computers, personal digital assistants, navigators, digital telephones, video phones, televisions, sensor devices, servers, etc., and embodiments of the present application are not specifically limited thereto. Here, the decoder or encoder described in embodiments of the present application may be the above-mentioned electronic devices.

[0069] The method of the embodiment of this application is mainly applied to the intra-prediction unit 103 shown in Figure 17 and the intra-prediction unit 203 shown in Figure 18. In other words, the embodiment of this application may be applied to an encoder, or to a decoder, or even to both an encoder and a decoder simultaneously, but the embodiment of this application is not specifically limited.

[0070] Furthermore, it should be explained that when applied to the intra-prediction unit 103, "current block" specifically refers to the coded block currently awaiting intra-prediction, and when applied to the intra-prediction unit 203, "current block" specifically refers to the decoded block currently awaiting intra-prediction.

[0071] One embodiment of the present invention proposes a decoding method applicable to a decoder, and Figure 20 is a schematic flowchart of the decoding method proposed in the embodiment of the present invention, and as shown in Figure 20, the decoding process by the decoder may include the following steps.

[0072] In step 101, if the prediction mode corresponding to the current block is a pre-configured prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, and the pre-configured prediction mode includes a template-based prediction mode.

[0073] In the embodiments of the present invention, first, a first template corresponding to the current block can be determined. Here, if the prediction mode corresponding to the current block is a pre-set prediction mode, the first template corresponding to the current block can be determined from at least one candidate template based on the size information of the current block.

[0074] The decoding method according to the embodiment of this application is applied to a decoder. Furthermore, the decoding method may include an intra-prediction method, and more specifically, a color component prediction method. Here, the video image is divided into a plurality of decoding blocks, each decoding block may include a first color component, a second color component, and a third color component, and the current block in the embodiment of this application refers to the decoding block in the video image that is currently awaiting intra-prediction.

[0075] Here, if it is necessary to predict the first color component, the component to be predicted is the first color component; if it is necessary to predict the second color component, the component to be predicted is the second color component; and if it is necessary to predict the third color component, the component to be predicted is the third color component. Furthermore, if we make a prediction for the first color component of the current block and assume that the first color component is the luminance component, i.e., the component to be predicted is the luminance component, then the current block can also be called a luminance block. Or, if we make a prediction for the second color component of the current block and assume that the second color component is the chromaticity component, i.e., the component to be predicted is the chromaticity component, then the current block can also be called a chromaticity block.

[0076] In the embodiments of this application, the first template corresponding to the current block may be a candidate template within the template set corresponding to the current block. Here, the candidate template corresponding to the current block includes candidate templates of multiple different template types.

[0077] To make it easier to understand, in the embodiments of the present invention, first a set of templates corresponding to the current block can be constructed based on different template types, and then a first template corresponding to the current block can be determined from the candidate templates in the set of templates.

[0078] Exemplary, in the embodiments of the present application, Figure 21 is a second schematic diagram showing a template type, and as shown in Figure 21, when the upper left reference sample, upper reference sample, and left reference sample are all available, the template shape is as shown in (a); when only the left reference sample is available, the template shape is as shown in (b); when only the upper reference sample is available, the template shape is as shown in (c); when only the left reference sample and upper left reference sample are available, the template shape is as shown in (d); when only the left reference sample and lower left reference sample are available, the template shape is as shown in (e); and when only the upper reference sample and upper right reference sample are available, the template shape is as shown in (f).

[0079] Furthermore, in the embodiments of the present invention, when constructing a template set corresponding to the current block based on the template type, first, a template reference sample for the current block can be determined based on the template type and the template size corresponding to the template type, then, candidate templates for the current block can be determined based on the template reference sample, and finally, the construction of the template set can be completed.

[0080] In the embodiments of this invention, the first candidate template in the template set may be a template that includes the left-side adjacent reconstruction sample and the upper-side adjacent reconstruction sample of the current block, for example, a TL template; the second candidate template in the template set may be a template that includes the upper-side adjacent reconstruction sample of the current block, for example, a T template; and the third candidate template in the template set may be a template that includes the left-side adjacent reconstruction sample of the current block, for example, an L template.

[0081] In other words, in the embodiments of the present application, the current block may include at least one candidate template, a TL template, a T template, and an L template.

[0082] Exemplary, in the embodiments of the present application, Figure 22 is a schematic diagram showing candidate templates, which correspond to four different template types as shown in Figure 22, and the candidate templates of the current block that are ultimately generated may also include four types, such as candidate template 1 (TL template), candidate template 2 (TL template), candidate template 3 (T template), and candidate template 4 (L template).

[0083] For example, in some embodiments, the first template corresponding to the current block may be the first candidate template in the set of templates corresponding to the current block, for example, candidate template 1.

[0084] For example, in some embodiments, the first template corresponding to the current block may be a second candidate template in the set of templates corresponding to the current block, for example, candidate template 3.

[0085] For example, in some embodiments, the first template corresponding to the current block may be a third candidate template in the set of templates corresponding to the current block, for example, candidate template 4.

[0086] Furthermore, in the embodiments of the present invention, the pre-configured prediction mode may include a template-based prediction mode. In other words, in the present invention, prediction methods involving the use of templates in the prediction processing process can be uniformly determined as pre-configured prediction modes.

[0087] For example, in some embodiments, a pre-configured prediction mode may include one of the following template-based prediction modes: intra-template matching prediction, intra-block copy, inter-template matching prediction, template-based intra-mode derivation, and intra-mode derivation.

[0088] To make it clear, in the embodiments of the present invention, the intra-template matching prediction intraTMP can use the optimal matching block found by template matching as the final determined prediction block. That is, since intraTMP can be a template-based prediction mode, it can be a pre-configured prediction mode.

[0089] To make it clear, in the embodiments of the present invention, the template matching of the intrablock copy IBC can determine the optimal matching block for the current block using a template matching method within the search range. That is, since the template matching of the IBC can be a template-based prediction mode, it can be a preset prediction mode.

[0090] To make it clear, in the embodiments of the present invention, inter-template matching prediction can determine the optimal matching block for the current block using a template matching method within a reference frame. That is, since inter-template matching prediction can be a template-based prediction mode, it can be a pre-configured prediction mode.

[0091] To make it clear, in the embodiments of the present invention, template-based intra-mode derivation (TIMD) predicts several candidate intra-prediction modes on a template and selects the one or two intra-prediction modes with the lowest cost as the intra-prediction value for the current block. That is, since TIMD can be a template-based prediction mode, it can be a pre-configured prediction mode.

[0092] To make it clear, in the embodiments of the present invention, the intra-mode derivation (DIMD) and TIMD processing processes are similar, and although DIMD does not perform predictions on the template, it uses the template's domain, so DIMD can be a template-based prediction mode, and furthermore, it can be a pre-configured prediction mode.

[0093] To ensure clarity, in the embodiments of this application, all other template-based prediction modes, in addition to intra-template matching prediction, intra-block copying, inter-template matching prediction, template-based intra-mode derivation, and intra-mode derivation, can be pre-configured prediction modes. This application is not specifically limited.

[0094] To make it clear, in the embodiments of the present invention, if it is determined that the prediction mode corresponding to the current block is a pre-set prediction mode, the size information of the current block can be used to select and restrict candidate templates. Specifically, based on the size information corresponding to the current block, a first template corresponding to the current block can be determined from at least one candidate template.

[0095] In the embodiments of this application, the first template is a template used when the current block performs prediction processing based on a pre-set prediction mode.

[0096] In the embodiments of this application, the size information corresponding to the current block may include information relating to the height and / or width of the current block.

[0097] For example, in some embodiments, the size information corresponding to the current block may be the height and width values ​​of the current block, where the height and width values ​​of the current block may be the absolute values ​​of the height and width of the current block.

[0098] Furthermore, in the embodiments of the present invention, the bitstream can be decoded to determine the prediction mode identifier corresponding to the current block. If the value of the prediction mode identifier is a first value, it can be determined that the prediction mode corresponding to the current block is a pre-set prediction mode, and if the value of the prediction mode identifier is a second value, it can be determined that the prediction mode corresponding to the current block is not a pre-set prediction mode.

[0099] To make it clear, in embodiments of the present application, prediction mode identification information may be used to determine whether the current block uses a template-based prediction mode. That is, it can be determined whether the prediction mode of the current block is a preset prediction mode, and further, via the prediction mode identification information, whether the current block uses the preset prediction mode to perform prediction processing.

[0100] For example, in some embodiments, the bitstream can be decoded to determine a single variable as predictive mode identification information, thereby enabling the determination of predictive mode identification information based on the value of that variable.

[0101] In this application, the value of the prediction mode identification information may be either a first value or a second value. Here, if the value of the prediction mode identification information is different, the method for determining the predicted value of the current block will also be different. Specifically, when determining the predicted value of the current block based on the value of the prediction mode identification information, it may be selected to use a pre-set prediction mode, or it may be selected not to use a pre-set prediction mode.

[0102] For example, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, the prediction mode identifier can be understood as a flag indicating whether or not to perform intra TMP. Here, if the value of the prediction mode identifier is a first value, it is possible to choose to determine the predicted value of the current block using intra TMP, and if the value of the prediction mode identifier is a second value, it is possible to choose to determine the predicted value of the current block without using intra TMP.

[0103] For illustrative purposes, in some embodiments, the first value may be set to 1 and the second value to 0, or the first value may be set to true and the second value to false. This application does not limit these options.

[0104] For example, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, the flag intra_tmp_flag can be used to represent the prediction mode identification information. That is, intra_tmp_flag is used as the flag for intra TMP.

[0105] Exemplary, in some embodiments, a value of 1 for intra_tmp_flag can represent choosing to use intra TMP to determine the predicted value of the current block, and a value of 0 for intra_tmp_flag can represent choosing not to use intra TMP to determine the predicted value of the current block.

[0106] To make it clear, in the embodiments of the present application, if the value of the prediction mode identification information is a first value, that is, after deciding to determine the predicted value of the current block using a preset prediction mode based on the value of the prediction mode identification information, it is possible to further determine a first template corresponding to the current block from at least one candidate template based on the size information corresponding to the current block.

[0107] Furthermore, in the embodiments of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, the bitstream is decoded to determine the first template indication information corresponding to the current block. If the value of the first template indication information is a third value, the first template can be determined to be the first candidate template.

[0108] In the embodiments of this application, the first candidate template may be one of the candidate templates within at least one candidate template corresponding to the current block. For example, the first candidate template may be a TL template within at least one candidate template.

[0109] To make it clearer, in embodiments of the present application, the first template instruction information may be used to determine whether the current block uses a first candidate template. That is, the first template instruction information may indicate whether the current block uses a first candidate template to perform a prediction process in a pre-configured prediction mode.

[0110] For example, in some embodiments, the bitstream can be decoded to determine a single variable as first template instruction information, thereby enabling the determination of the first template instruction information by the value of that variable.

[0111] In this application, the value of the first template instruction information may be a third or fourth value. Specifically, when performing a pre-set prediction mode based on the value of the first template instruction information, the user may choose to use the first candidate template, or they may choose not to use the first candidate template and instead use another template, for example, another template other than the first candidate template within at least one of the candidate templates.

[0112] For example, in some embodiments, the third value may be set to 0 and the fourth value to 1, or the third value may be set to false and the fourth value to true. This application is not particularly limited.

[0113] Exemplary, in some embodiments, assuming a pre-configured prediction mode is intra TMP, the flag intra_tmp_alternative_template_flag can be used to represent the first template indication information. For example, a value of intra_tmp_alternative_template_flag of 0 can indicate that the first candidate template is determined to be the first template corresponding to the current block, while a value of intra_tmp_alternative_template_flag of 1 can indicate that the first candidate template is not determined to be the first template corresponding to the current block, and that other templates continue to be selected as the first template corresponding to the current block.

[0114] In response to this, in the embodiment of the present invention, after determining the first template instruction information corresponding to the current block, if the value of the first template instruction information is the fourth value, it can be determined that the first template is not the first candidate template. At this time, if the size information of the current block satisfies the preset size conditions, it is necessary to further determine the second template instruction information corresponding to the current block, and thereby determine the first template based on the second template instruction information.

[0115] In other words, in the embodiment of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the value of the first template instruction information is the fourth value and the size information of the current block satisfies the pre-set size conditions, it is necessary to further decode the bitstream to determine a second template instruction information corresponding to the current block, and then determine the first template based on the second template instruction information.

[0116] To make it clear, in the embodiments of the present application, if it is decided not to use the first candidate template based on the first template instruction information, it is further necessary to decide whether to use any other candidate templates other than the first candidate template based on the size information corresponding to the current block. Specifically, if the size information corresponding to the current block satisfies the pre-set size conditions, it is decided that any other candidate template other than the first candidate template can be used, and the determination of the second template instruction information can then be continued to determine the first template based on the second template instruction information.

[0117] In the embodiments of this application, the pre-set size conditions may be used to restrict the use of candidate templates based on the current block size.

[0118] Furthermore, in the embodiments of the present invention, when determining the first template based on the second template instruction information, if the value of the second template instruction information is the fifth value, the first template can be determined as the second candidate template, and if the value of the second template instruction information is the sixth value, the first template can be determined as the third candidate template.

[0119] In the embodiments of this application, the second candidate template and the third candidate template may each be one candidate template within at least one candidate template corresponding to the current block. For example, the second candidate template may be a T template within at least one candidate template, and the third candidate template may be an L template within at least one candidate template.

[0120] To make it clearer, in embodiments of the present application, the second template instruction information may be used to determine whether the current block uses the second candidate template and / or the third candidate template. That is, the second template instruction information may indicate whether the current block uses the second candidate template and / or the third candidate template to perform prediction processing in a pre-configured prediction mode.

[0121] For example, in some embodiments, the bitstream can be decoded to determine a variable as second template instruction information, thereby enabling the determination of the second template instruction information by the value of the variable.

[0122] In this application, the value of the second template instruction information may be the fifth or sixth value. Specifically, when performing a pre-set prediction mode based on the value of the second template instruction information, the system may choose to use the second candidate template or the third candidate template.

[0123] For example, in some embodiments, the fifth value may be set to 0 and the sixth value to 1, or the fifth value may be set to false and the sixth value to true. This application is not particularly limited.

[0124] Exemplary, in some embodiments, assuming a pre-configured prediction mode is intra TMP, the flag intra_tmp_template_idx can be used to represent the second template indication information. For example, a value of intra_tmp_template_idx of 0 can indicate that the second candidate template is determined to be the first template corresponding to the current block, and a value of intra_tmp_template_idx of 1 can indicate that the third candidate template is determined to be the first template corresponding to the current block.

[0125] Furthermore, in the embodiments of the present application, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the value of the first template instruction information is the fourth value and the size information of the current block does not satisfy the preset size conditions, it is possible to choose to skip determining the second template instruction information and instead directly determine the longest side of the current block based on the size information of the current block, and then determine the first template from at least one candidate template based on the longest side of the current block.

[0126] To make it clear, in the embodiments of the present application, if it is decided not to use the first candidate template based on the first template instruction information, it is further necessary to decide whether to use any other candidate templates other than the first candidate template based on the size information corresponding to the current block. Specifically, if the size information corresponding to the current block does not satisfy the pre-set size conditions, then it is not necessary to determine the first template based on the second template instruction information, and the first template can be directly indicated according to the longest side of the current block.

[0127] To make it easier to understand, in the embodiment of the present application, if the width of the current block is greater than the height of the current block, the side corresponding to the width can be determined as the longest side of the current block, and if the height of the current block is greater than the width of the current block, the side corresponding to the height can be determined as the longest side of the current block.

[0128] In other words, in the embodiment of the present application, the longest side of the current block is the side corresponding to the height, which can be understood as the height of the current block being greater than the width, and the longest side of the current block is the side corresponding to the width, which can be understood as the width of the current block being greater than the height.

[0129] Correspondingly, in the embodiment of the present application, if the value of the first template instruction information is the fourth value and the size information of the current block does not satisfy the preset size conditions, and the height value of the current block is greater than the width value of the current block, that is, if the longest side of the current block is the side corresponding to the height, then the left adjacent region of the current block can be considered to contain more adjacent samples than the upper adjacent region. Therefore, an L template containing more left adjacent samples can be designated as the first template, that is, a third candidate template (L template) containing left adjacent reconstruction samples of the current block can be determined as the first template.

[0130] Correspondingly, in the embodiment of the present application, if the value of the first template instruction information is the fourth value and the size information of the current block does not satisfy the preset size conditions, and the width value of the current block is greater than the height value of the current block, that is, if the longest side of the current block is the side corresponding to the width, then the upper adjacent region of the current block can be considered to contain more adjacent samples than the left adjacent region. Therefore, a T template containing more upper adjacent samples can be designated as the first template, that is, a second candidate template (T template) containing upper adjacent reconstruction samples of the current block can be determined as the first template.

[0131] For example, in some embodiments, assuming that the current block has a height of 4 and a width of 1, the longest side of the current block can be determined to be the side corresponding to the height, and therefore the L template corresponding to the longest side can be designated as the first template.

[0132] For example, in some embodiments, assuming that the current block has a height of 1 and a width of 8, the longest side of the current block can be determined to be the side corresponding to the width, and therefore the T template corresponding to the longest side can be designated as the first template.

[0133] Furthermore, in the embodiments of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the size information of the current block satisfies a preset size condition, the bitstream can be decoded to determine the first template instruction information corresponding to the current block, and if the value of the first template instruction information is a third value, the first template can be determined to be the first candidate template.

[0134] In the embodiments of this application, the first candidate template may be one of the candidate templates within at least one candidate template corresponding to the current block. For example, the first candidate template may be a TL template within at least one candidate template.

[0135] In other words, in the embodiment of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, it is possible to first determine whether or not to use the first candidate template based on the size information corresponding to the current block. Specifically, if the size information corresponding to the current block satisfies the pre-set size conditions, it can be determined that the first candidate template can be used, and the determination of the first template instruction information can then be continued.

[0136] In the embodiments of this application, the pre-set size conditions may be used to restrict the use of candidate templates based on the current block size.

[0137] In response to this, in the embodiments of the present application, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the size information of the current block does not satisfy the pre-set size conditions, then it is not necessary to determine the first template based on the first template indication information, and instead, the first template can be directly indicated. For example, the first candidate template can be determined as the first template.

[0138] To make it clearer, in embodiments of the present application, the first template instruction information may be used to determine whether the current block uses a first candidate template. That is, the first template instruction information may indicate whether the current block uses a first candidate template to perform a prediction process in a pre-configured prediction mode.

[0139] For example, in some embodiments, the bitstream can be decoded to determine a single variable as first template instruction information, thereby enabling the determination of the first template instruction information by the value of that variable.

[0140] In this application, the value of the first template instruction information may be a third or fourth value. Specifically, when performing a pre-set prediction mode based on the value of the first template instruction information, the user may choose to use the first candidate template, or they may choose not to use the first candidate template and instead use another template, for example, another template other than the first candidate template within at least one of the candidate templates.

[0141] For example, in some embodiments, the third value may be set to 0 and the fourth value to 1, or the third value may be set to false and the fourth value to true. This application is not particularly limited.

[0142] Exemplary, in some embodiments, assuming a pre-configured prediction mode is intra TMP, the flag intra_tmp_alternative_template_flag can be used to represent the first template indication information. For example, a value of intra_tmp_alternative_template_flag of 0 can indicate that the first candidate template is determined to be the first template corresponding to the current block, while a value of intra_tmp_alternative_template_flag of 1 can indicate that the first candidate template is not determined to be the first template corresponding to the current block, and that other templates continue to be selected as the first template corresponding to the current block.

[0143] In response to this, in the embodiment of the present invention, after determining the first template instruction information corresponding to the current block, if the value of the first template instruction information is the fourth value, it can be determined that the first template is not the first candidate template. At this point, it is necessary to decode the bitstream to further determine the second template instruction information corresponding to the current block, thereby determining the first template based on the second template instruction information.

[0144] Furthermore, in the embodiments of the present invention, when determining the first template based on the second template instruction information, if the value of the second template instruction information is the fifth value, the first template can be determined as the second candidate template, and if the value of the second template instruction information is the sixth value, the first template can be determined as the third candidate template.

[0145] In the embodiments of this application, the second candidate template and the third candidate template may each be one candidate template within at least one candidate template corresponding to the current block. For example, the second candidate template may be a T template within at least one candidate template, and the third candidate template may be an L template within at least one candidate template.

[0146] To make it clearer, in embodiments of the present application, the second template instruction information may be used to determine whether the current block uses the second candidate template and / or the third candidate template. That is, the second template instruction information may indicate whether the current block uses the second candidate template and / or the third candidate template to perform prediction processing in a pre-configured prediction mode.

[0147] For example, in some embodiments, the bitstream can be decoded to determine a variable as second template instruction information, thereby enabling the determination of the second template instruction information by the value of the variable.

[0148] In this application, the value of the second template instruction information may be the fifth or sixth value. Specifically, when performing a pre-set prediction mode based on the value of the second template instruction information, the system may choose to use the second candidate template or the third candidate template.

[0149] For example, in some embodiments, the fifth value may be set to 0 and the sixth value to 1, or the fifth value may be set to false and the sixth value to true. This application is not particularly limited.

[0150] Exemplary, in some embodiments, assuming a pre-configured prediction mode is intra TMP, the flag intra_tmp_template_idx can be used to represent second template indication information. For example, a value of intra_tmp_template_idx of 0 can indicate that the second candidate template is determined as the first template corresponding to the current block, and a value of intra_tmp_template_idx of 1 can indicate that the third candidate template is determined as the first template corresponding to the current block.

[0151] In other words, in embodiments of the present invention, it is possible to choose to indicate in a bitstream which of at least one candidate template the first template corresponding to the current block is. For example, the first template may be indicated using first template indication information and / or second template indication information. On the other hand, the process of determining the first template may need to restrict the candidate templates using size information corresponding to the current block.

[0152] To make it clear, in the embodiments of this application, the use of candidate templates can be restricted based on the size of the current block, based on pre-set size conditions. Specifically, if the meaning contained in the size information corresponding to the current block is different, the corresponding pre-set size conditions may also be different.

[0153] Furthermore, in the embodiments of the present application, if the size information currently includes the height and width values ​​of the block, the corresponding preset size conditions include the width being less than a first numerical multiple of the height and the height being less than a second numerical multiple of the width.

[0154] To make it clear, in the embodiments of the present application, the first and second numerical multipliers may be used to limit the ratio of the width to the height of the block.

[0155] In the embodiments of this application, the first and second numerical multipliers may be any numerical values ​​greater than 0, and the first and second numerical multipliers may be the same or different, and this application does not specifically limit them.

[0156] For example, in the embodiments of the present application, the first numerical multiplier may be 4, and the second numerical multiplier may be 8.

[0157] For example, in the embodiments of the present application, both the first numerical multiplier and the second numerical multiplier may be 4.

[0158] For better understanding, in the embodiments of the present application, when determining whether the size information of the current block meets the preset size conditions, if the width value of the current block is smaller than the first numerical multiple of the height value, and the height value of the current block is smaller than the second numerical multiple of the width value, it can be determined that the size information of the current block meets the preset size conditions. Correspondingly, if the width value of the current block is greater than or equal to the first numerical multiple of the height value, or the height value of the current block is greater than or equal to the second numerical multiple of the width value, it can be determined that the size information of the current block does not meet the preset size conditions.

[0159] Exemplarily, in some embodiments, assuming that the preset prediction mode is intra TMP, and taking three candidate templates of TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, both the first ratio threshold and the second ratio threshold are 4, and the preset size condition is that the height-width ratio is smaller than the first ratio threshold and the width-height ratio is smaller than the second ratio threshold. That is, the preset size condition can be expressed as width < height × 4 && height < width × 4. The flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template indication information, and the flag intra_tmp_template_idx represents second template indication information. In this case, the information in the bitstream can be decoded as follows.

[0160] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width<height×4 && height<width×4) { intra_tmp_template_idx} } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, and the width value of the current block is less than 4 times the height value, and the height value is less than 4 times the width value, that is, when the conditions of height value and width value satisfy width < height × 4 and height < width × 4 simultaneously, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means the current block uses the T template, and when the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0161] Correspondingly, in the embodiments of the present application, when the height value and width value of the current block do not satisfy the conditions of width < height × 4 and height < width × 4 simultaneously, the candidate template corresponding to the long side can be selected by default. For example, when the long side is the side on the height side, the L template is selected, and when the long side is the side on the width side, the T template is selected.

[0162] Exemplarily, in some embodiments, assuming that the preset prediction mode is intra TMP, and taking three candidate templates, namely the TL template, the T template, and the L template, as an example, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, both the first ratio threshold and the second ratio threshold are 4, and the preset size condition is that the aspect ratio is smaller than the first ratio threshold and the width-to-height ratio is smaller than the second ratio threshold. That is, the preset size condition can be expressed as width < height × 4 && height < width × 4. The flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents the first template indication information, and the flag intra_tmp_template_idx represents the second template indication information. In this case, the information in the bitstream can be decoded as follows.

[0163] intra_tmp_flag if (intra_tmp_flag) { if (width < height × 4 && height < width × 4) { intra_tmp_alternative_template_flag if (intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the width value of the current block is smaller than 4 times the height value and the height value is smaller than 4 times the width value at the same time, that is, to determine whether the height value and the width value satisfy the conditions of width < height × 4 and height < width × 4. If not satisfied, skip the analysis of intra_tmp_alternative_template_flag and directly select the TL template by default. If satisfied, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means that the current block uses the T template. When the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0164] Furthermore, in the embodiments of the present application, when the size information includes the height value and the width value of the current block, correspondingly, the preset size condition includes that the height value is greater than the first size threshold and the width value is greater than the second size threshold.

[0165] As can be understood, in the embodiments of the present application, the first size threshold can be used to limit the height value (absolute value of the height) of the current block. Correspondingly, the second size threshold can be used to limit the width value (absolute value of the width) of the current block.

[0166] In the embodiments of this application, the first size threshold and the second size threshold may be any number greater than 0, and the first size threshold and the second size threshold may be the same or different, and this application does not specifically limit them.

[0167] For example, in the embodiments of the present application, the first size threshold may be 8, and the second size threshold may be 4.

[0168] For example, in the embodiments of the present application, both the first size threshold and the second size threshold may be 8.

[0169] To make it easier to understand, in the embodiments of the present invention, when determining whether the current block size information satisfies the preset size conditions, if the current block height is greater than the first size threshold and the current block width is greater than the second size threshold, it can be determined that the current block size information satisfies the preset size conditions. Correspondingly, if the current block height is less than or equal to the first size threshold, or if the current block width is less than or equal to the second size threshold, it can be determined that the current block size information does not satisfy the preset size conditions.

[0170] For illustrative purposes, in some embodiments, we assume that the pre-configured prediction mode is intra TMP, and take three candidate templates, TL template, T template, and L template, as examples. The first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second size thresholds are 4, and the pre-configured size condition is that the height is greater than the first size threshold and the width is greater than the second size threshold. That is, the pre-configured size condition can be expressed as width>4 && height>4, the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template indication information, and the flag intra_tmp_template_idx represents second template indication information. In this case, the information in the bitstream can be decoded as follows.

[0171] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width>4 && height>4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag, which indicates whether the current block uses another template. If the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1 and the current block's width and height are both width > 4 and height > 4, the decoder parses intra_tmp_template_idx, which indicates whether the current block uses the T template or the L template. For example, if the value of intra_tmp_template_idx is 0, it means the current block uses the T template, and if the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0172] In response to this, in the embodiment of the present invention, if the current block width and height values ​​do not satisfy the condition width > 4 and height > 4, a candidate template corresponding to the longer side can be selected by default. For example, if the longer side is one of the height sides, the L template is selected, and if the longer side is one of the width sides, the T template is selected.

[0173] For illustrative purposes, in some embodiments, we assume that the pre-configured prediction mode is intra TMP, and take three candidate templates, TL template, T template, and L template, as examples. The first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second size thresholds are 4, and the pre-configured size condition is that the height is greater than the first size threshold and the width is greater than the second size threshold. That is, the pre-configured size condition can be expressed as width>4 && height>4, the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template indication information, and the flag intra_tmp_template_idx represents second template indication information. In this case, the information in the bitstream can be decoded as follows.

[0174] intra_tmp_flag if(intra_tmp_flag){ if(width>4 && height>4){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is first necessary to determine whether the current block's width and height satisfy the conditions width > 4 and height > 4. If not, parsing intra_tmp_alternative_template_flag is skipped, and instead the TL template is selected directly by default. If the conditions are met, the decoder parses intra_tmp_alternative_template_flag, which indicates whether the current block uses another template. If the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, the decoder parses intra_tmp_template_idx, which indicates that the current block uses either the T template or the L template. For example, a value of 0 for intra_tmp_template_idx indicates that the current block uses a T template, and a value of 1 for intra_tmp_template_idx indicates that the current block uses an L template.

[0175] Furthermore, in the embodiments of the present application, if the size information currently includes the height and width values ​​of the block, the corresponding preset size conditions include the width value being less than a first numerical multiple of the height value, the height value being less than a second numerical multiple of the width value, the height value being greater than a first size threshold, and the width value being greater than a second size threshold.

[0176] To make it clear, in the embodiments of the present application, the first and second numerical multipliers may be used to limit the ratio of the width to the height of the current block, the first size threshold may be used to limit the height value (absolute value of height) of the current block, and the second size threshold may be used to limit the width value (absolute value of width) of the current block.

[0177] In the embodiments of this application, the first and second numerical multipliers may be any numerical values ​​greater than 0, and the first and second numerical multipliers may be the same or different, and this application does not specifically limit them.

[0178] In the embodiments of this application, the first size threshold and the second size threshold may be any numerical value greater than 0, and the first size threshold and the second size threshold may be the same or different, and this application does not specifically limit them.

[0179] For example, in the embodiments of the present application, the first numerical multiplier and the second numerical multiplier may both be 4, and the first size threshold and the second size threshold may both be 8.

[0180] To make it easier to understand, in the embodiments of the present invention, when determining whether the current block size information satisfies the preset size conditions, if the current block width is less than a first numerical multiple of the height and the current block height is less than a second numerical multiple of the width, and at the same time the current block height is greater than a first size threshold and the current block width is greater than a second size threshold, then it can be determined that the current block size information satisfies the preset size conditions. Correspondingly, if the current block width is greater than or equal to a first numerical multiple of the height, or if the current block height is greater than or equal to a second numerical multiple of the width, or if the current block height is less than or equal to a first size threshold, or if the current block width is less than or equal to a second size threshold, then it can be determined that the current block size information does not satisfy the preset size conditions.

[0181] For illustrative purposes, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, and taking three candidate templates, TL template, T template, and L template, the first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second ratio thresholds are 4, and both the first and second size thresholds are 4. The pre-configured size condition is that the height-to-width ratio is less than the first ratio threshold, the width-to-height ratio is less than the second ratio threshold, and at the same time, the height is greater than the first size threshold, and the width is greater than the second size threshold. That is, the pre-configured size condition is width <height×4 && height<width×4&& width> It can be expressed as 4 && height>4, where the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template instruction information, and the flag intra_tmp_template_idx represents second template instruction information. In this case, the information in the bitstream can be decoded as follows.

[0182] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width <height×4 && height<width×4&& width> 4 && height>4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, and at the same time the width value of the current block is smaller than 4 times the height value, and the height value is smaller than 4 times the width value, that is, when the height value and the width value satisfy width < height × 4 and height < width × 4, and at the same time the ratio of the height value to the width value of the current block satisfies width > 4 and height > 4, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means the current block uses the T template, and when the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0183] Correspondingly, in the embodiment of the present application, when the height value and the width value of the current block do not satisfy the conditions of width < height × 4, height < width × 4, width > 4, and height > 4 at the same time, a candidate template corresponding to the long side can be selected by default. For example, when the long side is one side of the height side, the L template is selected, and when the long side is one side of the width side, the T template is selected.

[0184] For illustrative purposes, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, and taking three candidate templates, TL template, T template, and L template, the first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second ratio thresholds are 4, and both the first and second size thresholds are 4. The pre-configured size condition is that the height-to-width ratio is less than the first ratio threshold, the width-to-height ratio is less than the second ratio threshold, and at the same time, the height is greater than the first size threshold, and the width is greater than the second size threshold. That is, the pre-configured size condition is width <height×4 && height<width×4&& width> It can be expressed as 4 && height>4, where the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template instruction information, and the flag intra_tmp_template_idx represents second template instruction information. In this case, the information in the bitstream can be decoded as follows.

[0185] intra_tmp_flag if(intra_tmp_flag){ if(width <height×4 && height<width×4&& width> 4 && height>4){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is first necessary to determine whether the width value of the current block is simultaneously less than 4 times the height value and the height value is less than 4 times the width value, that is, whether the height value and the width value satisfy width < height × 4 and height < width × 4, and whether the height value and the width value of the current block simultaneously satisfy the conditions of width > 4 and height > 4. If not satisfied, the analysis of intra_tmp_alternative_template_flag is skipped, and instead, the TL template is directly selected by default. If satisfied, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means that the current block uses the T template. When the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0186] As can be understood, in the embodiments of the present application, the above example selects different candidate templates in an explicit manner, that is, it is necessary to write information for selecting different templates into the bitstream. The method of restricting candidate templates by the size information of the current block can reduce unnecessary overhead.

[0187] Furthermore, in the embodiments of the present application, some template-based prediction techniques such as TIMD and DIMD can each derive one intra prediction mode based on the TL template, the T template, and the L template respectively. In order not to increase additional overhead, different processes can be performed based on threshold condition analysis.

[0188] As can be understood, in the embodiments of the present application, DIMD uses the gradients of the reconstructed samples around the current block to construct a histogram of intra prediction modes, selects the two highest intra prediction modes in the histogram as mode0 and mode1, adds the planar mode, and weights the prediction values of a total of three intra prediction modes.

[0189] Note that in the embodiments of the present application, when implementing the position-dependent weight derivation method of DIMD, when constructing the histogram of the TL template, it can be selected to construct the histogram of the T template (denoted as H_T) and the histogram of the L template (denoted as H_L) respectively. For each case where X is 0 or 1, if H_T[modeX]>H_L[modeX]×2, then modeX mainly depends on the T template, so modeX has a greater weight at a position closer to the upper side. Otherwise, if H_L[modeX]>H_T[modeX]×2, then modeX mainly depends on the L template, so modeX has a greater weight at a position closer to the left side. If neither is true, modeX does not use position-dependent weights.

[0190] As can be understood, the above position-dependent weight derivation method of DIMD can determine whether to use position-dependent weights based on direct data without adding information such as a flag. In this case, the size information can be applied to limit the weight derivation method. For example, when the block size satisfies the conditions, for example, width<height×4 && height<width×4 or width>4 && height>4, it can be executed according to the position-dependent weight derivation method of DIMD, otherwise, it is executed according to the method of not using direct position-dependent weights.

[0191] In step 102, the predicted value corresponding to the current block is determined based on the first template.

[0192] In the embodiments of the present invention, if the prediction mode corresponding to the current block is a pre-set prediction mode, a first template corresponding to the current block can be determined from at least one candidate template based on the size information of the current block, and then the predicted value corresponding to the current block can be determined based on the first template.

[0193] In the embodiment of this application, in the process in which the current block performs prediction processing using a pre-set prediction mode, the template-based prediction processing process for the current block can be completed using the determined first template. That is, the prediction block corresponding to the current block is obtained using the first template, and the prediction value corresponding to the current block is determined.

[0194] Furthermore, in the embodiments of the present application, when determining the predicted value corresponding to the current block based on the first template, first, the optimal matching block corresponding to the current block can be determined based on the first template, and then the predicted value corresponding to the current block can be determined based on the optimal matching block. For example, the reconstructed value corresponding to the optimal matching block can be determined as the predicted value of the current block.

[0195] To make it easier to understand, in the embodiments of the present application, after determining a first template for the current block, a search can be performed for the optimal matching block corresponding to the current block using the first template, and finally, the predicted value of the current block can be determined based on the obtained optimal matching block. For example, the optimal matching block can be set as the predicted block for the current block, and the predicted value corresponding to the current block can be determined. Here, the method of determining the predicted value of the current block based on the first template described above may be applied when the preset prediction mode is intra-template matching prediction intraTMP.

[0196] To make it easier to understand, in the embodiments of the present application, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, the best matching block for the current block can be determined within the search range using the first template, then the best matching block can be set as the predicted block for the current block, and then the predicted value corresponding to the current block can be determined. Here, the method of determining the predicted value of the current block based on the first template described above can be applied when the preset prediction mode is template matching of an intrablock copy IBC.

[0197] To make it easier to understand, in the embodiments of the present application, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, the best matching block for the current block can be determined using a template matching method in a reference frame using the first template, then the best matching block can be set as the predicted block for the current block, and the predicted value corresponding to the current block can be determined. Here, the method of determining the predicted value of the current block based on the first template described above may be applied when the preset prediction mode is inter-template matching prediction.

[0198] To make it clear, in the embodiments of the present invention, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, several candidate intra-prediction modes can be predicted on the first template, and the one or two intra-prediction modes with the lowest cost can be used as the intra-prediction value for the current block, and the predicted value corresponding to the current block can be determined. Herein, the method of determining the predicted value of the current block based on the first template described above may be applicable when the pre-set prediction modes are template-based intra-mode derivations (TIMDs).

[0199] To make it clear, in the embodiments of the present application, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, one or two intra-prediction modes with the lowest cost can be determined as the intra-prediction value of the current block using the region of the first template, and then the predicted value corresponding to the current block can be determined. Herein, the method of determining the predicted value of the current block based on the first template described above may be applied when the pre-set prediction mode is an intra-mode derivation (DIMD).

[0200] Furthermore, in the embodiments of the present application, after determining the predicted value of the current block based on a first template corresponding to the current block, the reconstruction value of the current block can be determined based on the predicted value of the current block.

[0201] In the embodiment of this invention, first, the bitstream can be decoded to determine the predicted residual corresponding to the current block, and then, based on the predicted residual and the predicted value, the reconstructed value of the current block can be determined.

[0202] As described above, the decoding method proposed in steps 101 to 102 above allows the process of performing prediction on the current block using template-based prediction techniques to select and restrict candidate templates using the size information of the current block, thereby determining the first template for prediction. In this process of selecting and restricting candidate templates, candidate templates that are not applicable to the current block can be excluded based on the size information of the current block, thereby reducing unnecessary overhead and interference from unreasonable results.

[0203] In other words, the encoding and decoding method proposed in the embodiment of the present application has the problem that the results derived may be unreasonable when the template ratio or template size is too small. However, the candidate templates can be limited by size information corresponding to the current block, and the first template used in the prediction process can be applied to the current block, thereby reducing interference caused by unreasonable results.

[0204] Embodiments of the present invention provide a decoding method in which, when the prediction mode corresponding to the current block is a pre-configured prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. Here, the pre-configured prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in embodiments of the present invention, when performing prediction processing on the current block using a pre-configured prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in the process of performing prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding and decoding performance.

[0205] One embodiment of the present invention proposes an encoding method applicable to an encoder, and Figure 23 is a schematic flowchart of the encoding method proposed in the embodiment of the present invention, and as shown in Figure 23, the encoding process by the encoder may include the following steps.

[0206] In step 201, if the prediction mode corresponding to the current block is a pre-configured prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, and the pre-configured prediction mode includes a template-based prediction mode.

[0207] In the embodiments of the present invention, first, a first template corresponding to the current block can be determined. Here, if the prediction mode corresponding to the current block is a pre-set prediction mode, the first template corresponding to the current block can be determined from at least one candidate template based on the size information of the current block.

[0208] The encoding method of the embodiment of this application is applied to an encoder. The encoding method may also include an intra-prediction method, and more specifically, it may be a color component prediction method. Here, the video image is divided into a plurality of encoding blocks, each encoding block may include a first color component, a second color component, and a third color component, and the current block in the embodiment of this application refers to the encoding block in the video image that is currently awaiting intra-prediction.

[0209] Here, if it is necessary to predict the first color component, the component to be predicted is the first color component; if it is necessary to predict the second color component, the component to be predicted is the second color component; and if it is necessary to predict the third color component, the component to be predicted is the third color component. Furthermore, if we make a prediction for the first color component of the current block and assume that the first color component is the luminance component, i.e., the component to be predicted is the luminance component, then the current block can also be called a luminance block. Or, if we make a prediction for the second color component of the current block and assume that the second color component is the chromaticity component, i.e., the component to be predicted is the chromaticity component, then the current block can also be called a chromaticity block.

[0210] In the embodiments of this application, the first template corresponding to the current block may be a candidate template within the template set corresponding to the current block. Here, the candidate template corresponding to the current block includes candidate templates of multiple different template types.

[0211] To make it easier to understand, in the embodiments of the present invention, first a set of templates corresponding to the current block can be constructed based on different template types, and then a first template corresponding to the current block can be determined from the candidate templates in the set of templates.

[0212] Exemplary examples, in the embodiments of the present application, as shown in Figure 21, when the upper left reference sample, upper reference sample, and left reference sample are all available, the template shape is as shown in (a); when only the left reference sample is available, the template shape is as shown in (b); when only the upper reference sample is available, the template shape is as shown in (c); when only the left reference sample and upper left reference sample are available, the template shape is as shown in (d); when only the left reference sample and lower left reference sample are available, the template shape is as shown in (e); and when only the upper reference sample and upper right reference sample are available, the template shape is as shown in (f).

[0213] Furthermore, in the embodiments of the present invention, when constructing a template set corresponding to the current block based on the template type, first, a template reference sample for the current block can be determined based on the template type and the template size corresponding to the template type, then, candidate templates for the current block can be determined based on the template reference sample, and finally, the construction of the template set can be completed.

[0214] In the embodiments of this invention, the first candidate template in the template set may be a template that includes the left-side adjacent reconstruction sample and the upper-side adjacent reconstruction sample of the current block, for example, a TL template; the second candidate template in the template set may be a template that includes the upper-side adjacent reconstruction sample of the current block, for example, a T template; and the third candidate template in the template set may be a template that includes the left-side adjacent reconstruction sample of the current block, for example, an L template.

[0215] In other words, in the embodiments of the present application, the current block may include at least one candidate template, a TL template, a T template, and an L template.

[0216] Exemplary, in the embodiment of the present application, as shown in Figure 22, four different template types are supported, and the candidate templates of the current block that are ultimately generated may also include four types, such as candidate template 1 (TL template), candidate template 2 (TL template), candidate template 3 (T template), and candidate template 4 (L template).

[0217] For example, in some embodiments, the first template corresponding to the current block may be the first candidate template in the set of templates corresponding to the current block, for example, candidate template 1.

[0218] For example, in some embodiments, the first template corresponding to the current block may be a second candidate template in the set of templates corresponding to the current block, for example, candidate template 3.

[0219] For example, in some embodiments, the first template corresponding to the current block may be a third candidate template in the set of templates corresponding to the current block, for example, candidate template 4.

[0220] Furthermore, in the embodiments of the present invention, the pre-configured prediction mode may include a template-based prediction mode. In other words, in the present invention, prediction methods involving the use of templates in the prediction processing process can be uniformly determined as pre-configured prediction modes.

[0221] For example, in some embodiments, a pre-configured prediction mode may include one of the following template-based prediction modes: intra-template matching prediction, intra-block copy, inter-template matching prediction, template-based intra-mode derivation, and intra-mode derivation.

[0222] To make it clear, in the embodiments of the present invention, the intra-template matching prediction intraTMP can use the optimal matching block found by template matching as the final determined prediction block. That is, since intraTMP can be a template-based prediction mode, it can be a pre-configured prediction mode.

[0223] To make it clear, in the embodiments of the present invention, the template matching of the intrablock copy IBC can determine the optimal matching block for the current block using a template matching method within the search range. That is, since the template matching of the IBC can be a template-based prediction mode, it can be a preset prediction mode.

[0224] To make it clear, in the embodiments of the present invention, inter-template matching prediction can determine the optimal matching block for the current block using a template matching method within a reference frame. That is, since inter-template matching prediction can be a template-based prediction mode, it can be a pre-configured prediction mode.

[0225] To make it clear, in the embodiments of the present invention, template-based intra-mode derivation (TIMD) predicts several candidate intra-prediction modes on a template and selects the one or two intra-prediction modes with the lowest cost as the intra-prediction value for the current block. That is, since TIMD can be a template-based prediction mode, it can be a pre-configured prediction mode.

[0226] To make it clear, in the embodiments of the present invention, the intra-mode derivation (DIMD) and TIMD processing processes are similar, and although DIMD does not perform predictions on the template, it uses the template's domain, so DIMD can be a template-based prediction mode, and furthermore, it can be a pre-configured prediction mode.

[0227] To ensure clarity, in the embodiments of this application, all other template-based prediction modes, in addition to intra-template matching prediction, intra-block copying, inter-template matching prediction, template-based intra-mode derivation, and intra-mode derivation, can be pre-configured prediction modes. This application is not specifically limited.

[0228] To make it clear, in the embodiments of the present invention, if it is determined that the prediction mode corresponding to the current block is a pre-set prediction mode, the size information of the current block can be used to select and restrict candidate templates. Specifically, based on the size information corresponding to the current block, a first template corresponding to the current block can be determined from at least one candidate template.

[0229] In the embodiments of this application, the first template is a template used when the current block performs prediction processing based on a pre-set prediction mode.

[0230] In the embodiments of this application, the size information corresponding to the current block may include information relating to the height and / or width of the current block.

[0231] For example, in some embodiments, the size information corresponding to the current block may be the height and width values ​​of the current block, where the height and width values ​​of the current block may be the absolute values ​​of the height and width of the current block.

[0232] Furthermore, in the embodiments of the present invention, prediction mode identification information corresponding to the current block can be determined. If the value of the prediction mode identification information is a first value, it can be determined that the prediction mode corresponding to the current block is a pre-set prediction mode, and if the value of the prediction mode identification information is a second value, it can be determined that the prediction mode corresponding to the current block is not a pre-set prediction mode.

[0233] To make it clear, in embodiments of the present application, prediction mode identification information may be used to determine whether the current block uses a template-based prediction mode. That is, it can be determined whether the prediction mode of the current block is a preset prediction mode, and further, via the prediction mode identification information, whether the current block uses the preset prediction mode to perform prediction processing.

[0234] For example, in some embodiments, one variable can be determined as predictive mode identification information, thereby enabling the determination of predictive mode identification information based on the value of that variable.

[0235] In this application, the value of the prediction mode identification information may be either a first value or a second value. Here, if the value of the prediction mode identification information is different, the method for determining the predicted value of the current block will also be different. Specifically, when determining the predicted value of the current block based on the value of the prediction mode identification information, it may be selected to use a pre-set prediction mode, or it may be selected not to use a pre-set prediction mode.

[0236] For example, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, the prediction mode identifier can be understood as a flag indicating whether or not to perform intra TMP. Here, if the value of the prediction mode identifier is a first value, it is possible to choose to determine the predicted value of the current block using intra TMP, and if the value of the prediction mode identifier is a second value, it is possible to choose to determine the predicted value of the current block without using intra TMP.

[0237] For illustrative purposes, in some embodiments, the first value may be set to 1 and the second value to 0, or the first value may be set to true and the second value to false. This application does not limit these options.

[0238] For example, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, the flag intra_tmp_flag can be used to represent the prediction mode identification information. That is, intra_tmp_flag is used as the flag for intra TMP.

[0239] Exemplary, in some embodiments, a value of 1 for intra_tmp_flag can represent choosing to use intra TMP to determine the predicted value of the current block, and a value of 0 for intra_tmp_flag can represent choosing not to use intra TMP to determine the predicted value of the current block.

[0240] To make it clear, in the embodiments of the present application, if the value of the prediction mode identification information is a first value, that is, after deciding to determine the predicted value of the current block using a preset prediction mode based on the value of the prediction mode identification information, it is possible to further determine a first template corresponding to the current block from at least one candidate template based on the size information corresponding to the current block.

[0241] Furthermore, in the embodiments of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, the first template indication information corresponding to the current block is determined. If the value of the first template indication information is a third value, the first template can be determined to be the first candidate template.

[0242] In the embodiments of this application, the first candidate template may be one of the candidate templates within at least one candidate template corresponding to the current block. For example, the first candidate template may be a TL template within at least one candidate template.

[0243] To make it clearer, in embodiments of the present application, the first template instruction information may be used to determine whether the current block uses a first candidate template. That is, the first template instruction information may indicate whether the current block uses a first candidate template to perform a prediction process in a pre-configured prediction mode.

[0244] For example, in some embodiments, one variable can be determined as first template instruction information, thereby enabling the determination of the first template instruction information based on the value of that variable.

[0245] In this application, the value of the first template instruction information may be a third or fourth value. Specifically, when performing a pre-set prediction mode based on the value of the first template instruction information, the user may choose to use the first candidate template, or they may choose not to use the first candidate template and instead use another template, for example, another template other than the first candidate template within at least one of the candidate templates.

[0246] For example, in some embodiments, the third value may be set to 0 and the fourth value to 1, or the third value may be set to false and the fourth value to true. This application does not particularly limit this.

[0247] Exemplary, in some embodiments, assuming a pre-configured prediction mode is intra TMP, the flag intra_tmp_alternative_template_flag can be used to represent the first template indication information. For example, a value of intra_tmp_alternative_template_flag of 0 can indicate that the first candidate template is determined to be the first template corresponding to the current block, while a value of intra_tmp_alternative_template_flag of 1 can indicate that the first candidate template is not determined to be the first template corresponding to the current block, and that other templates continue to be selected as the first template corresponding to the current block.

[0248] In response to this, in the embodiment of the present invention, after determining the first template instruction information corresponding to the current block, if the value of the first template instruction information is the fourth value, it can be determined that the first template is not the first candidate template. At this time, if the size information of the current block satisfies the preset size conditions, it is necessary to further determine the second template instruction information corresponding to the current block, and thereby determine the first template based on the second template instruction information.

[0249] In other words, in the embodiments of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the value of the first template instruction information is the fourth value and the size information of the current block satisfies the preset size conditions, it is necessary to further determine a second template instruction information corresponding to the current block, and thereby determine the first template based on the second template instruction information.

[0250] As can be understood, in the embodiments of the present application, when it is determined not to use the first candidate template based on the first template instruction information, it is further necessary to determine whether to use other candidate templates other than the first candidate template based on the size information corresponding to the current block. Specifically, when the size information corresponding to the current block satisfies the preset size condition, it is determined that other candidate templates other than the first candidate template can be used, and the determination of the second template instruction information is continued, and the first template can be determined based on the second template instruction information.

[0251] Note that in the embodiments of the present application, the preset size condition can be used to limit the use of candidate templates based on the size of the current block.

[0252] Furthermore, in the embodiments of the present application, when determining the first template based on the second template instruction information, if the value of the second template instruction information is the fifth value, the first template can be determined as the second candidate template, and if the value of the second template instruction information is the sixth value, the first template can be determined as the third candidate template.

[0253] Note that in the embodiments of the present application, the second candidate template and the third candidate template may each be one of the candidate templates within at least one candidate template corresponding to the current block. For example, the second candidate template may be the T template within at least one candidate template, and the third candidate template may be the L template within at least one candidate template.

[0254] As can be understood, in the embodiments of the present application, the second template instruction information can be used to determine whether the current block uses the second candidate template and / or the third candidate template. That is, the second template instruction information can indicate whether the current block uses the second candidate template and / or the third candidate template to perform the prediction process of the preset prediction mode.

[0255] Exemplarily, in some embodiments, one variable can be determined as the second template indication information, whereby the determination of the second template indication information can be realized according to the value of the variable.

[0256] Note that in the present application, the value of the second template indication information may be the fifth value or the sixth value. Specifically, when performing a preset prediction mode based on the value of the second template indication information, it may be selected to use the second candidate template, or it may be selected to use the third candidate template.

[0257] Exemplarily, in some embodiments, the fifth value may be set to 0 and the sixth value may be set to 1, or the fifth value may be set to false and the sixth value may be set to true. The present application is not particularly limited.

[0258] Exemplarily, in some embodiments, assuming that the preset prediction mode is intra TMP, the flag intra_tmp_template_idx can be used to represent the second template indication information. For example, when the value of intra_tmp_template_idx is 0, it can represent that the second candidate template is determined as the first template corresponding to the current block; when the value of intra_tmp_template_idx is 1, it can represent that the third candidate template is determined as the first template corresponding to the current block.

[0259] Furthermore, in the embodiments of the present application, when determining the first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the value of the first template indication information is the fourth value and the size information of the current block does not meet the preset size condition, it can be selected to skip the determination of the second template indication information, and instead directly determine the longest side of the current block based on the size information of the current block, and then it can be selected to determine the first template from at least one candidate template based on the longest side of the current block.

[0260] To make it clear, in the embodiments of the present application, if it is decided not to use the first candidate template based on the first template instruction information, it is further necessary to decide whether to use any other candidate templates other than the first candidate template based on the size information corresponding to the current block. Specifically, if the size information corresponding to the current block does not satisfy the pre-set size conditions, then it is not necessary to determine the first template based on the second template instruction information, and the first template can be directly indicated according to the longest side of the current block.

[0261] To make it easier to understand, in the embodiment of the present application, if the width of the current block is greater than the height of the current block, the side corresponding to the width can be determined as the longest side of the current block, and if the height of the current block is greater than the width of the current block, the side corresponding to the height can be determined as the longest side of the current block.

[0262] In other words, in the embodiment of the present application, the longest side of the current block is the side corresponding to the height, which can be understood as the height of the current block being greater than the width, and the longest side of the current block is the side corresponding to the width, which can be understood as the width of the current block being greater than the height.

[0263] Correspondingly, in the embodiment of the present application, if the value of the first template instruction information is the fourth value and the size information of the current block does not satisfy the preset size conditions, and the height value of the current block is greater than the width value of the current block, that is, if the longest side of the current block is the side corresponding to the height, then the left adjacent region of the current block can be considered to contain more adjacent samples than the upper adjacent region. Therefore, an L template containing more left adjacent samples can be designated as the first template, that is, a third candidate template (L template) containing left adjacent reconstruction samples of the current block can be determined as the first template.

[0264] Correspondingly, in the embodiment of the present application, if the value of the first template instruction information is the fourth value and the size information of the current block does not satisfy the preset size conditions, and the width value of the current block is greater than the height value of the current block, that is, if the longest side of the current block is the side corresponding to the width, then the upper adjacent region of the current block can be considered to contain more adjacent samples than the left adjacent region. Therefore, a T template containing more upper adjacent samples can be designated as the first template, that is, a second candidate template (T template) containing upper adjacent reconstruction samples of the current block can be determined as the first template.

[0265] For example, in some embodiments, assuming that the current block has a height of 4 and a width of 1, the longest side of the current block can be determined to be the side corresponding to the height, and therefore the L template corresponding to the longest side can be designated as the first template.

[0266] For example, in some embodiments, assuming that the current block has a height of 1 and a width of 8, the longest side of the current block can be determined to be the side corresponding to the width, and therefore the T template corresponding to the longest side can be designated as the first template.

[0267] Furthermore, in the embodiments of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the size information of the current block satisfies a preset size condition, the first template instruction information corresponding to the current block can be determined. If the value of the first template instruction information is a third value, the first template can be determined as the first candidate template.

[0268] In the embodiments of this application, the first candidate template may be one of the candidate templates within at least one candidate template corresponding to the current block. For example, the first candidate template may be a TL template within at least one candidate template.

[0269] In other words, in the embodiment of the present invention, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, it is possible to first determine whether or not to use the first candidate template based on the size information corresponding to the current block. Specifically, if the size information corresponding to the current block satisfies the pre-set size conditions, it can be determined that the first candidate template can be used, and the determination of the first template instruction information can then be continued.

[0270] In the embodiments of this application, the pre-set size conditions may be used to restrict the use of candidate templates based on the current block size.

[0271] In response to this, in the embodiments of the present application, when determining a first template corresponding to the current block from at least one candidate template based on the size information of the current block, if the size information of the current block does not satisfy the pre-set size conditions, then it is not necessary to determine the first template based on the first template indication information, and instead, the first template can be directly indicated. For example, the first candidate template can be determined as the first template.

[0272] To make it clearer, in embodiments of the present application, the first template instruction information may be used to determine whether the current block uses a first candidate template. That is, the first template instruction information may indicate whether the current block uses a first candidate template to perform a prediction process in a pre-configured prediction mode.

[0273] Exemplarily, in some embodiments, one variable can be determined as the first template indication information, whereby the determination of the first template indication information can be realized by the value of that variable.

[0274] In addition, in the present application, the value of the first template indication information may also be the third value or the fourth value. Specifically, when performing a preset prediction mode based on the value of the first template indication information, it may be selected to use the first candidate template, or without using the first candidate template, other templates, for example, other templates other than the first candidate template within at least one candidate template, may be selected to be used.

[0275] Exemplarily, in some embodiments, the third value may be set to 0 and the fourth value may be set to 1, or the third value may be set to false and the fourth value may be set to true. The present application is not particularly limited.

[0276] Exemplarily, in some embodiments, assuming that the preset prediction mode is intra TMP, the flag intra_tmp_alternative_template_flag can be used to represent the first template indication information. For example, when the value of intra_tmp_alternative_template_flag is 0, it can represent that the first candidate template is determined as the first template corresponding to the current block, and when the value of intra_tmp_alternative_template_flag is 1, it can represent that the first candidate template is not determined as the first template corresponding to the current block and other templates continue to be selected as the first template corresponding to the current block.

[0277] In response to this, in the embodiment of the present invention, after determining the first template instruction information corresponding to the current block, if the value of the first template instruction information is the fourth value, it can be determined that the first template is not the first candidate template. At this point, it is necessary to further determine the second template instruction information corresponding to the current block, thereby determining the first template based on the second template instruction information.

[0278] Furthermore, in the embodiments of the present invention, when determining the first template based on the second template instruction information, if the value of the second template instruction information is the fifth value, the first template can be determined as the second candidate template, and if the value of the second template instruction information is the sixth value, the first template can be determined as the third candidate template.

[0279] In the embodiments of this application, the second candidate template and the third candidate template may each be one candidate template within at least one candidate template corresponding to the current block. For example, the second candidate template may be a T template within at least one candidate template, and the third candidate template may be an L template within at least one candidate template.

[0280] To make it clearer, in embodiments of the present application, the second template instruction information may be used to determine whether the current block uses the second candidate template and / or the third candidate template. That is, the second template instruction information may indicate whether the current block uses the second candidate template and / or the third candidate template to perform prediction processing in a pre-configured prediction mode.

[0281] For example, in some embodiments, one variable can be determined as second template instruction information, thereby enabling the determination of the second template instruction information based on the value of the variable.

[0282] In this application, the value of the second template instruction information may be the fifth or sixth value. Specifically, when performing a pre-set prediction mode based on the value of the second template instruction information, the system may choose to use the second candidate template or the third candidate template.

[0283] For example, in some embodiments, the fifth value may be set to 0 and the sixth value to 1, or the fifth value may be set to false and the sixth value to true. This application is not particularly limited.

[0284] Exemplary, in some embodiments, assuming a pre-configured prediction mode is intra TMP, the flag intra_tmp_template_idx can be used to represent second template indication information. For example, a value of intra_tmp_template_idx of 0 can indicate that the second candidate template is determined to be the first template corresponding to the current block, and a value of intra_tmp_template_idx of 1 can indicate that the third candidate template is determined to be the first template corresponding to the current block.

[0285] In other words, in embodiments of the present invention, it is possible to choose to indicate in a bitstream which of at least one candidate template the first template corresponding to the current block is. For example, the first template may be indicated using first template indication information and / or second template indication information. On the other hand, the process of determining the first template may need to restrict the candidate templates using size information corresponding to the current block.

[0286] To make it clear, in the embodiments of this application, the use of candidate templates can be restricted based on the size of the current block, based on pre-set size conditions. Specifically, if the meaning contained in the size information corresponding to the current block is different, the corresponding pre-set size conditions may also be different.

[0287] Furthermore, in the embodiments of the present application, if the size information currently includes the height and width values ​​of the block, the corresponding preset size conditions include the width being less than a first numerical multiple of the height and the height being less than a second numerical multiple of the width.

[0288] To make it clear, in the embodiments of the present application, the first and second numerical multipliers may be used to limit the ratio of the width to the height of the block.

[0289] In the embodiments of this application, the first and second numerical multipliers may be any numerical values ​​greater than 0, and the first and second numerical multipliers may be the same or different, and this application does not specifically limit them.

[0290] For example, in the embodiments of the present application, the first numerical multiplier may be 4, and the second numerical multiplier may be 8.

[0291] For example, in the embodiments of the present application, both the first numerical multiplier and the second numerical multiplier may be 4.

[0292] To make it easier to understand, in the embodiments of the present invention, when determining whether the current block size information satisfies the preset size conditions, if the current block's width is less than a first numerical multiple of its height, and the current block's height is less than a second numerical multiple of its width, then it can be determined that the current block's size information satisfies the preset size conditions. Correspondingly, if the current block's width is greater than or equal to a first numerical multiple of its height, or if the current block's height is greater than or equal to a second numerical multiple of its width, then it can be determined that the current block's size information does not satisfy the preset size conditions.

[0293] Exemplarily, in some embodiments, assuming that the preset prediction mode is intra TMP, and taking three candidate templates of TL template, T template, and L template as an example, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, both the first ratio threshold and the second ratio threshold are 4, and the preset size condition is that the aspect ratio of height to width is smaller than the first ratio threshold and the aspect ratio of width to height is smaller than the second ratio threshold. That is, the preset size condition can be expressed as width < height × 4 && height < width × 4. The flag intra_tmp_flag represents the prediction mode identification information, the flag intra_tmp_alternative_template_flag represents the first template indication information, and the flag intra_tmp_template_idx represents the second template indication information. In this case, the information in the bit stream is as follows.

[0294] intra_tmp_flag if (intra_tmp_flag) { intra_tmp_alternative_template_flag if (intra_tmp_alternative_template_flag && width < height × 4 && height < width × 4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, intra_tmp_alternative_template_flag is determined, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, and the width value of the current block is less than 4 times the height value, and the height value is less than 4 times the width value, that is, when the conditions width < height×4 and height < width×4 for the height value and width value are simultaneously satisfied, intra_tmp_template_idx is determined, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means the current block uses the T template, and when the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0295] Correspondingly, in the embodiments of this application, when the height value and width value of the current block do not simultaneously satisfy the conditions width < height×4 and height < width×4, a candidate template corresponding to the long side can be selected by default. For example, when the long side is one side of the height side, the L template is selected, and when the long side is one side of the width side, the T template is selected.

[0296] Exemplarily, in some embodiments, assuming that the preset prediction mode is intra TMP, and taking three candidate templates of TL template, T template, and L template as an example, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, both the first ratio threshold and the second ratio threshold are 4, and the preset size condition is that the height-width ratio is smaller than the first ratio threshold and the width-height ratio is smaller than the second ratio threshold. That is, the preset size condition can be expressed as width < height × 4 && height < width × 4. The flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents the first template indication information, and the flag intra_tmp_template_idx represents the second template indication information. In this case, the information in the bitstream is as follows.

[0297] intra_tmp_flag if (intra_tmp_flag) { if (width < height × 4 && height < width × 4) { intra_tmp_alternative_template_flag if (intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the width value of the current block is less than 4 times the height value and the height value is less than 4 times the width value at the same time, that is, whether the height value and the width value satisfy the conditions of width < height × 4 and height < width × 4. If not satisfied, skip the analysis of intra_tmp_alternative_template_flag and directly select the TL template by default. If satisfied, determine intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses other templates. When the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, determine intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means that the current block uses the T template. When the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0298] Furthermore, in the embodiments of the present application, when the size information includes the height value and the width value of the current block, correspondingly, the preset size condition includes that the height value is greater than the first size threshold and the width value is greater than the second size threshold.

[0299] As can be understood, in the embodiments of the present application, the first size threshold can be used to limit the height value (absolute value of the height) of the current block. Correspondingly, the second size threshold can be used to limit the width value (absolute value of the width) of the current block.

[0300] In the embodiments of this application, the first size threshold and the second size threshold may be any numerical value greater than 0, and the first size threshold and the second size threshold may be the same or different, and this application does not specifically limit them.

[0301] For example, in the embodiments of the present application, the first size threshold may be 8, and the second size threshold may be 4.

[0302] For example, in the embodiments of the present application, both the first size threshold and the second size threshold may be 8.

[0303] To make it easier to understand, in the embodiments of the present invention, when determining whether the current block size information satisfies the preset size conditions, if the current block height is greater than the first size threshold and the current block width is greater than the second size threshold, it can be determined that the current block size information satisfies the preset size conditions. Correspondingly, if the current block height is less than or equal to the first size threshold, or if the current block width is less than or equal to the second size threshold, it can be determined that the current block size information does not satisfy the preset size conditions.

[0304] For illustrative purposes, in some embodiments, we assume that the pre-configured prediction mode is intra TMP, and take three candidate templates, TL template, T template, and L template, as examples. The first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second size thresholds are 4, and the pre-configured size condition is that the height is greater than the first size threshold and the width is greater than the second size threshold. That is, the pre-configured size condition can be expressed as width>4 && height>4, the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template instruction information, and the flag intra_tmp_template_idx represents second template instruction information. In this case, the information in the bitstream is as follows.

[0305] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width>4 && height>4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP, and if the current block uses intra TMP, intra_tmp_alternative_template_flag is determined, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template, and if the value of intra_tmp_alternative_template_flag is 1 and the conditions width > 4 and height > 4 are simultaneously met, intra_tmp_template_idx is determined, and intra_tmp_template_idx indicates that the current block uses either the T template or the L template. For example, if the value of intra_tmp_template_idx is 0, it means that the current block uses the T template, and if the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0306] In response to this, in the embodiment of the present invention, if the current block width and height values ​​do not satisfy the condition width > 4 and height > 4, a candidate template corresponding to the longer side can be selected by default. For example, if the longer side is one of the height sides, the L template is selected, and if the longer side is one of the width sides, the T template is selected.

[0307] For illustrative purposes, in some embodiments, we assume that the pre-configured prediction mode is intra TMP, and take three candidate templates, TL template, T template, and L template, as examples. The first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second size thresholds are 4, and the pre-configured size condition is that the height is greater than the first size threshold and the width is greater than the second size threshold. That is, the pre-configured size condition can be expressed as width>4 && height>4, the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template instruction information, and the flag intra_tmp_template_idx represents second template instruction information. In this case, the information in the bitstream is as follows.

[0308] intra_tmp_flag if(intra_tmp_flag){ if(width>4 && height>4){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is first necessary to determine whether the current block's width and height satisfy the conditions width > 4 and height > 4. If not, the analysis of intra_tmp_alternative_template_flag is skipped, and instead the TL template is selected directly by default. If the conditions are met, intra_tmp_alternative_template_flag is determined, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. If the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, intra_tmp_template_idx is determined, and intra_tmp_template_idx indicates that the current block uses either the T template or the L template. For example, a value of 0 for intra_tmp_template_idx indicates that the current block uses a T template, and a value of 1 for intra_tmp_template_idx indicates that the current block uses an L template.

[0309] Furthermore, in the embodiments of the present application, if the size information currently includes the height and width values ​​of the block, the corresponding preset size conditions include the width value being less than a first numerical multiple of the height value, the height value being less than a second numerical multiple of the width value, the height value being greater than a first size threshold, and the width value being greater than a second size threshold.

[0310] To make it clear, in the embodiments of the present application, the first and second numerical multipliers may be used to limit the ratio of the width to the height of the current block, the first size threshold may be used to limit the height value (absolute value of height) of the current block, and the second size threshold may be used to limit the width value (absolute value of width) of the current block.

[0311] In the embodiments of this application, the first and second numerical multipliers may be any numerical values ​​greater than 0, and the first and second numerical multipliers may be the same or different, and this application does not specifically limit them.

[0312] In the embodiments of this application, the first size threshold and the second size threshold may be any numerical value greater than 0, and the first size threshold and the second size threshold may be the same or different, and this application does not specifically limit them.

[0313] For example, in the embodiments of the present application, the first numerical multiplier and the second numerical multiplier may both be 4, and the first size threshold and the second size threshold may both be 8.

[0314] To make it easier to understand, in the embodiments of the present invention, when determining whether the current block size information satisfies the preset size conditions, if the current block width is less than a first numerical multiple of the height and the current block height is less than a second numerical multiple of the width, and at the same time the current block height is greater than a first size threshold and the current block width is greater than a second size threshold, then it can be determined that the current block size information satisfies the preset size conditions. Correspondingly, if the current block width is greater than or equal to a first numerical multiple of the height, or if the current block height is greater than or equal to a second numerical multiple of the width, or if the current block height is less than or equal to a first size threshold, or if the current block width is less than or equal to a second size threshold, then it can be determined that the current block size information does not satisfy the preset size conditions.

[0315] For illustrative purposes, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, and taking three candidate templates, TL template, T template, and L template, the first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second ratio thresholds are 4, and both the first and second size thresholds are 4. The pre-configured size condition is that the height-to-width ratio is less than the first ratio threshold, the width-to-height ratio is less than the second ratio threshold, and at the same time, the height is greater than the first size threshold, and the width is greater than the second size threshold. That is, the pre-configured size condition is width <height×4 && height<width×4&& width> It can be expressed as 4 && height>4, where the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template instruction information, and the flag intra_tmp_template_idx represents second template instruction information. In this case, the information in the bitstream is as follows:

[0316] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width <height×4 && height<width×4&& width> 4 && height>4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, intra_tmp_alternative_template_flag is determined, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, and at the same time the width value of the current block is less than 4 times the height value and the height value is less than 4 times the width value, that is, when the height value and the width value satisfy width < height × 4 and height < width × 4, and at the same time the ratio of the height value to the width value of the current block satisfies width > 4 and height > 4, intra_tmp_template_idx is determined, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means the current block uses the T template, and when the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0317] Correspondingly, in the embodiments of the present application, when the height value and the width value of the current block do not satisfy the conditions of width < height × 4, height < width × 4, width > 4, and height > 4 at the same time, the candidate template corresponding to the long side can be selected by default. For example, when the long side is the side on the height side, the L template is selected, and when the long side is the side on the width side, the T template is selected.

[0318] For illustrative purposes, in some embodiments, assuming that the pre-configured prediction mode is intra TMP, and taking three candidate templates, TL template, T template, and L template, the first candidate template is the TL template, the second candidate template is the T template, and the third candidate template is the L template. Both the first and second ratio thresholds are 4, and both the first and second size thresholds are 4. The pre-configured size condition is that the height-to-width ratio is less than the first ratio threshold, the width-to-height ratio is less than the second ratio threshold, and at the same time, the height is greater than the first size threshold, and the width is greater than the second size threshold. That is, the pre-configured size condition is width <height×4 && height<width×4&& width> It can be expressed as 4 && height>4, where the flag intra_tmp_flag represents prediction mode identification information, the flag intra_tmp_alternative_template_flag represents first template instruction information, and the flag intra_tmp_template_idx represents second template instruction information. In this case, the information in the bitstream is as follows:

[0319] intra_tmp_flag if(intra_tmp_flag){ if(width <height×4 && height<width×4&& width> 4 && height>4){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, first it is necessary to determine whether the width value of the current block is smaller than 4 times the height value and the height value is smaller than 4 times the width value at the same time, that is, whether the height value and the width value satisfy width < height × 4 and height < width × 4, and whether the height value and the width value of the current block satisfy width > 4 and height > 4 at the same time. If not satisfied, skip the analysis of intra_tmp_alternative_template_flag and instead directly select the TL template by default. If satisfied, determine intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, determine intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means that the current block uses the T template. When the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0320] As can be understood, in the embodiments of the present application, the above example selects different candidate templates in an explicit manner. That is, the method of writing information for selecting different templates into the bit stream and restricting the candidate templates according to the size information of the current block can reduce unnecessary overhead.

[0321] Furthermore, in the embodiments of the present application, some template-based prediction techniques such as TIMD and DIMD can each derive one intra prediction mode based on the TL template, the T template, and the L template respectively. In order not to increase additional overhead, different processes can be performed based on threshold condition analysis.

[0322] As can be understood, in the embodiments of the present application, DIMD uses the gradients of the reconstructed samples around the current block to construct a histogram of intra prediction modes, selects the two highest intra prediction modes in the histogram as mode0 and mode1, adds the planar mode, and weights the prediction values of a total of three intra prediction modes.

[0323] Note that in the embodiments of the present application, when implementing the position-dependent weight derivation method of DIMD, when constructing the histogram of the TL template, it is possible to choose to construct the histogram of the T template (denoted as H_T) and the histogram of the L template (denoted as H_L) respectively. For each case where X is 0 or 1, if H_T[modeX]>H_L[modeX]×2, then modeX mainly depends on the T template, so modeX has a greater weight at a position closer to the upper side. Otherwise, if H_L[modeX]>H_T[modeX]×2, then modeX mainly depends on the L template, so modeX has a greater weight at a position closer to the left side. If neither is true, modeX does not use position-dependent weights.

[0324] As can be understood, the above position-dependent weight derivation method of DIMD can determine whether to use position-dependent weights based directly on the data without adding information such as a flag. In this case, size information can be applied to limit the weight derivation method. For example, when the block size meets the conditions, for example, width<height×4 && height<width×4 or width>4 && height>4, it can be executed according to the position-dependent weight derivation method of DIMD, otherwise, it is executed according to the method of not using position-dependent weights directly.

[0325] In step 202, the predicted value corresponding to the current block is determined based on the first template.

[0326] In the embodiments of the present invention, if the prediction mode corresponding to the current block is a pre-set prediction mode, a first template corresponding to the current block can be determined from at least one candidate template based on the size information of the current block, and then the predicted value corresponding to the current block can be determined based on the first template.

[0327] In the embodiment of this application, in the process in which the current block performs prediction processing using a pre-set prediction mode, the template-based prediction processing process for the current block can be completed using the determined first template. That is, the prediction block corresponding to the current block is obtained using the first template, and the prediction value corresponding to the current block is determined.

[0328] Furthermore, in the embodiments of the present application, when determining the predicted value corresponding to the current block based on the first template, first, the optimal matching block corresponding to the current block can be determined based on the first template, and then the predicted value corresponding to the current block can be determined based on the optimal matching block. For example, the reconstructed value corresponding to the optimal matching block can be determined as the predicted value of the current block.

[0329] To make it easier to understand, in the embodiments of the present application, after determining a first template for the current block, a search can be performed for the optimal matching block corresponding to the current block using the first template, and finally, the predicted value of the current block can be determined based on the obtained optimal matching block. For example, the optimal matching block can be set as the predicted block for the current block, and the predicted value corresponding to the current block can be determined. Here, the method of determining the predicted value of the current block based on the first template described above may be applied when the preset prediction mode is intra-template matching prediction intraTMP.

[0330] To make it easier to understand, in the embodiments of the present application, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, the best matching block for the current block can be determined within the search range using the first template, then the best matching block can be set as the predicted block for the current block, and then the predicted value corresponding to the current block can be determined. Here, the method of determining the predicted value of the current block based on the first template described above can be applied when the preset prediction mode is template matching of an intrablock copy IBC. To make it easier to understand, in the embodiments of the present application, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, the best matching block for the current block can be determined using a template matching method in a reference frame using the first template, then the best matching block can be set as the predicted block for the current block, and the predicted value corresponding to the current block can be determined. Here, the method of determining the predicted value of the current block based on the first template described above may be applied when the preset prediction mode is inter-template matching prediction.

[0331] To make it clear, in the embodiments of the present invention, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, several candidate intra-prediction modes can be predicted on the first template, and the one or two intra-prediction modes with the lowest cost can be used as the intra-prediction value for the current block, and the predicted value corresponding to the current block can be determined. Herein, the method of determining the predicted value of the current block based on the first template described above may be applicable when the pre-set prediction modes are template-based intra-mode derivations (TIMDs).

[0332] To make it clear, in the embodiments of the present application, after determining a first template for the current block, a search can be performed using the first template for the best matching block corresponding to the current block, and finally, the predicted value of the current block can be determined based on the obtained best matching block. For example, one or two intra-prediction modes with the lowest cost can be determined as the intra-prediction value of the current block using the region of the first template, and then the predicted value corresponding to the current block can be determined. Herein, the method of determining the predicted value of the current block based on the first template described above may be applied when the pre-set prediction mode is an intra-mode derivation (DIMD).

[0333] Furthermore, in the embodiments of the present application, after determining the predicted value of the current block based on a first template corresponding to the current block, the reconstruction value of the current block can be determined based on the predicted value of the current block.

[0334] In the embodiment of this application, first, the predicted residual corresponding to the current block can be determined, and then, based on the predicted residual and the predicted value, the reconstruction value of the current block can be determined.

[0335] To make it clear, in the embodiments of the present application, the predicted residual of the current block can be determined based on the predicted value of the current block, and then the predicted residual can be written to the bitstream. The decoder can then decode the bitstream to determine the predicted residual corresponding to the current block, and then determine the reconstructed value of the current block based on the predicted residual and the predicted value.

[0336] As described above, the coding method proposed in steps 201 to 202 above allows the process of performing prediction on the current block using template-based prediction techniques to select and restrict candidate templates using the size information of the current block, thereby determining the first template for prediction. In this process of selecting and restricting candidate templates, candidate templates that are not applicable to the current block can be excluded based on the size information of the current block, thereby reducing unnecessary overhead and interference from unreasonable results.

[0337] In other words, the encoding and decoding method proposed in the embodiment of the present application has the problem that the results derived may be unreasonable when the template ratio or template size is too small. However, the candidate templates can be limited by size information corresponding to the current block, and the first template used in the prediction process can be applied to the current block, thereby reducing interference caused by unreasonable results.

[0338] Embodiments of the present invention provide an encoding method in which, when the prediction mode corresponding to the current block is a pre-configured prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. Here, the pre-configured prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in embodiments of the present invention, when performing prediction processing on the current block using a pre-configured prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in the process of performing prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding and decoding performance.

[0339] Based on the above embodiments, another embodiment of the present invention proposes an encoding and decoding method applicable to a codec. Herein, the encoding and decoding method can control and restrict the use of candidate templates based on the size of the current block. For example, in some situations, the use of T templates and / or L templates can be restricted based on the width-to-height ratio of the current block, and in other situations, the use of T templates and / or L templates can be restricted based on the absolute size of the current block (i.e., the absolute values ​​of width and height, such as height and width).

[0340] To understand this, common video encoding and decoding techniques support square and rectangular blocks. Here, the width-to-height ratio of a square block is 1:1, while the width-to-height ratio of a square block can reach 4:1 or 1:4, or even 8:1 or 1:8, and of course, the difference can be even greater. Currently, when the difference between the width and height of a block is large, it can be understood that the role of the candidate template corresponding to the shorter side is not very effective.

[0341] For example, in some embodiments, for a block with a width of 4 and a height of 16, the role of the L template corresponding to the width is not effective, so it can be specified that blocks of this size do not use the L template.

[0342] For example, in some embodiments, for a block with a width of 4 and a height of 16, the role of the L template corresponding to the width is ineffective, and therefore, it can be specified that a block of this shape can only use the TL template. This is because, if the L template is sufficiently smaller than the T template, the difference between the TL template and the T template is not very large.

[0343] For illustrative purposes, in some examples, taking intra TMP as an example, an example of a decoding syntax that does not impose any restrictions on T templates and L templates is as follows:

[0344] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means the current block uses the T template. When the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0345] Note that in the embodiments of this application, taking intra TMP as an example, when setting restrictions on the T template and the L template based on the width-to-height ratio and height-to-width ratio (height value and width value) of the current block, conditions such as && width<height×4 && height<width×4 may be added to the above example. Here, the ratio threshold (the first numerical multiple or the second numerical multiple) 4 can be replaced with other numerical values such as 2 or 8. That is, it is necessary to analyze intra_tmp_template_idx only when the above width-to-height ratio restriction conditions are met. Otherwise, when the value of intra_tmp_alternative_template_flag is 1, the candidate template corresponding to the long side is selected by default.

[0346] Exemplarily, in some embodiments, taking intra TMP as an example, the block examples of the decoding syntax that restricts the T template and the L template based on the width-to-height ratio of the current block are as follows.

[0347] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width<height×4 && height<width×4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, and the width value of the current block is less than 4 times the height value, and the height value is less than 4 times the width value, that is, when the conditions of height value and width value satisfy width<height×4 and height<width×4 simultaneously, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means that the current block uses the T template, and when the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0348] Correspondingly, in the embodiments of the present application, when the height value and width value of the current block do not simultaneously satisfy the condition that width < height × 4 and height < width × 4, a candidate template corresponding to the long side can be selected by default. For example, when the long side is one side of the height side, the L template is selected, and when the long side is one side of the width side, the T template is selected.

[0349] In addition, in the embodiments of the present application, taking intra TMP as an example, when setting restrictions on the T template and the L template based on the width-to-height ratio of the current block, the condition width < height × 4 && height < width × 4 may be added to the above example. Here, the ratio threshold 4 can be replaced with other numerical values such as 2 or 8. That is, it is necessary to analyze intra_tmp_alternative_template_flag only when the above width-to-height ratio restriction conditions are met. Otherwise, the TL template is selected by default.

[0350] Exemplarily, in some embodiments, taking intra TMP as an example, the block examples of the decoding syntax that restricts the T template and the L template based on the width-to-height ratio of the current block are as follows.

[0351] intra_tmp_flag if(intra_tmp_flag){ if(width<height×4 && height<width×4){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the width value of the current block is smaller than 4 times the height value and the height value is smaller than 4 times the width value simultaneously, that is, to determine whether the height value and width value satisfy the conditions of width < height × 4 and height < width × 4. If not satisfied, the analysis of intra_tmp_alternative_template_flag is skipped, and instead, the TL template is directly selected by default. If satisfied, the decoder analyzes intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates whether the current block uses another template. When the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. When the value of intra_tmp_alternative_template_flag is 1, the decoder analyzes intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, when the value of intra_tmp_template_idx is 0, it means that the current block uses the T template. When the value of intra_tmp_template_idx is 1, it means that the current block uses the L template.

[0352] As can be understood, in the embodiments of the present application, the absolute value of the size of the current block, that is, the absolute values of the width and height of the current block, can also be considered as elements to be considered.

[0353] Exemplarily, in some embodiments, the corresponding T template or L template can be used only when the absolute value of the width and / or height of the current block is greater than or equal to the size threshold.

[0354] In the embodiments of this application, taking intra TMP as an example, when setting limits on T templates and L templates based on the absolute size of the current block, the condition width > 4 && height > 4 may be added to the above example. Here, the size threshold of 4 can be replaced with other numbers such as 2 or 8. In other words, intra_tmp_template_idx only needs to be parsed if the above size limit conditions are met. Otherwise, if the value of intra_tmp_alternative_template_flag is 1, a candidate template corresponding to the longer side is selected by default.

[0355] For illustrative purposes, in some embodiments, taking intra TMP as an example, the following are examples of decryption syntax blocks that restrict T templates and L templates based on the absolute values ​​of the width and / or height of the current block:

[0356] intra_tmp_flag if(intra_tmp_flag){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag && width>4 && height>4) { intra_tmp_template_idx } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag, which indicates whether the current block uses another template. If the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1 and the current block's width and height are both width > 4 and height > 4, the decoder parses intra_tmp_template_idx, which indicates whether the current block uses the T template or the L template. For example, if the value of intra_tmp_template_idx is 0, it means the current block uses the T template, and if the value of intra_tmp_template_idx is 1, it means the current block uses the L template.

[0357] In response to this, in the embodiment of the present invention, if the current block width and height values ​​do not satisfy the condition width > 4 and height > 4, a candidate template corresponding to the longer side can be selected by default. For example, if the longer side is one of the height sides, the L template is selected, and if the longer side is one of the width sides, the T template is selected.

[0358] In the embodiments of this application, taking intra TMP as an example, when setting limits on T and L templates based on the absolute size of the current block, the condition width > 4 && height > 4 may be added to the above example. Here, the size threshold of 4 can be replaced with other numbers such as 2 or 8. In other words, intra_tmp_alternative_template_flag needs to be parsed only if the above size limit conditions are met. Otherwise, the TL template is selected by default.

[0359] For illustrative purposes, in some embodiments, taking intra TMP as an example, the following are examples of decryption syntax blocks that restrict T templates and L templates based on the absolute values ​​of the width and / or height of the current block:

[0360] intra_tmp_flag if(intra_tmp_flag){ if(width>4 && height>4){ intra_tmp_alternative_template_flag if(intra_tmp_alternative_template_flag) { intra_tmp_template_idx } } } Here, intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is first necessary to determine whether the current block's width and height satisfy the conditions width > 4 and height > 4. If not, the analysis of intra_tmp_alternative_template_flag is skipped, and instead the TL template is selected directly by default. If the conditions are met, the decoder analyzes intra_tmp_alternative_template_flag, which indicates whether the current block uses another template. If the value of intra_tmp_alternative_template_flag is 0, it means the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, the decoder analyzes intra_tmp_template_idx, which indicates that the current block uses either the T template or the L template. For example, a value of 0 for intra_tmp_template_idx indicates that the current block uses a T template, and a value of 1 for intra_tmp_template_idx indicates that the current block uses an L template.

[0361] To make it clear, in the embodiments of this application, both the width-to-height ratio and the absolute value of the size can be used in combination when restricting the use of candidate templates. This application is not specifically limited.

[0362] To make it clear, in the embodiments of the present application, the above example selects different candidate templates in an explicit manner, meaning that information for selecting different templates must be written to the bitstream, and the current method of limiting candidate templates by block size information can reduce unnecessary overhead.

[0363] Furthermore, in the embodiments of the present application, some template-based prediction techniques such as TIMD and DIMD can derive one intra prediction mode respectively based on the TL template, the T template, and the L template. In order not to increase additional overhead, different processes can be performed based on threshold condition analysis.

[0364] As can be understood, in the embodiments of the present application, DIMD uses the gradients of the reconstructed samples around the current block to construct a histogram of intra prediction modes, selects the two highest intra prediction modes in the histogram as mode0 and mode1, adds the planar mode, and weights the prediction values of a total of three intra prediction modes.

[0365] Note that in the embodiments of the present application, when implementing the position-dependent weight derivation method of DIMD, when constructing the histogram of the TL template, it can be selected to construct the histogram of the T template (denoted as H_T) and the histogram of the L template (denoted as H_L) respectively. For each case where X is 0 or 1, if H_T[modeX]>H_L[modeX]×2, since modeX mainly depends on the T template, the weight of modeX is larger at a position closer to the upper side. Otherwise, if H_L[modeX]>H_T[modeX]×2, since modeX mainly depends on the L template, the weight of modeX is larger at a position closer to the left side. If neither is true, modeX does not use the position-dependent weight.

[0366] As can be understood, the above position-dependent weight derivation method of DIMD can determine whether to use the position-dependent weight based on the direct data without adding information such as a flag. In this case, the size information can be applied to limit the weight derivation method. For example, when the block size satisfies the conditions, for example, width<height×4 && height<width×4 or width>4 && height>4, it can be executed according to the position-dependent weight derivation method of DIMD, otherwise, it is executed according to the method of not using the direct position-dependent weight.

[0367] As described above, in the encoding and decoding method proposed in the embodiment of the present application, the process of performing prediction processing on the current block using template-based prediction techniques can select and restrict candidate templates using the size information of the current block, thereby determining a first template for prediction processing. Here, in the process of selecting and restricting candidate templates, candidate templates that are not applicable to the current block can be excluded based on the size information of the current block, thereby reducing unnecessary overhead and interference from unreasonable results.

[0368] In other words, the encoding and decoding method proposed in the embodiment of the present application has the problem that the results derived may be unreasonable when the template ratio or template size is too small. However, the candidate templates can be limited by size information corresponding to the current block, and the first template used in the prediction process can be applied to the current block, thereby reducing interference caused by unreasonable results.

[0369] Embodiments of the present invention provide an encoding / decoding method in which, when the prediction mode corresponding to the current block is a pre-configured prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. Here, the pre-configured prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in embodiments of the present invention, when performing prediction processing on the current block using a pre-configured prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in the process of performing prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding / decoding performance.

[0370] In yet another embodiment of the present application, referring to Figure 24, which is a schematic diagram showing the configuration of the encoder provided in the embodiment of the present application. As shown in Figure 24, the encoder 180 may include a first determination unit 1801, where, The first decision unit 1801 is configured to determine a first template corresponding to the current block from at least one candidate template based on the size information of the current block, provided that the prediction mode corresponding to the current block is a pre-set prediction mode, wherein the pre-set prediction mode includes a template-based prediction mode, and to determine a predicted value corresponding to the current block based on the first template.

[0371] To ensure clarity, in the embodiments of this application, a "unit" may be a part of a circuit, a part of a processor, a part of a program, or software, and may, of course, be a module or non-modular. Furthermore, each component in these embodiments may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The integrated unit may be implemented in hardware form or in the form of a software function module.

[0372] If the integrated module is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored on a single computer-readable storage medium. Based on this understanding, an essential part of the technical solution of this embodiment, i.e., a part that contributes to the prior art, or all or part of the technical solution, can be implemented in the form of a software product, which is stored on a single storage medium and contains several instructions for causing 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 storage medium includes various media capable of storing program code, such as U disks, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0373] Accordingly, embodiments of the present application provide a computer-readable storage medium applicable to an encoder 180, wherein a computer program is stored in the computer storage medium, and when the computer program is executed by a first processor, the method described in any one of the above embodiments is realized.

[0374] Referring to Figure 25, based on the configuration of the encoder 180 and the computer-readable storage medium, Figure 25 is a schematic diagram showing the specific hardware configuration of the encoder 180 provided in the embodiment of the present application. As shown in Figure 25, the encoder 180 may comprise a first communication interface 1901, a first memory 1902, and a first processor 1903, each component being coupled via a first bus system 194. To understand this, the first bus system 1904 is used to provide connection communication between these components. In addition to the data bus, the first bus system 1904 includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity in this explanation, all the various buses are referred to as the first bus system 1904. Here, The first communication interface 1901 is configured to send and receive signals in the process of sending and receiving information with other external network elements. The first memory 1902 is configured to store a computer program that can be executed on the first processor 1903. The first processor 1903 is configured to, when executing the computer program, determine a first template corresponding to the current block from at least one candidate template based on the size information of the current block, provided that the prediction mode corresponding to the current block is a pre-set prediction mode, wherein the pre-set prediction mode includes a template-based prediction mode, and determine a predicted value corresponding to the current block based on the first template.

[0375] To ensure understanding, the first memory 1902 in the embodiments of this application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Here, the non-volatile memory may 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 may be random access memory (RAM) used as an external cache. To the extent of illustrative but non-limiting examples, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous-connected dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The first memory 1902 in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0376] The first processor 1903 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the method can be completed by instructions in the form of hardware integrated logic circuits or software in the first processor 1903. The first processor 1903 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 device, a discrete gate or transistor logic device, a discrete hardware component, etc. Each method, step and logic block diagram disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc. The steps of the method disclosed in the embodiments of this application may be performed directly by a hardware decoding processor, or by a combination of hardware and software modules within the decoding processor. The software module can be placed in a conventional storage medium such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, or registers. The storage medium is placed in the first memory 1902, and the first processor 1903 reads the information in the first memory 1902 and combines it with its hardware to complete the steps of the method described above.

[0377] To ensure understanding, these embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementations, the processing unit may 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 herein, or a combination thereof. For software implementations, the technical solutions described herein can be implemented by executing the functional modules (processes, functions, etc.) described herein. The software code may be stored in memory and executed by the processor. The memory may be implemented in the processor or outside the processor.

[0378] Optionally, in another embodiment, the first processor 1903 is further configured to perform the method described in any of the above embodiments when executing the computer program.

[0379] In yet another embodiment of the present application, referring to Figure 26, which is a schematic diagram showing the configuration of the decoder provided in an embodiment of the present application. As shown in Figure 26, the decoder 200 may include a second determination unit 2001, where, The second decision unit 2001 is configured to perform the following actions when the prediction mode corresponding to the current block is a pre-set prediction mode, wherein the pre-set prediction mode includes a template-based prediction mode, and to determine a predicted value corresponding to the current block based on the first template.

[0380] To make it clear, in this embodiment, a "unit" may be part of a circuit, part of a processor, part of a program, or software, and may be a module or non-modular. Furthermore, each component in this embodiment may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The integrated unit may be implemented in hardware form or in the form of a software function module.

[0381] If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a single computer-readable storage medium. Based on this understanding, this embodiment provides a computer storage medium applicable to the decoder 200, wherein a computer program is stored in the computer storage medium, and when the computer program is executed by a second processor, the method described in any one of the above embodiments is implemented.

[0382] Referring to Figure 27, based on the configuration of the decoder 200 and the computer-readable storage medium, Figure 27 is a schematic diagram showing the specific hardware configuration of the decoder 200 provided in the embodiment of the present application. As shown in Figure 27, the decoder 200 may comprise a second communication interface 2201, a second memory 2202, and a second processor 2203, each component being coupled via a second bus system 2204. To make it clear, the first bus system 2204 is used to provide connection communication between these components. The second bus system 2204 includes a power bus, a control bus, and a status signal bus, in addition to the data bus. However, for the sake of clarity, all the various buses are referred to as the second bus system 2204. Here, The second communication interface 2201 is configured to send and receive signals in the process of sending and receiving information with other external network elements. The second memory 2202 is configured to store a computer program that can be executed by the second processor 2203. The second processor 2203 is configured to, when executing the computer program, determine a first template corresponding to the current block from at least one candidate template based on the size information of the current block, provided that the prediction mode corresponding to the current block is a pre-set prediction mode, wherein the pre-set prediction mode includes a template-based prediction mode, and determine a predicted value corresponding to the current block based on the first template.

[0383] Optionally, in another embodiment, the second processor 2203 is further configured to perform the method described in any of the above embodiments when executing the computer program.

[0384] To make it easier to understand, the second memory 2202 has the same hardware functionality as the first memory 1902, and the second processor 2203 has the same hardware functionality as the first processor 1903, which will not be explained again here.

[0385] An embodiment of the present application provides a codec in which, when the prediction mode corresponding to the current block is a pre-configured prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. Here, the pre-configured prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in an embodiment of the present application, when performing prediction processing on the current block using a pre-configured prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in a process that performs prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding and decoding performance.

[0386] In yet another embodiment of the present application, referring to Figure 28, which is a schematic diagram showing the configuration of a codec system provided in an embodiment of the present application. As shown in Figure 28, the codec system 230 may comprise an encoder 2301 and a decoder 2302.

[0387] In the embodiments of the present application, the encoder 2301 may be the encoder described in any of the above embodiments, and the decoder 2302 may be the decoder described in any of the above embodiments.

[0388] Furthermore, embodiments of the present application further provide a bitstream, where the bitstream is generated by bit encoding based on information to be encoded, and the information to be encoded includes at least one of prediction mode identification information, first template instruction information, second template instruction information, and prediction residual.

[0389] In this application, the terms “composes,” “includes,” or any other variation thereof are intended to encompass non-exclusive inclusion, so that a process, method, article, or device containing a set of elements includes not only those elements but also other elements not expressly enumerated, or elements specific to such process, method, article, or device. Unless otherwise specified, an element defined by the expression “includes…” does not preclude the presence of another identical element in a process, method, article, or device containing that element.

[0390] The above-mentioned examples of the present invention are for illustrative purposes only and do not indicate any ranking of the examples.

[0391] The methods disclosed in some embodiments of the methods provided herein can be arbitrarily combined without contradiction to obtain new embodiments of the methods.

[0392] The features disclosed in the embodiments of some of the products provided in this application can be arbitrarily combined without contradiction to obtain embodiments of new products.

[0393] The features disclosed in some embodiments of the methods or apparatus provided herein can be arbitrarily combined without contradiction to obtain new embodiments of the methods or apparatus.

[0394] The above description is merely an embodiment of the present application, and the scope of protection of this application is not limited thereto. All modifications or substitutions that a person skilled in the art could easily conceive of within the technical scope disclosed herein should be included within the scope of protection of this application. Accordingly, the scope of protection of this application shall be subject to the scope of protection of the claims. [Industrial applicability]

[0395] Embodiments of the present application provide an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium. When the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block. The preset prediction mode includes a template-based prediction mode, and the predicted value corresponding to the current block is determined based on the first template. Thus, in embodiments of the present application, when performing prediction processing on the current block using a preset prediction mode of a template-based prediction mode, it is possible to select to determine at least one candidate template based on the size information of the current block, thereby obtaining a first template to be used in subsequent prediction processing processes by restricting the use of candidate templates that do not fit the size information of the current block. Here, since the first template is obtained based on the size information of the current block, the first template is applicable to the scene corresponding to the current block in the process of performing prediction processing in a template-based prediction mode. This reduces interference due to unnecessary overhead and unreasonable results, further improves compression efficiency, and enhances encoding / decoding performance.

Claims

1. A decoding method applicable to a decoder, If the prediction mode corresponding to the current block is a pre-configured prediction mode, then a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, wherein the pre-configured prediction mode includes a template-based prediction mode. A decoding method comprising determining a predicted value corresponding to the current block based on the first template.

2. The aforementioned decryption method is Decode the bitstream to determine the prediction mode identification information corresponding to the current block, If the value of the prediction mode identification information is a first value, the prediction mode corresponding to the current block is determined to be the preset prediction mode, If the value of the prediction mode identification information is a second value, the prediction mode corresponding to the current block is determined to be not the pre-set prediction mode, further comprising: The decoding method according to claim 1.

3. The aforementioned pre-configured prediction mode includes one of the following prediction modes: intra-template matching prediction, intra-block copy, inter-template matching prediction, template-based intra-mode derivation, or decoder-side intra-mode derivation. The decoding method according to claim 1.

4. Based on the size information of the current block, determining a first template corresponding to the current block from at least one candidate template is: Decrypting the bitstream to determine the first template instruction information corresponding to the current block, If the value of the first template instruction information is a third value, the first template is determined to be the first candidate template. The process includes, if the value of the first template instruction information is a fourth value and the size information of the current block satisfies a preset size condition, decoding the bitstream to determine the second template instruction information corresponding to the current block, and determining the first template based on the second template instruction information. The decoding method according to claim 2.

5. Determining the first template based on the second template instruction information means If the value of the second template instruction information is the fifth value, the first template is determined to be the second candidate template, If the value of the second template instruction information is the sixth value, the first template is determined to be the third candidate template, including the following: The decoding method according to claim 4.

6. The aforementioned decryption method is The value of the first template instruction information is the fourth value, and the size information of the current block does not satisfy the preset size conditions, and if the width value of the current block is greater than the height value of the current block, the first template is determined to be the second candidate template, and if the height value of the current block is greater than the width value of the current block, the first template is determined to be the third candidate template, further comprising: The decoding method according to claim 5.

7. Based on the size information of the current block, determining a first template corresponding to the current block from at least one candidate template is: If the size information of the current block satisfies the pre-set size conditions, the bitstream is decoded to determine the first template instruction information corresponding to the current block. If the value of the first template instruction information is a third value, the first template is determined to be the first candidate template. If the value of the first template instruction information is a fourth value, the bitstream is decoded to determine the second template instruction information corresponding to the current block, and the first template is determined based on the second template instruction information, The decoding method according to claim 2.

8. Determining the first template based on the second template instruction information means If the value of the second template instruction information is the fifth value, the first template is determined to be the second candidate template, If the value of the second template instruction information is the sixth value, the first template is determined to be the third candidate template, including the following: The decoding method according to claim 7.

9. The first candidate template is a template that includes the left-side adjacent reconstruction sample and the upper-side adjacent reconstruction sample of the current block, The second candidate template is a template that includes the upper adjacent reconstruction sample of the current block, The third candidate template is a template that includes a left-side adjacent reconstruction sample of the current block. The decoding method according to any one of claims 5, 6, or 8.

10. The aforementioned decryption method is If the current block size information does not satisfy the preset size conditions, the first template is further determined to be the first candidate template. The decoding method according to claim 7.

11. The aforementioned size information includes the height and width values ​​of the current block, and correspondingly, The aforementioned preset size conditions include the condition that the width value is less than a first numerical multiple of the height value, and the height value is less than a second numerical multiple of the width value. The decoding method according to any one of claims 4 to 10.

12. The aforementioned size information includes the height and width values ​​of the current block, and correspondingly, The aforementioned pre-set size conditions include the height value being greater than a first size threshold and the width value being greater than a second size threshold. The decoding method according to any one of claims 4 to 10.

13. The aforementioned size information includes the height and width values ​​of the current block, and correspondingly, The aforementioned preset size conditions include the condition that the width value is less than a first numerical multiple of the height value, the height value is less than a second numerical multiple of the width value, the height value is greater than a first size threshold, and the width value is greater than a second size threshold. The decoding method according to any one of claims 4 to 10.

14. The aforementioned at least one candidate template includes a TL template, a T template, and an L template. The decoding method according to claim 1.

15. The aforementioned communication method is, Decode the bitstream and determine the predicted residual corresponding to the current block, The further includes determining the reconstruction value of the current block based on the predicted residual and the predicted value, The decoding method according to claim 1.

16. Determining the predicted value corresponding to the current block based on the first template is: Based on the first template, determine the optimal matching block corresponding to the current block, This includes determining a predicted value corresponding to the current block based on the optimal matching block, The decoding method according to claim 1.

17. An encoding method applied to an encoder, If the prediction mode corresponding to the current block is a pre-configured prediction mode, then a first template corresponding to the current block is determined from at least one candidate template based on the size information of the current block, wherein the pre-configured prediction mode includes a template-based prediction mode. An encoding method comprising determining a predicted value corresponding to the current block based on the first template.

18. The aforementioned encoding method is Determining the prediction mode identification information corresponding to the current block, If the value of the prediction mode identification information is a first value, the prediction mode corresponding to the current block is determined to be the preset prediction mode, If the value of the prediction mode identification information is a second value, the prediction mode corresponding to the current block is determined to be not the pre-set prediction mode, further comprising: The encoding method according to claim 17.

19. The aforementioned pre-configured prediction mode includes one of the following prediction modes: intra-template matching prediction, intra-block copy, inter-template matching prediction, template-based intra-mode derivation, or decoder-side intra-mode derivation. The encoding method according to claim 17.

20. Based on the size information of the current block, determining a first template corresponding to the current block from at least one candidate template is: Determine the first template instruction information corresponding to the current block, If the value of the first template instruction information is a third value, the first template is determined to be the first candidate template. The process includes determining a second template instruction information corresponding to the current block if the value of the first template instruction information is a fourth value and the size information of the current block satisfies a preset size condition, and determining the first template based on the second template instruction information. The encoding method according to claim 18.

21. Determining the first template based on the second template instruction information means If the value of the second template instruction information is the fifth value, the first template is determined to be the second candidate template, If the value of the second template instruction information is the sixth value, the first template is determined to be the third candidate template, including the following: The encoding method according to claim 20.

22. The aforementioned encoding method is The value of the first template instruction information is the fourth value, and the size information of the current block does not satisfy the preset size conditions, and if the width value of the current block is greater than the height value of the current block, the first template is determined to be the second candidate template, and if the height value of the current block is greater than the width value of the current block, the first template is determined to be the third candidate template, further comprising: The encoding method according to claim 21.

23. Based on the size information of the current block, determining a first template corresponding to the current block from at least one candidate template is: If the size information of the current block satisfies the pre-set size conditions, the first template instruction information corresponding to the current block is determined. If the value of the first template instruction information is a third value, the first template is determined to be the first candidate template. The value of the first template instruction information is a fourth value, and the second template instruction information corresponding to the current block is determined, and the first template is determined based on the second template instruction information, The encoding method according to claim 18.

24. Determining the first template based on the second template instruction information means If the value of the second template instruction information is the fifth value, the first template is determined to be the second candidate template, If the value of the second template instruction information is the sixth value, the first template is determined to be the third candidate template, including the following: The encoding method according to claim 23.

25. The first candidate template is a template that includes the left-side adjacent reconstruction sample and the upper-side adjacent reconstruction sample of the current block, The second candidate template is a template that includes the upper adjacent reconstruction sample of the current block, The third candidate template is a template that includes a left-side adjacent reconstruction sample of the current block. The encoding method according to any one of claims 21, 22, or 24.

26. The aforementioned encoding method is If the current block size information does not satisfy the preset size conditions, the first template is further determined to be the first candidate template. The encoding method according to claim 23.

27. The aforementioned size information includes the height and width values ​​of the current block, and correspondingly, The aforementioned preset size conditions include the condition that the width value is less than a first numerical multiple of the height value, and the height value is less than a second numerical multiple of the width value. The encoding method according to any one of claims 20 to 26.

28. The aforementioned size information includes the height and width values ​​of the current block, and correspondingly, The aforementioned pre-set size conditions include the height value being greater than a first size threshold and the width value being greater than a second size threshold. The encoding method according to any one of claims 20 to 26.

29. The aforementioned size information includes the height and width values ​​of the current block, and correspondingly, The aforementioned preset size conditions include the condition that the width value is less than a first numerical multiple of the height value, the height value is less than a second numerical multiple of the width value, the height value is greater than a first size threshold, and the width value is greater than a second size threshold. The encoding method according to any one of claims 20 to 26.

30. The aforementioned at least one candidate template includes a TL template, a T template, and an L template. The encoding method according to claim 17.

31. The aforementioned encoding method is Determining the predicted residual corresponding to the current block, The further includes determining the reconstruction value of the current block based on the predicted residual and the predicted value, The encoding method according to claim 17.

32. Determining the predicted value corresponding to the current block based on the first template is: Based on the first template, determine the optimal matching block corresponding to the current block, This includes determining a predicted value corresponding to the current block based on the optimal matching block, The encoding method according to claim 17.

33. It is a bitstream, The bitstream is generated by bit encoding based on the information to be encoded, and the information to be encoded is, The prediction mode identification information includes at least one of the first template instruction information, the second template instruction information, and the prediction residual.

34. An encoder comprising a first decision unit, The first decision unit is configured to perform the following actions when the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block from at least one candidate template based on the size information of the current block, wherein the preset prediction mode includes a template-based prediction mode, and a predicted value corresponding to the current block based on the first template.

35. An encoder comprising a first memory and a first processor, The first memory is configured to store a computer program that can be executed by the first processor. An encoder wherein the first processor is configured to perform the method according to any one of claims 17 to 32 when executing the computer program.

36. A decoder comprising a second decision unit, The second decision unit is configured to perform the following actions when the prediction mode corresponding to the current block is a pre-set prediction mode, a first template corresponding to the current block from at least one candidate template based on the size information of the current block, wherein the pre-set prediction mode includes a template-based prediction mode, and a predicted value corresponding to the current block based on the first template.

37. A decoder comprising a second memory and a second processor, The second memory is configured to store a computer program that can be executed by the second processor. The second processor is configured to perform the method according to any one of claims 1 to 16 when executing the computer program, wherein the second processor is configured to perform the method according to any one of claims 1 to 16.

38. A computer-readable storage medium storing a computer program that, when executed, implements the method according to any one of claims 1 to 16 or the method according to any one of claims 17 to 32.