Encoding / decoding method, code stream, encoder, decoder and storage medium

MYPI2025006026A0Undetermined Publication Date: 2024-10-03GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
MYPI2025006026
Authority / Receiving Office
MY · MY
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-04-03
Publication Date
2024-10-03

AI Technical Summary

Technical Problem

Existing intra-frame template matching prediction technology has the problem of low prediction accuracy during the encoding process, resulting in reduced compression efficiency and performance.

Method used

Propose a prediction method that combines Intra TMP multi-candidate and multi-template. By constructing a block vector candidate list and selecting multiple candidate templates, it achieves multi-candidate and multi-template level multi-selection for intra-frame template matching prediction, improving compression efficiency and Codec performance.

Benefits of technology

It improves the compression efficiency and performance of encoding and decoding, and enhances the accuracy and flexibility of prediction through the combination of multiple candidates and multiple templates. It is suitable for intra-frame template matching prediction in video encoding and decoding technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure PI2025006026_DRAWING_001
    Figure PI2025006026_DRAWING_001
  • Figure PI2025006026_DRAWING_002
    Figure PI2025006026_DRAWING_002
  • Figure PI2025006026_DRAWING_003
    Figure PI2025006026_DRAWING_003
Patent Text Reader

Abstract

Disclosed in the embodiments of the present application are an encoding / decoding method, a code stream, an encoder, a decoder and a storage medium. The method comprises: an encoder / decoder determining a first template corresponding to the current block, wherein the first template is one or more candidate templates in a template set corresponding to the current block; according to the first template, determining a block vector candidate list corresponding to the current block; and according to the block vector candidate list corresponding to the current block, determining a block vector corresponding to the current block, and determining a predicted value of the current block according to the block vector. (Fig. 18)
Need to check novelty before this filing date? Find Prior Art

Description

Coding and decoding method, code stream, encoder, decoder and storage medium Technical Field

[0001] The embodiments of the present application relate to the field of video coding and decoding technology, and in particular to a coding and decoding method, a bit stream, an encoder, a decoder, and a storage medium. Background Art

[0002] Intra Template Matching Prediction (Intra TMP) technology uses the template of the coding block to search for the matching template with the minimum cost according to a preset cost function within a predefined search range in the current image, and uses the best matching reconstructed block corresponding to the matching template as the prediction block of the current coding block.

[0003] However, in the actual encoding process, related technologies may have large deviations and low prediction accuracy, which in turn reduces compression efficiency and performance.

[0004] Summary of the Invention

[0005] The embodiments of the present application provide a coding and decoding method, a code stream, an encoder, a decoder, and a storage medium, which can improve compression efficiency and improve coding and decoding performance.

[0006] The technical solution of the embodiment of the present application can be implemented as follows:

[0007] In a first aspect, an embodiment of the present application provides a decoding method, applied to a decoder, the method comprising:

[0008] Determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block;

[0009] determining a block vector candidate list corresponding to the current block according to the first template;

[0010] A block vector corresponding to the current block is determined according to a block vector candidate list corresponding to the current block, and a prediction value of the current block is determined according to the block vector.

[0011] In a second aspect, an embodiment of the present application provides an encoding method, applied to an encoder, the method comprising:

[0012] Determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block;

[0013] determining a block vector candidate list corresponding to the current block according to the first template;

[0014] A block vector corresponding to the current block is determined according to a block vector candidate list corresponding to the current block, and a prediction value of the current block is determined according to the block vector.

[0015] In a third aspect, an embodiment of the present application provides a code stream, wherein the code stream is generated by bit encoding based on information to be encoded; wherein the information to be encoded includes at least one of the following:

[0016] Template matching prediction identification information, first template indication information, second template indication information, third template indication information, index identification information, prediction difference.

[0017] In a fourth aspect, an embodiment of the present application provides an encoder, comprising a first determining unit; wherein,

[0018] The first determination unit is configured to determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determine a block vector candidate list corresponding to the current block based on the first template; determine a block vector corresponding to the current block based on the block vector candidate list corresponding to the current block, and determine a prediction value of the current block based on the block vector.

[0019] In a fifth aspect, an embodiment of the present application provides an encoder, comprising a first memory and a first processor; wherein,

[0020] The first memory is used to store a computer program that can be run on the first processor;

[0021] The first processor is configured to execute the method according to the second aspect when running the computer program.

[0022] In a sixth aspect, an embodiment of the present application provides a decoder, comprising a second determining unit; wherein,

[0023] The second determination unit is configured to determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determine a block vector candidate list corresponding to the current block based on the first template; determine a block vector corresponding to the current block based on the block vector candidate list corresponding to the current block, and determine a prediction value of the current block based on the block vector.

[0024] In a seventh aspect, an embodiment of the present application provides a decoder, comprising a second memory and a second processor; wherein,

[0025] The second memory is used to store a computer program that can be run on the second processor;

[0026] The second processor is configured to execute the method according to the first aspect when running the computer program.

[0027] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the method as described in the first aspect or the method as described in the second aspect is implemented.

[0028] The embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder, and a storage medium, wherein the encoder and decoder determine a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; a block vector candidate list corresponding to the current block is determined based on the first template; a block vector corresponding to the current block is determined based on the block vector candidate list corresponding to the current block, and a prediction value of the current block is determined based on the block vector. Thus, in the embodiment of the present application, a prediction method combining intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected, and a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing a combination of intraTMP multiple candidates and multiple selections at the template level. That is, the coding and decoding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and encoding and decoding performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] FIG1 is a schematic diagram of the basic flow of a video codec;

[0030] FIG2 is a schematic diagram showing the positional relationship between the current block and the reference sample;

[0031] FIG3 is a schematic diagram of using four reference rows / columns in an intra-frame prediction method;

[0032] FIG4 is a schematic diagram of nine modes of intra-frame prediction for a 4x4 block in H.264;

[0033] FIG5 is a schematic diagram of 35 intra-frame prediction modes used by HEVC;

[0034] Figure 6 is a schematic diagram of the 67 intra modes used by VVC;

[0035] FIG7 is a schematic diagram of a wide-angle mode;

[0036] Figure 8 is a schematic diagram of the 66 prediction modes used by AVS3;

[0037] Figure 9 is a schematic diagram of screen content;

[0038] FIG10 is a schematic diagram of inter-frame prediction;

[0039] Figure 11 is a schematic diagram of intraTMP;

[0040] FIG12 is a schematic diagram of a search;

[0041] FIG13 is a second schematic diagram of the search;

[0042] FIG14 is a schematic diagram of a template type 1;

[0043] FIG15 is a schematic block diagram of the encoder;

[0044] FIG16 is a schematic block diagram of the encoder;

[0045] FIG17 is a schematic diagram of the network architecture of the encoding and decoding system;

[0046] FIG18 is a schematic diagram of a flow chart of a decoding method proposed in an embodiment of the present application;

[0047] Figure 19 is a schematic diagram of the second template type;

[0048] FIG20 is a schematic diagram of a candidate template;

[0049] FIG21 is a schematic diagram of a flow chart of an encoding method proposed in an embodiment of the present application;

[0050] FIG22 is a schematic diagram of the composition structure of the encoder;

[0051] Figure 23 is a schematic diagram of the encoder hardware structure;

[0052] FIG24 is a schematic diagram of the composition structure of a decoder;

[0053] FIG25 is a schematic diagram of the decoder hardware structure;

[0054] FIG26 is a schematic diagram showing the composition structure of the encoding and decoding system. DETAILED DESCRIPTION

[0055] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.

[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.

[0057] In the following description, reference is made to "some embodiments," which describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. It should also be noted that the terms "first, second, and third" in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that "first, second, and third" may be interchanged in a specific order or sequential order where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0058] Before further explaining the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained first. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations:

[0059] Coding Block (CB);

[0060] Block Maching (BM);

[0061] Coding Unit (CU);

[0062] Block Vector (BV);

[0063] Sum of Absolute Difference (SAD);

[0064] Sum of Absolute Transformed Difference (SATD);

[0065] Mean Square Error (MSE);

[0066] Sum of Squared Differences (SSD);

[0067] Mean Absolute Deviation (MAD);

[0068] Mean Square Differences (MSD);

[0069] Normalized Correlation Coefficient (NCC);

[0070] H.266 / Versatile Video Coding (VVC);

[0071] VVC Test Model (VTM), a reference software testing platform for VVC;

[0072] Intra Template Matching Prediction (Intra TMP);

[0073] Beyond VVC's reference software testing platform (Enhanced Compression Model, ECM).

[0074] It can be understood that in a video image, a first color component, a second color component, and a third color component are generally used to represent a coding block. These three color components are a luminance component, a blue chrominance component, and a red chrominance component. Specifically, the luminance component is usually represented by the symbol Y, the blue chrominance component is usually represented by the symbol Cb or U, and the red chrominance component is usually represented by the symbol Cr or V. Thus, a video image can be represented in either the YCbCr format or the YUV format.

[0075] Most video coding standards use a block-based hybrid coding framework. Each image, sub-image, or frame in a video is divided into square largest coding units (LCUs) or coding tree units (CTUs) of the same size (e.g., 128x128 or 64x64). Each LCU or CTU can be divided into rectangular coding units (CUs) according to a rule. Coding units may also be divided into prediction units (PUs) and / or transform units (TUs). The hybrid coding 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 in a video frame, intra prediction is used in video coding technology to eliminate spatial redundancy between adjacent samples. Since there is a strong similarity between adjacent frames in a video, the inter-frame prediction method is used in video coding and decoding technology to eliminate the temporal redundancy between adjacent frames, thereby improving coding and decoding efficiency.

[0076] The basic process of a video codec is shown in Figure 1. At the encoder, a frame of image 101 is divided into blocks. Intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block for the current block. The prediction block is subtracted from the original block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. This quantization coefficient matrix is ​​entropy encoded and output as a bitstream. At the decoder (not shown), intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block for the current block. The bitstream is then parsed to obtain a quantization coefficient matrix. This quantization coefficient matrix is ​​inversely quantized and inversely transformed to obtain a residual block. The prediction block and residual block are added together to obtain a reconstructed block. The reconstructed blocks form a reconstructed image, which is then subjected to image-based or block-based loop filtering to obtain a decoded image. The encoder also performs similar operations as the decoder to obtain a decoded image. The decoded image can be used as a reference image for inter-frame prediction in subsequent frames. Block division information, prediction, transform, quantization, entropy coding, and loop filtering mode information or parameter information determined by the encoder, if necessary, are included in the output bitstream. The decoder uses parsing and analysis based on existing information to determine the same block division information, prediction, transform, quantization, entropy coding, and loop filtering mode or parameter information as the encoder, thereby ensuring that the decoded image obtained by the encoder and the decoder are identical. The decoded image obtained by the encoder is often called the reconstructed image. During prediction, the current block can be divided into prediction units, and during transform, the current block can be divided into transform units. The division of prediction units and transform units can be different.

[0077] The above is the basic process of the video codec under the block-based hybrid coding framework. As technology develops, some modules or steps of the framework or process may be optimized. The encoding and decoding method provided in the embodiment of the present application is applicable to the basic process of the video codec under the block-based hybrid coding framework, but is not limited to this framework and process. It is known to those skilled in the art that with the evolution of encoders and decoders and the emergence of new business scenarios, the method provided in the embodiment of the present application is also applicable to similar technical problems.

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

[0079] It can be understood that there is a strong spatial correlation between adjacent parts or adjacent samples within an image. Intra-frame prediction is a method of prediction that utilizes the spatial correlation between the encoded and decoded samples around the current block and the samples within the current block. For example, as shown in Figure 2, the white 4x4 block is the current block, and the gray samples in the column to the left and the row above the current block are the reference samples of the current block. Intra-frame prediction uses these reference samples to predict the current block. These reference samples may all be available, that is, all encoded and decoded. Or some may not be available. For example, if the current block is at the leftmost part of the entire frame, then the reference samples to the left of the current block are not available. Or, when encoding and decoding the current block, the lower left portion of the current block has not yet been encoded and decoded, then the reference samples to the lower left are also not available. In the case where reference samples are unavailable, available reference samples, certain values, or certain methods can be used for padding, or no padding can be performed.

[0080] The Multiple Reference Line (MRL) intra prediction method can use more reference samples, thereby improving coding efficiency. Figure 3 shows an example of using four reference rows / columns.

[0081] There are multiple intra-frame prediction modes. Figure 4 shows the nine intra-frame prediction modes for 4x4 blocks in H.264. Mode 0 copies the samples above the current block vertically to the current block as the prediction value. Mode 1 copies the reference samples on the left side horizontally to the current block as the prediction value. Mode 2 (i.e., DC mode) uses the average of the eight points A to D and I to L as the prediction value for all points. Modes 3 to 8 copy the reference samples to the corresponding positions of the current block at a certain angle (therefore, modes 3 to 8 are also called angular prediction modes). Because some positions of the current block cannot correspond exactly to the reference samples, it is necessary to use the weighted average of the reference samples, or interpolated sub-samples (sub-pixels) of the reference samples.

[0082] In addition, there are modes such as Plane and Planar. With technological advancements and the expansion of block sizes, the number of angular prediction modes is also increasing. As shown in Figure 5, HEVC uses intra-frame prediction modes including Planar, DC, and 33 angular modes, for a total of 35 prediction modes. As shown in Figure 6, VVC uses intra-frame modes including Planar, DC, and 65 angular 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 rectangular blocks with a large difference between length and width. These modes, indicated by the dotted lines in Figure 7, are in the ranges -14 to -1 and 67 to 80 degrees. These modes replace some conventional modes. As shown in Figure 8, AVS3 uses DC, Plane, Bilinear, PCM, and 62 angular modes, for a total of 66 prediction modes.

[0083] Videos are composed of multiple images. To ensure a smooth video appearance, each second of video contains dozens or even hundreds of frames, such as 24, 30, 50, 60, or 120 frames per second. This results in significant temporal redundancy in the video. In other words, there is a high degree of temporal correlation in the video. Inter-frame prediction exploits this temporal correlation to improve compression efficiency. Inter-frame prediction often uses motion to exploit temporal correlation. A very simple motion model is that an object is at a certain position in the image corresponding to a certain moment. After a certain period of time, it moves to another position in the image corresponding to the same moment. This is a basic and commonly used translational motion in video codecs. Inter-frame prediction uses motion information to represent motion. Basic motion information includes information about the reference frame (or reference picture) and motion vectors (MVs). The codec determines the reference picture based on the reference picture information and the coordinates of the reference block based on the motion vector information and the coordinates of the current block. The reference block is determined by the coordinates of the reference block in the reference picture. Using a determined reference block as a prediction block is the most basic prediction method for inter-frame prediction.

[0084] Motion in videos isn't always simple. Even motion that can be considered translation can exhibit subtle changes over time, including subtle deformations, brightness variations, and noise variations. More than one reference block can be used to predict the current block, achieving better prediction results. For example, bidirectional prediction uses two reference blocks to predict the current block. These two reference blocks can be a forward reference block and a backward reference block. It's also possible for both reference blocks to be forward or backward. Forward means the reference image corresponds to a moment before the current frame, while backward means it corresponds to a moment after the current frame. Alternatively, forward means the reference image's position in the video is before the current frame, while backward means it's after the current frame. Alternatively, forward means the reference image's POC (picture order count) is less than the current frame's POC, while backward means the reference image's POC is greater than the current frame's POC. Future video codec standards may support prediction using multiple reference blocks. A simple method for generating a prediction block using two reference blocks is to average the pixel values ​​at corresponding positions in the two reference blocks. To achieve better prediction results, weighted averaging can also be used, such as the BCW (Bi-prediction with CU-level weights) used by VVC. VVC's GPM (Geometric Partitioning Mode) can also be understood as a special form of bidirectional prediction. To use bidirectional prediction, two reference blocks must be available, which requires information from two sets of reference images and motion vectors.

[0085] Motion in videos isn't limited to simple translation; it also includes scaling, rotation, distortion, and various other complex motions. VVC uses affine to simulate some of these simple motions. The affine model in VVC uses two or three control points, based on which a linear model is used to derive the motion vector for each sub-block within the current block. The reason we only mention motion vectors here, rather than motion information, is because they both refer to the same reference image. While ordinary translational motion involves finding a "whole block" from a reference image, affine motion involves finding a group of non-close-to-one "sub-blocks" from the reference image. While the above descriptions are all about unidirectional prediction, affine can also implement bidirectional prediction and prediction of more "reference blocks." The reference blocks mentioned here are composed of sub-blocks. In practice, a single unidirectional motion information block in the affine motion information data structure can include information about one reference image and two to three motion vectors, or information about two to three groups of reference images and motion vectors, but the information for these reference images is the same.

[0086] Intra Block Copy (IBC) significantly improves the compression efficiency of screen content coding, and is therefore used in screen content coding from HEVC to VVC. Screen content, unlike camera-captured content, is computer-generated. Screen content is noise-free, contains text and computer graphics, and has sharp boundaries. Screen content often contains a large amount of repetitive content. As shown in Figure 9, the content within the two boxes in the first row is repeated, and the content within the boxes in the third and fourth rows is repeated.

[0087] As mentioned above, inter-frame prediction uses a reference block in a reference image as the prediction block for the current block. The reference image is not the current image. In contrast, IBC uses a block from the coded and decoded portion of the current image (called the reconstructed portion) as the prediction block for the current block. IBC is also sometimes referred to as intra picture block compensation or current picture referencing (CPR). In this embodiment, the name of IBC is not limited; unless otherwise specified, the aforementioned names are equivalent or interchangeable.

[0088] IBC uses a block vector (BV) to represent the position difference between the current block and the reference block. The encoder uses block matching within the search range to determine the best matching block for the current block and encodes the BV. There are multiple methods for encoding the BV, which are not detailed here. IBC can be considered an intra-frame prediction method, or a different type of prediction method independent of intra-frame prediction and inter-frame prediction.

[0089] The Template Matching (TM) method was first used in inter-frame prediction. This method exploits the correlation between adjacent samples and uses areas surrounding the current block as templates. When the current block is encoded or decoded, its left and upper sides have already been encoded and decoded according to the coding order. However, hardware decoder implementations cannot guarantee that the left and upper sides of the current block have already been decoded when decoding begins. This applies to inter-frame blocks. For example, in HEVC, the prediction process for inter-frame coded blocks does not require surrounding reconstructed samples, allowing the prediction process for inter-frame blocks to proceed in parallel. However, intra-frame coded blocks require reconstructed samples on the left and upper sides as reference samples. Theoretically, the left and upper sides of the current block are available, meaning that this is achievable with appropriate hardware design adjustments. In contrast, the right and lower sides of the current block are not available under the coding order specified in video standards (such as VVC).

[0090] 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, but can also be different. The best matching position of the template is found in the reference frame 1003 of the current frame 1002 to determine the motion information, or motion vector, of the current block 1001. This process can be roughly described as starting from a starting position in a reference frame and searching within a certain range around it. Search rules, such as the search range and search step size, can be predefined. At each position, the degree of match between the template corresponding to that position and the templates surrounding the current block is calculated. The degree of match can be measured using some distortion cost, such as SAD (sum of absolute difference), SATD (sum of absolute transformed difference), or MSE (mean-square error). A smaller SAD, SATD, or MSE value indicates a higher degree of match. The transform used for SATD can be the Hadamard transform. The cost is calculated using the predicted block of the template corresponding to the location and the reconstructed blocks of the template surrounding the current block. In addition to searching at whole-pixel locations, sub-pixel locations can also be searched, with the position with the highest degree of match found determining the motion information for the current block. By leveraging the correlation between adjacent samples, the appropriate motion information for the template may also be appropriate for the current block. Of course, template matching may not be applicable to all blocks, so methods can be used to determine whether template matching should be used for the current block, such as using a control switch to indicate whether template matching should be used for the current block. Template matching techniques include DMVD (decoder-side motion vector derivation). Both the encoder and decoder can use the template to search to derive motion information or find better motion information based on the existing motion information. This method does not require the transmission of specific motion vectors or motion vector differences; instead, both the encoder and decoder perform the same search rules to ensure consistent encoding and decoding. Template matching can improve compression performance, but it requires a "search" in the decoder, which increases decoder complexity.

[0091] Intra-template matching prediction (intraTMP) is also a prediction technique. As mentioned above, TM can reduce the overhead of encoding MVs, meaning that TM can also reduce the overhead of encoding BVs. For example, instead of encoding BVs, the matching block found by TM can be used directly as the intraTMP prediction block for the current block.

[0092] Figure 11 shows an example of intraTMP. The inverted L-shaped area 111 in the upper left corner of the current block 110 is used as a template. A search is performed within a search range 112, which represents the reconstructed area. Region 112 includes the current CTU in R1, the CTU to the upper left of R2, the CTU above R3, and the CTU to the left of R4. This is just an example; the search range will vary in actual applications. The example in Figure 11 finds the best matching block 113 in R2.

[0093] As mentioned above, a key reason IBC significantly improves the compression efficiency of screen content encoding is that screen content often contains repeated blocks. Screen content typically has sharp boundaries, and in terms of color (brightness and chroma), there can be patches of identical color (brightness and chroma). Camera-captured content also contains nearly repeated blocks. Even after accounting for noise, subtle brightness variations, and perspective, repeated textures are undeniably present in camera-captured content.

[0094] intraTMP will use the best matching block found by template matching as its final prediction block. That is to say, in the related art, when decoding the current block, there will be a flag to determine whether the current block uses intraTMP. If the current block uses intraTMP, the decoder will use the template matching method to find a best matching block and use the value of the best matching block as the prediction value of the current block. We know that although the template has a strong correlation with the current block, the template is not the current block after all. The best matching block found by the template (actually the position of the current block corresponding to the best matching block of the template) may not necessarily be the best matching block of the current block. However, the decoder does not have the current block when searching, so it can only use the best matching block found by the template as the best matching block found by intraTMP.

[0095] To further improve the accuracy of the prediction, you can choose to set N candidates for intraTMP, or set a candidate list intraTmpCandList[N] of length N. During encoding, if the current block uses intraTMP, after encoding the flag, you need to encode an index to determine which of the N candidates is selected for the current block. Accordingly, the decoding syntax is as follows, where intra_tmp_flag is the flag for intraTMP. If intra_tmp_flag is true, then continue to parse intra_tmp_idx, which represents the index of the selected candidate.

[0096]

[0097] The decoder uses the block corresponding to intraTmpCandList[intra_tmp_idx] as the block selected by intraTMP, or in other words, uses the BV corresponding to intraTmpCandList[intra_tmp_idx] as the BV selected by intraTMP.

[0098] When constructing intraTmpCandList, intraTMP calculates the cost of the template under each BV each time it searches it. The template cost is generally the cost of matching the template of the current block with the template of a block of the same size as the current block, as determined by the current BV. This cost can be SAD, SATD, SSE, etc. IntraTMP can sort the searched blocks or BVs in ascending order according to these costs, with the top N candidates becoming the N candidates for intraTmpCandList. Alternatively, only the top N candidates with the lowest cost are maintained, and candidates ranked above N can be discarded, thus saving computational effort.

[0099] Typically, blocks corresponding to adjacent BVs are relatively close, especially if the BV supports sub-pixel precision, such as 1 / 2, 1 / 4, 1 / 8, or 1 / 16. Uncontrolled sorting based solely on template cost can easily lead to concentrating multiple candidates within a small range. Therefore, some control is required to prevent excessive concentration of candidate BVs in intraTmpCandList.

[0100] Furthermore, during the search process, not every possible BV is searched sequentially. For example, the usual search order is from left to right and from top to bottom. Generally speaking, integer-pixel BVs can be searched sequentially. If the current BV being searched is (x0, y0), the next one is (x0+1, y0), provided that the search range boundary has not been reached. However, here, we can first perform a sparse search. For example, for integer-pixel BVs, if the current BV being searched is (x0, y0), the next one is (x0+3, y0), provided that the search range boundary has not been reached. In other words, template matching is performed every certain number of pixels, or every certain step size. The step size here can be a preset value, such as 2, 3, 4, 8, etc. Of course, the same process can be applied vertically. First, find the K BVs with the lowest cost, where K may be equal to N, or greater than or less than N. This process can be achieved by constructing a list, namely, a candidate list of length K. Next, based on the K lowest-cost BVs, each BV is refined within a small range. For example, if the search interval is 3 pixels, the refinement range can be set to 3x3. The refined BVs can be used to construct a candidate list of length N. This results in N BV candidates.

[0101] Figure 12 shows the first search diagram, and Figure 13 shows the second search diagram. For example, let N be 3. In the first step, a first search is performed using a preset step size. The upper left corner of the searched block is shown as the dark dot in Figure 12. A certain number of sorted BVs, such as 3 BVs, are found. The upper left corner of the corresponding block is shown as the dark dot in Figure 13. Here, the horizontal step size is 3, and the vertical step size is also 3.

[0102] In the second step, a second search is performed based on the three sorted BVs. This time, the search range is 4x4, as shown by the dark dots in Figure 13. Every BV in each 3x3 range participates in the sorting of intraTmpCandList. Of course, if the BV with the lowest cost is still the original BV, there is no need to re-sort it.

[0103] If sub-pixel accuracy is supported, the BV can be further refined to sub-pixel levels. For example, a 1 / 2 pixel search can be performed within a pixel range above, below, left, and right based on the whole pixel BV selected in the second step.

[0104] It should be noted that the construction of the candidate list is done by both the encoding end and the decoding end, so as to ensure that the candidate list obtained by the encoding end and the candidate list obtained by the decoding end are consistent.

[0105] During the binarization of intra_tmp_idx, considering that intraTmpCandList is sorted, statistically speaking, the higher the candidate number, the greater the probability of being selected. Therefore, variable-length encoding can be used for the binarization and debinarization of intra_tmp_idx, as shown in Table 1 below, or a truncated unary can be used.

[0106] Table 1

[0107] Of course, if the probabilities are similar, you can use fixed-length encoding or truncated binary.

[0108] If N is large, the probability of the candidate at the beginning is high, while the probability decreases toward the end, and the probabilities become closer toward the end. Therefore, the codewords at the beginning can be shorter than those at the end, and some of the later candidates can use the same code length. For example, as shown in Table 2, where N is 15, indexes 3 to 6 use codewords of the same length, and indexes 7 to 14 use codewords of the same length. The x in the table can be obtained using truncated binary.

[0109] Table 2

[0110] Figure 14 is a schematic diagram of the template type 1. As shown in Figure 14, the template currently used by intraTmp 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. In some other technologies that use template matching, some templates do not use upper-left adjacent samples.

[0111] In addition to the complete template, a portion of the area can also be used as a template, such as the upper template and left template shown in Figure 14. For convenience, the complete template (inverted L or T+L) is collectively referred to as the TL template, the upper template is called the T template, and the left template is called the L template. A variety of different templates can provide more options. We use template matching to estimate the current block using the template, assuming that blocks with a high template match also have a high match with the current block. However, video content is diverse, especially images captured by cameras. Assuming that the texture changes on both the left and right sides near the left edge of the current block, then using only the T template may be more appropriate than the TL template. Similarly, assuming that the texture changes on both the top and bottom sides near the top edge of the current block, then using only the L template may be more appropriate than the TL template.

[0112] Of course, the template can also include reconstruction samples for the upper right and lower left sides. For example, the T template extends to the right a certain distance in addition to the portion shown in the figure, and the L template extends downward a certain distance in addition to the portion shown in the figure. Alternatively, in addition to the T and L templates, a template for the upper right and lower left sides can be added.

[0113] In summary, the intraTMP multi-candidate method uses templates to filter a small number of promising candidates from a vast number of possible BVs. The encoder then selects one candidate to determine the reference block or prediction block for the current block. Due to the correlation between the current block and the template, the template can effectively filter out most unreasonable BVs. Furthermore, the encoder has access to the original pixel values ​​of the current block, enabling more accurate judgments than the decoder. This collaborative approach between the encoder and decoder achieves improved compression efficiency.

[0114] Since the template cannot represent the current block, intraTMP multiple candidates provide a variety of options to improve compression efficiency, and templates of different shapes provide multiple options at the template level. Therefore, the combination of intraTMP multiple candidates and multiple template types can provide better compression efficiency.

[0115] The embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder, and a storage medium, wherein the encoder and decoder determine a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; a block vector candidate list corresponding to the current block is determined based on the first template; a block vector corresponding to the current block is determined based on the block vector candidate list corresponding to the current block, and a prediction value of the current block is determined based on the block vector. Thus, in the embodiment of the present application, a prediction method combining intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected, and a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing a combination of intraTMP multiple candidates and multiple selections at the template level. That is, the coding and decoding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and encoding and decoding performance.

[0116] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0117] Referring to Figure 15, which shows a schematic block diagram of the composition of an encoder provided in an embodiment of the present application. As shown in Figure 15, the encoder (specifically, a "video encoder") 100 may include a transform and quantization unit 101, an intra-frame estimation unit 102, an intra-frame 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 decoded image cache unit 110, etc., wherein 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 can be obtained by dividing the coding tree unit (CTU). Then, the residual pixel information obtained after intra-frame or inter-frame prediction is transformed by the transformation and quantization unit 101, including transforming the residual information from the pixel domain to the transform domain and quantizing the obtained transform coefficients to further reduce the bit rate; the intra-frame estimation unit 102 and the intra-frame prediction unit 103 are used to perform intra-frame prediction on the video coding block. Specifically, the intra-frame estimation unit 102 and the intra-frame prediction unit 103 are used to determine the intra-frame prediction mode to be used to encode the video coding block; the motion compensation unit 104 and the motion estimation unit 105 are used to perform inter-frame prediction coding on the received video coding block relative to one or more blocks in one or more reference frames to provide temporal prediction information; the motion estimation performed by the motion estimation unit 105 is the process of generating a motion vector, which can estimate the motion of the video coding block. The motion compensation unit 104 then calculates the motion vector based on the motion vector determined by the motion estimation unit 105. After determining the intra-frame prediction mode, the intra-frame prediction unit 103 is further configured to provide the selected intra-frame prediction data to the encoding unit 109, and the motion estimation unit 105 also sends the calculated motion vector data to the encoding unit 109. In addition, the inverse transform and inverse quantization unit 106 is configured to reconstruct the video coding block and reconstruct a residual block in the pixel domain. The reconstructed residual block is subjected to the filter control analysis unit 107 and the filtering unit 108 to remove the block effect artifacts. The reconstructed residual block is then added to a predictive block in the frame of the decoded image buffer unit 110 to generate a reconstructed video coding block. The encoding unit 109 is configured to encode various coding parameters and quantized transform coefficients. In the CABAC-based coding algorithm, the context content can be based on adjacent coding blocks and can be used to encode information indicating the determined intra-frame prediction mode, and output the code stream of the video signal. The decoded image buffer unit 110 is configured to store the reconstructed video coding block for prediction reference. As the video image encoding proceeds, new reconstructed video encoding blocks are continuously generated, and these reconstructed video encoding blocks are stored in the decoded image buffer unit 110 .

[0118] Referring to Figure 16 , which shows a schematic block diagram of a decoder provided in an embodiment of the present application, as shown in Figure 16 , the decoder (specifically, a "video decoder") 200 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra-frame prediction unit 203, a motion compensation unit 204, a filtering unit 205, and a decoded image buffer unit 206. The decoding unit 201 can implement header information decoding and CABAC decoding, and the filtering unit 205 can implement deblocking filtering and SAO filtering. After the input video signal is coded as shown in FIG15 , a code stream of the video signal is output; the code stream is input to the decoder 200 and first passes through the decoding unit 201 to obtain decoded transform coefficients; the transform coefficients are processed by the inverse transform and inverse quantization unit 202 to generate a residual block in the pixel domain; the intra-frame prediction unit 203 can be used to generate prediction data for the current video decoding block based on the determined intra-frame prediction mode and data from the previously decoded block of the current frame or picture; the motion compensation unit 204 determines the prediction information for the video decoding block by analyzing the motion vector and other associated syntax elements, and uses The prediction information is used to generate a predictive block for the video decoding block being decoded; a decoded video block is formed by summing the residual block from the inverse transform and inverse quantization unit 202 with the corresponding predictive block generated by the intra-frame prediction unit 203 or the motion compensation unit 204; the decoded video signal passes through the filtering unit 205 to remove blocking artifacts, thereby improving video quality; the decoded video block is then stored in the decoded image buffer unit 206, which stores reference images used for subsequent intra-frame prediction or motion compensation, and is also used for outputting the video signal, thereby obtaining the restored original video signal.

[0119] Furthermore, the embodiment of the present application also provides a network architecture of a coding and decoding system including an encoder and a decoder, wherein Figure 17 shows a schematic diagram of the network architecture of a coding and decoding system provided by the embodiment of the present application. As shown in Figure 17, the network architecture includes one or more electronic devices 13 to 1N and a communication network 01, wherein the electronic devices 13 to 1N can perform video interaction through the communication network 01. During implementation, the electronic device can be various types of devices with video coding and decoding functions. For example, the electronic device can include a smart phone, a tablet computer, a personal computer, a personal digital assistant, a navigator, a digital phone, a video phone, a television, a sensing device, a server, etc., and the embodiment of the present application is not specifically limited. Here, the decoder or encoder described in the embodiment of the present application can be the above-mentioned electronic device.

[0120] It should be noted that the method of the embodiment of the present application is mainly applied to the intra-frame prediction unit 103 shown in Figure 15 and the intra-frame prediction unit 203 shown in Figure 16. In other words, the embodiment of the present application can be applied to both the encoder and the decoder, and can even be applied to both the encoder and the decoder at the same time, but the embodiment of the present application is not specifically limited thereto.

[0121] It should also be noted that, when applied to the intra-frame prediction unit 103, the "current block" specifically refers to the coding block currently to be intra-frame predicted; when applied to the intra-frame prediction unit 203, the "current block" specifically refers to the decoding block currently to be intra-frame predicted.

[0122] An embodiment of the present application provides a decoding method, which is applied to a decoder. FIG18 is a flowchart of the decoding method provided by the embodiment of the present application. As shown in FIG18 , the decoding method performed by the decoder may include the following steps:

[0123] Step 101: Determine a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block.

[0124] In an embodiment of the present application, a first template corresponding to the current block may be determined first.

[0125] It should be noted that the decoding method in the embodiment of the present application is applied to a decoder. Furthermore, the decoding method may include an intra-frame prediction method, more specifically, a color component prediction method. A video image may be divided into multiple decoding blocks, each of which may include a first color component, a second color component, and a third color component. The current block in the embodiment of the present application refers to a decoding block in the video image that is currently to be intra-frame predicted.

[0126] Here, when the first color component needs to be predicted, the component to be predicted is the first color component; when the second color component needs to be predicted, the component to be predicted is the second color component; when the third color component needs to be predicted, the component to be predicted is the third color component. In addition, assuming that the current block predicts the first color component and the first color component is the luminance component, that is, the component to be predicted is the luminance component, then the current block can also be called a luminance block; or assuming that the current block predicts the second color component and the second color component is the chrominance component, that is, the component to be predicted is the chrominance component, then the current block can also be called a chrominance block.

[0127] It should be noted that, in the embodiment of the present application, the first template corresponding to the current block may be any number of candidate templates in the template set corresponding to the current block, wherein the candidate templates corresponding to the current block include candidate templates of multiple different template types.

[0128] It is understandable that in the embodiment of the present application, a template set corresponding to the current block can be constructed based on different template types, and then any number of candidate templates can be selected from the template set as the first template corresponding to the current block.

[0129] Illustratively, in an embodiment of the present application, Figure 19 is a second schematic diagram of the template type. As shown in Figure 19, when the upper left reference sample, the upper reference sample, and the 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 the upper left reference sample are available, the template shape is as shown in (d); when only the left reference sample and the lower left reference sample are available, the template shape is as shown in (e); when only the upper reference sample and the upper right reference sample are available, the template shape is as shown in (f).

[0130] Furthermore, in an embodiment of the present application, when constructing a template set corresponding to the current block based on the template type, the template reference sample of the current block can be determined based on the template type and the template size corresponding to the template type, and then the candidate template of the current block can be determined based on the template reference sample, and finally the construction of the template set is completed.

[0131] For example, in an embodiment of the present application, Figure 20 is a schematic diagram of candidate templates. As shown in Figure 20, corresponding to four different template types, the candidate templates of the current block finally 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).

[0132] Furthermore, in an embodiment of the present application, the first template corresponding to the current block is determined based on candidate templates in the template set, wherein the first template may include any number of candidate templates.

[0133] It should be noted that, in an embodiment of the present application, the first candidate template in the template set may be a template including the left adjacent reconstructed samples and the upper adjacent reconstructed samples of the current block, such as the TL template; the second candidate template in the template set may be a template including the upper adjacent reconstructed samples of the current block, such as the T template; the third candidate template in the template set may be a template including the left adjacent reconstructed samples of the current block, such as the L template.

[0134] Exemplarily, in some embodiments, the first template corresponding to the current block may be the first candidate template in the template set corresponding to the current block, such as candidate template 1.

[0135] Exemplarily, in some embodiments, the first template corresponding to the current block may be the first candidate template and the second candidate template in the template set corresponding to the current block, such as candidate template 1 and candidate template 3.

[0136] Exemplarily, in some embodiments, the first template corresponding to the current block may be the first candidate template, the second candidate template, and the third candidate template in the template set corresponding to the current block, such as candidate template 1, candidate template 3, and candidate template 4.

[0137] Furthermore, in an embodiment of the present application, the decoded code stream can determine the template matching prediction identification information corresponding to the current block; if the value of the template matching prediction identification information is the first value, then the first template determination process can be executed, that is, the processing process for determining the first template proposed in step 101 can be executed.

[0138] It can be understood that, in the embodiment of the present application, the template matching prediction identification information can be used to determine whether the current block uses template matching prediction, that is, the template matching prediction identification information can indicate whether the current block is predicted through intraTMP.

[0139] For example, in some embodiments, the decoded code stream may determine a variable serving as the template matching prediction identification information, and thus the template matching prediction identification information may be determined by taking the value of the variable.

[0140] It should be noted that, in the present application, the value of the template matching prediction identification information can be the first value or the second value. Specifically, different values ​​of the template matching prediction identification information result in different methods for determining the prediction value of the current block. Specifically, based on the value of the template matching prediction identification information, when determining the prediction value of the current block, intraTMP can be used or not used.

[0141] For example, in some embodiments, the template matching prediction flag information can be understood as a flag indicating whether to perform intraTMP. If the value of the template matching prediction flag information is a first value, then intraTMP can be selected to determine the prediction value of the current block; if the value of the template matching prediction flag information is a second value, then intraTMP can be selected not to determine the prediction value of the current block.

[0142] For example, in some embodiments, the first value may be set to 1 and the second value may be set to 0; the first value may also be set to true and the second value may be set to false. This application does not impose any limitation.

[0143] Exemplarily, in some embodiments, the flag intra_tmp_flag may be used to represent the template matching prediction identification information, that is, intra_tmp_flag is used as the flag of intraTMP.

[0144] Exemplarily, in some embodiments, if the value of intra_tmp_flag is 1, it may indicate that intraTMP is selected to determine the prediction value of the current block; if the value of intra_tmp_flag is 0, it may indicate that intraTMP is not selected to determine the prediction value of the current block.

[0145] It can be understood that in an embodiment of the present application, when the value of the template matching prediction identification information is the first value, that is, after determining the prediction value of the current block using intraTMP based on the value of the template matching prediction identification information, the determination process of the first template corresponding to the current block can be executed.

[0146] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, the code stream is decoded to determine the first template indication information corresponding to the current block; if the value of the first template indication information is the third value, then the first template can be determined as the first candidate template.

[0147] It should be noted that, in the embodiment of the present application, the first candidate template may be a candidate template in the template set corresponding to the current block. For example, the first candidate template may be the TL template in the template set.

[0148] It can be understood that in the embodiment of the present application, the first template indication information can be used to determine whether the current block uses the first candidate template, that is, the first template indication information can indicate whether the current block uses the first candidate template to perform intraTMP prediction processing.

[0149] Exemplarily, in some embodiments, the decoded code stream may determine a variable as the first template indication information, so that the first template indication information may be determined by taking a value of the variable.

[0150] It should be noted that, in the present application, the value of the first template indication information may be the third value or the fourth value. Specifically, based on the value of the first template indication information, when performing intraTMP, one may choose to use the first candidate template, or may choose not to use the first candidate template and use other templates, such as other templates in the template set other than the first candidate template.

[0151] For example, in some embodiments, the third value may be set to 0 and the fourth value may be set to 1; the third value may also be set to false and the fourth value may be set to true. This application does not impose any limitation.

[0152] For example, in some embodiments, the flag intra_tmp_alternative_template_flag may be used to indicate the first template indication information. For example, if the value of intra_tmp_alternative_template_flag is 0, it may indicate that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_alternative_template_flag is 1, it may indicate that the first candidate template is not determined as the first template corresponding to the current block, but other templates are selected as the first template corresponding to the current block.

[0153] Correspondingly, in an embodiment of the present application, after determining the first template indication information corresponding to the current block, if the value of the first template indication information is the fourth value, then it can be determined that the first template is not the first candidate template, and then it is necessary to further determine the second template indication information corresponding to the current block.

[0154] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, the code stream is decoded to determine the second template indication information corresponding to the current block; if the value of the second template indication information is the fifth value, then the first template can be determined as the second candidate template; if the value of the second template indication information is the sixth value, then the first template can be determined as the third candidate template.

[0155] It should be noted that, in the embodiment of the present application, the second candidate template and the third candidate template can be a candidate template in the template set corresponding to the current block. For example, the second candidate template can be a T template in the template set, and the third candidate template can be an L template in the template set.

[0156] It can be understood that in an embodiment of the present application, the second template indication 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 indication information can indicate whether the current block uses the second candidate template and / or the third candidate template to perform intraTMP prediction processing.

[0157] Exemplarily, in some embodiments, the decoded code stream may determine a variable as the second template indication information, so that the second template indication information may be determined by taking a value of the variable.

[0158] It should be noted that, in this application, the value of the second template indication information may be the fifth value or the sixth value. Specifically, based on the value of the second template indication information, the second candidate template or the third candidate template may be selected for use during intraTMP.

[0159] For example, in some embodiments, the fifth value may be set to 0 and the sixth value may be set to 1; the fifth value may also be set to false and the sixth value may be set to true. This application does not impose any limitation.

[0160] For example, in some embodiments, the flag intra_tmp_template_idx may be used to indicate the second template indication information. For example, if the value of intra_tmp_template_idx is 0, it may indicate that the second candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it may indicate that the third candidate template is determined as the first template corresponding to the current block.

[0161] That is, in the embodiment of the present application, it is possible to select in the code stream which candidate template in the template set the first template corresponding to the current block is to be indicated as, for example, by using first template indication information and second template indication information to indicate the first template.

[0162] For example, in some embodiments, taking 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. The flag intra_tmp_flag indicates template matching prediction identification information, the flag intra_tmp_alternative_template_flag indicates first template indication information, and the flag intra_tmp_template_idx indicates second template indication information. Then, the information in the decoded bitstream is as follows:

[0163] Among them, the template matching prediction identification information intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, the decoder parses intra_tmp_alternative_template_flag. The first template indication information intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that 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. The second template indication information intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.

[0164] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, the code stream is decoded to determine the third template indication information corresponding to the current block; if the value of the third template indication information is the seventh value, then the first template can be determined as the first candidate template; if the value of the third template indication information is the eighth value, then the first template can be determined as the second candidate template; if the value of the third template indication information is the ninth value, then the first template can be determined as the third candidate template.

[0165] It should be noted that in the embodiments of the present application, the first candidate template, the second candidate template, and the third candidate template can each be a candidate template in the template set corresponding to the current block. For example, the first candidate template can be the TL template in the template set, the second candidate template can be the T template in the template set, and the third candidate template can be the L template in the template set.

[0166] It can be understood that in an embodiment of the present application, the third template indication information can be used to determine whether the current block uses the first candidate template and / or the second candidate template and / or the third candidate template, that is, the third template indication information can indicate whether the current block uses the first candidate template and / or the second candidate template and / or the third candidate template to perform intraTMP prediction processing.

[0167] Exemplarily, in some embodiments, the decoded code stream may be used to determine a variable as the third template indication information, so that the third template indication information may be determined by taking a value of the variable.

[0168] It should be noted that, in this application, the value of the third template indication information can be the seventh value, the eighth value, or the ninth value. Specifically, based on the value of the third template indication information, when performing intraTMP, you can choose to use the first candidate template, the second candidate template, or the third candidate template.

[0169] For example, in some embodiments, the seventh value may be set to 0, the eighth value may be set to 1, and the ninth value may be set to 2, and this application does not impose any limitation thereto.

[0170] Exemplarily, in some embodiments, the flag intra_tmp_template_idx may also be used to indicate third template indication information. For example, if the value of intra_tmp_template_idx is 0, it may indicate that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it may indicate that the second candidate template is determined as the first template corresponding to the current block; and if the value of intra_tmp_template_idx is 2, it may indicate that the third candidate template is determined as the first template corresponding to the current block.

[0171] That is, in the embodiment of the present application, it is possible to select in the code stream which candidate template in the template set the first template corresponding to the current block is to be indicated as, for example, by using the third template indication information to indicate the first template.

[0172] Exemplarily, in some embodiments, the first template indication information intra_tmp_alternative_template_flag and the second template indication information intra_tmp_template_idx may be merged into the same syntax element intra_tmp_template_idx, that is, merged into the third template indication information.

[0173] For example, in some embodiments, taking the 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, and the third candidate template is the L template. The flag intra_tmp_template_idx indicates the third template indication information. Then, the information in the decoded bitstream is as follows:

[0174] Among them, the template matching prediction identification information Intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, the decoder parses intra_tmp_template_idx, and the third template indication information intra_tmp_template_idx indicates that the current block uses TL template, T template or L template. If the value of intra_tmp_template_idx is 0, it means that the current block uses TL template. If the value of intra_tmp_template_idx is 1, it means that the current block uses T template. If the value of intra_tmp_template_idx is 2, it means that the current block uses L template.

[0175] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, the code stream is decoded to determine the candidate index corresponding to the current block; if the value of the candidate index is less than or equal to a preset threshold, the first template is determined to be the first candidate template.

[0176] Accordingly, in an embodiment of the present application, after the candidate index corresponding to the current block is determined by decoding the code stream, if the value of the candidate index is greater than a preset threshold, the code stream is decoded to determine the third template indication information corresponding to the current block; if the value of the third template indication information is the seventh value, the first template is determined to be the first candidate template; if the value of the third template indication information is the eighth value, the first template is determined to be the second candidate template; if the value of the third template indication information is the ninth value, the first template is determined to be the third candidate template.

[0177] It should be noted that, in an embodiment of the present application, a preset threshold can be used to determine whether to directly use the first candidate template, wherein, if the value of the candidate index corresponding to the current block is greater than (or greater than or equal to) the preset threshold, then the third template indication information is selected to continue to be used to determine the first template to be used; if the value of the candidate index corresponding to the current block is less than or equal to (or less than) the preset threshold, then the first candidate template can be directly determined as the first template corresponding to the current block.

[0178] It can be understood that in an embodiment of the present application, it is possible to choose to first decode the code stream to determine the candidate index corresponding to the current block, and combine the candidate index and the preset threshold to determine whether to determine the first candidate template in the template set as the first template. In this way, the first candidate template can be given a higher priority than other candidate templates, that is, first determine whether to use the first candidate template.

[0179] Understandably, because the TL template covers more adjacent areas and, in most cases, the texture is continuous from the left and top, it is often more valuable as a reference than the separate T and L templates. Therefore, the TL template is often chosen, with the separate T and L templates serving more as supplementary choices. Based on this distribution pattern, the TL template can be given a higher priority than the T and L templates.

[0180] That is, in the embodiments of the present application, the candidate index of the current block can be used to indirectly determine whether to use a higher-priority TL template. At the same time, the bitstream can also indicate which candidate template in the template set the first template corresponding to the current block is. For example, third template indication information can be used to indicate the first template.

[0181] For example, in some embodiments, taking the 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, and the third candidate template is the L template. The flag intra_tmp_template_idx indicates the third template indication information. Then, the information in the decoded bitstream is as follows:

[0182] Among them, the template matching prediction identification information intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, the decoder first parses intra_tmp_idx and then parses intra_tmp_template_idx. Among them, whether to parse intra_tmp_template_idx depends on the value of intra_tmp_idx. If the value of intra_tmp_idx is less than or equal to (or less than) the preset threshold THR, the TL template is used by default. Otherwise, that is, the value of intra_tmp_idx is greater than (or greater than or equal to) the preset threshold THR, it is necessary to parse intra_tmp_template_idx to determine which template to use for the current block. The third template indication information intra_tmp_template_idx indicates whether the current block uses the TL template, T template or L template. If the value of intra_tmp_template_idx is 0, it means that the current block uses the TL template. If the value of intra_tmp_template_idx is 1, it means that the current block uses the T template. If the value of intra_tmp_template_idx is 2, it means that the current block uses the L template.

[0183] As can be seen, in this embodiment of the present application, the candidate index and the preset threshold are combined to determine whether to use the TL template in the template set. This ensures that candidates with small indexes do not need to distinguish which template to use, but instead use the TL template by default. This reduces unnecessary overhead, as these candidates will most likely use the TL template. It can also be considered that the indexes of the T and L template candidates do not start at 0, but at THR, which is equivalent to assigning longer binary symbol strings to the T and L templates.

[0184] It should be noted that in embodiments of the present application, it is possible to select in the bitstream which candidate template or templates in the template set the first template corresponding to the current block is to be indicated. For example, the first template indication information and / or the second template indication information and / or the third template indication information may be used to indicate the first template. Of course, it is also possible to select not to indicate in the bitstream which candidate template or templates to be used, but to directly construct a candidate list of block vectors corresponding to the current block based on multiple candidate templates in the template set.

[0185] Furthermore, in an embodiment of the present application, the first template corresponding to the current block may include multiple candidate templates in the template geometry. For example, the first template may include three candidate templates: a first candidate template such as a TL template, a second candidate template such as a T template, and a third candidate template such as an L template.

[0186] Accordingly, in an embodiment of the present application, it is possible to directly use multiple possible candidate templates to construct a block vector candidate list, wherein each block vector in the list may be obtained by template matching using one of the TL template, L template or T template.

[0187] For example, in some embodiments, if the codestream does not indicate which candidate template or templates to use, the decoding syntax elements may be as follows:

[0188] Among them, intra_tmp_flag is the flag of intraTMP. If intra_tmp_flag is true, then continue to parse intra_tmp_idx, and intra_tmp_idx is used to indicate the candidate index.

[0189] Step 102: Determine a block vector candidate list corresponding to the current block according to the first template.

[0190] In an embodiment of the present application, after determining the first template corresponding to the current block, a block vector candidate list corresponding to the current block can be further determined based on the first template.

[0191] It should be noted that, in the embodiment of the present application, the block vector candidate list corresponding to the current block may include at least one block vector obtained by searching based on the first template corresponding to the current block.

[0192] Furthermore, in an embodiment of the present application, after determining the first template corresponding to the current block, it is possible to optionally determine a search parameter corresponding to the first template based on the first template.

[0193] It is understood that in the embodiment of the present application, the search parameters include at least one of the following parameters: a search range, a search order, and a list length. The search range is used to determine the range of the search area to be searched, the search order is used to determine the order of horizontal and vertical searches, and the list length is used to determine the length of the final generated block vector candidate list.

[0194] That is to say, in an embodiment of the present application, in the process of constructing a block vector candidate list according to the selected first template, when constructing lists according to different templates, the search methods used, including the search range, search order, etc., and the list lengths may be the same or different.

[0195] Exemplarily, in some embodiments, if the determined first template is the first candidate template, that is, when it is determined to use the TL template, the list length of the block vector candidate list is set to 15; if the determined first template is the second candidate template or the third candidate template, that is, when it is determined to use the T template or the L template, the list length of the block vector candidate list is set to 8.

[0196] Exemplarily, in some embodiments, if the first template determined is the second candidate template, that is, when it is determined to use the T template, the list length of the block vector candidate list is set to 8; if the first template determined is the third candidate template, that is, when it is determined to use the L template, the list length of the block vector candidate list is set to 4.

[0197] Furthermore, in an embodiment of the present application, after determining the search parameters corresponding to the first template, a search may be further performed based on the search parameters and the first template, thereby determining a block vector candidate list corresponding to the current block.

[0198] That is, in the embodiment of the present application, when determining the block vector candidate list corresponding to the current block according to the first template, the first reference template can be referred to. Specifically, during the search process, the search parameters determined by the first template can be used.

[0199] Furthermore, in an embodiment of the present application, a search may be performed based on the search parameters corresponding to the current block and the first template to ultimately determine a block vector candidate list. Specifically, the search may be performed based on search parameters such as a search range corresponding to the current block, a search order, and a list length to ultimately determine a block vector candidate list corresponding to the current block.

[0200] Furthermore, in an embodiment of the present application, when determining a block vector candidate list corresponding to a current block based on a first template, a preset search area corresponding to the first template may be determined first; then a search may be performed within the preset search area to determine a block vector candidate list corresponding to the current block.

[0201] It should be noted that in the embodiments of this application, the preset search area is the reconstructed portion of the current image and is limited by the search range. The preset search area here is actually the set of all search points. Because the shape of this area is often not representable by a single rectangular area, in a specific implementation, it is also possible to search in multiple rectangular areas, and then combine the search results from different areas to obtain the final best matching block and best block vector.

[0202] Furthermore, in an embodiment of the present application, when searching within a preset search area to determine a block vector candidate list corresponding to a current block, the search points in the preset search area can be traversed, and the matching costs between the matching templates corresponding to the search points in the preset search area and the first template can be determined based on a preset matching criterion; and then the block vector candidate list can be determined based on the matching costs.

[0203] It should be noted that, in the embodiment of the present application, the block vector candidate list corresponding to the current block includes one or more block vectors corresponding to the current block obtained through search, and one or more candidate templates corresponding to the one or more block vectors.

[0204] That is, in an embodiment of the present application, the number of block vectors determined by the search may be one or more. For example, if the length of the block vector candidate list is N, then N block vectors of the current block may be determined, where N is an integer greater than 0.

[0205] Accordingly, in an embodiment of the present application, when searching within a preset search area to determine a block vector candidate list corresponding to a current block, the search points in the preset search area can be traversed, and the matching costs between the matching templates corresponding to the search points in the preset search area and the first template can be determined based on a preset matching criterion; finally, based on the matching costs, N block vectors and N candidate templates corresponding to the N block vectors can be determined, and ultimately a corresponding block vector candidate list can be generated.

[0206] That is, in an embodiment of the present application, when searching for and determining N block vectors corresponding to N matching templates in a preset search area, that is, the process of searching for and determining the block vectors BV corresponding to N matching templates in the search area (preset search area) may include determining the value of the number N of candidate templates, determining the matching template comparison criteria and recording the N block vectors BV corresponding to the N matching templates (the selected N candidate templates).

[0207] It should be noted that in the embodiments of the present application, the preset matching criteria include any one of the cost functions used to measure the pattern, such as the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC.

[0208] Furthermore, in an embodiment of the present application, when determining a block vector candidate list corresponding to the current block based on the matching cost, that is, determining N block vectors and N candidate templates corresponding to the N block vectors (the list length of the block vector candidate list is N), N minimum matching costs can be first determined among the matching costs between the matching template corresponding to the search point in the preset search area and the first template; and then the N block vectors and N candidate templates corresponding to the N minimum matching costs are determined.

[0209] It should be noted that in an embodiment of the present application, when performing a search, the search strategies that can be adopted may include but are not limited to search methods based on different search step sizes, for example, a coarse search based on a first search step size and / or a fine search based on a second search step size, wherein the first search step size is larger than the second search step size.

[0210] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed according to a first search step size to determine an initial block vector and an initial matching template corresponding to the initial block vector; then, a first search area can be determined based on the initial matching template; wherein the first search area is smaller than the preset search area; finally, the search points in the first search area can be traversed according to a second search step size to determine block vectors and candidate templates to determine a corresponding block vector candidate list; wherein the first search step size is larger than the second search step size.

[0211] It can be seen that in the embodiments of the present application, during the search process, it is possible to choose not to search every possible BV in sequence, for example, the usual search order is from left to right, from top to bottom. Generally speaking, the BVs of integer pixels can be searched in sequence. If the BV currently being searched is (x0, y0), the next one is (x0+1, y0), provided that the boundary of the search range has not been reached. In the present application, a sparse search can be performed first, for example, for the BV of integer pixels, if the BV currently being searched is (x0, y0), the next one is (x0+3, y0), provided that the boundary of the search range has not been reached. In other words, template matching is performed every certain number of pixels, or it can be called template matching every certain step size. The step size here can be a preset value, such as 2, 3, 4, 8, etc. Of course, the same process can also be performed in the vertical direction. First find the K BVs with the lowest cost, K may be equal to N, or it may be greater than or less than N. This process can be achieved by constructing a list. Based on the K lowest-cost BVs, each BV is refined within a small range. For example, if the search interval is 3 pixels, the refinement range can be set to 3x3. The refined BVs can be used to construct a block vector candidate list of length N, thus obtaining N BV candidates.

[0212] For example, in some embodiments, for example, if N is set to 3, a first search pass can be performed with a preset step size to find a certain number of sorted BVs, for example, 3. The horizontal step size is 3, and the vertical step size is also 3. Then, based on the 3 sorted BVs, a second search pass is performed. This time, the search range is 3x3, and each BV in each 3x3 range participates in the sorting of the block vector candidate list intraTmpCandList.

[0213] It should be noted that in the embodiment of the present application, if sub-pixel precision is supported, the sub-pixel BV can be further refined. For example, a 1 / 2 pixel search is performed within a pixel range above, below, or left of the integer pixel BV selected in the second step.

[0214] It should be noted that, in the embodiments of the present application, if the code stream does not indicate which candidate template or templates to use, then in the process of constructing the block vector candidate list corresponding to the current block directly based on multiple candidate templates in the template set, it is necessary to compare the matching costs of different candidate templates. At this time, due to the different sizes or pixels of different candidate templates, when comparing the matching costs of different candidate templates, it is necessary to uniformly adjust the matching costs of different candidate templates.

[0215] It can be understood that in the embodiments of the present application, in the process of adjusting the matching costs of different candidate templates, you can choose to use the pixel parameters corresponding to the candidate template to adjust the corresponding initial cost, or you can choose to determine the template coefficient corresponding to the candidate template, and then use the template coefficient to adjust the corresponding initial cost.

[0216] Furthermore, in an embodiment of the present application, in the process of constructing a block vector candidate list, the search points in the preset search area can be traversed, and the initial cost between the matching template corresponding to the search point in the preset search area and the first template can be determined according to a preset matching criterion; then, the initial cost is adjusted according to the pixel parameters corresponding to the candidate template to determine the matching cost between the matching template corresponding to the search point in the preset search area and the first template; finally, the block vector candidate list can be determined based on the matching cost.

[0217] That is, in the embodiment of the present application, if a block vector candidate list is directly constructed using multiple candidate templates such as the TL template, the L template, and the T template, each block vector in the block vector candidate list may be obtained by template matching using one of the TL template, the L template, or the T template. In this case, the basic principle of constructing the block vector candidate list is to sort the matching costs of different candidate templates.

[0218] It is understood that in the embodiments of this application, if the matching costs of several different candidate templates are directly compared, the final result will be inaccurate due to the different number of pixels in different candidate templates. Taking the matching cost as an example, directly comparing the SADs of different templates is unreasonable. For example, for the same BV, the SAD of the TL template is equal to the SAD of the T template plus the SAD of the L template.

[0219] Exemplarily, in some embodiments, when comparing the matching costs of different candidate templates, the matching cost (initial cost) can be adjusted based on the pixel parameters of the different templates. The pixel parameter can be the number of pixels corresponding to the candidate template. For example, when using pixel parameters to adjust the matching cost (initial cost), the initial cost corresponding to a candidate template (such as SAD) can be divided by the number of pixels (pixel parameters) corresponding to the candidate template to obtain the average absolute value of the difference (adjusted matching cost). The result of this division can be called the average absolute difference (AAD), that is, the final matching cost can be the corresponding AAD.

[0220] It can be understood that in the embodiments of the present application, after adjusting the initial cost according to the pixel parameters of different templates and obtaining the matching costs AAD corresponding to different candidate templates, the influencing factor of the different numbers of pixels of different candidate templates can be removed, and then the matching costs of different candidate templates can be compared to finally generate the corresponding block vector candidate list.

[0221] Furthermore, in an embodiment of the present application, if the first template includes multiple candidate templates in the template set, then the template coefficient corresponding to each candidate template may also be determined first.

[0222] It should be noted that when determining the template coefficient corresponding to each candidate template, you can choose to determine the template coefficient based on the size parameters corresponding to the candidate template, or you can choose to determine the template coefficient based on the pixel parameters corresponding to the candidate template, or you can set the template coefficients of different candidate templates according to preset values.

[0223] It can be understood that in the embodiments of the present application, different candidate templates may correspond to different template coefficients. By using the template coefficients corresponding to different candidate templates to uniformly adjust the matching costs of different templates, a more reasonable and accurate block vector candidate list can be obtained when sorting the matching costs.

[0224] Furthermore, in an embodiment of the present application, in the process of constructing a block vector candidate list, the search points in the preset search area can be traversed, and the initial cost between the matching template corresponding to the search point in the preset search area and the first template can be determined according to a preset matching criterion; then, the initial cost can be adjusted according to the template coefficient to determine the matching cost between the matching template corresponding to the search point in the preset search area and the first template; finally, the block vector candidate list can be determined based on the matching cost.

[0225] For example, in some embodiments, when comparing the matching costs of different candidate templates, the comparison can be performed based on the template coefficients of the different templates. For example, the SAD of different candidate templates can be multiplied by a coefficient (template coefficient) to adjust the initial costs of the different candidate templates, thereby allowing the different candidate templates to be compared based on the adjusted matching costs.

[0226] It should be noted that in the embodiments of the present application, assuming that the TL template includes the T template and the L template, the number of pixels of the TL template is always the largest. Therefore, only one template coefficient can be multiplied for the T template and the L template, while the TL template does not need to be multiplied, or the template coefficient of the TL template can be set to 1.

[0227] For example, in some embodiments, the initial cost SAD of the TL template is denoted as SADTL , the initial cost SAD of T template is SAD T , the initial cost SAD of the L template is SAD L The matching cost of the TL template used for comparison with other templates is COST TL , the matching cost of T template is COST T , the matching cost of L template is COST L .

[0228] Then, use the corresponding template coefficients respectively, such as the template coefficient of the TL template is 1, and the template coefficient of the T template is COEF T , the template coefficient of the TL template is COEF L , we can determine: COST TL =SAD TL , COST T =SAD T *COEF T , COST L =SAD L *COEF L .

[0229] Among them, COEF T and COEF L It can be calculated by the number of pixels of the candidate template. COEF of different block sizes T and COEF L It can be calculated in advance.

[0230] For example, in some embodiments, if the TL template does not include the upper left corner, that is, the TL template is equal to the T template plus the L template, and if the width of the current block is equal to the height, then COEF T Equal to 2, COEF L Equal to 2. But this still cannot avoid COEF T or COEF L For example, if width is twice the height, COEF T Equal to 1.5, COEF L Equal to 3.

[0231] Then, after adjusting the corresponding template coefficients, we can determine: COST TL =SAD TL *COEF TL , COST T =SAD T *COEF T , COST L =SAD L*COEF L .

[0232] Among them, COEF TL , COEF T and COEF L It can be calculated by the number of pixels of several templates. COEF of different block sizes TL , COEF T and COEF L It can be calculated in advance.

[0233] For example, in some embodiments, if the TL template does not include the upper left corner, that is, the TL template is equal to the T template plus the L template, and if the width of the current block is equal to the height, then COEF TL Equal to 1, COEF T Equal to 2, COEF L Equal to 2. For example, if width is twice the height, COEF TL Equal to 2, COEF T Equal to 3, COEF L Equal to 6. The method for calculating the template coefficient of the specified template can be to divide the least common multiple of the number of pixels of each template by the number of pixels of the specified template.

[0234] It is understood that in the embodiment of the present application, the matching cost of the TL template, the matching cost of the T template, and the matching cost of the L template of the same BV. If the matching degree of the T template and the matching degree of the L template (such as the AAD mentioned above) are different, even if they are only slightly different, then the COST calculated according to the pixel ratio T or COST L There must be one less than COST TL In other words, if you use pixel parameters or size parameters to adjust the template coefficients of multiple candidate templates (such as the TL template, T template, and L template), and then directly compare the matching costs of the TL template, the T template, and the L template after the adjustment, the TL template will be at a disadvantage in most cases. In other words, directly comparing according to the above method will result in only comparing the parts with the highest matching degree between different BVs. However, in fact, because the TL template covers more adjacent areas, and in most cases the texture is continuous from the left and top, it is unreasonable to use the T template and L template instead of the TL template without restraint.

[0235] It should be noted that, in the embodiment of the present application, the template coefficient corresponding to the candidate template can be set according to a preset value, so that the adjustment range of the matching cost can be reasonably controlled.

[0236] Exemplarily, in some embodiments, when setting the template coefficients corresponding to the candidate templates according to preset values, the template coefficients of the T template and / or the L template may be set to values ​​greater than the template coefficients of the TL template.

[0237] For example, in the embodiment of the present application, when setting the template coefficient corresponding to the candidate template according to the preset value, COST T or COST L Expand so that they can and COST TL This template coefficient setting method not only eliminates the influence of the number of pixels, but also takes into account that the TL template is generally disadvantaged compared to the T template and the L template, so it needs to be adjusted. For example, to COST T or COST L Multiply by a factor greater than 1.

[0238] It should be noted that, in an embodiment of the present application, if the first template includes multiple candidate templates in a template set, each block vector in the block vector candidate list may be obtained by template matching using a TL template, an L template, or a T template. In this case, the number of block vectors corresponding to any candidate template in the block vector candidate list can be limited.

[0239] Furthermore, in an embodiment of the present application, an upper threshold corresponding to each candidate template is determined, and the number of block vectors corresponding to the candidate template in the block vector candidate list is determined based on the upper threshold. The value of the upper threshold may be less than or equal to the length of the block vector candidate list.

[0240] That is, in embodiments of the present application, some restrictions can be placed on the number of candidates (block vectors) selected based on the T template and the L template in the same block vector candidate list. For example, an upper limit can be set for the number of candidates (block vectors) selected by the T template and / or the L template. When the number of candidates (block vectors) selected by the T template and / or the L template in the block vector candidate list reaches the upper limit, no further attempts are made to add candidates (block vectors) selected by the T template and / or the L template to the block vector candidate list.

[0241] Furthermore, in an embodiment of the present application, when a plurality of candidate templates are directly used to construct a block vector candidate list, that is, when the first template includes more than one candidate template, for example, the first template includes at least a first candidate template, a second candidate template, and a third candidate template, a second search area can be determined based on the first candidate template, and the search points in the second search area are traversed according to the first search step length to determine the initial block vector; then, a third search area is determined based on the initial block vector and the first template, and the search points in the third search area are traversed according to the second search step length to determine the block vector candidate list; wherein the first search step length is greater than the second search step length.

[0242] It is understandable that in the embodiments of the present application, a first candidate template in the first template may be used to perform a preliminary search according to a first search step, and then an initial block vector may be screened out and determined. Subsequently, the matching costs of the first template including multiple candidate templates may be compared and adjusted using the initial block vector as a positioning point, and a further improved search may be performed according to a second search step, thereby finally completing the construction of a block vector candidate list.

[0243] Exemplarily, in an embodiment of the present application, assuming that the first candidate template is a TL template, during the first step of intraTmp multi-candidate search (coarse search with intervals of the first search step), the second search area can be determined based on the TL template, and after traversing the search points in the second search area, a certain number of BVs, i.e., initial block vectors, are screened out based on the matching cost corresponding to the first candidate template. These BVs serve as positioning points for the second step of search (i.e., improved search performed according to the second search step). Next, the matching of the TL template, T template, and L template of several of the BVs is analyzed. If the COST corresponding to a certain BV is found, T or COST L Big difference, or COST T or COST L If the COST value of a BV is greater than a preset value, then a template with a higher matching degree from the T template or L template can be selected to improve the search, that is, other candidate templates other than the first candidate template in the first template can be used to continue the search. T or COST L If the difference is not significant, the TL template is still used to improve the search, that is, the first candidate template is used to continue the search.

[0244] Furthermore, in an embodiment of the present application, if the first template includes at least a first candidate template, a second candidate template, and a third candidate template, then a search can be performed based on the first candidate template to determine a first list corresponding to the first candidate template; a search can be performed based on the second candidate template to determine a second list corresponding to the second candidate template; a search can be performed based on the third candidate template to determine a third list corresponding to the third candidate template; and the first list can be adjusted according to the second list and the third list to determine a block vector candidate list.

[0245] It should be noted that, in the embodiments of the present application, the list lengths of the second list and the third list may be the same or different, and this application does not impose any specific limitation.

[0246] It should be noted that when the first template is not indicated in the bitstream, only a single block vector candidate list is constructed, eliminating the need for syntax elements in the bitstream to indicate which template to select. However, since the template matching costs of different templates cannot be directly compared, certain rules are required to ensure that they are placed in a single block vector candidate list. One straightforward approach is to sort candidates from one candidate template by its matching cost, while candidates from other candidate templates are not sorted by their matching cost and are instead placed directly in a given position in the list.

[0247] For example, in some embodiments, assuming the first candidate template is a TL template, the second candidate template is a T template, and the third candidate template is an L template, the length of the block vector candidate list is N. Then, a first list of length N can be constructed using the TL template. The template matching costs of the searched BVs can be calculated according to a preset search method, and the templates are sorted according to the template matching costs, with the lowest costs placed at the front, ultimately generating the first list. The maximum number of T and L templates that can be included in the final block vector candidate list can also be specified as M. Due to the need for duplicate checking when adding them to the list, the final number that can be included may be less than M. The search can then continue based on the T and L templates, generating corresponding second and third lists, respectively. Finally, the block vectors and corresponding candidate templates in the second and third lists can be added to the first list in sequence. After completing the adjustment of the first list, the corresponding block vector candidate list can be obtained.

[0248] Exemplarily, in some embodiments, an example is that N is 15 and M is 2, that is, the length of the block vector candidate list finally generated is 15, the number of candidates for the T template can be at most 2, and the number of candidates for the L template can be at most 2.

[0249] Exemplarily, in some embodiments, an example is that N is 19 and M is 3, that is, the length of the block vector candidate list finally generated is 19, the number of candidates for the T template can be up to 3, and the number of candidates for the L template can be up to 3.

[0250] Furthermore, in an embodiment of the present application, if the first template includes at least a first candidate template, a second candidate template, and a third candidate template, then a search is performed based on the first candidate template, the second candidate template, and the third candidate template to respectively determine a first list corresponding to the first candidate template, a second list corresponding to the second candidate template, and a third list corresponding to the third candidate template; the first list is adjusted according to the second list and the third list to determine a block vector candidate list.

[0251] That is, in an embodiment of the present application, it is also possible to simultaneously search based on the first candidate template, the second candidate template, and the third candidate template to obtain the corresponding first list, second list, and third list; and then generate a corresponding block vector candidate list based on the first list, the second list, and the third list.

[0252] For example, in some embodiments, the search process can be performed using the same search process for the TL template as for the T template and the L template. This allows for simultaneous calculation of the matching cost for the TL template, without significantly increasing the search complexity. For example, during the same search process, lists can be constructed for the TL template, the T template, and the L template, respectively. After the search is complete, these three lists are combined into the final block vector candidate list.

[0253] For example, in some embodiments, the T template and the L template may use separate search processes from the TL template. Of course, some search processes may be shared and others may be separate. This application does not impose any specific limitations.

[0254] Furthermore, in an embodiment of the present application, when adjusting the first list according to the second list and the third list to determine the block vector candidate list, the first starting position corresponding to the second list and the second starting position corresponding to the third list can be first determined; then, according to the first starting position, the block vectors in the second list are added to the first list, and at the same time, according to the second starting position, the block vectors in the third list are added to the first list to obtain the block vector candidate list.

[0255] It should be noted that, in an embodiment of the present application, the first starting position may be used to determine the starting position of a block vector in the second list when it is added to the first list; the second starting position may be used to determine the starting position of a block vector in the third list when it is added to the first list; wherein the first starting position and the second starting position may be the same or different.

[0256] Furthermore, in an embodiment of the present application, when adding block vectors in the second list to the first list according to the first starting position, block vectors in the second list that do not exist in the first list can be added to the first starting position in the first list; when adding block vectors in the third list to the first list according to the second starting position, block vectors in the third list that do not exist in the first list can be added to the second starting position in the first list.

[0257] For example, in some embodiments, the position with the smallest index that the T template and L template can be placed in can be designated as Pos, or the position closest to the beginning, i.e., the first starting position and the second starting position can be designated as Pos. Pos can be calculated based on N and M, such as Pos = N-1-M×2. Alternatively, the closest position that the T template and L template can be placed in the list can be determined separately.

[0258] For example, in some embodiments, assuming that the first candidate template is a TL template, the second candidate template is a T template, and the third candidate template is an L template, the length of the block vector candidate list is N, i.e., the length of the first list is X, and the lengths of the second and third lists are N. Based on the first list of TL templates, candidates for T templates and L templates may be added to generate a block vector candidate list. A preset search method may be used to find X T template candidates and X L template candidates with optimal template matching costs. These X T template candidates and X L template candidates may be used to construct a temporary list of length X, i.e., the second and third lists, respectively. The T template and L template candidates are tried to be placed in the final block vector candidate list. A duplicate check operation can be performed first. If the same BV as the candidate to be placed in the second list or the third list already exists in the first list, it will not be placed in the list. If the same BV as the candidate to be placed in the second list or the third list does not exist in the first list, the candidate at the first starting position or the second starting position specified in the first list, and the candidates after the first starting position or the second starting position are moved back in sequence, and then the candidate to be placed is placed at the specified starting position in the first list. Specifically, each time a candidate is placed in the first list, the specified first starting position or the second starting position is moved back by one, until all the candidates in the M or X temporary lists have been checked.

[0259] It should be noted that in the embodiments of the present application, whether the first list, the second list, and the third list are searched separately or the first list, the second list, and the third list are searched simultaneously, the search method used may also include first performing a sparse search according to the first search step length and then performing an improved search according to the second search step length.

[0260] Exemplarily, in some embodiments, for the first step of sparse search, during the search process, not every possible BV is searched in sequence. For example, the usual search order is from left to right and from top to bottom. Generally speaking, the BV of integer pixels can be searched in sequence. If the BV currently being searched is (x0, y0), the next one is (x0+1, y0), provided that the boundary of the search range has not been reached. But here we can first do a sparse search. For example, for the BV of integer pixels, if the BV currently being searched is (x0, y0), the next one is (x0+3, y0), provided that the boundary of the search range has not been reached. That is, template matching is performed every certain number of pixels, or it can be called template matching every certain step size. The step size here can be a preset value, such as 2, 3, 4, 8, etc. Of course, the same process can also be done in the vertical direction. First find the BV with the lowest cost for the K TL templates, K may be equal to N, or it may be greater than or less than N. This process can be achieved by constructing a list. Simultaneously find the BVs with the minimum cost for X' T templates and the minimum cost for X' L templates. X' may be equal to, greater than, or less than M. This process can be achieved by constructing a list. In other words, each BV in this search step is simultaneously sorted by the template matching cost of the TL template, T template, and L template, effectively using a shared sparse search process.

[0261] For example, in some embodiments, in the second step of the improved search, based on the BVs with the lowest cost for the K TL templates, improvements are performed within a small range for each BV. For example, if the search interval is 3 pixels, the improved range can be set to 3x3, and the improved BV can be used to construct a block vector candidate list of length N. Furthermore, based on the BVs with the lowest cost for the X' T templates and L templates, improvements are performed within a small range for each BV. For example, if the search interval is 3 pixels, the improved range can be set to 3x3, and the improved BV can be used to construct a temporary block vector candidate list of length X for the T template and a temporary block vector candidate list of length X for the L template. The TL template list of length N, the T template list of length X, and the L template list of length X are then combined into the final block vector candidate list according to the above method.

[0262] For example, in some embodiments, N=15, K=2N, M=2, X=4, and X'=2X.

[0263] It should be noted that in the embodiment of the present application, if sub-pixel precision is supported, the sub-pixel BV can be further refined. For example, a 1 / 2 pixel search can be performed within a pixel range above, below, or left of the integer pixel BV selected in the second step.

[0264] It is understood that in the embodiments of the present application, sharing the sparse search process does not significantly increase the complexity of the search. Instead, the large-scale sparse search can be used to find improved search ranges for the TL template, the T template, and the L template. The improved search can be performed for different templates, making it more targeted.

[0265] Step 103: Determine a block vector corresponding to the current block according to the block vector candidate list corresponding to the current block, and determine a prediction value of the current block according to the block vector.

[0266] In an embodiment of the present application, after determining the block vector candidate list corresponding to the current block according to the first template, the block vector corresponding to the current block can be further determined according to the block vector candidate list, and then the prediction value of the current block can be determined according to the block vector.

[0267] It should be noted that in an embodiment of the present application, if the value of the template matching prediction identification information is the first value, that is, if the value of the template matching prediction identification information is determined to use the intraTmp prediction method to predict the current block, then the code stream can be further decoded to determine the index identification information corresponding to the current block; then, the candidate index corresponding to the current block can be determined based on the index identification information.

[0268] It can be understood that in the embodiment of the present application, the index identification information corresponding to the current block can determine the index of the block vector corresponding to the current block in the block vector candidate list, that is, the candidate index corresponding to the current block can be determined through the index identification information.

[0269] It should be noted that in an embodiment of the present application, if the list length of the block vector candidate list generated when using different candidate templates is different, it is necessary to first parse the syntax elements indicating the template such as the first module identification information intra_tmp_alternative_template_flag and / or the first module identification information intra_tmp_template_idx, and then parse the candidate index intra_tmp_idx.

[0270] Further, in an embodiment of the present application, if no matter which candidate template is used as the first template of the current block, the corresponding list length, binarization, debinarization method, context model, etc. are the same, then it can be considered that the candidate index intra_tmp_idx does not depend on the first template indication information intra_tmp_alternative_template_flag and / or the second template indication information intra_tmp_template_idx and other syntax elements indicating the template, then the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx and intra_tmp_idx can be parsed first.

[0271] Further, in an embodiment of the present application, if different candidate templates are selected as the first template of the current block, the corresponding list length, binarization, debinarization method, context model, etc. may have at least one difference, then it can be considered that the candidate index intra_tmp_idx depends on the first template indication information intra_tmp_alternative_template_flag and / or the second template indication information intra_tmp_template_idx and other syntax elements indicating the template, then it is necessary to first parse the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx, and then parse intra_tmp_idx.

[0272] Furthermore, in an embodiment of the present application, if the value of the first template indication information is the third value, the index identification information is determined according to the first context; if the value of the first template indication information is the fourth value, the index identification information is determined according to the second context.

[0273] It is understood that in the embodiment of the present application, after parsing the first template indication information intra_tmp_alternative_template_flag, the context used in the encoding and decoding process can be determined according to the first template indication information, that is, the context model (CABAC context model) in the encoding and decoding process is determined using the first template indication information. Of course, the context model in the encoding and decoding process can also be determined using the second template indication information, which is not specifically limited in this application.

[0274] It should be noted that in the embodiments of the present application, different context models (CABAC context models) can be set during binarization or debinarization encoding and decoding. That is, the probabilities of binary symbols based on context coding in the two cases are accumulated and updated separately. In other words, the codec can select a set of context models based on the values ​​of the syntax elements indicating the template, such as the first template indication information intra_tmp_alternative_template_flag and / or the second template indication information intra_tmp_template_idx.

[0275] Exemplarily, in some embodiments, if the value of intra_tmp_alternative_template_flag is 0, a group / number of context models contextModel0 are selected; if the value of intra_tmp_alternative_template_flag is 1, a group / number of context models contextModel1 are selected.

[0276] Furthermore, in an embodiment of the present application, in the process of determining the candidate index corresponding to the current block based on the index identification information, if the value of the first template indication information is the third value, the candidate index is determined based on the index identification information and the first debinarization strategy; if the value of the first template indication information is the fourth value, the candidate index is determined based on the index identification information and the second debinarization strategy.

[0277] It is understood that in the embodiment of the present application, after parsing the first template indication information intra_tmp_alternative_template_flag, the debinarization strategy used in the candidate index determination process can be determined based on the first template indication information, that is, the debinarization method is determined using the first template indication information. Of course, the second template indication information can also be used to determine the binarization (encoding end) or debinarization (decoding end) method in the encoding and decoding process, which is not specifically limited in this application.

[0278] It should be noted that in the embodiments of the present application, the binarization and debinarization methods for the candidate index intra_tmp_idx may vary based on the value of the template indication information. Even if the list lengths of the block vector candidate lists generated using different candidate templates are the same, they may follow different probability distribution patterns, so different binarization and debinarization methods may be used.

[0279] Exemplarily, in some embodiments, in a case (such as using a TL template), the probability of the first few candidates with very small indexes being selected is significantly higher than that of other candidates with larger indexes. The binarization and debinarization methods assign shorter binary symbols to the first few candidates with very small indexes and longer binary symbols to other candidates with larger indexes.

[0280] Exemplarily, in some embodiments, in another case (such as using a T template or an L template), the probability of the first few candidates with very small indices being selected is similar to that of other candidates with larger indices, and the difference in the binary symbol lengths assigned to them by the binarization and debinarization methods is not as large as in the previous case, or equal binary symbol lengths are directly used.

[0281] That is, in the embodiment of the present application, the codec selects a set of binarization or debinarization methods according to the values ​​of syntax elements indicating templates, such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx.

[0282] Exemplarily, in some embodiments, if the value of the first template indication information intra_tmp_alternative_template_flag is 0, the binarization and debinarization method 1 is selected, as shown in Table 3.

[0283] Table 3

[0284] Exemplarily, in some embodiments, if the value of the first template indication information intra_tmp_alternative_template_flag is 1, the second binarization and debinarization method is selected, as shown in Table 4.

[0285] Table 4

[0286] The Symbols in Tables 3 and 4 above correspond to the candidate index intra_tmp_idx.

[0287] It should be noted that in an embodiment of the present application, at the decoding end, the decoder uses a debinarization method. According to the correspondence table between Symbol and binary symbols, if a binary symbol is encoded using a context mode, the context model is selected, and the code stream is read to determine the value of the Symbol. At the encoding end, the encoder uses a binarization method. According to the correspondence table between Symbol and binary symbols, if a binary symbol is encoded using a context mode, the context model is selected, and the content written to the code stream is determined according to the value of the Symbol. Among them, Symbol corresponds to intra_tmp_idx.

[0288] Furthermore, in an embodiment of the present application, when performing binarization or debinarization of intra_tmp_idx, for the case where only the TL template is used, or for any case where multiple candidates and multiple templates are combined, if the list length N of the block vector candidate list is relatively large, then the probability of the candidates at the front is large, and the probability becomes smaller as the candidates at the back are closer, and the probabilities become closer as the candidates at the back are closer, so the codewords at the front can be shorter and the codewords at the back can be longer, and some of the candidates at the back can use the same code length.

[0289] For example, in some embodiments, assuming that the list length N of the block vector candidate list is 15, indexes 3 to 6 use codewords of the same length, and indexes 7 to 14 use codewords of the same length, the specific binarization and debinarization are shown in Table 5.

[0290] Table 5

[0291] The x in the table can be obtained using truncated binary. Binary symbols with BinIdx = 0 can use the context-based encoding method. When the value of the binary symbol with BinIdx = 0 is 1 (corresponding to the cases where intra_tmp_idx = 0, 1, or 2 above), the binary symbol with BinIdx = 1 can use the context-based encoding method. The binary symbol represented by x can use the bypass encoding method.

[0292] For example, in some embodiments, assuming that the list length N of the block vector candidate list is 19, indexes 3 to 18 use codewords of the same length, and specific binarization and debinarization are shown in Table 6.

[0293] Table 6

[0294] The x in the table can be obtained using truncated binary. Binary symbols with BinIdx = 0 can use the context-based encoding method. When the value of the binary symbol with BinIdx = 0 is 1 (corresponding to the cases where intra_tmp_idx = 0, 1, or 2 above), the binary symbol with BinIdx = 1 can use the context-based encoding method. The binary symbol represented by x can use the bypass encoding method.

[0295] Accordingly, in an embodiment of the present application, the encoder converts the value of a syntax element (such as intra_tmp_idx here) into a corresponding binary symbol (bin), and then uses an entropy coding engine to convert the binary symbol into a binary symbol (bit). The entropy coding (decoding) engine of the decoder converts the binary symbol (bit) into a binary symbol, and then converts the binary symbol (bin) into the value of the syntax element.

[0296] It should be noted that in the embodiments of the present application, the context model-based encoding method and the bypass encoding method are two modes of the entropy coding engine. During encoding, the entropy coding engine converts binary symbols into binary symbols in the code stream. During decoding, the entropy coding engine converts binary symbols in the code stream into binary symbols. The context model-based encoding method can be understood as follows: the more a value (0 or 1) of a binary symbol of a syntax element appears in the context, the more the entropy coding engine will tend to use fewer binary symbols to correspond to the binary symbol and more binary symbols to correspond to the other binary symbol. For example, if the value 1 of a binary symbol of a syntax element appears frequently, fewer binary symbols will be used to encode 1, and more binary symbols will be used to encode 0. The bypass encoding method is equivalent to using an equal probability model. Therefore, the bypass encoding method has a higher throughput than the context model-based mode. The context model-based encoding method theoretically has higher compression efficiency.

[0297] For example, in some embodiments, assuming that the list length N of the block vector candidate list is 19, the specific binarization and debinarization are shown in Table 7.

[0298] Table 7

[0299] Among them, x, y, and z in the same row of the table can be obtained using truncated binary. That is, the last two binary symbols of 3 to 6 are obtained using truncated binary, the last two binary symbols of 7 to 10 are obtained using truncated binary, and the last three binary symbols of 11 to 18 are obtained using truncated binary. Among them, the binary symbol with BinIdx=0 can use the encoding method based on the context model.

[0300] It can be understood that in the embodiment of the present application, when the value of the binary symbol with BinIdx being 0 is 1 (corresponding to the above cases where intra_tmp_idx is 0, 1, 2), the binary symbol with BinIdx being 1 can use the encoding method based on the context model.

[0301] It can be understood that in an embodiment of the present application, when the value of the binary symbol with BinIdx being 0 is 0 (corresponding to the above case where intra_tmp_idx is greater than 2), the binary symbol with BinIdx being 1 can use a context model-based encoding method and use a context model that is different from the case where intra_tmp_idx is 0, 1, or 2.

[0302] It can be understood that in an embodiment of the present application, when the value of the binary symbol with BinIdx being 0 is 0, and the value of the binary symbol with BinIdx being 1 is 1 (corresponding to the above case where intra_tmp_idx is 3 to 10), the binary symbol with BinIdx being 2 can use a context model-based encoding method.

[0303] It can be understood that, in the embodiment of the present application, the binary symbols represented by the above x, y, and z can use a bypass encoding method.

[0304] It should be noted that, in the embodiments of the present application, the above values ​​of 0 and 1 are an example. It is also possible that the values ​​of 0 and 1 are opposite but the results are equivalent. Reversing the order of the binary symbols obtained by truncated binary is also equivalent.

[0305] Furthermore, in an embodiment of the present application, after determining the candidate index corresponding to the current block, when determining the block vector corresponding to the current block based on the block vector candidate list corresponding to the current block, the block vector corresponding to the current block can be determined from the block vector candidate list based on the candidate index.

[0306] That is to say, in the embodiment of the present application, the block vector indicated by the candidate index corresponding to the current block in the block vector candidate list may be determined as the block vector corresponding to the current block.

[0307] Furthermore, in an embodiment of the present application, after determining the block vector corresponding to the current block based on the block vector candidate list corresponding to the current block and determining the prediction value of the current block based on the block vector, the reconstructed value of the current block can be further determined based on the prediction value of the current block.

[0308] It should be noted that, in the embodiment of the present application, the code stream may be decoded first to determine the prediction residual corresponding to the current block; and then the reconstructed value of the current block may be further determined based on the prediction residual and the prediction value.

[0309] To sum up, through the decoding method proposed in the above steps 101 to 103, the intraTMP multi-candidates realized by constructing a block vector candidate list corresponding to the current block can provide multiple options, and the first template corresponding to the current block, which can include one or more candidate templates, can provide multiple options at the template level. The combination of the two can improve compression efficiency and obtain better compression performance.

[0310] That is to say, the encoding and decoding method proposed in the embodiment of the present application can combine the intraTMP multiple candidates with the multiple selections at the template level. In the process of combining the two, one way to implement the combination is to indicate which template to use in the bitstream; another way to implement the combination is not to indicate which template to use in the bitstream, but to use different templates to construct the same block vector candidate list.

[0311] The embodiment of the present application provides a decoding method, wherein the decoder determines a first template corresponding to the current block; wherein the first template is one or more candidate templates in the template set corresponding to the current block; a block vector candidate list corresponding to the current block is determined based on the first template; a block vector corresponding to the current block is determined based on the block vector candidate list corresponding to the current block, and a prediction value of the current block is determined based on the block vector. Thus, in the embodiment of the present application, a prediction method combining intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected and determined, and at the same time, a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing the combination of intraTMP multiple candidates and multiple selections at the template level. That is, the encoding and decoding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and encoding and decoding performance.

[0312] An embodiment of the present application provides an encoding method, which is applied to an encoder. FIG21 is a flow chart of the encoding method provided in the embodiment of the present application. As shown in FIG21 , the encoding method performed by the encoder may include the following steps:

[0313] Step 201: Determine a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block.

[0314] In an embodiment of the present application, a first template corresponding to the current block may be determined first.

[0315] It should be noted that the encoding method of the embodiment of the present application is applied to an encoder. In addition, the encoding method may include an intra-frame prediction method, more specifically, a color component prediction method. The video image can be divided into multiple coding blocks, each coding block may include a first color component, a second color component, and a third color component, and the current block in the embodiment of the present application refers to the coding block in the video image that is currently to be intra-frame predicted.

[0316] Here, when the first color component needs to be predicted, the component to be predicted is the first color component; when the second color component needs to be predicted, the component to be predicted is the second color component; when the third color component needs to be predicted, the component to be predicted is the third color component. In addition, assuming that the current block predicts the first color component and the first color component is the luminance component, that is, the component to be predicted is the luminance component, then the current block can also be called a luminance block; or assuming that the current block predicts the second color component and the second color component is the chrominance component, that is, the component to be predicted is the chrominance component, then the current block can also be called a chrominance block.

[0317] It should be noted that, in the embodiment of the present application, the first template corresponding to the current block may be any number of candidate templates in the template set corresponding to the current block, wherein the candidate templates corresponding to the current block include candidate templates of multiple different template types.

[0318] It is understandable that in the embodiment of the present application, a template set corresponding to the current block can be constructed based on different template types, and then any number of candidate templates can be selected from the template set as the first template corresponding to the current block.

[0319] Illustratively, in an embodiment of the present application, as shown in Figure 19, when the upper left reference sample, the upper reference sample and the 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 the upper left reference sample are available, the template shape is as shown in (d); when only the left reference sample and the lower left reference sample are available, the template shape is as shown in (e); when only the upper reference sample and the upper right reference sample are available, the template shape is as shown in (f).

[0320] Furthermore, in an embodiment of the present application, when constructing a template set corresponding to the current block based on the template type, the template reference sample of the current block can be determined based on the template type and the template size corresponding to the template type, and then the candidate template of the current block can be determined based on the template reference sample, and finally the construction of the template set is completed.

[0321] For example, in an embodiment of the present application, as shown in FIG20 , corresponding to four different template types, the candidate templates of the current block finally 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).

[0322] Furthermore, in an embodiment of the present application, the first template corresponding to the current block is determined based on candidate templates in the template set, wherein the first template may include any number of candidate templates.

[0323] It should be noted that, in an embodiment of the present application, the first candidate template in the template set may be a template including the left adjacent reconstructed samples and the upper adjacent reconstructed samples of the current block, such as the TL template; the second candidate template in the template set may be a template including the upper adjacent reconstructed samples of the current block, such as the T template; the third candidate template in the template set may be a template including the left adjacent reconstructed samples of the current block, such as the L template.

[0324] Exemplarily, in some embodiments, the first template corresponding to the current block may be the first candidate template in the template set corresponding to the current block, such as candidate template 1.

[0325] Exemplarily, in some embodiments, the first template corresponding to the current block may be the first candidate template and the second candidate template in the template set corresponding to the current block, such as candidate template 1 and candidate template 3.

[0326] Exemplarily, in some embodiments, the first template corresponding to the current block may be the first candidate template, the second candidate template, and the third candidate template in the template set corresponding to the current block, such as candidate template 1, candidate template 3, and candidate template 4.

[0327] Furthermore, in an embodiment of the present application, the template matching prediction identification information corresponding to the current block can be determined; if the value of the template matching prediction identification information is the first value, then the first template determination process can be executed, that is, the processing process for determining the first template proposed in step 201 can be executed.

[0328] It can be understood that, in the embodiment of the present application, the template matching prediction identification information can be used to determine whether the current block uses template matching prediction, that is, the template matching prediction identification information can indicate whether the current block is predicted through intraTMP.

[0329] Illustratively, in some embodiments, a variable may be determined as the template matching prediction identification information, so that the template matching prediction identification information may be determined by taking a value of the variable.

[0330] It should be noted that, in the present application, the value of the template matching prediction identification information can be the first value or the second value. Specifically, different values ​​of the template matching prediction identification information result in different methods for determining the prediction value of the current block. Specifically, based on the value of the template matching prediction identification information, when determining the prediction value of the current block, intraTMP can be used or not used.

[0331] For example, in some embodiments, the template matching prediction flag information can be understood as a flag indicating whether to perform intraTMP. If the value of the template matching prediction flag information is a first value, then intraTMP can be selected to determine the prediction value of the current block; if the value of the template matching prediction flag information is a second value, then intraTMP can be selected not to determine the prediction value of the current block.

[0332] For example, in some embodiments, the first value may be set to 1 and the second value may be set to 0; the first value may also be set to true and the second value may be set to false. This application does not impose any limitation.

[0333] Exemplarily, in some embodiments, the flag intra_tmp_flag may be used to represent the template matching prediction identification information, that is, intra_tmp_flag is used as the flag of intraTMP.

[0334] Exemplarily, in some embodiments, if the value of intra_tmp_flag is 1, it may indicate that intraTMP is selected to determine the prediction value of the current block; if the value of intra_tmp_flag is 0, it may indicate that intraTMP is not selected to determine the prediction value of the current block.

[0335] It can be understood that in an embodiment of the present application, when the value of the template matching prediction identification information is the first value, that is, after determining the prediction value of the current block using intraTMP based on the value of the template matching prediction identification information, the determination process of the first template corresponding to the current block can be executed.

[0336] Furthermore, in an embodiment of the present application, when determining the first template corresponding to 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 the third value, then the first template can be determined as the first candidate template.

[0337] It should be noted that, in the embodiment of the present application, the first candidate template may be a candidate template in the template set corresponding to the current block. For example, the first candidate template may be the TL template in the template set.

[0338] It can be understood that in the embodiment of the present application, the first template indication information can be used to determine whether the current block uses the first candidate template, that is, the first template indication information can indicate whether the current block uses the first candidate template to perform intraTMP prediction processing.

[0339] Illustratively, in some embodiments, a variable may be determined as the first template indication information, so that the first template indication information may be determined by taking a value of the variable.

[0340] It should be noted that, in the present application, the value of the first template indication information may be the third value or the fourth value. Specifically, based on the value of the first template indication information, when performing intraTMP, one may choose to use the first candidate template, or may choose not to use the first candidate template and use other templates, such as other templates in the template set other than the first candidate template.

[0341] For example, in some embodiments, the third value may be set to 0 and the fourth value may be set to 1; the third value may also be set to false and the fourth value may be set to true. This application does not impose any limitation.

[0342] For example, in some embodiments, the flag intra_tmp_alternative_template_flag may be used to indicate the first template indication information. For example, if the value of intra_tmp_alternative_template_flag is 0, it may indicate that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_alternative_template_flag is 1, it may indicate that the first candidate template is not determined as the first template corresponding to the current block, but other templates are selected as the first template corresponding to the current block.

[0343] Correspondingly, in an embodiment of the present application, after determining the first template indication information corresponding to the current block, if the value of the first template indication information is the fourth value, then it can be determined that the first template is not the first candidate template, and then it is necessary to further determine the second template indication information corresponding to the current block.

[0344] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, the second template indication information corresponding to the current block is determined; if the value of the second template indication information is the fifth value, then the first template can be determined as the second candidate template; if the value of the second template indication information is the sixth value, then the first template can be determined as the third candidate template.

[0345] It should be noted that, in the embodiment of the present application, the second candidate template and the third candidate template can be a candidate template in the template set corresponding to the current block. For example, the second candidate template can be a T template in the template set, and the third candidate template can be an L template in the template set.

[0346] It can be understood that in an embodiment of the present application, the second template indication 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 indication information can indicate whether the current block uses the second candidate template and / or the third candidate template to perform intraTMP prediction processing.

[0347] Illustratively, in some embodiments, a variable may be determined as the second template indication information, so that the second template indication information may be determined by taking a value of the variable.

[0348] It should be noted that, in this application, the value of the second template indication information may be the fifth value or the sixth value. Specifically, based on the value of the second template indication information, the second candidate template or the third candidate template may be selected for use during intraTMP.

[0349] For example, in some embodiments, the fifth value may be set to 0 and the sixth value may be set to 1; the fifth value may also be set to false and the sixth value may be set to true. This application does not impose any limitation.

[0350] For example, in some embodiments, the flag intra_tmp_template_idx may be used to indicate the second template indication information. For example, if the value of intra_tmp_template_idx is 0, it may indicate that the second candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it may indicate that the third candidate template is determined as the first template corresponding to the current block.

[0351] That is, in the embodiment of the present application, it is possible to select in the code stream which candidate template in the template set the first template corresponding to the current block is to be indicated as, for example, by using first template indication information and second template indication information to indicate the first template.

[0352] Exemplarily, in some embodiments, taking the 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, and the third candidate template is the L template. The template matching prediction identification information Intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, intra_tmp_alternative_template_flag is determined. The first template indication information intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If intra_tmp The value of _alternative_template_flag is 0, indicating that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, determine intra_tmp_template_idx. The second template indication information intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, indicating that the current block uses the T template. The value of intra_tmp_template_idx is 1, indicating that the current block uses the L template.

[0353] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, the third template indication information corresponding to the current block is determined; if the value of the third template indication information is the seventh value, then the first template can be determined as the first candidate template; if the value of the third template indication information is the eighth value, then the first template can be determined as the second candidate template; if the value of the third template indication information is the ninth value, then the first template can be determined as the third candidate template.

[0354] It should be noted that in the embodiments of the present application, the first candidate template, the second candidate template, and the third candidate template can each be a candidate template in the template set corresponding to the current block. For example, the first candidate template can be the TL template in the template set, the second candidate template can be the T template in the template set, and the third candidate template can be the L template in the template set.

[0355] It can be understood that in an embodiment of the present application, the third template indication information can be used to determine whether the current block uses the first candidate template and / or the second candidate template and / or the third candidate template, that is, the third template indication information can indicate whether the current block uses the first candidate template and / or the second candidate template and / or the third candidate template to perform intraTMP prediction processing.

[0356] Illustratively, in some embodiments, a variable may be determined as the third template indication information, so that the third template indication information may be determined by taking a value of the variable.

[0357] It should be noted that, in this application, the value of the third template indication information can be the seventh value, the eighth value, or the ninth value. Specifically, based on the value of the third template indication information, when performing intraTMP, you can choose to use the first candidate template, the second candidate template, or the third candidate template.

[0358] For example, in some embodiments, the seventh value may be set to 0, the eighth value may be set to 1, and the ninth value may be set to 2, and this application does not impose any limitation thereto.

[0359] Exemplarily, in some embodiments, the flag intra_tmp_template_idx may also be used to indicate third template indication information. For example, if the value of intra_tmp_template_idx is 0, it may indicate that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it may indicate that the second candidate template is determined as the first template corresponding to the current block; and if the value of intra_tmp_template_idx is 2, it may indicate that the third candidate template is determined as the first template corresponding to the current block.

[0360] That is, in the embodiment of the present application, it is possible to select in the code stream which candidate template in the template set the first template corresponding to the current block is to be indicated as, for example, by using the third template indication information to indicate the first template.

[0361] Exemplarily, in some embodiments, the first template indication information intra_tmp_alternative_template_flag and the second template indication information intra_tmp_template_idx may be merged into the same syntax element intra_tmp_template_idx, that is, merged into the third template indication information.

[0362] Exemplarily, in some embodiments, taking the 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, and the third candidate template is the L template. The template matching prediction identification information Intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, intra_tmp_template_idx is determined. The third template indication information intra_tmp_template_idx indicates that the current block uses TL template, T template, or L template. If the value of intra_tmp_template_idx is 0, it means that the current block uses the TL template. If the value of intra_tmp_template_idx is 1, it means that the current block uses the T template. If the value of intra_tmp_template_idx is 2, it means that the current block uses the L template.

[0363] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block, a candidate index corresponding to the current block is determined; if the value of the candidate index is less than or equal to a preset threshold, the first template is determined to be the first candidate template.

[0364] Correspondingly, in an embodiment of the present application, after determining the candidate index corresponding to the current block, if the value of the candidate index is greater than the preset threshold, the third template indication information corresponding to the current block is determined; if the value of the third template indication information is the seventh value, the first template is determined to be the first candidate template; if the value of the third template indication information is the eighth value, the first template is determined to be the second candidate template; if the value of the third template indication information is the ninth value, the first template is determined to be the third candidate template.

[0365] It should be noted that, in an embodiment of the present application, a preset threshold can be used to determine whether to directly use the first candidate template, wherein, if the value of the candidate index corresponding to the current block is greater than (or greater than or equal to) the preset threshold, then the third template indication information is selected to continue to be used to determine the first template to be used; if the value of the candidate index corresponding to the current block is less than or equal to (or less than) the preset threshold, then the first candidate template can be directly determined as the first template corresponding to the current block.

[0366] It can be understood that in an embodiment of the present application, you can choose to first determine the candidate index corresponding to the current block, and combine the candidate index and the preset threshold to determine whether to determine the first candidate template in the template set as the first template. In this way, the first candidate template can be given a higher priority than other candidate templates, that is, first determine whether to use the first candidate template.

[0367] Understandably, because the TL template covers more adjacent areas and, in most cases, the texture is continuous from the left and top, it is often more valuable as a reference than the separate T and L templates. Therefore, the TL template is often chosen, with the separate T and L templates serving more as supplementary choices. Based on this distribution pattern, the TL template can be given a higher priority than the T and L templates.

[0368] That is, in the embodiments of the present application, the candidate index of the current block can be used to indirectly determine whether to use a higher-priority TL template. At the same time, the bitstream can also indicate which candidate template in the template set the first template corresponding to the current block is. For example, third template indication information can be used to indicate the first template.

[0369] Exemplarily, in some embodiments, taking the 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, and the third candidate template is the L template. The template matching prediction identification information Intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, intra_tmp_idx is determined and then intra_tmp_template_idx is parsed. Whether intra_tmp_template_idx is parsed depends on the value of intra_tmp_idx. If the value of intra_tmp_idx is less than or equal to (or less than) the preset threshold THR, the TL template is used by default. Otherwise, that is, the value of intra_tmp_idx is greater than (or greater than or equal to) the preset threshold THR, it is necessary to parse intra_tmp_template_idx to determine which template the current block uses. The third template indication information intra_tmp_template_idx indicates whether the current block uses the TL template, T template or L template. If the value of intra_tmp_template_idx is 0, it means that the current block uses the TL template. If the value of intra_tmp_template_idx is 1, it means that the current block uses the T template. If the value of intra_tmp_template_idx is 2, it means that the current block uses the L template.

[0370] As can be seen, in this embodiment of the present application, the candidate index and the preset threshold are combined to determine whether to use the TL template in the template set. This ensures that candidates with small indexes do not need to distinguish which template to use, but instead use the TL template by default. This reduces unnecessary overhead, as these candidates will most likely use the TL template. It can also be considered that the indexes of the T and L template candidates do not start at 0, but at THR, which is equivalent to assigning longer binary symbol strings to the T and L templates.

[0371] It should be noted that in embodiments of the present application, it is possible to select in the bitstream which candidate template or templates in the template set the first template corresponding to the current block is to be indicated. For example, the first template indication information and / or the second template indication information and / or the third template indication information may be used to indicate the first template. Of course, it is also possible to select not to indicate in the bitstream which candidate template or templates to be used, but to directly construct a candidate list of block vectors corresponding to the current block based on multiple candidate templates in the template set.

[0372] Furthermore, in an embodiment of the present application, the first template corresponding to the current block may include multiple candidate templates in the template geometry. For example, the first template may include three candidate templates: a first candidate template such as a TL template, a second candidate template such as a T template, and a third candidate template such as an L template.

[0373] Accordingly, in an embodiment of the present application, it is possible to directly use multiple possible candidate templates to construct a block vector candidate list, wherein each block vector in the list may be obtained by template matching using one of the TL template, L template or T template.

[0374] Exemplarily, in some embodiments, if the code stream does not indicate which candidate template or templates to use, intra_tmp_flag is the flag of intraTMP. If intra_tmp_flag is true, then continue to determine intra_tmp_idx, which is used to indicate the candidate index.

[0375] Step 202: Determine a block vector candidate list corresponding to the current block according to the first template.

[0376] In an embodiment of the present application, after determining the first template corresponding to the current block, a block vector candidate list corresponding to the current block may be further determined based on the first template.

[0377] It should be noted that, in the embodiment of the present application, the block vector candidate list corresponding to the current block may include at least one block vector obtained by searching based on the first template corresponding to the current block.

[0378] Furthermore, in an embodiment of the present application, after determining the first template corresponding to the current block, it is possible to optionally determine a search parameter corresponding to the first template based on the first template.

[0379] It is understood that in the embodiment of the present application, the search parameters include at least one of the following parameters: a search range, a search order, and a list length. The search range is used to determine the range of the search area to be searched, the search order is used to determine the order of horizontal and vertical searches, and the list length is used to determine the length of the final generated block vector candidate list.

[0380] That is to say, in an embodiment of the present application, in the process of constructing a block vector candidate list according to the selected first template, when constructing lists according to different templates, the search methods used, including the search range, search order, etc., and the list lengths may be the same or different.

[0381] Exemplarily, in some embodiments, if the determined first template is the first candidate template, that is, when it is determined to use the TL template, the list length of the block vector candidate list is set to 15; if the determined first template is the second candidate template or the third candidate template, that is, when it is determined to use the T template or the L template, the list length of the block vector candidate list is set to 8.

[0382] Exemplarily, in some embodiments, if the first template determined is the second candidate template, that is, when it is determined to use the T template, the list length of the block vector candidate list is set to 8; if the first template determined is the third candidate template, that is, when it is determined to use the L template, the list length of the block vector candidate list is set to 4.

[0383] Furthermore, in an embodiment of the present application, after determining the search parameters corresponding to the first template, a search may be further performed based on the search parameters and the first template, thereby determining a block vector candidate list corresponding to the current block.

[0384] That is, in the embodiment of the present application, when determining the block vector candidate list corresponding to the current block according to the first template, the first reference template can be referred to. Specifically, during the search process, the search parameters determined by the first template can be used.

[0385] Furthermore, in an embodiment of the present application, a search may be performed based on the search parameters corresponding to the current block and the first template to ultimately determine a block vector candidate list. Specifically, the search may be performed based on search parameters such as a search range corresponding to the current block, a search order, and a list length to ultimately determine a block vector candidate list corresponding to the current block.

[0386] Furthermore, in an embodiment of the present application, when determining a block vector candidate list corresponding to a current block based on a first template, a preset search area corresponding to the first template may be determined first; then a search may be performed within the preset search area to determine a block vector candidate list corresponding to the current block.

[0387] It should be noted that in the embodiments of this application, the preset search area is the reconstructed portion of the current image and is limited by the search range. The preset search area here is actually the set of all search points. Because the shape of this area is often not representable by a single rectangular area, in a specific implementation, it is also possible to search in multiple rectangular areas, and then combine the search results from different areas to obtain the final best matching block and best block vector.

[0388] Furthermore, in an embodiment of the present application, when searching within a preset search area to determine a block vector candidate list corresponding to a current block, the search points in the preset search area can be traversed, and the matching costs between the matching templates corresponding to the search points in the preset search area and the first template can be determined based on a preset matching criterion; and then the block vector candidate list can be determined based on the matching costs.

[0389] It should be noted that, in the embodiment of the present application, the block vector candidate list corresponding to the current block includes one or more block vectors corresponding to the current block obtained through search, and one or more candidate templates corresponding to the one or more block vectors.

[0390] That is, in an embodiment of the present application, the number of block vectors determined by the search may be one or more. For example, if the length of the block vector candidate list is N, then N block vectors of the current block may be determined, where N is an integer greater than 0.

[0391] Accordingly, in an embodiment of the present application, when searching within a preset search area to determine a block vector candidate list corresponding to a current block, the search points in the preset search area can be traversed, and the matching costs between the matching templates corresponding to the search points in the preset search area and the first template can be determined based on a preset matching criterion; finally, based on the matching costs, N block vectors and N candidate templates corresponding to the N block vectors can be determined, and ultimately a corresponding block vector candidate list can be generated.

[0392] That is, in an embodiment of the present application, when searching for and determining N block vectors corresponding to N matching templates in a preset search area, that is, the process of searching for and determining the block vectors BV corresponding to N matching templates in the search area (preset search area) may include determining the value of the number N of candidate templates, determining the matching template comparison criteria and recording the N block vectors BV corresponding to the N matching templates (the selected N candidate templates).

[0393] It should be noted that in the embodiments of the present application, the preset matching criteria include any one of the cost functions used to measure the pattern, such as the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC.

[0394] Furthermore, in an embodiment of the present application, when determining a block vector candidate list corresponding to the current block based on the matching cost, that is, determining N block vectors and N candidate templates corresponding to the N block vectors (the list length of the block vector candidate list is N), N minimum matching costs can be first determined among the matching costs between the matching template corresponding to the search point in the preset search area and the first template; and then the N block vectors and N candidate templates corresponding to the N minimum matching costs are determined.

[0395] It should be noted that in an embodiment of the present application, when performing a search, the search strategies that can be adopted may include but are not limited to search methods based on different search step sizes, for example, a coarse search based on a first search step size and / or a fine search based on a second search step size, wherein the first search step size is larger than the second search step size.

[0396] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed according to a first search step size to determine an initial block vector and an initial matching template corresponding to the initial block vector; then, a first search area can be determined based on the initial matching template; wherein the first search area is smaller than the preset search area; finally, the search points in the first search area can be traversed according to a second search step size to determine block vectors and candidate templates to determine a corresponding block vector candidate list; wherein the first search step size is larger than the second search step size.

[0397] It can be seen that in the embodiments of the present application, during the search process, it is possible to choose not to search every possible BV in sequence, for example, the usual search order is from left to right, from top to bottom. Generally speaking, the BVs of integer pixels can be searched in sequence. If the BV currently being searched is (x0, y0), the next one is (x0+1, y0), provided that the boundary of the search range has not been reached. In the present application, a sparse search can be performed first, for example, for the BV of integer pixels, if the BV currently being searched is (x0, y0), the next one is (x0+3, y0), provided that the boundary of the search range has not been reached. In other words, template matching is performed every certain number of pixels, or it can be called template matching every certain step size. The step size here can be a preset value, such as 2, 3, 4, 8, etc. Of course, the same process can also be performed in the vertical direction. First find the K BVs with the lowest cost, K may be equal to N, or it may be greater than or less than N. This process can be achieved by constructing a list. Based on the K lowest-cost BVs, each BV is refined within a small range. For example, if the search interval is 3 pixels, the refinement range can be set to 3x3. The refined BVs can be used to construct a block vector candidate list of length N, thus obtaining N BV candidates.

[0398] For example, in some embodiments, for example, if N is set to 3, a first search pass can be performed with a preset step size to find a certain number of sorted BVs, for example, 3. The horizontal step size is 3, and the vertical step size is also 3. Then, based on the 3 sorted BVs, a second search pass is performed. This time, the search range is 3x3, and each BV in each 3x3 range participates in the sorting of the block vector candidate list intraTmpCandList.

[0399] It should be noted that in the embodiment of the present application, if sub-pixel precision is supported, the sub-pixel BV can be further refined. For example, a 1 / 2 pixel search is performed within a pixel range above, below, or left of the integer pixel BV selected in the second step.

[0400] It should be noted that, in the embodiments of the present application, if the code stream does not indicate which candidate template or templates to use, then in the process of constructing the block vector candidate list corresponding to the current block directly based on multiple candidate templates in the template set, it is necessary to compare the matching costs of different candidate templates. At this time, due to the different sizes or pixels of different candidate templates, when comparing the matching costs of different candidate templates, it is necessary to uniformly adjust the matching costs of different candidate templates.

[0401] It can be understood that in the embodiments of the present application, in the process of adjusting the matching costs of different candidate templates, you can choose to use the pixel parameters corresponding to the candidate template to adjust the corresponding initial cost, or you can choose to determine the template coefficient corresponding to the candidate template, and then use the template coefficient to adjust the corresponding initial cost.

[0402] Furthermore, in an embodiment of the present application, in the process of constructing a block vector candidate list, the search points in the preset search area can be traversed, and the initial cost between the matching template corresponding to the search point in the preset search area and the first template can be determined according to a preset matching criterion; then, the initial cost is adjusted according to the pixel parameters corresponding to the candidate template to determine the matching cost between the matching template corresponding to the search point in the preset search area and the first template; finally, the block vector candidate list can be determined based on the matching cost.

[0403] That is, in the embodiment of the present application, if a block vector candidate list is directly constructed using multiple candidate templates such as the TL template, the L template, and the T template, each block vector in the block vector candidate list may be obtained by template matching using one of the TL template, the L template, or the T template. In this case, the basic principle of constructing the block vector candidate list is to sort the matching costs of different candidate templates.

[0404] It is understood that in the embodiments of this application, if the matching costs of several different candidate templates are directly compared, the final result will be inaccurate due to the different number of pixels in different candidate templates. Taking the matching cost as an example, directly comparing the SADs of different templates is unreasonable. For example, for the same BV, the SAD of the TL template is equal to the SAD of the T template plus the SAD of the L template.

[0405] Exemplarily, in some embodiments, when comparing the matching costs of different candidate templates, the matching cost (initial cost) can be adjusted based on the pixel parameters of the different templates. The pixel parameter can be the number of pixels corresponding to the candidate template. For example, when using pixel parameters to adjust the matching cost (initial cost), the initial cost corresponding to a candidate template (such as SAD) can be divided by the number of pixels (pixel parameters) corresponding to the candidate template to obtain the average absolute value of the difference (adjusted matching cost). The result of this division can be called the average absolute difference (AAD), that is, the final matching cost can be the corresponding AAD.

[0406] It can be understood that in the embodiments of the present application, after adjusting the initial cost according to the pixel parameters of different templates and obtaining the matching costs AAD corresponding to different candidate templates, the influencing factor of the different numbers of pixels of different candidate templates can be removed, and then the matching costs of different candidate templates can be compared to finally generate the corresponding block vector candidate list.

[0407] Furthermore, in an embodiment of the present application, if the first template includes multiple candidate templates in the template set, then the template coefficient corresponding to each candidate template may also be determined first.

[0408] It should be noted that when determining the template coefficient corresponding to each candidate template, you can choose to determine the template coefficient based on the size parameters corresponding to the candidate template, or you can choose to determine the template coefficient based on the pixel parameters corresponding to the candidate template, or you can set the template coefficients of different candidate templates according to preset values.

[0409] It can be understood that in the embodiments of the present application, different candidate templates may correspond to different template coefficients. By using the template coefficients corresponding to different candidate templates to uniformly adjust the matching costs of different templates, a more reasonable and accurate block vector candidate list can be obtained when sorting the matching costs.

[0410] Furthermore, in an embodiment of the present application, in the process of constructing a block vector candidate list, the search points in the preset search area can be traversed, and the initial cost between the matching template corresponding to the search point in the preset search area and the first template can be determined according to a preset matching criterion; then, the initial cost can be adjusted according to the template coefficient to determine the matching cost between the matching template corresponding to the search point in the preset search area and the first template; finally, the block vector candidate list can be determined based on the matching cost.

[0411] For example, in some embodiments, when comparing the matching costs of different candidate templates, the comparison can be performed based on the template coefficients of the different templates. For example, the SAD of different candidate templates can be multiplied by a coefficient (template coefficient) to adjust the initial costs of the different candidate templates, thereby allowing the different candidate templates to be compared based on the adjusted matching costs.

[0412] It should be noted that in the embodiments of the present application, assuming that the TL template includes the T template and the L template, the number of pixels of the TL template is always the largest. Therefore, only one template coefficient can be multiplied for the T template and the L template, while the TL template does not need to be multiplied, or the template coefficient of the TL template can be set to 1.

[0413] For example, in some embodiments, the initial cost SAD of the TL template is denoted as SADTL , the initial cost SAD of T template is SAD T , the initial cost SAD of the L template is SAD L The matching cost of the TL template used for comparison with other templates is COST TL , the matching cost of T template is COST T , the matching cost of L template is COST L .

[0414] Then, use the corresponding template coefficients respectively, such as the template coefficient of the TL template is 1, and the template coefficient of the T template is COEF T , the template coefficient of the TL template is COEF L , we can determine: COST TL =SAD TL , COST T =SAD T *COEF T , COST L =SAD L *COEF L .

[0415] Among them, COEF T and COEF L It can be calculated by the number of pixels of the candidate template. COEF of different block sizes T and COEF L It can be calculated in advance.

[0416] For example, in some embodiments, if the TL template does not include the upper left corner, that is, the TL template is equal to the T template plus the L template, and if the width of the current block is equal to the height, then COEF T Equal to 2, COEF L Equal to 2. But this still cannot avoid COEF T or COEF L For example, if width is twice the height, COEF T Equal to 1.5, COEF L Equal to 3.

[0417] Then, after adjusting the corresponding template coefficients, we can determine: COST TL =SAD TL *COEF TL , COST T =SAD T *COEF T , COST L =SAD L*COEF L .

[0418] Among them, COEF TL , COEF T and COEF L It can be calculated by the number of pixels of several templates. COEF of different block sizes TL , COEF T and COEF L It can be calculated in advance.

[0419] For example, in some embodiments, if the TL template does not include the upper left corner, that is, the TL template is equal to the T template plus the L template, and if the width of the current block is equal to the height, then COEF TL Equal to 1, COEF T Equal to 2, COEF L Equal to 2. For example, if width is twice the height, COEF TL Equal to 2, COEF T Equal to 3, COEF L Equal to 6. The method for calculating the template coefficient of the specified template can be to divide the least common multiple of the number of pixels of each template by the number of pixels of the specified template.

[0420] It is understood that in the embodiment of the present application, the matching cost of the TL template, the matching cost of the T template, and the matching cost of the L template of the same BV. If the matching degree of the T template and the matching degree of the L template (such as the AAD mentioned above) are different, even if they are only slightly different, then the COST calculated according to the pixel ratio T or COST L There must be one less than COST TL In other words, if you use pixel parameters or size parameters to adjust the template coefficients of multiple candidate templates (such as the TL template, T template, and L template), and then directly compare the matching costs of the TL template, the T template, and the L template after the adjustment, the TL template will be at a disadvantage in most cases. In other words, directly comparing according to the above method will result in only comparing the parts with the highest matching degree between different BVs. However, in fact, because the TL template covers more adjacent areas, and in most cases the texture is continuous from the left and top, it is unreasonable to use the T template and L template instead of the TL template without restraint.

[0421] It should be noted that, in the embodiment of the present application, the template coefficient corresponding to the candidate template can be set according to a preset value, so that the adjustment range of the matching cost can be reasonably controlled.

[0422] Exemplarily, in some embodiments, when setting the template coefficients corresponding to the candidate templates according to preset values, the template coefficients of the T template and / or the L template may be set to values ​​greater than the template coefficients of the TL template.

[0423] For example, in the embodiment of the present application, when setting the template coefficient corresponding to the candidate template according to the preset value, COST T or COST L Expand so that they can and COST TL This template coefficient setting method not only eliminates the influence of the number of pixels, but also takes into account that the TL template is generally disadvantaged compared to the T template and the L template, so it needs to be adjusted. For example, to COST T or COST L Multiply by a factor greater than 1.

[0424] It should be noted that, in an embodiment of the present application, if the first template includes multiple candidate templates in a template set, each block vector in the block vector candidate list may be obtained by template matching using a TL template, an L template, or a T template. In this case, the number of block vectors corresponding to any candidate template in the block vector candidate list can be limited.

[0425] Furthermore, in an embodiment of the present application, an upper threshold corresponding to each candidate template is determined, and the number of block vectors corresponding to the candidate template in the block vector candidate list is determined based on the upper threshold. The value of the upper threshold may be less than or equal to the length of the block vector candidate list.

[0426] That is, in embodiments of the present application, some restrictions can be placed on the number of candidates (block vectors) selected based on the T template and the L template in the same block vector candidate list. For example, an upper limit can be set for the number of candidates (block vectors) selected by the T template and / or the L template. When the number of candidates (block vectors) selected by the T template and / or the L template in the block vector candidate list reaches the upper limit, no further attempts are made to add candidates (block vectors) selected by the T template and / or the L template to the block vector candidate list.

[0427] Furthermore, in an embodiment of the present application, when a plurality of candidate templates are directly used to construct a block vector candidate list, that is, when the first template includes more than one candidate template, for example, the first template includes at least a first candidate template, a second candidate template, and a third candidate template, a second search area can be determined based on the first candidate template, and the search points in the second search area are traversed according to the first search step length to determine the initial block vector; then, a third search area is determined based on the initial block vector and the first template, and the search points in the third search area are traversed according to the second search step length to determine the block vector candidate list; wherein the first search step length is greater than the second search step length.

[0428] It is understandable that in the embodiments of the present application, the first candidate in the first template may be used to perform a preliminary search according to the first search step, and then the initial block vector may be screened out and determined. Then, the matching costs of the first template including multiple candidate templates may be compared and adjusted using the initial block vector as a positioning point, and a further improved search may be performed according to the second search step, thereby finally completing the construction of the block vector candidate list.

[0429] Exemplarily, in an embodiment of the present application, assuming that the first candidate template in the first template is a TL template, during the first step search of intraTmp multiple candidates (coarse search with intervals of the first search step), the second search area can be determined based on the TL template, and after traversing the search points in the second search area, a certain number of BVs, i.e., initial block vectors, are screened out based on the matching cost corresponding to the first candidate template. These BVs serve as positioning points for the second step search (i.e., improved search performed according to the second search step). Next, the matching of the TL template, T template, and L template of several of the BVs is analyzed. If the COST corresponding to a certain BV is found, T or COST L Big difference, or COST T or COST L If the COST value of a BV is greater than a preset value, then a template with a higher matching degree from the T template or L template can be selected to improve the search, that is, other candidate templates other than the first candidate template in the first template can be used to continue the search. T or COST L If the difference is not significant, the TL template is still used to improve the search, that is, the first candidate template is used to continue the search.

[0430] Furthermore, in an embodiment of the present application, if the first template includes at least a first candidate template, a second candidate template, and a third candidate template, then a search can be performed based on the first candidate template to determine a first list corresponding to the first candidate template; a search can be performed based on the second candidate template to determine a second list corresponding to the second candidate template; a search can be performed based on the third candidate template to determine a third list corresponding to the third candidate template; and the first list can be adjusted according to the second list and the third list to determine a block vector candidate list.

[0431] It should be noted that, in the embodiments of the present application, the list lengths of the second list and the third list may be the same or different, and this application does not impose any specific limitation.

[0432] It should be noted that when the first template is not indicated in the bitstream, only a single block vector candidate list is constructed, eliminating the need for syntax elements in the bitstream to indicate which template to select. However, since the template matching costs of different templates cannot be directly compared, certain rules are required to ensure that they are placed in a single block vector candidate list. One straightforward approach is to sort candidates from one candidate template by its matching cost, while candidates from other candidate templates are not sorted by their matching cost and are instead placed directly in a given position in the list.

[0433] For example, in some embodiments, assuming the first candidate template is a TL template, the second candidate template is a T template, and the third candidate template is an L template, the length of the block vector candidate list is N. Then, a first list of length N can be constructed using the TL template. The template matching costs of the searched BVs can be calculated according to a preset search method, and the templates are sorted according to the template matching costs, with the lowest costs placed at the front, ultimately generating the first list. The maximum number of T and L templates that can be included in the final block vector candidate list can also be specified as M. Due to the need for duplicate checking when adding them to the list, the final number that can be included may be less than M. The search can then continue based on the T and L templates, generating corresponding second and third lists, respectively. Finally, the block vectors and corresponding candidate templates in the second and third lists can be added to the first list in sequence. After completing the adjustment of the first list, the corresponding block vector candidate list can be obtained.

[0434] Exemplarily, in some embodiments, an example is that N is 15 and M is 2, that is, the length of the block vector candidate list finally generated is 15, the number of candidates for the T template can be at most 2, and the number of candidates for the L template can be at most 2.

[0435] Exemplarily, in some embodiments, an example is that N is 19 and M is 3, that is, the length of the block vector candidate list finally generated is 19, the number of candidates for the T template can be up to 3, and the number of candidates for the L template can be up to 3.

[0436] Furthermore, in an embodiment of the present application, if the first template includes at least a first candidate template, a second candidate template, and a third candidate template, then a search is performed based on the first candidate template, the second candidate template, and the third candidate template to respectively determine a first list corresponding to the first candidate template, a second list corresponding to the second candidate template, and a third list corresponding to the third candidate template; the first list is adjusted according to the second list and the third list to determine a block vector candidate list.

[0437] That is, in an embodiment of the present application, it is also possible to simultaneously search based on the first candidate template, the second candidate template, and the third candidate template to obtain the corresponding first list, second list, and third list; and then generate a corresponding block vector candidate list based on the first list, the second list, and the third list.

[0438] For example, in some embodiments, the search process can be performed using the same search process for the TL template as for the T template and the L template. This allows for simultaneous calculation of the matching cost for the TL template, without significantly increasing the search complexity. For example, during the same search process, lists can be constructed for the TL template, the T template, and the L template, respectively. After the search is complete, these three lists are combined into the final block vector candidate list.

[0439] For example, in some embodiments, the T template and the L template may use separate search processes from the TL template. Of course, some search processes may be shared and others may be separate. This application does not impose any specific limitations.

[0440] Furthermore, in an embodiment of the present application, when adjusting the first list according to the second list and the third list to determine the block vector candidate list, the first starting position corresponding to the second list and the second starting position corresponding to the third list can be first determined; then, according to the first starting position, the block vectors in the second list are added to the first list, and at the same time, according to the second starting position, the block vectors in the third list are added to the first list to obtain the block vector candidate list.

[0441] It should be noted that, in an embodiment of the present application, the first starting position may be used to determine the starting position of a block vector in the second list when it is added to the first list; the second starting position may be used to determine the starting position of a block vector in the third list when it is added to the first list; wherein the first starting position and the second starting position may be the same or different.

[0442] Furthermore, in an embodiment of the present application, when adding block vectors in the second list to the first list according to the first starting position, block vectors in the second list that do not exist in the first list can be added to the first starting position in the first list; when adding block vectors in the third list to the first list according to the second starting position, block vectors in the third list that do not exist in the first list can be added to the second starting position in the first list.

[0443] For example, in some embodiments, the position with the smallest index that the T template and L template can be placed in can be designated as Pos, or the position closest to the beginning, i.e., the first starting position and the second starting position can be designated as Pos. Pos can be calculated based on N and M, such as Pos = N-1-M×2. Alternatively, the closest position that the T template and L template can be placed in the list can be determined separately.

[0444] For example, in some embodiments, assuming that the first candidate template is a TL template, the second candidate template is a T template, and the third candidate template is an L template, the length of the block vector candidate list is N, i.e., the length of the first list is X, and the lengths of the second and third lists are N. Based on the first list of TL templates, candidates for T templates and L templates may be added to generate a block vector candidate list. A preset search method may be used to find X T template candidates and X L template candidates with optimal template matching costs. These X T template candidates and X L template candidates may be used to construct a temporary list of length X, i.e., the second and third lists, respectively. The T template and L template candidates are tried to be placed in the final block vector candidate list. A duplicate check operation can be performed first. If the same BV as the candidate to be placed in the second list or the third list already exists in the first list, it will not be placed in the list. If the same BV as the candidate to be placed in the second list or the third list does not exist in the first list, the candidate at the first starting position or the second starting position specified in the first list, and the candidates after the first starting position or the second starting position are moved back in sequence, and then the candidate to be placed is placed at the specified starting position in the first list. Specifically, each time a candidate is placed in the first list, the specified first starting position or the second starting position is moved back by one, until all the candidates in the M or X temporary lists have been checked.

[0445] It should be noted that in the embodiments of the present application, whether the first list, the second list, and the third list are searched separately or the first list, the second list, and the third list are searched simultaneously, the search method used may also include first performing a sparse search according to the first search step length and then performing an improved search according to the second search step length.

[0446] Exemplarily, in some embodiments, for the first step of sparse search, during the search process, not every possible BV is searched in sequence. For example, the usual search order is from left to right and from top to bottom. Generally speaking, the BV of integer pixels can be searched in sequence. If the BV currently being searched is (x0, y0), the next one is (x0+1, y0), provided that the boundary of the search range has not been reached. But here we can first do a sparse search. For example, for the BV of integer pixels, if the BV currently being searched is (x0, y0), the next one is (x0+3, y0), provided that the boundary of the search range has not been reached. That is, template matching is performed every certain number of pixels, or it can be called template matching every certain step size. The step size here can be a preset value, such as 2, 3, 4, 8, etc. Of course, the same process can also be done in the vertical direction. First find the BV with the lowest cost for the K TL templates, K may be equal to N, or it may be greater than or less than N. This process can be achieved by constructing a list. Simultaneously find the BVs with the minimum cost for X' T templates and the minimum cost for X' L templates. X' may be equal to, greater than, or less than M. This process can be achieved by constructing a list. In other words, each BV in this search step is simultaneously sorted by the template matching cost of the TL template, T template, and L template, effectively using a shared sparse search process.

[0447] For example, in some embodiments, in the second step of the improved search, based on the BVs with the lowest cost for the K TL templates, improvements are performed within a small range for each BV. For example, if the search interval is 3 pixels, the improved range can be set to 3x3, and the improved BV can be used to construct a block vector candidate list of length N. Furthermore, based on the BVs with the lowest cost for the X' T templates and L templates, improvements are performed within a small range for each BV. For example, if the search interval is 3 pixels, the improved range can be set to 3x3, and the improved BV can be used to construct a temporary block vector candidate list of length X for the T template and a temporary block vector candidate list of length X for the L template. The TL template list of length N, the T template list of length X, and the L template list of length X are then combined into the final block vector candidate list according to the above method.

[0448] For example, in some embodiments, N=15, K=2N, M=2, X=4, and X'=2X.

[0449] It should be noted that in the embodiment of the present application, if sub-pixel precision is supported, the sub-pixel BV can be further refined. For example, a 1 / 2 pixel search can be performed within a pixel range above, below, or left of the integer pixel BV selected in the second step.

[0450] It is understood that in the embodiments of the present application, sharing the sparse search process does not significantly increase the complexity of the search. Instead, the large-scale sparse search can be used to find improved search ranges for the TL template, the T template, and the L template. The improved search can be performed for different templates, making it more targeted.

[0451] Step 203: Determine a block vector corresponding to the current block according to the block vector candidate list corresponding to the current block, and determine a prediction value of the current block according to the block vector.

[0452] In an embodiment of the present application, after determining the block vector candidate list corresponding to the current block according to the first template, the block vector corresponding to the current block can be further determined according to the block vector candidate list, and then the prediction value of the current block can be determined according to the block vector.

[0453] It should be noted that in an embodiment of the present application, if the value of the template matching prediction identification information is the first value, that is, if the value of the template matching prediction identification information is determined to use the intraTmp prediction method to predict the current block, then the index identification information corresponding to the current block can be further determined; then, the candidate index corresponding to the current block can be determined based on the index identification information.

[0454] It can be understood that in the embodiment of the present application, the index identification information corresponding to the current block can determine the index of the block vector corresponding to the current block in the block vector candidate list, that is, the candidate index corresponding to the current block can be determined through the index identification information.

[0455] It should be noted that in an embodiment of the present application, if the list length of the block vector candidate list generated when using different candidate templates is different, it is necessary to first parse the syntax elements indicating the template such as the first module identification information intra_tmp_alternative_template_flag and / or the first module identification information intra_tmp_template_idx, and then parse the candidate index intra_tmp_idx.

[0456] Further, in an embodiment of the present application, if no matter which candidate template is used as the first template of the current block, the corresponding list length, binarization, debinarization method, context model, etc. are the same, then it can be considered that the candidate index intra_tmp_idx does not depend on the first template indication information intra_tmp_alternative_template_flag and / or the second template indication information intra_tmp_template_idx and other syntax elements indicating the template, then the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx and intra_tmp_idx can be parsed first.

[0457] Further, in an embodiment of the present application, if different candidate templates are selected as the first template of the current block, the corresponding list length, binarization, debinarization method, context model, etc. may have at least one difference, then it can be considered that the candidate index intra_tmp_idx depends on the first template indication information intra_tmp_alternative_template_flag and / or the second template indication information intra_tmp_template_idx and other syntax elements indicating the template, then it is necessary to first parse the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx, and then parse intra_tmp_idx.

[0458] Furthermore, in an embodiment of the present application, if the value of the first template indication information is the third value, the index identification information is determined according to the first context; if the value of the first template indication information is the fourth value, the index identification information is determined according to the second context.

[0459] It is understood that in the embodiment of the present application, after parsing the first template indication information intra_tmp_alternative_template_flag, the context used in the encoding and decoding process can be determined according to the first template indication information, that is, the context model (CABAC context model) in the encoding and decoding process is determined using the first template indication information. Of course, the context model in the encoding and decoding process can also be determined using the second template indication information, which is not specifically limited in this application.

[0460] It should be noted that in the embodiments of the present application, different context models (CABAC context models) can be set during binarization or debinarization encoding and decoding. That is, the probabilities of binary symbols based on context coding in the two cases are accumulated and updated separately. In other words, the codec can select a set of context models based on the values ​​of the syntax elements indicating the template, such as the first template indication information intra_tmp_alternative_template_flag and / or the second template indication information intra_tmp_template_idx.

[0461] Exemplarily, in some embodiments, if the value of intra_tmp_alternative_template_flag is 0, a group / number of context models contextModel0 are selected; if the value of intra_tmp_alternative_template_flag is 1, a group / number of context models contextModel1 are selected.

[0462] Furthermore, in an embodiment of the present application, in the process of determining the candidate index corresponding to the current block based on the index identification information, if the value of the first template indication information is the third value, the candidate index is determined based on the index identification information and the first binarization strategy; if the value of the first template indication information is the fourth value, the candidate index is determined based on the index identification information and the second binarization strategy.

[0463] It is understood that in the embodiment of the present application, after parsing the first template indication information intra_tmp_alternative_template_flag, the binarization strategy used in the candidate index determination process can be determined based on the first template indication information, that is, the first template indication information is used to determine the debinarization method. Of course, the second template indication information can also be used to determine the binarization (encoding end) or debinarization (decoding end) method in the encoding and decoding process, which is not specifically limited in this application.

[0464] It should be noted that in the embodiments of the present application, the binarization and debinarization methods for the candidate index intra_tmp_idx may vary based on the value of the template indication information. Even if the list lengths of the block vector candidate lists generated using different candidate templates are the same, they may follow different probability distribution patterns, so different binarization and debinarization methods may be used.

[0465] Exemplarily, in some embodiments, in a case (such as using a TL template), the probability of the first few candidates with very small indexes being selected is significantly higher than that of other candidates with larger indexes. The binarization and debinarization methods assign shorter binary symbols to the first few candidates with very small indexes and longer binary symbols to other candidates with larger indexes.

[0466] Exemplarily, in some embodiments, in another case (such as using a T template or an L template), the probability of the first few candidates with very small indices being selected is similar to that of other candidates with larger indices, and the difference in the binary symbol lengths assigned to them by the binarization and debinarization methods is not as large as in the previous case, or equal binary symbol lengths are directly used.

[0467] That is, in the embodiment of the present application, the codec selects a set of binarization or debinarization methods according to the values ​​of syntax elements indicating templates, such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx.

[0468] Exemplarily, in some embodiments, if the value of the first template indication information intra_tmp_alternative_template_flag is 0, the binarization and debinarization method 1 is selected, as shown in Table 3.

[0469] Exemplarily, in some embodiments, if the value of the first template indication information intra_tmp_alternative_template_flag is 1, the second binarization and debinarization method is selected, as shown in Table 4.

[0470] The Symbols in Tables 3 and 4 above correspond to the candidate index intra_tmp_idx.

[0471] It should be noted that in an embodiment of the present application, at the decoding end, the decoder uses a debinarization method. According to the correspondence table between Symbol and binary symbols, if a binary symbol is encoded using a context mode, the context model is selected, and the code stream is read to determine the value of the Symbol. At the encoding end, the encoder uses a binarization method. According to the correspondence table between Symbol and binary symbols, if a binary symbol is encoded using a context mode, the context model is selected, and the content written to the code stream is determined according to the value of the Symbol. Among them, Symbol corresponds to intra_tmp_idx.

[0472] Furthermore, in an embodiment of the present application, when performing binarization or debinarization of intra_tmp_idx, for the case where only the TL template is used, or for any case where multiple candidates and multiple templates are combined, if the list length N of the block vector candidate list is relatively large, then the probability of the candidates at the front is large, and the probability becomes smaller as the candidates at the back are closer, and the probabilities become closer as the candidates at the back are closer, so the codewords at the front can be shorter and the codewords at the back can be longer, and some of the candidates at the back can use the same code length.

[0473] For example, in some embodiments, assuming that the list length N of the block vector candidate list is 15, indexes 3 to 6 use codewords of the same length, and indexes 7 to 14 use codewords of the same length, the specific binarization and debinarization are shown in Table 5.

[0474] The x in the table can be obtained using truncated binary. Binary symbols with BinIdx = 0 can use the context-based encoding method. When the value of the binary symbol with BinIdx = 0 is 1 (corresponding to the cases where intra_tmp_idx = 0, 1, or 2 above), the binary symbol with BinIdx = 1 can use the context-based encoding method. The binary symbol represented by x can use the bypass encoding method.

[0475] For example, in some embodiments, assuming that the list length N of the block vector candidate list is 19, indexes 3 to 18 use codewords of the same length, and specific binarization and debinarization are shown in Table 6.

[0476] The x in the table can be obtained using truncated binary. Binary symbols with BinIdx = 0 can use the context-based encoding method. When the value of the binary symbol with BinIdx = 0 is 1 (corresponding to the cases where intra_tmp_idx = 0, 1, or 2 above), the binary symbol with BinIdx = 1 can use the context-based encoding method. The binary symbol represented by x can use the bypass encoding method.

[0477] Accordingly, in an embodiment of the present application, the encoder converts the value of a syntax element (such as intra_tmp_idx here) into a corresponding binary symbol (bin), and then uses an entropy coding engine to convert the binary symbol into a binary symbol (bit). The entropy coding (decoding) engine of the decoder converts the binary symbol (bit) into a binary symbol, and then converts the binary symbol (bin) into the value of the syntax element.

[0478] It should be noted that in the embodiments of the present application, the context model-based encoding method and the bypass encoding method are two modes of the entropy coding engine. During encoding, the entropy coding engine converts binary symbols into binary symbols in the code stream. During decoding, the entropy coding engine converts binary symbols in the code stream into binary symbols. The context model-based encoding method can be understood as follows: the more a value (0 or 1) of a binary symbol of a syntax element appears in the context, the more the entropy coding engine will tend to use fewer binary symbols to correspond to the binary symbol and more binary symbols to correspond to the other binary symbol. For example, if the value 1 of a binary symbol of a syntax element appears frequently, fewer binary symbols will be used to encode 1, and more binary symbols will be used to encode 0. The bypass encoding method is equivalent to using an equal probability model. Therefore, the bypass encoding method has a higher throughput than the context model-based mode. The context model-based encoding method theoretically has higher compression efficiency.

[0479] For example, in some embodiments, assuming that the list length N of the block vector candidate list is 19, the specific binarization and debinarization are shown in Table 7.

[0480] Among them, x, y, and z in the same row of the table can be obtained using truncated binary. That is, the last two binary symbols of 3 to 6 are obtained using truncated binary, the last two binary symbols of 7 to 10 are obtained using truncated binary, and the last three binary symbols of 11 to 18 are obtained using truncated binary. Among them, the binary symbol with BinIdx=0 can use the encoding method based on the context model.

[0481] It can be understood that in the embodiment of the present application, when the value of the binary symbol with BinIdx being 0 is 1 (corresponding to the above cases where intra_tmp_idx is 0, 1, 2), the binary symbol with BinIdx being 1 can use the encoding method based on the context model.

[0482] It can be understood that in an embodiment of the present application, when the value of the binary symbol with BinIdx being 0 is 0 (corresponding to the above case where intra_tmp_idx is greater than 2), the binary symbol with BinIdx being 1 can use a context model-based encoding method and use a context model that is different from the case where intra_tmp_idx is 0, 1, or 2.

[0483] It can be understood that in an embodiment of the present application, when the value of the binary symbol with BinIdx being 0 is 0, and the value of the binary symbol with BinIdx being 1 is 1 (corresponding to the above case where intra_tmp_idx is 3 to 10), the binary symbol with BinIdx being 2 can use a context model-based encoding method.

[0484] It can be understood that, in the embodiment of the present application, the binary symbols represented by the above x, y, and z can use a bypass encoding method.

[0485] It should be noted that, in the embodiments of the present application, the above values ​​of 0 and 1 are an example. It is also possible that the values ​​of 0 and 1 are opposite but the results are equivalent. Reversing the order of the binary symbols obtained by truncated binary is also equivalent.

[0486] Furthermore, in an embodiment of the present application, after determining the candidate index corresponding to the current block, when determining the block vector corresponding to the current block based on the block vector candidate list corresponding to the current block, the block vector corresponding to the current block can be determined from the block vector candidate list based on the candidate index.

[0487] That is to say, in the embodiment of the present application, the block vector indicated by the candidate index corresponding to the current block in the block vector candidate list may be determined as the block vector corresponding to the current block.

[0488] Furthermore, in an embodiment of the present application, after determining the block vector corresponding to the current block based on the block vector candidate list corresponding to the current block and determining the prediction value of the current block based on the block vector, the reconstructed value of the current block can be further determined based on the prediction value of the current block.

[0489] It should be noted that, in the embodiment of the present application, the prediction residual corresponding to the current block may be determined first; and then the reconstructed value of the current block may be further determined based on the prediction residual and the prediction value.

[0490] It is understood that in the embodiments of the present application, after determining the prediction residual value of the current block based on the prediction value of the current block, the prediction residual value can be written into the bitstream. This allows the decoder to determine the prediction residual value corresponding to the current block by decoding the bitstream; and then further determine the reconstructed value of the current block based on the prediction residual value and the prediction value.

[0491] To sum up, through the encoding method proposed in the above steps 201 to 203, the intraTMP multi-candidates realized by constructing a block vector candidate list corresponding to the current block can provide multiple options, and the first template corresponding to the current block, which can include one or more candidate templates, can provide multiple options at the template level. The combination of the two can improve compression efficiency and obtain better compression performance.

[0492] That is to say, the encoding and decoding method proposed in the embodiment of the present application can combine the intraTMP multiple candidates with the multiple selections at the template level. In the process of combining the two, one way to implement the combination is to indicate which template to use in the bitstream; another way to implement the combination is not to indicate which template to use in the bitstream, but to use different templates to construct the same block vector candidate list.

[0493] The embodiment of the present application provides an encoding method, wherein the encoder determines a first template corresponding to the current block; wherein the first template is one or more candidate templates in the template set corresponding to the current block; a block vector candidate list corresponding to the current block is determined based on the first template; a block vector corresponding to the current block is determined based on the block vector candidate list corresponding to the current block, and a prediction value of the current block is determined based on the block vector. Thus, in the embodiment of the present application, a prediction method combining Intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected and determined, and at the same time, a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing the combination of intraTMP multiple candidates and multiple selections at the template level. That is, the encoding and decoding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and encoding and decoding performance.

[0494] Based on the above embodiment, another embodiment of the present application proposes a coding method, which is applied to a codec, taking the three templates of TL template, T template, and L template as candidate templates in the template set as an example. Usually, when performing template matching, the matching cost of the template of the searched reference block and the template of the current block is calculated. This cost is generally measured by SAD, SATD, SSE, etc. Taking SAD as an example, if the TL template is the T template plus the L template, then the SAD of the TL template corresponding to the same BV is equal to the SAD of the T template plus the SAD of the L template. If the TL template also includes the upper left area in addition to the T template and the L template, then the SAD of the T template and the SAD of the L template corresponding to the same BV can still be calculated in the process of the SAD of the TL template.

[0495] It should be noted that the encoding and decoding method proposed in the embodiments of this application is an intra-frame prediction method that combines multiple intraTMP candidates with multiple selections at the template level. One combination method is to indicate to the decoder in the bitstream which template to use. Another combination method is to not indicate to the decoder in the bitstream which template to use, but instead use different templates to construct the same block vector candidate list.

[0496] For example, in some embodiments, if the code stream indicates which template the decoder should use, an example of a decoding syntax is as follows:

[0497] Intra_tmp_flag indicates whether the current block uses intraTmp. If the current block uses intraTmp, the decoder parses intra_tmp_alternative_template_flag. 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. If the value of intra_tmp_alternative_template_flag is 1, the decoder parses intra_tmp_template_idx. Intra_tmp_template_idx indicates whether the T template or L template is used. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template, and the value of intra_tmp_template_idx is 1, which means that the current block uses the L template.

[0498] Of course, intra_tmp_alternative_template_flag and intra_tmp_template_idx can also be combined into the same syntax element intra_tmp_template_idx. For example, if the value of intra_tmp_template_idx is 0, it means that the current block uses the TL template, if the value of intra_tmp_template_idx is 1, it means that the current block uses the T template, and if the value of intra_tmp_template_idx is 2, it means that the current block uses the L template.

[0499] The decoder constructs a block vector candidate list based on the selected template. When constructing lists based on different templates, the search method, including the search range and search order, as well as the list length can be the same or different. An example is a list length of 15 when using the TL template and 8 (or 4) when using the T template or L template.

[0500] Parsing Method

[0501] If the list lengths are different, it is necessary to first parse the syntax elements indicating the template, such as intra_tmp_alternative_template_flag and intra_tmp_template_idx, and then parse intra_tmp_idx.

[0502] An extreme case is that when the T template or the L template is used, the length of the block vector candidate list is 1, that is, there is only one candidate. In this case, there is no need to parse intra_tmp_idx when the T template or the L template is used.

[0503] Furthermore, the binarization and debinarization methods of intra_tmp_idx can also be different. Even if the list lengths of the two cases are the same, they may follow different probability distribution rules, so different binarization and debinarization methods can be set. To give an example that is easier to understand, in one case (such as using the TL template), the probability of the first few candidates with very small indexes being selected is significantly higher than that of other candidates with larger indexes. The binarization and debinarization methods assign shorter binary symbols to the first few candidates with very small indexes, and longer binary symbols to other candidates with larger indexes. In another case (such as using the T template or the L template), the probability of the first few candidates with very small indexes being selected is similar to that of other candidates with larger indexes. The difference in the length of the binary symbols assigned to them by the binarization and debinarization methods is not as large as in the previous case, or the same binary symbol length is directly used. That is to say, the codec selects a set of binarization and debinarization methods according to the values ​​of the syntax elements indicating the template, such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx. For example, if the value of intra_tmp_alternative_template_flag is 0, binarization and debinarization method one is selected; if the value of intra_tmp_alternative_template_flag is 1, binarization and debinarization method two is selected.

[0504] For example, in some embodiments, the first binarization and debinarization method is shown in Table 3. The second binarization and debinarization method is shown in Table 4.

[0505] Furthermore, even if the binarization method is the same, different context models (CABAC context models) can be set for the two cases during binarization and debinarization encoding and decoding. That is, the probabilities of the binary symbols based on context coding in the two cases are accumulated and updated separately. In other words, the codec selects a set of context models based on the values ​​of the syntax elements indicating the template, such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx. For example, if the value of intra_tmp_alternative_template_flag is 0, a set / individual context model contextModel0 is selected, and if the value of intra_tmp_alternative_template_flag is 1, a set / individual context model contextModel1 is selected.

[0506] If the list length, binarization and debinarization methods, context model, etc. are the same, that is, intra_tmp_idx does not depend on the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx, then either the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx or intra_tmp_idx can be parsed first; otherwise, that is, intra_tmp_idx depends on the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx, then the syntax elements indicating the template such as intra_tmp_alternative_template_flag and / or intra_tmp_template_idx are parsed first and then intra_tmp_idx.

[0507] The decoder uses a debinarization method. Based on the symbol-binary symbol correspondence table, if a binary symbol is encoded using a context mode, the decoder selects the context model and reads the bitstream to determine the symbol's value. The encoder uses a binarization method. Based on the symbol-binary symbol correspondence table, if a binary symbol is encoded using a context mode, the decoder selects the context model and determines the content written to the bitstream based on the symbol's value. Symbol corresponds to intra_tmp_idx.

[0508] Because the TL template covers more adjacent areas and, in most cases, the texture is continuous from the left and top, the TL template is more valuable as a reference than the separate T and L templates. In most cases, the encoder will select the TL template, with the separate T and L templates serving as supplements. Based on this distribution pattern, the TL template can be given a higher priority than the T and L templates. One method is as follows:

[0509] If the current block uses intraTmp, parse intra_tmp_idx first and then parse intra_tmp_template_idx. Whether to parse intra_tmp_template_idx depends on the value of intra_tmp_idx. If the value of intra_tmp_idx is less than or equal to the threshold THR (it can also be less than the threshold), the TL template is used by default. Otherwise, that is, the value of intra_tmp_idx is greater than the threshold THR (it can also be greater than or equal to the threshold), it is necessary to parse intra_tmp_template_idx to determine which template the current block uses. An example is that if the value of intra_tmp_template_idx is 0, it means that the current block uses the TL template, if the value of intra_tmp_template_idx is 1, it means that the current block uses the T template, and if the value of intra_tmp_template_idx is 2, it means that the current block uses the L template.

[0510] The advantage of this approach is that candidates with smaller indices don't need to distinguish between templates and instead use the TL template by default, reducing unnecessary overhead, as these candidates will typically use the TL template. Alternatively, consider the T and L template candidate indices starting at THR, not 0. This effectively assigns longer binary symbol strings to the T and L templates.

[0511] Furthermore, in the embodiment of the present application, the binarization and debinarization method of intra_tmp_idx, that is, the entropy coding and decoding method, can be used in the case of using only the TL template, and can also be used in the above-mentioned case of combining multiple candidates and multiple templates.

[0512] Exemplarily, in some embodiments, if N is relatively large, the probability of the candidate in the front is large, the probability is smaller as it goes on, and the probability is closer as it goes on, so the codeword in the front can be short and the codeword in the back can be long, and some of the candidates in the back can use the same code length. For example, in Table 5, N is 15, indexes 3 to 6 use codewords of the same length, and indexes 7 to 14 use codewords of the same length. The x in the above table can be obtained using truncated binary. The binary symbol with BinIdx of 0 can use a coding method based on the context model. When the value of the binary symbol with BinIdx of 0 is 1 (corresponding to the above intra_tmp_idx of 0, 1, 2), the binary symbol with BinIdx of 1 can use a coding method based on the context model. The binary symbol represented by x can use a bypass coding method.

[0513] The encoder converts the value of a syntax element (such as intra_tmp_idx here) into a corresponding binary symbol (bin), and then uses the entropy coding engine to convert the binary symbol into a binary symbol (bit). The decoder's entropy coding (decoding) engine converts the binary symbol (bit) into a binary symbol, and then converts the binary symbol (bin) into the value of the syntax element.

[0514] The context model-based encoding method and bypass encoding method are two modes of the entropy coding engine. During encoding, the entropy coding engine converts binary symbols into binary symbols in the code stream. During decoding, the entropy coding engine converts binary symbols in the code stream into binary symbols. The context model-based encoding method can be understood as follows: the more a value (0 or 1) of a binary symbol of a syntax element appears in the context, the more the entropy coding engine will tend to use fewer binary symbols to correspond to that binary symbol and more binary symbols to correspond to another binary symbol. For example, if a binary symbol of a syntax element appears more frequently as 1, fewer binary symbols will be used to encode 1, and more binary symbols will be used to encode 0. The bypass encoding method is equivalent to using an equal probability model. Therefore, the bypass encoding method has a higher throughput than the context model-based mode. The context model-based encoding method theoretically has higher compression efficiency.

[0515] For example, in some embodiments, such as Table 6, where N is 19, x, y, and z in the same row of the table can be derived using truncated binary. Specifically, the last two binary symbols of numbers 3 to 6 are derived using truncated binary, the last two binary symbols of numbers 7 to 10 are derived using truncated binary, and the last three binary symbols of numbers 11 to 18 are derived using truncated binary.

[0516] The binary symbol with BinIdx=0 can use the encoding method based on the context model.

[0517] When the value of the binary symbol with BinIdx being 0 is 1 (corresponding to the above cases where intra_tmp_idx is 0, 1, 2), the binary symbol with BinIdx being 1 can use a context model-based encoding method.

[0518] When the value of the binary symbol with BinIdx being 0 is 0 (corresponding to the above case where intra_tmp_idx is greater than 2), the binary symbol with BinIdx being 1 can use a context model-based encoding method and use a context model different from the cases where intra_tmp_idx is 0, 1, or 2.

[0519] When the value of the binary symbol with BinIdx being 0 is 0 and the value of the binary symbol with BinIdx being 1 is 1 (corresponding to the above case where intra_tmp_idx is 3 to 10), the binary symbol with BinIdx being 2 can use a context model-based encoding method.

[0520] The binary symbols represented by x, y, and z can use a bypass encoding method.

[0521] The values ​​0 and 1 above are just an example. It is also possible that the values ​​0 and 1 are opposite but the results are equivalent. Reversing the order of the binary symbols in the truncated binary is also equivalent.

[0522] For example, in some embodiments, if the decoder is not instructed in the bitstream which template to use, but different templates are used to construct the same block vector candidate list, then an example of decoding syntax is as follows, which is the same as the syntax of using multiple candidates alone:

[0523] The decoder uses the TL template, L template, and T template to construct a list of block vector candidates. Each block vector in the list may be obtained by template matching using one of the TL template, L template, or T template. The key point of this method is how to construct the block vector candidate list.

[0524] The advantage of this combination method is that it does not require explicit instruction on which template to use, and the overhead is lower than that of combination method 1. Compared with combination method 1, it is more flexible. If the block vector candidate list is constructed well enough, a template with a higher matching degree will be ranked higher.

[0525] A basic principle in constructing a list is to sort by template matching cost. The matching costs of several different templates need to be compared, but the number of pixels in each template varies. For example, directly comparing the SADs of different templates is illogical. For the same BV, the SAD of the TL template equals the SAD of the T template plus the SAD of the L template. One approach is to compare based on the number of pixels in each template. A simple example is to divide the SAD by the number of pixels in the template to obtain the average absolute difference, which can be called the AAD (average absolute difference). This approach allows comparison, but it involves division, which is very expensive to implement in hardware, so it should be avoided. One approach is to multiply the SADs of different templates by a coefficient to make them comparable. Assuming the TL template contains the T and L templates, the TL template always has the largest number of pixels. Therefore, only the T and L templates can be multiplied by the coefficient, while the TL template does not.

[0526] The SAD of the TL template is denoted as SAD TL , the SAD of the T template is SAD T , the SAD of the L template is SAD L The matching cost of the TL template used for comparison with other templates is COST TL , the matching cost of T template is COST T , the matching cost of L template is COST L .

[0527] One method is COST TL =SAD TL COST T =SAD T *COEF T COST L =SAD L *COEF L

[0528] Among them, COEF T and COEF L It can be calculated by the number of pixels of several templates. COEF of different block sizes T and COEF L It can be calculated in advance. For example, if the TL template does not include the upper left corner, that is, the TL template is equal to the T template plus the L template, and if the width of the current block is equal to the height, then COEF T Equal to 2, COEF L Equal to 2. But this still cannot avoid COEF T or COEF LFor example, if width is twice the height, COEF T Equal to 1.5, COEF L Equal to 3.

[0529] One method is COST TL =SAD TL *COEF TL COST T =SAD T *COEF T COST L =SAD L *COEF L

[0530] Among them, COEF TL , COEF T and COEF L It can be calculated by the number of pixels of several templates. COEF of different block sizes TL , COEF T and COEF L It can be calculated in advance. For example, if the TL template does not include the upper left corner, that is, the TL template is equal to the T template plus the L template, and if the width of the current block is equal to the height, then COEF TL Equal to 1, COEF T Equal to 2, COEF L Equal to 2. For example, if width is twice the height, COEF TL Equal to 2, COEF T Equal to 3, COEF L Equal to 6. The method for calculating the coefficient of the specified template can be to divide the least common multiple of the number of pixels of each template by the number of pixels of the specified template.

[0531] The above method allows the matching costs of different templates to be compared after adjustment and can be sorted together.

[0532] Imagine the matching cost of the TL template, the matching cost of the T template, and the matching cost of the L template for the same BV. If the matching degree of the T template and the matching degree of the L template (such as the AAD mentioned above) are different, even if they are only slightly different, then the COST calculated according to the pixel ratio will be T or COST L There must be one less than COST TLIn other words, if we directly compare the matching costs of the TL, T, and L templates using the above method, the TL template will be at a disadvantage in most cases. This means that only the parts with the highest matching scores will be compared between different BVs. However, because the TL template covers more adjacent areas, and in most cases the texture is continuous from the left and top, it is unreasonable to indiscriminately replace the TL template with the T and L templates.

[0533] One strategy is to convert COEF T and COEF L Artificially expand them so that they can be TL Compare. This is different from the above operation, which only mechanically eliminates the influence of the number of pixels. This is because the TL template is generally disadvantaged compared to the T template and the L template, so it needs to be adjusted. For example, for COEF T and COEF L Multiply by a factor greater than 1.

[0534] Another strategy is as follows: in the first step of intraTmp multiple candidate search (coarse search with a certain step length), a certain number of BVs are first screened out based on the matching cost of the TL template. These BVs are used as the positioning points for the second step of search (improved search). The matching of the TL template, T template, and L template of several BVs is analyzed. If the COST corresponding to a certain BV is found T and COST L Big difference, or COST T or COST L If the COST value is greater than a preset value, you can use a template with a higher matching degree from the T template or L template to improve the search. T and COST L The difference is not big, and TL templates are still used to improve the search.

[0535] On the other hand, some restrictions can be placed on the number of candidates selected by the T and L templates in the same list. For example, an upper limit can be set for the number of candidates selected by the T and / or L templates. When the number of candidates selected by the T and / or L templates in the list reaches the upper limit, no more candidates selected by the T and / or L templates will be added to the list.

[0536] It should be noted that in the embodiments of this application, if only a single list is constructed, there is no need to use syntax elements in the bitstream to indicate which template to select. However, since the template matching costs of different templates cannot be directly compared, certain rules must be established to ensure that they can be placed in the same list. A straightforward approach is to sort candidates from the same template by template matching cost, while candidates from different templates are not sorted by template matching cost and are directly placed in a given position.

[0537] For example, in some embodiments, the length of the final block vector candidate list is assumed to be N. A list of length N is first constructed using the TL template, using the same construction method as the IntraTmp multi-candidate list construction method described above. The template matching costs of the searched BVs are calculated using a preset search method, and the BVs are sorted by template matching cost, with the lowest cost placed at the front.

[0538] The maximum number of T and L templates that can be included in the final block vector candidate list is M. Due to the need for duplicate checking when adding them to the list, the final number that can be included may be less than M. For example, N is 15 and M is 2, that is, the final list length is 15, the maximum number of candidates for T templates can be 2, and the maximum number of candidates for L templates can be 2. Another example is N is 19 and M is 3, that is, the final list length is 19, the maximum number of candidates for T templates can be 3, and the maximum number of candidates for L templates can be 3.

[0539] Specify the position Pos with the smallest index, or the frontmost position, where the T and L templates can be placed. An example is to calculate Pos based on N and M, such as Pos = N - 1 - M × 2. You can also specify the frontmost position in the list for each T and L template, but this is not detailed here.

[0540] Based on the block vector candidate list of the TL template, try to put the candidates of the T template and the L template into it.

[0541] Try to put the T template and L template candidates into the block vector candidate list. A preset search method can be used to find X T template candidates and X L template candidates with the best template matching cost. The X T template candidates and X L template candidates can each construct a temporary list of length X. Try to put the T template and L template candidates into the final block vector candidate list. You can first perform a duplicate check. If the same BV as the candidate to be put in the list already exists in the list, it will not be put into the list. If the same BV as the candidate to be put in the list does not exist in the list, the candidates in the specified position and later in the original list will be moved back in sequence and placed in the specified position in the list. Each time one is put in, the specified position will be moved back by one. This is done until all the candidates in the M or X temporary lists have been checked.

[0542] One approach to the search process is to use the same search process for the TL template as for the T and L templates. This allows the matching costs of the TL template to be calculated simultaneously with the matching costs of the T and L templates, without significantly increasing the search complexity. For example, during the same search process, lists can be constructed for the TL template, T template, and L template, and then combined into the final list of candidate block vectors after the search is complete.

[0543] The T template and the L template can also use separate search processes from the TL template. Of course, some search processes can be shared and some search processes can be separated.

[0544] The first step is a sparse search: During the search process, not every possible BV is searched sequentially. For example, the usual search order is from left to right and from top to bottom. Generally speaking, integer-pixel BVs can be searched sequentially. If the current BV being searched is (x0, y0), the next one is (x0+1, y0), provided that the search range boundary has not been reached. However, here we can first perform a sparse search. For example, for integer-pixel BVs, if the current BV being searched is (x0, y0), the next one is (x0+3, y0), provided that the search range boundary has not been reached. In other words, template matching is performed every certain number of pixels, or every certain step size. The step size here can be a preset value, such as 2, 3, 4, 8, etc. Of course, the same process can be applied vertically. First, find the BV with the lowest TL template cost for K. K may be equal to N, or it may be greater than or less than N. This process can be achieved by constructing a list. Simultaneously find the BVs with the minimum cost for X' T templates and the minimum cost for X' L templates. X' may be equal to, greater than, or less than M. This process can be achieved by constructing a list. In other words, each BV in this search step is simultaneously sorted by the template matching cost of the TL template, T template, and L template, effectively using a shared sparse search process.

[0545] The second step is to improve the search: Based on the BV with the lowest cost for the K TL templates, improvements are performed within a small range based on each BV. If the search interval above is 3 pixels, then the improvement range can be set to 3x3, and the improved BV can be used to construct a block vector candidate list of length N. Then, based on the BV with the lowest cost for the X' T templates and L templates, improvements are performed within a small range based on each BV. If the search interval above is 3 pixels, then the improvement range can be set to 3x3, and the improved BV can be used to construct a temporary block vector candidate list of length X for the T template and a temporary block vector candidate list for the L template. Then, according to the above method, the TL template list of length N, the T template list of length X, and the L template list of length X are combined into the final block vector candidate list.

[0546] An example is N=15, K=2N, M=2, X=4, X'=2X.

[0547] If sub-pixel accuracy is supported, the BV can be further refined to sub-pixel levels. For example, a 1 / 2 pixel search can be performed within a pixel range above, below, or to the left of the whole pixel BV selected in the second step.

[0548] Sharing the sparse search process does not significantly increase the search complexity. In the large-scale sparse search, the improved search ranges of the TL template, T template, and L template can be found separately. The improved search can be performed on different templates, making it more targeted.

[0549] To sum up, the encoding and decoding method proposed in the embodiment of the present application can provide multiple options by constructing an intraTMP multi-candidate list of block vector candidates corresponding to the current block, and the first template corresponding to the current block, which can include one or more candidate templates, can provide multiple options at the template level. The combination of the two can improve compression efficiency and obtain better compression performance.

[0550] That is to say, the encoding and decoding method proposed in the embodiment of the present application can combine the intraTMP multiple candidates with the multiple selections at the template level. In the process of combining the two, one way to implement the combination is to indicate which template to use in the bitstream; another way to implement the combination is not to indicate which template to use in the bitstream, but to use different templates to construct the same block vector candidate list.

[0551] The embodiment of the present application provides a coding method, wherein the codec determines a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; a block vector candidate list corresponding to the current block is determined based on the first template; a block vector corresponding to the current block is determined based on the block vector candidate list corresponding to the current block, and a prediction value of the current block is determined based on the block vector. It can be seen that in the embodiment of the present application, a prediction method combining intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected, and a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing a combination of intraTMP multiple candidates and multiple selections at the template level. In other words, the coding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and improving coding and decoding performance.

[0552] In another embodiment of the present application, see Figure 22, which shows a schematic diagram of the structure of an encoder provided by an embodiment of the present application. As shown in Figure 22, the encoder 180 may include: a first determining unit 1801; wherein,

[0553] The first determination unit 1801 is configured to determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determine a block vector candidate list corresponding to the current block based on the first template; determine a block vector corresponding to the current block based on the block vector candidate list corresponding to the current block, and determine a prediction value of the current block based on the block vector.

[0554] It is understandable that in the embodiments of the present application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and of course it can also be a module, or it can be non-modular. Moreover, the various components in this embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into a single unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional modules.

[0555] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, or the portion that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0556] Therefore, an embodiment of the present application provides a computer-readable storage medium, which is applied to the encoder 180. The computer-readable storage medium stores a computer program, and when the computer program is executed by the first processor, it implements the method described in any one of the aforementioned embodiments.

[0557] Based on the composition of the encoder 180 and the computer-readable storage medium, refer to Figure 23, which shows a specific hardware structure diagram of the encoder 180 provided in an embodiment of the present application. As shown in Figure 23, the encoder 180 may include: a first communication interface 1901, a first memory 1902 and a first processor 1903; each component is coupled together through a first bus system 1904. It can be understood that the first bus system 1904 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 1904 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are labeled as the first bus system 1904. Among them,

[0558] The first communication interface 1901 is used to receive and send signals when sending and receiving information with other external network elements;

[0559] A first memory 1902 is used to store computer programs that can be run on the first processor 1903;

[0560] The first processor 1903 is configured to perform the following processing when running the computer program: determining a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determining a candidate list of block vectors corresponding to the current block based on the first template; determining a block vector corresponding to the current block based on the candidate list of block vectors corresponding to the current block, and determining a predicted value of the current block based on the block vector.

[0561] It is understood that the first memory 1902 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, 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 link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The first memory 1902 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0562] The first processor 1903 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in the first processor 1903. The above-mentioned first processor 1903 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the first memory 1902 , and the first processor 1903 reads the information in the first memory 1902 and completes the steps of the above method in combination with its hardware.

[0563] It is to be understood that these embodiments described in the present application can be implemented with hardware, software, firmware, middleware, microcode or its combination.For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing equipment (DSP Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other electronic units for performing functions described in the present application or its combination.For software implementation, the technology described in the present application can be realized by the module (such as process, function etc.) that performs functions described in the present application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0564] Optionally, as another embodiment, the first processor 1903 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.

[0565] In another embodiment of the present application, see FIG24, which shows a schematic diagram of the structure of a decoder provided by an embodiment of the present application. As shown in FIG24, the decoder 200 may include: a second determining unit 2001; wherein,

[0566] The second determination unit 2001 is configured to determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determine a candidate list of block vectors corresponding to the current block based on the first template; determine a block vector corresponding to the current block based on the candidate list of block vectors corresponding to the current block, and determine a predicted value of the current block based on the block vector.

[0567] It is understood that in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular system. Furthermore, the various components in this embodiment can be integrated into a single processing unit, or each unit can exist physically separately, or two or more units can be integrated into a single unit. The aforementioned integrated units can be implemented in the form of hardware or software functional modules.

[0568] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this embodiment provides a computer-readable storage medium, which is applied to the decoder 200 and stores a computer program. When the computer program is executed by the second processor, it implements any of the methods in the aforementioned embodiments.

[0569] Based on the composition of the decoder 200 and the computer-readable storage medium, refer to Figure 25, which shows a specific hardware structure diagram of the decoder 200 provided in an embodiment of the present application. As shown in Figure 25, the decoder 200 may include: a second communication interface 2201, a second memory 2202 and a second processor 2203; each component is coupled together through a second bus system 2204. It can be understood that the second bus system 2204 is used to achieve connection and communication between these components. In addition to the data bus, the second bus system 2204 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, all buses are labeled as the second bus system 2204. Among them,

[0570] The second communication interface 2201 is used to receive and send signals during the process of sending and receiving information between other external network elements;

[0571] The second memory 2202 is used to store computer programs that can be run on the second processor 2203;

[0572] The second processor 2203 is configured to perform the following processing when running the computer program: determining a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determining a candidate list of block vectors corresponding to the current block based on the first template; determining a block vector corresponding to the current block based on the candidate list of block vectors corresponding to the current block, and determining a predicted value of the current block based on the block vector.

[0573] Optionally, as another embodiment, the second processor 2203 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.

[0574] It can be understood that the hardware functions of the second memory 2202 are similar to those of the first memory 1902, and the hardware functions of the second processor 2203 are similar to those of the first processor 1903; they will not be described in detail here.

[0575] The present embodiment provides a codec that determines a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determines a block vector candidate list corresponding to the current block based on the first template; determines a block vector corresponding to the current block based on the block vector candidate list corresponding to the current block, and determines a prediction value of the current block based on the block vector. It can be seen that in the embodiment of the present application, a prediction method that combines intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected, and a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing a combination of intraTMP multiple candidates and multiple selections at the template level. That is, the coding and decoding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and improving coding and decoding performance.

[0576] In yet another embodiment of the present application, referring to FIG26 , a schematic diagram of the structure of a coding and decoding system provided by an embodiment of the present application is shown. As shown in FIG26 , the coding and decoding system 230 may include an encoder 2301 and a decoder 2302 .

[0577] In the embodiment of the present application, the encoder 2301 may be the encoder described in any one of the aforementioned embodiments, and the decoder 2302 may be the decoder described in any one of the aforementioned embodiments.

[0578] Furthermore, an embodiment of the present application also provides a code stream, wherein the code stream is generated by bit encoding based on the information to be encoded; wherein the information to be encoded includes at least one of the following: template matching prediction identification information, first template indication information, second template indication information, third template indication information, index identification information, and prediction difference.

[0579] It should be noted that, in this application, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0580] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0581] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0582] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0583] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0584] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims. Industrial Applicability

[0585] The embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder, and a storage medium, wherein the encoder and decoder determine a first template corresponding to a current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; a block vector candidate list corresponding to the current block is determined based on the first template; a block vector corresponding to the current block is determined based on the block vector candidate list corresponding to the current block, and a prediction value of the current block is determined based on the block vector. Thus, in the embodiment of the present application, a prediction method combining intra TMP multiple candidates with multiple templates is proposed, wherein a block vector candidate list including at least one block vector of the current block can be selected, and a first template including at least one candidate template can be selected to construct the block vector candidate list, thereby realizing a combination of intraTMP multiple candidates and multiple selections at the template level. That is, the coding and decoding method proposed in the embodiment of the present application, on the one hand, realizes intraTMP multiple candidates by constructing a block vector candidate list corresponding to the current block, and on the other hand, uses the first template corresponding to the current block including one or more candidate templates to provide multiple selections at the template level, thereby improving compression efficiency and encoding and decoding performance.

Claims

1. A decoding method, applied to a decoder, the method comprising: Determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; Determine a block vector candidate list corresponding to the current block according to the first template; A block vector corresponding to the current block is determined according to a block vector candidate list corresponding to the current block, and a prediction value of the current block is determined according to the block vector.

2. The method according to claim 1, wherein: The method further comprises: Decoding the bitstream to determine the template matching prediction identification information corresponding to the current block; If the value of the template matching prediction identification information is the first value, the determination process of the first template is executed.

3. The method according to claim 2, wherein: The determining the first template corresponding to the current block includes: Decoding the bitstream to determine first template indication information corresponding to the current block; If the value of the first template indication information is the third value, the first template is determined to be the first candidate template.

4. The method according to claim 3, wherein: The determining the first template corresponding to the current block includes: If the value of the first template indication information is the fourth value, decoding the bitstream to determine the second template indication information corresponding to the current block; If the value of the second template indication information is the fifth value, determining the first template as the second candidate template; If the value of the second template indication information is the sixth value, the first template is determined to be the third candidate template.

5. The method according to claim 2, wherein: The determining the first template corresponding to the current block includes: Decoding the bitstream, and determining third template indication information corresponding to the current block; If the value of the third template indication information is the seventh value, determining that the first template is the first candidate template; If the value of the third template indication information is the eighth value, determining that the first template is the second candidate template; If the value of the third template indication information is the ninth value, the first template is determined to be the third candidate template.

6. The method according to claim 2, wherein: The determining the first template corresponding to the current block includes: Decoding a bitstream to determine a candidate index corresponding to the current block; If the value of the candidate index is less than or equal to a preset threshold, the first template is determined to be a first candidate template.

7. The method according to claim 6, wherein: The method further comprises: If the value of the candidate index is greater than the preset threshold, decoding the bitstream to determine the third template indication information corresponding to the current block; If the value of the third template indication information is the seventh value, determining that the first template is the first candidate template; If the value of the third template indication information is the eighth value, determining that the first template is the second candidate template; If the value of the third template indication information is the ninth value, the first template is determined to be the third candidate template.

8. The method according to any one of claims 4, 5 and 7, wherein: The first candidate template is a template including left adjacent reconstructed samples and top adjacent reconstructed samples of the current block; The second candidate template is a template including an upper adjacent reconstructed sample of the current block; The third candidate template is a template including left adjacent reconstructed samples of the current block.

9. The method according to claim 4, wherein: The method further comprises: Determine search parameters corresponding to the first template according to the first template; wherein the search parameters include at least one of the following parameters: search range, search order, and list length.

10. The method according to claim 9, wherein: The determining, according to the first template, a block vector candidate list corresponding to the current block includes: A search is performed based on the search parameter and the first template to determine the block vector candidate list.

11. The method according to claim 2 or 9, wherein: The determining, according to the first template, a block vector candidate list corresponding to the current block includes: Determine a preset search area corresponding to the first template; Traversing the search points in the preset search area, and determining the matching cost between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; The block vector candidate list is determined according to the matching cost.

12. The method according to claim 11, wherein: The step of determining the block vector candidate list according to the matching cost includes: Determine N minimum matching costs among the matching costs between the matching template corresponding to the search point in the preset search area and the first template; wherein N is the list length of the block vector candidate list, and N is an integer greater than 0, The block vector candidate list is determined according to the N block vectors corresponding to the N minimum matching costs and the N candidate templates.

13. The method according to claim 11, wherein: The preset matching criteria include: any one of the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC.

14. The method according to claim 11, wherein: The method further comprises: Traversing the search points in the preset search area according to a first search step length to determine an initial block vector and an initial matching template corresponding to the initial vector block; Determine a first search area according to the initial matching template; wherein the first search area is smaller than the preset search area; The block vector candidate list is determined by traversing the search points in the first search area according to a second search step length; wherein the first search step length is greater than the second search step length.

15. The method according to claim 14, wherein: The method further comprises: If the first template includes multiple candidate templates in the template set, a template coefficient corresponding to each candidate template is determined.

16. The method according to claim 15, wherein: The determining of the template coefficient corresponding to each candidate template includes: The template coefficient is determined according to the size parameter corresponding to the candidate template.

17. The method according to claim 15, wherein: The determining of the template coefficient corresponding to each candidate template includes: The template coefficient is determined according to the pixel parameters corresponding to the candidate template.

18. The method according to claim 15, wherein: The template coefficient corresponding to the candidate template is set according to a preset value.

19. The method according to any one of claims 16 to 18, wherein: The method further comprises: Traversing the search points in the preset search area, and determining the initial cost between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; Adjusting the initial cost according to the template coefficient to determine a matching cost between a matching template corresponding to a search point in the preset search area and the first template; The block vector candidate list is determined according to the matching cost.

20. The method according to claim 15, wherein: The method further comprises: Traversing the search points in the preset search area, and determining the initial cost between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; Adjusting the initial cost according to the pixel parameters corresponding to the candidate template to determine the matching cost between the matching template corresponding to the search point in the preset search area and the first template; The block vector candidate list is determined according to the matching cost.

21. The method according to claim 15, wherein: The method further comprises: An upper threshold corresponding to each candidate template is determined, and the number of block vectors in the block vector candidate list corresponding to the candidate template is determined according to the upper threshold.

22. The method according to claim 8, wherein: If the first template includes at least the first candidate template, the second candidate template and the third candidate template, the method further includes: Determine a second search area according to the first candidate template, and traverse the search points in the second search area according to the first search step length to determine an initial block vector; A third search area is determined based on the initial block vector and the first template, and search points in the third search area are traversed according to a second search step length to determine the block vector candidate list; wherein the first search step length is greater than the second search step length.

23. The method according to claim 8, wherein: If the first template includes at least the first candidate template, the second candidate template and the third candidate template, the method further includes: Searching based on the first candidate template, determining a first list corresponding to the first candidate template; Searching based on the second candidate template, determining a second list corresponding to the second candidate template; Searching based on the third candidate template, determining a third list corresponding to the third candidate template; The first list is adjusted according to the second list and the third list to determine the block vector candidate list.

24. The method according to claim 8, wherein: If the first template includes at least the first candidate template, the second candidate template and the third candidate template, the method further includes: Search based on the first candidate template, the second candidate template, and the third candidate template to respectively determine a first list corresponding to the first candidate template, a second list corresponding to the second candidate template, and a third list corresponding to the third candidate template; The first list is adjusted according to the second list and the third list to determine the block vector candidate list.

25. The method according to claim 23 or 24, wherein: The step of adjusting the first list according to the second list and the third list to determine the block vector candidate list includes: Determine a first starting position corresponding to the second list and a second starting position corresponding to the third list; According to the first starting position, the block vectors in the second list are added to the first list, and at the same time, according to the second starting position, the block vectors in the third list are added to the first list to obtain the block vector candidate list.

26. The method according to claim 25, wherein: The method further comprises: adding a block vector in the second list that is not present in the first list to the first starting position in the first list; Block vectors in the third list that are not present in the first list are added to the second starting position in the first list.

27. The method according to claim 3, wherein: The method further comprises: If the value of the template matching prediction identification information is the first value, decoding the bitstream to determine the index identification information corresponding to the current block; A candidate index corresponding to the current block is determined according to the index identification information.

28. The method according to claim 27, wherein: The determining the block vector corresponding to the current block according to the block vector candidate list corresponding to the current block includes: According to the candidate index, a block vector corresponding to the current block is determined from the block vector candidate list.

29. The method according to claim 27, wherein: The method further comprises: If the value of the first template indication information is the third value, determining the index identification information according to the first context; If the value of the first template indication information is the fourth value, the index identification information is determined according to the second context.

30. The method of claim 27, wherein: The determining, according to the index identification information, a candidate index corresponding to the current block includes: If the value of the first template indication information is the third value, determining the candidate index according to the index identification information and the first debinarization strategy; If the value of the first template indication information is the fourth value, the candidate index is determined according to the index identification information and the second debinarization strategy.

31. The method of claim 1, wherein: The method further comprises: Decoding the bitstream to determine a prediction difference corresponding to the current block; A reconstructed value of the current block is determined according to the prediction difference and the prediction value.

32. The method of claim 1, wherein: The method further comprises: Based on different template types, the template set corresponding to the current block is constructed.

33. A coding method, applied to an encoder, the method comprising: Determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; Determine a block vector candidate list corresponding to the current block according to the first template; A block vector corresponding to the current block is determined according to a block vector candidate list corresponding to the current block, and a prediction value of the current block is determined according to the block vector.

34. The method of claim 33, wherein: The method further comprises: Determine the template matching prediction identification information corresponding to the current block; If the value of the template matching prediction identification information is the first value, the determination process of the first template is executed.

35. The method of claim 34, wherein: The determining the first template corresponding to the current block includes: Determine first template indication information corresponding to the current block; If the value of the first template indication information is the third value, the first template is determined to be the first candidate template.

36. The method of claim 35, wherein: The determining the first template corresponding to the current block includes: If the value of the first template indication information is the fourth value, determining the second template indication information corresponding to the current block; If the value of the second template indication information is the fifth value, determining the first template as the second candidate template; If the value of the second template indication information is the sixth value, the first template is determined to be the third candidate template.

37. The method of claim 34, wherein: The determining the first template corresponding to the current block includes: Determine third template indication information corresponding to the current block; If the value of the third template indication information is the seventh value, determining that the first template is the first candidate template; If the value of the third template indication information is the eighth value, determining that the first template is the second candidate template; If the value of the third template indication information is the ninth value, the first template is determined to be the third candidate template.

38. The method of claim 34, wherein: The determining the first template corresponding to the current block includes: Determine a candidate index corresponding to the current block; If the value of the candidate index is less than or equal to a preset threshold, the first template is determined to be a first candidate template.

39. The method of claim 38, wherein: The method further comprises: If the value of the candidate index is greater than the preset threshold, determining the third template indication information corresponding to the current block; If the value of the third template indication information is the seventh value, determining that the first template is the first candidate template; If the value of the third template indication information is the eighth value, determining that the first template is the second candidate template; If the value of the third template indication information is the ninth value, the first template is determined to be the third candidate template.

40. The method according to any one of claims 36, 37, and 39, wherein: The first candidate template is a template including left adjacent reconstructed samples and top adjacent reconstructed samples of the current block; The second candidate template is a template including an upper adjacent reconstructed sample of the current block; The third candidate template is a template including left adjacent reconstructed samples of the current block.

41. The method of claim 36, wherein: The method further comprises: Determine search parameters corresponding to the first template according to the first template; wherein the search parameters include at least one of the following parameters: search range, search order, and list length.

42. The method according to claim 41, wherein: The determining, according to the first template, a block vector candidate list corresponding to the current block includes: A search is performed based on the search parameter and the first template to determine the block vector candidate list.

43. The method according to claim 34 or 41, wherein: The determining, according to the first template, a block vector candidate list corresponding to the current block includes: Determine a preset search area corresponding to the first template; Traversing the search points in the preset search area, and determining the matching cost between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; The block vector candidate list is determined according to the matching cost.

44. The method of claim 43, wherein: The step of determining the block vector candidate list according to the matching cost includes: Determine N minimum matching costs among the matching costs between the matching template corresponding to the search point in the preset search area and the first template; wherein N is the list length of the block vector candidate list, and N is an integer greater than 0, The block vector candidate list is determined according to the N block vectors corresponding to the N minimum matching costs and the N candidate templates.

45. The method of claim 43, wherein: The preset matching criteria include: any one of the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC.

46. ​​The method of claim 43, wherein: The method further comprises: Traversing the search points in the preset search area according to a first search step length to determine an initial block vector and an initial matching template corresponding to the initial vector block; Determine a first search area according to the initial matching template; wherein the first search area is smaller than the preset search area; The block vector candidate list is determined by traversing the search points in the first search area according to a second search step length; wherein the first search step length is greater than the second search step length.

47. The method of claim 46, wherein: The method further comprises: If the first template includes multiple candidate templates in the template set, a template coefficient corresponding to each candidate template is determined.

48. The method of claim 47, wherein: The determining of the template coefficient corresponding to each candidate template includes: The template coefficient is determined according to the size parameter corresponding to the candidate template.

49. The method of claim 47, wherein: The determining of the template coefficient corresponding to each candidate template includes: The template coefficient is determined according to the pixel parameters corresponding to the candidate template.

50. The method of claim 47, wherein: The template coefficient corresponding to the candidate template is set according to a preset value.

51. A method according to any one of claims 48 to 50, wherein: The method further comprises: Traversing the search points in the preset search area, and determining the initial cost between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; Adjusting the initial cost according to the template coefficient to determine a matching cost between a matching template corresponding to a search point in the preset search area and the first template; The block vector candidate list is determined according to the matching cost.

52. The method of claim 47, wherein: The method further comprises: Traversing the search points in the preset search area, and determining the initial cost between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; Adjusting the initial cost according to the pixel parameters corresponding to the candidate template to determine the matching cost between the matching template corresponding to the search point in the preset search area and the first template; The block vector candidate list is determined according to the matching cost.

53. The method of claim 47, wherein: The method further comprises: An upper threshold corresponding to each candidate template is determined, and the number of block vectors in the block vector candidate list corresponding to the candidate template is determined according to the upper threshold.

54. The method of claim 40, wherein: If the first template includes at least the first candidate template, the second candidate template and the third candidate template, the method further includes: Determine a second search area according to the first candidate template, and traverse the search points in the second search area according to the first search step length to determine an initial block vector; A third search area is determined based on the initial block vector and the first template, and search points in the third search area are traversed according to a second search step length to determine the block vector candidate list; wherein the first search step length is greater than the second search step length.

55. The method of claim 40, wherein: If the first template includes at least the first candidate template, the second candidate template and the third candidate template, the method further includes: Searching based on the first candidate template, determining a first list corresponding to the first candidate template; Searching based on the second candidate template, determining a second list corresponding to the second candidate template; Searching based on the third candidate template, determining a third list corresponding to the third candidate template; The first list is adjusted according to the second list and the third list to determine the block vector candidate list.

56. The method of claim 40, wherein: If the first template includes at least the first candidate template, the second candidate template and the third candidate template, the method further includes: Search based on the first candidate template, the second candidate template, and the third candidate template to respectively determine a first list corresponding to the first candidate template, a second list corresponding to the second candidate template, and a third list corresponding to the third candidate template; The first list is adjusted according to the second list and the third list to determine the block vector candidate list.

57. The method of claim 55 or 56, wherein: The step of adjusting the first list according to the second list and the third list to determine the block vector candidate list includes: Determine a first starting position corresponding to the second list and a second starting position corresponding to the third list; According to the first starting position, the block vectors in the second list are added to the first list, and at the same time, according to the second starting position, the block vectors in the third list are added to the first list to obtain the block vector candidate list.

58. The method of claim 57, wherein: The method further comprises: adding a block vector in the second list that is not present in the first list to the first starting position in the first list; Adding the block vectors in the third list that are not present in the first list to the second starting position in the first list; 59. The method of claim 35, wherein: The method further comprises: If the value of the template matching prediction identification information is the first value, determining the index identification information corresponding to the current block; A candidate index corresponding to the current block is determined according to the index identification information.

60. The method of claim 59, wherein: The determining the block vector corresponding to the current block according to the block vector candidate list corresponding to the current block includes: According to the candidate index, a block vector corresponding to the current block is determined from the block vector candidate list.

61. The method of claim 59, wherein: The method further comprises: If the value of the first template indication information is the third value, determining the index identification information according to the first context; If the value of the first template indication information is the fourth value, the index identification information is determined according to the second context.

62. The method of claim 59, wherein: The determining, according to the index identification information, a candidate index corresponding to the current block includes: If the value of the first template indication information is the third value, determining the candidate index according to the index identification information and the first binarization strategy; If the value of the first template indication information is the fourth value, the candidate index is determined according to the index identification information and the second binarization strategy.

63. The method of claim 33, wherein: The method further comprises: Determining a prediction difference corresponding to the current block; A reconstructed value of the current block is determined according to the prediction difference and the prediction value.

64. The method of claim 33, wherein: The method further comprises: Based on different template types, the template set corresponding to the current block is constructed.

65. A code stream, wherein The code stream is generated by bit encoding according to the information to be encoded; wherein the information to be encoded includes at least one of the following: Template matching prediction identification information, first template indication information, second template indication information, third template indication information, index identification information, prediction difference.

66. An encoder, comprising a first determining unit; wherein, The first determination unit is configured to determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determine a block vector candidate list corresponding to the current block according to the first template; determine a block vector corresponding to the current block according to the block vector candidate list corresponding to the current block, and determine a prediction value of the current block according to the block vector.

67. An encoder comprising a first memory and a first processor; wherein: The first memory is used to store a computer program that can be run on the first processor; The first processor is configured to execute the method according to any one of claims 33 to 64 when running the computer program.

68. A decoder comprising a second determination unit; wherein: The second determination unit is configured to determine a first template corresponding to the current block; wherein the first template is one or more candidate templates in a template set corresponding to the current block; determine a block vector candidate list corresponding to the current block according to the first template; determine a block vector corresponding to the current block according to the block vector candidate list corresponding to the current block, and determine a prediction value of the current block according to the block vector.

69. A decoder, comprising a second memory and a second processor; wherein: The second memory is used to store a computer program that can be run on the second processor; The second processor is configured to execute the method according to any one of claims 1 to 32 when running the computer program.

70. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 32 is implemented, or the method according to any one of claims 33 to 64 is implemented.