Codec method, codestream, encoder, decoder and storage medium

By determining model parameters for a current block and performing filtering on reconstructed pixels, the method improves prediction accuracy and codec efficiency in video codecs.

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

Patent Information

Application Number
JP2025539459
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-01-04
Publication Date
2026-01-22

AI Technical Summary

Technical Problem

Existing video codec technologies suffer from poor prediction accuracy due to insufficient consideration in the reconstruction of predicted pixels, leading to deviations in certain scenarios.

Method used

A method that involves determining a first template for a current block, a matching template, and a reference block, and performing a filtering process based on model parameters to correct the reconstructed pixels, thereby improving prediction accuracy and codec performance.

Benefits of technology

This approach enhances prediction accuracy and codec efficiency by applying model parameters to correct reconstructed pixels, reducing bit rate and improving overall codec performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2026502383000001_ABST
    Figure 2026502383000001_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a codec method, a codestream, an encoder, a decoder, and a storage medium. The method includes the steps of: determining a first template for a current block, determining a matching template and a reference block, determining model parameters based on the first template and the matching template, performing a filtering process on the reference block based on the model parameters to determine a filtered reference block, determining a predicted value for the current block based on the filtered reference block, and determining a reconstructed value for the current block based on the predicted value for the current block. In this way, prediction accuracy can be improved, bit rate can be saved, and codec performance can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present application relates to the field of video codec technology, and in particular to codec methods, codestreams, encoders, decoders and storage media. [Background technology]

[0002] The intra template matching prediction (Intra TMP) technology searches for a matching template with the minimum cost according to a predetermined cost function within a predefined search range of a current image using a template of the coding block, and determines the optimal matching reconstruction block corresponding to the matching template as the prediction block of the current coding block.

[0003] However, in the actual encoding process, the related art generally takes the reconstructed pixels of the best matching reconstructed block as the predicted pixels of the current encoding block, but due to insufficient consideration, large deviations occur in some scenarios, resulting in poor prediction accuracy. Summary of the Invention [Means for solving the problem]

[0004] The present application provides a codec method, codestream, encoder, decoder and storage medium that can improve frame prediction accuracy and further improve codec performance.

[0005] The invention of the present application can be realized as follows.

[0006] In a first aspect, the examples of the present application include: A decoding method applied to a decoder, comprising: determining a first template for the current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a prediction of the current block based on the filtered reference block; determining a reconstructed value for the current block based on the predicted value for the current block.

[0007] In a second aspect, the examples of the present application include: A coding method applied to an encoder, comprising: determining a first template for the current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a prediction of the current block based on the filtered reference block; determining a prediction difference for the current block based on the predicted value of the current block.

[0008] In a third aspect, the examples of the present application include: A codestream generated by bit encoding based on encoding target information, The information to be encoded is The codestream includes at least one of a prediction difference of a current block, the number of coefficients of a target filter, the shape of the target filter, a value of a first syntax element identification information, and a value of a second syntax element identification information, wherein the first syntax element identification information is used to indicate whether intra-template matching is applied to the current block, and the second syntax element identification information is used to indicate whether a filter model is applied to the current block.

[0009] In a fourth aspect, an embodiment of the present application provides an encoder, a first determiner configured to determine a first template for the current block, to determine a matching template and a reference block, and to determine model parameters based on the first template and the matching template; a first filtering unit configured to perform a filtering operation on the reference block based on the model parameters to determine a filtered reference block; a first prediction unit configured to determine a prediction value of the current block based on the filtered reference block; The encoder further provides that the first determination unit is configured to determine a prediction difference for the current block based on the prediction value of the current block.

[0010] In a fifth aspect, the examples of the present application comprise: a first memory storing a computer program executable on a first processor; a first processor that, when a computer program is executed, performs the method according to the second aspect.

[0011] In a sixth aspect, the examples of the present application comprise: a second determiner configured to determine a first template for the current block, to determine a matching template and a reference block, and to determine model parameters based on the first template and the matching template; a second filtering unit configured to perform a filtering operation on the reference block based on the model parameters to determine a filtered reference block; a second prediction unit configured to determine a prediction value of the current block based on the filtered reference block; The second determination unit further provides a decoder configured to determine a reconstructed value of the current block based on the predicted value of the current block.

[0012] In a seventh aspect, the examples of the present application comprise: a second memory storing a computer program executable on a second processor; a second processor configured to perform the method according to the first aspect when the computer program is executed.

[0013] In an eighth aspect, the examples of the present application comprise: A computer program for implementing the method according to the second aspect to generate a codestream when executed by a processor and a computer-readable storage medium storing the codestream are provided.

[0014] The embodiments of the present application provide a codec method, a codestream, an encoder, a decoder, and a storage medium, which, whether on the encoding side or the decoding side, determine a first template for a current block, and determine a matching template and a reference block. Based on the first template and the matching template, model parameters are determined. Based on the model parameters, a filtering process is performed on the reference block to determine a filtered reference block. Based on the filtered reference block, a predicted value of the current block is determined. In this way, the encoding side can determine a prediction difference of the current block based on the predicted value of the current block. Based on this, the decoding side can determine a reconstructed value of the current block based on the predicted value of the current block. That is, by determining model parameters based on the first template and the matching template, the model parameters fully embody the correlation between the matching template and the first template of the current block, applying this correlation to the reference block, performing filtering correction on the reconstructed pixels, and using the filtered reconstructed pixels as the predicted pixels of the current block, prediction accuracy can be improved, bit rate can be saved, and at the same time, codec efficiency can be improved, and codec performance can be further improved. [Brief explanation of the drawings]

[0015] [Figure 1] FIG. 1 is a schematic diagram of the prediction process for the Intra TMP technology. [Figure 2] 1 is a prediction flowchart based on the Intra TMP technology. [Figure 3] FIG. 1 is a schematic diagram of the template type of the Intra TMP technique. [Figure 4A] FIG. 1 is a schematic diagram of a configuration block diagram of an encoder according to an embodiment of the present application. [Figure 4B] FIG. 2 is a schematic diagram of a configuration block diagram of a decoder according to an embodiment of the present application. [Figure 5]1 is a schematic diagram of a network architecture of a codec system according to an embodiment of the present application; [Figure 6] 1 is a flowchart of a decoding method according to an embodiment of the present application; [Figure 7] 3A-3C are schematic diagrams of different sub-region divisions of a search area according to an embodiment of the present application; [Figure 8] 1 is a prediction flowchart based on the Intra TMP-FLM technique according to an embodiment of the present application; [Figure 9] 1 is a search flowchart based on IntraTMP technology according to an embodiment of the present application; [Figure 10] FIG. 2 is a schematic diagram of parameter definitions of a current block and its template according to an embodiment of the present application; [Figure 11] FIG. 2 is a schematic diagram of a template search area according to an embodiment of the present application; [Figure 12] FIG. 1 is a schematic diagram of a specific search area determination process according to an embodiment of the present application. [Figure 13] 1 is a flowchart of a search process according to an embodiment of the present application. [Figure 14] 1 is a schematic diagram of a filter geometry according to an embodiment of the present application; [Figure 15] 1 is a flowchart of the calculation of filter coefficients according to an embodiment of the present application; [Figure 16A] FIG. 2 is a schematic diagram of a configuration of filter coefficients according to an embodiment of the present application; [Figure 16B] FIG. 2 is a schematic diagram of a configuration of a prediction pixel according to an embodiment of the present application; [Figure 17] FIG. 10 is a schematic diagram of another specific search area determination process according to an embodiment of the present application; [Figure 18] FIG. 10 is a schematic diagram of another specific search area determination process according to an embodiment of the present application; [Figure 19] FIG. 10 is a schematic diagram of yet another specific search area determination process according to an embodiment of the present application. [Figure 20] 1 is a flowchart of an encoding method according to an embodiment of the present application; [Figure 21]1 is a schematic diagram of the configuration and structure of an encoder according to an embodiment of the present application. [Figure 22] FIG. 2 is a schematic diagram of a specific hardware structure of an encoder according to an embodiment of the present application; [Figure 23] FIG. 1 is a schematic diagram of the configuration and structure of a decoder according to an embodiment of the present application. [Figure 24] FIG. 2 is a schematic diagram of a specific hardware structure of a decoder according to an embodiment of the present application; [Figure 25] 1 is a diagram illustrating the configuration and structure of a codec system according to an embodiment of the present application. DETAILED DESCRIPTION OF THE INVENTION

[0016] In order to understand the features and technical contents of the embodiments of the present application in more detail, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings, which are merely for reference and explanation purposes and are not intended to limit the embodiments of the present application.

[0017] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terms used herein are for the purpose of describing the examples of this application only and are not intended to be limiting of this application.

[0018] In the following description, reference will be made to "some examples" that describe a subset of all possible embodiments, but it should be understood that "some examples" may be the same or different subsets of all possible embodiments and may be combined with each other as long as they do not conflict. It should be understood that the terms "first / second / third" used in the examples of the present application are merely used to distinguish between similar objects and do not represent a particular ordering of the objects. It should be understood that the terms "first / second / third" can be interchanged, if practicable, to allow the examples of the present application described herein to be implemented in an order other than that shown or described herein.

[0019] Before describing the embodiments of the present application in more detail, the nouns and terms related to the embodiments of the present application will be explained. The following interpretations apply to the nouns and terms related to the embodiments of the present application. Coding Block (CB) Block Matching (BM) Coding Unit (CU) Block Vector (BV) Sum of Absolute Difference (SAD) Sum of Absolute Transformed Difference (SATD) Mean Square Error (MSE) Sum of Squared Differences (SSD) Mean Absolute Deviation (MAD) Mean Square Differences (MSD) Normalized Correlation Coefficient (NCC) H.266 / Versatile Video Coding (VVC) VVC Reference Software Test Platform (VVC Test Model, VTM) Intra Template Matching Prediction (Intra TMP) Beyond VVC Reference Software Test Platform (Enhanced Compression Model, ECM)

[0020] It should be understood that in a video image, a first color component, a second color component, and a third color component are generally used to characterize a coding block. Here, the three color components are a luminance component, a blue color difference component, and a red color difference component, respectively. Specifically, the luminance component is usually represented by the symbol Y, the blue color difference component is usually represented by the symbol Cb or U, and the red color difference component is usually represented by the symbol Cr or V. Thus, a video image may be represented in a YCbCr format or a YUV format.

[0021] Intra TMP is a special intra prediction mode, in which both the encoder and decoder use a coding block template (T) to search for a matching template (T_BEST) with the smallest cost within a predefined search range in the current image according to a predetermined cost function, and the offset of the best matching template relative to the current coding block template is the best block vector (BV_BEST).Then, a reconstruction block (Ref Block) corresponding to the matching template is set as the prediction block of the current coding block (Cur Block).The coding block template usually selects a reconstruction area adjacent to the current coding block.

[0022] Take the adjacent reconstruction area of ​​the current block as an example. As shown in Figure 1, the reconstruction area is represented by the area filled with dark colors, the block filled with grid is the current block, the adjacent area of ​​the current block is the first template (T), the block filled with slashes is the reference block, and the adjacent area of ​​the reference block is the second template (i.e., "reference template" or "matching template", T_BEST). Here, the offset of the second template relative to the first template is the best block vector (BV_BEST), and the reference block can be block-copied as the predicted block of the current block.

[0023] In the embodiments of the present application, the predetermined cost function may be, but is not limited to, the sum of absolute differences SAD, the sum of absolute differences after transformation SATD, the mean squared error MSE, the sum of squared differences SSD, the mean absolute deviation MAD, the mean squared difference MSD, the normalized correlation coefficient NCC, etc.

[0024] As an example, if we take the sum of absolute differences (SAD), the cost function in this case is as follows:

number

[0025] The prediction process of the conventional Intra TMP technique will now be described in detail.

[0026] Inputs for the IntraTMP technique: current block position (xTbCmp, yTbCmp), current block width nTbW, current block height nTbH. Output of the IntraTMP technique: predictions of the current block, predSamples[x][y], where x=0..nTbW-1, y=0..nTbH-1.

[0027] Specifically, the prediction process of the IntraTMP technique can be divided into four steps: determining the type of the current template, obtaining the reconstructed pixels of the current template, determining a block vector within a predefined search range, and generating a predicted value. Thus, the predicted value of the current block can be obtained through the above process. The IntraTMP technique may be used to predict either the luminance component or the chrominance component, and is not particularly limited.

[0028] Referring to Figure 2, a prediction flow chart based on IntraTMP technology is shown. As shown in Figure 2, the flow can include the following steps:

[0029] S201: Determine the current template type.

[0030] In addition, in the Intra TMP technique, a matching template is searched for within a predefined search area using adjacent reconstructed pixels of the current block as templates, such as the upper reference pixels, upper left reference pixels, upper right reference pixels, left reference pixels, and lower left reference pixels of the current block. Therefore, the template type can be classified according to the availability of adjacent reconstructed pixels, and the corresponding template type can be determined.

[0031] The template type can be represented by refTemplateType.,Figure 3 shows a schematic diagram of the template types,of the Intra TMP technique.,As shown in Figure 3, the block filled with grid,is the current block, and the adjacent area of ​​the,current block is the template T, where six template types are,shown.

[0032] For example, the six template types are shown below: 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 FIG. When only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is as shown in FIG. 3(b). When only the upper reference pixels are available, the value of refTemplateType is 3, and the template shape is as shown in FIG. When only the left and upper left reference pixels are available, the value of refTemplateType is 4, and the template shape is as shown in FIG. When only the left and bottom-left reference pixels are available, the value of refTemplateType is 5, and the template shape is as shown in FIG. When only the upper reference pixels and the upper right reference pixels are available, the value of refTemplateType is 6, and the template shape is as shown in FIG.

[0033] S202: The current template pixel is obtained.

[0034] The template for the Intra TMP technique can be configured with reconstructed pixels in one or more of the following regions: the upper right, upper right, left, lower left, and upper left of the current block. The template size may be preset. For example, when acquiring a left template, the template width (templateW_size) may be set to 4, and when acquiring an upper template, the template height (templateH_size) may be set to 4.

[0035] The portion of the reconstructed pixels to be acquired can be determined based on the value of refTemplateType. For example, when the value of refTemplateType is 1, the reconstructed pixels on the left, upper left, and upper sides of the current block are acquired, when the value of refTemplateType is 2, only the reconstructed pixels on the left four columns of the current block are acquired, and when the value of refTemplateType is 3, only the reconstructed pixels on the top four rows of the current block are acquired.

[0036] S203: Determine a block vector within a predefined search range.

[0037] It should be noted that the search process of the Intra TMP technique is mainly divided into an initialization process, determining a search area in the current frame of the template, searching in the search area, and determining an optimal block vector.

[0038] When searching for the optimal matching template in the search area, a search strategy may be adopted in which a coarse search is performed first followed by a fine search, or only a fine search may be performed, or only a coarse search may be performed; no specific limitations are imposed here.

[0039] In the embodiment of the present application, the coarse search here may specifically be determining an optimal coarse matching template in the search area with a first predetermined step size (e.g., 2), or determining an optimal coarse matching template in the search area using a downsampled template (e.g., the downsampling factor is 2).

[0040] In the embodiment of the present application, the fine search here may specifically be determining an optimal fine matching template within the search area with a second predetermined step size (e.g., 1), or determining an optimal fine matching template in the vicinity of the optimal coarse matching template after performing a coarse search.

[0041] In the embodiment of the present application, a coarse search is first performed, and then a fine search is performed, specifically, a first predetermined step size (e.g., 2) is used to determine an optimal coarse matching template in the search area, and then a second predetermined step size (e.g., 1) is used to determine an optimal fine matching template in the vicinity of the optimal coarse matching template.

[0042] In this way, after completing the above operations, the optimal block vector BV_BEST(pX_BEST, pY_BEST) is obtained, where pX_BEST and pY_BEST are respectively the horizontal offset and vertical offset of the optimal matching template relative to the current block template, and are also the horizontal offset and vertical offset of the optimal matching reconstruction block relative to the current block.

[0043] S204: A predicted value is generated.

[0044] This can be achieved here with a simple copy, namely: For x=0...nTbW-1, y=0...nTbH-1,

number

[0045] In short, in the prior art, the Intra TMP technique uses a current block template to search for a matching template with the smallest cost within a predefined search range in the current image according to a predetermined cost function, and selects the best matching reconstruction block (Ref Block) corresponding to the matching template as the prediction block of the current block (Cur Block). The current block template can usually select a reconstruction area adjacent to the current block.

[0046] However, in the actual encoding process, the conventional technique of directly using the reconstructed pixels of the best-matching reconstructed block as the predicted pixels of the current block may not be an optimal solution in some cases. For example, when there is a linear change in light illumination between the best-matching reconstructed block and the current block, directly using the reconstructed pixels of the best-matching reconstructed block as the predicted pixels of the current block may result in a large deviation, which may reduce the prediction accuracy and prevent the optimal prediction effect from being achieved.

[0047] Based on this, an embodiment of the present application provides an encoding method, which includes: determining a first template for a current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a predicted value of the current block based on the filtered reference block; and determining a prediction difference of the current block based on the predicted value of the current block.

[0048] An embodiment of the present application further provides a decoding method, which includes: determining a first template for a current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a predicted value of the current block based on the filtered reference block; and determining a reconstructed value of the current block based on the predicted value of the current block.

[0049] In this way, whether at the encoding side or the decoding side, the first template and the matching template are used to determine model parameters, which fully embody the correlation between the matching template and the first template of the current block. This correlation is applied to the reference block, and after performing filtering correction on its reconstructed pixels, the filtered reconstructed pixels are used as the predicted pixels of the current block. This effectively corrects the predicted value of the intra template matching technology, improves prediction accuracy, and saves bitrate, while also improving codec efficiency and further enhancing codec performance.

[0050] Hereinafter, each embodiment of the present application will be described in detail with reference to the drawings.

[0051] 4A, a schematic block diagram of an encoder according to an embodiment of the present application is shown. As shown in FIG. 4A, an encoder (specifically, a "video encoder") 100 may include a transform and quantization unit 101, an intra estimation unit 102, an intra prediction unit 103, a motion compensation unit 104, a motion estimation unit 105, an inverse transform and inverse quantization unit 106, a filter control analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoded image buffer unit 110. The filtering unit 108 may implement deblocking filtering and sample adaptive offset (SAO) filtering, and the encoding unit 109 may implement header information coding and context-based adaptive binary arithmetic coding (CABAC). The input original video signal can be divided into coding tree units (CTUs) to obtain video coding blocks. Then, the transform and quantization unit 101 performs transformation on the video coding blocks, including transforming the residual pixel information obtained after intra or inter prediction from the pixel domain to the transform domain and quantizing the obtained transform coefficients, to further reduce the bit rate. The intra estimation unit 102 and the intra prediction unit 103 perform intra prediction on the video coding blocks. Specifically, the intra estimation unit 102 and the intra prediction unit 103 determine an intra prediction mode for encoding the video coding blocks. The motion compensation unit 104 and the motion estimation unit 105 perform inter prediction coding of the received video coding blocks relative to one or more blocks in one or more reference frames to provide temporal prediction information. The motion estimation unit 105 performs a process of generating a motion vector capable of estimating the motion of the video coding blocks. The motion compensation unit 104 then performs motion compensation based on the motion vector determined by the motion estimation unit 105.After the intra-prediction mode is determined, the intra-prediction unit 103 further provides the selected intra-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. The inverse transform and inverse quantization unit 106 is used to reconstruct the video coding block, reconstructing a residual block in the pixel domain. The reconstructed residual block is then subjected to blockiness removal by the filter control analysis unit 107 and the filtering unit 108. The reconstructed residual block is then added to a prediction block in the frame stored in the decoded image buffer unit 110 to generate a reconstructed video coding block. The encoding unit 109 encodes various coding parameters and quantized transform coefficients, and encodes information indicating the determined intra-prediction mode using a CABAC coding algorithm in which contextual content is based on neighboring coding blocks, and outputs a codestream of the video signal. The decoded image buffer unit 110 stores the reconstructed video coding block for prediction reference. As the video image encoding progresses, new reconstructed video coding blocks are continually generated, and all of these reconstructed video coding blocks are stored in the decoded image buffer unit 110 .

[0052] Referring to FIG. 4B, a schematic block diagram of a decoder according to an embodiment of the present application is shown. As shown in FIG. 4B, a decoder (specifically, a "video decoder") 200 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra prediction unit 203, a motion compensation unit 204, a filtering unit 205, a decoded image buffer unit 206, etc. The decoding unit 201 performs header information decoding and CABAC decoding, and the filtering unit 205 performs deblocking filtering and SAO filtering. After an input video signal undergoes the encoding process of FIG. 4A, the decoder outputs a code stream of the video signal. 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 then processed by the inverse transform and inverse quantization unit 202 to generate residual blocks in the pixel domain. The intra prediction unit 203 generates prediction data for a current video decoding block based on a determined intra prediction mode and data of a previously decoded block from the current frame or image. The motion compensation unit 204 determines prediction information for the video decoded block by analyzing the motion vectors and other related syntax elements, and uses this prediction information to generate a prediction block for the video decoded block being decoded. A decoded video block is formed by adding the residual block from the inverse transform and inverse quantization unit 202 to the corresponding prediction block generated by the intra prediction unit 203 or motion compensation unit 204. This decoded video signal may then be passed through a filtering unit 205 to remove blockiness artifacts and improve video quality. The decoded video block is then stored in a decoded image buffer unit 206, which stores reference images for subsequent intra prediction or motion compensation, and is also used to output the video signal, i.e., the restored original video signal.

[0053] Furthermore, an embodiment of the present application provides a network architecture of a codec system including an encoder and a decoder. FIG. 5 shows a schematic diagram of the network architecture of the codec system according to an embodiment of the present application. As shown in FIG. 5, the network architecture includes one or more electronic devices 13 to 1N and a communication network 01, through which the electronic devices 13 to 1N can perform video interaction. Depending on the implementation process, the electronic devices may be various types of devices with video codec functions, including, but not limited to, smartphones, tablets, personal computers, personal digital assistants, navigators, digital telephones, video telephones, televisions, sensor devices, servers, etc. Note that the decoders and encoders described in the embodiments of the present application may be the electronic devices described above.

[0054] Note that the method of the embodiment of the present application is mainly applied to the part of the intra prediction unit 103 shown in Fig. 4A and the part of the intra prediction unit 203 shown in Fig. 4B. That is, the embodiment of the present application is applicable to both the encoder and the decoder, and can also be applied to both the encoder and the decoder, but the embodiment of the present application is not particularly limited.

[0055] Note that, when applied to the intra prediction unit 103, the term "current block" refers to the coded block that is the current target of intra prediction, and when applied to the intra prediction unit 203, it refers to the decoded block that is the current target of intra prediction. In the first item, a decoding method applied to a decoder includes the steps of: determining a first template for a current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a predicted value of the current block based on the filtered reference block; and determining a reconstructed value of the current block based on the predicted value of the current block. In the second item, the step of determining a first template for a current block includes the steps of determining a template type of the current block and determining a first template for the current block based on the template type of the current block. In the third item, the step of determining a template type of the current block includes a step of determining a template type of the current block based on reference pixels of the current block, and the reference pixels of the current block include at least one of a reference pixel to the left of the current block, a reference pixel to the upper neighbor of the current block, a reference pixel to the upper left of the current block, a reference pixel to the lower left of the current block, and a reference pixel to the upper right of the current block. In the fourth item, the step of determining the template type of the current block includes a step of determining the template type of the current block to a first value if the reference pixel to the left of the current block, the reference pixel to the upper neighbor of the current block, and the reference pixel to the upper left of the current block are all available; a step of determining the template type of the current block to a second value if the reference pixel to the left of the current block is available; and a step of determining the template type of the current block to a third value if the reference pixel to the upper neighbor of the current block is available; Item 3. The method according to item 3, comprising: determining the template type of the current block to a fourth value if both a reference pixel to the left of the current block and a reference pixel to the upper left of the current block are available; determining the template type of the current block to a fifth value if both a reference pixel to the left of the current block and a reference pixel to the lower left of the current block are available; and determining the template type of the current block to a sixth value if both a reference pixel to the upper right of the current block and a reference pixel to the upper right of the current block are available. In item 5, the step of determining a matching template and a reference block includes a step of performing template matching within a predetermined search area based on the first template to determine the matching template, and a step of determining the reference block based on the matching template. This is the method described in item 1. In item 6, the step of performing template matching within a predetermined search area based on the first template to determine the matching template includes the steps of performing a search within the predetermined search area based on the first template to determine a target block vector, and determining the matching template based on the target block vector. In item 7, the method described in item 1, wherein the step of determining a matching template and a reference block includes the steps of decoding a code stream to determine motion parameters, determining the reference block based on the motion parameters, and determining the matching template based on the first template and the reference block. Item 8: The method according to Item 6, wherein the step of determining a target block vector by performing a search within the predetermined search area based on the first template includes the step of performing a first search within the predetermined search area to determine the target block vector, or the step of performing a second search within the predetermined search area to determine the target block vector, wherein a search step size corresponding to the first search is larger than a search step size corresponding to the second search. Item 9. The method of item 6, wherein the step of performing a search within the predetermined search area based on the first template to determine a target block vector includes the steps of performing a first search within the predetermined search area to determine a first block vector and determining an initial matching template based on the first block vector, and determining a first search area based on the initial matching template and performing a second search within the first search area to determine the target block vector, wherein a search step size corresponding to the first search is larger than a search step size corresponding to the second search, and the first search area is smaller than the predetermined search area. In item 10, the predetermined search area includes at least one sub-search area, and the step of performing a search within the predetermined search area based on the first template to determine a target block vector includes the steps of performing a search within each of the at least one sub-search area to determine an optimal block vector and a corresponding matching cost value for each of the sub-search areas, determining an optimal block vector corresponding to a minimum matching cost value based on the optimal block vector and the corresponding matching cost value for each of the sub-search areas, and setting the optimal block vector corresponding to the minimum matching cost value as the target block vector. In an eleventh item, the step of performing a search within the predetermined search area based on the first template to determine a target block vector includes the steps of: performing a first search within each of the at least one sub-search area to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; performing area determination based on the optimal block vector for each of the sub-search areas and the corresponding second search area to determine at least two target sub-search areas involved in a second search; performing a second search within the at least two target sub-search areas to determine optimal block vectors corresponding to the at least two target sub-search areas; and setting the optimal block vectors corresponding to the at least two target sub-search areas as the target block vectors. In a twelfth item, the method according to the first item, wherein the step of determining model parameters based on the first template and the matching template includes a step in which the model parameters include coefficients of a target filter. Item 13. The method according to item 12, further comprising determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template. In a fourteenth item, the method according to the thirteenth item further includes a step in which the coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after processing by the target filter and a pixel reference value in the first template satisfies a first condition. Item 15. The method according to item 14, further comprising the step of: the first condition being that the first error is minimum. Item 16. The method according to item 14, further comprising the step of: the first condition being that the first error is within a first predetermined threshold range. In item 17, the method according to item 14 further includes a step in which the first condition is that the amount of change in the first error is within a second predetermined threshold range. In item 18, the method according to item 13, wherein the step of determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template includes the steps of determining autocorrelation parameters based on pixel reference values ​​in the matching template, determining cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template, and determining coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters. In a 19th item, the pixel reference value includes at least one of a pixel reconstruction value, a pixel gradient value, and pixel position information. In item 20, the method according to item 12, wherein the number of coefficients of the target filter is equal to a first predetermined value. Item 21. The method according to item 12, further comprising the step of decoding the codestream to determine the number of coefficients of the target filter. In a twenty-second item, the target filter is a one-dimensional or two-dimensional filter of a predetermined shape. Item 23. The method according to item 12, further comprising the step of decoding a codestream to determine the shape of the target filter. In item 24, the method described in item 12, wherein the step of performing a filtering process on the reference block based on the model parameters to determine a filtered reference block includes the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter, and the step of determining the filtered reference block based on the first output value of the target filter. In item 25, the method described in item 24, wherein the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes the steps of: calculating the product of a pixel reconstruction value of the reference block and a corresponding coefficient of the target filter; and setting the first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer. In item 26, the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes the steps of determining a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block, calculating a product of the first value and a corresponding coefficient of the target filter, and setting the first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer. In item 27, the method described in item 24, wherein the step of determining the filtered reference block based on a first output value of the target filter includes the step of determining a first offset value, and the step of performing an addition operation based on the first output value and the first offset value to determine the filtered reference block. Item 28. The method according to item 27, wherein determining a first offset value includes setting the first offset value equal to a second predetermined value. In item 29, the method described in item 27, wherein the step of determining a first offset value includes, when the number of coefficients of the target filter is n, a step of determining the n+1th coefficient of the target filter, and a step of determining the first offset value based on the n+1th coefficient and the second offset value. In item 30, the method described in item 29 further includes a step of setting the second offset value equal to a third predetermined value, and a step of setting the second offset value equal to a value in a second mapping relationship of pixel reconstruction values ​​of the reference block. In item 31, the step of determining a predicted value of the current block based on the filtered reference block includes a step of performing a first process on the filtered reference block to obtain a predicted value of the current block. In item 32, the method according to item 31, further comprising the step of setting a predicted value of the current block equal to the filtered reference block. In item 33, the method according to item 31, wherein the first processing further includes a step of a clip operation that limits the filtered reference block to within a predetermined numerical range. In item 34, the method described in item 1 further includes the steps of determining multiple sets of model parameters based on the first template and the matching template, constructing multiple filter models based on the multiple sets of model parameters, and performing filtering processes on the reference block based on the multiple filter models to determine multiple filtered reference blocks, and determining a predicted value of the current block based on the multiple filtered reference blocks. In item 35, the step of determining a predicted value of the current block based on the plurality of filtered reference blocks includes a step of performing a weighting calculation on the plurality of filtered reference blocks to determine a predicted value of the current block. In item 36, the method according to item 34 further includes the steps of: decoding a codestream to determine an index value of a target model; determining a corresponding target filter from the plurality of filter models based on the index value of the target model; and performing a filtering process on the reference block based on the target filter to determine a predicted value of the current block. In item 37, the step of determining multiple sets of model parameters based on the first template and the matching template includes the steps of classifying reconstructed pixels in the first template and the matching template according to a predetermined method, respectively, to obtain multiple sets of sub-templates and multiple sets of sub-matching templates, and determining the multiple sets of model parameters based on the multiple sets of sub-templates and the multiple sets of sub-matching templates. In item 38, the method according to item 1 further includes the steps of: decoding a codestream to determine a value of a first syntax element identification information; decoding the codestream to determine a value of a second syntax element identification information if the first syntax element identification information indicates that intra template matching is applied to the current block; performing a filtering operation on the reference block based on the model parameters to determine a filtered reference block; and determining a predicted value of the current block based on the filtered reference block if the second syntax element identification information indicates that a filter model is applied to the current block. In item 39, the method described in item 38 further includes a step of using reconstructed pixel values ​​in the reference block as predicted values ​​of the current block when the second syntax element identification information indicates that a filter model is not applied to the current block. In item 40, the method according to any one of items 1 to 39, wherein the step of determining a reconstructed value of the current block based on a predicted value of the current block includes the steps of: decoding a code stream to determine a prediction residual of the current block; and determining a reconstructed value of the current block based on the predicted value of the current block and the prediction residual of the current block. In item 41, an encoding method applied to an encoder includes the steps of determining a first template for a current block, determining a matching template and a reference block, determining model parameters based on the first template and the matching template, performing a filtering process on the reference block based on the model parameters to determine a filtered reference block, determining a predicted value of the current block based on the filtered reference block, and determining a prediction difference of the current block based on the predicted value of the current block. In item 42, the method described in item 41, wherein the step of determining a first template for the current block includes the step of determining a template type of the current block, and the step of determining a first template for the current block based on the template type of the current block. In item 43, the step of determining a template type of the current block includes a step of determining a template type of the current block based on reference pixels of the current block, and the reference pixels of the current block include at least one of a reference pixel to the left of the current block, a reference pixel to the upper neighbor of the current block, a reference pixel to the upper left of the current block, a reference pixel to the lower left of the current block, and a reference pixel to the upper right of the current block. In item 44, the step of determining the template type of the current block includes a step of determining the template type of the current block to a first value if the reference pixel to the left of the current block, the reference pixel to the upper neighbor of the current block, and the reference pixel to the upper left of the current block are all available; a step of determining the template type of the current block to a second value if the reference pixel to the left of the current block is available; and a step of determining the template type of the current block to a third value if the reference pixel to the upper neighbor of the current block is available; Item 44. The method according to item 43, comprising the steps of: determining the template type of the current block to a fourth value if both the reference pixel to the left of the current block and the reference pixel to the upper left of the current block are available; determining the template type of the current block to a fifth value if both the reference pixel to the left of the current block and the reference pixel to the lower left of the current block are available; and determining the template type of the current block to a sixth value if both the reference pixel to the upper right of the current block and the reference pixel to the upper right of the current block are available. In item 45, the step of determining a matching template and a reference block includes a step of performing template matching within a predetermined search area based on the first template to determine the matching template, and a step of determining the reference block based on the matching template, as described in item 41. In item 46, the step of performing template matching within a predetermined search area based on the first template to determine the matching template includes the step of performing a search within the predetermined search area based on the first template to determine a target block vector, and determining the matching template based on the target block vector. In item 47, the step of determining a matching template and a reference block includes a step of determining motion parameters and a corresponding reference block, and a step of determining the matching template based on the first template and the reference block, and accordingly, the method further includes a step of encoding the motion parameters and writing the resulting encoded bits into a code stream. Item 48: The method according to Item 46, wherein the step of determining a target block vector by performing a search within the predetermined search area based on the first template includes the step of performing a first search within the predetermined search area to determine the target block vector, or the step of performing a second search within the predetermined search area to determine the target block vector, wherein a search step size corresponding to the first search is larger than a search step size corresponding to the second search. In item 49, the step of performing a search within the predetermined search area based on the first template to determine a target block vector includes the steps of performing a first search within the predetermined search area to determine a first block vector and determining an initial matching template based on the first block vector, and determining a first search area based on the initial matching template and performing a second search within the first search area to determine the target block vector, wherein a search step size corresponding to the first search is larger than a search step size corresponding to the second search, and the first search area is smaller than the predetermined search area. In item 50, the predetermined search area includes at least one sub-search area, and the step of performing a search within the predetermined search area based on the first template to determine a target block vector includes the steps of performing a search within each of the at least one sub-search area to determine an optimal block vector and a corresponding matching cost value for each of the sub-search areas, determining an optimal block vector corresponding to a minimum matching cost value based on the optimal block vector and the corresponding matching cost value for each of the sub-search areas, and setting the optimal block vector corresponding to the minimum matching cost value as the target block vector. In item 51, the step of performing a search within the specified search area based on the first template to determine a target block vector includes the steps of performing a first search within each of the at least one sub-search area to determine an optimal block vector for each of the sub-search areas and a corresponding second search area, performing area determination based on the optimal block vector for each of the sub-search areas and the corresponding second search area to determine at least two target sub-search areas involved in the second search, performing a second search within the at least two target sub-search areas to determine optimal block vectors corresponding to the at least two target sub-search areas, and setting the optimal block vectors corresponding to the at least two target sub-search areas as the target block vectors. In item 52, the method described in item 41, wherein the step of determining model parameters based on the first template and the matching template includes a step in which the model parameters include coefficients of a target filter. Item 53. The method of item 52, further comprising determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template. In item 54, the method described in item 53 further includes a step in which the coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after processing by the target filter and a pixel reference value in the first template satisfies a first condition. In item 55, the method according to item 54 further comprises a step in which the first condition is that the first error is minimum. Item 56. The method according to item 54, further comprising the step of: the first condition being that the first error is within a first predetermined threshold range. In item 57, the method according to item 54 further includes a step in which the first condition is that the amount of change in the first error is within a second predetermined threshold range. In item 58, the step of determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template includes: Item 53. The method of item 53, comprising the steps of: determining autocorrelation parameters based on pixel reference values ​​in the matching template; determining cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; and determining coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters. In item 59, the pixel reference value includes at least one of a pixel reconstruction value, a pixel gradient value, and pixel position information. In item 60, the number of coefficients of the target filter is equal to a first predetermined value. In item 61, the method described in item 52 further includes the steps of determining the number of coefficients of the target filter, and encoding the number of coefficients of the target filter and writing the resulting encoded bits into a codestream. In item 62, the method according to item 52, wherein the target filter is a one-dimensional or two-dimensional filter of a predetermined shape. Item 63. The method of item 52, further comprising the steps of determining the shape of the target filter, encoding the shape of the target filter, and writing the resulting encoded bits into a codestream. In item 64, the method described in item 52, wherein the step of performing a filtering process on the reference block based on the model parameters to determine a filtered reference block includes the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter, and the step of determining the filtered reference block based on the first output value of the target filter. Item 65: The method described in Item 64, wherein the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes the steps of: calculating the product of a pixel reconstruction value of the reference block and a corresponding coefficient of the target filter; and setting the first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer. In item 66, the method described in item 64, wherein the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes the steps of determining a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block, calculating the product of the first value and a corresponding coefficient of the target filter, and setting the first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer. In item 67, the method described in item 64, wherein the step of determining the filtered reference block based on a first output value of the target filter includes the step of determining a first offset value, and the step of performing an addition operation based on the first output value and the first offset value to determine the filtered reference block. Item 68. The method according to item 67, wherein determining a first offset value includes setting the first offset value equal to a second predetermined value. In item 69, the method described in item 67, wherein the step of determining a first offset value includes a step of determining the n+1th coefficient of the target filter when the number of coefficients of the target filter is n, and a step of determining the first offset value based on the n+1th coefficient and the second offset value. In item 70, the method described in item 69 includes a step of setting the second offset value equal to a third predetermined value, or a step of setting the second offset value equal to a value in a second mapping relationship of pixel reconstruction values ​​of the reference block. In item 71, the step of determining a predicted value of the current block based on the filtered reference block includes a step of performing a first process on the filtered reference block to obtain a predicted value of the current block. In item 72, the method according to item 71, further comprising the step of setting a predicted value of the current block equal to the filtered reference block. In item 73, the method described in item 71 further includes a step in which the first processing is a clip operation that limits the filtered reference block to within a predetermined numerical range. In item 74, the method described in item 41 further includes the steps of determining multiple sets of model parameters based on the first template and the matching template, constructing multiple filter models based on the multiple sets of model parameters, and performing filtering processes on the reference block based on the multiple filter models to determine multiple filtered reference blocks, and determining a predicted value of the current block based on the multiple filtered reference blocks. In item 75, the step of determining a predicted value of the current block based on the plurality of filtered reference blocks includes a step of performing a weighting calculation on the plurality of filtered reference blocks to determine a predicted value of the current block. In item 76, the method described in item 74 further includes a step of determining a target filter from a plurality of filter models, and a step of performing a filtering process on the reference block based on the target filter to determine a predicted value of the current block. Item 77. The method of item 76, further comprising the steps of: determining a target model index value for indicating an index number of the target filter in the plurality of filter models; and encoding the target model index value and writing the resulting encoded bits into a codestream. In item 78, the step of determining a target filter from a plurality of filter models includes the steps of: determining original values ​​of the current block; performing rate-distortion cost calculations based on the original values ​​of the current block and a plurality of initial predicted values ​​of the current block to determine rate-distortion cost values ​​for each of the plurality of initial predicted values; determining a minimum rate-distortion cost value from the rate-distortion cost values ​​for each of the plurality of initial predicted values; and setting the filter model corresponding to the minimum rate-distortion cost value as the target filter. In item 79, the step of determining multiple sets of model parameters based on the first template and the matching template includes the steps of classifying reconstructed pixels in the first template and the matching template according to a predetermined method, respectively, to obtain multiple sets of sub-templates and multiple sets of sub-matching templates, and determining the multiple sets of model parameters based on the multiple sets of sub-templates and the multiple sets of sub-matching templates. In item 80, the method described in item 41 further includes the steps of determining a value of a first syntax element identification information to indicate whether intra template matching is applied to the current block, and encoding the value of the first syntax element identification information and writing the resulting encoded bits into a codestream. In item 81, the step of determining the value of a first syntax element identification information includes a step of determining the value of the first syntax element identification information to a first value if intra template matching is applied to the current block, and a step of determining the value of the first syntax element identification information to a second value if intra template matching is not applied to the current block. In item 82, the method according to item 80, wherein if the first syntax element identification information indicates that intra template matching is applied to the current block, the method further includes the steps of determining a value of a second syntax element identification information to indicate whether a filter model is applied to the current block or not, and encoding the value of the second syntax element identification information and writing the resulting encoded bits into a codestream. In item 83, the step of determining the value of a second syntax element identification information includes a step of determining the value of the second syntax element identification information to a first value if a filter model is applied to the current block, and a step of determining the value of the second syntax element identification information to a second value if a filter model is not applied to the current block. In item 84, the method according to item 82 further includes a step of performing a filtering process on the reference block based on the model parameters to determine a filtered reference block, and a step of determining a predicted value of the current block based on the filtered reference block, when a filter model is applied to the current block; and a step of using reconstructed pixel values ​​in the reference block as the predicted value of the current block when a filter model is not applied to the current block. In item 85, the method according to any one of items 41 to 84, wherein the step of determining a prediction difference of the current block based on a predicted value of the current block includes a step of determining an original value of the current block, and a step of determining a prediction difference of the current block based on the original value of the current block and the predicted value of the current block. In item 86, a codestream is generated by performing bit encoding based on encoding target information, wherein the encoding target information includes at least one of a prediction difference of a current block, the number of coefficients of a target filter, the shape of the target filter, a value of a first syntax element identification information, and a value of a second syntax element identification information, wherein the first syntax element identification information is used to indicate whether intra template matching is applied to the current block, and the second syntax element identification information is used to indicate whether a filter model is applied to the current block. In item 87, an encoder includes: a first determination unit configured to determine a first template for a current block, determine a matching template and a reference block, and further configured to determine model parameters based on the first template and the matching template; a first filtering unit configured to perform a filtering process on the reference block based on the model parameters to determine a filtered reference block; and a first prediction unit configured to determine a predicted value of the current block based on the filtered reference block, wherein the first determination unit is further configured to determine a prediction difference of the current block based on the predicted value of the current block. In item 88, an encoder includes a first memory and a first processor, wherein the first memory is for storing a computer program executable on the first processor, and the first processor, when executing the computer program, is for executing a method described in any one of items 41 to 85. In item 89, the decoder includes: a second determination unit configured to determine a first template for a current block, determine a matching template and a reference block, and further configured to determine model parameters based on the first template and the matching template; a second filtering unit configured to perform a filtering process on the reference block based on the model parameters to determine a filtered reference block; and a second prediction unit configured to determine a predicted value of the current block based on the filtered reference block, wherein the second determination unit is further configured to determine a reconstructed value of the current block based on the predicted value of the current block. In item 90, a decoder including a second memory and a second processor, wherein the second memory is for storing a computer program executable on the second processor, and the second processor, when executing the computer program, is for executing a method described in any one of items 1 to 40. In item 91, a computer-readable storage medium stores a computer program that, when executed, realizes the method according to any one of items 1 to 40 or the method according to any one of items 41 to 85.

[0056] In an embodiment of the present application, referring to Figure 6, a flowchart of a decoding method according to an embodiment of the present application is shown. As shown in Figure 6, the method may include the following steps:

[0057] S601: Determine the first template of the current block, and determine the matching template and the reference block.

[0058] It should be noted that the decoding method according to the embodiments of the present application is applied to a decoder. Specifically, the decoding method may refer to an intra prediction method, more specifically, an intra prediction method based on an intra template matching technique (Intra Template Matching Prediction based on Filter-based Linear Model, Intra TMP-FLM). Here, a video image may be divided into multiple decoding blocks, and the current block in the embodiments of the present application refers to the decoding block that is currently the target of intra prediction in the video image. The decoding method according to the embodiments of the present application may be applied to both luminance component prediction and chrominance component prediction, and is not particularly limited.

[0059] It should be noted that in the embodiments of the present application, a first template of the current block is first determined, so that the matching template and the reference block can be determined based on the first template. In some embodiments, the step of determining the first template of the current block includes: determining the template type of the current block; determining a first template for the current block based on the template type of the current block.

[0060] Here, the template type may be represented by refTemplateType. In some embodiments, determining the template type of the current block may include determining the template type of the current block based on reference pixels of the current block.

[0061] Here, the reference pixels of the current block include at least one of the reference pixel to the left of the current block, the reference pixel to the upper side of the current block, the reference pixel to the upper left of the current block, the reference pixel to the lower left of the current block, and the reference pixel to the upper right of the current block.

[0062] That is, in the embodiment of the present application, the reference pixels of the current block are determined based on the neighboring reconstructed regions of the current block, where the neighboring reconstructed regions of the current block include at least one of a left neighboring region, an upper neighboring region, an upper-left neighboring region, a lower-left neighboring region, and an upper-right neighboring region. For example, the left neighboring reference pixels of the current block may be determined by at least one column of reconstructed pixels in the left neighboring region, the upper neighboring reference pixels of the current block may be determined by at least one row of reconstructed pixels in the upper neighboring region, and the lower-left neighboring reference pixels of the current block may be determined by at least one column of reconstructed pixels in the lower-left neighboring region.

[0063] Furthermore, the template type may be classified based on the availability of neighboring reference pixels, and the template type of the current block may be determined. In some embodiments, the step of determining the template type of the current block includes: determining the template type of the current block to be a first value if the reference pixel to the left of the current block, the reference pixel to the upper neighbor of the current block, and the reference pixel to the upper left of the current block are all available; If the reference pixel to the left of the current block is available, determining the template type of the current block to a second value; If the reference pixel of the upper neighbor of the current block is available, determining the template type of the current block to be a third value; determining the template type of the current block to be a fourth value if both the left neighbor reference pixel of the current block and the upper left neighbor reference pixel of the current block are available; determining the template type of the current block to be a fifth value if both the left neighbor reference pixel of the current block and the lower left neighbor reference pixel of the current block are available; If both the reference pixel above the current block and the reference pixel to the upper right of the current block are available, determining the template type of the current block to be a sixth value.

[0064] In the embodiment of the present application, the first value, the second value, the third value, the fourth value, the fifth value, and the sixth value may be different. For example, the first value may be set to 1, the second value to 2, the third value to 3, the fourth value to 4, the fifth value to 5, and the sixth value to 6. For details of these six template types, see (a), (b), (c), (d), (e), and (f) in Figure 3.

[0065] In some embodiments, determining the first template for the current block based on the template type of the current block may include obtaining template pixels for the current block based on the template type of the current block and a corresponding template size, and determining the template pixels of the current block as the first template for the current block.

[0066] In the embodiment of the present application, the size of the template may be preset, may be determined based on the size of the current block, and may further be related to the template type of the current block, and is not particularly limited here.

[0067] For example, if the template type indicates that only the left template is to be acquired, the template width templateW_size may be set to 4, and if the template type indicates that only the top template is to be acquired, the template height templateH_size may be set to 4.

[0068] Also, it is possible to determine which portion of reconstructed pixels the first template will acquire based on the value of the template type. For example, if the value of refTemplateType is 1, reconstructed pixels on the left, upper left, and upper sides of the current block are acquired; if the value of refTemplateType is 2, only reconstructed pixels in the four columns on the left side of the current block are acquired; and if the value of refTemplateType is 3, only reconstructed pixels in the four rows on the top side of the current block are acquired.

[0069] For the matching template and reference block, in a possible embodiment, the step of determining the matching template and reference block may include the steps of decoding the codestream to determine motion parameters, determining the reference block based on the motion parameters, and determining the matching template based on the first template and the reference block.

[0070] That is, a reference block for the current block can be determined based on the motion parameters (e.g., BV) obtained by decoding the codestream, and a matching template can be determined by the reference block based on the first template for the current block.

[0071] Regarding the matching template and the reference block, in another possible embodiment, the step of determining the matching template and the reference block may include the step of performing template matching within a predetermined search area based on the first template to determine the matching template, and the step of determining the reference block based on the matching template.

[0072] In some embodiments, the step of performing template matching within a predetermined search area based on the first template to determine a matching template may include the steps of performing a search within a predetermined search area based on the first template to determine a target block vector, and determining a matching template based on the target block vector.

[0073] That is, a search can be performed within a predetermined search area based on the first template, and a matching template with the minimum cost can be found based on a predetermined cost function. Here, all search points within the predetermined search area can be scanned to obtain one or more candidate block vectors, which can represent one or more candidate matching templates. A cost calculation is performed on each of these search points with the first template of the current block to obtain the search point with the minimum cost through comparison, and the corresponding candidate block vector is the optimal block vector (i.e., the target block vector, BV_BEST). The corresponding candidate matching template is the optimal matching template (i.e., the matching template, T_BEST, described in this embodiment). The reference block can be determined based on the optimal matching template.

[0074] In the embodiments of the present application, the predetermined cost function may be the sum of absolute differences SAD, the sum of absolute differences after transformation SATD, the mean squared error MSE, the sum of squared differences SSD, the mean absolute deviation MAD, the mean squared difference MSD, the normalized correlation coefficient NCC, etc., and is not particularly limited here.

[0075] The search process within the predetermined search region may be a coarse search or a fine search, or the coarse search may be performed first and the fine search may be performed later.

[0076] In one possible embodiment, the step of performing a search within a predetermined search area based on the first template to determine a target block vector may include performing a first search within the predetermined search area to determine a target block vector.

[0077] In another possible embodiment, the step of performing a search within a predetermined search area based on the first template to determine the target block vector may include the step of performing a second search within the predetermined search area to determine the target block vector.

[0078] In yet another possible embodiment, the step of performing a search within a predetermined search area based on the first template to determine a target block vector may include the steps of performing a first search within the predetermined search area to determine a first block vector and determining an initial matching template based on the first block vector, and determining a first search area based on the initial matching template and performing a second search within the first search area to determine a target block vector.

[0079] In the embodiment of the present application, the search step size corresponding to the first search is larger than the search step size corresponding to the second search. For example, the search step size corresponding to the first search is 2, and the search step size corresponding to the second search is 1. Alternatively, the downsampling factor corresponding to the first search is larger than the downsampling factor corresponding to the second search. For example, the downsampling factor corresponding to the first search is 4, and the downsampling factor corresponding to the second search is 2. In other words, the first search is a coarse search, the second search is a fine search, and the downsampling factor is not particularly limited as long as it can reflect the characteristics that the first search is coarser than the second search.

[0080] When the first search is performed before the second search, not only is the search step size for the first search larger than the search step size for the second search, but the first search area is smaller than the predetermined search area. Here, the first search area is a search area near the initial matching template. For example, the step size can be set to 2 to determine an optimal coarse matching template in the predetermined search area, and the step size can be set to 1 to determine an optimal fine matching template (i.e., the final matching template) near the optimal coarse matching template.

[0081] In yet another possible embodiment, the predetermined search area may include at least one sub-search area, and the step of searching within the predetermined search area based on the first template to determine the target block vector may include: performing a search within each of at least one sub-search area to determine an optimal block vector and corresponding matching cost value for each of the sub-search areas; determining an optimal block vector corresponding to a minimum matching cost value based on the optimal block vectors and corresponding matching cost values ​​of each of the sub-search regions; and determining the optimal block vector corresponding to the minimum matching cost value as the target block vector.

[0082] In the embodiment of the present application, the search area of ​​the current block template may be the CTB-reconstructed part where the current block is located, or may be another reconstructed CTB area. The search area here is actually the set of all search points. Because the shape of this area often cannot be represented by a single rectangular area, in specific implementation, multiple rectangular areas are searched, and the search results of different areas are combined to obtain the final optimal reference block and optimal block vector.

[0083] Referring to FIG. 7, a schematic diagram of different sub-region divisions of the search area according to an embodiment of the present application is shown. As shown in FIG. 7, eight different sub-region division methods are shown. Here, the background block filled in black is the current block. Five division methods (a), (b), (c), (d), and (f) all divide the search area into four sub-search areas, while three division methods (e), (g), and (h) all divide the search area into three sub-search areas, with different fill patterns representing one sub-search area. Here, in FIG. 7, (a), (b), (c), and (d) consider all available search ranges, while (e), (f), (g), and (h) do not search the areas directly above or to the left.

[0084] Taking (f) of FIG. 7 as an example, the predetermined search area is divided into four sub-search areas, each of which is represented by regionId, where the value of regionId can be equal to 0, 1, 2, or 3. Using the search point (iPosHor, iPoxVer) in each sub-search area, i.e., each block vector BV (consisting of horizontal and vertical components: (pX, pY), where pX = iPosHor-xTbCmp, pY = iPosVer-yTbCmp, where pX is between bvXMins and bvXMaxs, and pY is between bvYMins and bvYMaxs), a reference block matching the current block is found in the reconstructed area, and the adjacent reconstructed pixels of the reference block are the matching template. Therefore, the matching cost between the first template of the current block and the matching template can be calculated, which can be denoted as pDiff.

[0085] In this way, all search points in all search ranges (regionId=0,1,2,3) are scanned, and the search point with the smallest matching cost pDiff is obtained by comparison. The corresponding matching cost is denoted as pDiff_BEST, and the corresponding block vector is denoted as the optimal block vector BV_BEST(pX_BEST, pY_BEST) (i.e., the target block vector described in this embodiment). The corresponding optimal matching template T_BEST is the finally required matching template.

[0086] S602: Determine model parameters based on the first template and the matching template.

[0087] In some embodiments, the model parameters may include coefficients of a target filter. In some embodiments, the method may further include determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template.

[0088] In some embodiments, the coefficients of the target filter may be determined by solving an optimization problem. Therefore, in some embodiments, the method may further include a step in which the coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after processing by the target filter and a pixel reference value in the first template satisfies a first condition.

[0089] It should be understood that when the first error satisfies the first condition, in one possible embodiment, the first condition is that the first error is minimal, or in another possible embodiment, the first condition is that the first error is within a first predetermined threshold range, or in yet another possible embodiment, the first condition is that the change in the first error is within a second predetermined threshold range.

[0090] It should also be understood that the first predetermined threshold range and the second predetermined threshold range are both measures set in advance by the decoding side for determining whether the first error satisfies the first condition. The first error here may be a mean square error (MSE), a sum of square errors (SSE), a sum of absolute differences (SAD), a sum of absolute differences after Hadamard transform (SATD), or a mean absolute error (MAE).

[0091] In some embodiments, determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template comprises: determining autocorrelation parameters based on pixel reference values ​​in the matching template; determining cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; and determining coefficients of the target filter based on the autocorrelation and cross-correlation parameters.

[0092] It should be noted that in the embodiment of the present application, the pixel reference values ​​include at least one of pixel reconstruction values, pixel gradient values, and pixel position information.

[0093] JPEG2026502383000098.jpg78167

[0094] In a specific embodiment, a reconstruction region R for calculating filter coefficients is first determined, and then a set of filter coefficients is derived by minimizing the MSE between the reconstructed pixels in region R and the reconstructed pixels of the first template.

number

number

[0095] Furthermore, the process of deriving the filter coefficients by minimizing the MSE is as follows:

[0096] JPEG2026502383000103.jpg872

number

number

[0097] Next, rearranging equations (5) and (6), we get

number

[0098] Next, after determining the reconstruction region R, the obtained equation (7) is expanded into a matrix form as follows:

number

[0099] Here, in A, the pixel reference value in the matching template is represented by refTemp[i][j], and A represents the autocorrelation parameter of refTemp[i][j], specifically as follows:

number

[0100] In B, the pixel reference value in the first template is represented by recTemp[i][j], and B represents the cross-correlation parameter of recTemp[i][j] and refTemp[i][j], specifically as follows:

number

[0101] JPEG2026502383000111.jpg32167

[0102] In the embodiment of the present application, it is further necessary to determine the number of coefficients of the target filter, the shape of the target filter, etc. Here, the number of coefficients of the target filter and the shape of the target filter may be preset fixed values, or may be directly determined by decoding the codestream.

[0103] In some embodiments, with respect to the number of coefficients of the target filter, the method may further include the step of the number of coefficients of the target filter being equal to a first predetermined value.

[0104] In some embodiments, with respect to the number of coefficients of the target filter, the method may further include decoding the codestream to determine the number of coefficients of the target filter.

[0105] The number of coefficients of the target filter can be represented by nTap. For example, the value of nTap may be 4, 5, 6, 7, 8, 9, etc., but is not particularly limited.

[0106] The number of coefficients of the target filter is also called the number of target filter taps, and may be a predetermined constant value, may be determined by decoding the codestream, or may be determined from the syntax element identification information of the current block.

[0107] In some embodiments, with respect to the shape of the target filter, the method may further include the target filter being a one-dimensional or two-dimensional filter of a predetermined shape.

[0108] In some embodiments, with respect to the shape of the target filter, the method may further include decoding the codestream to determine the shape of the target filter.

[0109] In some embodiments, with respect to the shape of the target filter, the method may further include decoding the codestream to determine values ​​of filter shape parameters, where the filter shape parameters indicate the shape of the target filter.

[0110] The filter shape parameter can be expressed by FilterIdx, which indicates the shape of the target filter. For example, the shape of the target filter may be a diamond, a rectangle, a cross, a bar, or may be a one-dimensional filter, a two-dimensional filter, or the like, but is not particularly limited thereto.

[0111] As an example, if the value of FilterIdx is equal to 0, the shape of the target filter is determined to be a diamond, if the value of FilterIdx is equal to 1, the shape of the target filter is determined to be a cross, and if the value of FilterIdx is equal to 2, the shape of the target filter is determined to be a rectangle.

[0112] The shape of the target filter may be a predetermined shape, may be determined by decoding the codestream, or may be determined from the syntax element identification information of the current block.

[0113] S603: Based on the model parameters, a filtering process is performed on the reference block to determine a filtered reference block.

[0114] S604: Determine a prediction value for the current block based on the filtered reference block.

[0115] It should be noted that in the embodiment of the present application, after determining the model parameters, a predicted value of the current block can be determined according to the model parameters and the reference block, specifically, a filtering process is performed on the reference block according to the model parameters, and a predicted value of the current block is determined according to the filtered reference block.

[0116] In some embodiments, performing a filtering process on the reference block based on the model parameters to determine a filtered reference block may include performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter, and determining the filtered reference block based on the first output value of the target filter.

[0117] In an embodiment of the present application, a first output value of the target filter can be calculated based on the pixel reconstruction value of the reference block and the coefficient of the target filter in the model parameters. Then, a filtered reference block can be determined based on the first output value of the target filter. The target filter here can be a linear filtering model or a nonlinear filtering model, and is not particularly limited.

[0118] In one possible embodiment, the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter comprises: calculating the product of pixel reconstruction values ​​of the reference block and the corresponding coefficients of the target filter; Setting a first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer.

[0119] It should be noted that the target filter in the embodiment of the present application is a linear filtering model. The first output value of the target filter can be calculated by the following equation:

number

[0120] In another possible embodiment, the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter comprises: determining a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block; calculating the product of the first value and the corresponding coefficient of the target filter; Setting a first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer.

[0121] In the embodiment of the present application, the target filter is a nonlinear filtering model. For example, when minimizing the MSE of the filter coefficients, the calculation formula is as follows:

number

[0122] Then, the first output value of the target filter is calculated as follows:

number

[0123] In the embodiment of the present application, the step of determining the filtered reference block based on the first output value of the target filter may directly set the first output value of the target filter as the filtered reference block, or may perform first filtering on the first output value of the target filter to obtain the filtered reference block. The first filtering here may be, but is not limited to, a low-pass filter, an up / down sampling filter, etc.

[0124] In addition, in the embodiment of the present application, after determining the first output value of the target filter, a first offset value (denoted by bias) can also be added to the first output value to determine the filtered reference block.

[0125] In some embodiments, determining the filtered reference block based on the first output value of the target filter may include determining a first offset value, and performing an addition operation based on the first output value and the first offset value to determine the filtered reference block.

[0126] In one possible embodiment, determining the first offset value may include setting the first offset value equal to a second predetermined value.

[0127] In another possible embodiment, the step of determining the first offset value may include a step of determining the n+1-th coefficient of the target filter, where the number of coefficients of the target filter is n, and a step of determining the first offset value based on the n+1-th coefficient and the second offset value.

[0128] In an embodiment of the present application, for the second offset value, the method may further include a step of setting the second offset value equal to a third predetermined value, or a step of setting the second offset value equal to a value in a second mapping relationship of the pixel reconstruction value of the reference block.

[0129] JPEG2026502383000117.jpg45167

number

[0130] In this case, adding a bias term gives the following equation:

number

[0131] JPEG2026502383000120.jpg61166

[0132] Furthermore, in some embodiments, determining a predicted value of the current block based on the filtered reference block may include performing a first process on the filtered reference block to obtain a predicted value of the current block.

[0133] In the embodiments of the present application, referring to the first processing, the first processing may be setting the predicted value of the current block equal to the filtered reference block, or the first processing may be a clip operation that limits the filtered reference block to a predetermined numerical range, or the first processing may be other operations, but are not particularly limited in this specification.

[0134] JPEG2026502383000121.jpg75166

[0135] JPEG2026502383000122.jpg14166

[0136] Furthermore, the number of filter models can be expanded to build not only one filter model but also multiple filter models. determining sets of model parameters based on the first template and the matching template; constructing a plurality of filter models based on the plurality of sets of model parameters, and performing filtering processes on the reference blocks based on the plurality of filter models, respectively, to determine a plurality of filtered reference blocks; determining a prediction value for the current block based on the plurality of filtered reference blocks.

[0137] In some embodiments, the step of determining the multiple sets of model parameters based on the first template and the matching template may include the steps of: classifying the reconstructed pixels in the first template and the matching template according to a predetermined scheme, respectively, to obtain multiple sets of sub-templates and multiple sets of sub-matching templates; and determining the multiple sets of model parameters based on the multiple sets of sub-templates and multiple sets of sub-matching templates.

[0138] In the embodiment of the present application, the predetermined method may be, but is not limited to, the magnitude of the reconstructed pixel value, the position information of the reconstructed pixel, the shape of the filter, etc. After classification according to the predetermined method, each set of sub-templates and the corresponding sub-matching template can calculate a set of model parameters, and each set of model parameters can determine a filter model, thereby constructing multiple filter models.

[0139] In one possible embodiment, the method may further include the steps of decoding the codestream to determine an index value of a target model, determining a corresponding target filter from a plurality of filter models based on the index value of the target model, and performing a filtering process on the reference block based on the target filter to determine a predicted value of the current block.

[0140] In another possible embodiment, multiple filtered reference blocks can be determined by performing respective filtering operations on the reference block based on multiple filter models. In some implementations, determining a prediction value for the current block based on the multiple filtered reference blocks can include performing a weighting calculation on the multiple filtered reference blocks to determine a prediction value for the current block.

[0141] It should be noted that if the weight of each filtered reference block is equal and equal to the reciprocal of the number of reference blocks, the weighting calculation here can also be regarded as an average value calculation, in other words, the average value of multiple filtered reference blocks is calculated to determine the predicted value of the current block.

[0142] For example, input information for calculating filter coefficients is classified, and a filter model is constructed for each type of input information. For example, when constructing a filter model using reconstruction information, one possible embodiment is to classify the reconstruction information according to its average value, and construct one filter model for reconstruction information greater than the average value, and another filter model for reconstruction information less than the average value. Another possible embodiment is to classify the reconstruction information according to its position. For example, one filter model can be constructed using available reconstruction information on the left and upper sides, and another filter model can be constructed using available reconstruction information on the left and upper left sides, and the encoding side determines which model to use. A possible determination method is for the encoding side to determine which model to use using a rate-distortion optimization method, and then transmit corresponding decoding parameters to the decoding side so that the decoding side can clearly select the filter model. Another possible embodiment is to classify according to the filter shape, and use multiple different filter shapes. A filter model can be constructed for each filter shape, and the encoding side determines which filter shape to use. A possible decision scheme is for the encoding side to decide which filter to use by rate-distortion optimization, and then send the corresponding decoding parameters to the decoding side so that the decoding side explicitly selects the filter model.

[0143] S605: Determine a reconstructed value of the current block based on the predicted value of the current block.

[0144] It should be noted that in embodiments of the present application, after the predicted value of the current block is determined, the reconstructed value of the current block may be restored. In some embodiments, determining the reconstructed value of the current block based on the predicted value of the current block may include decoding the codestream to determine a prediction residual of the current block, and determining the reconstructed value of the current block based on the predicted value of the current block and the prediction residual of the current block.

[0145] In one specific embodiment, the step of determining a reconstructed value of the current block based on the predicted value of the current block and the prediction difference of the current block may include the step of adding the predicted value of the current block and the prediction difference of the current block to determine the reconstructed value of the current block.

[0146] It should be noted that in the embodiments of the present application, whether intra template matching is applied to the current block or whether a filter model is applied to the current block may be determined by different syntax element identification information. decoding the codestream to determine a value of a first syntax element identification; if the first syntax element identification indicates that intra template matching is applied to the current block, decoding the codestream to determine a value of a second syntax element identification; The method may further include performing a filtering operation on the reference block based on the model parameters to determine a filtered reference block, and determining a predicted value of the current block based on the filtered reference block, when the second syntax element identification information indicates that a filter model is applied to the current block.

[0147] Furthermore, in some embodiments, the method may further include a step of using reconstructed pixel values ​​in the reference block as predicted values ​​of the current block if the second syntax element identification information indicates that a filter model is not applied to the current block.

[0148] In an embodiment of the present application, for a first syntax element identification information, it is determined that if the value of the first syntax element identification information is a first value, the first syntax element identification information indicates that intra template matching is applied to the current block, or if the value of the first syntax element identification information is a second value, it is determined that the first syntax element identification information indicates that intra template matching is not applied to the current block.

[0149] In an embodiment of the present application, for a second syntax element identification information, it is determined that if the value of the second syntax element identification information is a first value, the second syntax element identification information indicates that a filter model is applied to the current block, or if the value of the second syntax element identification information is a second value, it is determined that the second syntax element identification information indicates that a filter model is not applied to the current block.

[0150] In the embodiment of the present application, the first value and the second value are different, and the first value and the second value may be in a parameter format or a numerical format. Specifically, the first syntax element identification information and the second syntax element identification information may be parameters written in a profile or may be flag values, but are not specifically limited here.

[0151] As an example, for the first value and the second value, the first value may be set to 1 and the second value may be set to 0, or the first value may be set to true and the second value may be set to false, but this is not specifically limited here.

[0152] In the embodiment of the present application, whether the current block uses the filtered reference block as the final predicted value is determined by some conditions, but the conditions are not limited to the following three methods. For example, these three methods can be as follows:

[0153] Method 1: Determine whether to filter the matching template by comparing the distortion between the matching template and the current block template, such as SAD, MSE, SATD, or SSE, with a threshold T_Distortion1.

[0154] Method 2: Assuming that Method 1 satisfies the use of the filter model, then determine whether to filter the reference block by comparing the distortion between the filtered matching template and the current block template, such as SAD or MSE or SATD or SSE, with a threshold T_Distortion2.

[0155] Method 3: The encoding side transmits a Flag indicating whether to apply a filter model. The tmp Flag indicates whether to apply intra-template matching to the current block, and the filter Flag indicates whether to apply a filter model to the current block. If the tmp Flag is 1, the encoding side compares the distortion between the reference block and the current block before and after filtering, such as SAD, MSE, SATD, or SSE, to determine whether to filter the reference block. If the distortion after filtering is smaller than the distortion before filtering, the filter Flag is 1, and the current block uses the filtered reference block as its predicted block; otherwise, the filter Flag is 0, and the current block uses the unfiltered reference block as its predicted block. The encoding side transmits the filter Flag to the decoding side.

[0156] This embodiment provides a decoding method including the steps of: determining a first template for a current block, determining a matching template and a reference block, determining model parameters based on the first template and the matching template, performing a filtering process on the reference block based on the model parameters to determine a filtered reference block, determining a predicted value of the current block based on the filtered reference block, and determining a reconstructed value of the current block based on the predicted value of the current block. In this way, the model parameters are determined based on the first template and the matching template, and the model parameters fully embody the correlation between the matching template and the first template of the current block, and the correlation is applied to the reference block, and filtering correction is performed on its reconstructed pixels, and then the filtered reconstructed pixels are used as the predicted pixels of the current block, thereby improving prediction accuracy, saving bit rate, and improving codec efficiency, and further improving codec performance.

[0157] In another embodiment of the present application, based on the decoding method described in the previous embodiment, it is proposed to correct the best matching reconstructed block (i.e., reference block) in the prediction process of the Intra TMP technology, and the corrected reconstructed pixels are used as the predicted pixels of the current block. Specifically, a linear filtering model is constructed using the matching template and the pixels of the current block template, and this linear filtering model is applied to the reference block, and the filtered pixels are used as the final predicted pixels. The invention related to the embodiment of the present application can be called an intra template matching technology based on a linear filtering model (Intra TMP-FLM).

[0158] The prediction process of the Intra TMP-FLM technique is explained in detail below.

[0159] Input for Intra TMP-FLM technique: current block position (xTbCmp, yTbCmp), current block width nTbW, current predicted block height nTbH. Output of the Intra TMP-FLM technique: predictions of the current block, predSamples[x][y], where x=0..nTbW-1 and y=0..nTbH-1.

[0160] Specifically, the prediction process of the Intra TMP-FLM technique can be divided into five steps: determining the type of the current template, obtaining the reconstructed pixels of the current template, determining a block vector within a predefined search range, constructing a linear filtering model, and generating a predicted value. Note that the Intra TMP-FLM technique may be used to predict either the luminance component or the chrominance component, but is not particularly limited here.

[0161] 8, a prediction flow chart based on the Intra TMP-FLM technique according to an embodiment of the present application is shown. As shown in FIG. 8, the flow may include the following steps:

[0162] S801: Determine the current template type.

[0163] In addition, the Intra TMP-FLM technique searches for a matching template within a predefined search area using neighboring reconstructed pixels of the current block, such as the upper reference pixels, upper left reference pixels, upper right reference pixels, left reference pixels, and lower left reference pixels of the current block, as templates.Therefore, it is possible to classify template types according to the availability of neighboring reconstructed pixels and determine the corresponding template type.

[0164] The template type can be expressed as refTemplateType. As shown in Figure 3, the block filled with mesh is the current block, and the adjacent area of ​​the current block is template T. Here, six types of template types are shown.

[0165] For example, the six template types are shown below: 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 FIG. When only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is as shown in FIG. 3(b). When only the upper reference pixels are available, the value of refTemplateType is 3, and the template shape is as shown in FIG. When only the left and upper left reference pixels are available, the value of refTemplateType is 4, and the template shape is as shown in FIG. When only the left and bottom-left reference pixels are available, the value of refTemplateType is 5, and the template shape is as shown in FIG. When only the upper reference pixels and the upper right reference pixels are available, the value of refTemplateType is 6, and the template shape is as shown in FIG.

[0166] S802: The current template pixel is obtained.

[0167] The template for the Intra TMP-FLM technique can be configured using reconstructed pixels from one or more of the upper, upper right, left, lower left, and upper left regions of the current block. The template size may be preset. For example, the template width (templateW_size) may be set to 4 when acquiring the left template, and the template height (templateH_size) may be set to 4 when acquiring the upper template.

[0168] It is possible to determine which portion of the reconstructed pixels to acquire based on the value of refTemplateType. For example, if the value of refTemplateType is 1, the reconstructed pixels on the left, upper left, and upper sides of the current block are acquired, or if the value of refTemplateType is 2, only the reconstructed pixels on the left four columns of the current block are acquired, or if the value of refTemplateType is 3, only the reconstructed pixels on the top four rows of the current block are acquired.

[0169] S803: Determine a block vector within a predefined search range.

[0170] It should be noted that the search process of the Intra TMP-FLM technique is mainly divided into an initialization process, determining the search area of ​​the template in the current frame, searching in the search area and determining the optimal block vector.

[0171] When searching for the optimal matching template in the search area, a search strategy may be adopted in which a coarse search is performed first followed by a fine search, or only a fine search may be performed, or only a coarse search may be performed; no specific limitations are imposed here.

[0172] In the embodiment of the present application, the coarse search here may specifically be determining an optimal coarse matching template in the search area with a first predetermined step size (e.g., 2), or determining an optimal coarse matching template in the search area using a downsampled template (e.g., the downsampling factor is 2).

[0173] In the embodiment of the present application, the fine search here may specifically be determining an optimal fine matching template in the search area with a second predetermined step size (e.g., 1), or performing a coarse search and then determining an optimal fine matching template in the vicinity of the optimal coarse matching template.

[0174] 9, a search flow chart based on IntraTMP technology according to an embodiment of the present application is shown. As shown in FIG. 9, the flow may include the following steps:

[0175] S901: Initialize parameters.

[0176] Note that uiPatchWidth is initialized to nTbW + templateW_size, and uiPatchHeight is initialized to nTbH + templateH_size. However, templateW_size and templateH_size may be constants or may be dynamically adjusted according to the size of the current block, and templateW_size and templateH_size may or may not be equal. For example, templateW_size=4, templateH_size=4, or if the width of the current block is greater than 8, templateW_size=4, if the width of the current block is 8 or less, templateW_size=2, and if the height of the current block is greater than 8, templateH_size=4. If the height of the current block is 8 or less, templateH_size=2.

[0177] For example, Figure 10 shows a schematic diagram of parameter definitions of a current block and its template according to an embodiment of the present application. As shown in Figure 10, the specific meanings of the parameters are as follows: nTbW and nTbH represent the size of the current block, templateW_size and templateH_size represent the template size, and uiPatchWidth and uiPatchHeight represent the block size including the current block and its template.

[0178] Furthermore, the cost threshold between the initialization templates is represented by diffThreshold. For example, when the cost function is SAD, the threshold diffThreshold=((1<<bitDepth)> >2) × (uiPatchHeight × uiPatchWidth - nTbH × nTbW), where diffThreshold indicates that when the image bit depth bitDepth is 10, the maximum distortion of each pixel point in the template region is 256.

[0179] Furthermore, the positions ctbRsX and ctbRsY of the coding tree block CTB where the current block CB is located are initialized.

[0180] Furthermore, the position offsets of the current block CB in the current CTB are initialized so that offsetLCBY=yTbCmp-ctbRsY and offsetLCBX=xTbCmp-ctbRsX.

[0181] Furthermore, initialization is performed so that iTemplateSizeH=templateH_size and iTemplateSizeW=templateW_size.

[0182] Furthermore, iBvShift, which is the precision of the block vector BV, is initialized. For example, the precision of BV may be integer pixel precision, in which case iBvShift is 0, and the precision of BV may be sub-pixel precision, for example, when iBvShift is 1, it indicates 1 / 2 pixel precision, and when iBvShift is 2, it indicates 1 / 4 pixel precision, but this is not particularly limited here.

[0183] Furthermore, the predetermined search range of the template may be initialized and set to a fixed size, or the search range may be dynamically adjusted depending on the coding block size. For example, searchRangeWidth=TMP_SEARCH_RANGE_MULT_FACTOR×nTbW, searchRangeHeight=TMP_SEARCH_RANGE_MULT_FACTOR×nTbH, where the value of TMP_SEARCH_RANGE_MULT_FACTOR may be set to a predetermined value, for example, 5.

[0184] S902: Determine the search area of ​​the template in the current frame.

[0185] The search area of ​​the IntraTMP technique is the reconstructed portion of the current image and is limited by the size of the search range. As shown in Figure 11, the background area filled with dark colors is the reconstructed area, the background block filled with black colors is the current block, and the dashed frame is the search range window. Therefore, the search area of ​​the IntraTMP technique is no larger than the overlap between the reconstructed area represented by the dark background and the area identified by the dashed frame.

[0186] As can be seen from the above, the search area of ​​the current block template can be the reconstructed part of the CTB where the current block is located, or it can be another reconstructed CTB area. The search area here is actually the set of all search points. Because the shape of this area often cannot be represented by a single rectangular area, in specific implementation, multiple rectangular areas can be searched, and the search results of different areas can be combined to obtain the final best matching block and best block vector.

[0187] For example, using the aforementioned Figure 7 as an example, eight different sub-area division methods are shown here. Here, the background block filled in black is the current block. The five division methods (a), (b), (c), (d), and (f) all divide the search area into four sub-search areas, and the three division methods (e), (g), and (h) all divide the search area into three sub-search areas, where each different fill pattern represents one sub-search area.

[0188] In Figure 7, (a), (b), (c), and (d) consider all available search areas, while (e), (f), (g), and (h) do not search the areas directly above or to the left.

[0189] For example, if different sub-search areas are represented by regionId, the template pixels of the current block need to be obtained in the image reconstruction area, and the reconstruction block pixels corresponding to the template also need to be obtained in the reconstruction area. Therefore, the block vector BV needs to be determined by further determining searchable positions within the sub-search areas represented by different regionIds according to the position of the current block (xTbCmp, yTbCmp), the size of the current block (nTbW, nTbH), the size of the current image (picWidth, picHeight), the size of the CTB where the current block is located (CtbSizeW, CtbSizeH), the predetermined search range of the template (searchRangeWidth, searchRangeHeight), and the position offset of the current block within the current CTB (offsetLCBY, offsetLCBX). Specifically, the absolute coordinate positions that can be searched at least vertically and at most horizontally are represented by iVerMin and iVerMax, respectively, and the absolute coordinate positions that can be searched at least horizontally and at most horizontally are represented by iHorMin and iHorMax, respectively. The values ​​of iVerMin, iVerMax, iHorMin, and iHorMax differ for each search region indicated by regionId.

[0190] In the example of FIG. 7(f) described above, the search area is divided into four sub-search areas, and the embodiment thereof is as follows.

[0191] If regionId is equal to 0, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax0=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin0=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMax0=(yTbCmp-nTbH-offsetLCBY)< <iBvShift; iVerMin0=max(((iTemplateSizeH)< <iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。

[0192] If regionId is equal to 1, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin1=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax1=(xTbCmp-offsetLCBX-nTbW)< <iBvShift; iVerMin1=(yTbCmp+1)< <iBvShift; iVerMax1=min(picHeight-nTbH,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)< <iBvShift)。

[0193] If regionId is equal to 2, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax2=(xTbCmp-offsetLCBX-nTbW)< <iBvShift; iHorMin2=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMin2=max((iTemplateSizeH)< <iBvShift,(yTbCmp-nTbH-offsetLCBY)<<iBvShift); iVerMax2=(yTbCmp)< <iBvShift。

[0194] If regionId is equal to 3, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin3=max((iTemplateSizeW)< <iBvShift,(xTbCmp-offsetLCBX-nTbW+1)<<iBvShift); iHorMax3=(xTbCmp-nTbW)< <iBvShift; iVerMin3=max(((iTemplateSizeH)< <iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift); iVerMax3=(yTbCmp-nTbH)< <iBvShift。

[0195] In practical terms, iHorMin regionId , iHorMax regionId , iVerMin regionId , iVerMax regionId represent the left, right, top and bottom edges of different sub-search areas, respectively.

[0196] To visually illustrate the different sub-search areas corresponding to different regionIds, please refer to Figure 12, which shows a schematic diagram of a specific search area determination process according to an embodiment of the present application. As shown in Figure 12, R1, R2, R3, and R4 represent four different sub-search areas. Note that Figure 12 shows the pixel range aligned with the upper left pixel of the block.

[0197] S903: The search region is searched to determine the optimal block vector BV.

[0198] The minimum and maximum offsets of the block vector in the horizontal direction are indicated by bvXMins and bvXMaxs, respectively, and the minimum and maximum offsets of the block vector in the vertical direction are indicated by bvYMins and bvYMaxs, respectively.

[0199] bvXMins regionId , bvXMaxs regionId, bvYMins regionId , bvYMaxs regionId is the iVerMin determined in step S902. regionId , iVerMax regionId , iHorMin regionId , iHorMax regionId It can be calculated from bvXMins regionId =iHorMin regionId -xTbCmp; bvXMaxs regionId =iHorMax regionId -xTbCmp; bvYMins regionId =iVerMin regionId -yTbCmp; bvYMaxs regionId =iVerMax regionId -yTbCmp. where bvXMins regionId , bvXMaxs regionId , bvYMins regionId , and bvYMaxs regionId determines the horizontal and vertical offset range of the search point relative to the current block, i.e., the range of the block vector BV.

[0200] Note that the search point (iPosHor, iPoxVer) in each search area is each block vector BV (consisting of horizontal and vertical components: (pX, pY), where pX = iPosHor-xTbCmp, pY = iPosVer-yTbCmp, where pX is between bvXMins and bvXMaxs, and pY is between bvYMins and bvYMaxs). In this way, the matching reconstruction block of the current block can be found in the reconstruction area, and the adjacent reconstruction pixel of the matching reconstruction block is the matching template (i.e., the second template mentioned above). This allows the matching cost between the adjacent template of the current block and the adjacent template of the matching reconstruction block to be calculated, which is denoted as pDiff.

[0201] Furthermore, all search points within all search ranges (regionId=0,1,2,3) are scanned, and the search point with the smallest matching cost pDiff is obtained by comparison. The corresponding matching cost is defined as pDiff_BEST, the corresponding block vector BV is defined as the optimal block vector BV_BEST(pX_BEST, pY_BEST), and the corresponding matching template is defined as the optimal matching template T_BEST.

[0202] In one possible embodiment, if the search strategy is to perform only a coarse search, this is specifically performed as follows.

[0203] In each region, pX is bvXMins regionId and bvXMaxs regionId between bvYMins and pYMins regionId and bvYMaxs regionId A coarse search is performed within the search range between pX_BEST and pY_BEST with a step size greater than 1, for example, a step size of 2, and the optimal matching cost value obtained by template matching is denoted as pDiff_BEST, and the corresponding block vector BV is denoted as optimal block vector BV_BEST(pX_BEST, pY_BEST).

[0204] In another possible embodiment, if the search strategy is to perform only fine search, it is specifically implemented as follows.

[0205] In each region, pX is bvXMins regionId and bvXMaxs regionId and pY is between bvYMins regionId and bvYMaxs regionId Within the search range between pX_BEST and pY_BEST, a fine search is performed, for example, with a step size of 1, and the optimal matching cost value obtained by template matching is denoted as pDiff_BEST, and the corresponding block vector BV is denoted as optimal block vector BV_BEST(pX_BEST, pY_BEST).

[0206] In yet another possible embodiment, if the search strategy is to perform a coarse search first and then a fine search, as shown in FIG. 13, the specific flow is as follows: S1301: The step size is set to 2 to determine the optimal coarse matching template within the search area. S1302: The step size is set to 1 to determine the optimal fine matching template in the neighborhood of the optimal coarse matching template.

[0207] Regarding step S1301, in the rough search stage: In each region, pX is bvXMins regionId and bvXMaxs regionId and pY is between bvYMins regionId and bvYMaxs regionId Within the search range between pX1_BEST and pY1_BEST, the coarse search is performed with a step size greater than 1. For example, a coarse search is performed with a step size of 2, and the optimal matching cost obtained by template matching is denoted as pDiff1_BEST, the corresponding block vector BV is denoted as optimal block vector BV1_BEST(pX1_BEST, pY1_BEST), and the search region in which the optimal matching search point is located is denoted as bestRegionId.

[0208] Regarding step S1302, in the detailed search stage: Furthermore, the neighborhood of the optimal block vector BV1_BEST obtained by the coarse search is searched. Specifically, first, a fine search range TmpRefineRange is determined. The fine search range may be a fixed size or may depend on the current block size, for example, min(nTbW, nTbH) / 2. Then, the position of the optimal matching reconstruction block obtained by the coarse search is calculated as the reference position of the fine search area: BestPosX = xTbCmp + pX1_BEST, BestPosY = yTbCmp + pY1_BEST.

[0209] First, from the value of bestRegionId, iVerMin calculated in step S902 bestRegionId, iVerMax bestRegionId , iHorMin bestRegionId , iHorMax bestRegionId Then, from the optimal matching block position obtained by the coarse search, a new search range iVerMin refine , iVerMax refine , iHorMin refine , iHorMax refine The acquisition method is as follows: iHorMin refine =max(iHorMin bestRegionId , BestPosX-TmpRefineRange); iHorMax refine =min(iHorMax bestRegionId , BestPosX+TmpRefineRange); iVerMin refine =max(iVerMin bestRegionId , BestPosY-TmpRefineRange); iVerMax refine =min(iVerMax bestRegionId , BestPosY+TmpRefineRange);

[0210] And the adjusted block vectors BVbvXMins, bvXMaxs, bvYMins, bvYMaxs are iVerMin refine , iVerMax refine , iHorMin refine , iHorMax refine It is calculated as follows. bvXMins=iHorMin refine -xTbCmp; bvXMaxs=iHorMax refine -xTbCmp; bvYMins=iVerMin refine -yTbCmp; bvYMaxs=iVerMax refine -yTbCmp;

[0211] Thus, the refinement search is performed by finding that pX is bvXMins refineand bvXMaxs refine and pY is between bvYMins refine and bvYMaxs refine For example, a search is performed with a step size of 1, and the optimal matching cost obtained by template matching is denoted as pDiff_BEST, and the corresponding block vector BV is denoted as optimal block vector BV_BEST(pX_BEST, pY_BEST).

[0212] After the above operations are completed, a best block vector BV_BEST(pX_BEST, pY_BEST) is obtained, where pX_BEST and pY_BEST are the horizontal and vertical offsets of the best matching template relative to the current block template, and the horizontal and vertical offsets of the best matching reconstructed block relative to the current block, respectively.

[0213] S804: Configure a linear filtering model.

[0214] A linear filtering model is constructed using the optimal matching template obtained by the search in step S803 and the current block template. This mainly includes two processes: a process for determining a reconstruction region for calculating filter coefficients, and a process for calculating the filter coefficients.

[0215] The number of filter taps is defined as nTap. nTap may be a constant or a variable, and the number of filter taps can be dynamically adjusted depending on, for example, the size of the current block size. In the embodiment of the present application, filters of various shapes can be selected. For example, a fixed-shape filter shown in FIG. 14 can be selected, in which the number of filter taps nTap is 5 and the filter coefficients are C0, C1, C2, C3, and C4, respectively.

[0216] Referring to Figure 15, there is shown a flow chart of the calculation of filter coefficients according to an embodiment of the present application. As shown in Figure 15, the flow is structured as follows:

[0217] S1501: A reconstruction region for calculating filter coefficients is determined.

[0218] In the embodiment of the present application, available reconstruction pixels are determined based on the template type refTemplateType. For example, when the template type refTemplateType is 1, this indicates that the adjacent reconstruction pixels on the left, the upper left, and the upper right are all available, as shown in FIG. 10 above. In this case, the number of available reconstruction pixels on the left is templateW_size×nTbH, the number of available reconstruction pixels on the upper right is templateH_size×nTbW, and the number of available reconstruction pixels on the upper left is templateW_size×templateH_size.

[0219] In the embodiment of the present application, after determining the number of available reconstructed pixels, a reconstruction region for calculating filter coefficients from the available reconstructed pixels is determined, and this region may be referred to as R. R generally includes all available reconstructed pixels in the template. For example, when refTemplateType is 1, R may include all available reconstructed pixels on the left, upper left, and upper sides.

[0220] S1502: Calculate filter coefficients based on the reconstruction region.

[0221] In the embodiment of the present application, after determining the reconstruction region R for calculating the filter coefficients, a set of filter coefficients can be derived by minimizing the MSE between the reconstruction pixels in the reconstruction region R and the reconstruction pixels in the current block template.

number

number

[0222] Furthermore, the process of deriving the filter coefficients by minimizing the MSE is as follows:

[0223] JPEG2026502383000127.jpg775

number

number

[0224] Here, rearranging equations (18) and (19), we get

number

[0225] Next, after determining the reconstruction region R, the obtained equation is expanded into a matrix form, specifically as follows:

number

[0226] JPEG2026502383000133.jpg33167

[0227] JPEG2026502383000134.jpg36167

[0228] S805: A predicted value is generated.

[0229] JPEG2026502383000135.jpg39168

number

[0230] The specific calculation process for the predicted value is as follows.

[0231] JPEG2026502383000137.jpg60167

[0232] Here, the specific calculation process of the predicted value is as follows.

[0233] JPEG2026502383000138.jpg29166

number

[0234] For i=0,…,nTbW-1, j=0,…,nTbH-1,

number

[0235] JPEG2026502383000142.jpg14166

number

[0236] The clip function is specifically as follows:

number

[0237] In the embodiment of the present application, a linear filtering model is constructed between the optimal matching template obtained by the search and the current block template, and the filter coefficients are calculated by minimizing the MSE between the predicted template (prediction template = filter coefficients × matching template) and the current block template. Filtering correction is performed on the optimal matching block, and the filtered reconstructed pixels are used as the final predicted pixels.

[0238] In some embodiments, the input information for calculating the filter coefficients in the above-described embodiments can be expanded, where the input information for calculating the filter coefficients may be available reconstructed pixels of the matching template, or the gradient of each pixel in the matching template may be calculated, including but not limited to horizontal gradient, vertical gradient, etc., and the calculated gradient may be used as the input information for calculating the filter coefficients, or the position information of each pixel may be used as the input information for calculating the filter coefficients, where the position information may be absolute position information of each pixel in the entire image or relative position information of each pixel with respect to a reference point.

[0239] JPEG2026502383000145.jpg45167

number

[0240] In this case, adding a bias term gives the following equation:

number

[0241] In some embodiments, the number of filtering models in the above-described embodiments can be expanded. Here, only one linear filtering model may be configured, or multiple linear filtering models may be configured. Here, input information for calculating filter coefficients is classified, and a filter model is configured for each type of input information. For example, when constructing a filter model using reconstruction information, a feasible method is to classify the reconstruction information according to its average value, and construct one model for reconstruction information greater than the average value and another model for reconstruction information less than the average value.

[0242] Another possible method is to classify using the position of the reconstruction information, for example, construct one model using the available reconstruction information on the left and top, construct a second model using the available reconstruction information on the left and top-left, etc. The encoder decides which model to use, and a possible decision method is for the encoder to determine which model to use by rate-distortion optimization and send corresponding decoding parameters (e.g., flag) to the decoder.

[0243] Another feasible method is to classify filters by their shape. It is also possible to use multiple filters of different shapes and configure a filter model for each filter shape. The encoder decides which filter shape to use. A feasible decision method is for the encoder to determine which filter to use using a rate-distortion optimization method and send the corresponding decoding parameters (e.g., a flag) to the decoder.

[0244] In some embodiments, the type of filtering model in the above embodiments can be extended. Here, a linear filtering model can be configured, or a nonlinear filtering model can be configured to perform filtering. One possible method is to introduce a square term to configure a nonlinear filtering model. For example, when minimizing the MSE of the filter coefficients, the calculation formula is changed as follows:

number

[0245] At this time, the formula for calculating the predicted value is corrected as follows.

number

[0246] In some embodiments, the calculation predictor portion of the previous embodiment can be extended, where some conditional test determines whether the current block uses the filtered reference block as the final predictor, such as:

[0247] Method 1: Determine whether to filter the matching template by comparing the distortion between the matching template and the current block template, such as SAD, MSE, SATD, or SSE, with a threshold T_Distortion1.

[0248] Method 2: Assuming that Method 1 satisfies the use of the filter model, then determine whether to filter the reference block by comparing the distortion between the filtered matching template and the current block template, such as SAD or MSE or SATD or SSE, with a threshold T_Distortion2.

[0249] Method 3: The encoding side transmits a Flag indicating whether to apply a filter model. The tmp Flag indicates whether to apply intra-template matching to the current block, and the filter Flag indicates whether to apply a filter model to the current block. If the tmp Flag is 1, the encoding side compares the distortion between the reference block and the current block before and after filtering, such as SAD, MSE, SATD, or SSE, to determine whether to filter the reference block. If the distortion after filtering is smaller than the distortion before filtering, the filter Flag is 1, and the current block uses the filtered reference block as its predicted block; otherwise, the filter Flag is 0, and the current block uses the unfiltered reference block as its predicted block. The encoding side transmits the filter Flag to the decoding side.

[0250] In some embodiments, the above-mentioned Fig. 7(a) is implemented, where the search area is divided into four sub-search areas.

[0251] If regionId is equal to 0, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMax=(yTbCmp-nTbH-offsetLCBY)< <iBvShift; iVerMin=max(((iTemplateSizeH)< <iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。

[0252] If regionId is equal to 1, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax=(xTbCmp-offsetLCBX-nTbW)< <iBvShift; iVerMin=(yTbCmp+1)< <iBvShift; iVerMax=min(picHeight-nTbH,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)< <iBvShift)。

[0253] If regionId is equal to 2, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax=(xTbCmp-nTbW)< <iBvShift; iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMin=max((iTemplateSizeH)< <iBvShift,(yTbCmp-nTbH)<<iBvShift); iVerMax=(yTbCmp)< <iBvShift。

[0254] If regionId is equal to 3, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax=(xTbCmp)< <iBvShift; iVerMin=max(((iTemplateSizeH)< <iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift); iVerMax=(yTbCmp-nTbH)< <iBvShift。

[0255] In practice, iHorMin, iHorMax, iVerMin, iVerMax here represent the left, right, top and bottom edges of the different search regions, respectively. To visually explain the different sub-search areas corresponding to different regionIds, refer to Figure 17, which shows a schematic diagram of another specific search area determination process according to an embodiment of the present application. As shown in Figure 17, R1, R2, R3, and R4 represent four different sub-search areas. Note that Figure 17 shows the pixel range aligned with the upper left pixel of the block.

[0256] In some embodiments, the search area of ​​the template in the current frame may be different from the search area of ​​the template in the current frame determined by the existing Intra TMP technique. Here, when implementing the above-mentioned (b) of Figure 7 in another embodiment, it is divided into a total of four sub-search areas.

[0257] If regionId is equal to 0, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMax=(yTbCmp-nTbH-offsetLCBY)< <iBvShift; iVerMin=max(((iTemplateSizeH)< <iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。

[0258] If regionId is equal to 1, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax=(xTbCmp-offsetLCBX-nTbW)< <iBvShift; iVerMin=(yTbCmp+1)< <iBvShift; iVerMax=min(picHeight-nTbH,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)< <iBvShift)。

[0259] If regionId is equal to 2, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax=(xTbCmp-nTbW)< <iBvShift; iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMin=max((iTemplateSizeH)< <iBvShift,(yTbCmp-nTbH-offsetLCBY)<<iBvShift); iVerMax=(yTbCmp)< <iBvShift。

[0260] If regionId is equal to 3, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin=max((iTemplateSizeW)< <iBvShift,(xTbCmp-nTbW+1)<<iBvShift); iHorMax=(xTbCmp)< <iBvShift; iVerMin=max(((iTemplateSizeH)< <iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift); iVerMax=(yTbCmp-nTbH)< <iBvShift。

[0261] In practice, iHorMin, iHorMax, iVerMin, iVerMax here represent the left, right, top and bottom edges of the different search regions, respectively.

[0262] To visually illustrate the different sub-search areas corresponding to different regionIds, refer to Figure 18, which shows a schematic diagram of another specific search area determination process according to an embodiment of the present application. As shown in Figure 18, R1, R2, R3, and R4 represent four different sub-search areas. Note that Figure 18 shows the pixel range aligned with the upper left pixel of the block.

[0263] In some embodiments, the coarse search process may be similar to the previous embodiments. The fine search process may be performed along the boundaries of each region, i.e., the invention is now extended to perform a fine search across the boundaries between individual search regions. In an embodiment of the present application, the method includes: performing a first search within each of at least one sub-search area to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; performing region determination based on the best block vector of each of the sub-search regions and the corresponding second search region to determine at least two target sub-search regions involved in the second search; conducting a second search within the at least two target sub-search regions to determine optimal block vectors corresponding to the at least two target sub-search regions; The method may further include the step of determining the optimal block vectors corresponding to the at least two target sub-search regions as target block vectors.

[0264] Taking FIG. 7(a) as an example, another embodiment is provided here, which is specifically implemented by dividing the search area into a total of four sub-search areas.

[0265] If regionId is equal to 0, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax0=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin0=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift) iVerMax0=(yTbCmp-nTbH-offsetLCBY)< <iBvShift iVerMin0=max(((iTemplateSizeH)< <iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。

[0266] If regionId is equal to 1, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin1=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax1=(xTbCmp-offsetLCBX-nTbW)< <iBvShift; iVerMin1=(yTbCmp+1)< <iBvShift; iVerMax1=min(picHeight-nTbH,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)< <iBvShift)。

[0267] If regionId is equal to 2, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMax2=(xTbCmp-nTbW)< <iBvShift; iHorMin2=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift) iVerMin2=max((iTemplateSizeH)< <iBvShift,(yTbCmp-nTbH)<<iBvShift); iVerMax2=(yTbCmp)< <iBvShift。

[0268] If regionId is equal to 3, iVerMin, iVerMax, iHorMin, iHorMax can be calculated as follows: iHorMin3=max((iTemplateSizeW)< <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift) iHorMax3=(xTbCmp)< <iBvShift; iVerMin3=max(((iTemplateSizeH)< <iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift) iVerMax3=(yTbCmp-nTbH)< <iBvShift。

[0269] In practice, iHorMin, iHorMax, iVerMin, iVerMax here represent the left, right, top and bottom edges of the different search regions, respectively.

[0270] To visually explain the different sub-search areas corresponding to different regionIds, refer to Figure 19, which shows a schematic diagram of yet another specific search area determination process according to an embodiment of the present application. As shown in Figure 19, R1, R2, R3, and R4 represent four different sub-search areas, and fine searches are performed across the boundaries between each sub-search area. Note that Figure 19 shows the pixel range aligned with the upper left pixel of the block.

[0271] In the fine search stage, the neighborhood of the block vector obtained in each coarse search is searched.

[0272] Furthermore, the optimal block vector BV1_BEST obtained by the rough search k Specifically, first, a fine search range TmpRefineRange is determined. The fine search range may be a fixed size or may depend on the size of the current block, e.g., min(nTbW, nTbH) / 2. Then, the position of the best-matching reconstruction block obtained by the coarse search is calculated as the reference position of the fine search area: BestPosX. k =xTbCmp+pX1_BEST k , BestPosY k =yTbCmp+pY1_BEST k .

[0273] In addition, BestPosX k The detailed search performed each time can span multiple regions.

[0274] Determine the value of bestRegionId related to the calculation. Check regionId=0, 1, 2, 3 in order. BestPosY k -TmpRefineRange>=iVerMin regionId and BestPosY k -TmpRefineRange<=iVerMax regionId If Or, BestPosY k +TmpRefineRange>=iVerMinregionId and BestPosY k +TmpRefineRange<=iVerMax regionId If Or, BestPosY k -TmpRefineRange<=iVerMin regionId and BestPosY k +TmpRefineRange>=iVerMax regionId If The regionId is the corresponding bestSearchFlag regionId Set to 1.

[0275] Here, bestSearchFlag regionId For each search region where the value of is 1, bestRegionId is set as the regionId of that region in turn, and specifically, the following fine search is performed.

[0276] First, the iVerMin calculated based on the value of bestRegionId bestRegionId , iVerMax bestRegionId , iHorMin bestRegionId , iHorMax bestRegionId Then, a new search range iVerMin is obtained based on the optimal matching block position obtained by the coarse search. refine , iVerMax refine , iHorMin refine , iHorMax refine The acquisition method is as follows: iHorMin refine =max(iHorMin bestRegionId ,BestPosX-TmpRefineRange); iHorMax refine =min(iHorMax bestRegionId ,BestPosX+TmpRefineRange); iVerMin refine =max(iVerMin bestRegionId ,BestPosY-TmpRefineRange); iVerMaxrefine =min(iVerMax bestRegionId ,BestPosY+TmpRefineRange);

[0277] And the adjusted block vectors BVbvXMins, bvXMaxs, bvYMins, bvYMaxs are iVerMin refine ,iVerMax refine ,iHorMin refine ,iHorMax refine It is calculated as follows. bvXMins=iHorMin refine -xTbCmp; bvXMaxs=iHorMax refine -xTbCmp; bvYMins=iVerMin refine -yTbCmp; bvYMaxs=iVerMax refine -yTbCmp;

[0278] Thus, the refinement search is performed by finding that pX is bvXMins refine and bvXMaxs refine and pY is between bvYMins refine and bvYMaxs refine The search is performed within the range of block vectors between pX_BEST and pY_BEST. For example, let us use a step size of 1 to perform the search, and denote the optimal matching cost obtained by template matching as pDiff_BEST, and the corresponding block vector BV as the optimal block vector BV_BEST(pX_BEST, pY_BEST). The total optimal block vector for multiple regions involved in the search is obtained.

[0279] After the above operations are completed, a best block vector BV_BEST(pX_BEST, pY_BEST) is obtained, where pX_BEST and pY_BEST are the horizontal and vertical offsets of the best matching template relative to the current block template, and are also the horizontal and vertical offsets of the best matching block relative to the current block, respectively.

[0280] In view of the above, the embodiment of the present application proposes an intra template matching (Intra TMP-FLM) technology based on a linear filtering model, which uses the matching template and the current block template information to construct a linear filtering model, fully utilizes the correlation between the matching template and the current coding block template, performs filtering correction on the reconstructed pixels of the best matching block (i.e., reference block), and uses the filtered reconstructed pixels as predicted pixels, thereby improving prediction accuracy to a certain extent and effectively solving the problem of linear change between the best matching block and the current block.

[0281] In the embodiments of the present application, the specific implementation of the above-mentioned embodiments has been described in detail, and it can be seen that the invention according to the above-mentioned embodiments can effectively correct the predicted value of intra template matching technology and improve prediction accuracy. Specifically, a linear filtering model is constructed between the best matching template obtained by search and the current block template, and filter coefficients are calculated by minimizing the MSE between the predicted template (prediction template = filter coefficients × matching template) and the current coding block template, and the filter coefficients fully embody the correlation between the matching template and the current block template. This correlation is applied to the best matching block, and filtering correction is performed on the reconstructed pixels thereof. Finally, the filtered reconstructed pixels are used as predicted pixels, thereby improving prediction accuracy.

[0282] In yet another embodiment of the present application, referring to Figure 20, a flowchart of an encoding method according to an embodiment of the present application is shown. As shown in Figure 20, the method may include the following steps: S2001: Determine the first template of the current block, and determine the matching template and the reference block.

[0283] The encoding method of the embodiments of the present application is applied to an encoder. Specifically, the encoding method is an intra prediction method, more specifically, an intra prediction method based on the Intra TMP-FLM technique. A video image can be divided into multiple coding blocks, and the current block in the embodiments of the present application refers to the coding block that is currently the target of intra prediction in the video image. The encoding method of the embodiments of the present application can be used for predicting both a luminance component and a chrominance component, and is not particularly limited.

[0284] It should be noted that in the embodiments of the present application, it is necessary to first determine a first template for the current block. In some embodiments, the step of determining a first template for the current block includes: determining the template type of the current block; determining a first template for the current block based on the template type of the current block.

[0285] Here, the template type may be represented by refTemplateType. In some embodiments, determining the template type of the current block may include determining the template type of the current block based on reference pixels of the current block.

[0286] Here, the reference pixels of the current block include at least one of the reference pixel to the left of the current block, the reference pixel to the upper side of the current block, the reference pixel to the upper left of the current block, the reference pixel to the lower left of the current block, and the reference pixel to the upper right of the current block.

[0287] Furthermore, the template type may be classified based on the availability of neighboring reference pixels, and the template type of the current block may be determined. In some embodiments, the step of determining the template type of the current block includes: determining the template type of the current block to be a first value if the reference pixel to the left of the current block, the reference pixel to the upper neighbor of the current block, and the reference pixel to the upper left of the current block are all available; If the reference pixel to the left of the current block is available, determining the template type of the current block to a second value; If the reference pixel of the upper neighbor of the current block is available, determining the template type of the current block to be a third value; determining the template type of the current block to be a fourth value if both the left neighbor reference pixel of the current block and the upper left neighbor reference pixel of the current block are available; determining the template type of the current block to be a fifth value if both the left neighbor reference pixel of the current block and the lower left neighbor reference pixel of the current block are available; If both the reference pixel above the current block and the reference pixel to the upper right of the current block are available, determining the template type of the current block to be a sixth value.

[0288] In the embodiment of the present application, the first value, the second value, the third value, the fourth value, the fifth value, and the sixth value may be different. For example, the first value may be set to 1, the second value to 2, the third value to 3, the fourth value to 4, the fifth value to 5, and the sixth value to 6. For details of these six template types, see (a), (b), (c), (d), (e), and (f) in Figure 3.

[0289] In some embodiments, determining the first template for the current block based on the template type of the current block may include obtaining template pixels for the current block based on the template type of the current block and a corresponding template size, and determining the template pixels of the current block as the first template for the current block.

[0290] In the embodiment of the present application, the size of the template may be preset or may be determined based on the size of the current block, and may further be related to the template type of the current block, and is not particularly limited here. For example, if the template type indicates that only the left template is to be acquired, the template width (templateW_size) may be set to 4, and if the template type indicates that only the top template is to be acquired, the template height (templateH_size) may be set to 4.

[0291] In the embodiment of the present application, which part of the reconstructed pixels the first template acquires may be determined based on the value of the template type. For example, if the value of refTemplateType is 1, the reconstructed pixels on the left, upper left, and upper sides of the current block are acquired; if the value of refTemplateType is 2, only the reconstructed pixels on the left four columns of the current block are acquired; and if the value of refTemplateType is 3, only the reconstructed pixels on the top four rows of the current block are acquired.

[0292] Regarding the matching template and reference block, in one possible embodiment, the step of determining the matching template and reference block may include the steps of determining motion parameters and corresponding reference blocks, and determining the matching template based on the first template and the reference block.

[0293] Therefore, in some embodiments, the method may further include encoding the motion parameters and writing the resulting coded bits into a codestream. That is, the encoding side may determine the motion parameters (e.g., BV) and then write them into the codestream, and then the decoding side may determine the reference block of the current block by directly determining the motion parameters based on the decoded codestream, and then determine a matching template from the reference block based on the first template of the current block.

[0294] Regarding the matching template and the reference block, in another possible embodiment, the step of determining the matching template and the reference block may include the steps of: performing template matching within a predetermined search area based on a first template to determine a matching template; and determining a reference block based on the matching template.

[0295] In some embodiments, the step of performing template matching within a predetermined search area based on the first template to determine a matching template may include the steps of performing a search within a predetermined search area based on the first template to determine a target block vector, and determining a matching template based on the target block vector.

[0296] That is, a search can be performed within a predetermined search area based on the first template, and a matching template with the minimum cost can be searched for based on a predetermined cost function. Here, all search points within the predetermined search area can be scanned to obtain one or more candidate block vectors, which can represent one or more candidate matching templates. A cost calculation is performed on each of these search points with the first template of the current block to obtain the search point with the minimum cost, and the corresponding candidate block vector is the optimal block vector (i.e., the target block vector, BV_BEST). The corresponding candidate matching template is the optimal matching template (i.e., the matching template, T_BEST, described in this embodiment). A reference block can be determined based on the optimal matching template.

[0297] In the embodiments of the present application, the predetermined cost function may be the sum of absolute differences SAD, the sum of absolute differences after transformation SATD, the mean squared error MSE, the sum of squared differences SSD, the mean absolute deviation MAD, the mean squared difference MSD, the normalized correlation coefficient NCC, etc., and is not particularly limited here.

[0298] The search process within the predetermined search region may be a coarse search or a fine search, or the coarse search may be performed first and the fine search may be performed later.

[0299] In one possible embodiment, the step of performing a search within a predetermined search area based on the first template to determine a target block vector may include performing a first search within the predetermined search area to determine a target block vector.

[0300] In another possible embodiment, the step of performing a search within a predetermined search area based on the first template to determine the target block vector may include the step of performing a second search within the predetermined search area to determine the target block vector.

[0301] In yet another possible embodiment, the step of performing a search within a predetermined search area based on the first template to determine a target block vector may include the steps of performing a first search within the predetermined search area to determine a first block vector and determining an initial matching template based on the first block vector, and determining a first search area based on the initial matching template and performing a second search within the first search area to determine a target block vector.

[0302] In the embodiment of the present application, the search step size corresponding to the first search is larger than the search step size corresponding to the second search. For example, the search step size corresponding to the first search is 2, and the search step size corresponding to the second search is 1. Alternatively, the downsampling factor corresponding to the first search is larger than the downsampling factor corresponding to the second search. For example, the downsampling factor corresponding to the first search is 4, and the downsampling factor corresponding to the second search is 2. In other words, there are no particular limitations as long as the first search is a coarse search, the second search is a fine search, and the first search is coarser than the second search.

[0303] When the first search is performed before the second search, not only is the search step size for the first search larger than the search step size for the second search, but the first search area is smaller than the predetermined search area. Here, the first search area is a search area near the initial matching template. For example, a step size of 2 can be used to determine an optimal coarse matching template in the predetermined search area, and a step size of 1 can be used to determine an optimal fine matching template (i.e., a final matching template) near the optimal coarse matching template.

[0304] In yet another possible embodiment, the predetermined search area may include at least one sub-search area, and the step of searching within the predetermined search area based on the first template to determine the target block vector may include: performing a search within each of at least one sub-search area to determine an optimal block vector and corresponding matching cost value for each of the sub-search areas; determining an optimal block vector corresponding to a minimum matching cost value based on the optimal block vectors and corresponding matching cost values ​​of each of the sub-search regions; and determining the optimal block vector corresponding to the minimum matching cost value as the target block vector.

[0305] In yet another possible embodiment, the predetermined search area may include at least one sub-search area, and the step of searching within the predetermined search area based on the first template to determine the target block vector may include: performing a first search within each of at least one sub-search area to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; performing region determination based on the best block vector of each of the sub-search regions and the corresponding second search region to determine at least two target sub-search regions involved in the second search; conducting a second search within the at least two target sub-search regions to determine optimal block vectors corresponding to the at least two target sub-search regions; and determining the optimal block vectors corresponding to the at least two target sub-search regions as target block vectors.

[0306] It should be noted that in the embodiment of the present application, the search area of ​​the current block template may be the CTB-reconstructed part where the current block is located, or may be another reconstructed CTB area.The search area here is actually a set of all search points.Because the shape of this area often cannot be represented by a single rectangular area, specifically, multiple rectangular areas are searched, and the search results of different areas are integrated to obtain the final optimal reference block and optimal block vector.

[0307] In the embodiment of the present application, taking FIG. 7(f) as an example, the predetermined search area is divided into four sub-search areas, each of which is represented by regionId, and the value of regionId may be equal to 0, 1, 2, or 3. Using the search point (iPosHor, iPoxVer) in each sub-search area, i.e., each block vector BV (consisting of horizontal and vertical components: (pX, pY), where pX=iPosHor-xTbCmp, pY=iPosVer-yTbCmp, where pX is between bvXMins and bvXMaxs, and pY is between bvYMins and bvYMaxs), a reference block matching the current block is found in the reconstructed area, and the adjacent reconstructed pixels of the reference block are the matching template. Therefore, the matching cost between the first template of the current block and the matching template can be calculated, which is denoted as pDiff.

[0308] In this way, all search points in all search ranges (regionId=0,1,2,3) are scanned, and the search point with the smallest matching cost pDiff is obtained by comparison. The corresponding matching cost is denoted as pDiff_BEST, and the corresponding block vector is denoted as the optimal block vector BV_BEST(pX_BEST, pY_BEST) (i.e., the target block vector described in this embodiment). The corresponding optimal matching template T_BEST is the finally required matching template.

[0309] S2002: Determine model parameters based on the first template and the matching template.

[0310] In some embodiments, the model parameters may include coefficients of a target filter. In some embodiments, the method may further include determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template.

[0311] In some embodiments, the coefficients of the target filter may be determined by solving an optimization problem. Therefore, in some embodiments, the method may further include a step in which the coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after processing by the target filter and a pixel reference value in the first template satisfies a first condition.

[0312] With regard to the first error satisfying the first condition, it should be understood that in one possible embodiment, the first condition is that the first error is minimal, or in another possible embodiment, the first condition is that the first error is within a first predetermined threshold range, or in yet another possible embodiment, the first condition is that the amount of change in the first error is within a second predetermined threshold range.

[0313] It should also be understood that the first predetermined threshold range and the second predetermined threshold range are both measures preset on the decoding side for determining whether the first error satisfies the first condition. The first error here may be a mean square error (MSE), a sum of square errors (SSE), a sum of absolute differences (SAD), a sum of absolute differences after Hadamard transform (SATD), or a mean absolute error (MAE). The embodiments of the present application are not particularly limited thereto.

[0314] In some embodiments, determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template comprises: determining autocorrelation parameters based on pixel reference values ​​in the matching template; determining cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; and determining coefficients of the target filter based on the autocorrelation and cross-correlation parameters.

[0315] It should be noted that in the embodiment of the present application, the pixel reference values ​​include at least one of pixel reconstruction values, pixel gradient values, and pixel position information.

[0316] JPEG2026502383000151.jpg76167

[0317] In one specific example, a reconstruction region R for calculating filter coefficients may be first determined, and then a set of filter coefficients may be derived by minimizing the MSE between the reconstructed pixels in region R and the reconstructed pixels of the first template, as shown in the above equations (3) and (4).

[0318] JPEG2026502383000152.jpg44166

[0319] JPEG2026502383000153.jpg29166

[0320] In addition, in the embodiment of the present application, it is necessary to determine the number of coefficients of the target filter, the shape of the target filter, etc. Here, the number of coefficients of the target filter and the shape of the target filter may both be preset fixed values, or may be associated with the size of the current block.

[0321] In some embodiments, with respect to the number of coefficients of the target filter, the method may further include the step of the number of coefficients of the target filter being equal to a first predetermined value.

[0322] In some embodiments, with respect to the number of coefficients of the target filter, the method may further include determining the number of coefficients of the target filter, encoding the number of coefficients of the target filter, and writing the resulting encoded bits into the codestream.

[0323] The number of coefficients of the target filter can be represented by nTap. For example, the value of nTap may be 4, 5, 6, 7, 8, 9, etc., but is not particularly limited thereto.

[0324] The number of coefficients of the target filter is also called the number of target filter taps. Here, the number of coefficients of the target filter may be a preset constant value or may be determined according to the size of the current block, and is not particularly limited here.

[0325] In some embodiments, with respect to the shape of the target filter, the method may further comprise the step of the target filter being a one-dimensional or two-dimensional filter of a predetermined shape.

[0326] In some embodiments, with respect to the shape of the target filter, the method may further include determining the shape of the target filter, encoding the shape of the target filter, and writing the resulting encoded bits into the codestream.

[0327] In some embodiments, the method may further include determining values ​​of filter shape parameters to indicate the shape of the target filter, and may further include encoding the values ​​of the filter shape parameters and writing the resulting encoded bits into the codestream.

[0328] The filter shape parameter can be expressed by FilterIdx, which indicates the shape of the target filter. For example, the shape of the target filter may be a diamond, a rectangle, a cross, a bar, or even a one-dimensional filter or a two-dimensional filter, but is not particularly limited thereto.

[0329] As an example, if the value of FilterIdx is equal to 0, the shape of the target filter is determined to be a diamond, if the value of FilterIdx is equal to 1, the shape of the target filter is determined to be a cross, and if the value of FilterIdx is equal to 2, the shape of the target filter is determined to be a rectangle.

[0330] The shape of the target filter may be a predetermined shape, may be determined by the value of a filter shape parameter, or may be determined according to the size of the current block, but is not particularly limited here.

[0331] S2003: Based on the model parameters, a filtering process is performed on the reference block to determine a filtered reference block.

[0332] S2004: Determine a predicted value of the current block based on the filtered reference block.

[0333] In addition, in the embodiment of the present application, after determining the model parameters, the predicted value of the current block can be determined based on the model parameters and the reference block. Specifically, the reference block is filtered based on the model parameters, and the predicted value of the current block is determined based on the filtered reference block.

[0334] In some embodiments, the step of performing a filtering process on the reference block based on the model parameters to determine a filtered reference block may include the steps of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter, and determining the filtered reference block based on the first output value of the target filter.

[0335] In the embodiment of the present application, a first output value of the target filter can be calculated based on the pixel reconstruction value of the reference block and the coefficient of the target filter in the model parameter, and a filtered reference block can be determined based on the first output value of the target filter, where the target filter can be a linear filtering model or a nonlinear filtering model, but is not particularly limited thereto.

[0336] In one possible embodiment, the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter comprises: calculating the product of pixel reconstruction values ​​of the reference block and the corresponding coefficients of the target filter; Setting a first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer.

[0337] It should be noted that the target filter in the embodiment of the present application is a linear filtering model, and the first output value of the target filter can be calculated by the above-mentioned equation (11).

[0338] In another possible embodiment, the step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter comprises: determining a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block; calculating the product of the first value and the corresponding coefficient of the target filter; Setting a first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter and n is a positive integer.

[0339] It should be noted that the target filter in the embodiment of the present application is a nonlinear filtering model. For example, when minimizing the MSE of the filter coefficients, it can be calculated by the above-mentioned equations (12) and (13).

[0340] In the embodiment of the present application, the step of determining the filtered reference block based on the first output value of the target filter may directly set the first output value of the target filter as the filtered reference block, or may perform first filtering on the first output value of the target filter to obtain the filtered reference block. The first filtering here may be, but is not limited to, a low-pass filter, an up / down sampling filter, etc.

[0341] In addition, in the embodiment of the present application, after determining the first output value of the target filter, a first offset value (denoted by bias) can also be added to the first output value to determine the filtered reference block.

[0342] In some embodiments, determining the filtered reference block based on the first output value of the target filter may include determining a first offset value, and performing an addition operation based on the first output value and the first offset value to determine the filtered reference block.

[0343] In one possible embodiment, determining the first offset value may include setting the first offset value equal to a second predetermined value.

[0344] In another possible embodiment, the step of determining the first offset value may include a step of determining the n+1-th coefficient of the target filter, where the number of coefficients of the target filter is n, and a step of determining the first offset value based on the n+1-th coefficient and the second offset value.

[0345] In an embodiment of the present application, for the second offset value, the method may further include a step of setting the second offset value equal to a third predetermined value, or a step of setting the second offset value equal to a value in a second mapping relationship of the pixel reconstruction value of the reference block.

[0346] JPEG2026502383000154.jpg44166

[0347] Furthermore, in some embodiments, determining a predicted value of the current block based on the filtered reference block may include performing a first process on the filtered reference block to obtain a predicted value of the current block.

[0348] In the embodiments of the present application, referring to the first operation, the first operation may be to set the predicted value of the current block equal to the filtered reference block, or the first operation may be a clipping operation that limits the filtered reference block to a predetermined numerical range, or the first operation may be any other operation not particularly limited.

[0349] JPEG2026502383000155.jpg69166

[0350] JPEG2026502383000156.jpg22166

[0351] Furthermore, the number of filter models can be expanded. Instead of just one filter model, multiple filter models may be configured. Thus, in some embodiments, the method determining sets of model parameters based on the first template and the matching template; constructing a plurality of filter models based on the plurality of sets of model parameters, and performing filtering processes on the reference blocks based on the plurality of filter models, respectively, to determine a plurality of filtered reference blocks; determining a prediction value for the current block based on the plurality of filtered reference blocks.

[0352] In some embodiments, the step of determining the multiple sets of model parameters based on the first template and the matching template may include the steps of: classifying the reconstructed pixels in the first template and the matching template according to a predetermined scheme, respectively, to obtain multiple sets of sub-templates and multiple sets of sub-matching templates; and determining the multiple sets of model parameters based on the multiple sets of sub-templates and multiple sets of sub-matching templates.

[0353] In the embodiment of the present application, the predetermined method may be the magnitude of the reconstructed pixel value, the position information of the reconstructed pixel, the shape of the filter, etc., but is not limited to these. After classification according to the predetermined method, a set of model parameters can be calculated from each set of sub-templates and the corresponding sub-matching template, and a filter model can be determined from each set of model parameters, thereby configuring multiple filter models.

[0354] In one possible embodiment, the method may further include determining a target filter from a plurality of filter models, and performing a filtering process on the reference block based on the target filter to determine a predicted value of the current block.

[0355] Furthermore, in some embodiments, the method may further include determining a target model index value for indicating an index number of the target filter in the plurality of filter models, and encoding the target model index value and writing the resulting encoded bits into the codestream.

[0356] Furthermore, in some embodiments, the step of determining the target filter from the plurality of filter models may include the steps of: determining original values ​​of the current block; performing rate-distortion cost calculations based on the original values ​​of the current block and the plurality of initial predicted values ​​of the current block to determine rate-distortion cost values ​​for each of the plurality of initial predicted values; determining a minimum rate-distortion cost value from the rate-distortion cost values ​​for each of the plurality of initial predicted values; and selecting the filter model corresponding to the minimum rate-distortion cost value as the target filter.

[0357] In another possible embodiment, multiple filtered reference blocks can be determined by performing filtering operations on the reference block based on multiple filter models, respectively. In some implementations, determining a prediction value for the current block based on the multiple filtered reference blocks can include performing a weighting calculation on the multiple filtered reference blocks to determine a prediction value for the current block.

[0358] It should be noted that if the weights of the filtered reference blocks are equal and are each equal to the reciprocal of the number of reference blocks, the weighting calculation here can also be regarded as an average value calculation, in other words, the average value of multiple filtered reference blocks is calculated to determine the predicted value of the current block.

[0359] For example, input information for calculating filter coefficients is classified, and a filter model is constructed for each type of input information. For example, when constructing a filter model using reconstruction information, one possible embodiment is to classify the reconstruction information according to its average value, and construct one filter model for reconstruction information greater than the average value, and another filter model for reconstruction information less than the average value. Another possible embodiment is to classify the reconstruction information according to its position, for example, construct one filter model using available reconstruction information on the left and upper sides, and construct another filter model using available reconstruction information on the left and upper left sides, and the encoding side determines which model to use. A possible determination method is for the encoding side to determine which model to use using a rate-distortion optimization method, and then transmit corresponding decoding parameters to the decoding side so that the decoding side can clearly select the filter model. Another possible embodiment is to classify according to the filter shape, and use multiple different filter shapes. A filter model is constructed for each filter shape, and the encoding side determines which filter shape to use. A possible decision scheme is for the encoding side to decide which filter to use by rate-distortion optimization, and then send the corresponding decoding parameters to the decoding side so that the decoding side can explicitly select the filter model.

[0360] S2005: Determine a prediction difference for the current block based on the predicted value of the current block.

[0361] It should be noted that in the embodiments of the present application, after determining the predicted value of the current block, the prediction difference of the current block can be further calculated, and in some embodiments, the step of determining the prediction difference of the current block based on the predicted value of the current block can include the steps of determining an original value of the current block, and determining the prediction difference of the current block based on the original value of the current block and the predicted value of the current block.

[0362] In one specific embodiment, the step of determining a prediction difference for the current block based on the original value of the current block and the predicted value of the current block may include the step of subtracting the original value of the current block and the predicted value of the current block to determine a prediction difference for the current block.

[0363] It should be noted that in embodiments of the present application, whether intra template matching is applied to the current block or whether a filter model is applied to the current block may be determined by different syntax element identification information. In some embodiments, the method may further include determining a value of a first syntax element identification information to indicate whether intra template matching is applied to the current block, and encoding the value of the first syntax element identification information and writing the resulting encoded bits into the codestream.

[0364] In an embodiment of the present application, the step of determining the value of the first syntax element identification information may include the step of determining the value of the first syntax element identification information to a first value if intra-template matching is applied to the current block, or the step of determining the value of the first syntax element identification information to a second value if intra-template matching is not applied to the current block.

[0365] Furthermore, in some embodiments, if the first syntax element identification indicates that intra-template matching is applied to the current block, the method may further include determining a value of a second syntax element identification to indicate whether a filter model is applied to the current block, and encoding the value of the second syntax element identification and writing the resulting encoded bits into the codestream.

[0366] In an embodiment of the present application, the step of determining the value of the second syntax element identification information may include a step of determining the value of the second syntax element identification information to a first value if a filter model is applied to the current block, or a step of determining the value of the second syntax element identification information to a second value if a filter model is not applied to the current block.

[0367] Further, in some embodiments, the method further comprises: performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; and determining a predicted value of the current block based on the filtered reference block when the filter model is applied to the current block; If no filter model is applied to the current block, the method may further include using reconstructed pixel values ​​in the reference block as predicted values ​​for the current block.

[0368] In the embodiment of the present application, the first value and the second value are different, and the first value and the second value may be in a parameter format or a numeric format. Specifically, the first syntax element identification information and the second syntax element identification information may be parameters written in a profile or flag values, but this is not a specific limitation. For example, the first value and the second value may be set to 1 and 0, or the first value may be set to true and the second value may be set to false, but this is not a specific limitation.

[0369] In the embodiment of the present application, whether the current block uses the filtered reference block as the final predicted value is determined by some conditions, but the conditions are not limited to the following three methods. For example, these three methods can be as follows:

[0370] Method 1: Determine whether to filter the matching template by comparing the distortion between the matching template and the current block template, such as SAD, MSE, SATD, or SSE, with a threshold T_Distortion1.

[0371] Method 2: Assuming that Method 1 satisfies the use of the filter model, then determine whether to filter the reference block by comparing the distortion between the filtered matching template and the current block template, such as SAD or MSE or SATD or SSE, with a threshold T_Distortion2.

[0372] Method 3: The encoding side transmits a Flag indicating whether to apply a filter model. The tmp Flag indicates whether to apply intra-template matching to the current block, and the filter Flag indicates whether to apply a filter model to the current block. If the tmp Flag is 1, the encoding side compares the distortion between the reference block and the current block before and after filtering, such as SAD, MSE, SATD, or SSE, to determine whether to filter the reference block. If the distortion after filtering is smaller than the distortion before filtering, the filter Flag is 1, and the current block uses the filtered reference block as its predicted block; otherwise, the filter Flag is 0, and the current block uses the unfiltered reference block as its predicted block. The encoding side transmits the filter Flag to the decoding side.

[0373] Furthermore, an embodiment of the present application provides a codestream that is generated by bit-encoding based on information to be coded, where the information to be coded includes at least one of a prediction difference of a current block, a number of coefficients of a target filter, a shape of the target filter, a value of a first syntax element identification, and a value of a second syntax element identification.

[0374] In an embodiment of the present application, the first syntax element identification information is used to indicate whether intra-template matching is applied to the current block, and the second syntax element identification information is used to indicate whether a filter model is applied to the current block.

[0375] This embodiment provides a coding method including the steps of: determining a first template for a current block, determining a matching template and a reference block, determining model parameters based on the first template and the matching template, performing a filtering process on the reference block based on the model parameters to determine a filtered reference block, determining a predicted value of the current block based on the filtered reference block, and determining a prediction difference of the current block based on the predicted value of the current block. In this way, the model parameters are determined based on the first template and the matching template, and the model parameters fully embody the correlation between the matching template and the first template of the current block. This correlation is applied to the reference block, and filtering correction is performed on its reconstructed pixels, and then the filtered reconstructed pixels are used as the predicted pixels of the current block, thereby improving prediction accuracy and saving bit rate, while also improving codec efficiency and further improving codec performance.

[0376] In yet another embodiment of the present application, based on the same inventive concept as the previous embodiment, a schematic diagram of the configuration and structure of an encoder according to an embodiment of the present application is shown in Figure 21. As shown in Figure 21, an encoder 210 includes a first determination unit 2101, a first filtering unit 2102, and a first prediction unit 2103.

[0377] The first determining unit 2101 is configured to determine a first template for the current block, determine a matching template and a reference block, and further configured to determine model parameters based on the first template and the matching template.

[0378] The first filtering unit 2102 is configured to perform a filtering operation on the reference block based on the model parameters, and determine a filtered reference block.

[0379] The first predictor 2103 is configured to determine a prediction value for the current block based on the filtered reference block.

[0380] The first determining unit 2101 is further configured to determine, based on the predicted value of the current block, a prediction difference of the current block.

[0381] In some embodiments, the first determiner 2101 is further configured to determine a template type of the current block, and determine a first template for the current block based on the template type of the current block.

[0382] In some embodiments, the first determination unit 2101 is further configured to determine a template type of the current block based on reference pixels of the current block, where the reference pixels of the current block include at least one of: a reference pixel to the left of the current block, a reference pixel to the upper neighbor of the current block, a reference pixel to the upper left of the current block, a reference pixel to the lower left of the current block, and a reference pixel to the upper right of the current block.

[0383] In some embodiments, the first determiner 2101 is further configured to: determine the template type of the current block to a first value if the left-neighbor reference pixel of the current block, the upper-neighbor reference pixel of the current block, and the upper-left-neighbor reference pixel of the current block are all available; determine the template type of the current block to a second value if the left-neighbor reference pixel of the current block is available; determine the template type of the current block to a third value if the upper-neighbor reference pixel of the current block is available; determine the template type of the current block to a fourth value if both the left-neighbor reference pixel of the current block and the upper-left-neighbor reference pixel of the current block are available; determine the template type of the current block to a fifth value if both the left-neighbor reference pixel of the current block and the lower-left-neighbor reference pixel of the current block are available; and determine the template type of the current block to a sixth value if both the upper-neighbor reference pixel of the current block and the upper-right-neighbor reference pixel of the current block are available.

[0384] In some embodiments, the first determining unit 2101 is further configured to perform template matching within a predetermined search area based on the first template to determine a matching template, and to determine a reference block based on the matching template.

[0385] In some embodiments, the first determiner 2101 is further configured to: perform a search within a predetermined search area based on the first template to determine a target block vector; and determine a matching template based on the target block vector.

[0386] In some embodiments, the first determination unit 2101 is further configured to determine motion parameters and corresponding reference blocks, determine a matching template based on the first template and the reference block, encode the motion parameters, and write the resulting encoded bits into a codestream.

[0387] In some embodiments, the first determination unit 2101 is further configured to perform a first search within a predetermined search area to determine a target block vector, or to perform a second search within the predetermined search area to determine a target block vector, and a search step size corresponding to the first search is larger than a search step size corresponding to the second search.

[0388] In some embodiments, the first determination unit 2101 is further configured to perform a first search within a predetermined search area to determine a first block vector, determine an initial matching template based on the first block vector, determine a first search area based on the initial matching template, perform a second search within the first search area to determine a target block vector, wherein a search step size corresponding to the first search is larger than a search step size corresponding to the second search, and the first search area is smaller than the predetermined search area.

[0389] In some embodiments, the predetermined search area includes at least one sub-search area, and the first determination unit 2101 is further configured to: perform a search in each of the at least one sub-search area to determine an optimal block vector and a corresponding matching cost value for each of the sub-search areas; determine an optimal block vector corresponding to a minimum matching cost value based on the optimal block vector and the corresponding matching cost value for each of the sub-search areas; and set the optimal block vector corresponding to the minimum matching cost value as a target block vector.

[0390] In some embodiments, the first determination unit 2101 is further configured to: perform a first search in at least one sub-search area, respectively, to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; perform area determination based on the optimal block vector for each of the sub-search areas and the corresponding second search area, to determine at least two target sub-search areas involved in the second search; perform a second search in the at least two target sub-search areas, to determine optimal block vectors corresponding to the at least two target sub-search areas, and set the optimal block vectors corresponding to the at least two target sub-search areas as target block vectors.

[0391] In some embodiments, the first determiner 2101 is further configured such that the model parameters include coefficients of a target filter.

[0392] In some embodiments, the first determiner 2101 is further configured to determine coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template.

[0393] In some embodiments, the first determination unit 2101 is further configured to set the coefficients of the target filter to be coefficients to be used by the target filter if a first error between an output value of a pixel reference value in the matching template after processing by the target filter and the pixel reference value in the first template satisfies a first condition.

[0394] In some embodiments, the first determiner 2101 is further configured such that the first condition is that the first error is minimum.

[0395] In some embodiments, the first determiner 2101 is further configured such that the first condition is that the first error is within a first predetermined threshold range.

[0396] In some embodiments, the first determiner 2101 is further configured such that the first condition is that the variation of the first error is within a second predetermined threshold range.

[0397] In some embodiments, the first determiner 2101 is further configured to determine autocorrelation parameters based on pixel reference values ​​in the matching template, determine cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template, and determine coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters.

[0398] In some embodiments, the first determiner 2101 is further configured such that the pixel reference values ​​include at least one of pixel reconstruction values, pixel gradient values, and pixel position information.

[0399] In some embodiments, the first determiner 2101 is further configured such that the number of coefficients of the target filter is equal to a first predetermined value.

[0400] In some embodiments, the first determining unit 2101 is further configured to determine the number of coefficients of the target filter, encode the number of coefficients of the target filter, and write the resulting encoded bits into a codestream.

[0401] In some embodiments, the first determiner 2101 is further configured such that the target filter is a one-dimensional or two-dimensional filter of a predetermined shape.

[0402] In some embodiments, the first determiner 2101 is further configured to determine a target filter shape, encode the target filter shape, and write the resulting encoded bits into the codestream.

[0403] In some embodiments, the first filtering unit 2102 is further configured to perform a filtering process on the reference block based on the model parameters to determine a first output value of the target filter, and to determine a filtered reference block based on the first output value of the target filter.

[0404] In some embodiments, the first filtering unit 2102 is further configured to calculate products of pixel reconstruction values ​​of the reference block and corresponding coefficients of the target filter, and set a first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter, and n is a positive integer.

[0405] In some embodiments, the first filtering unit 2102 is further configured to determine a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block, calculate a product of the first value and a corresponding coefficient of the target filter, and set a first output value of the target filter equal to the sum of n products, where n represents the number of coefficients of the target filter, and n is a positive integer.

[0406] In some embodiments, the first filtering unit 2102 is further configured to determine a first offset value, and perform an addition operation based on the first output value and the first offset value to determine the filtered reference block.

[0407] In some embodiments, the first filtering unit 2102 is further configured to set the first offset value equal to a second predetermined value.

[0408] In some embodiments, the first filtering unit 2102 is further configured to: determine an n+1-th coefficient of the target filter when the number of coefficients of the target filter is n; and determine a first offset value based on the n+1-th coefficient and the second offset value.

[0409] In some embodiments, the first filtering unit 2102 is further configured to set the second offset value equal to a third predetermined value, or to set the second offset value equal to a value in a second mapping relationship of pixel reconstruction values ​​of the reference block.

[0410] In some embodiments, the first predictor 2103 is further configured to perform a first operation on the filtered reference block to obtain a predicted value of the current block.

[0411] In some embodiments, the first predictor 2103 is further configured such that the first operation is to set a predicted value of the current block equal to the filtered reference block.

[0412] In some embodiments, the first predictor 2103 is further configured such that the first processing is a clip operation that restricts the filtered reference block to within a predetermined numerical range.

[0413] In some embodiments, the first predictor 2103 is further configured to: determine, based on the first template and the matching template, a plurality of sets of model parameters; configure, based on the plurality of sets of model parameters, a plurality of filter models; perform filtering operations on the reference blocks, respectively, based on the plurality of filter models, to determine a plurality of filtered reference blocks; and determine, based on the plurality of filtered reference blocks, a predicted value of the current block.

[0414] In some embodiments, the first predictor 2103 is further configured to perform a weighting calculation on the plurality of filtered reference blocks to determine a prediction value for the current block.

[0415] In some embodiments, the first predictor 2103 is further configured to determine a target filter from a plurality of filter models, and perform a filtering operation on the reference block based on the target filter to determine a predicted value of the current block.

[0416] In some embodiments, the first predictor 2103 is further configured to determine a target model index value for indicating an index number of a target filter in the plurality of filter models, encode the target model index value, and write the resulting encoded bits into the codestream.

[0417] In some embodiments, the first predictor 2103 is further configured to: determine an original value of the current block; perform rate-distortion cost calculation based on the original value of the current block and a plurality of initial predicted values ​​of the current block, respectively, to determine a rate-distortion cost value for each of the plurality of initial predicted values; determine a minimum rate-distortion cost value from the rate-distortion cost values ​​for each of the plurality of initial predicted values; and set the filter model corresponding to the minimum rate-distortion cost value as the target filter.

[0418] In some embodiments, the first prediction unit 2103 is configured to classify the reconstructed pixels in the first template and the matching template according to a predetermined scheme, respectively, to obtain multiple sets of sub-templates and multiple sets of sub-matching templates, and determine multiple sets of model parameters based on the multiple sets of sub-templates and the multiple sets of sub-matching templates.

[0419] In some embodiments, the first determining unit 2101 is further configured to determine a value of a first syntax element identification information to indicate whether intra-template matching is applied to the current block, encode the value of the first syntax element identification information, and write the resulting encoded bits into the codestream.

[0420] In some embodiments, the first determination unit 2101 is further configured to determine the value of the first syntax element identification information to a first value if intra-template matching is applied to the current block, and to determine the value of the first syntax element identification information to a second value if intra-template matching is not applied to the current block.

[0421] In some embodiments, the first determining unit 2101 is further configured to determine a value of a second syntax element identification information to indicate whether a filter model is applied to the current block, encode the value of the second syntax element identification information, and write the resulting encoded bits into the codestream.

[0422] In some embodiments, the first determination unit 2101 is further configured to determine a value of the second syntax element identification information to a first value if a filter model is applied to the current block, and to determine a value of the second syntax element identification information to a second value if a filter model is not applied to the current block.

[0423] In some embodiments, the first determination unit 2101 is further configured to perform the steps of: performing a filtering operation on the reference block based on the model parameters to determine a filtered reference block; and determining a predicted value of the current block based on the filtered reference block when a filter model is applied to the current block; and when a filter model is not applied to the current block, to use a reconstructed pixel value in the reference block as the predicted value of the current block.

[0424] In some embodiments, the first determination unit 2101 is further configured to determine an original value of the current block, and determine a prediction difference of the current block based on the original value of the current block and the predicted value of the current block.

[0425] It should be understood that in the embodiments of the present application, a "unit" may be a partial circuit, a partial processor, a partial program, or software, and may of course be a module or a non-module. Note that each component in the present embodiment may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The integrated unit may be realized as hardware or as a software functional module.

[0426] The integrated units may be realized in the form of software functional modules and stored in a computer-readable storage medium when not sold or used as an independent product. Based on this understanding, the invention according to this embodiment may be embodied in the form of a software product stored in a storage medium, the software product including, in its entirety or in part, instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) or a processor to execute all or part of the steps of the method according to this embodiment. The storage medium may also include various media capable of storing program code, such as a U disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0427] Therefore, an embodiment of the present application provides a computer-readable storage medium applied to an encoder 210 that stores a computer program that, when executed by a first processor, implements the encoding method described in any of the previous embodiments.

[0428] Based on the configuration of the encoder 210 and the computer-readable storage medium, referring to FIG. 22, a schematic diagram of a specific hardware structure of the encoder 210 according to an embodiment of the present application is shown. As shown in FIG. 22, the encoder 210 may include a first communication interface 2201, a first memory 2202, and a first processor 2203, and each component is coupled to each other by a first bus system 2204. It should be understood that the first bus system 2204 is used to enable connection communication between these components. The first bus system 2204 includes a power bus, a control bus, and a status signal bus in addition to a data bus. However, for clarity, various buses are shown as the first bus system 2204 in FIG. 22. However, The first communication interface 2201 is used to send and receive signals when sending and receiving information to and from other external network elements. The first memory 2202 stores a computer program that is executable on the first processor 2103 . When executing the computer program, the first processor 2203: determining a first template for the current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a prediction of the current block based on the filtered reference block; determining a prediction difference for the current block based on the predicted value of the current block.

[0429] It should be understood that first memory 2202 according to embodiments of the present application may be volatile or nonvolatile memory, or may include both volatile and nonvolatile memory. Here, nonvolatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM) used as an external cache. Many forms of RAM are available, including, by way of illustrative, but non-limiting example, static random access memory (Static RAM, SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (Synchlink DRAM, SLDRAM), and direct Rambus random access memory (Direct Rambus RAM, DRRAM). The first memory 2202 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0430] The first processor 2203 may be an integrated circuit chip having signal processing capabilities. In the implementation process, each step of the above method may be performed by a hardware integrated logic circuit in the first processor 2203 or by instructions in software form. The above-mentioned first processor 2203 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The first processor 2203 may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc. The steps of the methods disclosed in the embodiments of the present application may be directly embodied as being performed 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 that is mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. This storage medium is located in the first memory 2202, and the first processor 2203 reads information from the first memory 2202 and completes the steps of the above-mentioned method together with its hardware.

[0431] It should be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. In a hardware implementation, a processing unit may be implemented in one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processing (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 described herein, or a combination thereof. In a software implementation, the techniques described herein may be implemented by modules (e.g., processes, functions, etc.) that perform the functions described herein. The software code may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.

[0432] Optionally, as another embodiment, the first processor 2203 is further configured to, when executing a computer program, perform the encoding method according to any of the previous embodiments.

[0433] This embodiment provides an encoder that determines model parameters based on a first template and a matching template, where the model parameters fully reflect the correlation between the matching template and the first template of a current block, and applies this correlation to a reference block to effectively correct the prediction value of intra-template matching technology, thereby improving prediction accuracy, saving bitrate, and simultaneously improving codec efficiency and performance.

[0434] In yet another embodiment of the present application, based on the same inventive concept as the previous embodiment, referring to Figure 23, there is shown a schematic diagram of the configuration and structure of a decoder 230 according to an embodiment of the present application. As shown in Figure 23, the decoder 230 may include a second decision unit 2301, a second filtering unit 2302, and a second prediction unit 2303.

[0435] The second determiner 2301 is configured to determine a first template for the current block, determine a matching template and a reference block, and is further configured to determine model parameters based on the first template and the matching template.

[0436] The second filtering unit 2302 is configured to perform a filtering operation on the reference block based on the model parameters, and determine a filtered reference block.

[0437] The second predictor 2303 determines a prediction value for the current block based on the filtered reference block.

[0438] The second determining unit 2301 is further configured to determine, based on the predicted value of the current block, a reconstructed value of the current block.

[0439] In some embodiments, the second determiner 2301 is further configured to determine a template type of the current block, and determine a first template for the current block based on the template type of the current block.

[0440] In some embodiments, the second determiner 2301 is further configured to determine the template type of the current block based on reference pixels of the current block, where the reference pixels of the current block include at least one of: a left neighbor reference pixel of the current block, an upper neighbor reference pixel of the current block, an upper left neighbor reference pixel of the current block, a lower left neighbor reference pixel of the current block, and an upper right neighbor reference pixel of the current block.

[0441] In some embodiments, the second determiner 2301 is further configured to: determine the template type of the current block to a first value if the left-neighbor reference pixel of the current block, the above-neighbor reference pixel of the current block, and the upper-left-neighbor reference pixel of the current block are all available; determine the template type of the current block to a second value if the left-neighbor reference pixel of the current block is available; determine the template type of the current block to a third value if the above-neighbor reference pixel of the current block is available; determine the template type of the current block to a fourth value if both the left-neighbor reference pixel of the current block and the above-left-neighbor reference pixel of the current block are available; determine the template type of the current block to a fifth value if both the left-neighbor reference pixel of the current block and the below-left-neighbor reference pixel of the current block are available; and determine the template type of the current block to a sixth value if both the above-neighbor reference pixel of the current block and the above-right-neighbor reference pixel of the current block are available.

[0442] In some embodiments, the second determining unit 2301 is further configured to perform template matching within a predetermined search area based on the first template to determine a matching template, and to determine a reference block based on the matching template.

[0443] In some embodiments, the second determiner 2301 is further configured to: perform a search within a predetermined search area based on the first template to determine a target block vector; and determine a matching template based on the target block vector.

[0444] In some embodiments, the second determination unit 2301 is further configured to decode the codestream to determine motion parameters, determine a reference block based on the motion parameters, and determine a matching template based on the first template and the reference block.

[0445] In some embodiments, the second determiner 2301 is further configured to perform a first search within a predetermined search area to determine the target block vector, or to perform a second search within the predetermined search area to determine the target block vector, wherein a search step size corresponding to the first search is larger than a search step size corresponding to the second search.

[0446] In some embodiments, the second determiner 2301 is further configured to: perform a first search within a predetermined search area to determine a first block vector; determine an initial matching template based on the first block vector; determine a first search area based on the initial matching template; and perform a second search within the first search area to determine a target block vector. A search step size corresponding to the first search is larger than a search step size corresponding to the second search, and the first search area is smaller than the predetermined search area.

[0447] In some embodiments, the predetermined search area includes at least one sub-search area, and the second determination unit 2301 is further configured to: perform a search in each of the at least one sub-search area to determine an optimal block vector and a corresponding matching cost value for each of the sub-search areas; determine an optimal block vector corresponding to a minimum matching cost value based on the optimal block vector and the corresponding matching cost value for each of the sub-search areas; and set the optimal block vector corresponding to the minimum matching cost value as a target block vector.

[0448] In some embodiments, the second determination unit 2301 is further configured to: perform a first search in at least one sub-search area, respectively, to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; perform area determination based on the optimal block vector for each of the sub-search areas and the corresponding second search area, to determine at least two target sub-search areas involved in the second search; perform a second search in the at least two target sub-search areas, to determine optimal block vectors corresponding to the at least two target sub-search areas, and set the optimal block vectors corresponding to the at least two target sub-search areas as target block vectors.

[0449] In some embodiments, the second determiner 2301 is further configured such that the model parameters include coefficients of a target filter.

[0450] In some embodiments, the second determiner 2301 is further configured to determine coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template.

[0451] In some embodiments, the second determination unit 2301 is further configured to set the coefficients of the target filter to be coefficients to be used by the target filter if a first error between an output value of a pixel reference value in the matching template after processing by the target filter and the pixel reference value in the first template satisfies a first condition.

[0452] In some embodiments, the second determiner 2301 is further configured such that the first condition is that the first error is minimum.

[0453] In some embodiments, the second determiner 2301 is further configured such that the first condition is that the first error is within a first predetermined threshold range.

[0454] In some embodiments, the second determiner 2301 is further configured such that the first condition is that the variation of the first error is within a second predetermined threshold range.

[0455] In some embodiments, the second determiner 2301 is further configured to determine autocorrelation parameters based on pixel reference values ​​in the matching template, determine cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template, and determine coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters.

[0456] In some embodiments, the second determiner 2301 is further configured such that the pixel reference values ​​include at least one of pixel reconstruction values, pixel gradient values, and pixel position information.

[0457] In some embodiments, the second determiner 2301 is further configured to set the number of coefficients of the target filter equal to a first predetermined value.

[0458] In some embodiments, the second determiner 2301 is further configured to decode the codestream to determine the number of coefficients of the target filter.

[0459] In some embodiments, the second determiner 2301 is further configured such that the target filter is a one-dimensional or two-dimensional filter of a predetermined shape.

[0460] In some embodiments, the second determiner 2301 is further configured to decode the codestream to determine the shape of the target filter.

[0461] In some embodiments, the second filtering unit 2302 is further configured to perform a filtering process on the reference block based on the model parameters to determine a first output value of the target filter, and to determine a filtered reference block based on the first output value of the target filter.

[0462] In some embodiments, the second filtering unit 2302 is further configured to calculate products of pixel reconstruction values ​​of the reference block and corresponding coefficients of the target filter, and set a first output value of the target filter equal to a sum of n products, where n represents the number of coefficients of the target filter, and n is a positive integer.

[0463] In some embodiments, the second filtering unit 2302 is further configured to determine a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block, calculate a product of the first value and a corresponding coefficient of the target filter, and set a first output value of the target filter equal to a sum of n products, where n represents the number of coefficients of the target filter, and n is a positive integer.

[0464] In some embodiments, the second filtering unit 2302 is further configured to determine a first offset value and perform an addition operation based on the first output value and the first offset value to determine the filtered reference block.

[0465] In some embodiments, the second filtering unit 2302 is further configured to set the first offset value equal to a second predetermined value.

[0466] In some embodiments, the second filtering unit 2302 is further configured to: determine an n+1-th coefficient of the target filter when the number of coefficients of the target filter is n; and determine a first offset value based on the n+1-th coefficient and the second offset value.

[0467] In some embodiments, the second filtering unit 2302 is further configured to set the second offset value equal to a third predetermined value, or to set the second offset value equal to a value in a second mapping relationship of pixel reconstruction values ​​of the reference block.

[0468] In some embodiments, the second predictor 2303 is further configured to perform a first operation on the filtered reference block to obtain a predicted value of the current block.

[0469] In some embodiments, the second predictor 2303 is configured such that the first operation is to set the prediction value of the current block equal to the filtered reference block.

[0470] In some embodiments, the second predictor 2303 is configured such that the first operation is a clip operation that restricts the filtered reference block to within a predetermined numerical range.

[0471] In some embodiments, the second predictor 2303 is further configured to: determine, based on the first template and the matching template, a plurality of sets of model parameters; configure, based on the plurality of sets of model parameters, a plurality of filter models; perform filtering operations on the reference blocks, respectively, based on the plurality of filter models, to determine a plurality of filtered reference blocks; and determine, based on the plurality of filtered reference blocks, a predicted value of the current block.

[0472] In some embodiments, the second predictor 2303 is further configured to perform a weighting calculation on the plurality of filtered reference blocks to determine a prediction value for the current block.

[0473] In some embodiments, the second predictor 2303 is further configured to: decode the codestream to determine an index value of a target model; determine a corresponding target filter from a plurality of filter models based on the index value of the target model; and perform a filtering operation on the reference block based on the target filter to determine a predicted value of the current block.

[0474] In some embodiments, the second prediction unit 2303 is further configured to classify the reconstructed pixels in the first template and the matching template according to a predetermined scheme, respectively, to obtain multiple sets of sub-templates and multiple sets of sub-matching templates, and determine multiple sets of model parameters based on the multiple sets of sub-templates and multiple sets of sub-matching templates.

[0475] In some embodiments, the second determination unit 2301 is further configured to perform the steps of: decoding the codestream to determine a value of a first syntax element identification information; if the first syntax element identification information indicates that intra template matching is applied to the current block; decoding the codestream to determine a value of a second syntax element identification information; performing a filtering operation on the reference block according to the model parameters to determine a filtered reference block; and determining a prediction value of the current block based on the filtered reference block if the second syntax element identification information indicates that a filter model is applied to the current block.

[0476] In some embodiments, the second determination unit 2301 is further configured to, if the second syntax element identification information indicates that a filter model is not applied to the current block, set a reconstructed pixel value in the reference block as a predicted value of the current block.

[0477] In some embodiments, the second determination unit 2301 is further configured to decode the codestream to determine a prediction residual of the current block, and determine a reconstructed value of the current block based on the prediction value of the current block and the prediction residual of the current block.

[0478] It should be understood that in this embodiment, a "unit" may be a partial circuit, a partial processor, a partial program, or software, and may of course be a module or a non-module. Note that each component in this embodiment may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The integrated unit may be realized as hardware or as a software functional module.

[0479] The integrated unit may be realized in the form of a software functional module and stored in a computer-readable storage medium when not sold or used as an independent product. Based on this understanding, this embodiment provides a computer-readable storage medium applied to the decoder 230, the computer-readable storage medium storing a computer program that, when executed by the second processor, implements the decoding method according to any of the above embodiments.

[0480] Based on the configuration of the decoder 230 and the computer-readable storage medium, referring to FIG. 24, a schematic diagram of a specific hardware structure of the decoder 230 according to an embodiment of the present application is shown. As shown in FIG. 24, the decoder 230 may include a second communication interface 2401, a second memory 2402, and a second processor 2403, and each component is coupled to each other by a second bus system 2404. It should be understood that the second bus system 2404 is used to enable connection communication between these components. The second bus system 2404 includes a power bus, a control bus, and a status signal bus in addition to a data bus. However, for clarity, various buses are shown as the second bus system 2404 in FIG. 24. However, The second communication interface 2401 is used to send and receive signals when sending and receiving information to and from other external network elements. The second memory 2402 stores a computer program executable on the second processor 2403 . When executing the computer program, the second processor 2403 determining a first template for the current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a prediction of the current block based on the filtered reference block; determining a reconstructed value for the current block based on the predicted value for the current block.

[0481] Optionally, as another embodiment, the second processor 2403, when executing a computer program, is further configured to perform the decoding method according to any of the previous embodiments.

[0482] It should be understood that the second memory 2402 is similar in hardware functionality to the first memory 2202, and the second processor 2403 is similar in hardware functionality to the first processor 2203.

[0483] This embodiment provides a decoder, which determines model parameters based on a first template and a matching template, and the model parameters fully embody the correlation between the matching template and the first template of a current block, and applies the correlation to a reference block to effectively correct the prediction value of intra-template matching technology, thereby improving prediction accuracy, saving bitrate, and simultaneously improving codec efficiency and performance.

[0484] In yet another embodiment of the present application, referring to Fig. 25, there is shown a block diagram of the configuration and structure of a codec system according to an embodiment of the present application. As shown in Fig. 25, a codec system 250 may include an encoder 2501 and a decoder 2502.

[0485] In an embodiment of the present application, the encoder 2501 may be the encoder according to any of the previous embodiments, and the decoder 2502 may be the decoder according to any of the previous embodiments.

[0486] As used herein, the terms "comprises," "comprises," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a set of elements includes not only those elements but also other elements not expressly listed or that are inherent in such process, method, article, or apparatus. In the absence of further limitations, an element qualified by the phrase "comprises one of" does not exclude the presence of other identical elements in a process, method, article, or apparatus that includes that element.

[0487] The numbers of the above-mentioned examples of the present application are merely for illustrative purposes and do not represent the superiority or inferiority of the examples.

[0488] The methods disclosed in the several method embodiments of this application can be combined in any manner to obtain new method embodiments, unless there is a contradiction.

[0489] The features disclosed in the various product embodiments of this application may be combined in any manner to arrive at new product embodiments, unless inconsistent.

[0490] The features disclosed in any method or apparatus embodiment of the present application may be combined in any manner, unless inconsistent, to arrive at a new method or apparatus embodiment.

[0491] The above are only specific embodiments of the present application, but the scope of protection of the present application is not limited thereto, and any modifications or replacements that can be easily thought up by a person skilled in the art within the technical scope disclosed by the present application shall be included in the scope of protection of the present application. Therefore, the scope of protection of the present application shall be governed by the claims. [Industrial Applicability]

[0492] In the embodiment of the present application, whether at the encoding side or the decoding side, a first template for a current block is determined, a matching template and a reference block are determined, model parameters are determined based on the first template and the matching template, a filtering process is performed on the reference block based on the model parameters to determine a filtered reference block, and a predicted value of the current block is determined based on the filtered reference block. In this way, the encoding side can determine a prediction difference of the current block based on the predicted value of the current block, and the decoding side can determine a reconstructed value of the current block based on the predicted value of the current block. That is, the model parameters are determined based on the first template and the matching template, and the model parameters fully embody the correlation between the matching template and the first template of the current block, and this correlation is applied to the reference block, and filtering correction is performed on the reconstructed pixels thereof. Then, the filtered reconstructed pixels are used as the predicted pixels of the current block. This can improve prediction accuracy, save bit rate, and simultaneously improve codec efficiency and further improve codec performance.

Claims

1. A decoding method applied to a decoder, comprising: determining a first template for the current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a prediction value for the current block based on the filtered reference block; determining a reconstructed value of the current block based on the predicted value of the current block; method.

2. The step of determining a first template for the current block comprises: determining a template type for the current block; determining a first template for the current block based on a template type of the current block; The method of claim 1.

3. The step of determining a template type of the current block comprises: determining a template type of the current block based on reference pixels of the current block; the reference pixels of the current block include at least one of a reference pixel to the left of the current block, a reference pixel to the upper side of the current block, a reference pixel to the upper left of the current block, a reference pixel to the lower left of the current block, and a reference pixel to the upper right of the current block; The method of claim 2.

4. The step of determining a template type of the current block comprises: determining a template type of the current block to be a first value when the reference pixel to the left of the current block, the reference pixel to the upper neighbor of the current block, and the reference pixel to the upper left of the current block are all available; determining the template type of the current block to a second value if the reference pixel to the left of the current block is available; determining the template type of the current block to a third value if the reference pixel of the upper neighbor of the current block is available; determining a template type of the current block to be a fourth value if both the left neighbor reference pixel of the current block and the upper left neighbor reference pixel of the current block are available; determining a template type of the current block to be a fifth value if both the reference pixel of the left neighbor of the current block and the reference pixel of the lower left neighbor of the current block are available; determining the template type of the current block to a sixth value if both the reference pixel of the upper neighbor of the current block and the reference pixel of the upper right neighbor of the current block are available; The method of claim 3.

5. The step of determining a matching template and a reference block includes: determining the matching template by performing template matching within a predetermined search area based on the first template; determining the reference block based on the matching template; The method of claim 1.

6. The step of determining the matching template by performing template matching within a predetermined search area based on the first template includes: determining a target block vector by searching within the predetermined search area based on the first template, and determining the matching template based on the target block vector; The method of claim 5.

7. The step of determining a matching template and a reference block includes: decoding the codestream to determine motion parameters; determining the reference block based on the motion parameters; determining the matching template based on the first template and the reference block; The method of claim 1.

8. The step of determining a target block vector by searching within the predetermined search area based on the first template includes: performing a first search within the predetermined search area to determine the target block vector; or performing a second search within the predetermined search area to determine the target block vector; a search step size corresponding to the first search is greater than a search step size corresponding to the second search; The method of claim 6.

9. The step of determining a target block vector by searching within the predetermined search area based on the first template includes: performing a first search within the predetermined search area to determine a first block vector; and determining an initial matching template based on the first block vector; determining a first search area based on the initial matching template, and performing a second search within the first search area to determine the target block vector; a search step size corresponding to the first search is larger than a search step size corresponding to the second search, and the first search area is smaller than the predetermined search area; The method of claim 6.

10. The predetermined search area includes at least one sub-search area, and the step of searching within the predetermined search area based on the first template to determine a target block vector includes: performing a search within each of the at least one sub-search area to determine a best-fit block vector and corresponding matching cost value for each of the sub-search areas; determining an optimal block vector corresponding to a minimum matching cost value based on the optimal block vectors and corresponding matching cost values ​​of each of the sub-search regions; and determining the optimal block vector corresponding to the minimum matching cost value as the target block vector. The method of claim 6.

11. The step of determining a target block vector by searching within the predetermined search area based on the first template includes: performing a first search within each of the at least one sub-search area to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; performing region determination based on the best block vectors of each of the sub-search regions and the corresponding second search region to determine at least two target sub-search regions for the second search; performing a second search within the at least two target sub-search areas to determine optimal block vectors corresponding to the at least two target sub-search areas; and determining the optimal block vectors corresponding to the at least two target sub-search regions as the target block vectors. The method of claim 10.

12. determining model parameters based on the first template and the matching template, the model parameters include coefficients of a target filter; The method of claim 1.

13. determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; The method of claim 12.

14. The method further includes a step in which the coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after processing by the target filter and a pixel reference value in the first template satisfies a first condition. The method of claim 13.

15. The method further includes the step of: the first condition is that the first error is minimum.

15. The method of claim 14.

16. The method further includes the step of: the first condition being that the first error is within a first predetermined threshold range.

15. The method of claim 14.

17. The first condition further includes a step in which the change amount of the first error is within a second predetermined threshold range.

15. The method of claim 14.

18. determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template, determining autocorrelation parameters based on pixel reference values ​​in the matching template; determining cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; determining coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters; The method of claim 13.

19. the pixel reference values ​​include at least one of pixel reconstruction values, pixel gradient values, and pixel position information; The method of claim 13.

20. the number of coefficients of the target filter is equal to a first predetermined value; The method of claim 12.

21. further comprising decoding the codestream to determine the number of coefficients of the target filter. The method of claim 12.

22. The target filter is a one-dimensional or two-dimensional filter of a predetermined shape. The method of claim 12.

23. further comprising decoding the codestream to determine the shape of the target filter. The method of claim 12.

24. The step of performing a filtering process on the reference block based on the model parameters to determine a filtered reference block includes: performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter; determining the filtered reference block based on a first output value of the target filter; The method of claim 12.

25. The step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes: calculating a product of pixel reconstruction values ​​of the reference block and corresponding coefficients of the target filter; setting a first output value of the target filter equal to the sum of n of the products, where n represents the number of coefficients of the target filter and n is a positive integer; 25. The method of claim 24.

26. The step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes: determining a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block; calculating the product of the first value and a corresponding coefficient of the target filter; setting a first output value of the target filter equal to the sum of n of the products, where n represents the number of coefficients of the target filter and n is a positive integer; 25. The method of claim 24.

27. determining the filtered reference block based on a first output value of the target filter, determining a first offset value; performing an addition operation based on the first output value and the first offset value to determine the filtered reference block; 25. The method of claim 24.

28. The step of determining a first offset value includes: setting the first offset value equal to a second predetermined value; 28. The method of claim 27.

29. The step of determining a first offset value includes: determining the n+1 th coefficient of the target filter if the number of coefficients of the target filter is n; determining the first offset value based on the n+1 th coefficient and a second offset value; 28. The method of claim 27.

30. setting the second offset value equal to a third predetermined value; setting the second offset value equal to a value in a second mapping relationship of pixel reconstruction values ​​of the reference block; 30. The method of claim 29.

31. determining a prediction value of the current block based on the filtered reference block, performing a first process on the filtered reference block to obtain a predicted value of the current block; The method of claim 1.

32. the first processing further comprises setting a predicted value of the current block equal to the filtered reference block; 32. The method of claim 31 .

33. The first processing further includes a step of clipping the filtered reference block to a predetermined range of values.

32. The method of claim 31 .

34. determining sets of model parameters based on the first template and the matching template; constructing a plurality of filter models based on the plurality of sets of model parameters, and performing filtering processes on the reference blocks based on the plurality of filter models to determine a plurality of filtered reference blocks; determining a prediction value of the current block based on the plurality of filtered reference blocks. The method of claim 1.

35. determining a prediction value of the current block based on the plurality of filtered reference blocks, performing a weighting calculation on the plurality of filtered reference blocks to determine a prediction value of the current block; 35. The method of claim 34.

36. decoding the codestream to determine an index value for the target model; determining a corresponding target filter from the plurality of filter models based on the index value of the target model; and performing a filtering process on the reference block based on the target filter to determine a predicted value of the current block.

35. The method of claim 34.

37. determining a plurality of sets of model parameters based on the first template and the matching template, classifying the reconstructed pixels in the first template and the matching template according to a predetermined method, respectively, to obtain a plurality of sets of sub-templates and a plurality of sets of sub-matching templates; determining the sets of model parameters based on the sets of sub-templates and the sets of sub-matching templates; 35. The method of claim 34.

38. decoding the codestream to determine a value of a first syntax element identification; if the first syntax element identification indicates that intra-template matching is applied to the current block, decoding the codestream to determine a value of a second syntax element identification; and determining a predicted value of the current block based on the filtered reference block by performing a filtering process on the reference block based on the model parameters, when the second syntax element identification information indicates that a filter model is applied to the current block. The method of claim 1.

39. and if the second syntax element identification information indicates that a filter model is not applied to the current block, setting a reconstructed pixel value in the reference block as a predicted value of the current block.

39. The method of claim 38.

40. determining a reconstructed value of the current block based on the predicted value of the current block, decoding the codestream to determine a residual for the current block; determining a reconstructed value of the current block based on the predicted value of the current block and a prediction difference of the current block; 40. The method of any one of claims 1 to 39.

41. A coding method applied to an encoder, comprising: determining a first template for the current block, and determining a matching template and a reference block; determining model parameters based on the first template and the matching template; performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; determining a prediction value for the current block based on the filtered reference block; determining a prediction difference for the current block based on a prediction value of the current block; method.

42. The step of determining a first template for the current block comprises: determining a template type for the current block; determining a first template for the current block based on a template type of the current block; 42. The method of claim 41.

43. The step of determining a template type of the current block comprises: determining a template type of the current block based on reference pixels of the current block; the reference pixels of the current block include at least one of a reference pixel to the left of the current block, a reference pixel to the upper side of the current block, a reference pixel to the upper left of the current block, a reference pixel to the lower left of the current block, and a reference pixel to the upper right of the current block; 43. The method of claim 42.

44. The step of determining a template type of the current block comprises: determining a template type of the current block to be a first value when the reference pixel to the left of the current block, the reference pixel to the upper neighbor of the current block, and the reference pixel to the upper left of the current block are all available; determining the template type of the current block to a second value if the reference pixel to the left of the current block is available; determining the template type of the current block to a third value if the reference pixel of the upper neighbor of the current block is available; determining a template type of the current block to be a fourth value if both the left neighbor reference pixel of the current block and the upper left neighbor reference pixel of the current block are available; determining a template type of the current block to be a fifth value if both the reference pixel of the left neighbor of the current block and the reference pixel of the lower left neighbor of the current block are available; determining the template type of the current block to a sixth value if both the reference pixel of the upper neighbor of the current block and the reference pixel of the upper right neighbor of the current block are available; 44. The method of claim 43.

45. The step of determining a matching template and a reference block includes: determining the matching template by performing template matching within a predetermined search area based on the first template; determining the reference block based on the matching template; 42. The method of claim 41.

46. The step of determining the matching template by performing template matching within a predetermined search area based on the first template includes: determining a target block vector by searching within the predetermined search area based on the first template, and determining the matching template based on the target block vector; 46. ​​The method of claim 45.

47. The step of determining a matching template and a reference block includes: determining motion parameters and corresponding reference blocks; determining the matching template based on the first template and the reference block; Accordingly, the method comprises: encoding the motion parameters and writing the resulting coded bits into a codestream.

42. The method of claim 41.

48. The step of determining a target block vector by searching within the predetermined search area based on the first template includes: performing a first search within the predetermined search area to determine the target block vector; or performing a second search within the predetermined search area to determine the target block vector; a search step size corresponding to the first search is greater than a search step size corresponding to the second search; 47. The method of claim 46.

49. The step of determining a target block vector by searching within the predetermined search area based on the first template includes: performing a first search within the predetermined search area to determine a first block vector; and determining an initial matching template based on the first block vector; determining a first search area based on the initial matching template, and performing a second search within the first search area to determine the target block vector; a search step size corresponding to the first search is larger than a search step size corresponding to the second search, and the first search area is smaller than the predetermined search area; 47. The method of claim 46.

50. The predetermined search area includes at least one sub-search area, and the step of searching within the predetermined search area based on the first template to determine a target block vector includes: performing a search within each of the at least one sub-search area to determine a best-fit block vector and corresponding matching cost value for each of the sub-search areas; determining an optimal block vector corresponding to a minimum matching cost value based on the optimal block vectors and corresponding matching cost values ​​of each of the sub-search regions; and determining the optimal block vector corresponding to the minimum matching cost value as the target block vector.

47. The method of claim 46.

51. The step of determining a target block vector by searching within the predetermined search area based on the first template includes: performing a first search within each of the at least one sub-search area to determine an optimal block vector for each of the sub-search areas and a corresponding second search area; performing region determination based on the best block vectors of each of the sub-search regions and the corresponding second search region to determine at least two target sub-search regions for the second search; performing a second search within the at least two target sub-search areas to determine optimal block vectors corresponding to the at least two target sub-search areas; and determining the optimal block vectors corresponding to the at least two target sub-search regions as the target block vectors.

51. The method of claim 50.

52. determining model parameters based on the first template and the matching template, the model parameters include coefficients of a target filter; 42. The method of claim 41.

53. determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; 53. The method of claim 52.

54. The method further includes a step in which the coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after processing by the target filter and a pixel reference value in the first template satisfies a first condition.

54. The method of claim 53.

55. The method further includes the step of: the first condition is that the first error is minimum.

55. The method of claim 54.

56. The method further includes the step of: the first condition being that the first error is within a first predetermined threshold range.

55. The method of claim 54.

57. The first condition further includes a step in which the change amount of the first error is within a second predetermined threshold range.

55. The method of claim 54.

58. determining coefficients of the target filter based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template, determining autocorrelation parameters based on pixel reference values ​​in the matching template; determining cross-correlation parameters based on pixel reference values ​​in the first template and pixel reference values ​​in the matching template; determining coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters; 54. The method of claim 53.

59. the pixel reference values ​​include at least one of pixel reconstruction values, pixel gradient values, and pixel position information; 54. The method of claim 53.

60. the number of coefficients of the target filter is equal to a first predetermined value; 53. The method of claim 52.

61. determining a number of coefficients of the target filter; encoding the number of coefficients of the target filter and writing the resulting coded bits into a codestream.

53. The method of claim 52.

62. The target filter is a one-dimensional or two-dimensional filter of a predetermined shape.

53. The method of claim 52.

63. determining the shape of the target filter; encoding the shape of the target filter and writing the resulting coded bits into a codestream.

53. The method of claim 52.

64. The step of performing a filtering process on the reference block based on the model parameters to determine a filtered reference block includes: performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter; determining the filtered reference block based on a first output value of the target filter; 53. The method of claim 52.

65. The step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes: calculating a product of pixel reconstruction values ​​of the reference block and corresponding coefficients of the target filter; setting a first output value of the target filter equal to the sum of n of the products, where n represents the number of coefficients of the target filter and n is a positive integer; 65. The method of claim 64.

66. The step of performing a filtering process on the reference block based on the model parameters to determine a first output value of the target filter includes: determining a first value in a first mapping relationship of pixel reconstruction values ​​of the reference block; calculating the product of the first value and a corresponding coefficient of the target filter; setting a first output value of the target filter equal to the sum of n of the products, where n represents the number of coefficients of the target filter and n is a positive integer; 65. The method of claim 64.

67. determining the filtered reference block based on a first output value of the target filter, determining a first offset value; performing an addition operation based on the first output value and the first offset value to determine the filtered reference block; 65. The method of claim 64.

68. The step of determining a first offset value includes: setting the first offset value equal to a second predetermined value; 68. The method of claim 67.

69. The step of determining a first offset value includes: determining the n+1 th coefficient of the target filter if the number of coefficients of the target filter is n; determining the first offset value based on the n+1 th coefficient and a second offset value; 68. The method of claim 67.

70. setting the second offset value equal to a third predetermined value; or setting the second offset value equal to a value in a second mapping relationship of pixel reconstruction values ​​of the reference block; 70. The method of claim 69.

71. determining a prediction value of the current block based on the filtered reference block, performing a first process on the filtered reference block to obtain a predicted value of the current block; 42. The method of claim 41.

72. the first processing further comprises setting a predicted value of the current block equal to the filtered reference block; 72. The method of claim 71.

73. The first processing further includes a step of clipping the filtered reference block to a predetermined range of values.

72. The method of claim 71.

74. determining sets of model parameters based on the first template and the matching template; constructing a plurality of filter models based on the plurality of sets of model parameters, and performing filtering processes on the reference blocks based on the plurality of filter models to determine a plurality of filtered reference blocks; determining a prediction value of the current block based on a plurality of filtered reference blocks; 42. The method of claim 41.

75. determining a prediction value of the current block based on the plurality of filtered reference blocks, performing a weighting calculation on the plurality of filtered reference blocks to determine a prediction value of the current block; 75. The method of claim 74.

76. determining a target filter from a plurality of filter models; and performing a filtering process on the reference block based on the target filter to determine a predicted value of the current block.

75. The method of claim 74.

77. determining a target model index value for indicating an index number of the target filter among the plurality of filter models; encoding the target model index values ​​and writing the resulting coded bits into a codestream.

77. The method of claim 76.

78. The step of determining a target filter from a plurality of filter models includes: determining an original value of the current block; performing a rate-distortion cost calculation based on the original value of the current block and a plurality of initial predicted values ​​of the current block to determine a rate-distortion cost value for each of the plurality of initial predicted values; determining a minimum rate-distortion cost value from the rate-distortion cost values ​​of each of the plurality of initial predictions; and determining the filter model corresponding to the minimum rate-distortion cost value as the target filter.

77. The method of claim 76.

79. determining a plurality of sets of model parameters based on the first template and the matching template, classifying the reconstructed pixels in the first template and the matching template according to a predetermined method, respectively, to obtain a plurality of sets of sub-templates and a plurality of sets of sub-matching templates; determining the sets of model parameters based on the sets of sub-templates and the sets of sub-matching templates; 75. The method of claim 74.

80. determining a value of a first syntax element identification information for indicating whether intra-template matching is applied to the current block; encoding the value of the first syntax element identification information and writing the resulting coded bits into a codestream.

42. The method of claim 41.

81. The step of determining a value of the first syntax element identification information comprises: If intra template matching is applied to the current block, determining a value of the first syntax element identification information to be a first value; and if intra-template matching is not applied to the current block, determining a value of the first syntax element identification information to a second value.

81. The method of claim 80.

82. If the first syntax element identification information indicates that intra template matching is applied to the current block, the method includes: determining a value of a second syntax element identification to indicate whether a filter model is applied to the current block; encoding the value of the second syntax element identification information and writing the resulting coded bits into a codestream.

81. The method of claim 80.

83. The step of determining the value of the second syntax element identification information comprises: determining a value of the second syntax element identification information to a first value if a filter model is applied to the current block; and if a filter model is not applied to the current block, determining a value of the second syntax element identification information to a second value.

83. The method of claim 82.

84. performing a filtering process on the reference block based on the model parameters to determine a filtered reference block; and determining a prediction value of the current block based on the filtered reference block, when a filter model is applied to the current block; If a filter model is not applied to the current block, a reconstructed pixel value in the reference block is used as a predicted value of the current block.

83. The method of claim 82.

85. determining a prediction difference for the current block based on a predicted value of the current block, determining an original value of the current block; determining a prediction difference for the current block based on the original value of the current block and the predicted value of the current block; 85. The method according to any one of claims 41 to 84.

86. A codestream generated by bit encoding based on encoding target information, The information to be encoded is the prediction difference of a current block, the number of coefficients of a target filter, the shape of the target filter, a value of a first syntax element identification information, and a value of a second syntax element identification information, wherein the first syntax element identification information is used to indicate whether intra-template matching is applied to the current block, and the second syntax element identification information is used to indicate whether a filter model is applied to the current block. Code stream.

87. a first determiner configured to determine a first template for the current block, and to determine a matching template and a reference block, and further configured to determine model parameters based on the first template and the matching template; a first filtering unit configured to perform a filtering process on the reference block based on the model parameters to determine a filtered reference block; a first prediction unit configured to determine a prediction value of the current block based on the filtered reference block; the first determination unit is further configured to determine a prediction difference of the current block based on a prediction value of the current block. Encoder.

88. 1. An encoder including a first memory and a first processor, the first memory is for storing a computer program executable on the first processor; The first processor, when executing the computer program, is adapted to perform the method of any one of claims 41 to 85. Encoder.

89. a second determiner configured to determine a first template for the current block, and to determine a matching template and a reference block, and further configured to determine model parameters based on the first template and the matching template; a second filtering unit configured to perform a filtering process on the reference block based on the model parameters to determine a filtered reference block; a second prediction unit configured to determine a prediction value of the current block based on the filtered reference block; the second determination unit is further configured to determine a reconstructed value of the current block based on a predicted value of the current block. decoder.

90. a decoder including a second memory and a second processor, the second memory is for storing a computer program executable on the second processor; The second processor, when executing the computer program, is adapted to perform the method of any one of claims 1 to 40. decoder.

91. storing a computer program which, when executed, implements the method according to any one of claims 1 to 40 or the method according to any one of claims 41 to 85, A computer-readable storage medium.