Decoding method, encoding method, decoder, and encoder

By introducing a first identifier and a first index into digital video compression technology, combined with intra-frame template prediction mode, the problem of insufficient video compression efficiency in existing technologies is solved, and higher decoding performance is achieved.

WO2024197744A9PCT designated stage expired Publication Date: 2025-10-30GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/085248
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2025-10-30

AI Technical Summary

Technical Problem

Existing digital video compression technologies are insufficient in improving compression efficiency, especially when high video resolution is required, existing decompression technologies are unable to meet the demands.

Method used

By introducing a first identifier and a first index, combined with the intra-frame template prediction mode, the candidate block vector (BV) of the current block is determined, improving the accuracy of the predicted block and thus enhancing decoding performance.

Benefits of technology

This improves the accuracy of the predicted blocks, thereby enhancing the decoding performance of the decoder.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023085248_30102025_PF_FP_ABST
    Figure CN2023085248_30102025_PF_FP_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 comprises: acquiring a first identifier used for indicating whether to perform filtering, and a first index; on the basis of a first prediction mode corresponding to intraframe template prediction, determining a first candidate list formed by a candidate block vector (BV) of a current block; and on the basis of the first identifier and a candidate BV, which is indicated by the first index, in the first candidate list, determining a prediction block of the current block. According to the present application, by introducing the first identifier and the first index, the prediction block of the current block can be determined according to the candidate BV indicated by the first index and the first identifier, so that the accuracy of the prediction block is improved, thereby further improving the decoding performance of the decoder.
Need to check novelty before this filing date? Find Prior Art

Description

Decoding methods, encoding methods, decoders, and encoders Technical Field

[0001] This application relates to the field of encoding and decoding technology, and more specifically, to decoding methods, encoding methods, decoders, and encoders. Background Technology

[0002] Digital video compression technology primarily compresses massive amounts of digital video data to facilitate transmission and storage. With the surge in internet video and increasing demands for video clarity, while existing digital video compression standards can achieve video decompression, there is still a need to pursue better digital video decompression technologies to improve compression efficiency.

[0003] Summary of the Invention

[0004] This application provides a decoding method, an encoding method, a decoder, and an encoder, which can improve encoding and decoding performance.

[0005] In a first aspect, embodiments of this application provide a decoding method, including:

[0006] Obtain the first identifier and first index used to indicate whether filtering is required;

[0007] Based on the first prediction mode corresponding to the intra-frame template prediction, a first candidate list is determined by the candidate block vector (BV) of the current block;

[0008] Based on the first identifier and the candidate BV indicated by the first index in the first candidate list, the predicted block of the current block is determined.

[0009] Secondly, embodiments of this application provide an encoding method, including:

[0010] Based on the first prediction mode corresponding to the intra-frame template prediction, determine at least one candidate list formed by the candidate block vector (BV) of the current block;

[0011] Based on the at least one candidate list, a first identifier for indicating whether filtering is performed and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list are determined;

[0012] The first identifier and the first index are encoded.

[0013] Thirdly, embodiments of this application provide a decoder, including:

[0014] The acquisition unit is used to acquire a first identifier and a first index that indicate whether filtering is required;

[0015] The first determining unit is used to determine a first candidate list formed by the candidate block vector (BV) of the current block based on the first prediction mode corresponding to the intra-frame template prediction.

[0016] The second determining unit is configured to determine the predicted block of the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list.

[0017] Fourthly, embodiments of this application provide an encoder, including:

[0018] The first determining unit is used to determine at least one candidate list formed by the candidate block vector (BV) of the current block based on the first prediction mode corresponding to the intra-frame template prediction.

[0019] The second determining unit is configured to determine, based on the at least one candidate list, a first identifier for indicating whether filtering is required and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list;

[0020] An encoding unit is used to encode the first identifier and the first index.

[0021] Fifthly, embodiments of this application provide a decoder, including:

[0022] Processor, adapted to implement computer instructions; and,

[0023] A computer-readable storage medium storing computer instructions adapted for loading by a processor and executing the decoding method in the first aspect or its various implementations mentioned above.

[0024] In one implementation, there are one or more processors and one or more memories.

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

[0026] Sixthly, embodiments of this application provide an encoder, including:

[0027] Processor, adapted to implement computer instructions; and,

[0028] A computer-readable storage medium storing computer instructions adapted for loading by a processor and executing the encoded methods of the second aspect or its various implementations mentioned above.

[0029] In one implementation, there are one or more processors and one or more memories.

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

[0031] In a seventh aspect, embodiments of this application provide a computer-readable storage medium storing computer instructions that, when read and executed by a processor of a computer device, cause the computer device to perform the decoding method or the encoding method described in the first aspect above.

[0032] Eighthly, embodiments of this application provide a computer program product or computer program that includes computer instructions 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, causing the computer device to perform the decoding method described in the first aspect above or the encoding method described in the second aspect above.

[0033] Ninthly, embodiments of this application provide a bitstream, which is the bitstream described in the first aspect above or the bitstream generated by the second aspect above.

[0034] Based on the above technical solutions, this application introduces a first identifier and a first index, which can combine the candidate BV indicated by the first index and the first identifier to determine the predicted block of the current block, thereby improving the accuracy of the predicted block and thus improving the decoding performance of the decoder. Attached Figure Description

[0035] Figure 1 is a schematic block diagram of the coding framework provided in an embodiment of this application.

[0036] Figure 2 is a schematic block diagram of the decoding framework provided in an embodiment of this application.

[0037] Figure 3 is an example of intra-frame prediction provided in an embodiment of this application.

[0038] Figure 4 is an example of an MRL provided in an embodiment of this application.

[0039] Figure 5 is an example of the intra-frame prediction mode provided in the embodiments of this application.

[0040] Figure 6 is another example of the intra-frame prediction mode provided in the embodiments of this application.

[0041] Figure 7 is another example of the intra-prediction mode provided in the embodiments of this application.

[0042] Figure 8 is an example of the wide-angle mode provided in the embodiments of this application.

[0043] Figure 9 is an example of screen content provided in an embodiment of this application.

[0044] Figure 10 is an example of TM provided in the embodiments of this application.

[0045] Figure 11 is an example of intraTMP in an embodiment of this application.

[0046] Figure 12 is an example of a candidate BV from the candidate list provided in an embodiment of this application.

[0047] Figure 13 is an example of a filter provided in an embodiment of this application.

[0048] Figure 14 is a schematic diagram of the training filter coefficients provided in an embodiment of this application.

[0049] Figure 15 is a schematic flowchart of the decoding method provided in the embodiments of this application.

[0050] Figure 16 is a schematic flowchart of the encoding method provided in the embodiments of this application.

[0051] Figure 17 is a schematic block diagram of the decoder provided in an embodiment of this application.

[0052] Figure 18 is a schematic block diagram of the encoder provided in an embodiment of this application.

[0053] Figure 19 is a schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0054] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0055] The solutions provided in this application can be applied to the field of digital video coding technology, including, but not limited to, image encoding and decoding, video encoding and decoding, hardware video encoding and decoding, dedicated circuit video encoding and decoding, and real-time video encoding and decoding. Furthermore, the solutions provided in this application can be combined with Audio Video Coding Standard (AVS), AVS2, or AVS3. For example, they include, but are not limited to, H.264 / Audio Video Coding (AVC), H.265 / High Efficiency Video Coding (HEVC), and H.266 / Versatile Video Coding (VVC). Additionally, the solutions provided in this application can be used for lossy compression or lossless compression of images. This lossless compression can be visually lossless compression or mathematically lossless compression.

[0056] Video codec standards can adopt a block-based hybrid coding framework. The basic process of a video codec is as follows:

[0057] At the encoding end, a frame of image is divided into blocks. Intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block. The original block of the current block is subtracted from the prediction block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. The quantization coefficient matrix is ​​then entropy-encoded and output to the bitstream. At the decoding end, intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block. On the other hand, the bitstream is parsed to obtain the quantization coefficient matrix. The quantization coefficient matrix is ​​inverse-quantized and inverse-transformed to obtain a residual block. The prediction block and the residual block are added to obtain a reconstructed block. The reconstructed blocks form a reconstructed image. Loop filtering is performed on the reconstructed image based on the image or based on the blocks to obtain a decoded image. The encoding end also needs similar operations to the decoding end to obtain the decoded image. The decoded image can be used as a reference image for inter-frame prediction in subsequent frames. The block division information, prediction, transform, quantization, entropy coding, loop filtering, and other mode information or parameter information determined at the encoding end need to be output to the bitstream if necessary. The decoding end determines the same block partitioning information, prediction, transform, quantization, entropy coding, loop filtering, and other mode or parameter information as the encoding end by parsing and analyzing existing information, thereby ensuring that the decoded image obtained by the encoding end is the same as that obtained by the decoding end. The decoded image obtained by the encoding end is usually also called the reconstructed image. During prediction, the current block can be divided into prediction units, and during transform, the current block can be divided into transform units. The division of prediction units and transform units can be different. The above is the basic flow of a video codec under a block-based hybrid coding framework. With the development of technology, some modules or steps of this framework or flow may be optimized. This application applies to the basic flow of a video codec under this block-based hybrid coding framework, but is not limited to this framework and flow.

[0058] Figure 1 is a schematic block diagram of the coding framework 100 provided in an embodiment of this application.

[0059] As shown in Figure 1, the coding framework 100 may include an intra-frame prediction unit 180, an inter-frame 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 also include a decoded image buffer unit 160.

[0060] The intra-frame prediction unit 180 or inter-frame prediction unit 170 can predict the image block to be encoded to output a predicted block. The residual unit 110 can calculate a residual block based on the predicted block and the image block to be encoded, i.e., the difference between the predicted block and the image block to be encoded. The transform and quantization unit 120 is used to perform transform and quantization operations on the residual block to remove information that is not sensitive to the human eye, thereby eliminating visual redundancy. Optionally, the residual block before transform and quantization by the transform and quantization unit 120 can be called a temporal residual block, and the temporal residual block after transform and quantization by the transform and quantization unit 120 can be called a frequency residual block or a frequency domain residual block. After receiving the transform and quantization coefficients output by the transform and quantization unit 120, the entropy coding unit 130 can output a bitstream based on the transform and quantization coefficients. For example, the entropy coding unit 130 can eliminate character redundancy based on the target context model and the probability information of the binary bitstream. For example, the entropy coding unit 130 can be used for context-based adaptive binary arithmetic entropy coding (CABAC). The entropy coding unit 130 can also be called a header information coding unit. Optionally, in this application, the image block to be encoded can also be called an original image block or a target image block, the prediction block can also be called a prediction image block or an image prediction block, or a prediction signal or prediction information, and the reconstruction block can also be called a reconstructed image block or an image reconstruction block, or a reconstruction signal or reconstruction information. Furthermore, for the encoding end, the image block to be encoded can also be called an encoded block or an encoded image block; for the decoding end, the image block to be encoded can also be called a decoded block or a decoded image block. The image block to be encoded can be a CTU or a CU.

[0061] The coding framework 100 calculates the residual between the predicted block and the image block to be encoded to obtain the residual block. Through processes such as transformation and quantization, the residual block is transmitted to the decoding end. Correspondingly, the decoding end receives the bitstream and decodes it. After performing steps such as inverse transformation and inverse quantization, the residual block is obtained. The predicted block obtained by the decoding end is superimposed with the residual block to obtain the reconstructed block.

[0062] It should be noted that the inverse transform and inverse quantization unit 140, the loop filtering unit 150, and the decoded image buffer unit 160 in the coding framework 100 can be used to form a decoder. This is equivalent to the intra-frame prediction unit 180 or the inter-frame prediction unit 170 predicting the image block to be encoded based on the existing reconstructed block, thus ensuring that the encoding and decoding ends have a consistent understanding of the reference image. In other words, the encoder can replicate the decoder's processing loop, thereby producing the same predictions as the decoder. Specifically, the quantized transform coefficients are inversely transformed and inverse quantized by the inverse transform and inverse quantization unit 140 to replicate the approximate residual block at the decoding end. This approximate residual block, plus the prediction block, can then pass through the loop filtering unit 150 to smoothly filter out block artifacts and other effects caused by block-based processing and quantization. The image block output by the loop filtering unit 150 can be stored in the decoded image buffer unit 160 for use in the prediction of subsequent images.

[0063] It should be understood that Figure 1 is merely an example of this application and should not be construed as a limitation of this application.

[0064] For example, the loop filtering unit 150 in the coding framework 100 may include a deblocking filter (DBF) and sample adaptive offset (SAO) filtering. The DBF removes blocking artifacts, and the SAO removes ringing artifacts. In other embodiments of this application, the coding framework 100 may employ a neural network-based loop filtering algorithm to improve video compression efficiency. Alternatively, the coding framework 100 may be a hybrid video coding framework based on deep learning neural networks. In one implementation, a convolutional neural network-based model can be used to calculate the filtered pixel results based on the deblocking filter and sample adaptive offset filtering. The network structures of the loop filtering unit 150 for the luminance and chrominance components may be the same or different. Considering that the luminance component contains more visual information, the luminance component can also guide the filtering of the chrominance component to improve the reconstruction quality of the chrominance component.

[0065] Figure 2 is a schematic block diagram of the decoding framework 200 provided in an embodiment of this application.

[0066] As shown in Figure 2, the decoding framework 200 may include an entropy decoding unit 210, an inverse transform and inverse quantization unit 220, a residual unit 230, an intra-frame prediction unit 240, an inter-frame prediction unit 250, a loop filtering unit 260, and a decoded image buffer unit 270. The entropy decoding unit 210 receives and parses the bitstream to obtain a prediction block and a frequency domain residual block. For the frequency domain residual block, the inverse transform and inverse quantization unit 220 performs inverse transform and inverse quantization steps to obtain a time domain residual block. The residual unit 230 superimposes the prediction block obtained by the intra-frame prediction unit 240 or the inter-frame prediction unit 250 onto the time domain residual block after inverse transform and inverse quantization by the inverse transform and inverse quantization unit 220 to obtain a reconstructed block.

[0067] For ease of understanding, the following explanation is provided regarding the content related to this application.

[0068] (1) Intra-frame prediction.

[0069] There is a strong spatial correlation between adjacent parts or adjacent pixels within an image. Intra-frame prediction is a prediction method that utilizes the spatial correlation between the encoded and decoded pixels surrounding the current block and the 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 left column and top row of the current block are the reference pixels for the current block. Intra-frame prediction uses these reference pixels to predict the current block. These reference pixels may all be available, i.e., all have been encoded and decoded. Some may also be unavailable. For example, if the current block is the leftmost part of the entire frame, then the reference pixels on the left side of the current block are unavailable. Or, if the lower left part of the current block has not yet been encoded and decoded, then the reference pixels in the lower left are also unavailable. In cases where reference pixels are unavailable, available reference pixels, certain values, or certain methods can be used to fill the gaps, or no filling can be performed.

[0070] Multiple reference line (MRL) intra-frame prediction can use more reference pixels, thereby improving coding efficiency. Figure 4 is an example of MRL provided in an embodiment of this application. As shown in Figure 4, the codec can also use four reference rows / columns as reference pixels for the current block. These four reference rows / columns can be divided into segments A to F.

[0071] Intra-frame prediction has multiple prediction modes, as shown in Figure 5. H.264 has 9 modes for intra-frame prediction of a 4x4 block. Mode 0 copies the pixels on the current block vertically to the current block as the prediction value. Mode 1 copies the reference pixels on the left horizontally to the current block as the prediction value. Mode 2 (DC) uses the average of the 8 points A to D and I to L as the prediction value for all points. Modes 3 to 8 copy the reference pixels to the corresponding positions in the current block at a certain angle. Because some positions in the current block cannot correspond exactly to the reference pixels, it may be necessary to use the weighted average of the reference pixels, or the interpolated reference pixel sub-pixels.

[0072] In addition to these, there are Plane, Planar, and other modes. With technological advancements and block size increases, the number of angle prediction modes is also increasing. As shown in Figure 6, HEVC uses 35 intra-frame prediction modes, including Planar, DC, and 33 angle modes. As shown in Figure 7, VVC uses 67 intra-frame prediction modes, including Planar, DC, and 65 angle modes. Of course, besides the 67 modes mentioned above, VVC also provides wide-angle modes for some rectangular blocks with significant differences in length and width. For example, as shown in Figure 8, the modes indicated by the dashed lines are the -14 to -1 and 67 to 80 degrees ranges, which replace some regular modes. Furthermore, AVS3 uses 66 prediction modes, including DC, Plane, Bilinear, PCM, and 62 angle modes.

[0073] (2) Inter-frame prediction.

[0074] Video consists of multiple images. To make the video appear smooth, each second of video contains dozens or even hundreds of frames, such as 24 frames per second, 30 frames per second, 50 frames per second, 60 frames per second, 120 frames per second, etc. Therefore, there is significant temporal redundancy in the video, or in other words, a great deal of temporal correlation. Inter-frame prediction utilizes this temporal correlation to improve compression efficiency. Inter-frame prediction often uses "motion" to leverage temporal correlation. A very simple "motion" model is that an object is at a certain position in the image at a certain moment, and after a certain period of time, it has translated to another position in the image corresponding to that moment. This is the most basic and commonly used translational motion in video encoding and decoding. Inter-frame prediction uses motion information to represent "motion." Basic motion information includes information about the reference frame (or reference picture) and motion vector (MV). The codec determines the reference picture based on the information of the reference picture, and determines the coordinates of the reference block based on the motion vector information and the coordinates of the current block. The coordinates of the reference block in the reference picture are used to determine the reference block. Using a defined reference block as the prediction block is the most basic prediction method for inter-frame prediction.

[0075] Motion in videos is not always simple. Even motion that can be considered translation undergoes subtle changes over time, including minute deformations, variations in brightness, and noise. More than one reference block can be used to predict the current block for better results. For example, the commonly used bidirectional prediction uses two reference blocks. These two reference blocks can be one forward reference block and one backward reference block. Later, it was also allowed that both be forward or both be backward. Forward refers to the reference image's position before the current frame, and backward refers to the reference image's position after the current frame. Alternatively, forward means the reference image's position in the video is before the current frame, and backward means the reference image's position is after the current frame. Or, forward means the reference image's POC (picture order count) is less than the current frame's POC, and backward means the reference image's POC is greater than the current frame's POC. Future video codec standards may support prediction with multiple reference blocks. A simple method to generate a prediction block using two reference blocks is to average the pixel values ​​at corresponding positions in the two reference blocks. To achieve better prediction results, weighted averaging, such as BCW (Bi-prediction with CU-level weight) currently used in VVC, can also be used. GPM (Geometric Partitioning Mode) in VVC can also be understood as a special type of bidirectional prediction. To use bidirectional prediction, two reference blocks are needed, requiring information from two sets of reference images and motion vectors.

[0076] Motion in videos isn't limited to simple translation; it also includes scaling, rotation, distortion, and various complex motions. VVC uses affine mapping to simulate some of these simpler motions. The affine model in VVC uses two or three control points, and based on these control points, a linear model is used to derive the motion vectors of each sub-block within the current block. We're referring to motion vectors rather than motion information here because they all point to the same reference image. You can think of it this way: ordinary translation finds a "whole block" from the reference image, while affine mapping finds a group of non-contiguous "sub-blocks" from the reference image. The above falls under the category of unidirectional prediction; affine mapping can also achieve bidirectional prediction or prediction of multiple "reference blocks." The reference block here is composed of sub-blocks. In practical implementation, a unidirectional motion information data structure for affine motion information can include information from a reference image and information from two to three motion vectors, or information from two to three sets of reference images and motion vectors, but the information from these reference images is identical.

[0077] (3) Intra Block Copy (IBC).

[0078] IBC significantly improves the compression efficiency of screen content coding, and therefore, it has been used for screen content coding from HEVC to VVC. Screen content differs from camera-captured content; it is computer-generated, noise-free, contains text, computer graphics, etc., and has clear boundaries. For example, as shown in Figure 9, screen content contains a large amount of repetitive content.

[0079] It can be considered that IBC applies inter-frame prediction methods to intra-frame prediction. As mentioned above, inter-frame prediction uses a reference block in a reference image as the prediction block for the current block, but the reference image is not the current image. IBC, on the other hand, selects a block from the already encoded or reconstructed portion of the current image as the prediction block for the current block. IBC is also sometimes called intra-picture block compensation or current-picture referencing (CPR).

[0080] IBC uses a block vector (BV) to represent the positional difference between the current block and the reference block, similar to the MV in inter-frame prediction. The encoder determines the best matching block for the current block within the search range using block matching and encodes the BV. There are various methods for encoding the BV, which will not be elaborated here.

[0081] IBC can be considered as an intra-frame prediction method, or it can be considered as another type of prediction method independent of intra-frame prediction and inter-frame prediction. This issue will not be discussed here.

[0082] (4) Template matching (TM).

[0083] The TM method was first used in inter-frame prediction. It utilizes the correlation between adjacent pixels, using some regions surrounding the current block as templates. During the encoding and decoding of the current block, its left and top sides are already encoded and decoded according to the encoding order. However, in existing hardware decoder implementations, it's not guaranteed that the left and top sides are already decoded when the current block begins decoding. This refers to inter-frame blocks; for example, in HEVC, inter-frame coded blocks do not require surrounding reconstructed pixels when generating prediction blocks, thus the prediction process for inter-frame blocks can be performed in parallel. However, intra-frame coded blocks always require reconstructed pixels on the left and top sides as reference pixels. Theoretically, the left and top sides are available, meaning that hardware design adjustments can be made accordingly. Relatively speaking, the right and bottom sides are not available under current standards such as VVC's encoding order.

[0084] Figure 10 is an example of TM provided in the embodiments of this application.

[0085] As shown in Figure 10, the rectangular regions on the left and top of the current block are set as templates. The height of the template on the left is generally the same as the height of the current block, and the width of the template on the top is generally the same as the width of the current block, although they can be different. The optimal matching position of the template is found in the reference frame to determine the motion information or motion vector of the current block. This process can be roughly described as starting from a starting position in a reference frame and searching within a certain range around it. Search rules, such as the search range and search step size, can be pre-defined. At each position, the matching degree between the template at that position and the templates surrounding the current block is calculated. The matching degree can be measured by some distortion costs, such as the sum of absolute difference (SAD), the sum of absolute transformed difference (SATD), and the mean-square error (MSE). The transformation generally used for SATD is the Hadamard transform. The smaller the values ​​of SAD, SATD, and MSE, the higher the matching degree. The cost is calculated using the predicted block of the template at that position and the reconstructed blocks of the templates surrounding the current block. Besides searching at integer pixel positions, pixel-level searches can also be performed. The motion information for the current block is determined based on the position with the highest matching degree. Utilizing the correlation between adjacent pixels, motion information suitable for the template may also be suitable for the current block. Of course, template matching may not be applicable to all blocks. Therefore, methods can be used to determine whether to use template matching for the current block, such as using a control switch within the current block to indicate whether template matching is used. A typical template matching technique is called decoder-side motion vector derivation (DMVD). Both the encoder and decoder can use templates to search and derive motion information or find better motion information based on existing motion information. It does not require transmitting specific motion vectors or motion vector differences; instead, both the encoder and decoder perform the same search rules to ensure consistency between encoding and decoding. Template matching can improve compression performance, but it requires a "search" in the decoder as well, thus introducing some decoder complexity.

[0086] (5) Intra-template matching prediction (intraTMP).

[0087] IntraTMP can be considered a technique combining IBC and TM. As mentioned above, using TM in inter-frame mapping can reduce the overhead of encoding MV; similarly, using TM in IBC can reduce the overhead of encoding BV. One example is that BV encoding can be eliminated, and the matching block found by TM can be directly used as the prediction block of the current block in the intraTMP mode.

[0088] An example of IntraTMP, as shown in Figure 11, involves the encoder (or decoder) selecting reconstructed pixels in the L-shaped region adjacent to the current coding block as templates. Within the reconstructed region of the given current frame, the encoder searches for the most similar template and uses the reconstructed block corresponding to the most similar template as the matching block, which is then used as the prediction block for the current coding block. For example, R1 to R4 in the figure represent the search regions available in IntraTMP mode. Matching blocks can be searched point-by-point within R1 to R4 in raster scan order.

[0089] One key reason why IBC significantly improves the compression efficiency of screen content encoding is that screen content often contains many repeating blocks and typically has sharp boundaries. In terms of color (brightness and chroma), there are often large areas of the same color (brightness and chroma). Camera-captured content, however, almost never exhibits this characteristic. Camera-captured content inevitably contains noise, and even areas that appear uniform in color at first glance usually show variations in brightness and chroma. Furthermore, camera-captured content rarely has sharp boundaries. On the other hand, while camera-captured content does contain near-repeating blocks, these are considered near-repeating because noise, subtle variations in brightness, and perspective make it difficult to find completely identical blocks. Nevertheless, the presence of repetitive textures in camera-captured content is undeniable.

[0090] Typically, intraTMP uses the best matching block found through template matching as its final predicted block. That is, when decoding the current block, a flag indicates whether intraTMP is used. If intraTMP is used, the decoder finds a best matching block using template matching and uses its value as the predicted value for the current block. It's important to note that while the template and the current block have a strong correlation, the template is not the current block. The best matching block found using the template (actually, the position of the current block corresponding to the template's best matching block) may not necessarily be the best matching block for the current block. However, since the decoder doesn't have the current block during the search, it can only use the best matching block found through template matching as the best matching block found by intraTMP.

[0091] (6) IntraTMP has multiple candidates.

[0092] Set N candidates for intraTMP, or in other words, set a candidate list of length N: intraTmpCandList[N]. During encoding, if the current block uses intraTMP, after encoding the flag, an index needs to be encoded to determine which of the N candidates the current block has selected. Correspondingly, the decoding syntax is as follows: intra_tmp_flag is the intraTMP flag; if intra_tmp_flag is true, then continue parsing intra_tmp_idx, where intra_tmp_idx represents the index of the selected candidate.

[0093] The decoder uses the block corresponding to intraTmpCandList[intra_tmp_idx] as the block selected by intraTMP. In other words, the decoder uses the block value corresponding to intraTmpCandList[intra_tmp_idx] as the block value selected by intraTMP.

[0094] So how should we construct an intraTmpCandList? Here's an example:

[0095] Because intraTMP calculates the cost on the template of each BV it searches. The cost on the template is generally the cost of matching the template of the current block with the template of a block of the same size determined by the current BV. This cost can be SAD, SATD, SSE, etc. IntraTMP can sort the searched blocks, or BVs, in ascending order of these costs, and the top N candidates are the N candidates in intraTmpCandList. Alternatively, it can only maintain the top N candidates with the lowest cost, and discard candidates with a ranking greater than N, thus saving computation.

[0096] Typically, adjacent Block Values ​​(BVs) are quite close to each other, especially if the BVs support pixel-level precision, such as 1 / 2, 1 / 4, 1 / 8, or 1 / 16 precision. Therefore, without control, simply sorting by the cost on the template can easily concentrate multiple candidates into a very small range. Thus, some controls are needed to prevent the candidate BVs in the `intraTmpCandList` from becoming too concentrated.

[0097] One method is as follows:

[0098] During the search process, not every possible BV is searched sequentially. For example, the usual search order is from left to right and from top to bottom. Generally, for integer-pixel BVs, a sequential search can be performed. If the currently searched BV is (x0, y0), the next one is (x0+1, y0), provided the search boundary is not reached. However, we can first perform a sparse search. For example, for integer-pixel BVs, if the currently searched BV is (x0, y0), the next one is (x0+4, y0), provided the search boundary is not reached. That is, template matching is performed every certain number of pixels, or every certain step size. The step size can be a preset value, such as 2, 4, 8, etc. The same process can be performed vertically. First, find the BV with the minimum cost N. Then, based on the BV with the minimum cost N intervals, improve within a small range for each BV. If the search interval above is 4 pixels, then the improvement range can be set to 4x4. The improved BV can replace the original BV and be reordered among the N candidates. This way, N candidates with BVs at certain distances can be obtained.

[0099] For example, if N is 3, it can be improved in the following way:

[0100] first step:

[0101] As shown in Figure 12(a), the first search is performed with a preset step size, and the upper left corner of the searched block is indicated by the gray dot. As shown in Figure 12(b), three sorted BVs are found, and the upper left corner of the corresponding block is indicated by the black dot. Here, the horizontal step size is 4, and the vertical step size is also 4.

[0102] Step Two:

[0103] Based on the three sorted BVs, a second search is performed. This time, the search range is 4x4, as shown by the green dots in the figure. In each 4x4 BV, the BV with the lowest cost is found to replace the original BV and participate in the sorting of intraTmpCandList. Of course, if the BV with the lowest cost is still the original BV, it is not necessary to re-sort.

[0104] If pixel-level precision is supported, further refinement to the pixel-level BV can be achieved. For example, based on the integer pixel BV selected in the second step, a search can be performed within a one-pixel range up, down, left, and right.

[0105] It is worth noting that both the encoder and decoder perform the construction of the candidate list, thus ensuring that the candidate list obtained by the encoder and the decoder are consistent.

[0106] (7) Binarization method of Intra_tmp_idx.

[0107] Since intraTmpCandList is sorted, statistically speaking, candidates that appear earlier in the list have a higher probability of being selected. Therefore, variable-length encoding can be set for the binarization and debinarization of intra_tmp_idx, or truncated unary codes can be used. For example, the side length encoding methods are shown in Table 1 below.

[0108] Table 1

[0109] Of course, if the probabilities are roughly the same, fixed-length encoding or truncated binary can be used.

[0110] If N is relatively large, the earlier candidates have higher probabilities, and the probabilities decrease as you go further down the list. Furthermore, the probabilities tend to become closer together as you go further down the list. Therefore, you can use shorter codewords for the earlier candidates and longer codewords for the later candidates, while using the same codeword length for some of the later candidates. For example, you can use the encoding method shown in Table 2.

[0111] Table 2

[0112] As shown in Table 2, assuming N is 15, indices 3 to 6 use codewords of the same length, and indices 7 to 14 use codewords of the same length. The x in the table above can be obtained by truncating binary.

[0113] (8) IntraTMP filtering.

[0114] In the intraTMP method described above, the prediction block is directly generated using the reference block. In other words, if the determined BV is of integer pixel precision, the value at the corresponding position in the reference block is directly used as the value at the corresponding position in the prediction block. If the determined BV is of fractional pixel precision, the value at the corresponding position obtained through interpolation filtering is directly used as the value at the corresponding position in the prediction block. After directly generating the prediction block, filtering operations can be performed on the predicted values ​​to improve the prediction block.

[0115] A block-level flag can be used to indicate whether the current block uses the filtering process.

[0116] There can be many forms of filters. One possible filter form is shown below:

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

[0118] This filter uses the pixel to be filtered and its three adjacent pixels (top, bottom, left, and right) 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 median of the pixel value range; that is, if the pixel value is the 10-bit maximum value of 1023, then B is set to 512. c0, c1, c2, c3, c4, and c5 are the filter coefficients.

[0119] In addition, one method for determining filter coefficients is to train the filter coefficients using a template from a reference block and a template from the current block. An example is shown in Figure 14. If intraTMP uses a template with a top height of 4 and a left width of 4, then the template for training the filter can also use the same size. Areas exceeding the reference block template can be padded from within the reference block template, thus not increasing bandwidth.

[0120] Another method for training filter coefficients is to calculate a set of coefficients that minimizes the mean square error (MSE) between the filtered reference block template and the current block template.

[0121] If the current block uses intraTMP filtering, the prediction block obtained directly from the reference block is filtered. One method is to filter each pixel sequentially from left to right and top to bottom. The filtered value is then used as the prediction value.

[0122] It is worth noting that the intraTMP multi-candidate method uses templates to filter a small subset of promising candidates from a massive number of possible block values ​​(BVs), and then the encoder selects one candidate to determine the reference block or prediction block for the current block. Due to the correlation between the current block and the template, the template can effectively filter out most unreasonable BVs. On the other hand, the encoder can access the original pixel values ​​of the current block, so it can make a more accurate judgment than the decoder. This collaboration between the encoder and decoder achieves better compression efficiency. IntraTMP filtering can use templates to train the filter coefficients, improving upon the original prediction values ​​of intraTMP.

[0123] Figure 15 is a schematic flowchart of the decoding method 300 provided in an embodiment of this application. It should be understood that this decoding method 300 can be executed by a decoder. For example, it can be applied to the decoding framework 200 shown in Figure 2. For ease of description, an encoder will be used as an example below.

[0124] As shown in Figure 15, the decoding method 300 may include some or all of the following:

[0125] S310, the decoder obtains a first identifier and a first index to indicate whether filtering is required.

[0126] For example, the first identifier can be a sequence-level identifier, an image-level (i.e., frame-level) identifier, a slice-level identifier, or an image block-level identifier.

[0127] S320, the decoder determines the first candidate list formed by the candidate block vector (BV) of the current block based on the first prediction mode corresponding to the intra-frame template prediction.

[0128] For example, the first prediction mode can be the intraTMP mode mentioned above.

[0129] S330, the decoder determines the predicted block of the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list.

[0130] In this embodiment, by introducing a first identifier and a first index, the predicted block of the current block can be determined by combining the candidate BV indicated by the first index and the first identifier, thereby improving the accuracy of the predicted block and thus improving the decoding performance of the decoder.

[0131] In some embodiments, S310 may include:

[0132] Obtain the second identifier;

[0133] If the second identifier indicates that the first prediction mode is used to predict the current block, then the first identifier and the first index are obtained.

[0134] For example, the decoder decodes the bitstream to obtain the second identifier. If the second identifier indicates that the first prediction mode is used for prediction, the decoder decodes the bitstream to obtain the first identifier and the first index; otherwise, the decoder uses other prediction modes to obtain the prediction block. The second identifier can be a sequence-level identifier, an image-level (i.e., frame-level) identifier, a slice-level identifier, or an image block-level identifier.

[0135] For example, a value of 0 for the second identifier indicates that the first prediction mode is used for prediction, and a value of 1 for the second identifier indicates that the first prediction mode is not used for prediction. Alternatively, a value of 1 for the second identifier indicates that the first prediction mode is used for prediction, and a value of 0 for the second identifier indicates that the first prediction mode is not used for prediction. Of course, other values ​​can also be used for indication, and this application does not limit this.

[0136] Of course, the identifier can also achieve the corresponding indication function in other ways, and this application does not limit it.

[0137] For example, when the value of the second identifier is "true", it indicates that the first prediction mode should be used for prediction; when the value of the second identifier is "false", it indicates that the first prediction mode should not be used for prediction.

[0138] In some embodiments, S320 may include:

[0139] The decoder first performs template matching on the current block based on the first prediction mode to obtain multiple candidate BVs; then, based on the multiple candidate BVs, it determines the first candidate list.

[0140] 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 preset parameters (e.g., search range, search step size, search order, at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; or it can perform template matching on the current block according to the parameters corresponding to the first identifier (e.g., search range, search step size, search order, at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs.

[0141] For example, when the decoder determines the first candidate list based on the multiple candidate BVs, it can also construct the first candidate list based on the multiple candidate BVs according to a preset construction method, or it can construct the first candidate list based on the multiple candidate BVs according to the construction method corresponding to the first identifier.

[0142] It is worth noting that regardless of whether the decoder performs template matching on the current block according to the parameters corresponding to the first identifier (e.g., search range, search step size, search order, or at least one of the 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 identifier, it indicates that the first candidate list determined by the decoder when filtering is performed is different from the first candidate list determined by the decoder when filtering is not performed.

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

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

[0145] In this embodiment, considering the first identifier, when the decoder performs template matching on the current block based on the first prediction mode, it performs template matching on the current block according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs. This ensures that the first candidate list used by the decoder is a candidate list that is adapted to the first identifier, thereby improving the decoding performance of the decoder.

[0146] Of course, in other alternative embodiments, different values ​​of the first identifier correspond to the same parameters. For example, regardless of the value of the first identifier, the decoder can perform template matching on the current block according to preset parameters to obtain the multiple candidate BVs.

[0147] In some embodiments, the parameters corresponding to the first identifier include at least one of the following: search range, search step size, search order, and the number of candidate BVs in the first candidate list.

[0148] Of course, in other alternative embodiments, the parameters corresponding to the first identifier may also include other parameters for the decoder to perform template matching, and this application does not specifically limit this.

[0149] In some embodiments, if the first identifier indicates filtering, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates no filtering, the parameters corresponding to the first identifier include a second search range; wherein the first search range is smaller than the second search range.

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

[0151] For example, if the first identifier indicates filtering, the decoder performs template matching on the current block according to the first prediction mode and the first search range to obtain multiple candidate BVs within the first search range, and determines the first candidate list based on the multiple candidate BVs within the first search range; if the first identifier indicates no filtering, the decoder performs template matching on the current block according to the second search range based on the first prediction mode to obtain multiple candidate BVs within the second search range, and then determines the first candidate list based on the multiple candidate BVs within the second search range. The first search range can be a search range smaller than the second search range.

[0152] Similarly, different values ​​of the first identifier can also correspond to different search step sizes, different search orders, or different numbers of candidate BVs.

[0153] For example, if the first identifier indicates that filtering is to be performed, the parameters corresponding to the first identifier include a first search step size; if the first identifier indicates that filtering is not to be performed, the parameters corresponding to the first identifier include a second search step size; wherein the first search step size is greater than the second search step size.

[0154] For example, if the first identifier indicates that filtering is to be performed, the parameters corresponding to the first identifier include a first search order; if the first identifier indicates that filtering is not to be performed, the parameters corresponding to the first identifier include a second search order; wherein the first search order is different from the second search order.

[0155] For example, if the first identifier indicates that filtering is performed, the number of candidate BVs in the first candidate list is a first number; if the first identifier indicates that filtering is not performed, the number of candidate BVs in the first candidate list is a second number; wherein the first number is less than the second number.

[0156] Of course, in the above embodiments, the first search range is smaller than the second search range, the first search step is larger than the second search step, and the first quantity is smaller than the second quantity. This is all to ensure that the number of candidate BVs in the first candidate list constructed by the decoder when the first identifier indicates filtering is less than the number of candidate BVs in the first candidate list constructed by the decoder when the first identifier indicates no filtering is performed. This reduces the complexity of the first candidate list constructed by the decoder when the first identifier indicates filtering is performed. However, this application is not limited to this. That is to say, in other alternative embodiments, the first search range may also be greater than or equal to the second search range. Similarly, the first search step may also be less than or equal to the second search step, and the first quantity may also be greater than or equal to the second quantity. This application does not make specific limitations on this.

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

[0158] In this embodiment, when the decoder determines the first candidate list based on the multiple candidate BVs, it does not need to consider the first identifier. Furthermore, since the decoder performs template matching based on the first prediction mode, there are two possibilities: considering or not considering the first identifier. Therefore, the scheme for the decoder to determine the first candidate list may include any of the following:

[0159] Option 1:

[0160] The decoder performs template matching on the current block according to preset parameters (e.g., search range, search step size, search order, and at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then, the multiple candidate BVs are sorted based on the template matching cost of the multiple candidate BVs to obtain the first candidate list.

[0161] For example, taking the preset parameters including the search range as an example, regardless of whether the first identifier indicates filtering or not, the decoder performs template matching on the current block according to the preset search range to obtain multiple candidate BVs within the preset search range. Then, based on the template matching cost of the multiple candidate BVs within the preset search range, the multiple candidate BVs within the preset search range are sorted to obtain the first candidate list.

[0162] Option 2:

[0163] The decoder performs template matching on the current block according to the parameters corresponding to the first identifier (e.g., search range, search step size, search order, and at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then, the multiple candidate BVs are sorted based on the template matching cost of the multiple candidate BVs to obtain the first candidate list.

[0164] For example, taking the search range as an example, if the first identifier 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, based on the template matching cost of the multiple candidate BVs within the first search range, the decoder sorts the multiple candidate BVs within the first search range to obtain the first candidate list. If the first identifier 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, based on the template matching cost of the multiple candidate BVs within the second search range, the decoder sorts the multiple candidate BVs within the second search range to obtain the first candidate list. The first search range is smaller than the second search range.

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

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

[0167] For example, the decoder uses the construction method corresponding to the first identifier to determine the first candidate list based on the multiple candidate BVs.

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

[0169] In some embodiments, if the first identifier indicates filtering, then the template matching cost of the plurality of candidate BVs is determined; based on the template matching cost of the plurality of candidate BVs, at least one candidate BV among the plurality of candidate BVs is determined; the template corresponding to the candidate BV among the at least one candidate BV is filtered to obtain the filtered template corresponding to the candidate BV among the at least one candidate BV; based on the filtered template corresponding to the candidate BV among the at least one candidate BV and the template of the current block, the template matching cost of the candidate BV among the at least one candidate BV is determined; the at least one candidate BV is sorted based on the template matching cost of the candidate BV among the at least one candidate BV to obtain the first candidate list.

[0170] For example, the template matching cost of the plurality of candidate BVs includes the template matching cost of each candidate BV, wherein 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 can be any parameter that can be used to measure the distortion cost, such as including but not limited to SAD, SATD, MSE, etc.

[0171] For example, when the decoder filters the template corresponding to the first candidate BV among the at least one candidate BVs, it can first determine the filter coefficients based on the template of the reference block corresponding to the first candidate BV and the template of the current block; then, it filters the template of the reference block corresponding to the first candidate BV based on the determined filter coefficients to obtain the filtered template corresponding to the first candidate BV. Further, 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.

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

[0173] In other words, if the first identifier indicates filtering, the decoder can determine the first candidate list according to the following construction method 1; wherein the construction method 1 may include the following steps: determining the template matching cost of the plurality of candidate BVs; determining at least one candidate BV among the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs; filtering the template corresponding to the candidate BV among the at least one candidate BV to obtain the filtered template corresponding to the candidate BV among the at least one candidate BV; determining the template matching cost of the candidate BV among the at least one candidate BV based on the filtered template corresponding to the candidate BV among the at least one candidate BV and the template of the current block; sorting the at least one candidate BV based on the template matching cost of the candidate BV among the at least one candidate BV to obtain the first candidate list.

[0174] In some embodiments, the decoder sorts the multiple candidate BVs based on the template matching cost of the multiple candidate BVs; and determines the candidate BVs that are ranked higher after sorting as at least one candidate BV.

[0175] For example, the decoder sorts the multiple candidate BVs in ascending order based on the template matching cost of the multiple candidate BVs; then, the candidate BV with the highest position after sorting is determined as the at least one candidate BV.

[0176] In some embodiments, if the first identifier indicates that filtering is not performed, 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 to obtain the first candidate list.

[0177] In other words, if the first identifier indicates that no filtering is performed, the decoder can determine the first candidate list according to the following construction method 2; wherein the construction method 2 may include the following process: sorting the multiple candidate BVs in ascending order based on the template matching cost of the multiple candidate BVs; and then determining the candidate BV with the highest position after sorting as the at least one candidate BV.

[0178] In this embodiment, when the decoder determines the first candidate list based on the multiple candidate BVs, it needs to determine the first candidate list based on the multiple candidate BVs and the first identifier. Since the decoder may consider or not consider the first identifier when performing template matching based on the first prediction mode, the decoder's method for determining the first candidate list may include any of the following:

[0179] Option 1:

[0180] The decoder performs template matching on the current block according to preset parameters (e.g., search range, search step size, search order, and at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then, according to the construction method corresponding to the first identifier (e.g., construction method 1 or construction method 2), the first candidate list is constructed based on the multiple candidate BVs.

[0181] For example, the decoder performs template matching on the current block according to preset parameters (e.g., search range, search step size, search order, and at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; if the first identifier indicates that filtering is to be performed, the decoder constructs the first candidate list based on the multiple candidate BVs according to construction method 1; if the first identifier indicates that filtering is not to be performed, the decoder constructs the first candidate list based on the multiple candidate BVs according to construction method 2.

[0182] Option 2:

[0183] The decoder performs template matching on the current block according to the parameters corresponding to the first identifier (e.g., search range, search step size, search order, and at least one of the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then, according to the construction method corresponding to the first identifier (e.g., construction method 1 or construction method 2), the first candidate list is constructed based on the multiple candidate BVs.

[0184] For example, taking the search range as an example, if the first identifier indicates that filtering is to be performed, 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, according to construction method 1, the first candidate list is constructed based on the multiple candidate BVs within the first search range. If the first identifier indicates that filtering is not to be performed, 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. The decoder then constructs the first candidate list based on the multiple candidate BVs within the second search range according to construction method 2. The first search range can be smaller than the second search range.

[0185] In some embodiments, S310 may include:

[0186] Obtain the first identifier;

[0187] Based on the first identifier, obtain the first index.

[0188] For example, the decoder first decodes the bitstream to obtain a first identifier, and then decodes the bitstream based on the first identifier to obtain the first index.

[0189] Of course, in other alternative embodiments, the first index may not depend on the decoding of the first identifier. For example, the decoder can obtain the first identifier and the first index simultaneously by decoding the bitstream, or the decoder can obtain the first index first by decoding the bitstream and then obtain the first identifier by decoding the bitstream.

[0190] In some embodiments, the first index is obtained based on the debinarization method corresponding to the first identifier.

[0191] In other words, different values ​​of the first identifier correspond to different debinarization methods.

[0192] In some embodiments, if the first identifier indicates that filtering is not performed, the debinarization method corresponding to the first identifier includes at least one of the following: a variable-length code binarization method and a truncated unary code binarization method; if the first identifier indicates that filtering is performed, the debinarization method corresponding to the first identifier includes at least one of the following: a fixed-length code binarization method and a truncated binary code binarization method.

[0193] For example, if the first identifier indicates that filtering is not performed, the decoder can follow the debinarization method shown in Table 3 below:

[0194] Table 3

[0195] As shown in Table 3, the smaller the value of the first index, the shorter the length of its binarized binary sequence. BinIdx0, BinIdx1, and BinIdx2 identify the first, second, and third binary numbers, respectively.

[0196] For example, if the first identifier indicates filtering, the decoder can follow the debinarization method shown in Table 4 below:

[0197] Table 4

[0198] As shown in Table 4, regardless of the value of the first index, the length of its binarized binary sequence is fixed at 2. BinIdx0 and BinIdx1 identify the first and second binary numbers, respectively.

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

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

[0201] In some embodiments, S330 may include:

[0202] If the first identifier indicates filtering, then the reference block corresponding to the candidate BV indicated by the first index is filtered to obtain the prediction block;

[0203] If the first identifier indicates that filtering is not performed, then the reference block corresponding to the candidate BV indicated by the first index is determined as the prediction block.

[0204] It is worth noting 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, it can also be understood as: the decoder first determines the reference block corresponding to the candidate BV indicated by the first index as the first predicted block of the current block, and then filters the first predicted block to obtain the second predicted block. In other words, for the decoder, the technical solution of 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; the difference lies in the perspective from which the filtering is described.

[0205] In some embodiments, the method 300 may further include:

[0206] Obtain the residual block of the current block;

[0207] Based on the residual block and the prediction block, the reconstruction block of the current block is determined.

[0208] The decoder obtains the reference block by decoding the bitstream, and determines the reconstructed block based on the residual block and the prediction block. For example, the decoder can determine the reconstructed block as the sum of the residual block and the prediction block.

[0209] In some embodiments, the method 300 may further include:

[0210] If the first identifier indicates filtering, then 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;

[0211] The filtering coefficients are determined based on the first template region and the second template region.

[0212] For example, if the first identifier indicates filtering, the decoder obtains the first template region and the second template region, determines the filtering coefficients based on the first template region and the second template region, and then filters the reference block corresponding to the candidate BV indicated by the first index to obtain the prediction block.

[0213] In some embodiments, the decoder may determine the filter coefficients in the following manner:

[0214] For the first sample within the first template region, the first sample is filtered using samples from the surrounding region to obtain the filtered second sample;

[0215] The filtering coefficients are determined based on the difference between the second sample and the third sample within the second template region; wherein the position of the first sample within the first template region is the same as the position of the third sample within the template region.

[0216] For example, the decoder can filter each sample within the first template region to obtain filtered samples within the first template region, and then determine the filtering coefficients based on the difference between the filtered samples within the first template region and the samples within the second template region. For instance, the decoder can determine the filtering coefficients based on the mean square error (MSE) between the filtered samples within the first template region and the samples within the second template region. Alternatively, the decoder can adjust the current coefficients used by the filter based on the MSE between the filtered samples within the first template region and the samples within the second template region until the MSE between the filtered samples within the first template region and the samples within the second template region is less than a preset threshold or the number of adjustments exceeds a preset number, at which point the current coefficients are determined as the filtering coefficients.

[0217] In some embodiments, when the sample in the area surrounding the first sample includes the sample at a first position outside the first template area, the sample at the first position is the sample obtained by filling the first position with the sample in the first template area.

[0218] For example, the first position is a position adjacent to the edge of the first template area. For instance, the first position can be adjacent to the top edge, bottom edge, left edge, or right edge of the first template area. For example, referring to FIG14, when the first template area is a reference template, the second template area is the current template, and the first sample is a sample at the upper left corner of the reference template, the sample at the first position can include samples above and to the left of the sample at the upper left corner of the reference template.

[0219] In some embodiments, the filtering coefficients are coefficients obtained through training.

[0220] Of course, in other alternative embodiments, the filtering coefficients can also be determined by calculating samples in the first template region and samples in the second template region, and this application does not limit this.

[0221] It should be noted that the first template region and the second template region can be referred to Figure 14 and the relevant content in the intraTMP filtering section mentioned above. To avoid repetition, they will not be repeated here. Furthermore, in other alternative embodiments, the method for determining the filter coefficients can be simplified. For example, as a possible implementation, the data used to determine the filter coefficients (i.e., the first template region and the second template region) can be simplified, for example, from the template region shown in Figure 14 to a 3x3 template region. As another possible implementation, simplification can be based on the training method; for example, a simpler training method than MSE can be used to train the filter coefficients. This application does not specifically limit this approach.

[0222] The following description is based on specific embodiments.

[0223] Example 1:

[0224] The syntax of the decoder is as follows:

[0225] The specific process of the decoder is as follows:

[0226] If the current block uses the intraTMP technique to determine the predicted value, then:

[0227] 1. Parse intra_tmp_idx and intra_tmp_filter_flag. They are independent of each other, and the order can be reversed.

[0228] 2. Within the preset search range, search for possible BVs according to the preset search method. Calculate the template matching cost of the BV based on the template corresponding to the searched BV and the template of the current block. Determine the candidate list intraTmpCandList based on the template matching cost.

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

[0230] 4. If `intra_tmp_filter_flag` is 1 or true, filter the reference block. One approach is to determine the reference block template based on the selected BV, and then determine the filter coefficients based on the reference block template and the current block template. Filter the reference block using the determined filter coefficients. Use the value at the corresponding position in the filtered reference block as the value at the corresponding position in the prediction block. If `intra_tmp_filter_flag` is 0 or false, use the value at the corresponding position in the reference block as the value at the corresponding position in the prediction block.

[0231] The encoder's specific process is as follows:

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

[0233] 2. Determine the values ​​of intra_tmp_idx and intra_tmp_filter_flag, determine the prediction value of intraTMP, and determine the encoding cost of using intraTMP.

[0234] 3. Based on the encoding cost of intraTMP, determine whether the current block uses intraTMP. If the current block uses intraTMP, encode the values ​​of intra_tmp_idx and intra_tmp_filter_flag and write them into the bitstream.

[0235] One specific method for step 2 is as follows:

[0236] For each candidate in intraTmpCandList, determine the Block Value (BV), identify the corresponding reference block, obtain the unfiltered prediction block, determine the reference block template, determine the filter coefficients based on the reference block template and the current block template, determine the filtered prediction block based on the filter coefficients and the reference block, and determine the filtered prediction block based on the current block. Compare the unfiltered and filtered prediction blocks of each candidate with the current block to determine the estimated distortion cost (SAD) or standard deviation cost (SATD). Add the estimated overhead cost (SAD) or standard deviation cost (SATD) to calculate the estimated coding cost. Based on these coding costs, select several candidate and filter combinations for Rate-Distortion Optimization (RDO) to determine the coding cost. The pseudocode is as follows:

[0237] Alternatively, rate-distortion optimization can be skipped, and the estimated encoding cost can be directly used as the encoding cost. This method is generally used when encoding complexity is limited.

[0238] Of course, the encoder can also be simplified. In the example above, the case where each candidate is filtered or not will be checked. Alternatively, all candidates can be checked first for the case where no filtering is applied, and the best one or a few can be selected to check the filtered case. The pseudocode is as follows:

[0239] In this embodiment, the encoder (or decoder) does not consider filtering when constructing the candidate list; it only arranges them according to the matching cost between the reference block template and the current block template.

[0240] Example 2:

[0241] The syntax of the decoder is as follows:

[0242] The specific process of the decoder is as follows:

[0243] If the current block uses the intraTMP technique to determine the predicted value, then:

[0244] 1. Parse intra_tmp_filter_flag and intra_tmp_idx.

[0245] 2. Construct intraTmpCandList based on intra_tmp_filter_flag.

[0246] 3. Determine the selected block volume (BV) for the current block based on the candidates in intraTmpCandList[intra_tmp_idx]. Determine the reference block.

[0247] 4. If `intra_tmp_filter_flag` is 1 or true, filter the reference block. One approach is to determine the reference block template based on the selected BV, and then determine the filter coefficients based on the reference block template and the current block template. Filter the reference block using the determined filter coefficients. Use the value at the corresponding position in the filtered reference block as the value at the corresponding position in the prediction block. If `intra_tmp_filter_flag` is 0 or false, use the value at the corresponding position in the reference block as the value at the corresponding position in the prediction block.

[0248] The decoder can take filtering into account when building the list. One approach is to filter the reference block template and use the filtered reference block template and the current block template to calculate the matching cost.

[0249] More specifically, the decoder can choose to build either a list for the unfiltered case or a list for the filtered case based on the value of `intra_tmp_filter_flag`. The search methods for the two lists, including the search range, search order, and list lengths, can be the same or different.

[0250] Analysis method:

[0251] If the list lengths are different, then you need to parse intra_tmp_filter_flag first and then parse intra_tmp_idx.

[0252] Furthermore, the binarization and debinarization methods for `intra_tmp_idx` can also be different. Even if the list lengths are the same in both cases, they may follow different probability distributions, so different binarization and debinarization methods can be set. To illustrate with a simple example, in one case (e.g., without filtering), the probability of selecting the first few candidates with very small indices is significantly higher than that of other candidates with larger indices. In this case, the binarization and debinarization methods assign shorter binary symbols to the first few candidates with very small indices and longer binary symbols to the other candidates with larger indices. In another case (e.g., with filtering), the probability of selecting the first few candidates with very small indices is similar to that of other candidates with larger indices. The difference in binary symbol lengths assigned to them by the binarization and debinarization methods is not as significant as in the first case, or they can simply use equal binary symbol lengths. In other words, the codec selects a set of binarization and debinarization methods based on the value of intra_tmp_filter_flag. For example, if the value of intra_tmp_filter_flag is 0, it selects binarization and debinarization method one; if the value of intra_tmp_filter_flag is 1, it selects binarization and debinarization method two.

[0253] Here is an example:

[0254] Binarization and debinarization method one: The correspondence between index and binary symbol is shown in Table 3 above.

[0255] Binarization and debinarization method two: The correspondence between index and binary symbol is shown in Table 4 above.

[0256] Furthermore, even if the binarization method is the same, different context models (CABAC context models) can be set for the two cases during binarization and debinarization encoding and decoding. This means that the probabilities of context-encoded binary symbols in the two cases are accumulated and updated separately. In other words, the encoder and decoder select 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, a set / one context model `contextModel0` is selected; if the value of `intra_tmp_filter_flag` is 1, a set / one context model `contextModel1` is selected.

[0257] If the list length, binarization and debinarization methods, context model, etc. are all the same, that is, if intra_tmp_idx does not depend on intra_tmp_filter_flag, then either intra_tmp_filter_flag or intra_tmp_idx can be parsed first; otherwise, that is, if intra_tmp_idx depends on intra_tmp_filter_flag, then intra_tmp_filter_flag should be parsed first, followed by intra_tmp_idx.

[0258] The decoder uses a debinarization method. Based on the mapping table between Symbols and binary symbols, if a binary symbol is encoded using context mode, the context model is selected, and the Symbol value is determined by reading the bitstream. The encoder uses a binarization method. Based on the mapping table between Symbols and binary symbols, if a binary symbol is encoded using context mode, the context model is selected, and the content to be written to the bitstream is determined based on the Symbol value. The Symbol corresponds to `intra_tmp_idx`.

[0259] Candidate list construction method:

[0260] If filtering is used, the filter coefficients can be determined based on the reference block template and the current block template corresponding to the searched BV when constructing the list. The reference block template is then filtered based on the determined filter coefficients. The matching cost is calculated using the filtered reference block template and the current block template. The list is then constructed based on the matching cost. A list sorted in ascending order of matching cost is maintained.

[0261] One approach is to derive the filter coefficients as described above for each BV in the search, filter the reference block template, and perform other similar operations. This results in a decoder with higher complexity compared to the case without filtering.

[0262] For ease of description, we refer to the process of determining the filter coefficients based on the reference block template and the current block template corresponding to the searched BV. Filtering the reference block template using the determined filter coefficients, and then calculating the matching cost using the filtered reference block template and the current block template, is called search filtering. The complexity can be reduced by decreasing the number of search filtering operations. One approach is to set a different search method than the case without filtering, such as a smaller search range or search order; for example, using a smaller search range than the case without filtering.

[0263] Another approach is to proceed in two steps. First, search without using filtering to select a small range of candidate BVs. Then, use filtering to search and filter the small range of candidate BVs to finally determine the candidate list.

[0264] Here's an example: regardless of whether the value of `intra_tmp_filter_flag` is 0 (false) or 1 (true), the existing method is used, i.e., no filtering is applied, and a candidate list `intraTmpUnfilterCandList` without filtering is constructed. If the value of `intra_tmp_filter_flag` is 1 (true), `intraTmpFilterCandList` is constructed based on `intraTmpUnfilterCandList` using search filtering. Specifically, let the length of `intraTmpUnfilterCandList` be N. Search filtering is performed on each candidate BV of the first M candidates in `intraTmpUnfilterCandList`. Based on the matching cost of the search filtering, `intraTmpFilterCandList[M]` is constructed, 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), intraTmpCandList = intraTmpFilteredCandList; otherwise, if the value of intra_tmp_filter_flag is 0 (false), intraTmpCandList = intraTmpUnfilteredCandList.

[0265] The above example can also be understood as follows: regardless of whether filtering is used or not, a candidate list for non-filtering is first constructed; if filtering is required, a candidate list for filtering is constructed based on the candidate list for non-filtering.

[0266] The encoder's specific process is as follows:

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

[0268] 2. Determine the values ​​of intra_tmp_idx and intra_tmp_filter_flag, determine the prediction value of intraTMP, and determine the encoding cost of using intraTMP.

[0269] 3. Based on the encoding cost of intraTMP, determine whether the current block uses intraTMP. If the current block uses intraTMP, encode the values ​​of intra_tmp_idx and intra_tmp_filter_flag and write them into the bitstream.

[0270] One specific method for step 2 is as follows:

[0271] For both cases where intra_tmp_filter_flag is 0 (false) or 1 (true), construct the candidate list intraTmpCandList according to the candidate list construction method described above.

[0272] For each candidate in `intraTmpCandList`, a prediction block (BV) is determined, and the corresponding reference block is identified. 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. Filter coefficients are determined based on the reference block template and the current block template. Filtered prediction blocks are determined based on the filter coefficients and the reference block. The estimated distortion cost (SAD) or standard deviation cost (SATD) is determined by comparing the prediction block with the current block. The estimated coding cost is calculated by adding the estimated distortion cost (SAD) or standard deviation cost (SATD) to the estimated overhead cost. Based on these coding costs, several candidate and filter combinations are selected for rate-distortion optimization (RDO) to determine the coding cost. The pseudocode is as follows:

[0273] If the candidate list length is M when intra_tmp_filter_flag = 1, and M is not equal to N, then 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++).

[0274] If intra_tmp_filter_flag = 0, Prediction is the prediction without filtering; if intra_tmp_filter_flag = 1, Prediction is the prediction with filtering.

[0275] Alternatively, rate-distortion optimization can be skipped, and the estimated encoding cost can be directly used as the encoding cost. This method is generally used when encoding complexity is limited.

[0276] The preferred embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the specific details of the embodiments described above. Within the scope of the technical concept of this application, various simple modifications can be made to the technical solutions of this application, and these simple modifications all fall within the protection scope of this application. For example, the various specific technical features described in the specific embodiments described above can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this application will not describe the various possible combinations separately. Furthermore, various different embodiments of this application can also be arbitrarily combined, as long as they do not violate the spirit of this application, and they should also be considered as the content disclosed in this application. It should also be understood that in the various method embodiments of this application, the sequence number of each process mentioned above does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0277] The decoding method according to the embodiments of this application has been described in detail above from the perspective of the decoder. The encoding method according to the embodiments of this application will be described below from the perspective of the encoder with reference to FIG16.

[0278] Figure 16 is a schematic flowchart of the encoding method 400 provided in an embodiment of this application. It should be understood that the encoding method 400 can be executed by an encoder. For example, it can be applied to the encoding framework 100 shown in Figure 1. For ease of description, an encoder will be used as an example below.

[0279] As shown in Figure 16, the encoding method 400 may include:

[0280] S410, based on the first prediction mode corresponding to the intra-frame template prediction, determine at least one candidate list formed by the candidate block vector BV of the current block;

[0281] S420, based on the at least one candidate list, determine a first identifier for indicating whether filtering is required and a first index for indicating candidate BV in the first candidate list of the at least one candidate list;

[0282] S430, the first identifier and the first index are encoded.

[0283] In some embodiments, the method 400 may further include:

[0284] Based on the first identifier and the first index, the predicted block of the current block is determined;

[0285] A second identifier is determined based on the distortion cost of the predicted block; the second identifier indicates whether the first prediction mode is used to predict the current block.

[0286] The second identifier is encoded.

[0287] In some embodiments, S410 may include:

[0288] Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs;

[0289] Based on the multiple candidate BVs, at least one candidate list is determined.

[0290] In some embodiments, the step of performing template matching on the current block based on the first prediction mode to obtain multiple candidate BVs includes:

[0291] Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs.

[0292] In some embodiments, the parameters corresponding to the first identifier include at least one of the following: search range, search step size, search order, and the number of candidate BVs in the first candidate list.

[0293] In some embodiments, if the first identifier indicates filtering, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates no filtering, the parameters corresponding to the first identifier include a second search range; wherein the first search range is smaller than the second search range.

[0294] In some embodiments, the at least one candidate list includes the first candidate list; wherein determining the at least one candidate list based on the plurality of candidate BVs includes:

[0295] Determine the template matching cost of the plurality of candidate BVs;

[0296] The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

[0297] In some embodiments, S420 may include:

[0298] Determine the distortion cost of the reference block corresponding to the candidate BV in the first candidate list;

[0299] Filter the reference block corresponding to the candidate BV in the first candidate list to obtain the distortion cost of the filtered reference block corresponding to the candidate BV in the first candidate list.

[0300] The first identifier and the first index are determined 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.

[0301] In some embodiments, the at least one candidate list includes a second candidate list and a third candidate list. If the first identifier indicates that filtering is to be performed, the first candidate list is the second candidate list. If the first identifier indicates that filtering is not to be performed, the first candidate list is the third candidate list.

[0302] In some embodiments, determining the at least one candidate list based on the plurality of candidate BVs includes:

[0303] Determine the template matching cost of the plurality of candidate BVs;

[0304] Based on the template matching cost of the plurality of candidate BVs, at least one candidate BV among the plurality of candidate BVs is determined;

[0305] Filter the template corresponding to the candidate BV in the at least one candidate BV to obtain the filtered template corresponding to the candidate BV in the at least one candidate BV.

[0306] Based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, determine the template matching cost of the candidate BV in the at least one candidate BV;

[0307] The at least one candidate BV is sorted based on the template matching cost of the candidate BVs among the at least one candidate BVs to obtain the second candidate list.

[0308] In some embodiments, determining at least one candidate BV among the plurality of candidate BVs based on the template matching cost of the plurality of candidate BVs includes:

[0309] The candidate BVs are sorted based on their template matching costs.

[0310] The candidate BVs that are ranked higher after sorting are identified as at least one candidate BV.

[0311] In some embodiments, determining the at least one candidate list based on the plurality of candidate BVs includes:

[0312] Determine the template matching cost of the plurality of candidate BVs;

[0313] The candidate BVs are sorted based on their template matching costs to obtain the third candidate list.

[0314] In some embodiments, S420 may include:

[0315] Determine the distortion cost of the reference block corresponding to the candidate BV in the second candidate list;

[0316] The reference blocks corresponding to the candidate BV in the third candidate list are filtered to obtain the distortion cost of the filtered reference blocks corresponding to the candidate BV in the third candidate list.

[0317] The first identifier and the first index are determined 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.

[0318] In some embodiments, S430 may include:

[0319] The first index is encoded based on the first identifier.

[0320] In some embodiments, encoding the first index based on the first identifier includes:

[0321] The first index is encoded based on the binarization method corresponding to the first identifier.

[0322] In some embodiments, if the first identifier indicates that filtering is not performed, the binarization method corresponding to the first identifier includes at least one of the following: a variable-length code binarization method and a truncated unary code binarization method; if the first identifier indicates that filtering is performed, the binarization method corresponding to the first identifier includes at least one of the following: a fixed-length code binarization method and a truncated binary code binarization method.

[0323] In some embodiments, encoding the first index based on the first identifier includes:

[0324] The first index is encoded based on the context model corresponding to the first identifier.

[0325] In some embodiments, the method 400 may further include:

[0326] Based on the predicted block of the current block and the original block of the current block, determine the residual block of the current block;

[0327] Based on the residual block and the prediction block, the reconstruction block of the current block is determined.

[0328] In some embodiments, the method 400 may further include:

[0329] If the first identifier indicates filtering, then 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;

[0330] The filtering coefficients are determined based on the first template region and the second template region.

[0331] In some embodiments, for a first sample within the first template region, the first sample is filtered using samples from the surrounding region to obtain a filtered second sample; the filtering coefficients are determined based on the difference between the second sample and a third sample within the second template region; wherein the position of the first sample within the first template region and the position of the third sample within the template region are the same.

[0332] In some embodiments, when the sample in the area surrounding the first sample includes the sample at a first position outside the first template area, the sample at the first position is the sample obtained by filling the first position with the sample in the first template area.

[0333] In some embodiments, the filtering coefficients are coefficients obtained through training.

[0334] It should be understood that the encoding method can be understood as the reverse process of the decoding method. Therefore, the specific scheme of the encoding method 400 can be found in the relevant content of the decoding method 300, and will not be repeated here for ease of description. In addition, the method embodiments of this application have been described in detail above, and the device embodiments of this application will be described in detail below with reference to Figures 17 to 19.

[0335] Figure 17 is a schematic block diagram of a decoder 500 according to an embodiment of this application.

[0336] As shown in Figure 17, the decoder 500 may include:

[0337] The acquisition unit 510 is used to acquire a first identifier and a first index for indicating whether filtering is required;

[0338] The first determining unit 520 is used to determine a first candidate list formed by the candidate block vector BV of the current block based on the first prediction mode corresponding to the intra-frame template prediction.

[0339] The second determining unit 530 is configured to determine the predicted block of the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list.

[0340] In some embodiments, the acquisition unit 510 is specifically used for:

[0341] Obtain the second identifier;

[0342] If the second identifier indicates that the first prediction mode is used to predict the current block, then the first identifier and the first index are obtained.

[0343] In some embodiments, the first determining unit 520 is specifically used for:

[0344] Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs;

[0345] Based on the multiple candidate BVs, the first candidate list is determined.

[0346] In some embodiments, the first determining unit 520 is specifically used for:

[0347] Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs.

[0348] In some embodiments, the parameters corresponding to the first identifier include at least one of the following: search range, search step size, search order, and the number of candidate BVs in the first candidate list.

[0349] In some embodiments, if the first identifier indicates filtering, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates no filtering, the parameters corresponding to the first identifier include a second search range; wherein the first search range is smaller than the second search range.

[0350] In some embodiments, the first determining unit 520 is specifically used for:

[0351] Determine the template matching cost of the plurality of candidate BVs;

[0352] The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

[0353] In some embodiments, the first determining unit 520 is specifically used for:

[0354] The first candidate list is determined based on the multiple candidate BVs and the first identifier.

[0355] In some embodiments, the first determining unit 520 is specifically used for:

[0356] If the first identifier indicates that filtering is to be performed, then the template matching cost of the plurality of candidate BVs is determined;

[0357] Based on the template matching cost of the plurality of candidate BVs, at least one candidate BV among the plurality of candidate BVs is determined;

[0358] Filter the template corresponding to the candidate BV in the at least one candidate BV to obtain the filtered template corresponding to the candidate BV in the at least one candidate BV.

[0359] Based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, determine the template matching cost of the candidate BV in the at least one candidate BV;

[0360] The at least one candidate BV is sorted based on the template matching cost of the candidate BV among the at least one candidate BV to obtain the first candidate list.

[0361] In some embodiments, the first determining unit 520 is specifically used for:

[0362] The candidate BVs are sorted based on their template matching costs.

[0363] The candidate BVs that are ranked higher after sorting are identified as at least one candidate BV.

[0364] In some embodiments, the first determining unit 520 is specifically used for:

[0365] If the first identifier indicates that filtering is not performed, then the template matching cost of the plurality of candidate BVs is determined;

[0366] The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

[0367] In some embodiments, the acquisition unit 510 is specifically used for:

[0368] Obtain the first identifier;

[0369] Based on the first identifier, obtain the first index.

[0370] In some embodiments, the acquisition unit 510 is specifically used for:

[0371] The first index is obtained based on the debinarization method corresponding to the first identifier.

[0372] In some embodiments, if the first identifier indicates that filtering is not performed, the debinarization method corresponding to the first identifier includes at least one of the following: a variable-length code binarization method and a truncated unary code binarization method; if the first identifier indicates that filtering is performed, the debinarization method corresponding to the first identifier includes at least one of the following: a fixed-length code binarization method and a truncated binary code binarization method.

[0373] In some embodiments, the acquisition unit 510 is specifically used for:

[0374] Based on the context model corresponding to the first identifier, obtain the first index.

[0375] In some embodiments, the second determining unit 530 is specifically used for:

[0376] If the first identifier indicates filtering, then the reference block corresponding to the candidate BV indicated by the first index is filtered to obtain the prediction block;

[0377] If the first identifier indicates that filtering is not performed, then the reference block corresponding to the candidate BV indicated by the first index is determined as the prediction block.

[0378] In some embodiments, the second determining unit 530 is further configured to:

[0379] Obtain the residual block of the current block;

[0380] Based on the residual block and the prediction block, the reconstruction block of the current block is determined.

[0381] In some embodiments, the second determining unit 530 is further configured to:

[0382] If the first identifier indicates filtering, then 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;

[0383] The filtering coefficients are determined based on the first template region and the second template region.

[0384] In some embodiments, the second determining unit 530 is specifically used for:

[0385] For the first sample within the first template region, the first sample is filtered using samples from the surrounding region to obtain the filtered second sample;

[0386] The filtering coefficients are determined based on the difference between the second sample and the third sample within the second template region; wherein the position of the first sample within the first template region is the same as the position of the third sample within the template region.

[0387] In some embodiments, when the sample in the area surrounding the first sample includes the sample at a first position outside the first template area, the sample at the first position is the sample obtained by filling the first position with the sample in the first template area.

[0388] In some embodiments, the filtering coefficients are coefficients obtained through training.

[0389] Figure 18 is a schematic block diagram of an encoder 600 according to an embodiment of this application.

[0390] As shown in Figure 18, the encoder 600 may include:

[0391] The first determining unit 610 is used to determine at least one candidate list formed by the candidate block vector BV of the current block based on the first prediction mode corresponding to the intra-frame template prediction.

[0392] The second determining unit 620 is configured to determine, based on the at least one candidate list, a first identifier for indicating whether filtering is required and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list;

[0393] The encoding unit 630 is used to encode the first identifier and the first index.

[0394] In some embodiments, the encoding unit 630 is further configured to:

[0395] Based on the first identifier and the first index, the predicted block of the current block is determined;

[0396] A second identifier is determined based on the distortion cost of the predicted block; the second identifier indicates whether the first prediction mode is used to predict the current block.

[0397] The second identifier is encoded.

[0398] In some embodiments, the first determining unit 610 is specifically used for:

[0399] Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs;

[0400] Based on the multiple candidate BVs, at least one candidate list is determined.

[0401] In some embodiments, the first determining unit 610 is specifically used for:

[0402] Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs.

[0403] In some embodiments, the parameters corresponding to the first identifier include at least one of the following: search range, search step size, search order, and the number of candidate BVs in the first candidate list.

[0404] In some embodiments, if the first identifier indicates filtering, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates no filtering, the parameters corresponding to the first identifier include a second search range; wherein the first search range is smaller than the second search range.

[0405] In some embodiments, the at least one candidate list includes the first candidate list; wherein, the first determining unit 610 is specifically configured to:

[0406] Determine the template matching cost of the plurality of candidate BVs;

[0407] The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

[0408] In some embodiments, the second determining unit 620 is specifically used for:

[0409] Determine the distortion cost of the reference block corresponding to the candidate BV in the first candidate list;

[0410] Filter the reference block corresponding to the candidate BV in the first candidate list to obtain the distortion cost of the filtered reference block corresponding to the candidate BV in the first candidate list.

[0411] The first identifier and the first index are determined 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.

[0412] In some embodiments, the at least one candidate list includes a second candidate list and a third candidate list. If the first identifier indicates that filtering is to be performed, the first candidate list is the second candidate list. If the first identifier indicates that filtering is not to be performed, the first candidate list is the third candidate list.

[0413] In some embodiments, the first determining unit 610 is specifically used for:

[0414] Determine the template matching cost of the plurality of candidate BVs;

[0415] Based on the template matching cost of the plurality of candidate BVs, at least one candidate BV among the plurality of candidate BVs is determined;

[0416] Filter the template corresponding to the candidate BV in the at least one candidate BV to obtain the filtered template corresponding to the candidate BV in the at least one candidate BV.

[0417] Based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, determine the template matching cost of the candidate BV in the at least one candidate BV;

[0418] The at least one candidate BV is sorted based on the template matching cost of the candidate BVs among the at least one candidate BVs to obtain the second candidate list.

[0419] In some embodiments, the first determining unit 610 is specifically used for:

[0420] The candidate BVs are sorted based on their template matching costs.

[0421] The candidate BVs that are ranked higher after sorting are identified as at least one candidate BV.

[0422] In some embodiments, the first determining unit 610 is specifically used for:

[0423] Determine the template matching cost of the plurality of candidate BVs;

[0424] The candidate BVs are sorted based on their template matching costs to obtain the third candidate list.

[0425] In some embodiments, the second determining unit 620 is specifically used for:

[0426] Determine the distortion cost of the reference block corresponding to the candidate BV in the second candidate list;

[0427] The reference blocks corresponding to the candidate BV in the third candidate list are filtered to obtain the distortion cost of the filtered reference blocks corresponding to the candidate BV in the third candidate list.

[0428] The first identifier and the first index are determined 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.

[0429] In some embodiments, the encoding unit 630 is specifically used for:

[0430] The first index is encoded based on the first identifier.

[0431] In some embodiments, the encoding unit 630 is specifically used for:

[0432] The first index is encoded based on the binarization method corresponding to the first identifier.

[0433] In some embodiments, if the first identifier indicates that filtering is not performed, the binarization method corresponding to the first identifier includes at least one of the following: a variable-length code binarization method and a truncated unary code binarization method; if the first identifier indicates that filtering is performed, the binarization method corresponding to the first identifier includes at least one of the following: a fixed-length code binarization method and a truncated binary code binarization method.

[0434] In some embodiments, the encoding unit 630 is specifically used for:

[0435] The first index is encoded based on the context model corresponding to the first identifier.

[0436] In some embodiments, the encoding unit 630 is further configured to:

[0437] Based on the predicted block of the current block and the original block of the current block, determine the residual block of the current block;

[0438] Based on the residual block and the prediction block, the reconstruction block of the current block is determined.

[0439] In some embodiments, the second determining unit 620 is further configured to:

[0440] If the first identifier indicates filtering, then 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;

[0441] The filtering coefficients are determined based on the first template region and the second template region.

[0442] In some embodiments, the second determining unit 620 is specifically used for:

[0443] For the first sample within the first template region, the first sample is filtered using samples from the surrounding region to obtain the filtered second sample;

[0444] The filtering coefficients are determined based on the difference between the second sample and the third sample within the second template region; wherein the position of the first sample within the first template region is the same as the position of the third sample within the template region.

[0445] In some embodiments, when the sample in the area surrounding the first sample includes the sample at a first position outside the first template area, the sample at the first position is the sample obtained by filling the first position with the sample in the first template area.

[0446] In some embodiments, the filtering coefficients are coefficients obtained through training.

[0447] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, further details are omitted here. Specifically, the decoder 500 shown in FIG17 can correspond to the corresponding subject in executing the method 300 of the embodiments of this application, and the aforementioned and other operations and / or functions of each unit in the decoder 500 are respectively for implementing the corresponding processes in the various methods such as method 300. The encoder 600 shown in FIG18 can correspond to the corresponding subject in executing the method 400 of the embodiments of this application, that is, the aforementioned and other operations and / or functions of each unit in the encoder 600 are respectively for implementing the corresponding processes in the various methods such as method 400.

[0448] It should also be understood that the various units in the decoder 500 or encoder 600 involved in the embodiments of this application can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This can achieve the same operation without affecting the technical effect of the embodiments of this application. The units mentioned above are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the decoder 500 or encoder 600 may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by multiple units working together. According to another embodiment of this application, the decoder 500 or encoder 600 involved in the embodiments of this application can be constructed by running a computer program (including program code) capable of performing the steps involved in the corresponding method on a general-purpose computing device including processing elements and storage elements such as a central processing unit (CPU), random access storage medium (RAM), and read-only storage medium (ROM), and the encoding method or decoding method of the embodiments of this application can be implemented. Computer programs can be recorded on, for example, a computer-readable storage medium, loaded into an electronic device via the computer-readable storage medium, and run therein to implement the corresponding methods of the embodiments of this application.

[0449] In other words, the units mentioned above can be implemented in hardware, in software instructions, or in a combination of hardware and software. Specifically, the steps of the method embodiments in this application can be completed by the integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or executed by a combination of hardware and software in the decoding processor. Optionally, the software can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps in the method embodiments mentioned above.

[0450] Figure 19 is a schematic structural diagram of the electronic device 700 provided in an embodiment of this application.

[0451] As shown in Figure 19, the electronic device 700 includes at least a processor 710 and a computer-readable storage medium 720. The processor 710 and the computer-readable storage medium 720 can be connected via a bus or other means. The computer-readable storage medium 720 stores a computer program 721, which includes computer instructions. The processor 710 executes the computer instructions stored in the computer-readable storage medium 720. The processor 710 is the computing and control core of the electronic device 700, and is suitable for implementing one or more computer instructions, specifically for loading and executing one or more computer instructions to achieve a corresponding method flow or function.

[0452] For example, processor 710 may also be referred to as a central processing unit (CPU). Processor 710 may include, but is not limited to: general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, discrete hardware components, etc.

[0453] Exemplarily, the computer-readable storage medium 720 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage device; optionally, it may also be at least one computer-readable storage medium located remotely from the aforementioned processor 710. Specifically, the computer-readable storage medium 720 includes, but is not limited to, volatile memory and / or non-volatile memory. 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), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0454] For example, the electronic device 700 may be an encoder or encoding framework involved in the embodiments of this application; the computer-readable storage medium 720 stores first computer instructions; the processor 710 loads and executes the first computer instructions stored in the computer-readable storage medium 720 to implement the corresponding steps in the encoding method provided in the embodiments of this application; in other words, the first computer instructions in the computer-readable storage medium 720 are loaded and executed by the processor 710 to implement the corresponding steps, which will not be described again here to avoid repetition.

[0455] For example, the electronic device 700 may be a decoder or decoding framework involved in the embodiments of this application; the computer-readable storage medium 720 stores second computer instructions; the processor 710 loads and executes the second computer instructions stored in the computer-readable storage medium 720 to implement the corresponding steps in the decoding method provided in the embodiments of this application; in other words, the second computer instructions in the computer-readable storage medium 720 are loaded and executed by the processor 710 to implement the corresponding steps, which will not be described again here to avoid repetition.

[0456] According to another aspect of this application, this application also provides an encoding and decoding system, including the encoder and decoder mentioned above.

[0457] According to another aspect of this application, a computer-readable storage medium (Memory) is also provided. This computer-readable storage medium is a memory device in the electronic device 700 for storing programs and data. For example, a computer-readable storage medium 720. It is understood that the computer-readable storage medium 720 here may include both the built-in storage medium in the electronic device 700 and extended storage media supported by the electronic device 700. The computer-readable storage medium provides storage space that stores the operating system of the electronic device 700. Furthermore, this storage space also stores one or more computer instructions suitable for loading and execution by the processor 710. These computer instructions may be one or more computer programs 721 (including program code).

[0458] According to another aspect of this application, this application also provides a computer program product or computer program that includes computer instructions 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. The processor 710 executes the computer instructions, causing the computer to perform the encoding or decoding methods provided in the various alternative methods described above.

[0459] In other words, when implemented using software, it can be implemented entirely or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes of the embodiments of this application are run or the functions of the embodiments of this application are implemented. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.

[0460] Those skilled in the art will recognize that the units and process steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0461] Finally, it should be noted that the above content is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A decoding method, characterized in that, include: Obtain the first identifier and first index used to indicate whether filtering is required; Based on the first prediction mode corresponding to the intra-frame template prediction, a first candidate list is determined by the candidate block vector (BV) of the current block; Based on the first identifier and the candidate BV indicated by the first index in the first candidate list, the predicted block of the current block is determined.

2. The method according to claim 1, characterized in that, The step of obtaining the first identifier and first index used to indicate whether filtering is required includes: Obtain the second identifier; If the second identifier indicates that the first prediction mode is used to predict the current block, then the first identifier and the first index are obtained.

3. The method according to claim 1 or 2, characterized in that, The first prediction mode based on intra-frame template prediction determines a first candidate list formed by the candidate block vector (BV) of the current block, including: Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs; Based on the multiple candidate BVs, the first candidate list is determined.

4. The method according to claim 3, characterized in that, The template matching of the current block based on the first prediction mode yields multiple candidate BVs, including: Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs.

5. The method according to claim 4, characterized in that, The parameters corresponding to the first identifier include at least one of the following: search range, search step size, search order, and the number of candidate BVs in the first candidate list.

6. The method according to claim 4, characterized in that, If the first identifier indicates that filtering is to be performed, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates that filtering is not to be performed, the parameters corresponding to the first identifier include a second search range; wherein the first search range is smaller than the second search range.

7. The method according to any one of claims 3 to 6, characterized in that, The step of determining the first candidate list based on the plurality of candidate BVs includes: Determine the template matching cost of the plurality of candidate BVs; The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

8. The method according to any one of claims 3 to 6, characterized in that, The step of determining the first candidate list based on the plurality of candidate BVs includes: The first candidate list is determined based on the multiple candidate BVs and the first identifier.

9. The method according to claim 8, characterized in that, The step of determining the first candidate list based on the plurality of candidate BVs and the first identifier includes: If the first identifier indicates that filtering is to be performed, then the template matching cost of the plurality of candidate BVs is determined; Based on the template matching cost of the plurality of candidate BVs, at least one candidate BV among the plurality of candidate BVs is determined; Filter the template corresponding to the candidate BV in the at least one candidate BV to obtain the filtered template corresponding to the candidate BV in the at least one candidate BV. Based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, determine the template matching cost of the candidate BV in the at least one candidate BV; The at least one candidate BV is sorted based on the template matching cost of the candidate BV among the at least one candidate BV to obtain the first candidate list.

10. The method according to claim 9, characterized in that, The step of determining at least one candidate BV among the multiple candidate BVs based on the template matching cost of the multiple candidate BVs includes: The candidate BVs are sorted based on their template matching costs. The candidate BVs that are ranked higher after sorting are identified as at least one candidate BV.

11. The method according to claim 8, characterized in that, The step of determining the first candidate list based on the plurality of candidate BVs and the first identifier includes: If the first identifier indicates that filtering is not performed, then the template matching cost of the plurality of candidate BVs is determined; The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

12. The method according to any one of claims 1 to 11, characterized in that, The step of obtaining the first identifier and first index used to indicate whether filtering is required includes: Obtain the first identifier; Based on the first identifier, obtain the first index.

13. The method according to claim 12, characterized in that, Obtaining the first index based on the first identifier includes: The first index is obtained based on the debinarization method corresponding to the first identifier.

14. The method according to claim 13, characterized in that, If the first identifier indicates that filtering is not performed, then the debinarization method corresponding to the first identifier includes at least one of the following: a binarization method for variable-length codes, and a binarization method for truncated unary codes; If the first identifier indicates filtering, the inverse binarization method corresponding to the first identifier includes at least one of the following: a fixed-length code binarization method, and a truncated binary code binarization method.

15. The method according to claim 12, characterized in that, Obtaining the first index based on the first identifier includes: Based on the context model corresponding to the first identifier, obtain the first index.

16. The method according to any one of claims 1 to 15, characterized in that, The step of determining the predicted block of the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list includes: If the first identifier indicates filtering, then the reference block corresponding to the candidate BV indicated by the first index is filtered to obtain the prediction block; If the first identifier indicates that filtering is not performed, then the reference block corresponding to the candidate BV indicated by the first index is determined as the prediction block.

17. The method according to any one of claims 1 to 16, characterized in that, The method further includes: Obtain the residual block of the current block; Based on the residual block and the prediction block, the reconstruction block of the current block is determined.

18. The method according to any one of claims 1 to 17, characterized in that, The method further includes: If the first identifier indicates filtering, then 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; The filtering coefficients are determined based on the first template region and the second template region.

19. The method according to claim 18, characterized in that, The step of determining the filtering coefficients based on the first template region and the second template region includes: For the first sample within the first template region, the first sample is filtered using samples from the surrounding region to obtain the filtered second sample; The filtering coefficients are determined based on the difference between the second sample and the third sample within the second template region; wherein the position of the first sample within the first template region is the same as the position of the third sample within the template region.

20. The method according to claim 19, characterized in that, When the samples in the surrounding area of ​​the first sample include the samples at the first position outside the first template area, the samples at the first position are samples obtained by filling the first position with samples from the first template area.

21. The method according to claim 18, characterized in that, The filtering coefficients are the coefficients obtained during training.

22. An encoding method, characterized in that, include: Based on the first prediction mode corresponding to the intra-frame template prediction, determine at least one candidate list formed by the candidate block vector (BV) of the current block; Based on the at least one candidate list, a first identifier for indicating whether filtering is performed and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list are determined; The first identifier and the first index are encoded.

23. The method according to claim 22, characterized in that, The method further includes: Based on the first identifier and the first index, the predicted block of the current block is determined; A second identifier is determined based on the distortion cost of the predicted block; the second identifier indicates whether the first prediction mode is used to predict the current block. The second identifier is encoded.

24. The method according to claim 22 or 23, characterized in that, The first prediction mode based on intra-frame template prediction determines at least one candidate list formed by the candidate block vector (BV) of the current block, including: Based on the first prediction mode, template matching is performed on the current block to obtain multiple candidate BVs; Based on the multiple candidate BVs, at least one candidate list is determined.

25. The method according to claim 24, characterized in that, The template matching of the current block based on the first prediction mode yields multiple candidate BVs, including: Based on the first prediction mode, template matching is performed on the current block according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs.

26. The method according to claim 25, characterized in that, The parameters corresponding to the first identifier include at least one of the following: search range, search step size, search order, and the number of candidate BVs in the first candidate list.

27. The method according to claim 25, characterized in that, If the first identifier indicates that filtering is to be performed, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates that filtering is not to be performed, the parameters corresponding to the first identifier include a second search range; wherein the first search range is smaller than the second search range.

28. The method according to any one of claims 24 to 27, characterized in that, The at least one candidate list includes the first candidate list; The step of determining the at least one candidate list based on the plurality of candidate BVs includes: Determine the template matching cost of the plurality of candidate BVs; The candidate BVs are sorted based on their template matching costs to obtain the first candidate list.

29. The method according to claim 28, characterized in that, The step of determining, based on the at least one candidate list, a first identifier for indicating whether filtering is required and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list, includes: Determine the distortion cost of the reference block corresponding to the candidate BV in the first candidate list; Filter the reference block corresponding to the candidate BV in the first candidate list to obtain the distortion cost of the filtered reference block corresponding to the candidate BV in the first candidate list. The first identifier and the first index are determined 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.

30. The method according to any one of claims 24 to 27, characterized in that, The at least one candidate list includes a second candidate list and a third candidate list. If the first identifier indicates that filtering is to be performed, the first candidate list is the second candidate list. If the first identifier indicates that filtering is not to be performed, the first candidate list is the third candidate list.

31. The method according to claim 30, characterized in that, Determining the at least one candidate list based on the plurality of candidate BVs includes: Determine the template matching cost of the plurality of candidate BVs; Based on the template matching cost of the plurality of candidate BVs, at least one candidate BV among the plurality of candidate BVs is determined; Filter the template corresponding to the candidate BV in the at least one candidate BV to obtain the filtered template corresponding to the candidate BV in the at least one candidate BV. Based on the filtered template corresponding to the candidate BV in the at least one candidate BV and the template of the current block, determine the template matching cost of the candidate BV in the at least one candidate BV; The at least one candidate BV is sorted based on the template matching cost of the candidate BVs among the at least one candidate BVs to obtain the second candidate list.

32. The method according to claim 31, characterized in that, The step of determining at least one candidate BV among the multiple candidate BVs based on the template matching cost of the multiple candidate BVs includes: The candidate BVs are sorted based on their template matching costs. The candidate BVs that are ranked higher after sorting are identified as at least one candidate BV.

33. The method according to claim 30, characterized in that, Determining the at least one candidate list based on the plurality of candidate BVs includes: Determine the template matching cost of the plurality of candidate BVs; The candidate BVs are sorted based on their template matching costs to obtain the third candidate list.

34. The method according to any one of claims 30 to 33, characterized in that, The step of determining, based on the at least one candidate list, a first identifier for indicating whether filtering is required and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list, includes: Determine the distortion cost of the reference block corresponding to the candidate BV in the second candidate list; The reference blocks corresponding to the candidate BV in the third candidate list are filtered to obtain the distortion cost of the filtered reference blocks corresponding to the candidate BV in the third candidate list. The first identifier and the first index are determined 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.

35. The method according to any one of claims 22 to 34, characterized in that, The encoding of the first identifier and the first index includes: The first index is encoded based on the first identifier.

36. The method according to claim 35, characterized in that, The step of encoding the first index based on the first identifier includes: The first index is encoded based on the binarization method corresponding to the first identifier.

37. The method according to claim 36, characterized in that, If the first identifier indicates that filtering is not performed, the binarization method corresponding to the first identifier includes at least one of the following: a binarization method for variable-length codes and a binarization method for truncated unary codes. If the first identifier indicates filtering, the binarization method corresponding to the first identifier includes at least one of the following: a fixed-length code binarization method and a truncated binary code binarization method.

38. The method according to claim 35, characterized in that, The step of encoding the first index based on the first identifier includes: The first index is encoded based on the context model corresponding to the first identifier.

39. The method according to any one of claims 22 to 38, characterized in that, The method further includes: Based on the predicted block of the current block and the original block of the current block, determine the residual block of the current block; Based on the residual block and the prediction block, the reconstruction block of the current block is determined.

40. The method according to any one of claims 22 to 39, characterized in that, The method further includes: If the first identifier indicates filtering, then 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; The filtering coefficients are determined based on the first template region and the second template region.

41. The method according to claim 40, characterized in that, The step of determining the filtering coefficients based on the first template region and the second template region includes: For the first sample within the first template region, the first sample is filtered using samples from the surrounding region to obtain the filtered second sample; The filtering coefficients are determined based on the difference between the second sample and the third sample within the second template region; wherein the position of the first sample within the first template region is the same as the position of the third sample within the template region.

42. The method according to claim 41, characterized in that, When the samples in the surrounding area of ​​the first sample include the samples at the first position outside the first template area, the samples at the first position are samples obtained by filling the first position with samples from the first template area.

43. The method according to claim 40, characterized in that, The filtering coefficients are the coefficients obtained during training.

44. A decoder, characterized in that, include: The acquisition unit is used to acquire a first identifier and a first index that indicate whether filtering is required; The first determining unit is used to determine a first candidate list formed by the candidate block vector (BV) of the current block based on the first prediction mode corresponding to the intra-frame template prediction. The second determining unit is configured to determine the predicted block of the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list.

45. An encoder, characterized in that, include: The first determining unit is used to determine at least one candidate list formed by the candidate block vector (BV) of the current block based on the first prediction mode corresponding to the intra-frame template prediction. The second determining unit is configured to determine, based on the at least one candidate list, a first identifier for indicating whether filtering is required and a first index for indicating a candidate BV in the first candidate list of the at least one candidate list; An encoding unit is used to encode the first identifier and the first index.

46. ​​An electronic device, characterized in that, include: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program that, when executed by the processor, implements the method as claimed in any one of claims 1 to 21, or the method as claimed in any one of claims 22 to 42.

47. A computer-readable storage medium, characterized in that, Used to store a computer program that causes a computer to perform the method as claimed in any one of claims 1 to 21, or the method as claimed in any one of claims 22 to 42.

48. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the method as described in any one of claims 1 to 21, or the method as described in any one of claims 22 to 42.

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