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

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

Patent Information

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

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

By constructing a list of candidate matching blocks, grouping them and determining index values, and using the index values ​​to indicate the matching block grouping for fusion prediction, the prediction accuracy is improved. Furthermore, by combining the IntraTMP multi-candidate prediction mode and the IntraTMP fusion prediction mode, the coding efficiency is optimized.

Benefits of technology

It improves intra-frame prediction accuracy, enhances encoding and decoding performance, saves bitrate, and increases encoding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120937360A_ABST
    Figure CN120937360A_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, and the method comprises the steps: building a first candidate matching block list of a current block based on template matching; grouping the first candidate matching block list, determining at least two candidate matching block groups, and determining an index value of each candidate matching block group; the coding end determines an index value of a first candidate matching block group corresponding to the current block and writes the index value of the first candidate matching block group into a code stream, and the decoding end determines the first candidate matching block group according to the index value, carries out fusion according to the first candidate matching block group and determines a prediction block of the current block. Therefore, through constructing the candidate matching block list and grouping, indicating the first candidate matching block group according to the index value, and performing fusion prediction by using the first candidate matching block group, the prediction accuracy can be improved, the code rate can be saved, the coding and decoding efficiency can be improved, and the coding and decoding performance is further improved.
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] Based on template matching, a first candidate matching block list of the current block is constructed;

[0009] 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;

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

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

[0012] At least one matching block in the first candidate matching block group is merged to determine a prediction block for 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] Based on template matching, a first candidate matching block list of the current block is constructed;

[0015] 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;

[0016] Determine an index value of a first candidate matching block group corresponding to the current block from at least two candidate matching block groups;

[0017] The index value of the first candidate matching block group is encoded, and the obtained encoded bits are written into the bitstream.

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

[0019] The syntax element used to indicate the prediction mode of the current block, the syntax element used to indicate the index value of the best matching block corresponding to the current block, the syntax element used to indicate the index value of the best matching block corresponding to the current block, the syntax element used to indicate the fusion prediction mode type of the current block, the syntax element used to indicate whether to determine the index value of the first candidate matching block group of the current block, the number of matching blocks in the candidate matching block group, the value N of the fusion matching block number, the length of the first candidate matching block list, and the length of the second candidate matching block list.

[0020] In a fourth aspect, an embodiment of the present application provides an encoder, comprising a first determining unit, a first grouping unit, and a first prediction unit; wherein:

[0021] a first determining unit configured to construct a first candidate matching block list for the current block based on template matching;

[0022] a first grouping unit configured to group the first candidate matching block list, determine at least two candidate matching block groups, and determine an index value of each candidate matching block group;

[0023] The first determining unit is further configured to determine an index value of a first candidate matching block group corresponding to the current block;

[0024] The first determining unit is further configured to determine the first candidate matching block group from at least two candidate matching block groups according to the index value of the first candidate matching block group;

[0025] The first prediction unit is configured to fuse at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

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

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

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

[0029] In a sixth aspect, an embodiment of the present application provides a decoder, comprising a second determining unit, a second grouping unit, and a second prediction unit; wherein:

[0030] a second determining unit configured to construct a first candidate matching block list for the current block based on template matching;

[0031] a second grouping unit configured to group the first candidate matching block list, determine at least two candidate matching block groups, and determine an index value of each candidate matching block group;

[0032] A second determining unit is configured to determine an index value of a first candidate matching block group corresponding to the current block;

[0033] The second determining unit is further configured to determine 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;

[0034] The second prediction unit is configured to fuse at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

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

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

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

[0038] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed, it implements the method of the first aspect or the method of the second aspect.

[0039] Embodiments of the present application provide a coding and decoding method, bitstream, encoder, decoder, and storage medium. Based on template matching, the method constructs a first candidate matching block list for a current block; groups the first candidate matching block list to determine at least two candidate matching block groups, and determines an index value for each candidate matching block group. The encoder determines the index value of the first candidate matching block group corresponding to the current block and writes the index value of the first candidate matching block group into the bitstream. The decoder determines the first candidate matching block group based on the index value, performs fusion prediction based on the first candidate matching block group, and determines a predicted block for the current block. By constructing and grouping the candidate matching block list, indicating the first candidate matching block group based on the index value, and using the first candidate matching block group for fusion prediction, prediction accuracy can be improved, bitrate can be saved, and coding and decoding efficiency can be improved, thereby enhancing coding and decoding performance. Furthermore, the IntraTMP fusion prediction mode and the IntraTMP multi-candidate prediction mode are combined to improve coding efficiency. Furthermore, by limiting the index value range of the candidate matching block group, codewords for encoding the index value can be saved, thereby improving coding efficiency. For example, by reordering the candidate matching block groups, the index values ​​can be controlled within a smaller index range. BRIEF DESCRIPTION OF THE DRAWINGS

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

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

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

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

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

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

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

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

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

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

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

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

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

[0053] FIG11 is a schematic flow chart of a reordering method in an embodiment of the present application;

[0054] FIG12 is a schematic diagram of a template prediction method according to an embodiment of the present application;

[0055] FIG13 is a schematic diagram of another template prediction method according to an embodiment of the present application;

[0056] FIG14 is a schematic diagram of a flow chart of a fusion method in an embodiment of the present application;

[0057] FIG15 is a schematic diagram of a flow chart of a method for determining a fusion matching block in an embodiment of the present application;

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

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

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

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

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

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

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

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

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

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

[0068] Coding Block (CB);

[0069] Block Matching (BM);

[0070] Coding Unit (CU);

[0071] Block Vector (BV);

[0072] Sum of Absolute Difference (SAD);

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

[0074] Mean Square Error (MSE);

[0075] Sum of Squared Differences (SSD);

[0076] Mean Absolute Deviation (MAD);

[0077] Mean Square Differences (MSD);

[0078] Normalized Correlation Coefficient (NCC);

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

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

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

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

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

[0084] 1) IntraTMP technology

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

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

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

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

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

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

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

[0092] 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;

[0093] 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;

[0094] 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;

[0095] 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;

[0096] 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;

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

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

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

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

[0101] 3) IntraTMP multi-candidate technology

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

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

[0104] 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);

[0105] 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).

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

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

[0108] A variable length encoding method is:

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

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

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

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

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

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

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

[0116] 5) IntraTMP filtering

[0117] 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 filtering for the prediction block.

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

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

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

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

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

[0123] 6) Template-derived IntraTMP fusion

[0124] 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 value is usually a predefined fixed value or calculated based on the template error of each reference block. For example, the template error value of the reference block is the absolute error and SAD, which are SAD1 to SADn respectively. One way to calculate the weight is: SADi = (SADi == 0)? 1: SADi Wi=(SUM-SADi) / ((n-1)*SUM)

[0125] Where n is the total number of reference blocks, and Wi is the weight value corresponding to the reference block with a template error value of SADi. The form of the prediction block after weighted fusion can be as follows:

[0126] The template-derived IntraTMP fusion method uses a method similar to filter coefficient training to obtain weights 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:

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

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

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

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

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

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

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

[0134] 9) IntraTMP fusion intra-frame prediction

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

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

[0137] 10) Intra-frame block copy technology

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

[0139] 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;

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

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

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

[0143] 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).A video coding block is obtained by dividing the input original video signal into coding tree units (CTUs). The residual pixel information obtained after intra-frame or inter-frame prediction is then transformed by the transform and quantization unit 101, including transforming the residual information from the pixel domain to the transform domain and quantizing the resulting 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 determined by the motion estimation unit 105 based on the motion vector. Perform motion compensation; after determining the intra-frame prediction mode, the intra-frame prediction unit 103 is also used 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 used to reconstruct the video coding block, reconstruct the residual block in the pixel domain, and the reconstructed residual block is removed from the block effect artifacts through the filter control analysis unit 107 and the filtering unit 108. 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 used 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; and the decoded image buffer unit 110 is used 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 .

[0144] 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 FIG4A , 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.

[0145] 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 of the embodiment of the present application can be the above-mentioned electronic device.

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

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

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

[0149] Step 1001: Based on template matching, construct a first candidate matching block list for the current block;

[0150] Possible matching blocks are searched for within a preset search range using a preset search method. A template error value corresponding to the matching block is calculated based on the template of the matching block and the template of the current block. A candidate matching block list is constructed based on the template error values ​​corresponding to each matching block. For example, the candidate matching block list may be sorted from smallest to largest based on the template error values.

[0151] Step 1002: 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;

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

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

[0154] Exemplarily, the first candidate matching block group may be a specific candidate matching block group of at least two candidate matching block groups.

[0155] Exemplarily, the index value of the first candidate matching block group can be a preset index value, an index value determined by decoding the bitstream, or an index value corresponding to a reference block. The first candidate matching block group is determined based on the index value, and IntraTMP fusion prediction is performed using the matching blocks in the first candidate matching block group to determine a prediction block for the current block.

[0156] Step 1004: Determine a first candidate matching block group from at least two candidate matching block groups according to the index value of the first candidate matching block group;

[0157] Step 1005: Fusing at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

[0158] In some embodiments, the method further includes: decoding relevant syntax elements of the current block. Exemplarily, the relevant syntax elements are used to indicate a prediction mode for the current block. In some embodiments, 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 prediction mode for the current block is an intra template matching prediction (IntraTMP) fusion prediction mode; and the second syntax element is used to indicate an index value of a first candidate matching block group.

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

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

[0161] In some embodiments, the relevant syntax elements further include: 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 the IntraTMP fusion prediction mode, and a syntax element for indicating whether the current block is predicted using the IntraTMP multi-candidate prediction mode. In practical applications, the relevant syntax elements may 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.

[0162] In some embodiments, the method further includes: determining that the prediction mode of the current block is the IntraTMP fusion prediction mode. Execute the decoding method of steps 1001 to 1005 of the embodiment of the present application.

[0163] In some embodiments, the first syntax element is decoded. In some embodiments, the second syntax element is decoded. In some embodiments, the first syntax element and the second syntax element are decoded. Exemplarily, when it is determined that the current block uses the IntraTMP prediction mode for prediction, the first syntax element and the second syntax element are decoded. Exemplarily, when it is determined that the current block allows the use of the IntraTMP fusion prediction mode for prediction, the first syntax element and the second syntax element are decoded. It should be noted that if it is necessary to decode the first syntax element and the second syntax element, the decoding order between the two is not strictly limited.

[0164] In some embodiments, when the value of the first syntax element is a first value, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and the index value of the first candidate matching block group corresponding to the current block is determined according to the second syntax element.

[0165] It should be noted that the IntraTMP fusion prediction mode can be a fusion mode based on at least one matching block, which can also be called the IntraTMP multi-matching block fusion prediction mode. In actual applications, the number of fused matching blocks can be determined by the fusion mode and the grouping rules of the matching blocks.

[0166] In some embodiments, when the value of the first syntax element is the second value, the prediction mode of the current block is determined to be an IntraTMP prediction mode other than the IntraTMP fusion prediction mode. Exemplarily, the other IntraTMP prediction mode may be an IntraTMP multi-candidate prediction mode based on a single matching block, wherein a matching block is selected from multiple candidate matching blocks and a prediction block is obtained using the selected matching block.

[0167] In some embodiments, when the value of the first syntax element is the second numerical value, the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and the index value of the optimal matching block corresponding to the current block is determined based on the second syntax element. In other words, the second syntax element can be used to indicate the index value of the first candidate matching block group, and can also be used to indicate the index value of the optimal matching block corresponding to the current block. The content referred to by the second syntax element is determined based on the prediction mode of the current block. The second syntax element can be set with different index value ranges depending on its purpose, or it can be set with the same index value range.

[0168] For example, the first value may be 1, and the second value may be 0. For example, the first value may be 0, and the second value may be 1.

[0169] Exemplarily, a related syntax element includes:

[0170] Decode IntraTMP related syntax elements, first decode intra_tmp_flag, if intra_tmp_flag is true, it means that the current block is encoded using the IntraTMP mode, and further decode intra_tmp_fusion_flag (which has the function of the first syntax element) and intra_tmp_fusion_idx (which has the function of the first syntax element); if intra_tmp_fusion_flag is true, it means that the current block is predicted using the IntraTMP fusion prediction mode, and which group of matching blocks is used for fusion prediction is determined according to intra_tmp_fusion_idx; if intra_tmp_fusion_flag is false, it means that the current block uses the IntraTMP multi-candidate prediction mode of a single matching block, and intra_tmp_fusion_idx determines the selected optimal matching block.

[0171] In some embodiments, decoding relevant syntax elements of the current block includes: decoding a first syntax element; when the value of the first syntax element is a first numerical value, determining that the prediction mode of the current block is the IntraTMP fusion prediction mode, decoding a second syntax element; and determining, based on the second syntax element, an index value of a first candidate matching block group corresponding to the current block.

[0172] Exemplarily, a related syntax element includes:

[0173] Decode IntraTMP related syntax elements. If intra_tmp_flag is true, it means that the current 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 current block is predicted using the IntraTMP fusion prediction mode, and further decode intra_tmp_fusion_idx to determine which group of matching blocks is used for fusion prediction. The value of intra_tmp_fusion_idx should be related to the grouping rule. For example, the total number of candidate matching block groups is 15, intra_tmp_fusion_idx can be 0 to 14, and intra_tmp_fusion_idx can also be 0 to N, where N is less than 14. intra_tmp_fusion_idx can use variable-length coding. The smaller the index, the shorter the corresponding codeword. The smaller the index value, the smaller the template error value of the corresponding candidate matching block, and the greater the probability of being selected. Shorter codewords can be set for smaller index values. For example, use the following table for encoding:

[0174] Indexes 3 to 6 use the same length codeword, and indexes 7 to 14 use the same length codeword. The x in the above table can be obtained using truncated binary. For example, intra_tmp_fusion_idx can be 0 to 4, using the following encoding:

[0175] The decoding methods of a single codeword in intra_tmp_fusion_idx include: decoding a single codeword with equal probability, decoding a single codeword based on a context model, or decoding a single codeword based on multiple context models.

[0176] In some embodiments, the relevant syntax elements further include a third syntax element, the third syntax element being used to indicate the index value of the best matching block corresponding to the current block. Decoding the relevant syntax elements of the current block further includes: when the value of the first syntax element is the second value, determining that the prediction mode of the current block is the IntraTMP multiple-candidate prediction mode based on a single matching block, decoding the third syntax element of the current block; and determining the index value of the best matching block corresponding to the current block based on the third syntax element. In other words, intra_tmp_fusion_idx and intra_tmp_idx can be decoded in different ways depending on the intra_tmp_fusion_flag.

[0177] Exemplarily, a related syntax element includes:

[0178] Decode the IntraTMP related syntax elements. If intra_tmp_flag is true, it means that the current 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 current block is predicted using the IntraTMP fusion prediction mode, and further decode intra_tmp_fusion_idx (which has the function of the second syntax element) to determine which group of matching blocks is used for fusion prediction; if intra_tmp_fusion_flag is false, it means that the current block uses the IntraTMP multiple candidate prediction mode of a single matching block, and further decode intra_tmp_idx (which has the function of the third syntax element) to indicate the index of the selected matching block in the candidate matching block list. For example, if intra_tmp_idx is equal to i, then the i+1th matching block in the candidate matching block list is the selected matching block, i starts from 0, and the index value starts from 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.

[0179] If intra_tmp_fusion_idx and intra_tmp_idx are decoded differently based on intra_tmp_fusion_flag, candidate matching block lists of different lengths can also be constructed based on intra_tmp_fusion_flag. For example, if intra_tmp_fusion_flag is true, a list of length N1 is constructed; if intra_tmp_fusion_flag is false, a list of length N2 is constructed. N1 and N2 can be preset fixed values ​​or determined by the decoded bitstream.

[0180] In some embodiments, when determining that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on a single matching block, the method further includes: determining the best matching block from the second candidate matching block list according to the index value of the best matching block; and determining the prediction block of the current block according to the best matching block.

[0181] In some embodiments, the method further includes: constructing a second candidate matching block list for the current block based on template matching; wherein the length of the second candidate matching block list is different from 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.

[0182] In some embodiments, the second syntax element is also used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block. Exemplarily, if the first candidate matching block group is provided with a fusion mode corresponding to an IntraTMP fusion prediction mode, the first candidate matching block group is indexed according to the index value of the first candidate matching block group, and the fusion mode corresponding to an IntraTMP fusion prediction mode can also be indexed. Different fusion modes have different matching block selection methods, weighted fusion methods, fusion weight values, etc. Exemplarily, the fusion modes include 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.

[0183] Exemplarily, the total length of the candidate matching block list is N, and every M matching blocks in the candidate matching block list can be set as 1 group, which is divided into N / M candidate matching block groups in total. Each candidate matching block group is set with more than one fusion mode, and the candidate matching block group is expanded. When the same candidate matching block group has two fusion modes, it can be regarded as two candidate matching block groups. {BV0, BV1, BV2, BV3, BV4, bFilter=1}, {BV0, BV1, BV2, BV3, BV4, bFilter=0}, {BV0, BV1, BV2, bFilter=1}, {BV0, BV1, bFilter=0}. bFilter=1 represents the first fusion mode, and bFilter=0 represents the second fusion mode. When indexing to the first candidate matching block group according to the index value, the corresponding fusion mode can also be indexed.

[0184] In some embodiments, the relevant syntax elements also include a fourth syntax element, and the method further includes: decoding the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block, or to indicate whether to filter the selected matching block.

[0185] In some embodiments, the first syntax element and the fourth syntax element are decoded. In some embodiments, the second syntax element and the fourth syntax element are decoded. In some embodiments, the third syntax element and the fourth syntax element are decoded. In some embodiments, the first syntax element, the second syntax element, and the fourth syntax element are decoded.

[0186] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and according to the fourth syntax element, the fusion mode of the IntraTMP fusion prediction mode of the current block is determined; the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and according to the fourth syntax element, it is determined whether to filter the selected matching block.

[0187] Exemplarily, a related syntax element includes:

[0188] Decode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further decode intra_tmp_fusion_flag, intra_tmp_filter_flag and intra_tmp_idx (which has the function of the second syntax element, also known as intra_tmp_fusion_idx); if intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and which group of matching blocks is used for fusion prediction is determined according to intra_tmp_idx. intra_tmp_filter_flag indicates the fusion mode. If intra_tmp_fusion_flag is false, intra_tmp_idx indicates that the current block uses the prediction method of a single matching block, and intra_tmp_filter_flag indicates whether to filter the single matching block. Exemplarily, if intra_tmp_filter_flag is true, it indicates that the IntraTMP fusion mode based on template derivation is used; if intra_tmp_filter_flag is false, it indicates that the IntraTMP fusion mode based on template error value is used.

[0189] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and a fourth syntax element is decoded; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block.

[0190] Exemplarily, a related syntax element includes:

[0191] Decode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further decode intra_tmp_fusion_flag. If intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and further decode intra_tmp_filter_flag (which has the function of the fourth syntax element) and intra_tmp_fusion_idx. Intra_tmp_filter_flag indicates the fusion mode, and intra_tmp_fusion_idx determines which group of matching blocks is used for fusion prediction. For example, if intra_tmp_filter_flag is true, it indicates that the template-based IntraTMP fusion mode is used; intra_tmp_fusion_idx determines which group of matching blocks is used for fusion prediction. The matching block group and the corresponding weight value are fused to obtain the final prediction block. If intra_tmp_filter_flag is false, it means that the IntraTMP fusion mode based on the template error value is used, and intra_tmp_fusion_idx determines which group of matching blocks is used for fusion prediction. The matching block group and the corresponding weight value are fused to obtain the final prediction block.

[0192] In some embodiments, the method further comprises: determining a fusion mode of the IntraTMP fusion prediction mode of the current block based on the fusion mode of the IntraTMP fusion prediction mode corresponding to the first candidate matching block group. It is understood that when the corresponding fusion mode is set for the selected candidate matching block group, the fusion mode corresponding to the first candidate matching block group can also be used as the fusion mode of the IntraTMP fusion prediction mode of the current block, without transmitting the intra_tmp_filter_flag to indicate the fusion mode.

[0193] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and a fourth syntax element is decoded; and according to the fourth syntax element, it is determined whether to filter the selected matching block.

[0194] Exemplarily, a related syntax element includes:

[0195] Decode IntraTMP-related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further decode intra_tmp_fusion_flag. If intra_tmp_fusion_flag is false, it indicates that the current block uses the IntraTMP multiple candidate prediction mode of a single matching block, and further decode intra_tmp_filter_flag to determine whether to filter the selected matching block, and further decode intra_tmp_idx to determine the selected optimal matching block. If intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and further decode intra_tmp_idx to determine which group of matching blocks is used for fusion prediction. In some embodiments, decoding intra_tmp_idx can also be performed before determining whether intra_tmp_fusion_flag is true or false. For example, if intra_tmp_flag is true, decode intra_tmp_fusion_flag and intra_tmp_idx.

[0196] In some embodiments, the relevant syntax elements further include a fourth syntax element and a fifth syntax element, and the method further includes: determining that the prediction mode of the current block is the IntraTMP fusion prediction mode, and decoding the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block; determining that the prediction mode of the current block is the IntraTMP multiple candidate prediction mode based on a single matching block, and decoding the fifth syntax element; wherein the fifth syntax element is used to indicate whether to filter the selected matching block. In other words, different syntax elements can be set to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block and to indicate whether to filter the selected matching block.

[0197] In some embodiments, the index range of the index value of the first candidate matching block group is smaller than the index range corresponding to at least two candidate matching block groups. Exemplarily, the index range corresponding to the two candidate matching block groups is 0-5, and the index range of the index value of the first candidate matching block group is 0-2. That is, the transmitted second syntax element is only used to indicate candidate matching block groups with index values ​​0-2. In other words, the value of intra_tmp_fusion_idx can be less than or equal to the number of candidate matching block groups. If all possible matching block groups are reordered, then the first N combinations thereof are indicated by intra_tmp_fusion_idx or intra_tmp_idx. That is, the value range of intra_tmp_fusion_idx or intra_tmp_idx is 0-N-1, and the number of matching block groups to be reordered is M, where M>N. For example, by reordering the candidate matching block groups, the index values ​​are controlled within a smaller index range, or only the first few groups are indexed. By limiting the index value range of the candidate matching block groups, codewords for encoding the index values ​​are saved, thereby improving coding efficiency.

[0198] In some embodiments, when the fusion mode includes a first fusion mode and a second fusion mode, the method further includes: when the fourth syntax element is used to indicate that the fusion mode of the IntraTMP fusion prediction mode of the current block is the first fusion mode, according to the second syntax element, determining the index value of the first candidate matching block group corresponding to the current block; when the fourth syntax element is used to indicate that the fusion mode of the IntraTMP fusion prediction mode of the current block is the second fusion mode, according to the second syntax element and the index offset value, determining the index value of the first candidate matching block group corresponding to the current block.

[0199] It should be noted that when the second syntax element is only used to indicate the index values ​​of some candidate matching block groups, more candidate matching block groups can be indicated according to the fourth syntax element. For example, the index range corresponding to the two candidate matching block groups is 0-5, and the index range of the index value of the first candidate matching block group is 0-2. When the fourth syntax element is used to indicate the first fusion mode, the index range of the second syntax element is 0-2. When the fourth syntax element is used to indicate the second fusion mode, the index range of the value of the second syntax element plus the index offset value is 3-5. It can also be understood that the candidate matching block groups with an index range of 0-2 correspond to the first fusion mode, and the candidate matching block groups with an index range of 3-5 correspond to the second fusion mode.

[0200] In some embodiments, the candidate matching block groups with indexes ranging from 0 to 2 and indexes ranging from 3 to 5 may be obtained by grouping using the same grouping rule or grouping using different grouping rules.

[0201] In some embodiments, determining that the current block is predicted using the IntraTMP fusion prediction mode, the method further includes: saving the index value of the first candidate matching block group corresponding to the current block; or saving a preset matching block in the first candidate matching block group corresponding to the current block. Exemplarily, a BV in the matching block group indicated by intra_tmp_fusion_idx can be saved for reference by other decoding blocks. For example, intra_tmp_fusion_idx = i, and the i*3+1th BV in the candidate block list is saved. Exemplarily, other decoding blocks use the index value of the first candidate matching block group corresponding to the current block as the index value used by themselves.

[0202] In some embodiments, the method further includes: decoding a sixth syntax element; wherein the sixth syntax element is used to indicate whether to decode some or all of the syntax elements related to the current block.

[0203] In some embodiments, the sixth 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.

[0204] 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 sixth syntax element can be set for each of the relevant syntax elements, or for two or more of the relevant syntax elements, or 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.

[0205] Furthermore, the construction of the candidate matching block list is illustrated with an example.

[0206] In some embodiments, template matching is used to search for N candidate matching blocks within a search area. Alternatively, a candidate block list of length N is constructed based on the template error values ​​of the N candidate matching blocks, sorted from smallest to largest. A template matching process for constructing the candidate block list is as follows: a first search is performed with a certain step size, for example, a horizontal step size of 4 and a vertical step size of 4. N optimal matching blocks with a certain spacing are obtained (the first N with the smallest template error values). A second search is then performed in the adjacent areas of the N matching blocks obtained in the first step. These adjacent areas can be configured as 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).

[0207] Furthermore, an example is given to illustrate a method for grouping the first candidate matching block list involved in the embodiment of the present application.

[0208] 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, and the like.

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

[0210] 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 as 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. In other words, 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.

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

[0212] The maximum length of the candidate matching block list constructed through the template matching process is N, for example, N is equal to 15. The 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.

[0213] 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. A total of 8 groups are obtained by grouping the candidate matching block list based on the first grouping rule and the second grouping rule.

[0214] 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}.

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

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

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

[0218] In some embodiments, at least one grouping rule includes a first matching rule and a third grouping rule. At least one grouping rule includes a first matching rule, a second grouping rule, and a third grouping rule. Exemplarily, each grouping rule also includes a corresponding number of groups.

[0219] In some embodiments, 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.

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

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

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

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

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

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

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

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

[0228] In some embodiments, the method further comprises: decoding the code stream to determine 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.

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

[0230] 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 set as a group. 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 set as a group. These two grouping rules can be used individually or in combination to obtain matching block groups. One method for selecting a matching block group is to indicate which group to use by using an index value. Another method is to reorder the matching block groups and then determine a matching block group based on the index value.

[0231] Furthermore, an example is given to illustrate the determination of the index value of each candidate matching block group.

[0232] 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 based on the grouping position of each candidate matching block group; and using the first index value of each candidate matching block group as the index value of each candidate matching block group. In some embodiments, selecting the smallest first index value as the index value of the first candidate matching block group.

[0233] Exemplarily, the candidate blocks in the candidate matching block list are BVn, where n is an integer from 1 to N, or n is an integer from 0 to N-1. The total length of the candidate matching block list is N, and every M matching blocks in the candidate matching block list can be set as 1 group, and a total of N / M candidate matching block groups can be divided. For example, M is equal to 3, and the i-th candidate matching block group is represented as {BV(3i), BV1(3i+1), BV2(3i+2)}, where i is the index value of each candidate matching block group. Here, in the embodiment of the present application, i is an integer greater than or equal to 1, and the number of groups is i less than or equal to the number of groups.

[0234] In some embodiments, determining the index value of each candidate matching block group includes: reordering at least two candidate matching block groups; 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. In some embodiments, the smallest second index value is selected as the index value of the first candidate matching block group.

[0235] Exemplarily, the candidate matching block groups are reordered according to their corresponding template error values, with the candidate matching block group with the smallest template error value being ranked first. The smaller the template error value, the smaller the weight value corresponding to the matching block group, and the greater the probability of the matching block group with the smaller template error value being selected. Reordering can reduce the number of index value encoding bits. Exemplarily, the candidate blocks in the candidate matching block list are BVn, where n is an integer from 1 to N, or n is an integer from 0 to N-1. The total length of the candidate matching block list is N, and every M matching blocks in the candidate matching block list can be set as 1 group, with a total of N / M candidate matching block groups. For example, M is equal to 3, and the i-th candidate matching block group is represented as {BV(3i), BV1(3i+1), BV2(3i+2)}, where i is the index value of each candidate matching block group. Here, in the embodiment of the present application, i is an integer greater than or equal to 1, and the number of groups is i less than or equal to the number of groups. For example, after reordering, if the template error value of the second candidate matching block group is determined to be the smallest, it is ranked first and its index value becomes 0. If the second syntax element is used to indicate the index value of the second candidate matching block group, only 0 needs to be encoded.

[0236] FIG11 is a flow chart of a reordering method according to an embodiment of the present application. As shown in FIG11 , in some embodiments, reordering at least two candidate matching block groups includes:

[0237] Step 1101: Determine N fused matching blocks to be fused from each candidate matching block group; where N is an integer greater than 0;

[0238] Step 1102: Determine fusion weight values ​​of N fusion matching blocks;

[0239] Step 1103: Fusing the templates of the N fused matching blocks according to their fusion weight values ​​to determine a prediction template corresponding to each candidate matching block group;

[0240] Step 1104: 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;

[0241] Step 1105: Reorder according to the template error value corresponding to each candidate matching block group.

[0242] In the template area, each candidate matching block group is used to perform template prediction, thereby calculating the prediction template corresponding to different candidate matching block groups, and calculating the template error value based on the predicted template and the template of the current block. The specific method is as follows:

[0243] As shown in FIG12 , a single matching block is predicted in the template region, and the template of the matching block is the prediction template of the template region.

[0244] As shown in Figure 13, multiple matching blocks are fused and predicted in the template region. This involves weighted fusion of the templates of the multiple matching blocks to obtain a predicted template. The weighted fusion process for the templates should be consistent with the weighted fusion process for predicting the current block.

[0245] Using the above-described method for predicting in a template region, a prediction template for each candidate matching block group in the template region can be obtained. Furthermore, by comparing the predicted template with the template of the current block, a template error value for each candidate matching block group can be obtained. Based on these template error values, the optimal candidate matching block group can be selected by reordering the blocks.

[0246] In some embodiments, determining the fusion weight values ​​of the N fusion matching blocks includes: determining the fusion weight values ​​of the N fusion matching blocks according to the fusion mode of the IntraTMP fusion prediction mode of the current block.

[0247] In some embodiments, when each candidate matching block group sets the fusion mode of the corresponding IntraTMP fusion prediction mode, the fusion weight values ​​of the N fused matching blocks are determined, including: determining the fusion weight values ​​of the N fused matching blocks according to the fusion mode of the IntraTMP fusion prediction mode corresponding to each candidate matching block group.

[0248] It should be noted that different fusion modes correspond to different weight value derivation methods. Therefore, it is necessary to derive the fusion weight value based on the fusion mode of the IntraTMP fusion prediction mode of the current block; the fusion weight value of the N fused matching blocks is determined based on the fusion mode of the IntraTMP fusion prediction mode corresponding to the current candidate matching block group. In this embodiment of the application, the fusion mode of the current block can be pre-agreed or indicated by transmitting the fourth syntax element.

[0249] Furthermore, the method for fusing matching blocks in the embodiment of the present application is further illustrated. FIG14 is a flow chart of a fusing method in the embodiment of the present application. As shown in FIG14 , fusing at least one matching block in the first candidate matching block group to determine a predicted block for the current block includes:

[0250] Step 1401: Determine N fused matching blocks to be fused from the first candidate matching block group; where N is an integer greater than 0;

[0251] Step 1402: Determine fusion weight values ​​of N fusion matching blocks;

[0252] Step 1403: Fusing the N fused matching blocks according to their fusion weight values ​​to determine a prediction block for the current block.

[0253] It should be noted that N is less than or equal to the number of matching blocks.

[0254] In some embodiments, determining the N fused matching blocks to be fused in at least one of step 1101 and step 1401 includes: determining a template error value of each matching block in the current 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 current 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; and determining a matching block with a template error value less than or equal to the template error threshold as a fused matching block.

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

[0256] In some embodiments, the method further comprises: determining a threshold coefficient corresponding to the current candidate matching block group; wherein the threshold coefficients corresponding to different candidate matching block groups are not completely the same. Exemplarily, the smaller the candidate matching block group index value, the larger the threshold coefficient.

[0257] In some embodiments, determining a matching block whose template error value is less than or equal to a template error threshold as a fused matching block includes: when the template error value of the i+jth matching block is greater than the number of matching blocks that is equal to the template error threshold, taking the i-th matching block in the current candidate matching block group as the i+j-th fused matching block.

[0258] 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. 3i The corresponding template error value SAD 3i Set the threshold value, when it satisfies: threshold = a*SAD 3i+j SAD 3i+j ≤threshold, j>0

[0259] Corresponding BV 3i+j It is used for fusion prediction to determine the number of fusions; among them, SAD 3i The minimum template error value of the matching block in the corresponding candidate matching block group, a can be any preset value, such as 1.2, 1.5 or 2. 3i+j If both are less than or equal to the threshold, the fusion form is as follows: pred=w0*BV 3i +w1*BV 3i+1 +w2*BV3i+2 +w3*Bias

[0260] If there is a matching block whose template error value is greater than the threshold, such as SAD 3i+2 >threshold, then you can use BV 3i Replace BV 3i+2 Perform fusion coefficient derivation and weighted calculation, that is, BV 3i , BV 3i+1 and BV 3i The template of the current block is used as input and the current block template is used as output. The coefficients w0 to w3 are derived and the fusion form is as follows: pred=w0*BV 3i +w1*BV 3i+1 +w2*BV 3i +w3*Bias

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

[0262] FIG15 is a flow chart of a method for determining a fusion matching block in an embodiment of the present application. As shown in FIG15 , determining N fusion matching blocks to be fused in step 1101 and step 1401 includes:

[0263] Step 1501: Divide 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 and fused matching blocks of different candidate matching block sets are not exactly the same;

[0264] Step 1502: Determine the fusion weight values ​​of the N fused matching blocks in each candidate matching block set;

[0265] Step 1503: Fusing the templates of the N fused matching blocks 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;

[0266] Step 1504: determining a template error value corresponding to each candidate matching block set based on the prediction template corresponding to each candidate matching block set and the template of the current block;

[0267] Step 1505: Determine the best candidate matching block set with the smallest template error value based on the template error value corresponding to each candidate matching block set; and use the matching blocks in the best candidate matching block set as N fused matching blocks.

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

[0269] 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 based on 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 predicted block of the current block.

[0270] In some embodiments, determining the N fused matching blocks to be fused in steps 1101 and 1401 includes: determining the N fused matching blocks to be fused, including: 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. In other words, if the fused number N is less than the number of matching blocks M, only the N matching blocks can 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 can 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.

[0271] In some embodiments, the method further includes: decoding the code stream, and determining a value N of the number of fusion matching blocks. Exemplarily, the relevant syntax elements further include a syntax element intra_tmp_fusion_num, which is used to indicate the value N of the number of fusion matching blocks.

[0272] In some embodiments, the fusion weight values ​​of the N fusion matching blocks in at least one of step 1102 , step 1402 , and step 1502 are predefined fixed values.

[0273] In some embodiments, determining the fusion weight values ​​of the N fused matching blocks in at least one of step 1102, step 1402 and step 1502 may include: determining the fusion weight values ​​of the N fused 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.

[0274] It should be noted that different fusion modes correspond to different weighted fusion methods and fusion weight value derivation methods. Therefore, when determining the fusion weight value of each fused matching block, it is necessary to determine the weight value derivation method based on the fusion mode of the IntraTMP fusion prediction mode corresponding to the current candidate matching block group.

[0275] 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 fused matching blocks includes: determining the fusion weight values ​​of the N fused matching blocks and the fusion weight value of the bias parameter according to the templates of the N fused matching blocks, the template of the current block, and the bias parameter;

[0276] The N fused matching blocks are fused according to the fusion weight values ​​of the N fused matching blocks to determine the prediction block of the current block, including: fusing the N fused matching blocks and the bias parameter according to the fusion weight values ​​of the N fused matching blocks and the fusion weight value of the bias parameter to determine the prediction block of the current block.

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

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

[0279] In some embodiments, the fusion mode is an intra-frame template matching fusion mode based on template error values, and determining the fusion weight values ​​of 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.

[0280] 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)

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

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

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

[0284] Step 1601: Based on template matching, construct a first candidate matching block list for the current block;

[0285] Possible matching blocks are searched for within a preset search range using a preset search method. A template error value corresponding to the matching block is calculated based on the template of the matching block and the template of the current block. A candidate matching block list is constructed based on the template error values ​​corresponding to each matching block. For example, the candidate matching block list may be sorted from smallest to largest based on the template error values.

[0286] Step 1602: 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;

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

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

[0289] Exemplarily, the first candidate matching block group may be a specific candidate matching block group of at least two candidate matching block groups, or any candidate matching block group.

[0290] Exemplarily, the index value of the first candidate matching block group can be a preset index value, or the best candidate matching block group selected through a coding decision process such as SATD or RDO by performing fusion prediction using at least two candidate matching block groups. The encoder encodes the index value of the best candidate matching block group, or the index value corresponding to the reference block. The first candidate matching block group is determined based on the index value, and IntraTMP fusion prediction is performed using the matching blocks in the first candidate matching block group to determine the predicted block for the current block.

[0291] Step 1604: Determine a first candidate matching block group from at least two candidate matching block groups according to the index value of the first candidate matching block group;

[0292] Step 1605: Fusing at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

[0293] In some embodiments, the method further includes: determining relevant syntax elements of the current block based on the index value of the first candidate matching block group corresponding to the previous block. Further, the method further includes: encoding relevant syntax elements of the current block. Exemplarily, the relevant syntax elements are used to indicate the prediction mode of the current block. In some embodiments, 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 prediction mode of the current block is an IntraTMP fusion prediction mode based on intra-frame template matching prediction, and the second syntax element is used to indicate the index value of the first candidate matching block group.

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

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

[0296] In some embodiments, the relevant syntax elements further include: 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 the IntraTMP fusion prediction mode, and a syntax element for indicating whether the current block is predicted using the IntraTMP multi-candidate prediction mode. In practical applications, the relevant syntax elements may 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.

[0297] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode. The encoding method of steps 1601 to 1605 of the embodiment of the present application is executed.

[0298] In some embodiments, a first syntax element is encoded. In some embodiments, a second syntax element is encoded. In some embodiments, a first syntax element and a second syntax element are encoded. Exemplarily, when it is determined that the current block uses the IntraTMP prediction mode for prediction, the first syntax element and the second syntax element are encoded. Exemplarily, when it is determined that the current block allows the use of the IntraTMP fusion prediction mode for prediction, the first syntax element and the second syntax element are encoded. It should be noted that if it is necessary to encode the first syntax element and the second syntax element, the encoding order between the two is not strictly limited.

[0299] In some embodiments, when the value of the first syntax element is a first value, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and the index value of the first candidate matching block group corresponding to the current block is determined according to the second syntax element.

[0300] It should be noted that the IntraTMP fusion prediction mode can be a fusion mode based on at least one matching block, which can also be called the IntraTMP multi-matching block fusion prediction mode. In actual applications, the number of fused matching blocks can be determined by the fusion mode and the grouping rules of the matching blocks.

[0301] In some embodiments, when the value of the first syntax element is the second value, the prediction mode of the current block is determined to be an IntraTMP prediction mode other than the IntraTMP fusion prediction mode. Exemplarily, the other IntraTMP prediction mode may be an IntraTMP multi-candidate prediction mode based on a single matching block, wherein a matching block is selected from multiple candidate matching blocks and a prediction block is obtained using the selected matching block.

[0302] In some embodiments, when the value of the first syntax element is the second numerical value, the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and the index value of the optimal matching block corresponding to the current block is determined based on the second syntax element. In other words, the second syntax element can be used to indicate the index value of the first candidate matching block group, and can also be used to indicate the index value of the optimal matching block corresponding to the current block. The content referred to by the second syntax element is determined based on the prediction mode of the current block. The second syntax element can be set with different index value ranges depending on its purpose, or it can be set with the same index value range.

[0303] For example, the first value may be 1, and the second value may be 0. For example, the first value may be 0, and the second value may be 1.

[0304] Exemplarily, a related syntax element includes:

[0305] To encode IntraTMP related syntax elements, first decode intra_tmp_flag. If intra_tmp_flag is true, it means that the current block is encoded using the IntraTMP mode, and further encode intra_tmp_fusion_flag (which has the function of the first syntax element) and intra_tmp_fusion_idx (which has the function of the first syntax element); if intra_tmp_fusion_flag is true, it means that the current block is predicted using the IntraTMP fusion prediction mode, and which group of matching blocks is used for fusion prediction is determined according to intra_tmp_fusion_idx; if intra_tmp_fusion_flag is false, it means that the current block uses the IntraTMP multi-candidate prediction mode of a single matching block, and intra_tmp_fusion_idx determines the selected optimal matching block.

[0306] In some embodiments, encoding relevant syntax elements of the current block includes: encoding a first syntax element; when the value of the first syntax element is a first numerical value, determining that the prediction mode of the current block is the IntraTMP fusion prediction mode, encoding a second syntax element; and determining, based on the second syntax element, an index value of a first candidate matching block group corresponding to the current block.

[0307] Exemplarily, a related syntax element includes:

[0308] Encode IntraTMP related syntax elements. If intra_tmp_flag is true, it means that the current 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 current block is predicted using the IntraTMP fusion prediction mode, and further encode intra_tmp_fusion_idx to determine which group of matching blocks is used for fusion prediction. The value of intra_tmp_fusion_idx should be related to the grouping rule. For example, the total number of candidate matching block groups is 15, intra_tmp_fusion_idx can be 0 to 14, and intra_tmp_fusion_idx can also be 0 to N, where N is less than 14. intra_tmp_fusion_idx can use variable-length coding. The smaller the index, the shorter the corresponding codeword. The smaller the index value, the smaller the template error value of the corresponding candidate matching block, and the greater the probability of being selected. Shorter codewords can be set for smaller index values. For example, use the following table for encoding:

[0309] Indexes 3 to 6 use the same length codeword, and indexes 7 to 14 use the same length codeword. The x in the above table can be obtained using truncated binary. For example, intra_tmp_fusion_idx can be 0 to 4, using the following encoding:

[0310] The encoding methods of a single codeword in intra_tmp_fusion_idx include: encoding a single codeword with equal probability, encoding a single codeword based on a context model, or encoding a single codeword based on multiple context models.

[0311] In some embodiments, the method further includes: making an encoding decision based on the predicted block and the original block of the current block corresponding to each candidate matching block group to determine the best candidate matching block group; when the index value of the first candidate matching block group is not the index value of the best candidate matching block group, using the index value of the best candidate matching block group as the index value of the first candidate matching block group; and determining the second syntax element based on the index value of the first candidate matching block group.

[0312] It should be noted that the encoding end and the decoding end use the same matching block grouping method and use the same process to perform fusion prediction on each group of matching blocks. The encoding end can select the best prediction mode through coding decision processes such as SATD and RDO, determine the values ​​of the first syntax element and the second syntax element, encode the first syntax element and the second syntax element, write the coded bits into the bitstream, and complete the coding process of the current block.

[0313] In some embodiments, the relevant syntax elements further include a third syntax element, the third syntax element being used to indicate the index value of the best matching block corresponding to the current block. Encoding the relevant syntax elements for the current block further includes: when the value of the first syntax element is the second value, determining that the prediction mode for the current block is the IntraTMP multiple-candidate prediction mode based on a single matching block, encoding the third syntax element for the current block; and determining the index value of the best matching block corresponding to the current block based on the third syntax element. That is, intra_tmp_fusion_idx and intra_tmp_idx can be encoded in different ways depending on the intra_tmp_fusion_flag.

[0314] Exemplarily, a related syntax element includes:

[0315] Encode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further encode intra_tmp_fusion_flag; if intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and further encode intra_tmp_fusion_idx (which has the function of the second syntax element) to determine which group of matching blocks is used for fusion prediction; if intra_tmp_fusion_flag is false, it indicates that the current block uses the IntraTMP multiple candidate prediction mode of a single matching block, and further encode intra_tmp_idx (which has the function of the third syntax element) to indicate the index of the selected matching block in the candidate matching block list. 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 from 0, and the index value starts from 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.

[0316] If intra_tmp_fusion_idx and intra_tmp_idx are encoded differently based on the intra_tmp_fusion_flag, candidate matching block lists of different lengths can also be constructed based on the intra_tmp_fusion_flag. For example, if intra_tmp_fusion_flag is true, a list of length N1 is constructed; if intra_tmp_fusion_flag is false, a list of length N2 is constructed. N1 and N2 can be preset fixed values ​​or written into the bitstream.

[0317] In some embodiments, when determining that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on a single matching block, the method further includes: determining the best matching block from the second candidate matching block list according to the index value of the best matching block; and determining the prediction block of the current block according to the best matching block.

[0318] In some embodiments, the method further includes: constructing a second candidate matching block list for the current block based on template matching; wherein the length of the second candidate matching block list is different from 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.

[0319] In some embodiments, the second syntax element is also used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block. Exemplarily, if the first candidate matching block group is provided with a fusion mode corresponding to an IntraTMP fusion prediction mode, the first candidate matching block group is indexed according to the index value of the first candidate matching block group, and the fusion mode corresponding to an IntraTMP fusion prediction mode can also be indexed. Different fusion modes have different matching block selection methods, weighted fusion methods, fusion weight values, etc. Exemplarily, the fusion modes include 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.

[0320] Exemplarily, the total length of the candidate matching block list is N, and every M matching blocks in the candidate matching block list can be set as 1 group, which is divided into N / M candidate matching block groups in total. Each candidate matching block group is set with more than one fusion mode, and the candidate matching block group is expanded. When the same candidate matching block group has two fusion modes, it can be regarded as two candidate matching block groups. {BV0, BV1, BV2, BV3, BV4, bFilter=1}, {BV0, BV1, BV2, BV3, BV4, bFilter=0}, {BV0, BV1, BV2, bFilter=1}, {BV0, BV1, bFilter=0}. bFilter=1 represents the first fusion mode, and bFilter=0 represents the second fusion mode. When indexing to the first candidate matching block group according to the index value, the corresponding fusion mode can also be indexed.

[0321] In some embodiments, the relevant syntax elements also include a fourth syntax element, and the method further includes: encoding the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block, or to indicate whether to filter the selected matching block.

[0322] In some embodiments, the first syntax element and the fourth syntax element are encoded. In some embodiments, the second syntax element and the fourth syntax element are encoded. In some embodiments, the third syntax element and the fourth syntax element are encoded. In some embodiments, the first syntax element, the second syntax element, and the fourth syntax element are encoded.

[0323] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and according to the fourth syntax element, the fusion mode of the IntraTMP fusion prediction mode of the current block is determined; the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and according to the fourth syntax element, it is determined whether to filter the selected matching block.

[0324] Exemplarily, a related syntax element includes:

[0325] Encode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further encodes intra_tmp_fusion_flag, intra_tmp_filter_flag and intra_tmp_idx (which has the function of the second syntax element, also known as intra_tmp_fusion_idx); if intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and which group of matching blocks is used for fusion prediction is determined according to intra_tmp_idx, and intra_tmp_filter_flag indicates the fusion mode; if intra_tmp_fusion_flag is false, intra_tmp_idx indicates that the current block uses the prediction method of a single matching block, and intra_tmp_filter_flag indicates whether to filter the single matching block. Exemplarily, if intra_tmp_filter_flag is true, it indicates that the IntraTMP fusion mode based on template derivation is used; if intra_tmp_filter_flag is false, it indicates that the IntraTMP fusion mode based on template error value is used.

[0326] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and a fourth syntax element is encoded; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block.

[0327] Exemplarily, a related syntax element includes:

[0328] Encode IntraTMP related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further encode intra_tmp_fusion_flag. If intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and further encode intra_tmp_filter_flag (which has the function of the fourth syntax element) and intra_tmp_fusion_idx. Intra_tmp_filter_flag indicates the fusion mode, and intra_tmp_fusion_idx determines which group of matching blocks is used for fusion prediction. For example, if intra_tmp_filter_flag is true, it indicates that the template-based IntraTMP fusion mode is used; intra_tmp_fusion_idx determines which group of matching blocks is used for fusion prediction. The matching block group and the corresponding weight value are fused to obtain the final prediction block. If intra_tmp_filter_flag is false, it means that the IntraTMP fusion mode based on the template error value is used, and intra_tmp_fusion_idx determines which group of matching blocks is used for fusion prediction. The matching block group and the corresponding weight value are fused to obtain the final prediction block.

[0329] In some embodiments, the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and a fourth syntax element is encoded; and according to the fourth syntax element, it is determined whether to filter the selected matching block.

[0330] Exemplarily, a process of encoding a syntax element includes:

[0331] Encode IntraTMP-related syntax elements. If intra_tmp_flag is true, it indicates that the current block is encoded using the IntraTMP mode, and further encode intra_tmp_fusion_flag. If intra_tmp_fusion_flag is false, it indicates that the current block uses the IntraTMP multiple-candidate prediction mode of a single matching block, and further encode intra_tmp_filter_flag to determine whether to filter the selected matching block, and further encode intra_tmp_idx to determine the selected optimal matching block. If intra_tmp_fusion_flag is true, it indicates that the current block is predicted using the IntraTMP fusion prediction mode, and further encode intra_tmp_idx to determine which group of matching blocks is used for fusion prediction. In some embodiments, encoding intra_tmp_idx can also be performed before determining whether intra_tmp_fusion_flag is true or false.

[0332] In some embodiments, the relevant syntax elements further include a fourth syntax element and a fifth syntax element, and the method further includes: determining that the prediction mode of the current block is the IntraTMP fusion prediction mode, encoding the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block; determining that the prediction mode of the current block is the IntraTMP multiple candidate prediction mode based on a single matching block, encoding the fifth syntax element; wherein the fifth syntax element is used to indicate whether to filter the selected matching block. In other words, different syntax elements can be set to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block and to indicate whether to filter the selected matching block.

[0333] In some embodiments, the index range of the index value of the first candidate matching block group is smaller than the index range corresponding to at least two candidate matching block groups. Exemplarily, the index range corresponding to the two candidate matching block groups is 0-5, and the index range of the index value of the first candidate matching block group is 0-2, that is, the second syntax element transmitted is only used to indicate the candidate matching block groups with index values ​​0-2. In other words, the value of intra_tmp_fusion_idx can be less than or equal to the number of candidate matching block groups. If all possible matching block groups are reordered, then the first N combinations thereof are indicated by intra_tmp_fusion_idx or intra_tmp_idx. That is, the value range of intra_tmp_fusion_idx or intra_tmp_idx is 0-N-1, and the matching block groups to be reordered are M, M>N.

[0334] In some embodiments, when the fusion mode includes a first fusion mode and a second fusion mode, the method further includes: when the fourth syntax element is used to indicate that the fusion mode of the IntraTMP fusion prediction mode of the current block is the first fusion mode, the second syntax element is determined according to the index value of the first candidate matching block group; when the fourth syntax element is used to indicate that the fusion mode of the IntraTMP fusion prediction mode of the current block is the second fusion mode, the second syntax element is determined according to the index value and index offset value of the first candidate matching block group.

[0335] It should be noted that when the second syntax element is only used to indicate the index values ​​of some candidate matching block groups, more candidate matching block groups can be indicated according to the fourth syntax element. For example, the index range corresponding to the two candidate matching block groups is 0-5, and the index range of the index value of the first candidate matching block group is 0-2. When the fourth syntax element is used to indicate the first fusion mode, the index range of the second syntax element is 0-2. When the fourth syntax element is used to indicate the second fusion mode, the index range of the value of the second syntax element plus the index offset value is 3-5. It can also be understood that the candidate matching block groups with an index range of 0-2 correspond to the first fusion mode, and the candidate matching block groups with an index range of 3-5 correspond to the second fusion mode.

[0336] In some embodiments, the candidate matching block groups with indexes ranging from 0 to 2 and indexes ranging from 3 to 5 may be obtained by grouping using the same grouping rule or grouping using different grouping rules.

[0337] In some embodiments, it is determined that the current block is predicted using the IntraTMP fusion prediction mode, and the method further includes: saving the index value of the first candidate matching block group corresponding to the current block; or saving the preset matching block in the first candidate matching block group corresponding to the current block. Exemplarily, a BV in the matching block group indicated by intra_tmp_fusion_idx can be saved for reference by other decoding blocks. For example, intra_tmp_fusion_idx=i, and the i*3+1th BV in the candidate block list is saved. Exemplarily, other decoding blocks use the index value of the first candidate matching block group corresponding to the current block as the index value used by themselves, or use the preset matching block of the first candidate matching block group as the reference block of other decoding blocks.

[0338] In some embodiments, the method further includes: encoding a sixth syntax element; wherein the sixth syntax element is used to indicate whether to encode some or all of the syntax elements related to the current block.

[0339] In some embodiments, the sixth 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.

[0340] 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 sixth syntax element can be set for each of the relevant syntax elements, or for two or more of the relevant syntax elements, or 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.

[0341] Furthermore, the construction of the candidate matching block list is illustrated with an example.

[0342] In some embodiments, template matching is used to search for N candidate matching blocks within a search area. Alternatively, a candidate block list of length N is constructed based on the template error values ​​of the N candidate matching blocks, sorted from smallest to largest. A template matching process for constructing the candidate block list is as follows: a first search is performed with a certain step size, for example, a horizontal step size of 4 and a vertical step size of 4. N optimal matching blocks with a certain spacing are obtained (the first N with the smallest template error values). A second search is then performed in the adjacent areas of the N matching blocks obtained in the first step. These adjacent areas can be configured as 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).

[0343] Furthermore, an example is given to illustrate a method for grouping the first candidate matching block list involved in the embodiment of the present application.

[0344] 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, and the like.

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

[0346] 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 as 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.

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

[0348] The maximum length of the candidate matching block list constructed through the template matching process is N, for example, N is equal to 15. The 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.

[0349] 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. A total of 8 groups are obtained by grouping the candidate matching block list based on the first grouping rule and the second grouping rule.

[0350] 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}.

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

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

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

[0354] In some embodiments, at least one grouping rule includes a first matching rule and a third grouping rule. At least one grouping rule includes a first matching rule, a second grouping rule, and a third grouping rule. Exemplarily, each grouping rule also includes a corresponding number of groups.

[0355] In some embodiments, 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.

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

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

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

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

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

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

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

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

[0364] In some embodiments, the method further includes: determining at least one grouping rule, and encoding a syntax element for the at least one grouping rule. Exemplarily, the encoding includes a syntax element indicating one grouping rule, or a syntax element indicating a grouping rule combination, where the grouping rule combination includes at least two preset grouping rules.

[0365] In some embodiments, when the codec pre-agreed on one or more grouping rules, the method includes encoding variable parameters in the grouping rules. For example, when the codec pre-agreed on a first grouping rule, the method includes encoding a first preset number. The method also includes encoding the grouping number.

[0366] In other words, one or more grouping rules can be set. For example, one grouping rule uses 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 uses 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 generate matching block groups. One method for selecting a matching block group is to use an index value to indicate which group to use. Another method is to reorder the matching block groups and then determine a matching block group based on the index value.

[0367] Furthermore, an example is given to illustrate the determination of the index value of each candidate matching block group.

[0368] 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 based on the grouping position of each candidate matching block group; and using the first index value of each candidate matching block group as the index value of each candidate matching block group. In some embodiments, selecting the smallest first index value as the index value of the first candidate matching block group.

[0369] Exemplarily, the candidate blocks in the candidate matching block list are BVn, where n is an integer from 1 to N, or n is an integer from 0 to N-1. The total length of the candidate matching block list is N, and every M matching blocks in the candidate matching block list can be set as 1 group, and a total of N / M candidate matching block groups can be divided. For example, M is equal to 3, and the i-th candidate matching block group is represented as {BV(3i), BV1(3i+1), BV2(3i+2)}, where i is the index value of each candidate matching block group. Here, in the embodiment of the present application, i is an integer greater than or equal to 1, and the number of groups is i less than or equal to the number of groups.

[0370] In some embodiments, determining the index value of each candidate matching block group includes: reordering at least two candidate matching block groups; 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. In some embodiments, the smallest second index value is selected as the index value of the first candidate matching block group.

[0371] Exemplarily, the candidate matching block groups are reordered according to their corresponding template error values, with the candidate matching block group with the smallest template error value being ranked first. The smaller the template error value, the smaller the weight value corresponding to the matching block group, and the greater the probability of the matching block group with the smaller template error value being selected. Reordering can reduce the number of index value encoding bits. Exemplarily, the candidate blocks in the candidate matching block list are BVn, where n is an integer from 1 to N, or n is an integer from 0 to N-1. The total length of the candidate matching block list is N, and every M matching blocks in the candidate matching block list can be set as 1 group, with a total of N / M candidate matching block groups. For example, M is equal to 3, and the i-th candidate matching block group is represented as {BV(3i), BV1(3i+1), BV2(3i+2)}, where i is the index value of each candidate matching block group. Here, in the embodiment of the present application, i is an integer greater than or equal to 1, and the number of groups is i less than or equal to the number of groups. For example, after reordering, if the template error value of the second candidate matching block group is determined to be the smallest, it is ranked first and its index value becomes 0. If the second syntax element is used to indicate the index value of the second candidate matching block group, only 0 needs to be encoded.

[0372] FIG11 is a flow chart of a reordering method according to an embodiment of the present application. As shown in FIG11 , in some embodiments, reordering at least two candidate matching block groups includes:

[0373] Step 1101: Determine N fused matching blocks to be fused from each candidate matching block group; where N is an integer greater than 0;

[0374] Step 1102: Determine fusion weight values ​​of N fusion matching blocks;

[0375] Step 1103: Fusing the templates of the N fused matching blocks according to their fusion weight values ​​to determine a prediction template corresponding to each candidate matching block group;

[0376] Step 1104: 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;

[0377] Step 1105: Reorder according to the template error value corresponding to each candidate matching block group.

[0378] In the template area, each candidate matching block group is used to perform template prediction, thereby calculating the prediction template corresponding to different candidate matching block groups, and calculating the template error value based on the predicted template and the template of the current block. The specific method is as follows:

[0379] As shown in FIG12 , a single matching block is predicted in the template region, and the template of the matching block is the prediction template of the template region.

[0380] As shown in Figure 13, multiple matching blocks are fused and predicted in the template region. This involves weighted fusion of the templates of the multiple matching blocks to obtain a predicted template. The weighted fusion process for the templates should be consistent with the weighted fusion process for predicting the current block.

[0381] Using the above-described method for predicting in a template region, a prediction template for each candidate matching block group in the template region can be obtained. Furthermore, by comparing the predicted template with the template of the current block, a template error value for each candidate matching block group can be obtained. Based on these template error values, the optimal candidate matching block group can be selected by reordering the blocks.

[0382] In some embodiments, determining the fusion weight values ​​of the N fusion matching blocks includes: determining the fusion weight values ​​of the N fusion matching blocks according to the fusion mode of the IntraTMP fusion prediction mode of the current block.

[0383] In some embodiments, when each candidate matching block group sets the fusion mode of the corresponding IntraTMP fusion prediction mode, the fusion weight values ​​of the N fused matching blocks are determined, including: determining the fusion weight values ​​of the N fused matching blocks according to the fusion mode of the IntraTMP fusion prediction mode corresponding to each candidate matching block group.

[0384] It should be noted that different fusion modes correspond to different weight value derivation methods. Therefore, it is necessary to derive the fusion weight value based on the fusion mode of the IntraTMP fusion prediction mode of the current block; the fusion weight value of the N fused matching blocks is determined based on the fusion mode of the IntraTMP fusion prediction mode corresponding to the current candidate matching block group. In this embodiment of the application, the fusion mode of the current block can be pre-agreed or indicated by transmitting the fourth syntax element.

[0385] Furthermore, the method for fusing matching blocks in the embodiment of the present application is further illustrated. FIG14 is a flow chart of a fusing method in the embodiment of the present application. As shown in FIG14 , fusing at least one matching block in the first candidate matching block group to determine a predicted block for the current block includes:

[0386] Step 1401: Determine N fused matching blocks to be fused from the first candidate matching block group; where N is an integer greater than 0;

[0387] Step 1402: Determine fusion weight values ​​of N fusion matching blocks;

[0388] Step 1403: Fusing the N fused matching blocks according to their fusion weight values ​​to determine a prediction block for the current block.

[0389] It should be noted that N is less than or equal to the number of matching blocks.

[0390] In some embodiments, determining the N fused matching blocks to be fused in at least one of step 1101 and step 1401 includes: determining a template error value of each matching block in the current 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 current 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; and determining a matching block with a template error value less than or equal to the template error threshold as a fused matching block.

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

[0392] In some embodiments, the method further comprises: determining a threshold coefficient corresponding to the current candidate matching block group; wherein the threshold coefficients corresponding to different candidate matching block groups are not completely the same. Exemplarily, the smaller the candidate matching block group index value, the larger the threshold coefficient.

[0393] In some embodiments, determining a matching block whose template error value is less than or equal to a template error threshold as a fused matching block includes: when the template error value of the i+jth matching block is greater than the number of matching blocks that is equal to the template error threshold, taking the i-th matching block in the current candidate matching block group as the i+j-th fused matching block.

[0394] FIG15 is a flow chart of a method for determining a fusion matching block in an embodiment of the present application. As shown in FIG15 , determining N fusion matching blocks to be fused in step 1101 and step 1401 includes:

[0395] Step 1501: Divide 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 and fused matching blocks of different candidate matching block sets are not exactly the same;

[0396] Step 1502: Determine the fusion weight values ​​of the N fused matching blocks in each candidate matching block set;

[0397] Step 1503: Fusing the templates of the N fused matching blocks 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;

[0398] Step 1504: determining a template error value corresponding to each candidate matching block set based on the prediction template corresponding to each candidate matching block set and the template of the current block;

[0399] Step 1505: Determine the best candidate matching block set with the smallest template error value based on the template error value corresponding to each candidate matching block set; and use the matching blocks in the best candidate matching block set as N fused matching blocks.

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

[0401] 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 based on 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 predicted block of the current block.

[0402] In some embodiments, determining the N fused matching blocks to be fused in steps 1101 and 1401 includes: determining the N fused matching blocks to be fused, including: 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. In other words, if the fused number N is less than the number of matching blocks M, only the N matching blocks can 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 can 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.

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

[0404] In some embodiments, the fusion weight values ​​of the N fusion matching blocks in at least one of step 1102 , step 1402 , and step 1502 are predefined fixed values.

[0405] In some embodiments, determining the fusion weight values ​​of the N fused matching blocks in at least one of step 1102, step 1402 and step 1502 may include: determining the fusion weight values ​​of the N fused 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.

[0406] It should be noted that different fusion modes correspond to different weighted fusion methods and fusion weight value derivation methods. Therefore, when determining the fusion weight value of each fused matching block, it is necessary to determine the weight value derivation method based on the fusion mode of the IntraTMP fusion prediction mode corresponding to the current candidate matching block group.

[0407] 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 fused matching blocks includes: determining the fusion weight values ​​of the N fused matching blocks and the fusion weight value of the bias parameter according to the templates of the N fused matching blocks, the template of the current block, and the bias parameter;

[0408] The N fused matching blocks are fused according to the fusion weight values ​​of the N fused matching blocks to determine the prediction block of the current block, including: fusing the N fused matching blocks and the bias parameter according to the fusion weight values ​​of the N fused matching blocks and the fusion weight value of the bias parameter to determine the prediction block of the current block.

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

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

[0411] In some embodiments, the fusion mode is an intra-frame template matching fusion mode based on template error values, and determining the fusion weight values ​​of 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.

[0412] For example, n is the total number of matching blocks (ie, 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:

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

[0414] By adopting the above technical solution, by constructing a list of candidate matching blocks and grouping them, indicating the first candidate matching block group according to the index value, and using the first candidate matching block group for fusion prediction, it is possible to improve prediction accuracy, save bit rate, and improve encoding and decoding efficiency, thereby improving encoding and decoding performance. Furthermore, combining the IntraTMP fusion prediction mode and the IntraTMP multi-candidate prediction mode improves coding efficiency. Furthermore, by limiting the index value range of the candidate matching block group, index value encoding codewords are saved and coding efficiency is improved. For example, by reordering the candidate matching block group, the index value is controlled within a smaller index range.

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

[0416] A first determining unit 1701 is configured to construct a first candidate matching block list for the current block based on template matching;

[0417] A first grouping unit 1702 is configured to group the first candidate matching block list, determine at least two candidate matching block groups, and determine an index value of each candidate matching block group;

[0418] The first determining unit 1701 is further configured to determine an index value of a first candidate matching block group corresponding to the current block;

[0419] The first determining unit 1701 is further configured to determine a first candidate matching block group from at least two candidate matching block groups according to an index value of the first candidate matching block group;

[0420] The first prediction unit 1703 is configured to fuse at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

[0421] In some embodiments, the encoder 170 may further include: an encoding unit configured to encode relevant syntax elements of the current block; 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 prediction mode of the current block is an intra-frame template matching prediction IntraTMP fusion prediction mode, and the second syntax element is used to indicate the index value of the first candidate matching block group.

[0422] In some embodiments, the second syntax element is further used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block. The encoding method of the second syntax element includes: fixed-length encoding method or variable-length encoding method. In some embodiments, the encoding method of a single codeword in the second syntax element includes: encoding a single codeword with equal probability, encoding a single codeword based on a context model, or encoding a single codeword based on multiple context models.

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

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

[0425] 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 of this embodiment. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0426] 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. When the computer program is executed by the first processor, it implements the encoding method of any one of the aforementioned embodiments.

[0427] 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,

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

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

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

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

[0432] 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;

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

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

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

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

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

[0438] It is understood that the embodiments described herein can be implemented with hardware, software, firmware, middleware, microcode or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSP devices, DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions of the present application or a combination thereof. For software implementation, the technology of the present application can be implemented by a module (such as a process, a function, etc.) that performs the functions of 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.

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

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

[0441] 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 second determination unit 1901, a second grouping unit 1902, and a second prediction unit 1903; wherein:

[0442] The second determining unit 1901 is configured to construct a first candidate matching block list for the current block based on template matching;

[0443] A second grouping unit 1902 is configured to group the first candidate matching block list, determine at least two candidate matching block groups, and determine an index value of each candidate matching block group;

[0444] The second determining unit 1901 is further configured to determine an index value of a first candidate matching block group corresponding to the current block;

[0445] The second determining unit is further configured to determine 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;

[0446] The second prediction unit 1903 is configured to fuse at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

[0447] In some embodiments, the decoder 190 may further include: a decoding unit configured to decode relevant syntax elements of the current block; 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 prediction mode of the current block is an intra-frame template matching prediction IntraTMP fusion prediction mode, and the second syntax element is used to indicate the index value of the first candidate matching block group.

[0448] In some embodiments, the second syntax element is further used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block. The encoding method of the second syntax element includes: fixed-length encoding method or variable-length encoding method. In some embodiments, the encoding method of a single codeword in the second syntax element includes: encoding a single codeword with equal probability, encoding a single codeword based on a context model, or encoding a single codeword based on multiple context models.

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

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

[0451] 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 the decoding method of any of the aforementioned embodiments.

[0452] 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,

[0453] 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;

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

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

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

[0457] 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;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0472] The embodiments of the present application provide a coding and decoding method, a bitstream, an encoder, a decoder, and a storage medium. Based on template matching, a first candidate matching block list for a current block is constructed; the first candidate matching block list is grouped to determine at least two candidate matching block groups, and an index value for each candidate matching block group is determined; the encoding end determines the index value of the first candidate matching block group corresponding to the current block and writes the index value of the first candidate matching block group into the bitstream; the decoding end determines the first candidate matching block group based on the index value, and fuses the first candidate matching block group to determine a predicted block for the current block. By constructing a candidate matching block list and grouping the candidate matching block list, transmitting an index value indicating the first candidate matching block group, and using the first candidate matching block group for fusion prediction, prediction accuracy can be improved, bit rate can be saved, and encoding and decoding efficiency can be improved, thereby improving encoding and decoding performance.

Claims

1. A decoding method, applied to a decoder, the method comprising: Based on template matching, construct a first candidate matching block list for the current block; 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; Determine 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; At least one matching block in the first candidate matching block group is merged to determine a prediction block of the current block.

2. The method according to claim 1, wherein: The method further comprises: Decode the relevant syntax elements of the current block; The related grammatical elements include: a first grammatical element and / or a second grammatical element; The first syntax element is used to indicate whether the prediction mode of the current block is an IntraTMP fusion prediction mode based on intra-frame template matching prediction, and the second syntax element is used to indicate the index value of the first candidate matching block group.

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; decoding the second syntax element; When the value of the first syntax element is a first value, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and the index value of the first candidate matching block group corresponding to the current block is determined according to the second syntax element.

4. The method according to claim 3, wherein: The second syntax element is also used to indicate the index value of the best matching block corresponding to the current block, and the method further includes: When the value of the first syntax element is the second value, the prediction mode of the current block is determined to be the IntraTMP multi-candidate prediction mode based on a single matching block, and the index value of the optimal matching block corresponding to the current block is determined according to the second syntax element.

5. The method according to claim 2, wherein: The decoding of the relevant syntax elements of the current block includes: decoding a first syntax element; When the value of the first syntax element is a first value, determining that the prediction mode of the current block is the IntraTMP fusion prediction mode, and decoding the second syntax element; Determine, according to the second syntax element, an index value of the first candidate matching block group corresponding to the current block.

6. The method according to claim 5, wherein: The related syntax elements further include a third syntax element, where the third syntax element is used to indicate an index value of a best matching block corresponding to the current block, and the decoding of the related syntax elements of the current block further includes: When the value of the first syntax element is the second value, determining that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on a single matching block, and decoding the third syntax element of the current block; According to the third syntax element, an index value of a best matching block corresponding to the current block is determined.

7. The method according to claim 4 or 6, wherein: When determining that the prediction mode of the current block is an IntraTMP multi-candidate prediction mode based on a single matching block, the method further includes: Determine the best matching block from a second candidate matching block list according to the index value of the best matching block; A prediction block of the current block is determined according to the best matching block.

8. The method according to claim 7, wherein: The method further comprises: Based on template matching, the second candidate matching block list of the current block is constructed; wherein the length of the second candidate matching block list is not equal to the length of the first candidate matching block list.

9. The method according to any one of claims 2 to 8, wherein: The second syntax element is also used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block.

10. The method according to claim 2, wherein: The decoding method of the second syntax element includes: a fixed-length decoding method corresponding to fixed-length coding, or a variable-length decoding method corresponding to variable-length coding.

11. The method according to claim 10, wherein: The decoding method of the single codeword in the second syntax element includes: decoding the single codeword with equal probability, decoding the single codeword based on a context model, or decoding the single codeword based on multiple context models.

12. The method according to any one of claims 2 to 11, wherein: The related syntax elements further include a fourth syntax element, and the method further includes: Decode the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block, or to indicate whether to filter the selected matching block.

13. The method according to claim 12, wherein: The method further comprises: Determine that the prediction mode of the current block is the IntraTMP fusion prediction mode, and determine the fusion mode of the IntraTMP fusion prediction mode of the current block according to the fourth syntax element; Determine that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on the single matching block, and determine whether to filter the selected matching block according to the fourth syntax element.

14. The method according to claim 12, wherein: The method further comprises: Determine that the prediction mode of the current block is the IntraTMP fusion prediction mode, and decode the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block; Determining, according to the fourth syntax element, a fusion mode of the IntraTMP fusion prediction mode of the current block; or, Determine that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on a single matching block, and decode the fourth syntax element; It is determined whether to filter the selected matching block according to the fourth syntax element.

15. The method according to any one of claims 12 to 14, wherein: When the fusion mode includes a first fusion mode and a second fusion mode, the method further includes: When the fourth syntax element is used to indicate that the fusion mode of the IntraTMP fusion prediction mode of the current block is the first fusion mode, the index value of the first candidate matching block group corresponding to the current block is determined according to the second syntax element; The fourth syntax element is used to indicate that when the fusion mode of the IntraTMP fusion prediction mode of the current block is the second fusion mode, the index value of the first candidate matching block group corresponding to the current block is determined according to the second syntax element and the index offset value.

16. The method according to any one of claims 2 to 14, wherein: The index range of the index value of the first candidate matching block group is smaller than or equal to the index ranges corresponding to the at least two candidate matching block groups.

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

18. The method according to claim 17, wherein: The sixth 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.

19. The method according to claim 1, wherein: The grouping of the first candidate matching block list comprises: The first candidate matching block list is grouped according to at least one grouping rule.

20. The method according to claim 19, wherein: The at least one grouping rule comprises a first grouping rule; The first grouping rule includes: starting from the first matching block in the first candidate matching block list, every 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.

21. The method according to claim 20, wherein: 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 is not equal to the second preset number.

22. The method according to claim 21, wherein: The first grouping rule further 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; 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 is equal to the second preset number.

23. The method according to any one of claims 19 to 22, wherein: 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.

24. The method according to claim 23, wherein: The third grouping rule also includes that the values ​​of M2 in different matching block groups are equal, or the third grouping rule also includes that the values ​​of M2 in different matching block groups are not completely equal.

25. The method according to any one of claims 19 to 24, wherein: 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 an i-th candidate matching block group; wherein i is an integer greater than 0.

26. The method according to any one of claims 19 to 25, wherein: The grouping rule also includes: the distance between any two matching blocks in the candidate matching block group is greater than a first distance threshold; Alternatively, the grouping rule further includes: the distance between any two matching blocks in the candidate matching block group is less than a second distance threshold.

27. The method of claim 19, wherein: Each grouping rule also includes a corresponding number of groups.

28. The method according to any one of claims 19 to 27, wherein: The grouping of the first candidate matching block list comprises: Grouping the first candidate matching block list according to at least one grouping rule to obtain at least one candidate matching block group; A corresponding fusion mode of at least one IntraTMP fusion prediction mode is set for each candidate matching block group to obtain at least two candidate matching block groups.

29. The method according to claim 28, wherein: The fusion modes include an intra-frame template matching fusion mode based on template derivation and an intra-frame template matching fusion mode based on template error values.

30. The method according to any one of claims 19 to 29, wherein: The method further comprises: A syntax element indicating the at least one grouping rule is decoded to determine the at least one grouping rule.

31. The method of claim 1, 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; The first index value of each candidate matching block group is used as the index value of each candidate matching block group.

32. The method of claim 1, wherein: The step of determining the index value of each candidate matching block group includes: reordering the at least two candidate matching block groups; 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.

33. The method of claim 32, wherein: The reordering of the at least two candidate matching block groups comprises: Determine N fused matching blocks to be fused from each candidate matching block group; where N is an integer greater than 0; Determining fusion weight values ​​of the N fusion 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; Determine a template error value corresponding to each candidate matching block group according to the prediction template corresponding to each candidate matching block group and the template of the current block; Reorder according to the template error value corresponding to each candidate matching block group.

34. The method according to claim 31 or 32, wherein: When each candidate matching block group sets a corresponding fusion mode of the IntraTMP fusion prediction mode, the method further includes: According to the fusion mode of the IntraTMP fusion prediction mode corresponding to the first candidate matching block group, the fusion mode of the IntraTMP fusion prediction mode of the current block is determined.

35. The method of claim 1, wherein: The step of fusing at least one matching block in the first candidate matching block group to determine a prediction block of the current block includes: Determine N fused matching blocks to be fused from the first candidate matching block group, where N is an integer greater than 0; Determining fusion weight values ​​of the N fusion matching blocks; The N fused matching blocks are fused according to the fusion weight values ​​of the N fused matching blocks to determine a prediction block of the current block.

36. The method according to claim 33 or 35, wherein: The determining of N fusion matching blocks to be fused includes: Determine a template error value of each matching block in the current candidate matching block group; Determine the template error threshold according to the template error value and the threshold coefficient of the i-th matching block in the current 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; A matching block whose template error value is less than or equal to the template error threshold is determined as a fused matching block.

37. The method of claim 36, wherein: The method further comprises: Determine a threshold coefficient corresponding to the current candidate matching block group; wherein the threshold coefficients corresponding to different candidate matching block groups are not completely the same.

38. The method of claim 36, wherein: The determining as a fused matching block a matching block whose template error value is less than or equal to the template error threshold includes: 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 current candidate matching block group is used as the i+j-th fused matching block.

39. The method according to claim 33 or 35, wherein: The determining of N fusion matching blocks to be fused includes: Divide 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 fused matching blocks in different candidate matching block sets are not completely the same; Determine the fusion weight value 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, and determining a prediction template corresponding to each candidate matching block set; Determine 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; According to the template error value corresponding to each candidate matching block set, determine the best candidate matching block set with the smallest template error value; The matching blocks in the best candidate matching block set are used as the N fused matching blocks.

40. The method of claim 33 or 35, wherein: The determining of N fusion matching blocks to be fused includes: The first N matching blocks in the current candidate matching block group are used 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.

41. The method of claim 40, wherein: The method further comprises: Decode the code stream and determine the value N of the number of fusion matching blocks.

42. The method according to any one of claims 33, 35 or 39, wherein: The determining of the fusion weight values ​​of the N fusion matching blocks includes: Determining the fusion weight values ​​of the N fused matching blocks according to the fusion mode of the IntraTMP fusion prediction mode corresponding to the current candidate matching block group; 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.

43. The method of claim 42, wherein: The fusion mode is a fusion mode of intra-frame template matching based on template derivation, and the determining of fusion weight values ​​of the N fusion matching blocks includes: Determining fusion weight values ​​of the N fusion matching blocks and a 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; 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: According to the fusion weight values ​​of the N fusion matching blocks and the fusion weight value of the bias parameter, the N fusion matching blocks and the bias parameter are fused to determine a prediction block of the current block.

44. The method of claim 42, wherein: The fusion mode is a fusion mode of intra-frame template matching based on a template error value, and the determining of fusion weight values ​​of the N fusion matching blocks includes: Determining template error values ​​of the N fused matching blocks according to the templates of the N fused matching blocks and the template of the current block; Determining a cumulative sum of template error values ​​of the N fused matching blocks according to the template error values ​​of the N fused matching blocks; The fusion weight values ​​of the N fusion matching blocks are determined according to the template error values ​​of the N fusion matching blocks and the accumulated sum of the template error values.

45. The method of claim 1, wherein: The method further comprises: The index value of the first candidate matching block group corresponding to the current block is saved; or the preset matching block in the first candidate matching block group corresponding to the current block is saved.

46. ​​A coding method, applied to an encoder, the method comprising: Based on template matching, construct a first candidate matching block list for the current block; 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; Determine 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; At least one matching block in the first candidate matching block group is merged to determine a prediction block of the current block.

47. The method of claim 46, wherein: The method further comprises: Encode the relevant syntax elements of the current block; The related grammatical elements include: a first grammatical element and / or a second grammatical element; The first syntax element is used to indicate whether the prediction mode of the current block is an IntraTMP fusion prediction mode based on intra-frame template matching prediction, and the second syntax element is used to indicate the index value of the first candidate matching block group.

48. The method of claim 46, wherein: The coding of the relevant syntax elements of the current block includes: encoding the first syntax element; encoding the second syntax element; When the value of the first syntax element is a first value, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and the index value of the first candidate matching block group corresponding to the current block is determined according to the second syntax element.

49. The method of claim 48, wherein: The second syntax element is also used to indicate the index value of the best matching block corresponding to the current block, and the method further includes: When the value of the first syntax element is a second value, it is determined that the prediction mode of the current block is an IntraTMP multi-candidate prediction mode based on a single matching block, and the second syntax element is encoded.

50. The method of claim 46, wherein: The coding of the relevant syntax elements of the current block includes: encoding a first syntax element; When the value of the first syntax element is the first value, the prediction mode of the current block is determined to be the IntraTMP fusion prediction mode, and the second syntax element is encoded.

51. The method of claim 50, wherein: The related syntax elements further include a third syntax element, where the third syntax element is used to indicate an index value of a best matching block corresponding to the current block, and the related syntax elements for encoding the current block further include: When the value of the first syntax element is the second value, it is determined that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on a single matching block, and the third syntax element of the current block is encoded.

52. The method of claim 49 or 51, wherein: When determining that the prediction mode of the current block is an IntraTMP multi-candidate prediction mode based on a single matching block, the method further includes: Determine the best matching block from a second candidate matching block list according to the index value of the best matching block; A prediction block of the current block is determined according to the best matching block.

53. The method of claim 52, wherein: The method further comprises: Based on template matching, the second candidate matching block list of the current block is constructed; wherein the length of the second candidate matching block list is not equal to the length of the first candidate matching block list.

54. The method according to any one of claims 47 to 53, wherein: The second syntax element is also used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block.

55. The method of claim 47, wherein: The encoding method of the second syntax element includes: a fixed-length encoding method or a variable-length encoding method.

56. The method of claim 55, wherein: The encoding method of the single codeword in the second syntax element includes: encoding the single codeword with equal probability, encoding the single codeword based on a context model, or encoding the single codeword based on multiple context models.

57. The method according to any one of claims 47 to 56, wherein: The method further comprises: Determine a prediction block of a current block corresponding to the at least two candidate matching block groups; Make coding decisions based on the predicted blocks and original blocks of the current blocks corresponding to each candidate matching block group, and determine the best candidate matching block group; When the index value of the first candidate matching block group is not the index value of the best candidate matching block group, using the index value of the best candidate matching block group as the index value of the first candidate matching block group; The second syntax element is determined according to the index value of the first candidate matching block group.

58. The method according to any one of claims 47 to 57, wherein: The related syntax elements further include a fourth syntax element, and the method further includes: Encode the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block, or to indicate whether to filter the selected matching block.

59. The method of claim 58, wherein: The method further comprises: Determine that the prediction mode of the current block is the IntraTMP fusion prediction mode, and determine the fusion mode of the IntraTMP fusion prediction mode of the current block according to the fourth syntax element; Determine that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on the single matching block, and determine whether to filter the selected matching block according to the fourth syntax element.

60. The method of claim 58, wherein: The method further comprises: Determine that the prediction mode of the current block is the IntraTMP fusion prediction mode, and encode the fourth syntax element; wherein the fourth syntax element is used to indicate the fusion mode of the IntraTMP fusion prediction mode of the current block; or, Determine that the prediction mode of the current block is the IntraTMP multi-candidate prediction mode based on a single matching block, and encode the fourth syntax element; wherein the fourth syntax element is used to indicate whether to filter the selected matching block.

61. The method according to any one of claims 58 to 60, wherein: When the fusion mode includes a first fusion mode and a second fusion mode, the method further includes: The fourth syntax element is used to indicate that when the fusion mode of the IntraTMP fusion prediction mode of the current block is the first fusion mode, the second syntax element is determined according to the index value of the first candidate matching block group; The fourth syntax element is used to indicate that when the fusion mode of the IntraTMP fusion prediction mode of the current block is the second fusion mode, the second syntax element is determined according to the index value and index offset value of the first candidate matching block group.

62. The method according to any one of claims 47 to 60, wherein: The index range of the index value of the first candidate matching block group is smaller than or equal to the index ranges corresponding to the at least two candidate matching block groups.

63. The method according to any one of claims 47 to 60, wherein: The method further comprises: Encode a sixth syntax element; wherein the sixth syntax element is used to indicate whether to encode part of the relevant syntax element of the current block Syntax elements or all syntax elements.

64. The method of claim 63, wherein: The sixth 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.

65. The method of claim 46, wherein: The grouping of the first candidate matching block list comprises: The first candidate matching block list is grouped according to at least one grouping rule.

66. The method of claim 65, wherein: The at least one grouping rule comprises a first grouping rule; The first grouping rule includes: starting from the first matching block in the first candidate matching block list, every 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.

67. The method of claim 66, wherein: 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 is not equal to the second preset number.

68. The method of claim 67, wherein: The first grouping rule further 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; 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 is equal to the second preset number.

69. The method according to any one of claims 65 to 68, wherein: 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.

70. The method of claim 69, wherein: The third grouping rule also includes that the values ​​of M2 in different matching block groups are equal, or the third grouping rule also includes that the values ​​of M2 in different matching block groups are not completely equal.

71. The method according to any one of claims 65 to 70, wherein: 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 an i-th candidate matching block group; wherein i is an integer greater than 0.

72. The method according to any one of claims 65 to 71, wherein: The grouping rule also includes: the distance between any two matching blocks in the candidate matching block group is greater than a first distance threshold; Alternatively, the grouping rule further includes: the distance between any two matching blocks in the candidate matching block group is less than a second distance threshold.

73. The method of claim 65, wherein: Each grouping rule also includes a corresponding number of groups.

74. The method according to any one of claims 65 to 73, wherein: The grouping of the first candidate matching block list comprises: Grouping the first candidate matching block list according to at least one grouping rule to obtain at least one candidate matching block group; A corresponding fusion mode of at least one IntraTMP fusion prediction mode is set for each candidate matching block group to obtain at least two candidate matching block groups.

75. The method of claim 74, wherein: The fusion modes include an intra-frame template matching fusion mode based on template derivation and an intra-frame template matching fusion mode based on template error values.

76. The method according to any one of claims 65 to 75, wherein: The method further comprises: A syntax element for indicating the at least one grouping rule is encoded.

77. The method of claim 46, 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; The first index value of each candidate matching block group is used as the index value of each candidate matching block group.

78. The method of claim 46, wherein: The step of determining the index value of each candidate matching block group includes: reordering the at least two candidate matching block groups; 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.

79. The method of claim 78, wherein: The reordering of the at least two candidate matching block groups comprises: Determine N fused matching blocks to be fused from each candidate matching block group; where N is an integer greater than 0; Determining fusion weight values ​​of the N fusion 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; Determine the template corresponding to each candidate matching block group according to the prediction template corresponding to each candidate matching block group and the template of the current block. Plate error value; Reorder according to the template error value corresponding to each candidate matching block group.

80. The method of claim 77 or 78, wherein: When each candidate matching block group sets a corresponding fusion mode of the IntraTMP fusion prediction mode, the method further includes: According to the fusion mode of the IntraTMP fusion prediction mode corresponding to the first candidate matching block group, the fusion mode of the IntraTMP fusion prediction mode of the current block is determined.

81. The method of claim 46, wherein: The step of fusing at least one matching block in the first candidate matching block group to determine a prediction block of the current block includes: Determine N fused matching blocks to be fused from the first candidate matching block group, where N is an integer greater than 0; Determining fusion weight values ​​of the N fusion matching blocks; The N fused matching blocks are fused according to the fusion weight values ​​of the N fused matching blocks to determine a prediction block of the current block.

82. The method of claim 79 or 81, wherein: The determining of N fusion matching blocks to be fused includes: Determine a template error value of each matching block in the current candidate matching block group; Determine the template error threshold according to the template error value and the threshold coefficient of the i-th matching block in the current 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; A matching block whose template error value is less than or equal to the template error threshold is determined as a fused matching block.

83. The method of claim 82, wherein: The method further comprises: Determine a threshold coefficient corresponding to the current candidate matching block group; wherein the threshold coefficients corresponding to different candidate matching block groups are not completely the same.

84. The method of claim 82, wherein: The determining as a fused matching block a matching block whose template error value is less than or equal to the template error threshold includes: 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 current candidate matching block group is used as the i+j-th fused matching block.

85. The method of claim 79 or 81, wherein: The determining of N fusion matching blocks to be fused includes: Divide 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 fused matching blocks in different candidate matching block sets are not completely the same; Determine the fusion weight value 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, and determining a prediction template corresponding to each candidate matching block set; Determine 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; According to the template error value corresponding to each candidate matching block set, determine the best candidate matching block set with the smallest template error value; The matching blocks in the best candidate matching block set are used as the N fused matching blocks.

86. The method of claim 79 or 81, wherein: The determining of N fusion matching blocks to be fused includes: The first N matching blocks in the current candidate matching block group are used 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.

87. The method of claim 86, wherein: The method further comprises: The value N of the number of encoding fusion matching blocks.

88. The method of any one of claims 79, 81 or 85, wherein: The determining of the fusion weight values ​​of the N fusion matching blocks includes: Determining fusion weight values ​​of the N fusion matching blocks according to a fusion mode of an IntraTMP fusion prediction mode; 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.

89. The method of claim 88, wherein: The fusion mode is a fusion mode of intra-frame template matching based on template derivation, and the determining of fusion weight values ​​of the N fusion matching blocks includes: Determining fusion weight values ​​of the N fusion matching blocks and a 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; 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: According to the fusion weight values ​​of the N fusion matching blocks and the fusion weight value of the bias parameter, the N fusion matching blocks and the bias parameter are fused to determine a prediction block of the current block.

90. The method of claim 88, wherein: The fusion mode is a fusion mode of intra-frame template matching based on a template error value, and the determining of fusion weight values ​​of the N fusion matching blocks includes: Determining template error values ​​of the N fused matching blocks according to the templates of the N fused matching blocks and the template of the current block; Determining a cumulative sum of template error values ​​of the N fused matching blocks according to the template error values ​​of the N fused matching blocks; The fusion weight values ​​of the N fusion matching blocks are determined according to the template error values ​​of the N fusion matching blocks and the accumulated sum of the template error values.

91. The method of claim 46, wherein: The method further comprises: The index value of the first candidate matching block group corresponding to the current block is saved; or the preset matching block in the first candidate matching block group corresponding to the current block is saved.

92. A code stream, wherein The code stream is generated by bit encoding according to the information to be encoded; wherein the information to be encoded includes at least one of the following: a syntax element for indicating a prediction mode of a current block, a syntax element for indicating an index value of an optimal matching block corresponding to the current block, a syntax element for indicating an index value of an optimal matching block corresponding to the current block, a syntax element for indicating a fusion mode of the current block, a syntax element for indicating whether to determine the index value of the first candidate matching block group of the current block, a syntax element for indicating at least one grouping rule, a value N of the number of fused matching blocks, a length of a first candidate matching block list, and a length of a second candidate matching block list.

93. An encoder, comprising a first determining unit, a first grouping unit and a first prediction unit; wherein: The first determining unit is configured to construct a first candidate matching block list for the current block based on template matching; The first grouping unit is configured to group the first candidate matching block list, determine at least two candidate matching block groups, and determine an index value of each candidate matching block group; The first determining unit is further configured to determine an index value of a first candidate matching block group corresponding to the current block; The first determining unit is further configured to 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; The first prediction unit is configured to fuse at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

94. 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 as claimed in any one of claims 46 to 91 when running the computer program.

95. A decoder comprising a second determination unit, a second grouping unit and a second prediction unit; wherein: The second determining unit is configured to construct a first candidate matching block list for the current block based on template matching; The second grouping unit is configured to group the first candidate matching block list, determine at least two candidate matching block groups, and determine an index value of each candidate matching block group; The second determining unit is configured to determine an index value of a first candidate matching block group corresponding to the current block; The second determining unit is further configured to 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; The second prediction unit is configured to fuse at least one matching block in the first candidate matching block group to determine a prediction block for the current block.

96. 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 45 when running the computer program.

97. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, which, when executed, implements the method according to any one of claims 1 to 45, or implements the method according to any one of claims 46 to 91.