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

CN120982082APending Publication Date: 2025-11-18GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380096781.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing intra-frame template matching prediction techniques have low prediction accuracy in certain scenarios, resulting in poor encoding and decoding performance.

Method used

The IntraTMP fusion intra-prediction mode is adopted. By combining template matching and non-template matching, multiple prediction blocks of the current block are determined and fused to improve prediction accuracy.

Benefits of technology

It improves the accuracy of intra-frame prediction and encoding/decoding performance, making it suitable for more encoding/decoding scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120982082A_ABST
    Figure CN120982082A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a coding and decoding method, a code stream, a coder, a decoder and a storage medium. The method comprises the following steps: decoding related syntax elements of a current block; according to the related syntax elements, determining that the current block uses an IntraTMP fusion intra-frame prediction mode to perform prediction; determining a matching block of the current block based on a prediction mode of template matching, and determining a first prediction block of the current block according to the matching block; determining a second prediction block of the current block based on an intra prediction mode of non-template matching; and fusing the first prediction block and the second prediction block, and determining a final prediction block of the current block. Thus, whether the current block is predicted by using the IntraTMP fusion intra-frame prediction mode or not is indicated by coding and decoding related syntax elements, the prediction efficiency is improved, meanwhile, the IntraTMP fusion intra-frame prediction mode combines IntraTMP technologies such as IntraTMP multiple candidates, IntraTMP multiple matching block fusion and IntraTMP filtering to adapt to more coding and decoding scenes, and the prediction accuracy and the coding and decoding efficiency are ensured.
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 present application relates 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 reconstructed block corresponding to the matching template as the matching block, which is used as the prediction block of the current coding block.

[0003] However, in the actual encoding process, related technologies usually directly use the reconstructed pixels of the matching block as the predicted pixels of the current encoding block. However, due to incomplete consideration, there will be large deviations in some scenarios, resulting in low prediction accuracy.

[0004] Summary of the Invention

[0005] The present application provides a coding and decoding method, a bit stream, an encoder, a decoder and a storage medium, which can improve prediction accuracy and thus enhance coding and decoding performance.

[0006] The technical solution of this 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] Decoding relevant syntax elements of the current block; wherein the relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra prediction mode;

[0009] Determining, according to the relevant syntax elements, that the current block is predicted using the IntraTMP fusion intra prediction mode;

[0010] Determining a matching block of the current block based on a prediction mode of template matching, and determining a first prediction block of the current block according to the matching block;

[0011] Determining a second prediction block for the current block based on a non-template matching intra prediction mode;

[0012] The first prediction block and the second prediction block are merged to determine a final prediction block of the current block.

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

[0014] Determining a matching block of the current block based on a prediction mode of template matching, and determining a first prediction block of the current block according to the matching block;

[0015] Determining a second prediction block for the current block based on a non-template matching intra prediction mode;

[0016] Fusing the first prediction block and the second prediction block to determine a final prediction block of the current block;

[0017] Make an encoding decision based on the final predicted block and the original block of the current block to determine whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode;

[0018] Encode the relevant syntax elements of the current block and write the obtained coded bits into the bitstream;

[0019] The relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra-frame prediction mode.

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

[0021] Syntax element used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, syntax element used to indicate whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode, syntax element used to indicate whether to filter the first matching block, syntax element used to filter the prediction block of the current block, syntax element used to indicate the index value of the first matching block in the candidate matching block list, syntax element used to indicate the index value of the first candidate matching block group in the candidate matching block list, syntax element used to indicate the intra-frame prediction mode of non-template matching, syntax element used to indicate whether to decode the relevant syntax elements of the current block, the number of matching blocks in the candidate matching block group, the value N of the number of matching blocks when multiple matching blocks are fused, the length of the first candidate matching block list, and the length of the second candidate matching block list.

[0022] In a fourth aspect, an embodiment of the present application provides an encoder, comprising a first prediction unit, a first determination unit, and an encoding unit; wherein:

[0023] The first prediction unit is configured to determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block;

[0024] The first prediction unit is configured to determine a second prediction block of the current block based on a non-template matching intra prediction mode;

[0025] The first prediction unit is configured to fuse the first prediction block and the second prediction block to determine a final prediction block of the current block;

[0026] The first determining unit is configured to make an encoding decision based on the final predicted block and the original block of the current block, and determine whether the current block is predicted using the IntraTMP fusion intra prediction mode;

[0027] The encoding unit is configured to encode relevant syntax elements of the current block and write the obtained coded bits into the bitstream;

[0028] The relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra-frame prediction mode.

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

[0030] a first memory for storing a computer program capable of running on the first processor;

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

[0032] In a sixth aspect, an embodiment of the present application provides a decoder, comprising a decoding unit, a second determining unit, and a second predicting unit; wherein:

[0033] The decoding unit is configured to decode relevant syntax elements of the current block; wherein the relevant syntax elements are used to indicate whether the current block is predicted using an intra prediction mode based on intra template matching prediction IntraTMP;

[0034] The second determining unit is configured to determine, based on the relevant syntax elements, whether the current block is predicted using the IntraTMP fusion intra prediction mode;

[0035] The second prediction unit is configured to determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block;

[0036] The second prediction unit is further configured to determine a second prediction block of the current block based on a non-template matching intra prediction mode;

[0037] The second prediction unit is further configured to fuse the first prediction block and the second prediction block to determine a final prediction block of the current block.

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

[0039] a second memory for storing a computer program capable of running on the second processor;

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

[0041] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed, implements the method described in the first aspect or the method described in the second aspect.

[0042] The embodiment of the present application provides a coding and decoding method, code stream, encoder, decoder and storage medium, which decodes the relevant syntax elements of the current block; determines whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode based on the relevant syntax elements; determines the matching block of the current block based on the template matching prediction mode, and determines the first prediction block of the current block based on the matching block; determines the second prediction block of the current block based on the non-template matching intra-frame prediction mode; fuses the first prediction block and the second prediction block to determine the final prediction block of the current block. In this way, by coding and decoding relevant syntax elements, it is indicated whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode, thereby improving prediction efficiency. At the same time, the IntraTMP fusion intra-frame prediction mode combines IntraTMP technologies such as IntraTMP multiple candidates, IntraTMP multi-matching block fusion and IntraTMP filtering to adapt to more coding and decoding scenarios, ensuring prediction accuracy and coding and decoding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] FIG1 is a schematic diagram of a prediction process of an Intra TMP technology;

[0044] FIG2 is a schematic diagram of a matching block of an Intra TMP technology;

[0045] FIG3 is a schematic diagram of a template type of Intra TMP technology;

[0046] FIG4A is a schematic diagram of a coarse search process of template matching in an intra TMP technique;

[0047] FIG4B is a schematic diagram of a detailed search process for template matching in an intra TMP technique;

[0048] FIG5 is a schematic diagram of weighted fusion of an IntraTMP fusion prediction technology;

[0049] FIG6A is a schematic diagram of a filter shape;

[0050] FIG6B is a schematic diagram of a filter coefficient derivation method;

[0051] FIG7 is a schematic diagram of a method for dividing a coding block vertically and horizontally;

[0052] FIG8A is a schematic block diagram of an encoder provided in an embodiment of the present application;

[0053] FIG8B is a schematic block diagram of a decoder according to an embodiment of the present application;

[0054] FIG9 is a schematic diagram of a network architecture of a coding and decoding system provided in an embodiment of the present application;

[0055] FIG10 is a schematic diagram of a flowchart of a decoding method provided in an embodiment of the present application;

[0056] FIG11 is a schematic flow chart of a matching block reordering method according to an embodiment of the present application;

[0057] FIG12 is a schematic diagram of a template prediction method in an intra-frame prediction mode according to an embodiment of the present application;

[0058] FIG13 is a schematic diagram of the template weighted fusion process in an embodiment of the present application;

[0059] FIG14 is a schematic flow chart of a method for reordering intra-frame prediction modes according to an embodiment of the present application;

[0060] FIG15 is a flowchart of a method for determining a first candidate matching block group in an embodiment of the present application;

[0061] FIG16 is a schematic diagram of a flow chart of an encoding method provided in an embodiment of the present application;

[0062] FIG17 is a schematic diagram of the structure of an encoder provided in an embodiment of the present application;

[0063] FIG18 is a schematic diagram of a specific hardware structure of an encoder provided in an embodiment of the present application;

[0064] FIG19 is a schematic diagram of the structure of a decoder provided in an embodiment of the present application;

[0065] FIG20 is a schematic diagram of a specific hardware structure of a decoder provided in an embodiment of the present application;

[0066] FIG21 is a schematic diagram of the composition structure of a coding and decoding system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0067] 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.

[0068] 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.

[0069] 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.

[0070] 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:

[0071] Coding Block (CB);

[0072] Block Matching (BM);

[0073] Coding Unit (CU);

[0074] Block Vector (BV);

[0075] Sum of Absolute Difference (SAD);

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

[0077] Mean Square Error (MSE);

[0078] Sum of Squared Differences (SSD);

[0079] Mean Absolute Deviation (MAD);

[0080] Mean Square Differences (MSD);

[0081] Normalized Correlation Coefficient (NCC);

[0082] Rate Distortion Optimization (RDO);

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

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

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

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

[0087] 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.

[0088] 1) IntraTMP technology

[0089] Intra TMP technology, abbreviated as IntraTMP, is a specialized intra-frame prediction technology. It is a specialized intra-frame prediction coding tool primarily used for screen content encoding. IntraTMP is implemented through the following process: Reconstructed pixels adjacent to the current coding block are selected as a template. The most similar template is searched for within the reconstructed region of the given current frame. The reconstructed block corresponding to the most similar template is then used as a matching block, which is then used as the prediction block for the current coding block. The template for the coding block is typically selected from the reconstructed region adjacent to the current coding block.

[0090] For example, taking the adjacent reconstructed area of ​​the current block as an example, as shown in Figure 1, the area filled with a grid represents the reconstructed area. In the reconstructed area, R1, R2, R3, and R4 are search areas. R1 to R4 search for matching blocks in sequence. The adjacent area of ​​the current block is the first template (T); and the adjacent area of ​​the matching block (also called the "reference block") is the second template (i.e., the "reference template" or "matching template", T_BEST). As shown in Figure 2, both the encoder and the decoder search the predefined search range in the current image using the template (T) of the coding block to determine the matching template (T_BEST) with the smallest template error value, and then use the reconstructed block (Ref Block) corresponding to the matching template as the prediction block for the current coding block (Cur Block). The degree of similarity between templates is represented by the size of the template error value. The smaller the template error value, the higher the degree of similarity. In an embodiment of the present application, the template error value can be the absolute error sum SAD, the absolute transformation difference sum SATD, the mean square error MSE, the error square sum SSD, the mean absolute difference MAD, the mean error square sum MSD, the normalized correlation coefficient NCC, etc., which is not specifically limited here.

[0091] For example, taking absolute error and SAD as an example, the template error value at this time is as follows:

[0092] Among them, T i is the template in the search process, and M represents the number of pixels in the template.

[0093] It should be noted that the Intra TMP technology uses the adjacent reconstructed pixels of the current block as templates to search for matching templates within a predefined search area, where the adjacent reconstructed pixels can be the upper reference pixel, upper left reference pixel, upper right reference pixel, left reference pixel, lower left reference pixel, etc. of the current block. Therefore, the template type can be classified and the corresponding template type can be determined based on the availability of the adjacent reconstructed pixels.

[0094] It should also be noted that refTemplateType can be used to represent a template type. Figure 3 shows a schematic diagram of template types for the Intra TMP technology. As shown in Figure 3, the block filled with a grid is the current block, and the adjacent area of ​​the current block is the template T. Six template types are shown here.

[0095] For example, the six template types are as follows:

[0096] When the upper left reference pixel, the upper reference pixel, and the left reference pixel are all available, the value of refTemplateType is 1, and the template shape is as shown in (a) of Figure 3;

[0097] When only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is shown in (b) in Figure 3;

[0098] When only the upper reference pixel is available, the value of refTemplateType is 3, and the template shape is shown in (c) in Figure 3;

[0099] When only the left reference pixel and the upper left reference pixel are available, the value of refTemplateType is 4, and the template shape is shown in (d) in Figure 3;

[0100] When only the left reference pixel and the lower left reference pixel are available, the value of refTemplateType is 5, and the template shape is shown in (e) of Figure 3;

[0101] When only the upper reference pixel and the upper right reference pixel are available, the value of refTemplateType is 6, and the template shape is shown in (f) in Figure 3.

[0102] In intra TMP technology, the codec uses the flag intra_tmp_flag to indicate whether the current coded block is encoded using the intraTMP mode. If so, the decoder performs the same template matching process to obtain the same predicted block, eliminating the need for additional encoding of the block vector information from the current coded block to the matching block. The following example illustrates intra TMP technology.

[0103] 2) IntraTMP adaptation technology for camera-captured content

[0104] The IntraTMP adaptation for camera-captured content technology builds on the existing IntraTMP technology by performing template matching with a step size S (i.e., every S points in the horizontal and vertical directions, where S>1) (as shown in Figure 4A). For example, rather than searching for matching blocks point by point using a raster scan, the search area is searched for alternate points in the horizontal and vertical directions. For example, if the current template matching block vector is (X0, Y0), the next template matching block vector should be (X0+S, Y0), and the vertical coordinate of the next template matching block vector should be Y0+S. After template matching is complete, the best matching block is refined within a certain range (as shown in Figure 4B, where template matching is performed with a smaller step size S') to optimize the matching result. This technology effectively reduces the complexity of the IntraTMP mode while maintaining good coding efficiency.

[0105] 3) IntraTMP multi-candidate technology

[0106] IntraTMP multi-candidate technology uses a template matching process to obtain N candidate matching blocks within the reference area, or to construct a candidate block list of length N. The candidate matching blocks in the list can be sorted by the template error value between them and the current block. A candidate block in the list is selected as the final prediction block by index. For a coded block using IntraTMP multi-candidate technology, after decoding the IntraTMP flag intra_tmp_flag as true, it continues to decode intra_tmp_idx. The intra_tmp_idx syntax element can represent the index of the selected candidate block.

[0107] Exemplarily, a template matching process for constructing a candidate block list is as follows:

[0108] The first step is to perform the first search with a certain step size, for example, both the horizontal step size and the vertical step size are 4. N optimal matching blocks with a certain spacing are obtained (the first N with the smallest template error value);

[0109] In the second step, a second search is performed in the N neighboring areas of the matching blocks obtained in the first step. These neighboring areas can be set to multiple non-overlapping areas based on the step size in the first step. M optimal matching blocks are obtained from these areas (which may include the matching blocks obtained in the first step).

[0110] The same construction process is used at the encoding and decoding ends to obtain a consistent list of candidate blocks.

[0111] Intra_tmp_idx may use fixed-length encoding or variable-length encoding, for example, truncated binary encoding.

[0112] A variable length encoding method is:

[0113] The smaller the index (the smaller the intra_tmp_idx value), the smaller the template error value of the corresponding candidate block, and the greater the probability of being selected statistically. You can set a shorter codeword for a smaller intra_tmp_idx. For example:

[0114] If the maximum value N of intra_tmp_idx is large, a codeword of the same length may be allocated to the larger intra_tmp_idx, for example, N is 15.

[0115] In the above table, x can be obtained using truncated binary.

[0116] 4) IntraTMP fusion prediction technology, also known as IntraTMP multi-matching block fusion technology

[0117] Through intra-frame template matching, we can obtain the template error values ​​between the reconstructed blocks and the current coding block at different positions. These reconstructed blocks can be represented by block vectors pointing to the reconstructed blocks from the current coding block. A candidate block vector list is constructed to record the block vectors with the smallest template error values ​​during the template matching process. Based on conditions such as the block vector spacing and the template error value, one or more block vectors are selected from the candidate block vector list, and the reconstructed blocks they point to are used as matching blocks for the current coding block. A weight value is determined for each matching block. These matching blocks are weighted and fused according to their weight values ​​to obtain the final prediction block, thus achieving IntraTMP combined fusion prediction. The process is shown in Figure 5.

[0118] The number of matching blocks to be fused can be a fixed value or determined based on the size of the template error values ​​of each matching block. For example, for the N available matching blocks, a threshold Threshold = minSAD << 1 is set, where minSAD is the minimum template error value among these matching blocks. Only matching blocks with a template error value less than or equal to this threshold are used in the fusion process. This method can determine the matching blocks for fusion.

[0119] After the matching blocks for fusion are determined, the weight of each matching block can be determined by using a preset fixed value, calculating based on the template error value, or deducing based on the template.

[0120] 5) IntraTMP filtering

[0121] The matching block (also called the reference block) obtained by intra-frame template matching is usually used directly as the prediction block for the current block. The prediction block can be filtered to improve the prediction effect. A block-level flag can be used to indicate whether the current block uses the filtering process for the prediction block.

[0122] There are many forms of filters. One possible filter form is as follows: PredC = c0C + c1N + c2S + c3E + c4W + c5B

[0123] Where C is the pixel to be filtered, N is the pixel above it, S is the pixel below it, W is the pixel to its left, and E is the pixel to its right, as shown in Figure 6A. B (Bias) is a fixed value, for example, B is the median of the pixel range. c0 to c5 are the filter coefficients.

[0124] One method for determining filter coefficients is to train the filter coefficients using a reference block template and the current block template. For example, the template area is the reconstruction area four rows above and four columns to the left of the current block. For the reference block, an additional row of area above, below, and to the left of the template area is also required as a reference. As shown in Figure 6B, if part of the additional area is not fully encoded, it can be copied from the template area.

[0125] One method for training filter coefficients is to calculate a set of coefficients so that the template error between the filtered reference block template and the current block template is minimized.

[0126] If the current block uses IntraTMP filtering, one method is to filter the prediction block directly obtained from the reference block. One method is to filter each pixel in order from left to right and from top to bottom, and use the filtered value as the prediction value.

[0127] 6) Template-derived IntraTMP fusion

[0128] IntraTMP fusion prediction can obtain multiple reference blocks through the intra-frame template matching process and perform weighted fusion on these reference blocks. The weight values ​​are usually predefined fixed values ​​or calculated based on the error of each reference block template. The template-derived IntraTMP fusion method uses a method similar to filter coefficient training to obtain the weights used for fusion prediction based on the training of each reference block template and the current block template. For example, using 5 reference blocks for weighted fusion, the form is as follows:

[0129] One weighted approach is to calculate a set of coefficients so that the template error between the reference block template and the current block template is minimized.

[0130] 7) Template-based intra-frame mode derivation technology

[0131] The Template-Based Intra Mode Derivation (TIMD) technique uses the reconstructed pixels of the L-shaped portion adjacent to the current coding block as a template. By traversing the MPM list, the predicted pixels of the template area under different intra prediction modes are calculated. The template error values ​​of the predicted and reconstructed pixels under different intra prediction modes are obtained, represented by the Sum of Absolute Transformed Difference (SATD). The optimal intra prediction mode is selected based on the template error value. At the decoding end, the intra prediction mode is obtained through the same derivation method, thereby reducing the coding bits of the mode information.

[0132] 8) Joint intra-frame and inter-frame prediction technology

[0133] Combined Inter and Intra Prediction (CIIP) technology combines intra prediction and inter prediction to obtain the prediction block of the current coding block using a weighted combination of intra prediction blocks and inter prediction blocks. CIIP in ECM is combined with template-based prediction technology, and different weight values ​​are assigned to different areas, further improving the accuracy of the prediction. Specifically, its intra prediction block pred_intra is obtained by the TIMD mode, and the inter prediction block pred_inter is obtained by the template-based Merge mode. According to the derived intra prediction mode and the position of the pixel to be predicted, the weight values ​​wIntra and wInter are determined. The final prediction block Pred is calculated as follows: Pred = (wIntra*pred_intra+wInter*pred_inter+4)>>3

[0134] Among them, wIntra and wInter are determined by the intra prediction mode intra_dir derived from TIMD. There are 65 intra-frame angular prediction modes in ECM (2≤intra_dir<=66). When 2≤intra_dir<34, the current coding block is divided into four equal parts vertically; when 34<=intra_dir<=66, the current coding block is divided into four equal parts horizontally. The weight values ​​of wIntra and wInter for each region are:

[0135] The indexes of each region under vertical or horizontal quartering are shown in Figure 7. In particular, when intra_dir is equal to 0 or 1, no sub-region is divided, and wIntra and wInter are selected from (3, 1), (2, 2), and (1, 3) according to the coding type (intra-frame or inter-frame) of the two coding blocks located on the left and above.

[0136] 9) IntraTMP fusion intra-frame prediction

[0137] The IntraTMP fusion intra-frame prediction mode obtains a matching block through intra-frame template matching, and then fuses other intra-frame prediction blocks into a prediction block for the current coding block. Specifically, a matching block of the current coding block is obtained as prediction block 1 through intra-frame template matching; prediction block 2 of the current coding block is obtained through an intra-frame prediction mode other than IntraTMP; weight values ​​are determined for prediction blocks 1 and 2; and these prediction blocks are weighted and fused according to their weight values ​​to obtain the final prediction block, implementing IntraTMP combined fusion prediction. Whether to use this fusion prediction mode can be indicated by a block-level flag.

[0138] Among them, the intra-frame prediction mode can be derived by methods such as TIMD, and the weighted fusion process can be similar to the fusion process of the CIIP method, using weight values ​​related to the intra-frame angle and pixel position, so as to further improve the prediction accuracy.

[0139] 10) Intra-frame block copy technology

[0140] Intra Block Copy (IBC) is an intra-frame prediction technique that uses block matching to obtain predicted pixels. Similar to inter-frame prediction, prediction is achieved by using a block vector pointing from the current block to a reference block. The difference is that the reference block for inter-frame prediction comes from the encoded reconstructed frame, while the reference block for IBC comes from the reconstructed portion of the current frame. Block vector information needs to be transmitted in the codestream, so similar to intra-frame prediction, there are IBC-AMVP mode and IBC-Merge mode.

[0141] The IBC-AMVP mode obtains the predicted block vector by constructing a list of candidate block vectors, and obtains the reference block and the corresponding final block vector of the current block through hash search, full search, etc. The final block vector is encoded according to the predicted block vector to improve coding efficiency;

[0142] The IBC-Merge mode predicts by constructing a list of candidate block vectors. Through encoding processes such as SATD and RDO, the best block vector in the list is selected as the final block vector. The reconstructed block it points to is used as the reference block to complete the prediction. The index of the block vector in the list is encoded rather than the block vector itself, improving coding efficiency.

[0143] The candidate block vector list may be composed of coding information such as block vectors of adjacent coding blocks, historical block vectors, and average block vectors.

[0144] However, in actual encoding, each of these Intra TMP techniques has its own advantages. When used alone, due to incomplete considerations, they can lead to significant deviations in certain scenarios, resulting in low prediction accuracy. By integrating multiple Intra TMP techniques, the present embodiment enables Intra TMP to be applied in more scenarios, improving intra-frame prediction accuracy and ultimately enhancing encoding and decoding performance.

[0145] Referring to FIG8A , which shows a block diagram of an encoder provided in an embodiment of the present application. As shown in FIG8A , 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 may implement deblocking filtering and sample adaptive offset (SAO) filtering, and the encoding unit 109 may 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 .

[0146] Referring to FIG8B , which shows a block diagram of a decoder provided in an embodiment of the present application, as shown in FIG8B , 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 encoded as shown in FIG8A , 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.

[0147] Furthermore, an embodiment of the present application also provides a network architecture of a coding and decoding system including an encoder and a decoder, wherein FIG9 shows a schematic diagram of a network architecture of a coding and decoding system provided by an embodiment of the present application. As shown in FIG9 , 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., which are not specifically limited here. In addition, the decoder or encoder described in the embodiment of the present application can be the above-mentioned electronic device.

[0148] 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 8A and the intra-frame prediction unit 203 shown in Figure 8B. 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 simultaneously, but the embodiment of the present application is not specifically limited thereto.

[0149] 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.

[0150] In one embodiment of the present application, referring to FIG10 , a schematic flow chart of a decoding method provided by an embodiment of the present application is shown. As shown in FIG10 , the method may include:

[0151] Step 1001: Decode relevant syntax elements of the current block; wherein the relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra prediction mode;

[0152] Step 1002: Determine, based on the relevant syntax elements, whether the current block should be predicted using the IntraTMP fusion intra prediction mode;

[0153] It should be noted that the relevant syntax elements can be understood as being used to indicate the prediction mode of the current block, specifically, to indicate the IntraTMP prediction mode, and more specifically, to indicate whether the prediction mode of the current block is the IntraTMP fusion intra-frame prediction mode.

[0154] In some embodiments, the relevant syntax elements include: a first syntax element and / or a second syntax element; wherein the first syntax element is used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode; and the second syntax element is used to indicate whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode.

[0155] In some embodiments, the relevant syntax elements further include at least one of the following: a syntax element for indicating whether the current block is allowed to be predicted using the IntraTMP prediction mode; a syntax element for indicating whether the current block is predicted using an IntraTMP prediction mode other than the IntraTMP fusion prediction mode; a syntax element for indicating whether the current block is predicted using an IntraTMP fusion prediction mode other than the IntraTMP fusion intra-frame prediction mode; a syntax element for indicating whether the current block is predicted using the IntraTMP multi-match block fusion prediction mode; a syntax element for indicating whether the current block is predicted using the IntraTMP multi-candidate prediction mode. In practical applications, these syntax elements can be one or more of block-level syntax elements, slice-level syntax elements, slice-level syntax elements, picture-level syntax elements, and sequence-level syntax elements.

[0156] It should be noted that the IntraTMP prediction mode refers to a prediction mode based on intra-frame template matching, and the IntraTMP fusion prediction mode can be understood as a fusion prediction mode based on intra-frame template matching. The IntraTMP fusion prediction mode includes the IntraTMP fusion intra-frame prediction mode and other IntraTMP fusion prediction modes other than the IntraTMP fusion intra-frame prediction mode. Exemplarily, the other IntraTMP fusion prediction modes include any prediction mode that uses matching blocks obtained based on template matching to participate in the fusion, such as the IntraTMP multi-matching block fusion prediction mode, the joint intra-frame and inter-frame prediction mode, and the template-derived IntraTMP fusion.

[0157] It should be noted that the value of the first syntax element can be a first numerical value or a second numerical value, and each value of the first syntax element is used to indicate a specific meaning. Exemplarily, when the value of the first syntax element is the first numerical value, it is a syntax element used to indicate that the current block allows prediction using the IntraTMP fusion intra-frame prediction mode; or, when the value of the first syntax element is the second numerical value, it is a syntax element used to indicate that the current block allows prediction using the IntraTMP fusion intra-frame prediction mode. Exemplarily, the first numerical value can be 1, and the second numerical value can be 0.

[0158] In some examples, the first syntax element comprises a block-level syntax element. In some embodiments, the first syntax element further comprises at least one of: a slice-level syntax element, a slice-level syntax element, a picture-level syntax element, and a sequence-level syntax element.

[0159] In some examples, the second syntax element comprises a block-level syntax element. In some embodiments, the second syntax element further comprises at least one of: a slice-level syntax element, a slice-level syntax element, a picture-level syntax element, and a sequence-level syntax element.

[0160] In some embodiments, the decoding of the relevant syntax elements of the current block includes: decoding the first syntax element; when the value of the first syntax element is a first value, determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and decoding the second syntax element; the value of the second syntax element is a first numerical value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; the value of the second syntax element is a second numerical value, determining that the current block is predicted using the IntraTMP multi-match block fusion prediction mode.

[0161] It should be noted that determining whether the current block is allowed to use the IntraTMP fusion intra prediction mode for prediction, further decoding the second syntax element, and determining whether the current block is predicted using the IntraTMP fusion intra prediction mode or the IntraTMP multi-match block fusion prediction mode based on the value of the second syntax element. IntraTMP multi-match block fusion prediction and IntraTMP fusion intra prediction are used as two fusion prediction modes, and the block-level flag indicates which fusion prediction mode to use.

[0162] Exemplarily, a related syntax element includes:

[0163] Among them, intra_tmp_fusion_flag has the function of the first syntax element, and intra_tmp_intra_flag has the function of the second syntax element. Intra_tmp_flag is used to indicate that the current block allows prediction using the IntraTMP prediction mode. Decode the IntraTMP related syntax elements. If intra_tmp_flag is true, it means that the current block uses the IntraTMP prediction mode, and further decode intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it means that the current block allows prediction using the IntraTMP fusion intra-frame prediction mode. Further decode intra_tmp_intra_flag; if intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra-frame prediction mode is used. If intra_tmp_intra_flag is false, it indicates that the IntraTMP multi-match block fusion mode is used.

[0164] In some embodiments, the decoding of the relevant syntax elements of the current block includes: decoding the first syntax element; when the value of the first syntax element is a first value, determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and decoding the second syntax element; the value of the second syntax element is a first numerical value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; the value of the second syntax element is a second numerical value, determining that the current block is predicted using the IntraTMP multi-candidate prediction mode.

[0165] It should be noted that it is determined whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and further, the second syntax element is decoded, and according to the value of the second syntax element, it is determined whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode or the IntraTMP multi-candidate prediction mode. The IntraTMP multi-candidate prediction mode can be understood as an IntraTMP prediction mode based on a single matching block. Taking the IntraTMP multi-matching block fusion prediction and the IntraTMP fusion intra-frame prediction as two fusion prediction modes, the IntraTMP multi-candidate prediction mode extends the IntraTMP fusion intra-frame prediction mode, and indicates through a block-level flag whether the selected matching block is fused with the second prediction block obtained by the intra-frame prediction mode. Furthermore, the selected first matching block can also be indicated by an index value.

[0166] In some embodiments, the decoding of relevant syntax elements of the current block includes: when the value of the first syntax element is a first value, determining that the current block is predicted using the IntraTMP multi-match block fusion prediction mode; when the value of the first syntax element is a second value, determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and decoding the second syntax element; the value of the second syntax element is a first numerical value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; the value of the second syntax element is a second numerical value, determining that the current block is predicted using the IntraTMP multi-candidate prediction mode.

[0167] It should be noted that when the value of the first syntax element is the first numerical value, it is determined that the current block is predicted using the IntraTMP multi-match block fusion prediction mode, that is, it is determined that the current block is not allowed to be predicted using the IntraTMP fusion intra-frame prediction mode. In addition to being used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, the first syntax element is also used to indicate whether the current block is predicted using the IntraTMP multi-match block fusion prediction mode. The IntraTMP multi-match block fusion prediction mode, the IntraTMP multi-candidate prediction mode, and the IntraTMP fusion intra-frame prediction mode are used as three prediction modes. The block-level flag indicates which prediction mode is selected and indicates whether the selected matching block is fused with the second prediction block obtained by the intra-frame prediction mode.

[0168] Exemplarily, a related syntax element includes:

[0169] Among them, if intra_tmp_flag is true, it means that the current block uses the IntraTMP prediction mode, and further decodes intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it means that the current block uses the IntraTMP multi-matching block fusion mode. If intra_tmp_fusion_flag is false, it means that the coding block uses the prediction mode of a single matching block, and it can also mean that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, and further decodes intra_tmp_intra_flag; if intra_tmp_intra_flag is true, it means that the IntraTMP fusion intra-frame prediction mode is used. If intra_tmp_intra_flag is false, it means that the prediction mode of a single matching block is used, that is, the IntraTMP multi-candidate prediction mode is used.

[0170] In some embodiments, the above prediction mode can also integrate IntraTMP filtering technology. Exemplarily, the relevant syntax element also includes a third syntax element; in some embodiments, it also includes: decoding the third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block or whether to filter the prediction block of the current block. Exemplarily, the value of the third syntax element is a first numerical value, which determines whether to filter the first matching block or the prediction block of the current block. The value of the third syntax element is a second numerical value, which determines not to filter the first matching block or the prediction block of the current block.

[0171] In some embodiments, the second syntax element and the third syntax element are decoded.

[0172] In some embodiments, it is determined that the current block allows prediction using the IntraTMP fusion intra prediction mode, and a third syntax element is decoded; in some embodiments, it is determined that the current block uses the IntraTMP multi-candidate prediction mode for prediction, and a third syntax element is decoded.

[0173] It should be noted that the first matching block is the first matching block determined by the prediction mode based on template matching. Whether to filter the first matching block or the prediction block of the current block can be pre-determined. Alternatively, two syntax elements can be used to indicate whether to filter the first matching block and whether to filter the prediction block of the current block, respectively. Alternatively, only one syntax element can be configured, with the other pre-determined.

[0174] Exemplarily, a related syntax element includes:

[0175] or

[0176] Among them, based on the above embodiment, if it is determined that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, the intra_tmp_filter_flag is decoded. If the intra_tmp_filter_flag is true, it indicates that the selected matching block is filtered. If the intra_tmp_filter_flag is false, it indicates that the selected matching block is not filtered. It should be noted that if the intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra-frame prediction mode is used, and the first selected matching block is used for fusion intra-frame prediction. If the intra_tmp_intra_flag is false, it indicates that the selected matching block is not fused with the intra-frame prediction block, indicating that the prediction mode of a single matching block is used, that is, the IntraTMP multi-candidate prediction mode is used.

[0177] In some embodiments, index information may also be transmitted to indicate which matching block in the candidate matching block list is to be fused. The relevant syntax elements also include a fourth syntax element. The method further includes: determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and decoding the fourth syntax element; wherein the fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list; or, the fourth syntax element is used to indicate the index value of the first candidate matching block group in the candidate matching block list.

[0178] Exemplarily, a related syntax element includes:

[0179] If intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra prediction mode is used, and intra_tmp_intra_idx indicates which matching block is fused with the intra prediction block. If intra_tmp_intra_flag is false, it indicates that the IntraTMP multi-matching block fusion mode is used, and intra_tmp_intra_idx indicates which candidate matching block group in the candidate matching block list is grouped for multi-matching block fusion. intra_tmp_intra_idx can also be called intra_tmp_fusion_idx.

[0180] Exemplarily, a related syntax element includes:

[0181] Among them, if intra_tmp_intra_flag is true, it means using the IntraTMP fusion intra-frame prediction mode, and intra_tmp_intra_idx indicates which matching block is fused with the intra-frame prediction block; if intra_tmp_intra_flag is false, it means using the IntraTMP multi-candidate prediction mode, and intra_tmp_intra_idx indicates which matching block is predicted.

[0182] In some embodiments, the first and fourth syntax elements are decoded; the fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list; or the fourth syntax element is used to indicate the index value of the first candidate matching block group in the candidate matching block list. In some embodiments, the first matching block corresponding to the current block is saved, specifically the BV of the first matching block. In some embodiments, the index value of the first candidate matching block group corresponding to the current block is saved. In some embodiments, a preset matching block in the first candidate matching block group corresponding to the current block is saved as reference information for other decoded blocks.

[0183] In some embodiments, when the value of the first syntax element is the first value, it is determined that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode; the index value of the first candidate matching block group is determined according to the fourth syntax element; when the value of the first syntax element is the second value, it is determined that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and the second syntax element is decoded; the value of the second syntax element is the first value, and it is determined that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; in some embodiments, the index value of the first matching block is determined according to the fourth syntax element; the value of the second syntax element is the second value, and it is determined that the current block is predicted using the IntraTMP multi-candidate prediction mode; in some embodiments, the index value of the first matching block is determined according to the fourth syntax element.

[0184] Exemplarily, a related syntax element includes:

[0185] If intra_tmp_flag is true, it means that the current block uses the IntraTMP prediction mode, and intra_tmp_fusion_flag is further decoded; if intra_tmp_fusion_flag is true, it means that the current block uses the IntraTMP multi-matching block fusion mode, and intra_tmp_fusion_idx indicates which candidate matching block group in the candidate matching block list is to be fused with multiple matching blocks. By transmitting the index value of the group, the best candidate matching block group can be quickly located, which can improve the prediction accuracy and efficiency. If intra_tmp_fusion_flag is false, it means that the coding block uses the prediction mode of a single matching block, or it can indicate that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, and further decodes intra_tmp_intra_flag; if intra_tmp_intra_flag is true, it means that the IntraTMP fusion intra-frame prediction mode is used, and intra_tmp_fusion_idx indicates which matching block is fused with the intra-frame prediction block; if intra_tmp_intra_flag is false, it means that the prediction mode of a single matching block is used, that is, the IntraTMP multiple candidate prediction mode is used, and intra_tmp_intra_idx indicates which matching block is predicted. For example, if intra_tmp_idx is equal to i, the i+1th matching block in the candidate matching block list is the selected matching block, i starts at 0, and the index value starts at 1. Alternatively, if intra_tmp_idx is equal to i, the i-th matching block in the candidate matching block list is the selected matching block, and the value of i starts from 0, and the index value also starts from 0.

[0186] In some embodiments, the above prediction mode can also be integrated with the IntraTMP filtering technology. Exemplarily, a related syntax element includes:

[0187] Decode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the coding block is encoded using the IntraTMP mode, and further decode intra_tmp_fusion_flag. If intra_tmp_fusion_flag is true, it determines that the IntraTMP fusion intra-frame prediction mode is used, and further decode intra_tmp_intra_flag, intra_tmp_filter_flag, and intra_tmp_idx (the order can be reversed). Among them, intra_tmp_idx indicates the index of the selected matching block in the candidate matching block list. If intra_tmp_filter_flag is true, it indicates that the selected matching block is filtered. If intra_tmp_filter_flag is false, it indicates that the selected matching block is not filtered. If intra_tmp_intra_flag is true, it indicates that the selected matching block is fused with the intra-frame prediction block. If intra_tmp_intra_flag is false, it indicates that the selected matching block is not fused with the intra-frame prediction block.

[0188] Decode IntraTMP related syntax elements. If intra_tmp_flag is true, it means that the coding block is encoded using the IntraTMP mode, and further decode intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it means that the coding block is predicted using the multi-matching block fusion method; if intra_tmp_fusion_flag is false, it means that the coding block uses the prediction method of a single matching block, which can also be understood as determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and further decode intra_tmp_intra_flag, intra_tmp_filter_flag and intra_tmp_idx (the order can be reversed). Among them, intra_tmp_idx represents the index of the selected matching block in the candidate matching block list; intra_tmp_filter_flag is true, indicating that the selected matching block is filtered, and intra_tmp_filter_flag is false, indicating that the selected matching block is not filtered; intra_tmp_intra_flag is true, indicating that the selected matching block is used to merge with the intra-frame prediction block, and intra_tmp_intra_flag is false, indicating that the selected matching block is not merged with the intra-frame prediction block.

[0189] In some embodiments, intra_tmp_intra_idx and intra_tmp_fusion_idx can also be decoded in different ways according to intra_tmp_intra_flag. Exemplarily, the relevant syntax elements also include a fourth syntax element and a fifth syntax element. The method also includes: determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode, decoding the fourth syntax element; determining the index value of the first matching block in the candidate matching block list according to the fourth syntax element; or determining that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode, decoding the fifth syntax element; determining the index value of the first candidate matching block group in the candidate matching block list according to the fifth syntax element. The index ranges of the index values ​​indicated by the fifth syntax element and the fourth syntax element are the same or different.

[0190] Exemplarily, a related syntax element includes:

[0191] or

[0192] Based on the above embodiment, if it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode, intra_tmp_intra_idx (the fourth syntax element) is decoded to indicate the index value of the selected matching block in the candidate matching block list. If it is determined that the IntraTMP multi-matching block fusion prediction mode is used, intra_tmp_fusion_idx (the fifth syntax element) is decoded to indicate the index value of the first selected candidate matching block group in the candidate matching block list. The value ranges of intra_tmp_intra_idx and intra_tmp_fusion_idx can be the same or different.

[0193] In some embodiments, intra_tmp_intra_idx and intra_tmp_idx can also be decoded in different ways according to intra_tmp_intra_flag. The relevant syntax elements also include a fourth syntax element and a sixth syntax element. The method also includes: determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode, decoding the fourth syntax element; determining the index value of the first matching block in the candidate matching block list according to the fourth syntax element; or determining that the current block is predicted using the IntraTMP multi-candidate prediction mode, decoding the sixth syntax element; determining the index value of the first matching block in the candidate matching block list according to the sixth syntax element. The index ranges of the index values ​​indicated by the sixth syntax element and the fourth syntax element are the same or different.

[0194] Exemplarily, a related syntax element includes:

[0195] Among them, on the basis of the above embodiment, if it is determined that the current block is predicted using the IntraTMP fusion intra-frame prediction mode, intra_tmp_intra_idx (the fourth syntax element) is decoded to indicate the index value of the selected matching block in the candidate matching block list. If it is determined to use the IntraTMP multi-candidate prediction mode, intra_tmp_idx (the sixth syntax element) is decoded to indicate the index value of the selected matching block in the candidate matching block list. The value ranges of intra_tmp_intra_idx and intra_tmp_idx can be the same or different. Exemplarily, the maximum value of the value range of intra_tmp_intra_idx is less than the maximum value of the value range of intra_tmp_idx, the value range of intra_tmp_intra_idx is 0-3, and the value range of intra_tmp_idx is 0-15.

[0196] In some embodiments, IntraTMP fusion intra prediction and IntraTMP filtering may not be used simultaneously. Exemplarily, determining that the current block is predicted using the IntraTMP fusion intra prediction mode includes: determining, based on the value of the third syntax element, not to filter the first matching block or not to filter the prediction block of the current block, and decoding the second syntax element; when the value of the second syntax element is a first value, determining that the current block is predicted using the IntraTMP fusion intra prediction mode.

[0197] Furthermore, the method further includes: decoding a fourth syntax element; wherein the fourth syntax element is used to indicate an index value of the first matching block in the candidate matching block list.

[0198] Exemplarily, a related syntax element includes:

[0199] Among them, based on the above embodiment, if it is determined that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, decode intra_tmp_filter_flag (the third syntax element). If intra_tmp_filter_flag is false, it indicates that the single matching block is not filtered, decode intra_tmp_intra_flag (the second syntax element), further decode intra_tmp_idx (the fourth syntax element), and determine the selected matching block. If intra_tmp_filter_flag is true, it indicates that the single matching block is filtered, decode intra_tmp_idx, and determine the selected matching block. In some embodiments, if intra_tmp_filter_flag is true, it can also indicate that the IntraTMP multi-candidate prediction mode is used for prediction. That is, according to the value of intra_tmp_filter_flag, it is determined whether to decode intra_tmp_intra_flag.

[0200] In some embodiments, IntraTMP fusion intra prediction and IntraTMP filtering may not be used simultaneously. The method further includes: determining that the current block is predicted using IntraTMP multiple candidate prediction modes, and decoding a third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block.

[0201] Furthermore, the method further includes: decoding a fourth syntax element; wherein the fourth syntax element is used to indicate an index value of the first matching block in the candidate matching block list.

[0202] Exemplarily, a related syntax element includes:

[0203] Among them, based on the above embodiment, if it is determined that the current block allows prediction using the IntraTMP fusion intra prediction mode, intra_tmp_intra_flag (the second syntax element) is decoded. If intra_tmp_intra_flag is false, it indicates that the IntraTMP multiple candidate prediction mode is used for prediction. Intra_tmp_filter_flag (the third syntax element) is decoded to determine whether to filter the single matching block. Intra_tmp_idx (the fourth syntax element) is further decoded to determine the selected matching block. If intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra prediction mode is used for prediction. Intra_tmp_idx (the fourth syntax element) is further decoded to determine the selected matching block. In other words, whether to decode intra_tmp_filter_flag is determined based on the value of intra_tmp_intra_flag.

[0204] In some embodiments, multiple intra-frame prediction modes may be set, and a specific intra-frame prediction mode may be indicated by a transmission syntax element. The relevant syntax elements also include a seventh syntax element. The method further includes: determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode, and decoding the seventh syntax element; wherein the seventh syntax element is used to indicate the non-template matching intra-frame prediction mode used by the current block.

[0205] Exemplarily, a related syntax element includes:

[0206] or

[0207] In the IntraTMP fusion intra prediction mode, multiple intra prediction modes can be set, such as a predefined intra prediction mode, an intra prediction mode from a matching block, and an intra prediction mode derived based on methods such as TIMD or DIMD, and a certain intra prediction mode is selected by transmitting an index. Based on the above embodiment, if it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode, that is, intra_tmp_intra_flag is true, the seventh syntax element (intra_tmp_intra_mode_idx) is decoded, and an intra prediction mode is determined according to intra_tmp_intra_mode_idx for determining the second prediction block.

[0208] In some embodiments, the relevant syntax elements include a first syntax element (intra_tmp_fusion_flag), and the method further includes: when the value of the first syntax element is the first value, determining that the current block is allowed to use the IntraTMP fusion intra-frame prediction mode, using the IntraTMP fusion intra-frame prediction mode to predict in the template area of ​​the current block, and determining the first prediction template of the current block; determining a first template error value based on the first prediction template and the template of the current block; using the first IntraTMP prediction mode to predict in the template area of ​​the current block, and determining the second prediction template of the current block; determining a second template error value based on the second prediction template and the template of the current block; when the minimum template error value is the first template error value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; when the minimum template error value is the second template error value, determining that the current block is predicted using the first IntraTMP prediction mode; wherein, the first IntraTMP prediction mode includes the IntraTMP multi-matching block fusion prediction mode and / or the IntraTMP multi-candidate prediction mode.

[0209] That is, when intra_tmp_fusion_flag is true, decoding intra_tmp_intra_flag is not required. The prediction mode is selected based on at least one of the template error value of the multi-matching block fusion prediction in the template area and the template error value of the multi-candidate prediction in the template area, and the template error value of the fused intra-frame prediction in the template area.

[0210] In some embodiments, the method further includes: decoding an eighth syntax element; wherein the eighth syntax element is used to indicate whether to decode some or all of the relevant syntax elements of the current block. In some embodiments, the eighth syntax element includes at least one of the following: a sequence-level syntax element, a picture-level syntax element, a slice-level syntax element, a slice-level syntax element, or a block-level syntax element.

[0211] It should be noted that some or all of the relevant syntax elements can be controlled by one or more syntax elements at the block level, slice level, picture level, or sequence level. That is, a corresponding eighth syntax element can be set for each of the relevant syntax elements, or a corresponding eighth syntax element can be set for two or more of the relevant syntax elements, or a corresponding sixth syntax element can be set for all of the relevant syntax elements. For example, when the relevant syntax element is a block-level syntax element, the sixth syntax element can be a picture-level and / or sequence-level syntax element.

[0212] Step 1003: determining a matching block of the current block based on a prediction mode of template matching, and determining a first prediction block of the current block according to the matching block;

[0213] It should be noted that template matching is performed to construct a candidate matching block list. Possible matching blocks are searched for within a preset search range using a preset search method. Template error values ​​corresponding to the matching blocks are calculated based on the templates of the matching blocks and the template of the current block. A candidate matching block list is constructed based on each matching block and its corresponding template error value. The candidate matching block list can be sorted from smallest to largest based on the template error values.

[0214] Exemplarily, a template matching process for constructing a candidate block list is as follows:

[0215] The first step is to perform the first search with a certain step size, for example, both the horizontal step size and the vertical step size are 4. N optimal matching blocks with a certain spacing are obtained (the first N with the smallest template error value);

[0216] In the second step, a second search is performed in the adjacent areas of the N matching blocks obtained in the first step. These adjacent areas can be set to multiple non-overlapping regions based on the step size in the first step. From these regions, the M best matching blocks are obtained (which may include the matching blocks obtained in the first step). The same construction process is used on both the encoder and decoder to obtain a consistent list of candidate blocks.

[0217] In some embodiments, the prediction mode based on template matching determines the matching block of the current block, including: constructing a first candidate matching block list for the current block based on template matching; determining a first candidate matching block group from the first candidate matching block list; and determining at least one matching block to be fused from the first candidate matching block group. Correspondingly, obtaining the first prediction block of the current block based on the matching block includes: fusing at least one matching block in the first candidate matching block group to determine the first prediction block of the current block. That is, in the IntraTMP fusion intra-frame prediction method, the IntraTMP multi-matching block fusion prediction method is combined to determine at least one matching block of the current block, and matching blocks are fused to obtain the first prediction block of the current block. In some embodiments, the fused matching block can also be filtered to obtain the first prediction block.

[0218] In some embodiments, the template matching-based prediction mode determines a matching block for the current block, including: constructing a second candidate matching block list for the current block based on template matching; and determining a first matching block from the second candidate matching block list. In other words, the second candidate matching block list can be understood as a list constructed using the IntraTMP multi-candidate prediction method, used to determine a list of single matching blocks. In the IntraTMP fused intra-frame prediction method, the IntraTMP multi-candidate prediction method is combined to determine the first matching block for the current block, and the first predicted block for the current block is obtained based on the first matching block.

[0219] Accordingly, obtaining a first prediction block for the current block based on the matching block includes: using the first matching block as the first prediction block; or, when determining to filter the first matching block, filtering the first matching block to obtain the first prediction block. In the IntraTMP fusion intra-frame prediction method, the IntraTMP filtering method is combined to further improve prediction accuracy.

[0220] In some embodiments, determining the first matching block from the second candidate matching block list includes: determining the matching block with the smallest template error from the second candidate matching block list as the first matching block; or determining the index value of the first matching block; and determining the first matching block from the second candidate matching block list based on the index value of the first matching block. That is, by extending the IntraTMP fused intra-frame prediction mode through the IntraTMP multi-candidate prediction mode, using the selected matching block to obtain the first prediction block, which is then fused with the second prediction block obtained by the intra-frame prediction mode, the combination of the IntraTMP multi-candidate prediction mode and the IntraTMP fused intra-frame prediction mode can improve prediction accuracy.

[0221] It should be noted that the length of the second candidate matching block list is not equal to the length of the first candidate matching block list. In some embodiments, the length of the second candidate matching block list is equal to the length of the first candidate matching block list, which can also be understood as the first candidate matching block list and the second candidate matching block list being the same candidate matching block list.

[0222] In some embodiments, determining the first matching block from the second candidate matching block list further includes: reordering the first N matching blocks in the second candidate matching block list; and determining index values ​​of the first N matching blocks according to the reordered positions of the first N matching blocks;

[0223] Determining the first matching block from the second candidate matching block list based on the index value of the first matching block includes: determining the first matching block from the second candidate matching block list based on the index value of the first matching block and the index values ​​of the first N matching blocks, where N is less than or equal to the number of matching blocks in the second candidate matching block list.

[0224] FIG11 is a flow chart of a matching block reordering method according to an embodiment of the present application. As shown in FIG11 , reordering the first N matching blocks in the second candidate matching block list includes:

[0225] Step 1101: Determine a first prediction template for the current block based on the template of the i-th matching block;

[0226] In some embodiments, the template of the i-th matching block is used as the first prediction template of the current block, or the matching block template is filtered to obtain a filtered prediction template.

[0227] Step 1102: Determine a second prediction template for the current block according to the non-template matching intra prediction mode used by the current block;

[0228] Figure 12 is a schematic diagram of the template prediction method of the intra-frame prediction mode in an embodiment of the present application. As shown in Figure 12, based on the template type of the current block, the reference pixels of the adjacent area of ​​the current block template are determined, and then these reference pixels are used to implement intra-frame prediction other than IntraTMP in the template area. The intra-frame prediction method can be a preset intra-frame prediction mode, such as the Planar mode, or an intra-frame prediction mode derived using the template area according to methods such as TIMD.

[0229] Step 1103: Fusing the first prediction template and the second prediction template to determine a final prediction template for the current block;

[0230] Figure 13 is a schematic diagram of the weighted template fusion process in an embodiment of the present application. When the upper left reference pixel, upper reference pixel, and left reference pixel of the current block are all available, the shape of the current block template is shown in Figure 13. The first prediction template of the matching block and the second prediction template of the intra-frame prediction are fused to obtain the final prediction template of the current block. Furthermore, this prediction template is compared with the template of the current block to obtain the template error value of the specific prediction method.

[0231] The first prediction template is weighted and fused with the second prediction template. For example, the first prediction template is pred_tmp, the second prediction template is pred_intra, and the weight values ​​are wTmp and wIntra, then the final prediction template Pred is: Pred=(wTmp*pred_tmp+wIntra*pred_intra+offset)>>shift

[0232] Step 1104: Determine the template error value corresponding to the i-th matching block based on the final prediction template of the current block and the template of the current block;

[0233] Step 1105: reorder the first N matching blocks according to the template error values ​​corresponding to the first N matching blocks.

[0234] The template error values ​​SADi of the N matching blocks are reordered from small to large.

[0235] In some embodiments, when the non-template matching intra-frame prediction mode used by the current block is determined, the first N matching blocks are used in the template area for template prediction, so as to calculate the prediction templates corresponding to different matching blocks, and the template error value is calculated based on the prediction template and the template of the current block. The template error value is reordered and the best matching block is selected, or the index value of the smaller matching block is selected for encoding.

[0236] In some embodiments, when filtering the first matching block is determined based on intra_tmp_filter_flag, the method further includes: determining filter coefficients for the matching block based on a template of the first matching block and a template of the current block; and filtering the first matching block based on the filter coefficients of the matching block to obtain the first predicted block. If intra_tmp_filter_flag is true, filter coefficients are derived based on the selected matching block template and the current block template. The filtering form may be: predC = c0C + c1N + c2S + c3E + c4W + c5B

[0237] As shown in Figure 6A, predC represents the pixel value of the current block template, C represents the pixel value to be filtered in the matching block template, N represents the pixel above it, S represents the pixel below it, W represents the pixel to its left, and E represents the pixel to its right. B (Bias) is a fixed value, for example, B is the median of the pixel range. c0 to c5 represent the filter coefficients. Using the template-derived filter coefficients c0 to c5, the matching block is filtered to obtain the first prediction block. If intra_tmp_filter_flag is false, the selected matching block is directly used as the first prediction block.

[0238] Step 1004: Determine a second prediction block for the current block based on a non-template matching intra prediction mode;

[0239] In some embodiments, the non-template matching intra-frame prediction mode corresponding to the current block may be a specific intra-frame prediction mode pre-agreed by the codec. For example, the non-template matching intra-frame prediction mode includes one of the following: a predefined intra-frame prediction mode, an intra-frame prediction mode of a matching block, an intra-frame prediction mode derived based on TIMD, or an intra-frame prediction mode derived based on DIMD.

[0240] In some embodiments, the method further includes: determining that the current block is predicted using the IntraTMP fusion intra prediction mode, decoding the seventh syntax element, and determining a non-template matching intra prediction mode corresponding to the current block.

[0241] In some embodiments, the non-template matching intra-frame prediction mode includes at least two candidate intra-frame prediction modes; the method also includes: reordering the at least two candidate intra-frame prediction modes to obtain a candidate intra-frame prediction mode list and an index value of each candidate intra-frame prediction mode; determining the index value of the first intra-frame prediction mode used by the current frame; determining the first intra-frame prediction mode from the candidate intra-frame prediction mode list according to the index value of the first intra-frame prediction mode; and using the first intra-frame prediction mode as the non-template matching intra-frame prediction mode used by the current block.

[0242] In some embodiments, the best intra prediction mode with the smallest template error value is determined as the first intra prediction mode. In other embodiments, the seventh syntax element is decoded to determine the non-template matching intra prediction mode used by the current block.

[0243] FIG14 is a flow chart of a method for reordering intra-frame prediction modes according to an embodiment of the present application. As shown in FIG14 , reordering at least two candidate intra-frame prediction modes includes:

[0244] Step 1401: using the template of the matching block of the current block as the first prediction template of the current block;

[0245] Step 1402: Determine a second prediction template for the current block according to the i-th candidate intra prediction mode;

[0246] Step 1403: Fusing the first prediction template and the second prediction template to determine a final prediction template for the current block;

[0247] Step 1404: Determine a template error value corresponding to the i-th candidate intra prediction mode according to the final prediction template of the current block and the template of the current block;

[0248] Step 1405: Reorder at least two candidate intra prediction modes according to the template error values ​​corresponding to the at least two candidate intra prediction modes.

[0249] In some embodiments, when the matching block used by the current block is determined, multiple intra-frame prediction modes are used in the template area to perform template prediction, thereby calculating the prediction templates corresponding to different intra-frame prediction modes, and calculating the template error value based on the prediction template and the template of the current block. The template error value is reordered and the best matching block is selected, or a smaller intra-frame prediction mode index value is selected for encoding.

[0250] Step 1005: Fusing the first prediction block and the second prediction block to determine a final prediction block of the current block.

[0251] It should be noted that the fusion weight value of the first prediction block and the second prediction block can be a predefined fixed value, or can be flexibly selected according to the characteristics of the current block.

[0252] In some embodiments, the fusing the first prediction block and the second prediction block to determine the final prediction block of the current block includes: fusing the first prediction block and the second prediction block according to a preset first weight value and a second weight value to determine the final prediction block of the current block.

[0253] In some embodiments, the fusing of the first prediction block and the second prediction block to determine the final prediction block of the current block includes: dividing the current block into four sub-regions based on the intra-frame prediction mode derived from TIMD; respectively determining the first weight value and the second weight value of the four sub-regions of the current block; fusing the first prediction block and the second prediction block according to the first weight value and the second weight value of the four sub-regions of the current block to determine the final prediction block of the current block; or, determining the first weight value and the second weight value of the current block based on the intra-frame prediction mode derived from TIMD; fusing the first prediction block and the second prediction block according to the first weight value and the second weight value of the current block to determine the final prediction block of the current block.

[0254] Exemplarily, weight values ​​are determined for prediction block 1 and prediction block 2 according to the intra prediction mode derived from TIMD and the position of the pixel to be predicted. For example, the current coding block is divided according to the intra prediction mode intra_dir derived from TIMD, and different weight values ​​are set for prediction block 1 and prediction block 2 in different areas. For example, there are 65 intra-frame angle prediction modes in ECM (2≤intra_dir<=66). When 2≤intra_dir<34, the current coding block is divided into four equal parts vertically; when 34<=intra_dir<=66, the current coding block is divided into four equal parts horizontally. The indexes of each area under vertical or horizontal quartering are shown in Figure 7. The weight value wTMP of prediction block 1 and the weight value wIntra of prediction block 2 in each area are:

[0255] When intra_dir is equal to 0 or 1, no sub-region is divided, and (wIntra, wTMP) is equal to (1, 3). (wIntra, wTMP) can also be equal to (3, 1) or (2, 2).

[0256] Weighted fusion of prediction block 1 and prediction block 2. For example, if prediction block 1 is pred_tmp and prediction block 2 is pred_intra, and the weight values ​​are wTmp and wIntra, then the final prediction block Pred is: Pred=(wTmp*pred_tmp+wIntra*pred_intra+offset)>>shift

[0257] Wherein, offset=1<<(shift-1), shift=log2(wIntra+wTMP).

[0258] In some embodiments, when filtering the prediction block of the current block is determined based on intra_tmp_filter_flag, the method further includes: determining the filter coefficients of the prediction block based on the prediction template of the current block and the template of the current block; filtering the prediction block of the current block based on the filter coefficients of the prediction block to obtain the final prediction block of the current block. If intra_tmp_filter_flag is true, the filter coefficients are derived based on the selected prediction template and the current block template, and the filtering form can be: predC = c0C + c1N + c2S + c3E + c4W + c5B

[0259] As shown in Figure 6A, the filter shape is predC, which represents the pixel value of the current block template. C represents the pixel value to be filtered in the prediction template. N represents the pixel above it, S represents the pixel below it, W represents the pixel to its left, and E represents the pixel to its right. B (Bias) is a fixed value, for example, B is the median of the pixel range. c0 to c5 represent the filter coefficients. Using the template-derived filter coefficients c0 to c5, the fused prediction block is filtered to obtain the final prediction block for the current block. If intra_tmp_filter_flag is false, the fused prediction block is directly used as the final prediction block.

[0260] Furthermore, the process of using the IntraTMP multi-matching block fusion prediction mode for prediction is illustrated by way of example. In some embodiments, when determining, based on relevant syntax elements, that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode, the method further includes: constructing a first candidate matching block list for the current block based on template matching; determining a first candidate matching block group from the first candidate matching block list; and fusing at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

[0261] In some embodiments, determining the first candidate matching block group from the first candidate matching block list includes: forming the first N matching blocks in the first candidate matching block list into the first candidate matching block group, where N is an integer greater than 0, for example, N is 3.

[0262] FIG15 is a flow chart of a method for determining a first candidate matching block group in an embodiment of the present application. As shown in FIG15 , in other embodiments, determining the first candidate matching block group from the first candidate matching block list includes:

[0263] Step 1501: Grouping the first candidate matching block list to determine at least two candidate matching block groups, and determining an index value of each candidate matching block group;

[0264] Exemplarily, the first candidate matching block list is grouped according to at least one grouping rule. Each grouping rule specifies the number of groups, the number of matching blocks in each candidate matching block group, the distance between matching blocks in each candidate matching block group, and the like. In embodiments of the present application, the first candidate matching block list can be grouped according to one or more grouping rules to determine at least two candidate matching block groups, each candidate matching block group including at least one matching block.

[0265] In some embodiments, grouping the first candidate matching block list includes grouping the first candidate matching block list according to at least one grouping rule. Each grouping rule specifies the number of groups, the number of matching blocks in each candidate matching block group, the distance between matching blocks in each candidate matching block group, etc.

[0266] In some embodiments, the at least one grouping rule includes a first grouping rule; the first grouping rule includes: starting from the first matching block in the first candidate matching block list, each first preset number of matching blocks is set as a candidate matching block group; wherein the first preset number is an integer greater than 0. Here, the first preset number is the number of matching blocks in each candidate matching block group.

[0267] The maximum length of the candidate matching block list constructed through the template matching process is N, for example, N is equal to 45. Fusion prediction can use a maximum of M matching blocks for fusion, for example, M is equal to 3, and the first preset number is set to 3. According to the first grouping rule, every M matching blocks in the candidate matching block list can be set to 1 group, and a total of N / M=15 groups can be divided. If the total length N of the candidate matching block list cannot be divided by the maximum fusion number M, the number of matching blocks in the last group should be less than M, and the remaining matching blocks in the candidate matching block list can be added to the group. That is, the first grouping rule also includes: if the number of matching blocks in the last candidate matching block group is less than the first preset number, obtaining the preset matching blocks in the first candidate matching block list and adding them to the last candidate matching block group, so that the number of matching blocks in the last candidate matching block group is equal to the first preset number.

[0268] The at least one grouping rule includes a second grouping rule; the second grouping rule includes: starting from the first matching block in the first candidate matching block list, every second preset number of matching blocks is set as a candidate matching block group; wherein the second preset number is an integer greater than 0, and the first preset number and the second preset number are not equal.

[0269] The maximum length of the candidate matching block list constructed through the template matching process is N, for example, N is equal to 15. Fusion prediction can use a maximum of M matching blocks for fusion, for example, M is equal to 5. The second preset number is set to 5, and according to the first grouping rule, every M matching blocks in the candidate matching block list can be set as 1 group, for a total of N / M = 3 groups. Accordingly, the second grouping rule also includes: if the number of matching blocks in the last candidate matching block group is less than the second preset number, obtaining the preset matching blocks in the first candidate matching block list and adding them to the last candidate matching block group, so that the number of matching blocks in the last candidate matching block group equals the second preset number.

[0270] In some embodiments, the at least one grouping rule includes a first grouping rule and a second grouping rule. Exemplarily, the maximum length of the candidate matching block list constructed through the template matching process is N, for example, N equals 15. The first preset number is set to 3, and the second preset number is set to 5. Based on the first grouping rule, a maximum of N / M = 5 groups are obtained, and based on the second grouping rule, a maximum of N / M = 3 groups are obtained. Grouping the candidate matching block list according to the first grouping rule and the second grouping rule results in a total of 8 groups.

[0271] In some embodiments, each grouping rule further includes a corresponding number of groups. Exemplarily, the number of groups corresponding to the first grouping rule is 2, and the number of groups corresponding to the second grouping rule is 2. Then, according to the first grouping rule and the second grouping rule, the candidate matching block list is grouped into a total of 4 groups. Exemplarily, the candidate block in the candidate matching block list is BVn, where n is an integer from 1 to N, or n is an integer from 0 to N-1. In some embodiments, i can be the index value of the candidate matching block. According to the first grouping rule, two candidate matching blocks are grouped into {BV0, BV1, BV2}, {BV3, BV4, BV5}, and according to the second grouping rule, two candidate matching blocks are grouped into {BV0, BV1, BV3, BV2, BV4}, {BV5, BV6, BV7, BV8, BV9}.

[0272] In some embodiments, the at least one grouping rule includes a third grouping rule; the third grouping rule includes: forming a candidate matching block group with the first M1 matching blocks in the first candidate matching block list and every M2 matching blocks starting from the M1+1th matching block. In some embodiments, the third grouping rule also includes a corresponding number of groups.

[0273] In some embodiments, the third grouping rule further includes that the values ​​of M2 in different matching block groups are equal, or the third grouping rule further includes that the values ​​of M2 in different matching block groups are not completely equal.

[0274] Exemplarily, BVn (i>N) is combined with the first M1 in the candidate matching block list. For example, M1=2, M2=1, then the possible combinations are {BV0, BV1, BV2}, {BV0, BV1, BV3}, {BV0, BV1, BV4}, and so on. M1=2, then the possible combinations are {BV0, BV1, BV2, BV3}, {BV0, BV1, BV4}, {BV0, BV1, BV5}, and so on. BVn-BV(n+M2) (n>N) is combined with the first N in the candidate matching block list. For example, M1=1, M2=2, then the possible combinations are {BV0, BV1, BV2}, {BV0, BV3, BV4}, {BV0, BV5, BV6}, and so on.

[0275] In some embodiments, the at least one grouping rule includes a first matching rule and a third grouping rule. The at least one grouping rule includes a first matching rule, a second grouping rule, and a third grouping rule. Exemplarily, each grouping rule further includes a corresponding number of groups.

[0276] In some embodiments, the at least one grouping rule includes a fourth grouping rule; the fourth grouping rule includes: grouping the first i matching blocks in the first candidate matching block list into the i-th candidate matching block group; wherein i is an integer greater than 0. Exemplarily, the first matching block is grouped into the first candidate matching block group, the first two matching blocks are grouped into the second candidate matching block group, the first three matching blocks are grouped into the third candidate matching block group, the first four matching blocks are grouped into the fourth candidate matching block group, and so on. The maximum length of the candidate matching block list is N, and the maximum value of i is N. By limiting the maximum value of i, the number of groups can be limited.

[0277] In some embodiments, the fifth grouping rule includes: grouping the first two i matching blocks form the i-th candidate matching block group; the fifth grouping rule includes: forming the first (2i+a) matching blocks in the first candidate matching block list into the i-th candidate matching block group, where a is a positive integer.

[0278] In some embodiments, matching blocks can also be grouped based on the distance between them. Exemplarily, the grouping rules further include: the distance between any two matching blocks within the candidate matching block group is greater than a first distance threshold; or, the grouping rules further include: the distance between any two matching blocks within the candidate matching block group is less than a second distance threshold. By restricting the distance between matching blocks, the distribution of matching blocks within the candidate matching block group can be limited. It should be noted that when more than two grouping rules are set, each grouping rule has a restriction or partial restriction.

[0279] In some embodiments, grouping the first candidate matching block list includes: grouping the first candidate matching block list according to at least one grouping rule to obtain at least one candidate matching block group; setting a corresponding fusion mode of at least one IntraTMP fusion prediction mode for each candidate matching block group to obtain at least two candidate matching block groups.

[0280] It should be noted that, after grouping the first candidate matching block list according to any of the above grouping embodiments, one or more fusion modes may be set for the candidate matching block groups. It is understood that a candidate matching block group and a fusion mode are combined to form a new candidate matching block group, and two fusion modes are set for a candidate matching block group to form two new candidate matching block groups.

[0281] For example, according to the first and second grouping rules, two candidate matching block groups are obtained: {BV0, BV1, BV2, BV3, BV4} and {BV0, BV1}. Two fusion modes are set for each candidate group, resulting in four candidate matching block groups: {BV0, BV1, BV2, BV3, BV4, bFilter=1}, {BV0, BV1, BV2, BV3, BV4, bFilter=0}, {BV0, BV1, bFilter=1}, and {BV0, BV1, bFilter=0}. bFilter=1 indicates the first fusion mode, and bFilter=0 indicates the second fusion mode.

[0282] Exemplarily, the fusion mode includes a fusion mode of intra-frame template matching based on template derivation and a fusion mode of intra-frame template matching based on template error value.

[0283] The first fusion mode is a fusion mode of intra-frame template matching based on template derivation, and the second fusion mode is a fusion mode of intra-frame template matching based on template error value. Exemplarily, one grouping result includes: {BV0, BV1, BV2, BV3, BV4, bFilter=1}, {BV0, BV1, BV2, BV3, BV4, bFilter=0}, {BV0, BV1, bFilter=1}, {BV0, BV1, bFilter=0}. Exemplarily, another grouping result includes: {BV0, BV1, BV2, BV3, BV4, bFilter=1}, {BV0, BV1, BV2, BV3, BV4, bFilter=0}, {BV0, BV1, BV2, bFilter=1}, {BV0, BV1, bFilter=0}, and so on.

[0284] In some embodiments, the codec end pre-agreed on one or a combination of grouping rules.

[0285] In some embodiments, the method further comprises: decoding the code stream to determine the at least one grouping rule. Exemplarily, the decoding syntax element is used to indicate a grouping rule, or to indicate a grouping rule combination, wherein the grouping rule combination includes at least two preset grouping rules.

[0286] In some embodiments, when the codec pre-agreed on one or more grouping rules, the method includes: decoding the bitstream and determining variable parameters in the grouping rules. Exemplarily, when the codec pre-agreed on a first grouping rule, the method includes: decoding the bitstream and determining a first preset number. The method also includes: decoding the bitstream and determining the number of groups.

[0287] In other words, one or more grouping rules can be set. For example, one grouping rule is to use a maximum of M1 matching blocks for fusion, for example, M1 is equal to 3. Each M1 matching block in the candidate matching block list is grouped together. Another grouping rule is to use a maximum of M2 matching blocks for fusion, for example, M2 is equal to 2. Each M2 matching block in the candidate matching block list is grouped together. These two grouping rules can be used individually or in combination to obtain matching block groupings.

[0288] In some embodiments, determining the index value of each candidate matching block group includes: determining a first index value of each candidate matching block group according to the grouping position of each candidate matching block group; using the first index value of each candidate matching block group as the index value of each candidate matching block group; it can be understood that the method of selecting a matching block group is to indicate which group to use by the index value,

[0289] In some embodiments, determining the index value of each candidate matching block group includes: reordering the at least two candidate matching block groups based on the template error value corresponding to each candidate matching block group; determining a second index value for each candidate matching block group based on the reordered position of each candidate matching block group; and using the second index value of each candidate matching block group as the index value of each candidate matching block group. This can be understood as reordering the matching block groups and then determining a matching block group based on the index value.

[0290] In some embodiments, the reordering of the at least two candidate matching block groups includes: determining N fused matching blocks to be fused from each candidate matching block group; wherein N is an integer greater than 0; determining fusion weight values ​​of the N fused matching blocks; fusing the templates of the N fused matching blocks according to the fusion weight values ​​of the N fused matching blocks to determine a prediction template corresponding to each candidate matching block group; determining a template error value corresponding to each candidate matching block group based on the prediction template corresponding to each candidate matching block group and the template of the current block; and reordering according to the template error value corresponding to each candidate matching block group.

[0291] Step 1502: Determine the index value of the first candidate matching block group corresponding to the current block;

[0292] Exemplarily, the first candidate matching block group may be a specific candidate matching block group among the at least two candidate matching block groups, i.e., the index value of the first candidate matching block group may be a preset index value. Exemplarily, the index value of the first candidate matching block group is the minimum index value. The index values ​​of the candidate matching block groups are arranged from small to large, and the smaller the index value, the smaller the template error value of the matching block. After grouping, the candidate matching block group corresponding to the minimum index value is directly obtained as the first candidate matching block group.

[0293] Alternatively, the encoder uses at least two candidate matching block groups for fusion prediction, selects the best candidate matching block group through a coding decision process such as SATD and RDO, and encodes the index value of the best candidate matching block group, or the index value corresponding to the reference block. Based on the index value, the encoder determines the first candidate matching block group, uses the matching blocks in the first candidate matching block group to implement IntraTMP multi-matching block fusion prediction, and determines the final prediction block or the first prediction block for the current block.

[0294] In some embodiments, intra_tmp_intra_idx or intra_tmp_fusion_idx is decoded to determine the index value of the first candidate matching block group.

[0295] Step 1503: Determine the first candidate matching block grouping from the at least two candidate matching block groups according to the index value of the first candidate matching block grouping.

[0296] Furthermore, the IntraTMP multi-matching block fusion prediction is implemented using the matching blocks in the first candidate matching block group to determine the final prediction block or the first prediction block of the current block.

[0297] Furthermore, the matching block fusion method of the embodiment of the present application is further illustrated. The method of fusing at least one matching block from the first candidate matching block group to determine a prediction block for the current block includes: determining N fused matching blocks to be fused from the first candidate matching block group; where N is an integer greater than 0; determining fusion weights for the N fused matching blocks; and fusing the N fused matching blocks based on the fusion weights of the N fused matching blocks to determine a prediction block for the current block.

[0298] In some embodiments, determining the N fused matching blocks to be fused includes: determining the N fused matching blocks to be fused includes: using the first N matching blocks in the current candidate matching block group as the N fused matching blocks; wherein N is less than or equal to the number of matching blocks in the current candidate matching block group. That is, if the fused number N is less than the number of matching blocks M, only the N matching blocks may be used to derive the fusion weight value and perform the weighted calculation. If the fused number N is equal to the number of matching blocks M, all matching blocks may be used to derive the fusion weight value and perform the weighted calculation. For example, if the number of fused blocks N = 3, BV0, BV1, and BV2 are always fused.

[0299] In some embodiments, the method further comprises: encoding a value N of the number of fusion matching blocks. Exemplarily, the relevant syntax elements further comprise a syntax element intra_tmp_fusion_num, which is used to indicate the value N of the number of fusion matching blocks.

[0300] In some embodiments, determining the fusion weight values ​​of the N fusion matching blocks may include: determining the fusion weight values ​​of the N fusion matching blocks according to the fusion mode of the IntraTMP fusion prediction mode corresponding to the current candidate matching block group; wherein, the fusion mode is a fusion mode of intra-frame template matching based on template derivation or a fusion mode of intra-frame template matching based on template error value.

[0301] In some embodiments, the fusion mode is an intra-frame template matching fusion mode based on template derivation, and determining the fusion weight values ​​of the N fusion matching blocks includes: determining the fusion weight values ​​of the N fusion matching blocks and the fusion weight value of the bias parameter according to the templates of the N fusion matching blocks, the template of the current block, and the bias parameter;

[0302] The fusing the N fused matching blocks according to the fusion weight values ​​of the N fused matching blocks to determine the prediction block of the current block includes: fusing the N fused matching blocks and the bias parameters according to the fusion weight values ​​of the N fused matching blocks and the fusion weight value of the bias parameters to determine the prediction block of the current block.

[0303] For example, the template-derived IntraTMP fusion method uses a method similar to filter coefficient training to obtain weight values ​​for fusion prediction based on the training of each matching block template and the current block template. For example, a candidate matching block group or candidate matching block set includes 3 matching blocks, represented as {BV(3i), BV1(3i+1), BV2(3i+2)}, and the fusion form is as follows: pred=w0*BV 3*i +w1*BV 3*i +w2*BV 3*i+2 +w3*Bias

[0304] The templates of the matching blocks BV(3i), BV1(3i+1) and BV2(3i+2) are used as input, the current block template is used as output pred, and Bias is a fixed value, such as the median of the pixel range, to derive a set of weight values ​​w0 to w3. When fusing the matching blocks, the same fusion method is used, as well as the reconstructed values ​​and weight values ​​w0 to w3 of the matching blocks BV(3i), BV1(3i+1) and BV2(3i+2) to obtain the predicted block of the current block. Alternatively, when fusing the templates of the matching blocks, the same fusion method is used, as well as the reconstructed values ​​and weight values ​​w0 to w3 of the matching blocks BV(3i), BV1(3i+1) and BV2(3i+2) to obtain the predicted template.

[0305] In some embodiments, the fusion mode is an intra-frame template matching fusion mode based on template error value, and determining the fusion weight values ​​of the N fused matching blocks includes: determining the template error values ​​of the N fused matching blocks based on the templates of the N fused matching blocks and the template of the current block; determining the cumulative sum of the template error values ​​of the N fused matching blocks based on the template error values ​​of the N fused matching blocks; and determining the fusion weight values ​​of the N fused matching blocks based on the template error values ​​of the N fused matching blocks and the cumulative sum of the template error values.

[0306] For example, the template errors between the templates of N matching blocks and the template of the current block are absolute errors and SADs, which are SAD1 to SADn respectively. One way to calculate the weights is: SADi=(SADi==0)? 1:SADi Wi=(SUM-SADi) / ((n-1)*SUM)

[0307] Where n is the total number of matching blocks (i.e. N), and Wi is the weight value corresponding to the matching block with a template error value of SADi. The fusion form is as follows:

[0308] Where Pred is the prediction block or prediction template, and Predi is the matching block or matching block template. The fusion method described above is used to obtain the fused template error value corresponding to each matching block group. The matching blocks are reordered from small to large based on the template error value, i.e., the matching block groups with smaller template error values ​​should have smaller index values. Based on the determined index values, candidate matching block groups are selected. The weighted fusion prediction of the current block is performed using the selected candidate matching block groups and their corresponding weight values ​​to obtain the final predicted block.

[0309] In some embodiments, determining the N fused matching blocks to be fused includes: dividing the matching blocks in the current candidate matching block group into at least two candidate matching block sets; wherein each candidate matching block set includes N fused matching blocks to be fused, and the number of fused matching blocks and the number of fused matching blocks in different candidate matching block sets are not exactly the same; determining fusion weight values ​​of the N fused matching blocks in each candidate matching block set; fusing the templates of the N fused matching blocks in each candidate matching block set according to the fusion weight values ​​of the N fused matching blocks in each candidate matching block set to determine a prediction template corresponding to each candidate matching block set; determining a template error value corresponding to each candidate matching block set according to the prediction template corresponding to each candidate matching block set and the template of the current block; determining an optimal candidate matching block set with the smallest template error value according to the template error value corresponding to each candidate matching block set; and using the matching blocks in the optimal candidate matching block set as the N fused matching blocks.

[0310] It should be noted that when predicting a matching block for the current block, the current candidate matching block group is the first candidate matching block group. When reordering at least two candidate matching block groups and using the at least two candidate matching block groups for template prediction, the current candidate matching block group is the currently selected candidate matching block group.

[0311] For example, the current candidate matching block group includes three matching blocks {BV(3i), BV1(3i+1), BV2(3i+2)}. The candidate matching block sets that can be tried for template prediction are: {BV(3i)}, {BV(3i), BV1(3i+1)}, and {BV(3i), BV1(3i+1), BV2(3i+2)}. A weight value is derived for each set for a specific fusion mode. The best candidate matching block set is determined, and the matching blocks in the best candidate matching block set are used for fusion to determine the final prediction block or the first prediction block of the current block.

[0312] In some embodiments, fusing at least one matching block in the first candidate matching block group includes: determining a template error value for each matching block in the first candidate matching block group; determining a template error threshold based on the template error value and a threshold coefficient of the i-th matching block in the first candidate matching block group; wherein the i-th matching block is the matching block with the smallest template error value in the current candidate matching block group; when the template error value of the i+j-th matching block is greater than the number of matching blocks specified by the template error threshold, using the i-th matching block in the first candidate matching block group as the i+j-th fused matching block; and fusing using all matching blocks in the updated first candidate matching block group.

[0313] For example, based on the template error value of each matching block in the current candidate matching block group, some of them can be selected for fusion. For example, the candidate matching block group includes 3 matching blocks, {BV0, BV1, BV2}, and the threshold threshold is set according to the template error value SAD0 corresponding to BV0. When the following is satisfied: threshold = a*SAD0 SADi≤threshold, i>0

[0314] The corresponding BVi is used for fusion prediction to determine the number of fusions; among them, SAD0 corresponds to the minimum template error value of the matching block in the candidate matching block group, and a can be any preset value, such as 1.2, 1.5 or 2. If SADi are all less than or equal to the threshold, the fusion form is as follows: pred=w0*BV0+w1*BV1+w2*BV0+w3*Bias

[0315] If there is a matching block whose template error value is greater than the threshold, for example, SAD2>threshold, BV0 can be used instead of BV2 to derive the fusion coefficient and weighted calculation, that is, the templates of BV0, BV1, and BV0 are used as input, and the current block template is used as output to derive coefficients w0 to w3. The fusion form is as follows: Pred=w0*BV0+w1*BV1+w2*BV0+w3*Bias

[0316] If the fusion number N is less than the maximum fusion number M, only the N matching blocks can be used to derive coefficients and weighted calculations. For example, if N = 2, the fusion form is as follows: Pred = w0*BV0+w1*BV1+w2*Bias

[0317] Furthermore, the process of using the IntraTMP multi-candidate prediction mode for prediction is illustrated by way of example. When determining that the current block is predicted using the IntraTMP multi-candidate prediction mode, the method includes: constructing a second candidate matching block list for the current block based on template matching; determining a first matching block from the second candidate matching block list; and determining a prediction block for the current block based on the first matching block.

[0318] In some embodiments, determining the first matching block from the second candidate matching block list includes: determining an index value of the first matching block; and determining the first matching block from the second candidate matching block list according to the index value of the first matching block.

[0319] Correspondingly, determining the prediction block of the current block according to the first matching block includes: using the first matching block as the prediction block; or, when determining to filter the first matching block, filtering the matching block to obtain the prediction block.

[0320] In some embodiments, determining the first matching block from the second candidate matching block list includes: determining a matching block with the smallest template error from the second candidate matching block list as the first matching block; or determining an index value of the first matching block; and determining the first matching block from the second candidate matching block list based on the index value of the first matching block.

[0321] In some embodiments, determining the first matching block from the second candidate matching block list further includes: reordering the first N matching blocks in the second candidate matching block list; determining index values ​​of the first N matching blocks based on the reordered positions of the first N matching blocks; and determining the first matching block based on the index value of the first matching block. For the matching block reordering method, see FIG11 and its corresponding description.

[0322] Using the above technical solution, the decoding end decodes the relevant syntax elements to determine whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode, thereby improving prediction efficiency. At the same time, the IntraTMP fusion intra-frame prediction mode combines IntraTMP technologies such as IntraTMP multi-candidate, IntraTMP multi-matching block fusion and IntraTMP filtering to adapt to more encoding and decoding scenarios, ensuring prediction accuracy and encoding and decoding efficiency.

[0323] In another embodiment of the present application, an encoding method is also provided. See Figure 16, which shows a flow chart of an encoding method provided in an embodiment of the present application. As shown in Figure 16, the method further includes:

[0324] Step 1601: Determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block;

[0325] It should be noted that template matching is performed to construct a candidate matching block list. Possible matching blocks are searched for within a preset search range using a preset search method. Template error values ​​corresponding to the matching blocks are calculated based on the templates of the matching blocks and the template of the current block. A candidate matching block list is constructed based on each matching block and its corresponding template error value. The candidate matching block list can be sorted from smallest to largest based on the template error values.

[0326] In some embodiments, the template matching-based prediction mode determines the matching block of the current block, including: constructing a first candidate matching block list for the current block based on template matching; determining a first candidate matching block group from the first candidate matching block list; and determining at least one matching block to be fused from the first candidate matching block group. Accordingly, obtaining the first prediction block of the current block based on the matching blocks includes: fusing at least one matching block in the first candidate matching block group to determine the first prediction block of the current block. That is, in the IntraTMP fusion intra-frame prediction method, the IntraTMP multi-matching block fusion prediction method is combined to determine at least one matching block for the current block, and matching blocks are fused to obtain the first prediction block of the current block.

[0327] In some embodiments, determining the first candidate matching block group from the first candidate matching block list includes: grouping the first candidate matching block list to determine at least two candidate matching block groups, and determining an index value for each candidate matching block group; determining the index value of the first candidate matching block group corresponding to the current block; and determining the first candidate matching block group from the at least two candidate matching block groups based on the index value of the first candidate matching block group.

[0328] In some embodiments, determining the index value of each candidate matching block group includes: determining a first index value of each candidate matching block group according to a grouping position of each candidate matching block group; using the first index value of each candidate matching block group as the index value of each candidate matching block group;

[0329] Alternatively, the at least two candidate matching block groups are reordered according to the template error value corresponding to each candidate matching block group; the second index value of each candidate matching block group is determined according to the reordered position of each candidate matching block group; and the second index value of each candidate matching block group is used as the index value of each candidate matching block group.

[0330] In some embodiments, fusing at least one matching block in the first candidate matching block group includes: determining a template error value for each matching block in the first candidate matching block group; determining a template error threshold based on the template error value and a threshold coefficient of the i-th matching block in the first candidate matching block group; wherein the i-th matching block is the matching block with the smallest template error value in the current candidate matching block group; when the template error value of the i+j-th matching block is greater than the number of matching blocks specified by the template error threshold, using the i-th matching block in the first candidate matching block group as the i+j-th fused matching block; and fusing using all matching blocks in the updated first candidate matching block group.

[0331] In some embodiments, the template matching-based prediction mode determines a matching block for the current block, including: constructing a second candidate matching block list for the current block based on template matching; and determining a first matching block from the second candidate matching block list. That is, in the IntraTMP fusion intra-frame prediction method, the IntraTMP multi-candidate prediction method is combined to determine the first matching block for the current block, and a first prediction block for the current block is obtained based on the first matching block. In some embodiments, obtaining the first prediction block for the current block based on the first matching block includes: using the first matching block as the first prediction block; and filtering the first matching block to obtain the first prediction block.

[0332] In some embodiments, determining the first matching block from the second candidate matching block list includes: determining first N matching blocks from the second candidate matching block list; wherein N is an integer greater than 0.

[0333] In some embodiments, determining the first matching block from the second candidate matching block list further includes: reordering the first N matching blocks in the second candidate matching block list; determining index values ​​of the first N matching blocks based on the reordered positions of the first N matching blocks; and determining the first matching block based on the index values ​​of the first N matching blocks.

[0334] In some embodiments, the reordering of the first N matching blocks in the second candidate matching block list includes: determining a first prediction template of the current block based on the template of the i-th matching block; determining a second prediction template of the current block based on the non-template matching intra-frame prediction mode used by the current block; fusing the first prediction template and the second prediction template to determine a final prediction template of the current block; determining a template error value corresponding to the i-th matching block based on the final prediction template of the current block and the template of the current block; and reordering the first N matching blocks based on the template error values ​​corresponding to the first N matching blocks.

[0335] Step 1602: Determine a second prediction block for the current block based on a non-template matching intra prediction mode;

[0336] In some embodiments, the non-template matching intra-frame prediction mode includes at least two candidate intra-frame prediction modes; the method also includes: reordering the at least two candidate intra-frame prediction modes to obtain a candidate intra-frame prediction mode list and an index value of each candidate intra-frame prediction mode; determining the index value of the first intra-frame prediction mode used by the current frame; determining the first intra-frame prediction mode from the candidate intra-frame prediction mode list according to the index value of the first intra-frame prediction mode; and using the first intra-frame prediction mode as the non-template matching intra-frame prediction mode used by the current block.

[0337] In some embodiments, the reordering of at least two candidate intra-frame prediction modes includes: taking the template of the matching block of the current block as the first prediction template of the current block; determining the second prediction template of the current block based on the i-th candidate intra-frame prediction mode; fusing the first prediction template and the second prediction template to determine the final prediction template of the current block; determining the template error value corresponding to the i-th candidate intra-frame prediction mode based on the final prediction template of the current block and the template of the current block; and reordering the at least two candidate intra-frame prediction modes based on the template error values ​​corresponding to the at least two candidate intra-frame prediction modes.

[0338] In some embodiments, an optimal intra-frame prediction mode with a minimum template error value is determined as the first intra-frame prediction mode.

[0339] Step 1603: Fusing the first prediction block and the second prediction block to determine a final prediction block of the current block;

[0340] In some embodiments, the fusing the first prediction block and the second prediction block to determine the final prediction block of the current block includes: fusing the first prediction block and the second prediction block according to a preset first weight value and a second weight value to determine the final prediction block of the current block.

[0341] In some embodiments, the fusing of the first prediction block and the second prediction block to determine the final prediction block of the current block includes: dividing the current block into four sub-regions based on the intra-frame prediction mode derived from TIMD; respectively determining the first weight value and the second weight value of the four sub-regions of the current block; fusing the first prediction block and the second prediction block according to the first weight value and the second weight value of the four sub-regions of the current block to determine the final prediction block of the current block; or, determining the first weight value and the second weight value of the current block based on the intra-frame prediction mode derived from TIMD; fusing the first prediction block and the second prediction block according to the first weight value and the second weight value of the current block to determine the final prediction block of the current block.

[0342] In some embodiments, when determining that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode, it also includes: constructing a first candidate matching block list for the current block based on template matching; determining a first candidate matching block group from the first candidate matching block list; and fusing at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

[0343] In some embodiments, determining the first candidate matching block group from the first candidate matching block list includes: forming the first N matching blocks in the first candidate matching block list into the first candidate matching block group, where N is an integer greater than 0, for example, N is 3.

[0344] In some embodiments, when determining that the current block is predicted using the IntraTMP multi-candidate prediction mode, the method includes: constructing a second candidate matching block list for the current block based on template matching; determining a first matching block from the second candidate matching block list; and determining a prediction block for the current block based on the first matching block.

[0345] In some embodiments, determining the prediction block of the current block according to the first matching block includes: using the first matching block as the prediction block of the current block; and filtering the matching block to obtain the prediction block of the current block.

[0346] Step 1604: Make an encoding decision based on the final predicted block and the original block of the current block to determine whether the current block is predicted using the IntraTMP fusion intra prediction mode;

[0347] The encoding end and the decoding end use the same process to obtain the prediction blocks under each prediction mode. Exemplarily, a list of candidate matching blocks is constructed and sorted by template error value from small to large, and IntraTMP multi-matching block fusion prediction is performed to obtain the prediction block. An attempt is made to select a matching block in the candidate block list, and filter coefficients are derived based on the template of the matching block and the current block template to obtain a prediction block filtered or unfiltered based on a single matching block; the filtered or unfiltered prediction block is used to perform IntraTMP fusion intra-frame prediction to determine the final prediction block of the current block. In some embodiments, the encoding end selects the best prediction mode by comparing the distortion between the prediction blocks and the original blocks under multiple prediction modes, such as SAD or MSE or SATD or SSE, determines the values ​​of relevant syntax elements according to the best prediction mode, encodes the relevant syntax elements, writes the coded bits into the bitstream, and completes the encoding process of the current block.

[0348] Step 1605: Encode the relevant syntax elements of the current block and write the obtained coded bits into the bitstream;

[0349] The relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra-frame prediction mode.

[0350] It should be noted that the relevant syntax elements can be understood as being used to indicate the prediction mode of the current block, specifically, to indicate the IntraTMP prediction mode, and more specifically, to indicate whether the prediction mode of the current block is the IntraTMP fusion intra-frame prediction mode.

[0351] In some embodiments, the relevant syntax elements include: a first syntax element and / or a second syntax element; wherein the first syntax element is used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode; and the second syntax element is used to indicate whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode.

[0352] In some embodiments, the relevant syntax elements also include at least one of the following: a syntax element for indicating whether the current block is allowed to be predicted using the IntraTMP prediction mode; a syntax element for indicating whether the current block is predicted using an IntraTMP prediction mode other than the IntraTMP fusion prediction mode; a syntax element for indicating whether the current block is predicted using an IntraTMP fusion prediction mode other than the IntraTMP fusion intra-frame prediction mode. A syntax element for indicating whether the current block is predicted using the IntraTMP multi-match block fusion prediction mode; a syntax element for indicating whether the current block is predicted using the IntraTMP multi-candidate prediction mode. In actual applications, these syntax elements can be one or more of block-level syntax elements, slice-level syntax elements, slice-level syntax elements, image-level syntax elements, and sequence-level syntax elements.

[0353] It should be noted that the IntraTMP prediction mode refers to a prediction mode based on intra-frame template matching, and the IntraTMP fusion prediction mode can be understood as a fusion prediction mode based on intra-frame template matching. The IntraTMP fusion prediction mode includes the IntraTMP fusion intra-frame prediction mode and other IntraTMP fusion prediction modes other than the IntraTMP fusion intra-frame prediction mode. Exemplarily, the other IntraTMP fusion prediction modes include any prediction mode that uses matching blocks obtained based on template matching to participate in the fusion, such as the IntraTMP multi-matching block fusion prediction mode, the joint intra-frame and inter-frame prediction mode, and the template-derived IntraTMP fusion.

[0354] It should be noted that the value of the first syntax element can be a first numerical value or a second numerical value, and each value of the first syntax element is used to indicate a specific meaning. Exemplarily, when the value of the first syntax element is the first numerical value, it is a syntax element used to indicate that the current block allows prediction using the IntraTMP fusion intra-frame prediction mode; or, when the value of the first syntax element is the second numerical value, it is a syntax element used to indicate that the current block allows prediction using the IntraTMP fusion intra-frame prediction mode. Exemplarily, the first numerical value can be 1, and the second numerical value can be 0.

[0355] In some examples, the first syntax element comprises a block-level syntax element. In some embodiments, the first syntax element further comprises at least one of: a slice-level syntax element, a slice-level syntax element, a picture-level syntax element, and a sequence-level syntax element.

[0356] In some examples, the second syntax element comprises a block-level syntax element. In some embodiments, the second syntax element further comprises at least one of: a slice-level syntax element, a slice-level syntax element, a picture-level syntax element, and a sequence-level syntax element.

[0357] In some embodiments, the encoding of relevant syntax elements of the current block includes: encoding the first syntax element; when the value of the first syntax element is a first value, determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and encoding the second syntax element; the value of the second syntax element is a first numerical value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; the value of the second syntax element is a second numerical value, determining that the current block is predicted using the IntraTMP multi-match block fusion prediction mode.

[0358] It should be noted that determining whether the current block is allowed to use the IntraTMP fusion intra prediction mode for prediction further encodes a second syntax element, and determining whether the current block is predicted using the IntraTMP fusion intra prediction mode or the IntraTMP multi-match block fusion prediction mode based on the value of the second syntax element. IntraTMP multi-match block fusion prediction and IntraTMP fusion intra prediction are used as two fusion prediction modes, and the block-level flag indicates which fusion prediction mode to use.

[0359] Exemplarily, a related syntax element includes:

[0360] Among them, intra_tmp_fusion_flag has the function of the first syntax element, and intra_tmp_intra_flag has the function of the second syntax element. Intra_tmp_flag is used to indicate that the current block allows prediction using the IntraTMP prediction mode. Encode the IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the current block uses the IntraTMP prediction mode, and further encode intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it indicates that the current block allows prediction using the IntraTMP fusion intra-frame prediction mode. Further encode intra_tmp_intra_flag; if intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra-frame prediction mode is used. If intra_tmp_intra_flag is false, it indicates that the IntraTMP multi-match block fusion mode is used.

[0361] In some embodiments, the encoding of relevant syntax elements of the current block includes: encoding the first syntax element; when the value of the first syntax element is a first value, determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and encoding the second syntax element; the value of the second syntax element is a first numerical value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; the value of the second syntax element is a second numerical value, determining that the current block is predicted using the IntraTMP multi-candidate prediction mode.

[0362] It should be noted that it is determined whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and further, the second syntax element is encoded, and according to the value of the second syntax element, it is determined whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode or the IntraTMP multi-candidate prediction mode. The IntraTMP multi-candidate prediction mode can be understood as an IntraTMP prediction mode based on a single matching block. Taking the IntraTMP multi-matching block fusion prediction and the IntraTMP fusion intra-frame prediction as two fusion prediction modes, the IntraTMP multi-candidate prediction mode extends the IntraTMP fusion intra-frame prediction mode, and indicates through a block-level flag whether the selected matching block is fused with the second prediction block obtained by the intra-frame prediction mode. Furthermore, the selected first matching block can also be indicated by an index value.

[0363] In some embodiments, the encoding of relevant syntax elements of the current block includes: when the value of the first syntax element is a first value, determining that the current block is predicted using the IntraTMP multi-match block fusion prediction mode; when the value of the first syntax element is a second value, determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, encoding the second syntax element; the value of the second syntax element is a first numerical value used to indicate that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; the value of the second syntax element is a second numerical value used to indicate that the current block is predicted using the IntraTMP multi-candidate prediction mode.

[0364] It should be noted that when the value of the first syntax element is the first numerical value, it is determined that the current block is predicted using the IntraTMP multi-match block fusion prediction mode, that is, it is determined that the current block is not allowed to be predicted using the IntraTMP fusion intra-frame prediction mode. In addition to being used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, the first syntax element is also used to indicate whether the current block is predicted using the IntraTMP multi-match block fusion prediction mode. The IntraTMP multi-match block fusion prediction mode, the IntraTMP multi-candidate prediction mode, and the IntraTMP fusion intra-frame prediction mode are used as three prediction modes. The block-level flag indicates which prediction mode is selected and indicates whether the selected matching block is fused with the second prediction block obtained by the intra-frame prediction mode.

[0365] Exemplarily, a related syntax element includes:

[0366] Among them, if intra_tmp_flag is true, it means that the current block uses the IntraTMP prediction mode, and further encodes intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it means that the current block uses the IntraTMP multi-matching block fusion mode. If intra_tmp_fusion_flag is false, it means that the coding block uses the prediction mode of a single matching block, and it can also mean that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, and further encodes intra_tmp_intra_flag; if intra_tmp_intra_flag is true, it means that the IntraTMP fusion intra-frame prediction mode is used. If intra_tmp_intra_flag is false, it means that the prediction mode of a single matching block is used, that is, the IntraTMP multi-candidate prediction mode is used.

[0367] In some embodiments, the above prediction mode can also integrate IntraTMP filtering technology. Exemplarily, the relevant syntax element also includes a third syntax element; in some embodiments, it also includes: encoding the third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block or whether to filter the prediction block of the current block. Exemplarily, the value of the third syntax element is a first numerical value, which determines whether to filter the first matching block or the prediction block of the current block. The value of the third syntax element is a second numerical value, which determines not to filter the first matching block or the prediction block of the current block.

[0368] In some embodiments, the second syntax element and the third syntax element are encoded.

[0369] In some embodiments, it is determined that the current block allows prediction using the IntraTMP fusion intra prediction mode, and a third syntax element is encoded; in some embodiments, it is determined that the current block uses the IntraTMP multi-candidate prediction mode for prediction, and a third syntax element is encoded.

[0370] It should be noted that the first matching block is the first matching block determined by the prediction mode based on template matching. Whether to filter the first matching block or the prediction block of the current block can be pre-determined. Alternatively, two syntax elements can be used to indicate whether to filter the first matching block and whether to filter the prediction block of the current block, respectively. Alternatively, only one syntax element can be configured, with the other pre-determined.

[0371] Exemplarily, a related syntax element includes:

[0372] or

[0373] Among them, based on the above embodiment, if it is determined that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, intra_tmp_filter_flag is encoded. If intra_tmp_filter_flag is true, it indicates that the selected matching block is filtered. If intra_tmp_filter_flag is false, it indicates that the selected matching block is not filtered. It should be noted that if intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra-frame prediction mode is used, and the first selected matching block is used for fusion intra-frame prediction. If intra_tmp_intra_flag is false, it indicates that the selected matching block is not fused with the intra-frame prediction block, indicating that the prediction mode of a single matching block is used, that is, the IntraTMP multi-candidate prediction mode is used.

[0374] In some embodiments, index information may also be transmitted to indicate which matching block in the candidate matching block list is to be fused. The method further includes: determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and encoding a fourth syntax element; wherein the fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list; or, the fourth syntax element is used to indicate the index value of the first candidate matching block group in the candidate matching block list.

[0375] Exemplarily, a related syntax element includes:

[0376] If intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra prediction mode is used, and intra_tmp_intra_idx indicates which matching block is fused with the intra prediction block. If intra_tmp_intra_flag is false, it indicates that the IntraTMP multi-matching block fusion mode is used, and intra_tmp_intra_idx indicates which candidate matching block group in the candidate matching block list is grouped for multi-matching block fusion. intra_tmp_intra_idx can also be called intra_tmp_fusion_idx.

[0377] Exemplarily, a related syntax element includes:

[0378] Among them, if intra_tmp_intra_flag is true, it means using the IntraTMP fusion intra-frame prediction mode, and intra_tmp_intra_idx indicates which matching block is fused with the intra-frame prediction block; if intra_tmp_intra_flag is false, it means using the IntraTMP multi-candidate prediction mode, and intra_tmp_intra_idx indicates which matching block is predicted.

[0379] In some embodiments, the first syntax element and the fourth syntax element are encoded; wherein the fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list; or, the fourth syntax element is used to indicate the index value of the first candidate matching block group in the candidate matching block list.

[0380] In some embodiments, when the value of the first syntax element is the first value, it is determined that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode; the index value of the first candidate matching block group is determined according to the fourth syntax element; when the value of the first syntax element is the second value, it is determined that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and the second syntax element is encoded; the value of the second syntax element is the first numerical value, and it is determined that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; in some embodiments, the index value of the first matching block is determined according to the fourth syntax element; the value of the second syntax element is the second numerical value, and it is determined that the current block is predicted using the IntraTMP multi-candidate prediction mode; in some embodiments, the index value of the first matching block is determined according to the fourth syntax element;

[0381] Exemplarily, a related syntax element includes:

[0382] If intra_tmp_flag is true, it means that the current block uses the IntraTMP prediction mode, and intra_tmp_fusion_flag is further encoded; if intra_tmp_fusion_flag is true, it means that the current block uses the IntraTMP multi-matching block fusion mode, and intra_tmp_fusion_idx indicates which candidate matching block group in the candidate matching block list is used for multi-matching block fusion. If intra_tmp_fusion_flag is false, it indicates that the coding block uses the prediction mode of a single matching block, or it indicates that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, and further encodes intra_tmp_intra_flag; if intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra-frame prediction mode is used, and intra_tmp_fusion_idx indicates which matching block is fused with the intra-frame prediction block; if intra_tmp_intra_flag is false, it indicates that the prediction mode of a single matching block is used, that is, the IntraTMP multiple candidate prediction mode is used, and intra_tmp_intra_idx indicates which matching block is predicted. For example, if intra_tmp_idx is equal to i, the i+1th matching block in the candidate matching block list is the selected matching block, i starts at 0, and the index value starts at 1. Alternatively, if intra_tmp_idx is equal to i, the i-th matching block in the candidate matching block list is the selected matching block, and the value of i starts from 0, and the index value also starts from 0.

[0383] In some embodiments, the above prediction mode can also be integrated with the IntraTMP filtering technology. Exemplarily, a related syntax element includes:

[0384] Encode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the coding block is encoded using the IntraTMP mode, and further encode intra_tmp_fusion_flag. If intra_tmp_fusion_flag is true, it determines the use of the IntraTMP fusion intra prediction mode, and further encode intra_tmp_intra_flag, intra_tmp_filter_flag, and intra_tmp_idx (the order can be reversed). Among them, intra_tmp_idx represents the index of the selected matching block in the candidate matching block list. If intra_tmp_filter_flag is true, it indicates that the selected matching block is filtered. If intra_tmp_filter_flag is false, it indicates that the selected matching block is not filtered. If intra_tmp_intra_flag is true, it indicates that the selected matching block is fused with the intra prediction block. If intra_tmp_intra_flag is false, it indicates that the selected matching block is not fused with the intra prediction block.

[0385] Encode IntraTMP related syntax elements. If intra_tmp_flag is true, it means that the coding block is encoded using the IntraTMP mode, and further encode intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it means that the coding block is predicted using the multi-matching block fusion method; if intra_tmp_fusion_flag is false, it means that the coding block uses the prediction method of a single matching block, which can also be understood as determining that the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, and further encode intra_tmp_intra_flag, intra_tmp_filter_flag and intra_tmp_idx (the order can be reversed). Among them, intra_tmp_idx represents the index of the selected matching block in the candidate matching block list; intra_tmp_filter_flag is true, indicating that the selected matching block is filtered, and intra_tmp_filter_flag is false, indicating that the selected matching block is not filtered; intra_tmp_intra_flag is true, indicating that the selected matching block is used to merge with the intra-frame prediction block, and intra_tmp_intra_flag is false, indicating that the selected matching block is not merged with the intra-frame prediction block.

[0386] In some embodiments, intra_tmp_intra_idx and intra_tmp_fusion_idx may be encoded in different ways according to intra_tmp_intra_flag. Exemplarily, the method further includes: determining that the current block is predicted using the IntraTMP fusion intra prediction mode, encoding a fourth syntax element; determining the index value of the first matching block in the candidate matching block list based on the fourth syntax element; or determining that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode, encoding a fifth syntax element; determining the index value of the first candidate matching block group in the candidate matching block list based on the fifth syntax element.

[0387] Exemplarily, a related syntax element includes:

[0388] or

[0389] Based on the above embodiment, if the current block is determined to be predicted using the IntraTMP fusion intra prediction mode, intra_tmp_intra_idx (the fourth syntax element) is encoded to indicate the index value of the selected matching block in the candidate matching block list. If the IntraTMP multi-matching block fusion prediction mode is determined to be used, intra_tmp_fusion_idx (the fifth syntax element) is encoded to indicate the index value of the first selected candidate matching block group in the candidate matching block list. The value ranges of intra_tmp_intra_idx and intra_tmp_fusion_idx can be the same or different.

[0390] In some embodiments, intra_tmp_intra_idx and intra_tmp_idx may be encoded in different manners according to intra_tmp_intra_flag. The method further includes: determining that the current block is predicted using the IntraTMP fusion intra prediction mode, encoding a fourth syntax element; determining the index value of the first matching block in the candidate matching block list based on the fourth syntax element; or determining that the current block is predicted using the IntraTMP multi-candidate prediction mode, encoding a sixth syntax element; and determining the index value of the first matching block in the candidate matching block list based on the sixth syntax element.

[0391] Exemplarily, a related syntax element includes:

[0392] Among them, on the basis of the above embodiment, if it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode, intra_tmp_intra_idx (the fourth syntax element) is encoded to indicate the index value of the selected matching block in the candidate matching block list. If it is determined to use the IntraTMP multi-candidate prediction mode, intra_tmp_idx (the sixth syntax element) is encoded to indicate the index value of the selected matching block in the candidate matching block list. The value ranges of intra_tmp_intra_idx and intra_tmp_idx can be the same or different. Exemplarily, the maximum value of the value range of intra_tmp_intra_idx is less than the maximum value of the value range of intra_tmp_idx, the value range of intra_tmp_intra_idx is 0-3, and the value range of intra_tmp_idx is 0-15.

[0393] In some embodiments, IntraTMP fusion intra prediction and IntraTMP filtering may not be used simultaneously. Exemplarily, determining that the current block is predicted using the IntraTMP fusion intra prediction mode includes: determining not to filter the first matching block or not to filter the prediction block of the current block, and encoding the second syntax element; wherein the value of the second syntax element is a first value, which is used to indicate that the current block is predicted using the IntraTMP fusion intra prediction mode.

[0394] Furthermore, the method further includes: encoding a fourth syntax element; wherein the fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list.

[0395] Exemplarily, a related syntax element includes:

[0396] Among them, based on the above embodiment, if it is determined that the current block allows the use of the IntraTMP fusion intra-frame prediction mode for prediction, intra_tmp_filter_flag (the third syntax element) is encoded. If intra_tmp_filter_flag is false, it indicates that the single matching block is not filtered, and intra_tmp_intra_flag (the second syntax element) is encoded. Further, intra_tmp_idx (the fourth syntax element) is encoded to determine the selected matching block. If intra_tmp_filter_flag is true, it indicates that the single matching block is filtered, and intra_tmp_idx is encoded to determine the selected matching block. In some embodiments, if intra_tmp_filter_flag is true, it can also indicate that the IntraTMP multi-candidate prediction mode is used for prediction. That is, whether to encode intra_tmp_intra_flag is determined based on the value of intra_tmp_filter_flag.

[0397] In some embodiments, IntraTMP fusion intra prediction and IntraTMP filtering may not be used simultaneously. The method further includes: determining that the current block is predicted using IntraTMP multiple candidate prediction modes, encoding a third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block.

[0398] Furthermore, the method further includes: encoding a fourth syntax element; wherein the fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list.

[0399] Exemplarily, a related syntax element includes:

[0400] Among them, based on the above embodiment, if it is determined that the current block allows prediction using the IntraTMP fusion intra prediction mode, intra_tmp_intra_flag (the second syntax element) is encoded. If intra_tmp_intra_flag is false, it indicates that the IntraTMP multiple candidate prediction mode is used for prediction. Intra_tmp_filter_flag (the third syntax element) is encoded to determine whether to filter the single matching block. Intra_tmp_idx (the fourth syntax element) is further encoded to determine the selected matching block. If intra_tmp_intra_flag is true, it indicates that the IntraTMP fusion intra prediction mode is used for prediction. Intra_tmp_idx (the fourth syntax element) is further encoded to determine the selected matching block. In other words, whether to encode intra_tmp_filter_flag is determined based on the value of intra_tmp_intra_flag.

[0401] In some embodiments, multiple intra-frame prediction modes can be set, and a specific intra-frame prediction mode can be indicated by transmitting a syntax element. The method further includes: determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode, and encoding a seventh syntax element; wherein the seventh syntax element is used to indicate the non-template matching intra-frame prediction mode used by the current block.

[0402] Exemplarily, a related syntax element includes:

[0403] or

[0404] In the IntraTMP fusion intra prediction mode, multiple intra prediction modes can be set, such as a predefined intra prediction mode, an intra prediction mode from a matching block, and an intra prediction mode derived based on methods such as TIMD or DIMD, and a certain intra prediction mode is selected by transmitting an index. Based on the above embodiment, if it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode, that is, intra_tmp_intra_flag is true, the seventh syntax element (intra_tmp_intra_mode_idx) is encoded, and an intra prediction mode is determined according to intra_tmp_intra_mode_idx for determining the second prediction block.

[0405] In some embodiments, the relevant syntax elements include a first syntax element (intra_tmp_fusion_flag), and the method further includes: when the value of the first syntax element is the first value, determining that the current block is allowed to use the IntraTMP fusion intra-frame prediction mode, using the IntraTMP fusion intra-frame prediction mode to predict in the template area of ​​the current block, and determining the first prediction template of the current block; determining a first template error value based on the first prediction template and the template of the current block; using the first IntraTMP prediction mode to predict in the template area of ​​the current block, and determining the second prediction template of the current block; determining a second template error value based on the second prediction template and the template of the current block; when the minimum template error value is the first template error value, determining that the current block is predicted using the IntraTMP fusion intra-frame prediction mode; when the minimum template error value is the second template error value, determining that the current block is predicted using the first IntraTMP prediction mode; wherein, the first IntraTMP prediction mode includes the IntraTMP multi-matching block fusion prediction mode and / or the IntraTMP multi-candidate prediction mode.

[0406] That is, when intra_tmp_fusion_flag is true, intra_tmp_intra_flag does not need to be encoded. The prediction mode is selected based on at least one of the template error value of the multi-matching block fusion prediction in the template area and the template error value of the multi-candidate prediction in the template area, and the template error value of the fused intra-frame prediction in the template area.

[0407] In some embodiments, the method further comprises: encoding an eighth syntax element; wherein the eighth syntax element is used to indicate whether to encode some or all of the relevant syntax elements of the current block. In some embodiments, the eighth syntax element comprises at least one of the following: a sequence-level syntax element, a picture-level syntax element, a slice-level syntax element, a slice-level syntax element, or a block-level syntax element.

[0408] It should be noted that some or all of the relevant syntax elements can be controlled by one or more syntax elements at the block level, slice level, picture level, or sequence level. That is, a corresponding eighth syntax element can be set for each of the relevant syntax elements, or a corresponding eighth syntax element can be set for two or more of the relevant syntax elements, or a corresponding sixth syntax element can be set for all of the relevant syntax elements. For example, when the relevant syntax element is a block-level syntax element, the sixth syntax element can be a picture-level and / or sequence-level syntax element.

[0409] Using the above technical solution, the encoder determines whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode and encodes relevant syntax elements to improve the prediction efficiency of the decoder. At the same time, the IntraTMP fusion intra-frame prediction mode combines IntraTMP technologies such as IntraTMP multi-candidate, IntraTMP multi-matching block fusion and IntraTMP filtering to adapt to more encoding and decoding scenarios, ensuring prediction accuracy and encoding and decoding efficiency.

[0410] Furthermore, an embodiment of the present application also provides a code stream, which is generated by bit encoding based on information to be encoded; wherein the information to be encoded includes at least one of the following: a syntax element for indicating whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, a syntax element for indicating whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode, a syntax element for indicating whether to filter the first matching block, a syntax element for filtering the prediction block of the current block, a syntax element for indicating the index value of the first matching block in the candidate matching block list, a syntax element for indicating the index value of the first candidate matching block group in the candidate matching block list, a syntax element for indicating the intra-frame prediction mode of non-template matching, a syntax element for indicating whether to decode the relevant syntax elements of the current block, the number of matching blocks in the candidate matching block group, the value N of the number of matching blocks when multiple matching blocks are fused, the length of the first candidate matching block list, and the length of the second candidate matching block list.

[0411] In another embodiment of the present application, based on the same inventive concept as the above embodiment, see Figure 17, which shows a schematic diagram of the structure of an encoder provided by an embodiment of the present application. As shown in Figure 17, the encoder 170 may include: a first prediction unit 1701, a first determination unit 1702 and an encoding unit 1703; wherein,

[0412] The first prediction unit 1701 is configured to determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block;

[0413] The first prediction unit 1701 is configured to determine a second prediction block of the current block based on a non-template matching intra prediction mode;

[0414] The first prediction unit 1701 is configured to fuse the first prediction block and the second prediction block to determine a final prediction block of the current block;

[0415] The first determining unit 1702 is configured to make an encoding decision based on the final predicted block and the original block of the current block, and determine whether the current block is predicted using the IntraTMP fusion intra prediction mode;

[0416] The encoding unit 1703 is configured to encode relevant syntax elements of the current block and write the obtained coded bits into the bitstream;

[0417] The relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra-frame prediction mode.

[0418] It can be understood that each functional unit of the encoder also executes the encoding method described in any one of the aforementioned embodiments.

[0419] 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.

[0420] 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.

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

[0422] Based on the composition of the encoder 170 and the computer-readable storage medium, refer to Figure 18, which shows a specific hardware structure diagram of the encoder 170 provided in an embodiment of the present application. As shown in Figure 18, the encoder 170 may include: a first communication interface 1801, a first memory 1802 and a first processor 1803; each component is coupled together through a first bus system 1804. It can be understood that the first bus system 1804 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 1804 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 1804 in Figure 18. Among them,

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

[0424] The first memory 1802 is used to store computer programs that can be run on the first processor 1703;

[0425] The first processor 1803 is configured to, when running the computer program, execute:

[0426] Determining a matching block of the current block based on a prediction mode of template matching, and determining a first prediction block of the current block according to the matching block;

[0427] Determining a second prediction block for the current block based on a non-template matching intra prediction mode;

[0428] Fusing the first prediction block and the second prediction block to determine a final prediction block of the current block;

[0429] Make an encoding decision based on the final predicted block and the original block of the current block to determine whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode;

[0430] Encode the relevant syntax elements of the current block and write the obtained coded bits into the bitstream;

[0431] The relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra-frame prediction mode.

[0432] It is understood that the first memory 1802 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 1802 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0433] The first processor 1803 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 1803. The above-mentioned first processor 1803 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 1802 , and the first processor 1803 reads the information in the first memory 1802 and completes the steps of the above method in combination with its hardware.

[0434] 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.

[0435] Optionally, as another embodiment, the first processor 1803 is further configured to execute the encoding method described in any one of the aforementioned embodiments when running the computer program.

[0436] This embodiment provides an encoder that constructs and groups a candidate matching block list, transmits an index value indicating a first candidate matching block group, and uses the first candidate matching block group for fusion prediction. This improves prediction accuracy, saves bit rate, and improves encoding and decoding efficiency, thereby enhancing encoding and decoding performance. Furthermore, by limiting the index value range of the candidate matching block group, codewords for encoding the index value are saved, improving encoding efficiency. For example, by reordering the candidate matching block groups, the index values ​​are controlled within a smaller index range.

[0437] In yet another embodiment of the present application, based on the same inventive concept as the aforementioned embodiment, FIG19 is a schematic diagram showing the structure of a decoder 190 provided in an embodiment of the present application. As shown in FIG19 , the decoder 190 may include: a decoding unit 1901, a second determination unit 1902, and a second prediction unit 1903; wherein:

[0438] The decoding unit 1901 is configured to decode relevant syntax elements of the current block; wherein the relevant syntax elements are used to indicate whether the current block is predicted using the intra prediction mode based on intra template matching prediction IntraTMP;

[0439] The second determining unit 1902 is configured to determine, based on the relevant syntax elements, whether the current block is predicted using the IntraTMP fusion intra prediction mode;

[0440] The second prediction unit 1903 is configured to determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block;

[0441] The second prediction unit 1903 is further configured to determine a second prediction block for the current block based on a non-template matching intra prediction mode;

[0442] The second prediction unit 1903 is further configured to fuse the first prediction block and the second prediction block to determine a final prediction block of the current block.

[0443] It can be understood that each functional unit of the decoder also executes the decoding method described in any one of the aforementioned embodiments.

[0444] 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.

[0445] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this embodiment provides a computer-readable storage medium for use in decoder 190. The computer-readable storage medium stores a computer program that, when executed by a second processor, implements any of the decoding methods described in the aforementioned embodiments.

[0446] Based on the composition of the decoder 190 and the computer-readable storage medium, refer to Figure 20, which shows a specific hardware structure diagram of the decoder 190 provided in an embodiment of the present application. As shown in Figure 20, the decoder 190 may include: a second communication interface 2001, a second memory 2002 and a second processor 2003; each component is coupled together through a second bus system 2004. It can be understood that the second bus system 2004 is used to achieve connection and communication between these components. In addition to the data bus, the second bus system 2004 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 second bus system 2004 in Figure 20. Among them,

[0447] The second communication interface 2001 is used for sending and receiving signals during the process of sending and receiving information with other external network elements;

[0448] The second memory 2002 is used to store computer programs that can be run on the second processor 2003;

[0449] The second processor 2003 is configured to, when running the computer program, execute:

[0450] Based on template matching, a first candidate matching block list of the current block is constructed;

[0451] Grouping the first candidate matching block list to determine at least two candidate matching block groups, and determining an index value of each candidate matching block group;

[0452] Determine the index value of the first candidate matching block group corresponding to the current block;

[0453] determining the first candidate matching block group from the at least two candidate matching block groups according to the index value of the first candidate matching block group;

[0454] At least one matching block in the first candidate matching block group is merged to determine a prediction block for the current block.

[0455] Optionally, as another embodiment, the second processor 2003 is further configured to execute the decoding method described in any one of the aforementioned embodiments when running the computer program.

[0456] It can be understood that the hardware functions of the second memory 2002 are similar to those of the first memory 1802, and the hardware functions of the second processor 2003 are similar to those of the first processor 1803; they will not be described in detail here.

[0457] This embodiment provides a decoder that constructs and groups a candidate matching block list, transmits an index value indicating a first candidate matching block group, and uses the first candidate matching block group for fusion prediction. This improves prediction accuracy, saves bitrate, and increases encoding and decoding efficiency, thereby enhancing encoding and decoding performance. Furthermore, by limiting the index value range of the candidate matching block group, codewords for encoding the index value are conserved, improving encoding efficiency. For example, by reordering the candidate matching block groups, the index values ​​are controlled within a smaller index range.

[0458] In yet another embodiment of the present application, referring to FIG21 , 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 FIG21 , the coding and decoding system 210 may include an encoder 2101 and a decoder 2102 .

[0459] In the embodiment of the present application, the encoder 2101 may be the encoder described in any one of the aforementioned embodiments, and the decoder 2102 may be the decoder described in any one of the aforementioned embodiments.

[0460] 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.

[0461] 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.

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

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

[0464] 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.

[0465] 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

[0466] The embodiments of the present application provide a coding and decoding method, code stream, encoder, decoder, and storage medium. Based on relevant syntax elements, it is determined whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode; based on the prediction mode of template matching, the matching block of the current block is determined, and the first prediction block of the current block is determined based on the matching block; based on the intra-frame prediction mode of non-template matching, the second prediction block of the current block is determined; the first prediction block and the second prediction block are fused to determine the final prediction block of the current block. In this way, by encoding and decoding relevant syntax elements, it is indicated whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode, thereby improving prediction efficiency. At the same time, the IntraTMP fusion intra-frame prediction mode combines IntraTMP technologies such as IntraTMP multiple candidates, IntraTMP multi-matching block fusion, and IntraTMP filtering to adapt to more coding and decoding scenarios, ensuring prediction accuracy and coding and decoding efficiency.

Claims

1. A decoding method, applied to a decoder, the method comprising: Decoding relevant syntax elements of the current block; wherein the relevant syntax elements are used to indicate whether the current block is predicted using the intra-frame template matching prediction IntraTMP fusion intra-frame prediction mode; Determine, according to the relevant syntax elements, that the current block is predicted using the IntraTMP fusion intra prediction mode; Determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block; Determine a second prediction block of the current block based on the intra prediction mode without template matching; The first prediction block and the second prediction block are merged to determine a final prediction block of the current block.

2. The method according to claim 1, wherein: The relevant syntax elements include: a first syntax element and / or a second syntax element; The first syntax element is used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra prediction mode; The second syntax element is used to indicate whether the current block is predicted using the IntraTMP fusion intra prediction mode.

3. The method according to claim 2, wherein: The decoding of the relevant syntax elements of the current block includes: decoding the first syntax element; When the value of the first syntax element is the first value, determining that the current block is allowed to use the IntraTMP fusion intra prediction mode for prediction, and decoding the second syntax element; The value of the second syntax element is a first value, and it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode; The value of the second syntax element is a second numerical value, which determines that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode.

4. The method according to claim 2, wherein: The decoding of the relevant syntax elements of the current block includes: When the value of the first syntax element is the first value, it is determined that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode; When the value of the first syntax element is the second value, determining that the current block is allowed to use the IntraTMP fusion intra prediction mode for prediction, and decoding the second syntax element; The value of the second syntax element is a first value, and it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode; The value of the second syntax element is a second numerical value, which determines that the current block is predicted using the IntraTMP multi-candidate prediction mode.

5. The method according to claim 3 or 4, wherein: The related syntax elements further include a third syntax element; and the method further includes: Decode a third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block or whether to filter the prediction block of the current block.

6. The method according to claim 5, wherein: The determining that the current block uses the IntraTMP fusion intra prediction mode for prediction includes: According to the value of the third syntax element, determine not to filter the first matching block or not to filter the prediction block of the current block, and decode the second syntax element; When the value of the second syntax element is the first value, it is determined that the current block is predicted using the IntraTMP fusion intra-frame prediction mode.

7. The method according to claim 4, wherein: The method further comprises: Determine that the current block is predicted using the IntraTMP multi-candidate prediction mode, and decode a third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block.

8. The method according to any one of claims 5 to 7, wherein: When determining to filter the first matching block, the method further includes: Determining a filter coefficient of a matching block according to the template of the first matching block and the template of the current block; Filtering the first matching block according to the filter coefficient of the matching block to obtain the first prediction block; or, When determining to filter the prediction block of the current block, the method further includes: Determining a filter coefficient of a prediction block according to a prediction template of the current block and a template of the current block; The prediction block of the current block is filtered according to the filter coefficient of the prediction block to obtain a final prediction block of the current block.

9. The method according to any one of claims 2 to 8, wherein: The related grammatical elements further include a fourth grammatical element; and the method further includes: decoding a fourth syntax element; The fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list; or the fourth syntax element is used to indicate the index value of the first candidate matching block group in the candidate matching block list.

10. The method according to any one of claims 2 to 8, wherein: The method further comprises: Determine that the current block uses the IntraTMP fusion intra prediction mode for prediction, and decode the fourth syntax element; Determine, according to the fourth syntax element, an index value of a first matching block in the candidate matching block list; or, Determine that the current block uses the IntraTMP multi-matching block fusion prediction mode for prediction, and decode the fifth syntax element; According to the fifth syntax element, an index value of the first candidate matching block group in the candidate matching block list is determined.

11. The method according to any one of claims 2 to 8, wherein: The method further comprises: Determine that the current block uses the IntraTMP fusion intra prediction mode for prediction, and decode the fourth syntax element; Determine, according to the fourth syntax element, an index value of a first matching block in the candidate matching block list; or, Determine that the current block uses the IntraTMP multi-candidate prediction mode for prediction, and decode the sixth syntax element; An index value of a first matching block in the candidate matching block list is determined according to the sixth syntax element.

12. The method according to any one of claims 2 to 11, wherein: The method further comprises: Determine that the current block uses the IntraTMP fusion intra prediction mode for prediction, and decode the seventh syntax element; The seventh syntax element is used to indicate the non-template matching intra prediction mode used by the current block.

13. The method according to claim 12, wherein: The non-template matching intra prediction mode includes one of the following: a predefined intra prediction mode, an intra prediction mode of a matching block, an intra prediction mode derived based on TIMD, an intra prediction mode derived based on DIMD, and a Planar mode.

14. The method according to claim 2, wherein: The relevant syntax element includes a first syntax element; when the value of the first syntax element is a first value, it is determined that the current block is allowed to use the IntraTMP fusion intra prediction mode, and the method further includes: Using the IntraTMP fusion intra-frame prediction mode to perform prediction in the template area of ​​the current block, and determine a first prediction template of the current block; Determine a first template error value according to the first prediction template and a template of the current block; Using the first IntraTMP prediction mode to perform prediction in the template area of ​​the current block to determine a second prediction template of the current block; Determine a second template error value according to the second prediction template and the template of the current block; When the minimum template error value is the first template error value, determining that the current block is predicted using the IntraTMP fusion intra prediction mode; When the minimum template error value is the second template error value, determining that the current block is predicted using the first IntraTMP prediction mode; The first IntraTMP prediction mode includes the IntraTMP multi-matching block fusion prediction mode and / or the IntraTMP multi-candidate prediction mode.

15. The method according to any one of claims 2 to 14, wherein: The method further comprises: Decode an eighth syntax element; wherein the eighth syntax element is used to indicate whether to decode some or all of the related syntax elements of the current block.

16. The method according to claim 15, wherein: The eighth syntax element includes at least one of the following: a sequence-level syntax element, a picture-level syntax element, a slice-level syntax element, a slice-level syntax element, and a block-level syntax element.

17. The method according to any one of claims 2 to 16, wherein: When determining that the current block uses the IntraTMP multi-matching block fusion prediction mode for prediction, the method includes: Based on template matching, construct a first candidate matching block list for the current block; Determine a first candidate matching block group from the first candidate matching block list; At least one matching block in the first candidate matching block group is merged to determine a prediction block of the current block.

18. The method according to claim 1, wherein: The prediction mode based on template matching determines the matching block of the current block, including: Based on template matching, construct a first candidate matching block list for the current block; Determine a first candidate matching block group from the first candidate matching block list; Determine at least one matching block to be merged from the first candidate matching block group; The step of obtaining a first prediction block of the current block according to the matching block comprises: At least one matching block in the first candidate matching block group is merged to determine the first prediction block.

19. The method according to claim 17 or 18, wherein: The determining a first candidate matching block group from the first candidate matching block list comprises: Grouping the first candidate matching block list to determine at least two candidate matching block groups, and determining an index value of each candidate matching block group; Determine the index value of the first candidate matching block group corresponding to the current block; The first candidate matching block grouping is determined from the at least two candidate matching block groupings according to the index value of the first candidate matching block grouping.

20. The method according to claim 19, wherein: The step of determining the index value of each candidate matching block group includes: Determine a first index value of each candidate matching block group according to the grouping position of each candidate matching block group; Using the first index value of each candidate matching block group as the index value of each candidate matching block group; or, reordering the at least two candidate matching block groups according to a template error value corresponding to each candidate matching block group; Determine a second index value of each candidate matching block group according to the reordered position of each candidate matching block group; The second index value of each candidate matching block group is used as the index value of each candidate matching block group.

21. The method according to claim 17 or 18, wherein: The fusing at least one matching block in the first candidate matching block group includes: Determine a template error value of each matching block in the first candidate matching block group; Determining a template error threshold according to the template error value and the threshold coefficient of the i-th matching block in the first candidate matching block group; wherein the i-th matching block is a matching block with the smallest template error value in the current candidate matching block group; When the template error value of the i+jth matching block is greater than the number of matching blocks of the template error threshold, the i-th matching block in the first candidate matching block group is used as the i+jth fused matching block; All the matching blocks in the updated first candidate matching block group are used for fusion.

22. The method according to claim 4, wherein: When determining that the current block is predicted using the IntraTMP multi-candidate prediction mode, the method includes: Based on template matching, construct a second candidate matching block list for the current block; Determine a first matching block from the second candidate matching block list; A prediction block of the current block is determined according to the first matching block.

23. The method according to claim 1, wherein: The prediction mode based on template matching determines the matching block of the current block, including: Based on template matching, construct a second candidate matching block list for the current block; A first matching block is determined from the second candidate matching block list.

24. The method according to claim 22 or 23, wherein: The determining the first matching block from the second candidate matching block list comprises: Determining an index value of the first matching block; Determine a first matching block from the second candidate matching block list according to the index value of the first matching block.

25. The method according to claim 24, wherein: The determining of the first matching block from the second candidate matching block list further includes: Reorder the first N matching blocks in the second candidate matching block list; Determine the index values ​​of the first N matching blocks according to the reordered positions of the first N matching blocks; The determining the first matching block from the second candidate matching block list according to the index value of the first matching block includes: A first matching block is determined from the second candidate matching block list according to the index value of the first matching block and the index values ​​of the first N matching blocks.

26. The method according to claim 25, wherein: The reordering of the first N matching blocks in the second candidate matching block list includes: Determine a first prediction template of the current block according to the template of the i-th matching block; Determine a second prediction template for the current block according to a non-template matching intra prediction mode used by the current block; fusing the first prediction template and the second prediction template to determine a final prediction template for the current block; Determine the template error value corresponding to the i-th matching block according to the final prediction template of the current block and the template of the current block; The first N matching blocks are reordered according to the template error values ​​corresponding to the first N matching blocks.

27. The method of claim 1, wherein: The non-template matching intra-frame prediction mode includes at least two candidate intra-frame prediction modes; the method further includes: Reorder at least two candidate intra prediction modes to obtain a candidate intra prediction mode list and an index value of each candidate intra prediction mode; Determine an index value of a first intra-frame prediction mode used by a current frame; Determining the first intra prediction mode from a candidate intra prediction mode list according to an index value of the first intra prediction mode; The first intra-frame prediction mode is used as the non-template matching intra-frame prediction mode used by the current block.

28. The method according to claim 27, wherein: The reordering of at least two candidate intra prediction modes comprises: Using the template of the matching block of the current block as the first prediction template of the current block; Determine a second prediction template for the current block according to the i-th candidate intra prediction mode; fusing the first prediction template and the second prediction template to determine a final prediction template for the current block; Determining a template error value corresponding to the i-th candidate intra prediction mode according to a final prediction template of the current block and a template of the current block; At least two candidate intra-frame prediction modes are reordered according to template error values ​​corresponding to the at least two candidate intra-frame prediction modes.

29. The method according to claim 28, wherein: An optimal intra-frame prediction mode with a minimum template error value is determined as the first intra-frame prediction mode.

30. The method of claim 1, wherein: The fusing the first prediction block and the second prediction block to determine a final prediction block of the current block includes: The first prediction block and the second prediction block are merged according to a preset first weight value and a second weight value to determine a final prediction block of the current block.

31. The method of claim 1, wherein: The fusing the first prediction block and the second prediction block to determine a final prediction block of the current block includes: Based on the intra prediction mode derived from TIMD, the current block is divided into four sub-regions; Determine first weight values ​​and second weight values ​​of four sub-regions of the current block respectively; According to the first weight values ​​and the second weight values ​​of the four sub-regions of the current block, the first prediction block and the second prediction block are merged to determine a final prediction block of the current block; Alternatively, determining a first weight value and a second weight value of the current block based on the intra prediction mode derived from the TIMD; The first prediction block and the second prediction block are merged according to the first weight value and the second weight value of the current block to determine a final prediction block of the current block.

32. A coding method, applied to an encoder, the method comprising: Determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block; Determine a second prediction block of the current block based on the intra prediction mode without template matching; Merging the first prediction block and the second prediction block to determine a final prediction block of the current block; Make a coding decision based on the final predicted block and the original block of the current block to determine whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode; Encode the relevant syntax elements of the current block and write the obtained coded bits into the bitstream; The relevant syntax elements are used to indicate whether the current block is predicted using the IntraTMP fusion intra prediction mode based on intra-frame template matching prediction.

33. The method according to claim 32, wherein: The relevant syntax elements include: a first syntax element and / or a second syntax element; The first syntax element is used to indicate whether the current block is allowed to be predicted using the IntraTMP fusion intra prediction mode; The second syntax element is used to indicate whether the current block is predicted using the IntraTMP fusion intra prediction mode.

34. The method of claim 33, wherein: The coding of the relevant syntax elements of the current block includes: encoding the first syntax element; When the value of the first syntax element is the first value, determining that the current block is allowed to use the IntraTMP fusion intra prediction mode for prediction, and encoding the second syntax element; The value of the second syntax element is a first value, and it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode; The value of the second syntax element is a second numerical value, which determines that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode.

35. The method of claim 33, wherein: The coding related syntax elements of the current block include: When the value of the first syntax element is the first value, it is determined that the current block is predicted using the IntraTMP multi-matching block fusion prediction mode; When the value of the first syntax element is the second value, determining that the current block is allowed to use the IntraTMP fusion intra prediction mode for prediction, and encoding the second syntax element; The value of the second syntax element is a first value, and it is determined that the current block is predicted using the IntraTMP fusion intra prediction mode; The value of the second syntax element is a second numerical value, which determines that the current block is predicted using the IntraTMP multi-candidate prediction mode.

36. The method according to claim 34 or 35, wherein: The related syntax elements further include a third syntax element; and the method further includes: encoding a third syntax element; The third syntax element is used to indicate whether to filter the first matching block or whether to filter the prediction block of the current block. Wave.

37. The method of claim 36, wherein: The determining that the current block uses the IntraTMP fusion intra prediction mode for prediction includes: According to the value of the third syntax element, determine not to filter the first matching block or not to filter the prediction block of the current block, and encode the second syntax element; When the value of the second syntax element is the first value, it is determined that the current block is predicted using the IntraTMP fusion intra-frame prediction mode.

38. The method of claim 35, wherein: The method further comprises: Determine that the current block uses the IntraTMP multi-candidate prediction mode for prediction, and encode a third syntax element; wherein the third syntax element is used to indicate whether to filter the first matching block.

39. The method according to any one of claims 36 to 38, wherein: When determining to filter the first matching block, the method further includes: Determining a filter coefficient of a matching block according to the template of the first matching block and the template of the current block; Filtering the first matching block according to the filter coefficient of the matching block to obtain the first prediction block; or, When determining to filter the prediction block of the current block, the method further includes: Determining a filter coefficient of a prediction block according to a prediction template of the current block and a template of the current block; The prediction block of the current block is filtered according to the filter coefficient of the prediction block to obtain a final prediction block of the current block.

40. The method according to any one of claims 33 to 39, wherein: The related grammatical elements further include a fourth grammatical element; and the method further includes: encoding a fourth syntax element; The fourth syntax element is used to indicate the index value of the first matching block in the candidate matching block list; or the fourth syntax element is used to indicate the index value of the first candidate matching block group in the candidate matching block list.

41. The method according to any one of claims 33 to 39, wherein: The method further comprises: Determine that the current block uses the IntraTMP fusion intra prediction mode for prediction, and encode a fourth syntax element; Determine, according to the fourth syntax element, an index value of a first matching block in the candidate matching block list; or, Determine that the current block uses the IntraTMP multi-matching block fusion prediction mode for prediction, and encode the fifth syntax element; According to the fifth syntax element, an index value of the first candidate matching block group in the candidate matching block list is determined.

42. The method according to any one of claims 33 to 39, wherein: The method further comprises: Determine that the current block uses the IntraTMP fusion intra prediction mode for prediction, and encode a fourth syntax element; Determine, according to the fourth syntax element, an index value of a first matching block in the candidate matching block list; or, Determine that the current block uses the IntraTMP multi-candidate prediction mode for prediction, and encode the sixth syntax element; An index value of a first matching block in the candidate matching block list is determined according to the sixth syntax element.

43. The method according to any one of claims 33 to 42, wherein: The method further comprises: Determine that the current block uses the IntraTMP fusion intra prediction mode for prediction, and encode the seventh syntax element; The seventh syntax element is used to indicate a non-template matching intra prediction mode.

44. The method of claim 43, wherein: The intra prediction mode includes one of the following: a predefined intra prediction mode, an intra prediction mode of a matching block, an intra prediction mode derived based on TIMD, and an intra prediction mode derived based on DIMD.

45. The method of claim 33, wherein: The relevant syntax element includes a first syntax element; when the value of the first syntax element is a first value, it is determined that the current block is allowed to use the IntraTMP fusion intra prediction mode, and the method further includes: Using the IntraTMP fusion intra-frame prediction mode to perform prediction in the template area of ​​the current block, and determine a first prediction template of the current block; Determine a first template error value according to the first prediction template and a template of the current block; Using the first IntraTMP prediction mode to perform prediction in the template area of ​​the current block to determine a second prediction template of the current block; Determine a second template error value according to the second prediction template and the template of the current block; When the minimum template error value is the first template error value, determining that the current block is predicted using the IntraTMP fusion intra prediction mode; When the minimum template error value is the second template error value, determining that the current block is predicted using the first IntraTMP prediction mode; The first IntraTMP prediction mode includes the IntraTMP multi-matching block fusion prediction mode and / or the IntraTMP multi-candidate prediction mode.

46. ​​The method according to any one of claims 33 to 45, wherein: The method further comprises: Encode an eighth syntax element; wherein the eighth syntax element is used to indicate whether to encode some or all of the related syntax elements of the current block.

47. The method of claim 46, wherein: The eighth syntax element includes at least one of the following: a sequence-level syntax element, a picture-level syntax element, a slice-level syntax element, a slice-level syntax element, and a block-level syntax element.

48. The method according to any one of claims 33 to 47, wherein: When determining that the current block uses the IntraTMP multi-matching block fusion prediction mode for prediction, the method includes: Based on template matching, construct a first candidate matching block list for the current block; Determine a first candidate matching block group from the first candidate matching block list; At least one matching block in the first candidate matching block group is merged to determine a prediction block of the current block.

49. The method of claim 32, wherein: The prediction mode based on template matching determines the matching block of the current block, including: Based on template matching, construct a first candidate matching block list for the current block; Determine a first candidate matching block group from the first candidate matching block list; Determine at least one matching block to be merged from the first candidate matching block group; The step of obtaining a first prediction block of the current block according to the matching block comprises: At least one matching block in the first candidate matching block group is merged to determine the first prediction block.

50. The method of claim 48 or 49, wherein: The determining a first candidate matching block group from the first candidate matching block list comprises: Grouping the first candidate matching block list to determine at least two candidate matching block groups, and determining an index value of each candidate matching block group; Determine the index value of the first candidate matching block group corresponding to the current block; The first candidate matching block grouping is determined from the at least two candidate matching block groupings according to the index value of the first candidate matching block grouping.

51. The method of claim 50, wherein: The step of determining the index value of each candidate matching block group includes: Determine a first index value of each candidate matching block group according to the grouping position of each candidate matching block group; Using the first index value of each candidate matching block group as the index value of each candidate matching block group; or, reordering the at least two candidate matching block groups according to a template error value corresponding to each candidate matching block group; Determine a second index value of each candidate matching block group according to the reordered position of each candidate matching block group; The second index value of each candidate matching block group is used as the index value of each candidate matching block group.

52. The method of claim 48 or 49, wherein: The fusing at least one matching block in the first candidate matching block group includes: Determine a template error value of each matching block in the first candidate matching block group; Determining a template error threshold according to the template error value and the threshold coefficient of the i-th matching block in the first candidate matching block group; wherein the i-th matching block is a matching block with the smallest template error value in the current candidate matching block group; When the template error value of the i+jth matching block is greater than the number of matching blocks of the template error threshold, the i-th matching block in the first candidate matching block group is used as the i+jth fused matching block; All the matching blocks in the updated first candidate matching block group are used for fusion.

53. The method of claim 35, wherein: When determining that the current block is predicted using the IntraTMP multi-candidate prediction mode, the method includes: Based on template matching, construct a second candidate matching block list for the current block; Determine a first matching block from the second candidate matching block list; Determine a prediction block of the current block according to the first matching block; An encoding decision is made based on the predicted block and the original block of the current block to determine whether the current block is predicted using the IntraTMP multi-candidate prediction mode.

54. The method of claim 32, wherein: The prediction mode based on template matching determines the matching block of the current block, including: Based on template matching, construct a second candidate matching block list for the current block; A first matching block is determined from the second candidate matching block list.

55. The method of claim 53 or 54, wherein: The determining the first matching block from the second candidate matching block list comprises: Determine the first N matching blocks from the second candidate matching block list; wherein N is an integer greater than 0.

56. The method of claim 55, wherein: The determining of the first matching block from the second candidate matching block list further includes: Reorder the first N matching blocks in the second candidate matching block list; Determine the index values ​​of the first N matching blocks according to the reordered positions of the first N matching blocks; A first matching block is determined from the second candidate matching block list according to the index values ​​of the first N matching blocks.

57. The method of claim 56, wherein: The reordering of the first N matching blocks in the second candidate matching block list includes: Determine a first prediction template of the current block according to the template of the i-th matching block; Determine a second prediction template for the current block according to a non-template matching intra prediction mode used by the current block; fusing the first prediction template and the second prediction template to determine a final prediction template for the current block; Determine the template error value corresponding to the i-th matching block according to the final prediction template of the current block and the template of the current block; The first N matching blocks are reordered according to the template error values ​​corresponding to the first N matching blocks.

58. The method of claim 32, wherein: The non-template matching intra-frame prediction mode includes at least two candidate intra-frame prediction modes; the method further includes: Reorder at least two candidate intra prediction modes to obtain a candidate intra prediction mode list and an index value of each candidate intra prediction mode; Determine an index value of a first intra-frame prediction mode used by a current frame; Determining the first intra prediction mode from a candidate intra prediction mode list according to an index value of the first intra prediction mode; The first intra-frame prediction mode is used as the non-template matching intra-frame prediction mode used by the current block.

59. The method of claim 58, wherein: The reordering of at least two candidate intra prediction modes comprises: Using the template of the matching block of the current block as the first prediction template of the current block; Determine a second prediction template for the current block according to the i-th candidate intra prediction mode; fusing the first prediction template and the second prediction template to determine a final prediction template for the current block; Determining a template error value corresponding to the i-th candidate intra prediction mode according to a final prediction template of the current block and a template of the current block; At least two candidate intra-frame prediction modes are reordered according to template error values ​​corresponding to the at least two candidate intra-frame prediction modes.

60. The method of claim 59, wherein: An optimal intra-frame prediction mode with a minimum template error value is determined as the first intra-frame prediction mode.

61. The method of claim 32, wherein: The fusing the first prediction block and the second prediction block to determine a final prediction block of the current block includes: The first prediction block and the second prediction block are merged according to a preset first weight value and a second weight value to determine a final prediction block of the current block.

62. The method of claim 32, wherein: The fusing the first prediction block and the second prediction block to determine a final prediction block of the current block includes: Based on the intra prediction mode derived from TIMD, the current block is divided into four sub-regions; Determine first weight values ​​and second weight values ​​of four sub-regions of the current block respectively; According to the first weight values ​​and the second weight values ​​of the four sub-regions of the current block, the first prediction block and the second prediction block are merged to determine a final prediction block of the current block; Alternatively, determining a first weight value and a second weight value of the current block based on the intra prediction mode derived from the TIMD; The first prediction block and the second prediction block are merged according to the first weight value and the second weight value of the current block to determine a final prediction block of the current block.

63. A code stream, wherein The bitstream 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: a syntax element for indicating whether the current block is allowed to be predicted using the IntraTMP fusion intra-frame prediction mode, a syntax element for indicating whether the current block is predicted using the IntraTMP fusion intra-frame prediction mode, a syntax element for indicating whether to filter the first matching block, a syntax element for filtering the prediction block of the current block, a syntax element for indicating the index value of the first matching block in the candidate matching block list, a syntax element for indicating the index value of the first candidate matching block group in the candidate matching block list, a syntax element for indicating the intra-frame prediction mode of non-template matching, a syntax element for indicating whether to decode the relevant syntax elements of the current block, the number of matching blocks in the candidate matching block group, the value N of the number of matching blocks when multiple matching blocks are fused, the length of the first candidate matching block list, and the length of the second candidate matching block list.

64. An encoder, comprising a first prediction unit, a first determination unit and an encoding unit; wherein: The first prediction unit is configured to determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block; The first prediction unit is configured to determine a second prediction block of the current block based on a non-template matching intra prediction mode; The first prediction unit is configured to merge the first prediction block and the second prediction block to determine a final prediction block of the current block; The first determination unit is configured to make a coding decision based on the final prediction block and the original block of the current block to determine whether the current block is predicted using the IntraTMP fusion intra prediction mode; The encoding unit is configured to encode relevant syntax elements of the current block and write the obtained coded bits into the bitstream; The relevant syntax elements are used to indicate whether the current block is predicted using the IntraTMP fusion intra prediction mode based on intra-frame template matching prediction.

65. 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 32 to 62 when running the computer program.

66. A decoder comprising a decoding unit, a second determining unit and a second predicting unit; wherein: The decoding unit is configured to decode the relevant syntax elements of the current block; wherein the relevant syntax elements are used to indicate whether the current block is predicted using the intra prediction mode based on intra template matching prediction IntraTMP fusion; The second determining unit is configured to determine, according to the relevant syntax elements, that the current block is predicted using the IntraTMP fusion intra prediction mode; The second prediction unit is configured to determine a matching block of the current block based on a prediction mode of template matching, and determine a first prediction block of the current block according to the matching block; The second prediction unit is further configured to determine a second prediction block of the current block based on a non-template matching intra prediction mode; The second prediction unit is further configured to merge the first prediction block and the second prediction block to determine a final prediction block of the current block.

67. 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 31 when running the computer program.

68. 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 31 is implemented, or the method according to any one of claims 32 to 62 is implemented.