Decoding method, encoding method, decoder, and encoder

The proposed decoding and encoding methods enhance video compression efficiency by using a first flag and index to improve predicted block accuracy, addressing the limitations of existing standards in handling high-resolution Internet videos.

JP2026511750APending Publication Date: 2026-04-14GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing digital video compression standards face challenges in improving compression efficiency to handle the increasing demands of high-resolution Internet videos.

Method used

Introduce a decoding method and encoding method that utilize a first flag and a first index to determine candidate block vectors for intra-template prediction, enhancing the accuracy of predicted blocks through filtering.

Benefits of technology

Improves decoding performance by accurately determining predicted blocks, thereby enhancing the overall encoding and decoding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2026511750000001_ABST
    Figure 2026511750000001_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a decoding method, an encoding method, a decoder, and an encoder, the decoding method comprising: obtaining a first flag and a first index to indicate whether or not to filter; determining a first candidate list consisting of candidate block vectors (BVs) of the current block based on a first prediction mode corresponding to an intra-template prediction; and determining a predicted block of the current block based on the first flag and a candidate BV indicated by the first index in the first candidate list. By introducing the first flag and the first index, the present application makes it possible to determine a predicted block of the current block based on a candidate BV indicated by the first index and the first flag, thereby improving the accuracy of the predicted block and further improving the decoding performance of the decoder.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0005] , , , , ,

[0001] This application relates to the technical field of encoding and decoding, and in particular, to a decoding method, an encoding method, a decoder, and an encoder.

Background Art

[0002] Digital video compression technology is mainly for compressing huge digital video data to facilitate transmission and storage. With the rapid increase of Internet videos and the increasing requirements for resolution by people, although the existing digital video compression standards can realize video decompression technology, in order to improve the compression efficiency, there is still a need for a better digital video decompression technology.

Summary of the Invention

[0003] Embodiments of this application provide a decoding method, an encoding method, a decoder, and an encoder that can improve encoding and decoding performance.

[0004] In a first aspect, embodiments of this application provide a decoding method, the method including: obtaining a first flag and a first index for indicating whether to perform filtering; determining a first candidate list consisting of candidate block vectors (BVs) of a current block based on a first prediction mode corresponding to intra-template prediction; determining a predicted block of the current block based on the first flag and a candidate BV indicated by the first index in the first candidate list.

[0005] In a second aspect, embodiments of this application provide an encoding method, the method including: determining at least one candidate list consisting of candidate block vectors (BVs) of a current block based on a first prediction mode corresponding to intra-template prediction; Based on the aforementioned at least one candidate list, a first flag to indicate whether or not to filter, and a first index to indicate a candidate BV within the first candidate list of the aforementioned at least one candidate list are determined. This includes encoding the first flag and the first index.

[0006] In a third aspect, an embodiment of the present application provides a decoder, the decoder is An acquisition unit configured to acquire a first flag and a first index to indicate whether or not to filter, A first decision unit is configured to determine a first candidate list consisting of candidate block vectors (BVs) of the current block based on a first prediction mode corresponding to intra-template prediction, The system comprises a first flag and a second decision unit configured to determine a predicted block for the current block based on a candidate BV indicated by the first index in the first candidate list.

[0007] In a fourth aspect, an embodiment of the present application provides an encoder, the encoder is, A first decision unit is configured to determine at least one candidate list consisting of candidate block vectors (BVs) of the current block, based on a first prediction mode corresponding to intra-template prediction, A second decision unit is configured to determine a first flag for indicating whether or not to filter based on the at least one candidate list, and a first index for indicating a candidate BV within the first candidate list of the at least one candidate list. The system comprises an encoding unit configured to encode the first flag and the first index.

[0008] In a fifth aspect, an embodiment of the present application provides a decoder, the decoder is A processor configured to run computer programs, The system comprises a computer-readable storage medium in which computer program instructions are stored, and the computer instructions are suitable for executing the decoding method in the first embodiment or each of its implementations when loaded and executed by a processor.

[0009] In one implementation, the processor is one or more, and the memory is one or more.

[0010] In one implementation, the computer-readable storage medium may be integrated with the processor, or it may be provided separately from the processor.

[0011] In the sixth aspect, an embodiment of the present application provides an encoder, the encoder is, A processor configured to run computer programs, The system comprises a computer-readable storage medium in which computer program instructions are stored, and the computer instructions are suitable for executing the encoding method in the second embodiment or each of its implementations when loaded and executed by a processor.

[0012] In one implementation, the processor is one or more, and the memory is one or more.

[0013] In one implementation, the computer-readable storage medium may be integrated with the processor, or it may be provided separately from the processor.

[0014] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium in which computer instructions are stored, and when the computer instructions are read and executed by the processor of the computer equipment, the computer equipment causes the computer equipment to execute the decoding method in the first aspect or the encoding method in the second aspect.

[0015] In an eighth aspect, an embodiment of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions to cause the computer device to execute the decoding method in the first aspect or the encoding method in the second aspect described above.

[0016] In a ninth aspect, an embodiment of the present application provides a bitstream, and the bitstream is the bitstream in the method described in the first aspect above or the bitstream generated by the method described in the second aspect above.

[0017] Based on the above technical solutions, the present application can introduce a first flag and a first index, and based on a candidate BV indicated by the first index and the first flag, determine a predicted block of the current block, improve the accuracy of the predicted block, and further improve the decoding performance of the decoder.

Brief Description of the Drawings

[0018] [Figure 1] It is a schematic block diagram of an encoding framework according to an embodiment of the present application. [Figure 2] It is a schematic block diagram of a decoding framework according to an embodiment of the present application. [Figure 3] It is a diagram showing an example of intra prediction according to an embodiment of the present application. [Figure 4] It is a diagram showing an example of MRL according to an embodiment of the present application. [Figure 5] It is a diagram showing an example of an intra prediction mode according to an embodiment of the present application. [Figure 6] It is a diagram showing another example of an intra prediction mode according to an embodiment of the present application. [Figure 7]It is a diagram showing yet another example of the intra prediction mode according to an embodiment of the present application. [Figure 8] It is a diagram showing an example of the wide-angle mode according to an embodiment of the present application. [Figure 9] It is a diagram showing an example of screen content according to an embodiment of the present application. [Figure 10] It is a diagram showing an example of TM according to an embodiment of the present application. [Figure 11] It is a diagram showing an example of intraTMP according to an embodiment of the present application. [Figure 12] It is a diagram showing an example of a candidate BV in a candidate list according to an embodiment of the present application. [Figure 13] It is a diagram showing an example of a filter according to an embodiment of the present application. [Figure 14] It is a schematic diagram of the training of filter coefficients according to an embodiment of the present application. [Figure 15] It is a schematic flowchart of a decoding method according to an embodiment of the present application. [Figure 16] It is a schematic flowchart of an encoding method according to an embodiment of the present application. [Figure 17] It is a schematic block diagram of a decoder according to an embodiment of the present application. [Figure 18] It is a schematic block diagram of an encoder according to an embodiment of the present application. [Figure 19] It is a schematic block diagram of an electronic device according to an embodiment of the present application.

Mode for Carrying Out the Invention

[0019] Hereinafter, referring to the drawings, the technical solutions in the embodiments of the present application will be described.

[0020] The solutions provided in the embodiments of this application may be applied to the field of digital video coding, including, but not limited to, the fields of image coding and decoding, video coding and decoding, hardware video coding and decoding, dedicated circuit video coding and decoding, and real-time video coding and decoding. Furthermore, the solutions provided in the embodiments of this application can be combined with Audio Video Coding Standards (AVS), second-generation AVS standards (AVS2), or third-generation AVS standards (AVS3). Examples include the H.264 / Audio Video Coding (AVC) standard, the H.265 / High Efficiency Video Coding (HEVC) standard, and the H.266 / Versatile Video Coding (VVC) standard. In addition, the solutions provided in the embodiments of this application may be used for both lossy and lossless compression of images. Here, the lossless compression may be visually lossless compression or mathematically lossless compression.

[0021] Video coding and decoding standards can employ a block-based hybrid coding framework, and the basic process of a video codec is as follows:

[0022] On the encoding side, the image of one frame is divided into blocks, intra-prediction or inter-prediction is used on the current block to generate a predicted block of the current block, the predicted block is subtracted from the original block of the current block to obtain a residual block, transformation and quantization are performed on the residual block to obtain a quantization coefficient matrix, the quantization coefficient matrix is ​​entropy encoded and output to a bitstream. On the decoding side, intra-prediction or inter-prediction is used on the current block to generate a predicted block of the current block, the bitstream is analyzed to obtain a quantization coefficient matrix, inverse quantization and inverse transformation are performed on the quantization coefficient matrix to obtain a residual block, and the predicted block and residual block are added to obtain a reconstructed block. The reconstructed block constitutes a reconstructed image, and the reconstructed image is loop-filtered based on the image or based on the blocks to obtain a decoded image. The encoding side also requires the same operations as the decoding side to obtain the decoded image. The decoded image can be used as a reference frame for inter-prediction of subsequent frames. Block partitioning information, mode information such as prediction, transformation, quantization, entropy coding, and loop filtering, or parameter information determined on the encoding side, must be output to the bitstream as needed. The decoding side analyzes the existing information to determine the same block partitioning information, mode information such as prediction, transformation, quantization, entropy coding, and loop filtering, or parameter information as the encoding side, thereby ensuring that the decoded image obtained on the encoding side is the same as the decoded image obtained on the decoding side. The decoded image obtained on the encoding side is usually also called the reconstructed image. During prediction, the current block can be divided into prediction units, and during transformation, the current block can be divided into transformation units, and the division of the prediction units and transformation units may differ. The above description is the basic process of a video codec in a block-based hybrid coding framework, and as technology advances, some modules or steps of the framework or process may be optimized.This invention can be applied to, but is not limited to, the basic process of a video codec in the aforementioned block-based hybrid coding framework.

[0023] Figure 1 is a schematic block diagram of the coding framework 100 according to an embodiment of the present application.

[0024] As shown in Figure 1, the coding framework 100 may include an intra-prediction unit 180, an inter-prediction unit 170, a residual unit 110, a transform and quantization unit 120, an entropy coding unit 130, an inverse transform and inverse quantization unit 140, and a loop filtering unit 150. Optionally, the coding framework 100 may further include a decoded image buffer unit 160.

[0025] Here, the intra-prediction unit 180 or inter-prediction unit 170 can predict the image block to be encoded and output the predicted block. The residual unit 110 can calculate the residual block, i.e., the difference between the predicted block and the image block to be encoded, based on the predicted block and the image block to be encoded. The transformation and quantization unit 120 is configured to perform operations such as transformation and quantization on the residual block to remove information that is not sensitive to the human eye and to remove visual redundancy. Optionally, the residual block before transformation and quantization by the transformation and quantization unit 120 may be called a time-domain residual block, and the time-domain residual block after transformation and quantization by the transformation and quantization unit 120 may be called a frequency residual block or frequency-domain residual block. The entropy coding unit 130 receives the transformation / quantization coefficients output from the transformation and quantization unit 120 and can output a bitstream based on the transformation / quantization coefficients. For example, the entropy coding unit 130 can remove character redundancy based on the target context model and the probability information of the binary bitstream. For example, the entropy coding unit 130 may be used for context-based adaptive binary arithmetic coding (CABAC). The entropy coding unit 130 may also be called a header information coding unit. Optionally, in this application, the image block to be coded may also be called an original image block or a target image block; the prediction block may also be called a prediction image block or an image prediction block, or a prediction signal or prediction information; and the reconstruction block may also be called a reconstruction image block or an image reconstruction block, or a reconstruction signal or reconstruction information. Furthermore, on the coding side, the image block to be coded may also be called a coding block or a coded image block; and on the decoding side, the image block to be coded may also be called a decoding block or a decoding image block. The image block to be coded may be a CTU or a CU.

[0026] The encoding framework 100 calculates the residual between the predicted block and the image block to be encoded to obtain a residual block, and transmits the residual block to the decoding side after going through processes such as transformation and quantization. Correspondingly, the decoding side receives the bitstream, decodes the bitstream, obtains a residual block through steps such as inverse transformation and inverse quantization, and superimposes the residual block onto the predicted block obtained by the decoding side to obtain a reconstructed block.

[0027] It should be explained that the inverse transform and inverse quantization unit 140, the loop filtering unit 150, and the decoding image buffer unit 160 within the encoding framework 100 can be used to constitute a single decoder. That is, the intra-prediction unit 180 or inter-prediction unit 170 can predict the image blocks to be encoded based on existing reconstruction blocks, thereby ensuring that the encoding and decoding sides have a consistent understanding of the reference image. In other words, the encoder can copy the decoder's processing loop and thus generate the same predictions as the decoding side. Specifically, the quantization transformation coefficients are inversely transformed and inversely quantized by the inverse transform and inverse quantization unit 140, copying the approximate residual blocks from the decoding side. After being added to the prediction blocks, the approximate residual blocks pass through the loop filtering unit 150 to smoothly remove effects such as block effects resulting from block processing and quantization. The image blocks output from the loop filtering unit 150 can be stored in the decoding image buffer unit 160 for subsequent image prediction.

[0028] It should be understood that Figure 1 is merely one example of the present application and should not be interpreted as limiting the scope of the present application.

[0029] For example, the loop filtering unit 150 within the coding framework 100 may include a deblocking filter (DBF) and sample adaptive offset (SAO) filtering. The role of the DBF is the deblocking effect, and the role of the SAO is the Delling effect. In another embodiment of the present invention, the coding framework 100 may employ a neural network-based loop filtering algorithm to improve the video compression efficiency. Alternatively, the coding framework 100 may be a deep learning neural network-based video coding hybrid framework. In one implementation, a convolutional neural network-based model can be employed to calculate the results after pixel filtering, based on the deblocking filter and sample adaptive offset filtering. The network structures for the luminance and chromaticity components of the loop filtering unit 150 may be the same or different. Since the luminance component contains more visual information, the luminance component may also be used to guide the filtering of the chromaticity component and improve the reconstruction quality of the chromaticity component.

[0030] Figure 2 is a schematic block diagram of the decoding framework 200 according to an embodiment of the present application.

[0031] As shown in Figure 2, the decoding framework 200 may include an entropy decoding unit 210, an inverse transform inverse quantization unit 220, a residual unit 230, an intra prediction unit 240, an inter prediction unit 250, a loop filtering unit 260, and a decoded image buffer unit 270. Here, the entropy decoding unit 210 receives and analyzes a bitstream to obtain a prediction block and a frequency-domain residual block. The inverse transform inverse quantization unit 220 performs steps such as inverse transform and inverse quantization on the frequency-domain residual block to obtain a time-domain residual block. The residual unit 230 can obtain a reconstructed block by superimposing the prediction block predicted by the intra prediction unit 240 or the inter prediction unit 250 onto the time-domain residual block after inverse transform and inverse quantization by the inverse transform inverse quantization unit 220.

[0032] For the sake of understanding, the following is an explanation of the contents related to this application.

[0033] (1) Intra prediction Strong spatial correlations exist between adjacent parts and adjacent pixels within an image, and intra-prediction is a prediction method that utilizes the spatial correlation between encoded / decoded pixels around the current block and pixels within the current block. For example, as shown in Figure 3, the white 4x4 block is the current block, and the gray pixels in the leftmost column and topmost row of the current block are the reference pixels of the current block. Intra-prediction uses these reference pixels to predict the current block. All of these reference pixels may be obtainable, that is, they may all be encoded / decoded. Some may not be obtainable; for example, if the current block is at the far left of the entire frame, the reference pixels to the left of the current block may not be obtainable. Or, if the lower left portion of the current block is not encoded / decoded when the current block is encoded / decoded, the reference pixels in the lower left may also not be obtainable. If reference pixels are not obtainable, padding may be performed using obtainable reference pixels or specific values ​​or methods, or not.

[0034] In the Multiple Reference Line (MRL) intraprediction method, encoding efficiency can be improved by using more reference pixels. Figure 4 shows an example of MRL according to an embodiment of the present invention, and as shown in Figure 4, the codec can also use four reference rows / columns as reference pixels for the current block. Here, these four reference rows / columns can be divided into segments A to F.

[0035] Intra prediction has multiple prediction modes, and as shown in Figure 5, H.264 has nine modes for intra prediction of a 4x4 block. In mode 0, the upper pixels of the current block are copied vertically to the current block to be used as the predicted value; in mode 1, the left reference pixels are copied horizontally to the current block to be used as the predicted value; in mode 2 (DC mode), the average of eight points A-D and I-L is used as the predicted value for all points; and in modes 3-8, the reference pixels are copied to the corresponding positions in the current block at specific angles. Since some positions in the current block may not perfectly correspond to the reference pixels, it may be necessary to use the weighted average of the reference pixels or the interpolated subpixels of the reference pixels.

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

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

[0038] Not all motion in video is this simple; even motion considered as translation involves subtle changes over time, including slight deformations, changes in brightness, and changes in noise. To achieve better prediction effectiveness for the current block, multiple reference blocks can be used for prediction. For example, in commonly used bidirectional prediction, two reference blocks are used to predict the current block. One forward reference block and one backward reference block can be used as the two reference blocks, and later it became permissible to use either both forward reference blocks or both backward reference blocks. So-called forward refers to the time corresponding to the reference image being before the current frame, and backward refers to the time corresponding to the reference image being after the current frame. Alternatively, forward refers to the position of the reference image in the video being before the current frame, and backward refers to the position of the reference image in the video being after the current frame. Alternatively, forward refers to the POC (picture order count) of the reference image being smaller than the POC of the current frame, and backward refers to the POC of the reference image being larger than the POC of the current frame. Future video encoding and decoding standards may support prediction of multiple reference blocks. A simple method for generating a prediction block using two reference blocks is to obtain the prediction block by averaging the pixels at corresponding positions in the two reference blocks. To obtain better prediction effects, weighted averaging, such as BCW (Bi-prediction with CU-level weight) used in VVC, can also be used. VVC's GPM (Geometric partitioning mode) can also be understood as a special type of bidirectional prediction. To use bidirectional prediction, it is necessary to find two reference blocks, which requires information from two sets of reference images and motion vector information.

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

[0040] (3) Intra Block Copy (IBC) Because IBC can significantly improve the compression efficiency of screen content coding, it is used for screen content coding in all HEVC-VVC encodings. Unlike camera-captured content, screen content is generated by a computer, is free of noise, contains text and computer graphics, and has clear boundaries. For example, as shown in Figure 9, screen content contains a large amount of duplicate content.

[0041] IBC can be considered an application of the inter-prediction method to intra-prediction. As mentioned above, in inter-prediction, a reference block on the reference image is used as the predicted block for the current block, and the reference image is not the current image. On the other hand, IBC finds a single block from the encoded / decoded or reconstructed portion of the current image to be used as the predicted block for the current block. In some regions, IBC is called intra-picture block compensation or current picture referencing (CPR).

[0042] In IBC, the positional difference between the current block and the reference block is represented by a block vector (BV), which is similar to the MV in interpretation. The encoder determines the best matching block for the current block within the search range using a block matching method and encodes the BV. There are various methods for encoding the BV, which will not be explained again here.

[0043] IBC can be considered either a type of intra-prediction method or a separate prediction method independent of intra-prediction and inter-prediction, but this will not be discussed in detail here.

[0044] (4) Template matching (TM) Initially, the mTM method is used for inter-block prediction, which utilizes the correlation between adjacent pixels and uses a portion of the area surrounding the current block as a template. When encoding and decoding is performed on the current block, the left and top sides are already encoded according to the encoding order. Of course, when implementing existing hardware decoders, it is not always guaranteed that the left and top sides of the current block will already be encoded and decoded when decoding is started. Of course, what is being referred to here is inter-blocks, and in HEVC, for example, when an inter-encoded block generates a prediction block, the surrounding reconstructed pixels are not required, so the inter-block prediction process can be performed in parallel. However, an intra-encoded block requires the reconstructed pixels on the left and top to be used as reference pixels. Theoretically, the left and top sides are obtainable, meaning they can be realized with appropriate adjustments in the hardware design. On the other hand, the right and bottom sides are not obtainable with the encoding order of video standards such as VVC.

[0045] Figure 10 shows an example of TM according to the embodiment of the present application.

[0046] As shown in Figure 10, the rectangular areas to the left and above the current block are set as templates. The height of the left template portion is generally the same as the height of the current block, and the width of the upper template portion is generally the same as the width of the current block, although they may be different. The motion information or motion vector of the current block is determined by finding the optimal matching position of the template within the reference frame. Roughly speaking, this process starts a search within a certain range around the starting position in a given reference frame. Search rules such as the search range and search step length can be set in advance. Each time the block moves to a position, the degree of matching between the template corresponding to this position and the template around the current block is calculated. The so-called degree of matching can be evaluated using distortion costs such as the sum of absolute difference (SAD), sum of absolute transformed difference (SATD), and mean-squared error (MSE). The transformation commonly used for SATD is the Hadamard transformation. Smaller values ​​for SAD, SATD, MSE, etc., indicate a higher degree of matching. The cost is calculated using the predicted block of the template corresponding to this position and the reconstructed block of the template around the current block. In addition to pixel-level position searching, sub-pixel position searching can also be performed, and the motion information of the current block is determined based on the position with the highest degree of matching obtained through searching. Due to the correlation between adjacent pixels, motion information that fits the template may also be motion information that fits the current block. Of course, the template matching method is not necessarily applicable to all blocks, so several methods can be used to determine whether or not to use the above template matching method for the current block. For example, a control switch can be used for the current block to indicate whether or not to use the template matching method. One typical template matching technique is decoder-side motion vector derivation (DMVD).Both the encoder and decoder can derive motion information or find better motion information based on the original motion information by using templates to perform searches. There is no need to transmit specific motion vectors or differences in motion vectors; the encoder and decoder perform searches using the same rules, guaranteeing consistency in encoding and decoding. While template matching can improve compression performance, it introduces a certain degree of decoder complexity because the decoder also needs to perform a "search."

[0047] (5) Intra template matching prediction (intraTMP) intraTMP can be considered a technique that combines IBC and TM. As mentioned above, using TM for interpretation reduces the overhead of MV coding, and similarly, using TM for IBC reduces the overhead of BV coding. As an example, there is no need to encode BV, and the matching block found by TM is directly used as the prediction block in intraTMP mode for the current block.

[0048] As an example of intraTMP, as shown in Figure 11, the encoder (or decoder) selects the reconstructed pixels of the L-shaped region adjacent to the current encoded block as a template, searches for the most similar template within the specified reconstructed region of the current frame, and uses the reconstructed block corresponding to the most similar template as the matching block and the prediction block for the current encoded block. For example, R1 to R4 in the figure are search regions available in IntraTMP mode. For example, matching blocks can be searched point by point sequentially using a raster scan in R1 to R4.

[0049] One of the key reasons why IBC significantly improves the compression efficiency of screen content encoding is that many overlapping blocks can be found within screen content, and screen content typically has sharp boundaries and, in terms of color (luminance and chromaticity), has large areas of the same color (luminance and chromaticity). In contrast, this situation rarely exists in camera-captured content, and the presence of noise in camera-captured content is unavoidable. Some areas of camera-captured content appear to have uniform color at first glance, but there are slight variations in luminance and chromaticity within those areas, and camera-captured content rarely has sharp boundaries. Also, camera-captured content certainly contains blocks that are almost identical. The reason it is almost identical is that it is difficult to find perfectly identical blocks due to noise, subtle changes in luminance, perspective angles, etc. However, it cannot be denied that overlapping textures exist in camera-captured content.

[0050] Generally, intraTMP uses the best-matching block found through template matching as the final predicted block. In other words, generally, when decoding the current block, there is a flag that determines whether or not to use intraTMP on the current block. If intraTMP is used on the current block, the decoder uses the template matching method to find one best-matching block and uses the value of the best-matching block as the predicted value of the current block. It should be noted that although templates have a strong correlation with the current block, templates are not inherently the current block, so the best-matching block found in the template (actually, the position of the current block corresponding to the best-matching block in the template) is not necessarily the best-matching block of the current block. However, since the current block does not exist when the decoder searches, it has no choice but to use the best-matching block found in the template as the best-matching block found by intraTMP.

[0051] (6) Multiple intraTMP candidates Either set N candidates in intraTMP, or set a candidate list of length N, intraTmpCandList[N]. When encoding, if intraTMP is used for the current block, after encoding a flag, one index must be encoded to determine which block from the N candidates was selected for the current block. Accordingly, the decoding syntax is shown as follows, where intra_tmp_flag is the flag of intraTMP, and if intra_tmp_flag is true, continue parsing intra_tmp_idx, where intra_tmp_idx represents the index of the selected candidate.

[0052] intra_tmp_flag If(intra_tmp_flag) { intra_tmp_idx }

[0053] The decoder uses the block corresponding to intraTmpCandList[intra_tmp_idx] as the block selected in intraTMP. Alternatively, the decoder uses the BV corresponding to intraTmpCandList[intra_tmp_idx] as the BV selected in intraTMP.

[0054] And here is an example of how to construct intraTmpCandList.

[0055] In intraTMP, each time a BV is obtained through a search, the cost in the template indicated by that BV is calculated. The template cost is generally the matching cost between the template of the current block and the template of a block of the same size as the current block, determined by the current BV. This cost may be SAD, SATD, SSE, etc. IntraTMP can sort the blocks or BVs obtained through the search according to the order of these costs, and the N candidates at the top are the N candidates in intraTmpCandList. Alternatively, computational complexity can be saved by keeping only the top N candidates with the minimum cost and directly discarding candidates with a rank higher than N.

[0056] Generally, blocks corresponding to adjacent BVs are close to each other. This tendency is especially pronounced when BVs support sub-pixel accuracies such as 1 / 2, 1 / 4, 1 / 8, and 1 / 16. Therefore, sorting solely according to cost in the template without any control can lead to multiple candidates concentrating within a very narrow range. Consequently, some control is needed to avoid excessive concentration of candidate BVs within intraTmpCandList.

[0057] One way to address this is as follows:

[0058] During the search process, not all possible BVs are searched sequentially. For example, the usual search order is from left to right and from top to bottom. Generally, BVs are searched sequentially on a pixel-by-pixel basis. For example, if the currently searched BV is (x0, y0), and the search range boundary has not been reached, the next BV is (x0+1, y0). In contrast, a sparse search can be performed first. For example, when searching for BVs on a pixel-by-pixel basis, if the currently searched BV is (x0, y0), and the search range boundary has not been reached, the next BV is (x0+4, y0). In other words, template matching is performed every certain number of pixels, or every certain step length. The step length here can be a predetermined value such as 2, 4, or 8. Of course, the same process can be performed in the vertical direction. First, the N BVs with the minimum cost are found. Next, based on the N BVs with the minimum cost, improvements are made in small increments for each BV. For example, if the search interval is 4 pixels, the improvement range can be set to 4x4, the improved BV can be used in place of the original BV, and the N candidates can be rearranged again. In this way, N BV candidates that are a certain distance apart can be obtained.

[0059] For example, if we set N to 3, we can make improvements using the following method.

[0060] In the first step, First, the first search is performed according to a predetermined step length, and as shown in Figure 12(a), the upper left corner of the block being searched is indicated by the gray dot. The three rearranged BVs are found, and as shown in Figure 12(b), the upper left corner of the corresponding block is indicated by the black dot. Here, the horizontal step length is 4 and the vertical step length is 4.

[0061] In the second step, A second search is performed based on the three rearranged BVs. This time, the search area is 4x4, and as shown by the green dots in the diagram, the BV with the minimum cost is found within each 4x4 BV and is used in place of the original BV to participate in the rearrangement of intraTmpCandList. Of course, if the BV with the minimum cost remains the original BV, another rearrangement is unnecessary.

[0062] If sub-pixel precision is supported, the subdivision of subpixels into BV can be continued in subsequent steps. For example, based on the BV of each pixel selected in the second step, a search for half a pixel can be performed within a 1-pixel range in all directions (up, down, left, and right).

[0063] It is important to note that the candidate list is constructed on both the encoding and decoding sides, thus guaranteeing that the candidate list obtained on the encoding side matches the candidate list obtained on the decoding side.

[0064] (7) Method for binarizing Intra_tmp_idx Since intraTmpCandList is a sorted list, statistically, candidates closer to the beginning of the list have a higher probability of being selected. Therefore, variable-length coding can be set up for the binarization and de-binarization of intra_tmp_idx, or a truncated unary code can be used. For example, the variable-length coding schemes are shown in Table 1.

[0065] [Table 1]

[0066] Of course, if there is no significant difference in probability, fixed-length encoding or truncated binary can be used.

[0067] When N is relatively large, the probability of the first candidate is high, the probability decreases as you move further back, and the probabilities tend to get closer and closer as you move further back. Therefore, the first codeword is short, the second codeword is long, and the second candidates can use the same codeword length. For example, encoding can be performed using the method shown in Table 2.

[0068] [Table 2]

[0069] As shown in Table 2, assuming N is 5, indices 3-6 use codewords of the same length, indices 7-14 use codewords of the same length, and x in the table above is obtained by the truncated binary.

[0070] (8) intraTMP filtering In the intraTMP method described above, the prediction block is generated directly using the reference block. In other words, if the determined BV has pixel-level precision, the value of the corresponding position on the reference block is directly used as the value of the corresponding position on the prediction block. If the determined BV has sub-pixel precision, the value of the corresponding position obtained by interpolation filtering is directly used as the value of the corresponding position on the prediction block. After directly generating the prediction block, filtering operations can be performed on the predicted values ​​to further improve the prediction block.

[0071] A single block-level flag can be used to indicate whether or not to apply the filtering process to the current block.

[0072] Filters can take various forms. An example of a possible filter format is shown below.

[0073] predC=c0C+c1N+c2S+c3E+c4W+c5B.

[0074] Here, the filter uses the pixel to be filtered and the adjacent pixels above, below, to the left and to the right of it to form a cross shape as shown in Figure 13. Here, C is the pixel to be filtered, N is the pixel above it, S is the pixel below it, W is the pixel to its left, E is the pixel to its right, and B (bias) is a fixed value. For example, B is the midpoint within the pixel value range; that is, if the pixel value is the maximum value of 10 bits, 1023, then B is set to 512. c0, c1, c2, c3, c4, and c5 are the filter coefficients.

[0075] Furthermore, as a method for determining the filter coefficients, the filter coefficients are trained using the template of the reference block and the template of the current block. For example, as shown in Figure 14, if intraTMP uses a template with a top height of 4 and a left width of 4, the template used to train the filter can also use the same size, and the area exceeding the reference block template can be filled in with padding from the reference block template, so no additional bandwidth is required.

[0076] Furthermore, as a method for training the filter coefficients, a set of coefficients is calculated that minimizes the mean squared error (MSE) between the filtered reference block template and the current block template.

[0077] When using intraTMP filtering on the current block, filtering is performed on the predicted block directly obtained based on the reference block. One method is to sequentially filter each pixel from left to right and top to bottom. The filtered value is then used as the predicted value.

[0078] It should be noted that in the intraTMP multiple candidate method, a template is used to select a few promising candidates from a large number of possible BVs, and the encoder selects one candidate to determine the reference block or predicted block of the current block. Due to the correlation between the current block and the template, the template can effectively filter out most irrational BVs. On the other hand, the encoder can make more accurate decisions than the decoder because it has access to the original pixel values ​​of the current block. In this way, better compression efficiency can be achieved by utilizing the cooperation between the encoder and decoder. IntraTMP filtering can use a template to train the filter coefficients and make improvements based on the original prediction values ​​of intraTMP.

[0079] Figure 15 is a schematic flowchart of the decoding method 300 according to an embodiment of the present application. It should be understood that the decoding method 300 can be performed by a decoder. For example, it can be applied to the decoding framework 200 shown in Figure 2. For the sake of explanation, an encoder will be used as an example below.

[0080] As shown in Figure 15, the decoding method 300 may include some or all of the following steps.

[0081] In step S310, the decoder obtains a first flag and a first index to indicate whether or not to filter.

[0082] For example, the first flag may be a sequence-level flag, an image-level (i.e., frame-level) flag, a slice-level flag, or an image block-level flag.

[0083] In step S320, the decoder determines a first candidate list consisting of candidate block vectors (BVs) for the current block based on a first prediction mode corresponding to intra-template prediction.

[0084] Exemplary, the first prediction mode may be the IntraTMP mode described above.

[0085] In step S330, the decoder determines the predicted block of the current block based on the first flag and the candidate BV indicated by the first index in the first candidate list.

[0086] In this embodiment, by introducing a first flag and a first index, the predicted block of the current block can be determined based on the candidate BV indicated by the first index and the first flag, thereby improving the accuracy of the predicted block and further improving the decoding performance of the decoder.

[0087] In some embodiments, step S310 is, To obtain the second flag, If the second flag indicates that the current block will be predicted using the first prediction mode, then obtaining the first flag and the first index may include:

[0088] Exemplary, the decoder decodes the bitstream to obtain the second flag, and if the second flag indicates that the first prediction mode is used for prediction, the decoder decodes the bitstream to obtain the first flag and the first index; otherwise, the decoder employs another prediction mode to obtain the predicted block. The second flag may be a sequence-level flag, an image-level (i.e., frame-level) flag, a slice-level flag, or an image block-level flag.

[0089] For example, a value of 0 for the second flag indicates that the prediction will be made using the first prediction mode, and a value of 1 for the second flag indicates that the prediction will be made without using the first prediction mode. Alternatively, a value of 1 for the second flag indicates that the prediction will be made using the first prediction mode, and a value of 0 for the second flag indicates that the prediction will be made without using the first prediction mode. Of course, this can also be indicated by other numerical values, and this application is not limited thereto.

[0090] Of course, the second flag can implement the corresponding instruction function by other means, and this invention is not limited thereto.

[0091] For example, if the value of the second flag is "true", it indicates that the prediction will be made using the first prediction mode, and if the value of the second flag is "false", it indicates that the prediction will be made without using the first prediction mode.

[0092] In some embodiments, step S320 is, The decoder may first perform template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs, and then determine the first candidate list based on the plurality of candidate BVs.

[0093] For example, when the decoder performs template matching on the current block based on the first prediction mode, it can perform template matching on the current block according to predetermined parameters (e.g., at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs. Alternatively, it can also perform template matching on the current block according to parameters corresponding to the first flag (e.g., at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs.

[0094] For example, when the decoder determines the first candidate list based on the plurality of candidate BVs, it may construct the first candidate list based on the plurality of candidate BVs according to a predetermined construction method, or it may construct the first candidate list based on the plurality of candidate BVs according to a construction method corresponding to the first flag.

[0095] It should be explained that whether the decoder performs template matching on the current block according to the parameters corresponding to the first flag (e.g., at least one of the search range, search step length, search order, and number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs, or constructs the first candidate list based on the multiple candidate BVs according to the construction method corresponding to the first flag, the first candidate list determined by the decoder when the first flag indicates filtering is different from the first candidate list determined by the decoder when the first flag indicates not filtering.

[0096] In some embodiments, the decoder performs template matching on the current block according to the parameters corresponding to the first flag based on the first prediction mode to obtain the plurality of candidate BVs.

[0097] In other words, different values ​​of the first flag correspond to different parameters.

[0098] In this embodiment, when the decoder performs template matching on the current block based on the first prediction mode, taking the first flag into consideration, the decoder performs template matching on the current block according to the parameter corresponding to the first flag and obtains the multiple candidate BVs, thereby ensuring that the first candidate list used by the decoder is a candidate list adapted to the first flag, and further improving the decoding performance of the decoder.

[0099] Of course, in another alternative embodiment, different values ​​of the first flag correspond to the same parameter. For example, regardless of the value of the first flag, the decoder can perform template matching on the current block according to predetermined parameters to obtain the multiple candidate BVs.

[0100] In some embodiments, the parameter corresponding to the first flag includes at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list.

[0101] Of course, in other alternative embodiments, the parameter corresponding to the first flag may further include other parameters for the decoder to perform template matching, and the present invention is not specifically limited thereto.

[0102] In some embodiments, if the first flag indicates filtering, the parameter corresponding to the first flag includes a first search range, and if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search range, the first search range being smaller than the second search range.

[0103] In other words, different values ​​of the first flag correspond to different search ranges.

[0104] For example, if the first flag indicates filtering, the decoder performs template matching on the current block according to the first search range based on the first prediction mode, obtains a plurality of candidate BVs within the first search range, and determines the first candidate list based on the plurality of candidate BVs within the first search range. If the first flag indicates not filtering, the decoder performs template matching on the current block according to the second search range based on the first prediction mode, obtains a plurality of candidate BVs within the second search range, and then determines the first candidate list based on the plurality of candidate BVs within the second search range. Here, the first search range may be a smaller search range than the second search range.

[0105] Similarly, different values ​​of the first flag may correspond to different search step lengths, different search orders, or different numbers of candidate BVs.

[0106] For example, if the first flag indicates filtering, the parameter corresponding to the first flag includes the first search step length, and if the first flag indicates no filtering, the parameter corresponding to the first flag includes the second search step length, where the first search step length is greater than the second search step length.

[0107] In another example, if the first flag indicates filtering, the parameter corresponding to the first flag includes a first search order, and if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search order, where the first search order is different from the second search order.

[0108] In another example, if the first flag indicates filtering, the number of candidate BVs in the first candidate list is the first quantity, and if the first flag indicates no filtering, the number of candidate BVs in the first candidate list is the second quantity, where the first quantity is smaller than the second quantity.

[0109] Of course, in the above embodiment, the fact that the first search range is smaller than the second search range, the first search step length is larger than the second search step length, and the first quantity is smaller than the second quantity is to ensure that the number of candidate BVs in the first candidate list constructed by the decoder when the first flag indicates filtering is smaller than the number of candidate BVs in the first candidate list constructed by the decoder when the first flag indicates not filtering, and furthermore, to reduce the complexity of the first candidate list constructed by the decoder when the first flag indicates filtering, but the present invention is not limited thereto. In other words, in another alternative embodiment, the first search range may be greater than or equal to the second search range, similarly, the first search step length may be less than or equal to the second search step length, and the first quantity may be greater than or equal to the second quantity, and the present invention is not specifically limited thereto.

[0110] In some embodiments, the decoder determines the template matching cost of the plurality of candidate BVs, then sorts the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the first candidate list.

[0111] In this embodiment, when the decoder determines the first candidate list based on the plurality of candidate BVs, it is not necessary to consider the first flag. Furthermore, when the decoder performs template matching based on the first prediction mode, there are two cases: when the first flag is considered or when it is not. Therefore, the solution for the decoder to determine the first candidate list includes one of the following:

[0112] In Solution 1, The decoder performs template matching on the current block according to predetermined parameters (for example, at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain a plurality of candidate BVs, and then sorts the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the first candidate list.

[0113] For example, taking the predetermined parameter as including a search range, regardless of whether the first flag indicates filtering or not, the decoder performs template matching on the current block according to the predetermined block search range to obtain a plurality of candidate BVs within the predetermined search range, and then sorts the plurality of candidate BVs within the predetermined search range based on the template matching cost of the plurality of candidate BVs within the predetermined search range to obtain the first candidate list.

[0114] In Solution 2, The decoder performs template matching on the current block according to the parameters corresponding to the first flag (for example, at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain the plurality of candidate BVs, and then sorts the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the first candidate list.

[0115] For example, taking the parameter corresponding to the first flag as including a search range, if the first flag indicates filtering, the decoder performs template matching on the current block according to the first search range to obtain multiple candidate BVs within the first search range, then sorts the multiple candidate BVs within the first search range based on their template matching costs to obtain the first candidate list. If the first flag indicates no filtering, the decoder performs template matching on the current block according to the second search range to obtain multiple candidate BVs within the second search range, then sorts the multiple candidate BVs within the second search range based on their template matching costs to obtain the first candidate list. The first search range is smaller than the second search range.

[0116] For example, the decoder may, by default, determine the first candidate list according to solution 1 or solution 2.

[0117] In some embodiments, the decoder determines the first candidate list based on the plurality of candidate BVs and the first flag.

[0118] For example, the decoder determines the first candidate list based on the plurality of candidate BVs by employing a construction method corresponding to the first flag.

[0119] In other words, different values ​​of the first flag correspond to different methods of constructing the first candidate list.

[0120] In some embodiments, if the first flag indicates filtering, the template matching cost of the plurality of candidate BVs is determined, at least one candidate BV is determined from the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs, filtering is performed on the template corresponding to the candidate BV within the at least one candidate BV, a filtered template corresponding to the candidate BV within the at least one candidate BV is obtained, the template matching cost of the candidate BV within the at least one candidate BV is determined based on the filtered template corresponding to the candidate BV within the at least one candidate BV and the template of the current block, the at least one candidate BV is reordered based on the template matching cost of the candidate BV within the at least one candidate BV, and the first candidate list is obtained.

[0121] For example, the template matching cost of the plurality of candidate BVs includes the template matching cost of each candidate BV within the plurality of candidate BVs, where the template matching cost of each candidate BV refers to the matching cost between the template of the reference block corresponding to each candidate BV and the template of the current block. The matching cost may be any parameter that can be used to evaluate the strain cost, including, but is not limited to, SAD, SATD, MSE, etc.

[0122] For example, when the decoder performs filtering on a template corresponding to a first candidate BV within the at least one candidate BV, it first determines a filter coefficient based on the template of the reference block corresponding to the first candidate BV and the template of the current block, and then filters the template of the reference block corresponding to the first candidate BV based on the determined filter coefficient to obtain a filtered template corresponding to the first candidate BV. Furthermore, the decoder can determine the matching cost of the first candidate BV based on the filtered template corresponding to the first candidate BV and the template of the current block.

[0123] For example, when the decoder sorts the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV, it can sort them in ascending order to obtain the first candidate list.

[0124] In other words, if the first flag indicates filtering, the decoder can determine the first candidate list according to the following construction method 1. Here, the construction method 1 may include the following processes: determining the template matching cost of the plurality of candidate BVs; determining at least one candidate BV from the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs; filtering the templates corresponding to the candidate BVs within the at least one candidate BV to obtain a filtered template corresponding to the candidate BVs within the at least one candidate BV; determining the template matching cost of the candidate BVs within the at least one candidate BV based on the filtered template corresponding to the candidate BVs within the at least one candidate BV and the template of the current block; and rearranging the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV to obtain the first candidate list.

[0125] In some embodiments, the decoder sorts the candidate BVs based on their template matching costs and determines that some of the candidate BVs that are at the top after sorting are the at least one candidate BV.

[0126] For example, the decoder sorts the candidate BVs in ascending order based on their template matching costs, and then determines the candidate BV at the top after sorting as the at least one candidate BV.

[0127] In some embodiments, if the first flag indicates no filtering, the template matching cost of the plurality of candidate BVs is determined, the plurality of candidate BVs are sorted based on the template matching cost of the plurality of candidate BVs, and the first candidate list is obtained.

[0128] In other words, if the first flag indicates no filtering, the decoder can determine the first candidate list according to the following construction method 2, where the construction method 2 may include the following processes: sorting the plurality of candidate BVs in ascending order based on the template matching costs of the plurality of candidate BVs, and then determining the candidate BV that is at the top after sorting as the at least one candidate BV.

[0129] In this embodiment, when the decoder determines the first candidate list based on the plurality of candidate BVs, it is necessary to determine the first candidate list based on the plurality of candidate BVs and the first flag. When the decoder performs template matching based on the first prediction mode, there are two cases: when the first flag is considered and when it is not. Therefore, the solution for the decoder to determine the first candidate list includes one of the following:

[0130] In Solution 1, The decoder performs template matching on the current block according to predetermined parameters (for example, at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain the plurality of candidate BVs, and then constructs the first candidate list based on the plurality of candidate BVs according to a construction method corresponding to the first flag (for example, construction method 1 or construction method 2).

[0131] For example, the decoder performs template matching on the current block according to predetermined parameters (e.g., at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain the plurality of candidate BVs. If the first flag indicates filtering, the decoder constructs the first candidate list based on the plurality of candidate BVs according to construction method 1; if the first flag indicates not filtering, the decoder constructs the first candidate list based on the plurality of candidate BVs according to construction method 2.

[0132] In Solution 2, The decoder performs template matching on the current block according to the parameters corresponding to the first flag (for example, at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list) to obtain the plurality of candidate BVs, and then constructs the first candidate list based on the plurality of candidate BVs according to the construction method corresponding to the first flag (for example, construction method 1 or construction method 2).

[0133] For example, taking the parameter corresponding to the first flag as including a search range, if the first flag indicates filtering, the decoder performs template matching on the current block according to the first search range to obtain multiple candidate BVs within the first search range, and then constructs the first candidate list based on the multiple candidate BVs within the first search range according to construction method 1. If the first flag indicates no filtering, the decoder performs template matching on the current block according to the second search range to obtain multiple candidate BVs within the second search range, and then constructs the first candidate list based on the multiple candidate BVs within the second search range according to construction method 2. Here, the first search range may be smaller than the second search range.

[0134] In some embodiments, step S310 is, Obtaining the aforementioned first flag, This may include obtaining the first index based on the first flag.

[0135] For example, the decoder first decodes the bitstream to obtain a first flag, then decodes the bitstream based on the first flag to obtain the first index.

[0136] Of course, in another alternative embodiment, the first index does not have to depend on the decoding of the first flag. For example, the decoder can decode the bitstream to obtain the first flag and the first index simultaneously, or the decoder can decode the bitstream to obtain the first index and then decode the bitstream to obtain the first flag.

[0137] In some embodiments, the first index is obtained based on a de-binarization method corresponding to the first flag.

[0138] In other words, different values ​​of the first flag correspond to different inverse binarization methods.

[0139] In some embodiments, if the first flag indicates no filtering, the inverse binarization method corresponding to the first flag includes at least one of a variable-length code binarization method and a truncated unary binarization method; if the first flag indicates filtering, the inverse binarization method corresponding to the first flag includes at least one of a fixed-length code binarization method and a truncated binary binarization method.

[0140] For example, if the first flag indicates no filtering, the decoder may follow the inverse binarization method shown in Table 3 below.

[0141] [Table 3]

[0142] As shown in Table 3, the smaller the value of the first index, the shorter the length of the binary sequence after binarization. Here, BinIdx0, BinIdx1, and BinIdx2 represent the first, second, and third binary values, respectively.

[0143] For example, if the first flag indicates filtering, the decoder may follow the inverse binarization method shown in Table 4 below.

[0144] [Table 4]

[0145] As shown in Table 4, the length of the binarized binary sequence is fixed at 2, regardless of the value of the first index. Here, BinIdx0 and BinIdx1 represent the first and second binary values, respectively.

[0146] In some embodiments, the decoder obtains the first index based on the context model corresponding to the first flag.

[0147] In other words, different values ​​of the first flag correspond to different context models.

[0148] In some embodiments, step S330 is, If the first flag indicates filtering, filtering is performed on the reference block corresponding to the candidate BV indicated by the first index to obtain the predicted block, If the first flag indicates no filtering, the following may be included: determining the reference block corresponding to the candidate BV indicated by the first index as the predicted block.

[0149] It should be noted that the decoder filtering the reference block corresponding to the candidate BV indicated by the first index to obtain the predicted block can also be understood as the decoder filtering the first predicted block corresponding to the candidate BV indicated by the first index to obtain the second predicted block, or as the decoder first determining the reference block corresponding to the candidate BV indicated by the first index as the first predicted block of the current block, and then filtering the first predicted block to obtain the second predicted block. In other words, for the decoder, filtering the reference block corresponding to the candidate BV indicated by the first index and filtering the predicted block of the current block are essentially the same, differing only in the perspective from which the filtering is described.

[0150] In some embodiments, the method 300 is, Obtaining the residual block of the current block, This may further include determining the reconstruction block of the current block based on the residual block and the predicted block.

[0151] The decoder decodes the bitstream to obtain the reference block and determines the reconstructed block based on the residual block and the prediction block. For example, the decoder may determine the sum of the residual block and the prediction block as the reconstructed block.

[0152] In some embodiments, the method 300 is, If the first flag indicates filtering, the first template region of the reference block corresponding to the candidate BV indicated by the first index and the second template region of the current block are obtained, This may further include determining filter coefficients based on the first template region and the second template region.

[0153] For example, if the first flag indicates filtering, the decoder obtains the first template region and the second template region, determines the filter coefficient based on the first and second template regions, then filters the reference block corresponding to the candidate BV indicated by the first index to obtain the predicted block.

[0154] In some embodiments, the decoder can obtain the filter coefficients according to the following method: For the first sample within the first template region, the first sample is filtered using samples from the surrounding region of the first sample to obtain a filtered second sample. The filter coefficient is determined based on the difference between the second sample and the third sample in the second template region, and the position of the first sample in the first template region is the same as the position of the third sample in the template region.

[0155] For example, the decoder may filter each sample in the first template region to obtain filtered samples in the first template region, and then determine the filter coefficients based on the difference between the filtered samples in the first template region and the samples in the second template region. For example, the decoder may determine the filter coefficients based on the mean square error (MSE) between the filtered samples in the first template region and the samples in the second template region. For example, the decoder may adjust the current coefficient used by the filter based on the MSE between the filtered samples in the first template region and the samples in the second template region, adjusting until the MSE between the filtered samples in the first template region and the samples in the second template region falls below a predetermined threshold or the number of adjustments exceeds a predetermined number, and after adjustment, determine the current coefficient as the filter coefficient.

[0156] In some embodiments, if the sample in the peripheral region of the first sample includes a sample at a first position other than the first template region, the sample at the first position is a sample obtained by padding the first position using a sample within the first template region.

[0157] Exemplary, the first position is a position adjacent to the edge of the sample at the edge of the first template region. For example, the first position is adjacent to the top edge, bottom edge, left edge, or right edge of the first template region. For example, referring to Figure 14, if the first template region is a reference template, the second template region is the current template, and the first sample is the sample at the top-left corner of the reference template, then the sample at the first position may include samples above and to the left of the sample at the top-left corner of the reference template.

[0158] In some embodiments, the filter coefficients are coefficients obtained through training.

[0159] Of course, in other alternative embodiments, the filter coefficients may be determined by calculating the samples in the first template region and the samples in the second template region, and the present invention is not limited thereto.

[0160] Regarding the first and second template regions, please refer to Figure 14 and the relevant content of the intraTMP filtering (filter) portion described above, and for brevity, we will not repeat the explanation here. Furthermore, in another alternative embodiment, the method for determining the filter coefficients may be simplified. For example, as one possible implementation, the data for determining the filter coefficients (i.e., the first and second template regions) can be simplified, for example, to a 3x3 template region compared to the template region shown in Figure 14. In another example, as another possible implementation, the training method can be simplified, for example, the filter coefficients can be trained using a simpler training method than MSE, and this application is not specifically limited thereto.

[0161] The following will provide an explanation with reference to specific examples.

[0162] Example 1: The decoder syntax is as follows:

[0163] intra_tmp_flag if(intra_tmp_flag) { intra_tmp_idx intra_tmp_filter_flag }

[0164] The specific decoder process is as follows:

[0165] Currently, when determining the predicted value for a block using intraTMP technology, 1. Analyze intra_tmp_idx and intra_tmp_filter_flag. They are independent of each other and their order can be reversed.

[0166] 2. Within a predetermined search range, possible BVs are searched according to a predetermined search method, the template matching cost of the BV is calculated based on the template corresponding to the searched BV and the template of the current block, and a candidate list intraTmpCandList is determined based on the template matching cost.

[0167] 3. Determine the BV selected for the current block based on the candidates in intraTmpCandList[intra_tmp_idx], and then determine the reference block.

[0168] 4. If the value of intra_tmp_filter_flag is 1 or true, filtering is performed on the reference block. One method is to determine the reference block template based on the selected BV, and then determine the filter coefficient based on the reference block template and the current block template. Filtering is performed on the reference block based on the determined filter coefficient. The value at the position corresponding to the filtered reference block is set to the value at the position corresponding to the predicted block. If the value of Intra_tmp_filter_flag is 0 or false, the value at the position corresponding to the reference block is set to the value at the position corresponding to the predicted block.

[0169] The specific process for the encoder is as follows:

[0170] 1. Construct the candidate list intraTmpCandList using the same method as in step 2 of the decoder.

[0171] 2. Determine the values ​​of intra_tmp_idx and intra_tmp_filter_flag, determine the predicted value of intraTMP, and determine the encoding cost when using intraTMP.

[0172] 3. Based on the encoding cost of intraTMP, decide whether or not to use intraTMP for the current block. If intraTMP is to be used for the current block, encode the values ​​of intra_tmp_idx and intra_tmp_filter_flag and then write them to the bitstream.

[0173] One specific method for Step 2 is as follows:

[0174] Based on each candidate in intraTmpCandList, a BV is determined, the reference block corresponding to the BV is determined to obtain a prediction block without filtering, the reference block template is determined, the filter coefficients are determined based on the reference block template and the current block template, and the prediction block with filtering is determined based on the filter coefficients and the reference block. The prediction block without filtering and the prediction block with filtering for each candidate are compared with the current block to determine the estimated distortion cost SAD or SATD, the estimated distortion cost SAD or SATD is added to the estimated distortion cost SAD or SATD to calculate the estimated coding cost, several combinations of candidates and filtering are selected based on these coding costs, rate-distortion optimization (RDO) is performed to determine the coding cost. The pseudocode is as follows.

[0175] for(intra_tmp_idx=0;intra_tmp_idx <N;intra_tmp_idx++){ Prediction for(intra_tmp_filter_flag=0;intra_tmp_filter_flag<2;intra_tmp_fusion_flag++){ if(intra_tmp_filter){filter prediction} } Calculate cost }

[0176] Of course, the estimated coding cost may be used directly without performing rate distortion optimization. This method is generally used when coding complexity is limited.

[0177] Of course, the encoder can also be simplified. In the example above, both whether or not to filter each candidate is checked, and it is also possible to first check the case where no filtering is performed on any candidates, and then check the case where one or more of the best ones are selected and filtered. The pseudocode is as follows:

[0178] for(intra_tmp_idx=0;intra_tmp_idx <N;intra_tmp_idx++){ Prediction Calculate cost Select versions } for (selected candidate) { for(intra_tmp_filter_flag=0;intra_tmp_filter_flag<2;intra_tmp_fusion_flag++){ if(intra_tmp_filter){filter prediction} } Calculate cost }.

[0179] In this embodiment, when the encoder (or decoder) constructs the candidate list, it does not consider filtering and simply sorts it based on the matching cost of the reference block template and the current block template.

[0180] Example 2: The decoder is as follows:

[0181] intra_tmp_flag if(intra_tmp_flag) { intra_tmp_filter_flag intra_tmp_idx }.

[0182] The specific decoder process is as follows:

[0183] Currently, when determining the predicted value for a block using intraTMP technology, 1. Analyze intra_tmp_filter_flag and intra_tmp_idx.

[0184] 2. Construct intraTmpCandList based on intra_tmp_filter_flag.

[0185] 3. Determine the BV selected for the current block based on the candidates in intraTmpCandList[intra_tmp_idx]. Determine the referenced block.

[0186] 4. If the value of intra_tmp_filter_flag is 1 or true, filtering is performed on the reference block. One method is to determine the reference block template based on the selected BV and then determine the filter coefficient based on the reference block template and the current block template. Filtering is performed on the reference block based on the determined filter coefficient. The value at the position corresponding to the filtered reference block is set to the value at the position corresponding to the predicted block. If the value of Intra_tmp_filter_flag is 0 or false, the value at the position corresponding to the reference block is set to the value at the position corresponding to the predicted block.

[0187] When constructing a list, the decoder can take filtering into account. One way is to filter the reference block templates and then calculate the matching cost using the filtered reference block templates and the current block template.

[0188] More specifically, the decoder can choose to build either a list without filtering or a list with filtering, based on the value of intra_tmp_filter_flag. The search method for the two lists, including the search range and search order, can be the same or different in length.

[0189] Analysis method: If the list lengths are different, you need to first parse intra_tmp_filter_flag and then intra_tmp_idx.

[0190] Furthermore, the binarization and de-binarization methods for intra_tmp_idx may also be different. Even if the list lengths are the same in both cases, they follow different probability distributions, so different binarization and de-binarization methods can be set. To give an easy-to-understand example, in one case (e.g., no filtering), the probability of selecting the first few candidates with small indices is clearly higher than that of other candidates with larger indices, and the binarization and de-binarization methods assign short binary symbols to the first few candidates with small indices and long binary symbols to the other candidates with large indices. In another case (e.g., filtering), the probability of selecting the first few candidates with small indices is not significantly different from that of other candidates with large indices, and the difference in the binary symbol lengths assigned to them by the binarization and de-binarization methods is not as large as in the previous case, or they use directly equal binary symbol lengths. In other words, the codec selects a set of binarization and de-binarization methods based on the value of intra_tmp_filter_flag. For example, if the value of intra_tmp_filter_flag is 0, the first binarization / inverse binarization method is selected, and if the value of intra_tmp_filter_flag is 1, the second binarization / inverse binarization method is selected.

[0191] An example is shown below.

[0192] In the first binarization / de-binarization method, the correspondence between the index and the binary symbol is as shown in Table 3 above.

[0193] In the second binarization / de-binarization method, the correspondence between the index and the binary symbol is as shown in Table 4 above.

[0194] Furthermore, even if the binarization method is the same, different context models (CABAC-like context models) may be set for the two cases during the encoding and decoding of binarization and de-binarization. In other words, the probability of binary symbols in context-based coding is accumulated and updated in each of the two cases. That is, the codec selects a set of context models based on the value of intra_tmp_filter_flag. For example, if the value of intra_tmp_filter_flag is 0, one set of context models contextModel0 is selected, and if the value of intra_tmp_filter_flag is 1, one set of context models contextModel1 is selected.

[0195] If the list length, binarization / de-binarization method, and context model are all the same, i.e., if intra_tmp_idx does not depend on intra_tmp_filter_flag, then it is acceptable to parse either intra_tmp_filter_flag or intra_tmp_idx first. Otherwise, i.e., if intra_tmp_idx depends on intra_tmp_filter_flag, then parse intra_tmp_filter_flag first, and then parse intra_tmp_idx.

[0196] The decoder uses a de-binarization method and, based on a correspondence table between Symbols and binary symbols, selects a context model when encoding a binary symbol in context mode, reads the bitstream, and determines the value of Symbol. The encoder uses a binarization method and, based on a correspondence table between Symbols and binary symbols, selects a context model when encoding a binary symbol in context mode, and determines what to write to the bitstream based on the value of Symbol. Symbol corresponds to intra_tmp_idx.

[0197] How to build a candidate list: When using filtering, when constructing the list, the filter coefficient can be determined based on the reference block template and the current block template corresponding to the BV obtained through the search. Filtering is performed on the reference block template based on the determined filter coefficient. The matching cost is calculated using the filtered reference block template and the current block template. A list is constructed based on the matching cost. A list is maintained sorted in ascending order of matching cost.

[0198] One approach is to perform operations such as deriving the filter coefficients described above and filtering the reference block template for each BV being searched. In this case, the decoder complexity will be higher than when filtering is not used.

[0199] For the sake of explanation, the operations of determining filter coefficients based on the reference block template and current block template corresponding to the BV obtained through the search, performing filtering on the reference block template based on the determined filter coefficients, and calculating the matching cost using the filtered reference block template and current block template are referred to as search filtering. The complexity can be reduced by reducing the number of operations of the search filtering. One method is to set a different search method than the case without filtering, for example, by setting the search range or search order, for example, by using a smaller search range than in the case without filtering.

[0200] Another approach involves two steps. In the first step, you first explore without filtering to select a small range of candidate BVs, and then use filtering to perform search filtering on that small range of candidate BVs, ultimately determining the candidate list.

[0201] As an example, regardless of whether the value of intra_tmp_filter_flag is 0 (false) or 1 (true), the conventional method is followed according to the existing method, that is, a candidate list intraTmpUnfilterCandList is constructed without using filtering. If the value of intra_tmp_filter_flag is 1 (true), intraTmpFilterCandList is constructed using search filtering based on intraTmpUnfilterCandList. Specifically, if the length of intraTmpUnfilterCandList is N, search filtering is performed on each candidate BV of the first M candidates in intraTmpUnfilterCandList, and intraTmpFilterCandList[M] is constructed based on the matching cost of the search filtering, and the candidates in intraTmpFilterCandList are sorted in ascending order of the matching cost of the search filtering. Here, M is less than or equal to N. If the value of intra_tmp_filter_flag is 1 (true), then intraTmpCandList = intraTmpFilteredCandList; otherwise, i.e., if the value of intra_tmp_filter_flag is 0 (false), then intraTmpCandList = intraTmpUnfilteredCandList.

[0202] The above example can also be understood as first building a list of candidates that will not be filtered, regardless of whether filtering is used or not, and then, if filtering is necessary, building a list of candidates that will be filtered based on the list of candidates that will not be filtered.

[0203] The specific process for the encoder is as follows:

[0204] 1. Construct the candidate list intraTmpCandList using the same method as in step 2 of the decoder.

[0205] 2. Determine the values ​​of intra_tmp_idx and intra_tmp_filter_flag, determine the predicted value of intraTMP, and determine the encoding cost when using intraTMP.

[0206] 3. Based on the encoding cost of intraTMP, decide whether or not to use intraTMP for the current block. If intraTMP is to be used for the current block, encode the values ​​of intra_tmp_idx and intra_tmp_filter_flag and then write them to the bitstream.

[0207] One specific method for Step 2 is as follows:

[0208] In the two cases where intra_tmp_filter_flag is 0 (false) or 1 (true), the candidate list intraTmpCandList is constructed according to the candidate list construction method described above. Based on each candidate in intraTmpCandList, a BV is determined, and the reference block corresponding to the BV is determined. If intra_tmp_filter_flag is 0, a prediction block without filtering is obtained. If intra_tmp_filter_flag is 1, a reference block template is determined, and filter coefficients are determined based on the reference block template and the current block template. A prediction block with filtering is determined based on the filter coefficients and the reference block. The prediction block and the current block are compared to determine the estimated distortion cost SAD or SATD. The estimated distortion cost SAD or SATD is added to the estimated distortion cost SAD or SATD to calculate the estimated coding cost. Based on these coding costs, several combinations of candidates and filtering are selected, rate-distortion optimization (RDO) is performed, and the coding cost is determined. The pseudocode is as follows.

[0209] for(intra_tmp_filter_flag=0;intra_tmp_filter_flag<2;intra_tmp_fusion_flag++){ for(intra_tmp_idx=0;intra_tmp_idx <N;intra_tmp_idx++){ Prediction } Calculate cost }.

[0210] When intra_tmp_filter_flag=1, if the length of the candidate list is M and M is not equal to N, the second for loop can be written as for(intra_tmp_idx=0; intra_tmp_idx<(intra_tmp_filter_flag?M:N); intra_tmp_idx++).

[0211] If intra_tmp_filter_flag=0, the prediction is that no filtering will be performed. If intra_tmp_filter_flag=1, the prediction is that filtering will be performed.

[0212] Of course, the estimated coding cost may be used directly without performing rate distortion optimization. This method is generally used when coding complexity is limited.

[0213] While preferred embodiments of the present application have been described above with reference to the drawings, the present application is not limited to the specific details of the embodiments described above. Within the scope of the technical concept of the present application, various simple modifications can be made to the technical solutions of the present application, and all such simple modifications fall within the scope of protection of the present application. For example, each specific technical feature described in the specific embodiments described above can be combined in any suitable manner without contradiction, and in order to avoid unnecessary repetition, the present application does not describe various possible combinations. In another example, various different embodiments of the present application can also be combined in any way, and such combinations should also be considered as part of the disclosures of the present application, as long as they do not violate the spirit of the present application. Furthermore, it should be understood that in the various embodiments of the present application, the magnitude of the sequence numbers of the above processes does not indicate the order of execution, and the order of execution of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0214] The decoding method according to the embodiment of the present invention has been described above from the perspective of the decoder. Below, with reference to Figure 16, the encoding method according to the embodiment of the present invention will be described from the perspective of the encoder.

[0215] Figure 16 is a schematic flowchart of the encoding method 400 according to an embodiment of the present application. It should be understood that the encoding method 400 can be performed by an encoder. For example, it can be applied to the encoding framework 100 shown in Figure 1. For the sake of explanation, an encoder will be used as an example below.

[0216] As shown in Figure 16, the encoding method 400 may include the following steps.

[0217] In step S410, based on a first prediction mode corresponding to intra-template prediction, at least one candidate list consisting of candidate block vectors (BVs) for the current block is determined.

[0218] In step S420, a first flag is determined based on the at least one candidate list to indicate whether or not to filter, and a first index is determined to indicate a candidate BV within the first candidate list of the at least one candidate list.

[0219] In step S430, the first flag and the first index are encoded.

[0220] In some embodiments, the method 400 is, Based on the first flag and the first index, the predicted block of the current block is determined, A second flag is determined based on the distortion cost of the predicted block, the second flag indicating whether or not to predict the current block using the first prediction mode. This may further include encoding the second flag.

[0221] In some embodiments, step S410 is, Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs, This may include determining the at least one candidate list based on the plurality of candidate BVs.

[0222] In some embodiments, template matching is performed on the current block based on the first prediction mode to obtain a plurality of candidate BVs. The process includes performing template matching on the current block according to the parameters corresponding to the first flag, based on the first prediction mode, to obtain the plurality of candidate BVs.

[0223] In some embodiments, the parameter corresponding to the first flag includes at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list.

[0224] In some embodiments, if the first flag indicates filtering, the parameter corresponding to the first flag includes a first search range, and if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search range, the first search range being smaller than the second search range.

[0225] In some embodiments, the at least one candidate list includes the first candidate list, where determining the at least one candidate list based on the plurality of candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, The process includes sorting the multiple candidate BVs based on their template matching costs to obtain the first candidate list.

[0226] In some embodiments, step S420 is, Determining the distortion cost of the reference block corresponding to the candidate BV in the first candidate list, Filtering is performed on the reference blocks corresponding to the candidate BV in the first candidate list, and the distortion cost of the filtered reference blocks corresponding to the candidate BV in the first candidate list is obtained. This may include determining the first flag and the first index based on the distortion cost of the reference block corresponding to the candidate BV in the first candidate list and the distortion cost of the filtered reference block corresponding to the candidate BV in the first candidate list.

[0227] In some embodiments, the at least one candidate list includes a second candidate list and a third candidate list, where the first candidate list is the second candidate list if the first flag indicates filtering, and the first candidate list is the third candidate list if the first flag indicates no filtering.

[0228] In some embodiments, determining the at least one candidate list based on the plurality of candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, Based on the template matching costs of the plurality of candidate BVs, at least one candidate BV is determined from among the plurality of candidate BVs. Filtering is performed on the templates corresponding to the candidate BVs within the at least one candidate BV, and a filtered template corresponding to the candidate BVs within the at least one candidate BV is obtained. The template matching cost of the candidate BV in the at least one candidate BV is determined based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, The method includes sorting the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV to obtain the second candidate list.

[0229] In some embodiments, determining at least one candidate BV from among the multiple candidate BVs based on the template matching cost of the multiple candidate BVs is: The process involves rearranging the multiple candidate BVs based on their template matching costs, This includes determining some of the candidate BVs that are at the front after being rearranged as the at least one candidate BV.

[0230] In some embodiments, determining the at least one candidate list based on the plurality of candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, The process includes sorting the multiple candidate BVs based on their template matching costs to obtain the third candidate list.

[0231] In some embodiments, step S420 is, Determining the distortion cost of the reference block corresponding to the candidate BV in the second candidate list, Filtering is performed on the reference blocks corresponding to the candidate BV in the third candidate list, and the distortion cost of the filtered reference blocks corresponding to the candidate BV in the third candidate list is obtained. This may include determining the first flag and the first index based on the distortion cost of the reference block corresponding to the candidate BV in the second candidate list and the distortion cost of the filtered reference block corresponding to the candidate BV in the third candidate list.

[0232] In some embodiments, step S430 is, This may include encoding the first index based on the first flag.

[0233] In some embodiments, encoding the first index based on the first flag is: This includes encoding the first index based on a binarization method corresponding to the first flag.

[0234] In some embodiments, if the first flag indicates no filtering, the binarization method corresponding to the first flag includes at least one of a variable-length code binarization method and a truncated unary binarization method; if the first flag indicates filtering, the binarization method corresponding to the first flag includes at least one of a fixed-length code binarization method and a truncated binary binarization method.

[0235] In some embodiments, encoding the first index based on the first flag is: This includes encoding the first index based on the context model corresponding to the first flag.

[0236] In some embodiments, the method 400 is, Determining a residual block of the current block based on a predicted block of the current block and an original block of the current block; It may further include determining a reconstructed block of the current block based on the residual block and the predicted block.

[0237] In some embodiments, the method 400 When the first flag indicates filtering, obtaining a first template region of a reference block corresponding to a candidate BV indicated by the first index and a second template region of the current block; It may further include determining a filter coefficient based on the first template region and the second template region.

[0238] In some embodiments, for a first sample in the first template region, filtering is performed on the first sample using samples in a peripheral region of the first sample to obtain a filtered second sample, and the filter coefficient is determined based on a difference between the second sample and a third sample in the second template region, and a position of the first sample in the first template region is the same as a position of the third sample in the template region.

[0239] In some embodiments, when samples in a peripheral region of the first sample include samples at a first position outside the first template region, the samples at the first position are samples obtained by padding the first position using samples in the first template region.

[0240] In some embodiments, the filter coefficient is a coefficient obtained by training.

[0241] It should be understood that the encoding method can be understood as the reverse process of the decoding method. Therefore, the specific solution of the encoding method 400 can refer to the relevant content of the decoding method 300, and for the convenience of description, it will not be repeated here. Furthermore, the embodiments of the method of the present application have been described in detail above. Hereinafter, referring to FIGS. 17 to 19, the embodiments of the apparatus of the present application will be described in detail.

[0242] FIG. 17 is a schematic block diagram of a decoder 500 according to an embodiment of the present application.

[0243] As shown in FIG. 17, the decoder 500 includes an acquisition unit 510 configured to acquire a first flag and a first index for indicating whether to perform filtering, a first determination unit 520 configured to determine a first candidate list composed of candidate block vectors (BVs) of a current block based on a first prediction mode corresponding to intra-template prediction, and a second determination unit 530 configured to determine a predicted block of the current block based on the first flag and the candidate BV indicated by the first index in the first candidate list.

[0244] In some embodiments, the acquisition unit 510 is specifically configured to acquire a second flag, and when the second flag indicates that the current block is predicted using the first prediction mode, acquire the first flag and the first index.

[0245] In some embodiments, the first determination unit 520 is specifically configured to perform template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs, and determine the first candidate list based on the plurality of candidate BVs.

[0246] In some embodiments, the first decision unit 520 specifically, Based on the first prediction mode, the system is configured to perform template matching on the current block according to the parameters corresponding to the first flag to obtain the plurality of candidate BVs.

[0247] In some embodiments, the parameter corresponding to the first flag includes at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list.

[0248] In some embodiments, if the first flag indicates filtering, the parameter corresponding to the first flag includes a first search range, and if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search range, the first search range being smaller than the second search range.

[0249] In some embodiments, the first decision unit 520 specifically, Determine the template matching cost for the aforementioned multiple candidate BVs. The system is configured to sort the multiple candidate BVs based on their template matching costs to obtain the first candidate list.

[0250] In some embodiments, the first decision unit 520 specifically, The system is configured to determine the first candidate list based on the plurality of candidate BVs and the first flag.

[0251] In some embodiments, the first decision unit 520 specifically, If the first flag indicates filtering, the template matching cost of the multiple candidate BVs is determined. Based on the template matching costs of the plurality of candidate BVs, at least one candidate BV is determined from among the plurality of candidate BVs. Filtering is performed on the templates corresponding to the candidate BV within the at least one candidate BV, and filtered templates corresponding to the candidate BV within the at least one candidate BV are obtained. Based on the filtered template corresponding to the candidate BV within the at least one candidate BV and the template of the current block, the template matching cost of the candidate BV within the at least one candidate BV is determined. The system is configured to sort the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV to obtain the first candidate list.

[0252] In some embodiments, the first decision unit 520 specifically, Based on the template matching cost of the aforementioned multiple candidate BVs, the multiple candidate BVs are sorted. The system is configured to determine some of the candidate BVs that are at the top after being sorted as the at least one candidate BV.

[0253] In some embodiments, the first decision unit 520 specifically, If the first flag indicates that filtering is not performed, the template matching cost of the multiple candidate BVs is determined. The system is configured to sort the multiple candidate BVs based on their template matching costs to obtain the first candidate list.

[0254] In some embodiments, the acquisition unit 510 specifically, Obtain the aforementioned first flag, The system is configured to obtain the first index based on the first flag.

[0255] In some embodiments, the acquisition unit 510 specifically, The system is configured to obtain the first index based on a de-binarization method corresponding to the first flag.

[0256] In some embodiments, when the first flag indicates not to filter, the inverse binarization method corresponding to the first flag includes at least one of a variable-length code binarization method and a truncated monadic binarization method. When the first flag indicates to filter, the inverse binarization method corresponding to the first flag includes at least one of a fixed-length code binarization method and a truncated binary binarization method.

[0257] In some embodiments, the obtaining unit 510 is specifically configured to obtain the first index based on the context model corresponding to the first flag.

[0258] In some embodiments, the second determination unit 530 is specifically configured to when the first flag indicates to filter, perform filtering on the reference block corresponding to the candidate BV indicated by the first index to obtain the prediction block. when the first flag indicates not to filter, determine the reference block corresponding to the candidate BV indicated by the first index as the prediction block.

[0259] In some embodiments, the second determination unit 530 further obtains the residual block of the current block, and is configured to determine the reconstructed block of the current block based on the residual block and the prediction block.

[0260] In some embodiments, the second determination unit 530 further when the first flag indicates to filter, obtains the first template region of the reference block corresponding to the candidate BV indicated by the first index and the second template region of the current block. The system is configured to determine the filter coefficients based on the first template region and the second template region.

[0261] In some embodiments, the second decision unit 530 specifically, For the first sample within the first template region, the first sample is filtered using samples from the surrounding region of the first sample to obtain a filtered second sample. The filter coefficient is determined based on the difference between the second sample and the third sample in the second template region, and the position of the first sample in the first template region is the same as the position of the third sample in the template region.

[0262] In some embodiments, if the sample in the peripheral region of the first sample includes a sample at a first position other than the first template region, the sample at the first position is a sample obtained by padding the first position using a sample within the first template region.

[0263] In some embodiments, the filter coefficients are coefficients obtained through training.

[0264] Figure 18 is a schematic block diagram of an encoder 600 according to an embodiment of the present application.

[0265] As shown in Figure 18, the encoder 600 is A first decision unit 610 is configured to determine at least one candidate list consisting of candidate block vectors (BVs) of the current block based on a first prediction mode corresponding to intra-template prediction, A second decision unit 620 is configured to determine a first flag for indicating whether or not to filter based on the at least one candidate list, and a first index for indicating a candidate BV within the first candidate list of the at least one candidate list. The system may include an encoding unit 630 configured to encode the first flag and the first index.

[0266] In some embodiments, the encoding unit 630 further, Based on the first flag and the first index, the predicted block of the current block is determined, A second flag is determined based on the distortion cost of the predicted block, the second flag indicating whether or not to predict the current block using the first prediction mode. The system is configured to encode the second flag and to perform the following actions.

[0267] In some embodiments, the first decision unit 610 specifically, Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs, The system is configured to determine the at least one candidate list based on the plurality of candidate BVs.

[0268] In some embodiments, the first decision unit 610 specifically, Based on the first prediction mode, the system is configured to perform template matching on the current block according to the parameters corresponding to the first flag to obtain the plurality of candidate BVs.

[0269] In some embodiments, the parameter corresponding to the first flag includes at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list.

[0270] In some embodiments, if the first flag indicates filtering, the parameter corresponding to the first flag includes a first search range, and if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search range, the first search range being smaller than the second search range.

[0271] In some embodiments, the at least one candidate list includes the first candidate list, where the first decision unit 610 specifically, Determine the template matching cost for the aforementioned multiple candidate BVs. The system is configured to sort the multiple candidate BVs based on their template matching costs to obtain the first candidate list.

[0272] In some embodiments, the second decision unit 620 specifically, Determine the distortion cost of the reference block corresponding to the candidate BV in the first candidate list. Filtering is performed on the reference blocks corresponding to the candidate BV in the first candidate list, and the distortion cost of the filtered reference blocks corresponding to the candidate BV in the first candidate list is obtained. The system is configured to determine the first flag and the first index based on the distortion cost of the reference block corresponding to the candidate BV in the first candidate list and the distortion cost of the filtered reference block corresponding to the candidate BV in the first candidate list.

[0273] In some embodiments, the at least one candidate list includes a second candidate list and a third candidate list, where the first candidate list is the second candidate list if the first flag indicates filtering, and the first candidate list is the third candidate list if the first flag indicates no filtering.

[0274] In some embodiments, the first decision unit 610 specifically, Determine the template matching cost for the aforementioned multiple candidate BVs. Based on the template matching costs of the plurality of candidate BVs, at least one candidate BV is determined from among the plurality of candidate BVs. Filtering is performed on the templates corresponding to the candidate BV within the at least one candidate BV, and filtered templates corresponding to the candidate BV within the at least one candidate BV are obtained. Based on the filtered template corresponding to the candidate BV within the at least one candidate BV and the template of the current block, the template matching cost of the candidate BV within the at least one candidate BV is determined. The system is configured to sort the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV to obtain the second candidate list.

[0275] In some embodiments, the first decision unit 610 specifically, Based on the template matching cost of the aforementioned multiple candidate BVs, the multiple candidate BVs are sorted. The system is configured to determine some of the candidate BVs that are at the top after being sorted as the at least one candidate BV.

[0276] In some embodiments, the first decision unit 610 specifically, Determine the template matching cost for the aforementioned multiple candidate BVs. The system is configured to sort the multiple candidate BVs based on their template matching costs to obtain the third candidate list.

[0277] In some embodiments, the second decision unit 620 specifically, Determine the distortion cost of the reference block corresponding to the candidate BV in the second candidate list. Filter the reference blocks corresponding to the candidate BV in the third candidate list, and obtain the distortion cost of the filtered reference blocks corresponding to the candidate BV in the third candidate list. The system is configured to determine the first flag and the first index based on the distortion cost of the reference block corresponding to the candidate BV in the second candidate list and the distortion cost of the filtered reference block corresponding to the candidate BV in the third candidate list.

[0278] In some embodiments, the encoding unit 630 specifically, The system is configured to encode the first index based on the first flag.

[0279] In some embodiments, the encoding unit 630 specifically, The first index is configured to be encoded based on a binarization method corresponding to the first flag.

[0280] In some embodiments, if the first flag indicates no filtering, the binarization method corresponding to the first flag includes at least one of a variable-length code binarization method and a truncated unary binarization method; if the first flag indicates filtering, the binarization method corresponding to the first flag includes at least one of a fixed-length code binarization method and a truncated binary binarization method.

[0281] In some embodiments, the encoding unit 630 specifically, The first index is configured to encode based on the context model corresponding to the first flag.

[0282] In some embodiments, the encoding unit 630 further, Based on the predicted block of the current block and the original block of the current block, the residual block of the current block is determined. The system is configured to determine the reconstruction block of the current block based on the residual block and the prediction block. In some embodiments, the second decision unit 620 further, If the first flag indicates filtering, obtain the first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and the second template area of ​​the current block. The system is configured to determine the filter coefficients based on the first template region and the second template region. In some embodiments, the second decision unit 620 specifically, For the first sample within the first template region, the first sample is filtered using samples from the surrounding region of the first sample to obtain a filtered second sample. The filter coefficient is determined based on the difference between the second sample and the third sample in the second template region, and the position of the first sample in the first template region is the same as the position of the third sample in the template region. In some embodiments, if the sample in the peripheral region of the first sample includes a sample at a first position other than the first template region, the sample at the first position is a sample obtained by padding the first position using a sample within the first template region. In some embodiments, the filter coefficients are coefficients obtained through training. It should be understood that the embodiments of the apparatus and the embodiments of the method correspond to each other, and similar descriptions can refer to the embodiments of the method. For brevity, this will not be repeated here. Specifically, the decoder 500 shown in Figure 17 can correspond to the corresponding implementing body in Method 300 of the embodiments of this application, and the operations and other operations and / or functions of each unit within the decoder 500 described above are for realizing the corresponding processes in each method, such as Method 300. The encoder 600 shown in Figure 18 can correspond to the corresponding implementing body in Method 400 of the embodiments of this application, that is, the operations and other operations and / or functions of each unit within the encoder 600 described above are for realizing the corresponding processes in each method, such as Method 400. Furthermore, it should be understood that each unit within the decoder 500 or encoder 600 according to the embodiment of the present application may be configured separately, or all may be integrated into one or more other units, or one (part of) a unit may be further divided into several functionally smaller units. This allows for similar operation to be achieved without affecting the realization of the technical effects of the embodiment of the present application. Although the above units are divided based on logical function, in actual applications, the function of one unit may be realized by multiple units, and the function of multiple units may be realized by one unit. In another embodiment of the present application, the decoder 500 or encoder 600 may include other units, and in actual applications, these functions may be realized with the assistance of other units or by the coordination of multiple units. According to another embodiment of the present application, for example, a decoder 500 or encoder 600 according to an embodiment of the present application can be configured by executing a computer program (including program code) capable of executing each step of the corresponding method on a general-purpose computer device such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM), thereby realizing the encoding method or decoding method provided by the embodiment of the present application. The computer program can be recorded on a computer-readable storage medium, loaded onto an electronic device via the computer-readable storage medium, and executed therein to realize the corresponding method of the embodiment of the present application. In other words, the units described above may be implemented in hardware form, in software instruction form, or in combination of hardware and software. Specifically, each step of the embodiment of the method in the embodiments of the present application can be completed by hardware integrated logic circuits and / or software instruction in a processor, and the steps of the method disclosed in the embodiments of the present application can be completed by a hardware decoding processor or by a combination of hardware and software in a decoding processor. Optionally, the software may be placed in a conventional storage medium such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers, etc. The storage medium is placed in memory, and the processor reads the information in memory and, in combination with its hardware, completes the steps of the embodiment of the method described above.

[0283] Figure 19 is a schematic diagram of the electronic device 700 according to an embodiment of the present application.

[0284] As shown in Figure 19, the electronic device 700 comprises at least a processor 710 and a computer-readable storage medium 720, where the processor 710 and the computer-readable storage medium 720 are connected via a bus or by other means. The computer-readable storage medium 720 is configured to store a computer program 721, which includes computer instructions, and the processor 710 is configured to execute the computer instructions stored in the computer-readable storage medium 720. The processor 710 is the computing core and control core of the electronic device 700, and is adapted to execute one or more computer instructions, specifically, to realize a process or function in a corresponding manner by loading and executing one or more computer instructions.

[0285] For example, the processor 710 may also be called a Central Processing Unit (CPU). The processor 710 may include, but is not limited to, a general-purpose computer, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, a transistor logic device, or a distributed hardware component.

[0286] Exemplary, the computer-readable storage medium 720 may be high-speed RAM memory, non-volatile memory such as at least one disk memory, or optionally at least one computer-readable storage medium located away from the processor 710. Specifically, the computer-readable storage medium 720 includes, but is not limited to, volatile memory and / or non-volatile memory. Here, the non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM) used as an external cache. To illustrate with illustrative but not limited examples, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM), and direct Rambus random access memory (DRRAM).

[0287] For example, the electronic device 700 may be an encoder or encoding framework according to an embodiment of the present application, the computer-readable storage medium 720 stores a first computer instruction, and the processor 710 loads and executes the first computer instruction stored in the computer-readable storage medium 720 to realize the corresponding step in the encoding method according to an embodiment of the present application. In other words, the first computer instruction in the computer-readable storage medium 720 is loaded and executed by the processor 710 to perform the corresponding step, which will not be described again here for the sake of brevity.

[0288] For example, the electronic device 700 may be a decoder or decoding framework according to an embodiment of the present application, the computer-readable storage medium 720 stores a second computer instruction, and the processor 710 loads and executes the second computer instruction stored in the computer-readable storage medium 720 to realize the corresponding step in the decoding method according to an embodiment of the present application. In other words, the second computer instruction in the computer-readable storage medium 720 is loaded and executed by the processor 710 to perform the corresponding step, which will not be described again here for brevity.

[0289] According to another aspect of the present invention, the present invention further provides an encoding and decoding system comprising the encoder and decoder described above.

[0290] In another aspect of the present invention, the present invention further provides a computer-readable memory medium (Memory) which is a storage device within an electronic device 700 for storing programs and data. For example, a computer-readable memory medium 720. Understandably, the computer-readable memory medium 720 in the present invention may include a storage medium built into the electronic device 700, and of course may include an extended storage medium supported by the electronic device 700. The computer-readable memory medium provides a storage space which stores the operating system of the electronic device 700. The storage space also stores one or more computer instructions which are loaded and executed by a processor 710, and the computer instructions may be one or more computer programs 721 (including program code).

[0291] In another aspect of the present application, the present application further provides a computer program product or computer program, the computer program product or computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium, for example, computer program 721. In this case, the data processing device 700 may be a computer, and the processor 710 reads the computer instructions from the computer-readable storage medium 720, and the processor 710 executes the computer instructions, thereby causing the computer to execute an encoding or decoding method provided in the various alternative forms described above.

[0292] In other words, when implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer loads and executes the computer program instructions on a computer, it may perform the process of the embodiment of the application in whole or in part, or implement the functionality of the embodiment of the application in whole or in part. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable device. The computer instructions may be stored on a computer-readable storage medium and may be transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wired means (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless means (infrared, radio, microwave, etc.).

[0293] Those skilled in the art will recognize that each illustrative unit and process step described in conjunction with the embodiments disclosed herein may be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art will recognize that for each specific application, the described functions may be implemented using different methods, but such implementations should not be considered beyond the scope of this application.

[0294] Finally, it should be noted that the above describes only specific embodiments of the present application and does not limit the scope of protection. Any modifications or substitutions that a person skilled in the art could easily conceive within the technical scope disclosed herein are included within the scope of protection. Therefore, the scope of protection is subject to the scope of protection of the claims.

Claims

1. A decryption method, Obtain a first flag and a first index to indicate whether or not to filter, Based on the first prediction mode corresponding to intra-template prediction, a first candidate list consisting of candidate block vectors (BVs) of the current block is determined, A decoding method comprising determining a predicted block for the current block based on the first flag and a candidate BV indicated by the first index in the first candidate list.

2. Obtaining the first flag and first index to indicate whether or not to perform the filtering is: To obtain the second flag, If the second flag indicates that the current block will be predicted using the first prediction mode, then obtaining the first flag and the first index, The decoding method according to claim 1.

3. Based on the first prediction mode corresponding to the intra-template prediction, determining a first candidate list consisting of candidate block vectors (BVs) for the current block is: Based on the first prediction mode, template matching is performed on the current block to obtain a plurality of candidate BVs, The process includes determining the first candidate list based on the plurality of candidate BVs, The decoding method according to claim 1 or 2.

4. Performing template matching on the current block based on the first prediction mode and obtaining multiple candidate BVs is: Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first flag, and the plurality of candidate BVs are obtained. The decoding method according to claim 3.

5. The parameter corresponding to the first flag includes at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list. The decoding method according to claim 4.

6. If the first flag indicates filtering, the parameter corresponding to the first flag includes a first search range; if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search range, and the first search range is smaller than the second search range. The decoding method according to claim 4.

7. Determining the first candidate list based on the aforementioned multiple candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, This includes sorting the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the first candidate list, The decoding method according to any one of claims 3 to 6.

8. Determining the first candidate list based on the aforementioned multiple candidate BVs is: The process includes determining a first candidate list based on the plurality of candidate BVs and the first flag, The decoding method according to any one of claims 3 to 6.

9. Determining the first candidate list based on the plurality of candidate BVs and the first flag means that If the first flag indicates filtering, the template matching cost of the plurality of candidate BVs is determined, Based on the template matching costs of the plurality of candidate BVs, at least one candidate BV is determined from among the plurality of candidate BVs. The process involves filtering the templates corresponding to the candidate BVs within the at least one candidate BV, and obtaining filtered templates corresponding to the candidate BVs within the at least one candidate BV. The template matching cost of the candidate BV in the at least one candidate BV is determined based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, The process includes sorting the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV to obtain the first candidate list, The decoding method according to claim 8.

10. Determining at least one candidate BV from among the multiple candidate BVs based on the template matching costs of the multiple candidate BVs is: The process involves rearranging the multiple candidate BVs based on the template matching cost of each candidate BV, This includes determining some of the candidate BVs that are at the front after being rearranged as the at least one candidate BV, The decoding method according to claim 9.

11. Determining the first candidate list based on the plurality of candidate BVs and the first flag means that If the first flag indicates that filtering is not performed, the template matching cost of the multiple candidate BVs is determined, This includes sorting the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the first candidate list, The decoding method according to claim 8.

12. Obtaining the first flag and first index to indicate whether or not to perform the filtering is: Obtaining the first flag, This includes obtaining the first index based on the first flag, The decoding method according to any one of claims 1 to 11.

13. Obtaining the first index based on the first flag means that The process includes obtaining the first index based on the inverse binarization method corresponding to the first flag, The decoding method according to claim 12.

14. If the first flag indicates no filtering, the inverse binarization method corresponding to the first flag includes at least one of a variable-length code binarization method and a truncated unary binarization method; if the first flag indicates filtering, the inverse binarization method corresponding to the first flag includes at least one of a fixed-length code binarization method and a truncated binary binarization method. The decoding method according to claim 13.

15. Obtaining the first index based on the first flag means that This includes obtaining the first index based on the context model corresponding to the first flag, The decoding method according to claim 12.

16. Determining the predicted block of the current block based on the first flag and the candidate BV indicated by the first index in the first candidate list is: If the first flag indicates filtering, filtering is performed on the reference block corresponding to the candidate BV indicated by the first index to obtain the predicted block, If the first flag indicates no filtering, the reference block corresponding to the candidate BV indicated by the first index is determined to be the predicted block, The decoding method according to any one of claims 1 to 15.

17. The aforementioned decryption method is Obtaining the residual block of the current block, The further includes determining the reconstruction block of the current block based on the residual block and the predicted block, The decoding method according to any one of claims 1 to 16.

18. The aforementioned decryption method is If the first flag indicates filtering, the first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and the second template area of ​​the current block are obtained, The further includes determining filter coefficients based on the first template region and the second template region, The decoding method according to any one of claims 1 to 17.

19. Determining the filter coefficients based on the first template region and the second template region is: With respect to the first sample in the first template region, the first sample is filtered using samples from the surrounding region of the first sample to obtain a filtered second sample. The method involves determining the filter coefficient based on the difference between the second sample and the third sample in the second template region, wherein the position of the first sample in the first template region is the same as the position of the third sample in the template region. The decoding method according to claim 18.

20. If the samples in the peripheral region of the first sample include samples at a first position other than the first template region, the samples at the first position are samples obtained by padding the first position using samples within the first template region. The decoding method according to claim 19.

21. The aforementioned filter coefficients are coefficients obtained through training. The decoding method according to claim 18.

22. An encoding method, Based on a first prediction mode corresponding to intra-template prediction, determine at least one candidate list consisting of candidate block vectors (BVs) of the current block, Based on the at least one candidate list, a first flag to indicate whether or not to filter, and a first index to indicate candidate BV within the first candidate list of the at least one candidate list are determined. An encoding method comprising encoding the first flag and the first index.

23. The aforementioned encoding method is Based on the first flag and the first index, the predicted block of the current block is determined, A second flag is determined based on the distortion cost of the predicted block, the second flag indicating whether or not to predict the current block using the first prediction mode. The further includes encoding the second flag, The encoding method according to claim 22.

24. Based on the first prediction mode corresponding to the intra-template prediction, determining at least one candidate list consisting of candidate block vectors (BVs) of the current block is: Based on the first prediction mode, template matching is performed on the current block to obtain a plurality of candidate BVs, The process includes determining the at least one candidate list based on the plurality of candidate BVs, The encoding method according to claim 22 or 23.

25. Performing template matching on the current block based on the first prediction mode and obtaining multiple candidate BVs is: Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first flag, and the plurality of candidate BVs are obtained. The encoding method according to claim 24.

26. The parameter corresponding to the first flag includes at least one of the search range, search step length, search order, and the number of candidate BVs in the first candidate list. The encoding method according to claim 25.

27. If the first flag indicates filtering, the parameter corresponding to the first flag includes a first search range; if the first flag indicates no filtering, the parameter corresponding to the first flag includes a second search range, and the first search range is smaller than the second search range. The encoding method according to claim 25.

28. The aforementioned at least one candidate list includes the first candidate list, Determining the at least one candidate list based on the plurality of candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, This includes sorting the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the first candidate list, The encoding method according to any one of claims 24 to 27.

29. Based on the aforementioned at least one candidate list, determining a first flag to indicate whether or not to filter, and a first index to indicate candidate BV within the first candidate list of the aforementioned at least one candidate list, Determining the distortion cost of the reference block corresponding to the candidate BV in the first candidate list, Filtering is performed on the reference blocks corresponding to the candidate BV in the first candidate list, and the distortion cost of the filtered reference blocks corresponding to the candidate BV in the first candidate list is obtained. The process includes determining the first flag and the first index based on the distortion cost of the reference block corresponding to the candidate BV in the first candidate list and the distortion cost of the filtered reference block corresponding to the candidate BV in the first candidate list, The encoding method according to claim 28.

30. The at least one candidate list includes a second candidate list and a third candidate list, and if the first flag indicates filtering, the first candidate list is the second candidate list, and if the first flag indicates no filtering, the first candidate list is the third candidate list. The encoding method according to any one of claims 24 to 27.

31. Determining the at least one candidate list based on the plurality of candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, Based on the template matching costs of the plurality of candidate BVs, at least one candidate BV is determined from among the plurality of candidate BVs. The process involves filtering the templates corresponding to the candidate BVs within the at least one candidate BV, and obtaining filtered templates corresponding to the candidate BVs within the at least one candidate BV. The template matching cost of the candidate BV in the at least one candidate BV is determined based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, The process includes sorting the at least one candidate BV based on the template matching cost of the candidate BVs within the at least one candidate BV to obtain the second candidate list, The encoding method according to claim 30.

32. Determining at least one candidate BV from among the multiple candidate BVs based on the template matching costs of the multiple candidate BVs is: The process involves rearranging the multiple candidate BVs based on the template matching cost of each candidate BV, This includes determining some of the candidate BVs that are at the front after being rearranged as the at least one candidate BV, The encoding method according to claim 31.

33. Determining the at least one candidate list based on the plurality of candidate BVs is: The template matching cost of the aforementioned multiple candidate BVs is determined, This includes sorting the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs to obtain the third candidate list, The encoding method according to claim 30.

34. Based on the aforementioned at least one candidate list, determining a first flag to indicate whether or not to filter, and a first index to indicate candidate BV within the first candidate list of the aforementioned at least one candidate list, Determining the distortion cost of the reference block corresponding to candidate BV in the second candidate list, The process involves filtering the reference blocks corresponding to the candidate BV in the third candidate list, and obtaining the distortion cost of the filtered reference blocks corresponding to the candidate BV in the third candidate list. The process includes determining the first flag and the first index based on the distortion cost of the reference block corresponding to the candidate BV in the second candidate list and the distortion cost of the filtered reference block corresponding to the candidate BV in the third candidate list. The encoding method according to any one of claims 30 to 33.

35. Encoding the first flag and the first index is The first index is encoded based on the first flag, The encoding method according to any one of claims 22 to 34.

36. Encoding the first index based on the first flag is: The first index is encoded based on a binarization method corresponding to the first flag, The encoding method according to claim 35.

37. If the first flag indicates no filtering, the binarization method corresponding to the first flag includes at least one of a variable-length code binarization method and a truncated unary binarization method; if the first flag indicates filtering, the binarization method corresponding to the first flag includes at least one of a fixed-length code binarization method and a truncated binary binarization method. The encoding method according to claim 36.

38. Encoding the first index based on the first flag is: The first index is encoded based on the context model corresponding to the first flag. The encoding method according to claim 35.

39. The aforementioned encoding method is Based on the predicted block of the current block and the original block of the current block, the residual block of the current block is determined. The further includes determining the reconstruction block of the current block based on the residual block and the predicted block, The encoding method according to any one of claims 22 to 38.

40. The aforementioned encoding method is If the first flag indicates filtering, the first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and the second template area of ​​the current block are obtained, The further includes determining filter coefficients based on the first template region and the second template region, The encoding method according to any one of claims 22 to 39.

41. Determining the filter coefficients based on the first template region and the second template region is: With respect to the first sample in the first template region, the first sample is filtered using samples from the surrounding region of the first sample to obtain a filtered second sample. The method involves determining the filter coefficient based on the difference between the second sample and the third sample in the second template region, wherein the position of the first sample in the first template region is the same as the position of the third sample in the template region. The encoding method according to claim 40.

42. If the samples in the peripheral region of the first sample include samples at a first position other than the first template region, the samples at the first position are samples obtained by padding the first position using samples within the first template region. The encoding method according to claim 41.

43. The aforementioned filter coefficients are coefficients obtained through training. The encoding method according to claim 40.

44. It is a decoder, An acquisition unit configured to acquire a first flag and a first index to indicate whether or not to filter, A first decision unit is configured to determine a first candidate list consisting of candidate block vectors (BVs) of the current block based on a first prediction mode corresponding to intra-template prediction, A decoder comprising: a first flag and a second decision unit configured to determine a predicted block for the current block based on a candidate BV indicated by the first index in the first candidate list.

45. It is an encoder, A first decision unit is configured to determine at least one candidate list consisting of candidate block vectors (BVs) of the current block based on a first prediction mode corresponding to intra-template prediction, A second decision unit is configured to determine a first flag for indicating whether or not to filter based on the at least one candidate list, and a first index for indicating a candidate BV within the first candidate list of the at least one candidate list. An encoder comprising: a coding unit configured to encode the first flag and the first index.

46. It is an electronic device, A processor configured to run computer programs, An electronic device comprising: a computer-readable storage medium storing a computer program, wherein when the computer program is executed by the processor, the computer-readable storage medium implements the method according to any one of claims 1 to 21 or the method according to any one of claims 22 to 42.

47. A computer-readable storage medium storing a computer program that causes a computer to perform the method according to any one of claims 1 to 21, or the method according to any one of claims 22 to 42.

48. A computer program product comprising a computer program / instruction that, when executed by a processor, implements the method according to any one of claims 1 to 21 or the method according to any one of claims 22 to 42.

49. A bitstream, wherein the bitstream is a bitstream that is decoded by the method described in any one of claims 1 to 21, or a bitstream that is encoded and generated by the method described in any one of claims 22 to 42.