Decoding method, encoding method, decoder and encoder

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

Patent Information

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

AI Technical Summary

Technical Problem

Existing digital video decompression technology has shortcomings in improving compression efficiency, especially under high video definition requirements, which require more efficient encoding and decoding performance.

Method used

By introducing the first identifier and the first index, combined with the intra-frame template prediction mode, the candidate list formed by the candidate block vector BV is determined, and then the prediction block of the current block is determined, thereby improving the accuracy of the prediction block, thereby improving the decoding performance of the decoder.

Benefits of technology

It improves video encoding and decoding performance and video compression efficiency. It is suitable for the field of digital video encoding technology, including image and video encoding and decoding, and supports multiple video encoding standards such as AVS, AVC, HEVC and VVC.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120958819A_ABST
    Figure CN120958819A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a decoding method, an encoding method, a decoder and an encoder. The decoding method comprises the following steps: acquiring a first identifier and a first index which are used for indicating whether to filter or not; determining a first candidate list formed by candidate block vectors BV of the current block based on a first prediction mode corresponding to intra-frame template prediction; and determining a prediction block of the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list. By introducing the first identifier and the first index, the prediction block of the current block can be determined in combination with the candidate BV indicated by the first index and the first identifier, so that the accuracy of the prediction block is improved, and the decoding performance of a decoder can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Decoding method, encoding method, decoder and encoder Technical Field

[0001] The embodiments of the present application relate to the field of coding and decoding technology, and more specifically, to a decoding method, an encoding method, a decoder, and an encoder. Background Art

[0002] Digital video compression technology primarily compresses large amounts of digital video data for easier transmission and storage. With the surge in Internet video usage and increasing demand for higher-quality video, while existing digital video compression standards are capable of implementing video decompression technology, there is still a need for better digital video decompression technologies to improve compression efficiency.

[0003] Summary of the Invention

[0004] The embodiments of the present application provide a decoding method, an encoding method, a decoder and an encoder, which can improve encoding and decoding performance.

[0005] In a first aspect, an embodiment of the present application provides a decoding method, comprising:

[0006] Obtaining a first flag and a first index for indicating whether to filter;

[0007] Determine, based on a first prediction mode corresponding to the intra template prediction, a first candidate list formed by candidate block vectors BV of the current block;

[0008] Determine a prediction block for the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list.

[0009] In a second aspect, an embodiment of the present application provides an encoding method, including:

[0010] Determine, based on a first prediction mode corresponding to intra template prediction, at least one candidate list formed by candidate block vectors BV of the current block;

[0011] Based on the at least one candidate list, determining a first identifier for indicating whether to filter and a first index for indicating a candidate BV in a first candidate list among the at least one candidate list;

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

[0013] In a third aspect, an embodiment of the present application provides a decoder, including:

[0014] An acquiring unit, configured to acquire a first identifier and a first index for indicating whether to filter;

[0015] A first determining unit, configured to determine a first candidate list formed by candidate block vectors BV of the current block based on a first prediction mode corresponding to the intra template prediction;

[0016] The second determining unit is configured to determine a prediction 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] In a fourth aspect, an embodiment of the present application provides an encoder, including:

[0018] A first determining unit, configured to determine, based on a first prediction mode corresponding to the intra template prediction, at least one candidate list formed by candidate block vectors BV of the current block;

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

[0020] An encoding unit, configured to encode the first identifier and the first index.

[0021] In a fifth aspect, an embodiment of the present application provides a decoder, including:

[0022] a processor adapted to implement computer instructions; and,

[0023] A computer-readable storage medium stores computer instructions, wherein the computer instructions are suitable for being loaded 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 provided separately from the processor.

[0026] In a sixth aspect, an embodiment of the present application provides an encoder, including:

[0027] a processor adapted to implement computer instructions; and,

[0028] A computer-readable storage medium stores computer instructions, wherein the computer instructions are suitable for being loaded by a processor and executing the encoding method in 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 provided separately from the processor.

[0031] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are read and executed by a processor of a computer device, the computer device executes the decoding method involved in the first aspect mentioned above or the encoding method involved in the second aspect mentioned above.

[0032] In an eighth aspect, embodiments of the present application provide a computer program product or computer program, comprising 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 of the first aspect or the encoding method of the second aspect.

[0033] In a ninth aspect, an embodiment of the present application provides a code stream, which is the code stream involved in the method described in the first aspect above or the code stream generated by the method described in the second aspect above.

[0034] Based on the above technical solution, this application introduces a first identifier and a first index, which can determine the prediction block of the current block in combination with the candidate BV indicated by the first index and the first identifier, thereby improving the accuracy of the prediction block and, in turn, improving the decoding performance of the decoder. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] FIG1 is a schematic block diagram of a coding framework provided in an embodiment of the present application.

[0036] FIG2 is a schematic block diagram of a decoding framework provided in an embodiment of the present application.

[0037] FIG3 is an example of intra-frame prediction provided by an embodiment of the present application.

[0038] FIG4 is an example of an MRL provided in an embodiment of the present application.

[0039] FIG5 is an example of an intra-frame prediction mode provided by an embodiment of the present application.

[0040] FIG6 is another example of the intra-frame prediction mode provided by an embodiment of the present application.

[0041] FIG7 is another example of the intra-frame prediction mode provided by an embodiment of the present application.

[0042] FIG8 is an example of a wide-angle mode provided by an embodiment of the present application.

[0043] FIG9 is an example of screen content provided by an embodiment of the present application.

[0044] FIG10 is an example of a TM provided in an embodiment of the present application.

[0045] FIG. 11 is an example of an intraTMP according to an embodiment of the present application.

[0046] FIG12 is an example of a candidate BV in the candidate list provided in an embodiment of the present application.

[0047] FIG13 is an example of a filter provided in an embodiment of the present application.

[0048] FIG14 is a schematic diagram of training filter coefficients provided in an embodiment of the present application.

[0049] FIG15 is a schematic flowchart of the decoding method provided in an embodiment of the present application.

[0050] FIG16 is a schematic flowchart of the encoding method provided in an embodiment of the present application.

[0051] FIG17 is a schematic block diagram of a decoder provided in an embodiment of the present application.

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

[0053] FIG19 is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0055] The solution provided in the embodiment of the present application can be applied to the field of digital video coding technology, for example, including but not limited to: image coding and decoding field, video coding and decoding field, hardware video coding and decoding field, dedicated circuit video coding and decoding field and real-time video coding and decoding field. In addition, the solution provided in the embodiment of the present application can be combined with the audio and video coding standard (Audio Video Coding Standard, AVS), the second generation AVS standard (AVS2) or the third generation AVS standard (AVS3). For example, including but not limited to: H.264 / Audio Video Coding (AVC) standard, H.265 / High Efficiency Video Coding (HEVC) standard and H.266 / Versatile Video Coding (VVC) standard. In addition, the solution provided in the embodiment of the present application can be used for lossy compression of images, and can also be used for lossless compression of images. The lossless compression can be visually lossless compression or mathematically lossless compression.

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

[0057] On the encoder side, a frame is divided into blocks. Intra-frame prediction or inter-frame prediction is used on the current block to generate a predicted block for the current block. The predicted block is subtracted from the original block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix, which is then entropy-encoded and output to the bitstream. On the decoder side, intra-frame prediction or inter-frame prediction is used on the current block to generate a predicted block for the current block. The bitstream is then parsed to obtain a quantization coefficient matrix, which is then inversely quantized and inversely transformed to obtain a residual block. The predicted block and residual block are added together to obtain a reconstructed block. The reconstructed blocks form a reconstructed image, which is then subjected to image-based or block-based loop filtering to obtain a decoded image. The encoder side also performs similar operations as the decoder side to obtain a decoded image. The decoded image can serve as a reference image for inter-frame prediction in subsequent frames. The block division information determined by the encoder, as well as information about the prediction, transform, quantization, entropy coding, loop filtering, and other modes or parameters, are output to the bitstream if necessary. The decoding end determines the same block division information as the encoding end by parsing and analyzing the existing information, as well as the mode information or parameter information such as prediction, transformation, quantization, entropy coding, and loop filtering, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end. The decoded image obtained by the encoding end is also usually called a reconstructed image. The current block can be divided into prediction units during prediction, and the current block can be divided into transformation units during transformation. The division of prediction units and transformation units can be different. The above is the basic process of the video codec under the block-based hybrid coding framework. With the development of technology, some modules or steps of the framework or process may be optimized. The present application is applicable to the basic process of the video codec under the block-based hybrid coding framework, but is not limited to the framework and process.

[0058] FIG1 is a schematic block diagram of a coding framework 100 provided in an embodiment of the present application.

[0059] 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 filter unit 150. Optionally, the coding framework 100 may further include a decoded image buffer unit 160.

[0060] The intra-frame prediction unit 180 or the inter-frame prediction unit 170 may predict the image block to be encoded and output a prediction block. The residual unit 110 may calculate a residual block based on the prediction block and the image block to be encoded, i.e., the difference between the prediction block and the image block to be encoded. The transform and quantization unit 120 is configured to perform operations such as transform and quantization on the residual block to remove information that is insensitive to the human eye, thereby eliminating visual redundancy. Optionally, the residual block before transformation and quantization by the transform and quantization unit 120 may be referred to as a time-domain residual block, and the time-domain residual block after transformation and quantization by the transform and quantization unit 120 may be referred to as 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 may output a bitstream based on the transform and quantization coefficients. For example, the entropy coding unit 130 may eliminate character redundancy based on a target context model and probability information of the binary bitstream. For example, the entropy coding unit 130 may be configured for context-based adaptive binary arithmetic entropy coding (CABAC). The entropy coding unit 130 may also be referred to as a header information coding unit. Optionally, in this application, the image block to be encoded may also be referred to as an original image block or a target image block, the prediction block may also be referred to as a prediction image block or an image prediction block, or may also be referred to as a prediction signal or prediction information, and the reconstruction block may also be referred to as a reconstructed image block or an image reconstruction block, or may also be referred to as a reconstruction signal or reconstruction information. In addition, for the encoding end, the image block to be encoded may also be referred to as a coding block or a coding image block, and for the decoding end, the image block to be encoded may also be referred to as a decoding block or a decoding image block. The image block to be encoded may be a CTU or a CU.

[0061] The encoding framework 100 calculates the residual between the prediction block and the image block to be encoded, generates a residual block, and transmits the residual block to the decoder through processes such as transformation and quantization. Correspondingly, the decoder receives and decodes the bitstream, then performs inverse transformation and inverse quantization to generate a residual block. The predicted block, obtained by the decoder, is then superimposed on the residual block to create a reconstructed block.

[0062] It should be noted that the inverse transform and inverse quantization unit 140, the loop filter unit 150, and the decoded image buffer unit 160 in the coding framework 100 can be used to form a decoder. This means that the intra-frame prediction unit 180 or the inter-frame prediction unit 170 can predict the image block to be coded based on the existing reconstructed block, thereby ensuring that the encoder and decoder have a consistent understanding of the reference image. In other words, the encoder can replicate the decoder's processing loop, thereby generating the same prediction as the decoder. Specifically, the quantized transform coefficients are inversely transformed and inversely quantized by the inverse transform and inverse quantization unit 140 to replicate the approximate residual block at the decoder. This approximate residual block, after adding the prediction block, can pass through the loop filter unit 150 to smooth out block artifacts caused by block-based processing and quantization. The image block output by the loop filter unit 150 can be stored in the decoded image buffer unit 160 for use in subsequent image prediction.

[0063] It should be understood that FIG1 is merely an example of the present application and should not be construed as limiting the present application.

[0064] For example, the loop filtering unit 150 in the coding framework 100 may include a deblocking filter (DBF) and a sample adaptive offset (SAO) filter. The function of DBF is to remove the blocking effect, and the function of SAO is to remove the ringing effect. In other embodiments of the present application, the coding framework 100 may adopt a neural network-based loop filtering algorithm to improve the compression efficiency of the video. In other words, the coding framework 100 may be a video coding hybrid framework based on a deep learning neural network. In one implementation, a convolutional neural network-based model may be used to calculate the result of pixel filtering on the basis of the deblocking filter and the sample adaptive offset filter. The network structure of the loop filtering unit 150 on the luminance component and the chrominance component may be the same or different. Considering that the luminance component contains more visual information, the luminance component may also be used to guide the filtering of the chrominance component to improve the reconstruction quality of the chrominance component.

[0065] FIG2 is a schematic block diagram of a decoding framework 200 provided in an embodiment of the present application.

[0066] As shown in FIG2 , the decoding framework 200 may include an entropy decoding unit 210, an inverse transform and dequantization unit 220, a residual unit 230, an intra-frame prediction unit 240, an inter-frame prediction unit 250, a loop filter 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. The frequency domain residual block is inversely transformed and dequantized by the inverse transform and dequantization unit 220 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 that has been inversely transformed and dequantized by the inverse transform and dequantization unit 220 to obtain a reconstructed block.

[0067] For ease of understanding, the contents related to this application are explained below.

[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 uses the spatial correlation between the coded and decoded pixels around 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 the upper row of the current block are the reference pixels of the current block. Intra-frame prediction uses these reference pixels to predict the current block. These reference pixels may all be available, that is, all have been coded and decoded. Or some may not be available. For example, if the current block is at the leftmost part of the entire frame, then the reference pixels to the left of the current block are not available. Or when encoding and decoding the current block, the lower left part of the current block has not yet been coded and decoded, then the reference pixels to the lower left are also not available. In the case where reference pixels are unavailable, available reference pixels, certain values, or certain methods can be used for filling, or no filling can be performed.

[0070] The Multiple Reference Line (MRL) intra prediction method can use more reference pixels to improve coding efficiency. Figure 4 shows an example of MRL provided by an embodiment of the present 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] There are multiple prediction modes for intra-frame prediction, as shown in Figure 5. There are 9 modes for intra-frame prediction of 4x4 blocks in H.264, where mode 0 copies the pixels above 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 2DC uses the average of the 8 points A~D and I~L as the prediction value of all points, and modes 3~8 copy the reference pixels to the corresponding positions of the current block at a certain angle. Because some positions of 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 sub-pixels of the interpolated reference pixels.

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

[0073] (2) Inter-frame prediction.

[0074] Videos are composed of multiple images. To ensure a smooth video appearance, each second of video contains dozens or even hundreds of frames. Examples include 24 fps, 30 fps, 50 fps, 60 fps, and 120 fps. Consequently, there is significant temporal redundancy in the video. In other words, there is a high degree of temporal correlation. Inter-frame prediction exploits this temporal correlation to improve compression efficiency. Inter-frame prediction often uses motion to exploit temporal correlation. A very simple motion model is that an object is at a certain position in the image corresponding to a certain moment. After a certain period of time, it moves to another position in the image corresponding to the same moment. This is the most basic and commonly used translational motion in video codecs. Inter-frame prediction uses motion information to represent motion. Basic motion information includes information about the reference frame (or reference picture) and motion vectors (MVs). The codec determines the reference picture based on the reference picture information and the coordinates of the reference block based on the motion vector information and the coordinates of the current block. The reference block is determined by the coordinates of the reference block in the reference picture. Taking the determined reference block as the prediction block is the most basic prediction method of inter-frame prediction.

[0075] Motion in videos isn't always so simple. Even motion that can be considered translational can exhibit subtle changes over time, including subtle deformations, brightness variations, and noise variations. For better prediction, more than one reference block can be used to predict the current block. For example, bidirectional prediction is commonly used today, using two reference blocks to predict the current block. These two reference blocks can be a forward reference block and a backward reference block. Later, both forward and backward reference blocks were also allowed. Forward refers to the reference image corresponding to a moment before the current frame, while backward refers to the reference image corresponding to a moment after the current frame. Alternatively, forward refers to the reference image's position in the video before the current frame, while backward refers to the reference image's position in the video after the current frame. Alternatively, forward refers to the reference image's POC (picture order count) being less than the current frame's POC, while backward refers to the reference image's POC being greater than the current frame's POC. Future video codec standards may support prediction using multiple reference blocks. A simple method for generating 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 can also be used, such as the BCW (Bi-prediction with CU-level weights) currently used in VVC. VVC's GPM (Geometric Partitioning Mode) can also be understood as a special form of bidirectional prediction. To use bidirectional prediction, two reference blocks must be available, which requires 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 other complex motions. VVC uses affine to model some of these simple motions. The affine model in VVC uses two or three control points, based on which a linear model is used to derive the motion vector for each sub-block within the current block. The reason we only mention motion vectors here, rather than motion information, is because they both refer to the same reference image. While ordinary translational motion involves finding a "whole block" from a reference image, affine motion involves finding a group of non-close-to-one "sub-blocks" from the reference image. While the above descriptions are all about unidirectional prediction, affine can also implement bidirectional prediction or prediction of more "reference blocks." The reference blocks mentioned here are composed of sub-blocks. In practice, a single unidirectional motion information block in the affine motion information data structure can include information about one reference image and two to three motion vectors, or information about two to three groups of reference images and motion vectors, but the information for these reference images is the same.

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

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

[0079] IBC can be thought of as applying inter-frame prediction to intra-frame prediction. As mentioned above, inter-frame prediction uses a reference block in a different image as the prediction block for the current block. IBC, on the other hand, uses a block from the coded or reconstructed portion of the current image as the prediction block for the current block. IBC is also sometimes referred to as intra picture block compensation or current picture referencing (CPR).

[0080] IBC uses a block vector (BV) to represent the position difference between the current block and the reference block, similar to the MV used in inter-frame prediction. The encoder uses block matching within the search range to determine the best matching block for the current block and encodes the BV. There are multiple methods for encoding the BV, which are not detailed 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 is not discussed here.

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

[0083] The TM method was first used in inter-frame prediction. It leverages the correlation between adjacent pixels and uses areas surrounding the current block as a template. When the current block is encoded or decoded, its left and upper sides are already encoded and decoded according to the coding order. However, existing hardware decoder implementations do not guarantee that the left and upper sides are already decoded when decoding begins. This applies to inter-frame blocks. For example, in HEVC, the prediction process for inter-frame coded blocks does not require surrounding reconstructed pixels, allowing prediction to proceed in parallel. However, intra-frame coded blocks require reconstructed pixels on the left and upper sides as reference pixels. Theoretically, the left and upper sides are available, meaning they can be implemented with appropriate hardware design adjustments. In contrast, the right and lower sides are not available under current coding standards, such as VVC.

[0084] FIG10 is an example of a TM provided in an embodiment of the present application.

[0085] As shown in Figure 10, the rectangular areas to the left and above the current block are used as templates. The height of the left template portion is generally the same as the height of the current block, and the width of the upper template portion is generally the same as the width of the current block, but they can also be different. The best 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 predefined. At each position, the degree of match between the template corresponding to that position and the templates surrounding the current block is calculated. The degree of match can be measured using distortion costs, such as the sum of absolute difference (SAD), the sum of absolute transformed difference (SATD), and the mean-squared error (MSE). SATD generally uses the Hadamard transform. Smaller values ​​of SAD, SATD, and MSE indicate a higher degree of match. The cost is calculated using the predicted block of the template corresponding to that position and the reconstructed blocks of the templates surrounding the current block. In addition to searching at whole-pixel positions, sub-pixel positions can also be searched. The motion information for the current block is determined based on the position with the highest degree of match. By leveraging the correlation between adjacent pixels, motion information that is appropriate for the template may also be appropriate 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 the template matching method for the current block, such as using a control switch to indicate whether template matching is used for the current block. A typical template matching technique is called decoder-side motion vector derivation (DMVD). Both the encoder and decoder can use the template to search to derive motion information or find better motion information based on the existing motion information. This method does not require the transmission of specific motion vectors or motion vector differences. Instead, both the encoder and decoder perform the same search rules to ensure consistent encoding and decoding. Template matching can improve compression performance, but it requires a "search" in the decoder, which increases decoder complexity.

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

[0087] IntraTMP can be considered a combination of IBC and TM. As mentioned above, using TM in inter-frame mode can reduce the overhead of encoding MVs. Similarly, using TM in IBC can reduce the overhead of encoding BVs. For example, instead of encoding BVs, the matching block found by TM can be used directly as the intraTMP prediction block for the current block.

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

[0089] A key reason IBC can significantly improve the compression efficiency of screen content encoding is that many repeated blocks can be found in screen content, and screen content often has sharp boundaries. In terms of color (brightness and chroma), there are often large areas with the same color (brightness and chroma). However, this is almost never the case with camera-captured content. Camera-captured content inevitably contains noise, and even if some areas of camera-captured content appear uniform in color at first glance, there are often variations in brightness and chroma. Camera-captured content rarely has sharp boundaries. On the other hand, camera-captured content does contain nearly repeated blocks. This is because noise, subtle variations in brightness, and perspective make it difficult to find identical blocks. However, it is undeniable that repeated textures exist in camera-captured content.

[0090] Normally, intraTMP will use the best matching block found by template matching as its final prediction block. That is to say, when decoding the current block, there will be a flag to determine whether the current block uses intraTMP. If the current block uses intraTMP, the decoder will use the template matching method to find a best matching block and use the value of the best matching block as the prediction value of the current block. It is worth noting that although the template has a strong correlation with the current block, the template is not the current block after all. The best matching block found by the template (actually the position of the current block corresponding to the best matching block of the template) may not necessarily be the best matching block of the current block. However, the decoder does not have the current block when searching, so it can only use the best matching block found by the template as the best matching block found by intraTMP.

[0091] (6) IntraTMP multiple candidates.

[0092] Set N candidates for intraTMP, or set a candidate list intraTmpCandList[N] of length N. During encoding, if the current block uses intraTMP, after encoding the flag, it is necessary to encode an index to determine which of the N candidates is selected for the current block. Accordingly, the decoding syntax is as follows, where intra_tmp_flag is the flag for intraTMP. If intra_tmp_flag is true, then continue to parse intra_tmp_idx, which 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 BV corresponding to intraTmpCandList[intra_tmp_idx] as the BV selected by intraTMP.

[0094] So how should we construct intraTmpCandList? An example is as follows:

[0095] Each time intraTMP searches a BV, it calculates the cost of the template under the BV. The template cost is generally the cost of matching the template of the current block with the template of a block of the same size as the current block, as determined by the current BV. This cost can be SAD, SATD, SSE, etc. IntraTMP can sort the searched blocks or BVs in ascending order according to these costs. The top N candidates become the N candidates in intraTmpCandList. Alternatively, only the top N candidates with the lowest cost are maintained, and candidates ranked beyond N can be discarded, thus saving computational effort.

[0096] Typically, blocks corresponding to adjacent BVs are relatively close, especially if the BV supports sub-pixel precision, such as 1 / 2, 1 / 4, 1 / 8, or 1 / 16. Uncontrolled sorting based solely on template cost can easily congregate multiple candidates into a small range. Therefore, some control is required to prevent excessive concentration of candidate BVs in intraTmpCandList.

[0097] One way to do this 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 speaking, the BVs of integer pixels can be searched sequentially. If the BV currently being searched is (x0, y0), the next one is (x0+1, y0), provided that the boundary of the search range has not been reached. However, here we can first do a sparse search. For example, for the BV of integer pixels, if the BV currently being searched is (x0, y0), the next one is (x0+4, y0), provided that the boundary of the search range has not been reached. That is, template matching is performed every certain number of pixels, or template matching is performed every certain step length. The step length here can be a preset value, such as 2, 4, 8, etc. Of course, the same process can be done in the vertical direction. First find the BV with the lowest N costs. Then, based on the BV with the lowest N costs, make improvements within a small range based on each BV. If the search interval is 4 pixels, the improved range can be set to 4x4, and the improved BV can replace the original BV and re-rank it among the N candidates. In this way, N BV candidates with a certain distance can be obtained.

[0099] For example, if N is 3, it can be improved as follows:

[0100] first step:

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

[0102] Step 2:

[0103] A second search is performed based on the three sorted BVs. 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 re-participate in the sorting of intraTmpCandList. Of course, if the BV with the lowest cost is still the original BV, there is no need to re-sort it.

[0104] If sub-pixel accuracy is supported, the BV can be further refined to sub-pixel levels. For example, a 1 / 2 pixel search can be performed within a pixel range above, below, left, and right based on the whole pixel BV selected in the second step.

[0105] It is worth noting that building the candidate list is done by both the encoding and decoding ends, so as to ensure that the candidate list obtained by the encoding end is consistent with the candidate list obtained by the decoding end.

[0106] (7) Binarization method of intra_tmp_idx.

[0107] Since intraTmpCandList is sorted, statistically speaking, the higher the candidate's position, the greater the probability of being selected. Therefore, variable-length encoding or truncated unary encoding can be used for the binarization and debinarization of intra_tmp_idx. For example, edge length encoding is shown in Table 1 below.

[0108] Table 1

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

[0110] If N is large, the probability of the candidate at the front is high, and the probability decreases as the candidate moves forward, and the probabilities become closer as the candidate moves forward. Therefore, the codeword at the front can be shorter than the codeword at the back, and the codewords at the back can be longer, so that some candidates at the back can use the same code length. For example, the encoding method shown in Table 2 can be used.

[0111] Table 2

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

[0113] (8) IntraTMP filter.

[0114] In the intraTMP method described above, the reference block is used to directly generate the prediction block. In other words, if the BV is determined to be integer-pixel accurate, 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 BV is determined to be fractional-pixel accurate, the value at the corresponding position obtained by interpolation filtering is directly used as the value at the corresponding position in the prediction block. After directly generating the prediction block, the predicted value can be further filtered to improve the prediction block.

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

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

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

[0118] The filter uses the pixel to be filtered and one adjacent pixel above, below, left, and right to form a cross, as shown in Figure 13. C represents the pixel to be filtered, N represents the pixel above it, S represents the pixel below it, W represents the pixel to its left, and E represents the pixel to its right. B (bias) is a fixed value. For example, if B is the median of the pixel value range, for example, 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] Alternatively, one method for determining filter coefficients is to train the filter coefficients using the templates of the reference block and 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, the template for training the filter can also use the same size. Areas outside the reference block template can be padded from within the reference block template using padding, thus not adding additional bandwidth.

[0120] In addition, one method for training filter coefficients is to calculate a set of coefficients so that the mean square error (MSE) between the filtered reference block template and the current block template is minimized.

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

[0122] It is worth noting that the intraTMP multi-candidate method uses templates to screen a small number of promising candidates from a large number of possible BVs. The encoder then 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 more accurate judgments than the decoder. In this way, the collaboration between the encoder and decoder can achieve better compression efficiency. IntraTMP filtering can use templates to train filter coefficients, improving on the original prediction values ​​of intraTMP.

[0123] FIG15 is a schematic flow chart of a decoding method 300 provided in an embodiment of the present application. It should be understood that the decoding method 300 can be executed by a decoder. For example, it can be applied to the decoding framework 200 shown in FIG2 . For ease of description, the following description uses an encoder as an example.

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

[0125] S310: The decoder obtains a first identifier and a first index for indicating whether to filter.

[0126] Exemplarily, the first identifier may be a sequence-level identifier, an image-level (ie, frame-level) identifier, a slice-level identifier, or an image block-level identifier.

[0127] S320 : The decoder determines a first candidate list formed by candidate block vectors BV of the current block based on a first prediction mode corresponding to the intra template prediction.

[0128] Exemplarily, the first prediction mode may be the intraTMP mode mentioned above.

[0129] S330: The decoder determines a prediction 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 the first identifier and the first index, the prediction block of the current block can be determined in combination with the candidate BV indicated by the first index and the first identifier, thereby improving the accuracy of the prediction block and, further, improving the decoding performance of the decoder.

[0131] In some embodiments, the S310 may include:

[0132] Obtain a second identifier;

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

[0134] Exemplarily, 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 another prediction mode 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, when the value of the second flag is 0, it indicates that the first prediction mode is used for prediction, and when the value of the second flag is 1, it indicates that the first prediction mode is not used for prediction. Alternatively, when the value of the second flag is 1, it indicates that the first prediction mode is used for prediction, and when the value of the second flag is 0, it indicates that the first prediction mode is not used for prediction. Of course, other values ​​can also be used for indication, and this application is not limited to this.

[0136] Of course, the second mark can also achieve the corresponding indication function through other methods, and this application does not limit this.

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

[0138] In some embodiments, the 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; and then determines the first candidate list based on the multiple candidate BVs.

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

[0141] Exemplarily, 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 no matter whether the decoder performs template matching on the current block according to the parameters corresponding to the first identifier (such as at least one of the search range, search step, search order, and 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 means that the first candidate list determined by the decoder when the first identifier indicates filtering is different from the first candidate list determined by the decoder when the first identifier indicates not filtering.

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

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

[0145] In this embodiment, taking into account the first identifier, when the decoder performs template matching on the current block based on the first prediction mode, the current block is template matched according to the parameters corresponding to the first identifier to obtain the multiple candidate BVs, which can ensure 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 the preset parameters to obtain the multiple candidate BVs.

[0147] In some embodiments, the parameter corresponding to the first identifier includes at least one of the following: a search range, a search step, a 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 used by the decoder to perform template matching, which is not specifically limited in this application.

[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 not 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] Exemplarily, 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 based on the first prediction mode 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 that filtering is not to be performed, 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 may be a search range smaller than the second search range.

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

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

[0154] For another example, if the first identifier indicates filtering, the parameters corresponding to the first identifier include a first search order; if the first identifier indicates not filtering, 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 another example, if the first identifier indicates filtering, the number of candidate BVs in the first candidate list is a first number; if the first identifier indicates not filtering, the number of candidate BVs in the first candidate list is a second number; wherein the first number is smaller 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 number is smaller than the second number, 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 smaller than the number of candidate BVs in the first candidate list constructed by the decoder when the first identifier indicates no filtering, thereby reducing the complexity of the first candidate list constructed by the decoder when the first identifier indicates filtering. However, the present application is not limited to this, that is, 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 number may also be greater than or equal to the second number. The present application does not make specific limitations on this.

[0157] In some embodiments, the decoder determines template matching costs of the plurality of candidate BVs; and then sorts the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs 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 may consider or not consider the first identifier when performing template matching based on the first prediction mode, the scheme for the decoder to determine the first candidate list may include any one of the following:

[0159] Option 1:

[0160] The decoder performs template matching on the current block according to preset parameters (such as at least one of the search range, search step, search order, and the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then sorts the multiple candidate BVs based on their template matching costs 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, and then sorts the multiple candidate BVs within the preset search range based on the template matching costs of the multiple candidate BVs within the preset search range 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 (for example, at least one of the search range, search step, search order, and the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then sorts the multiple candidate BVs based on their template matching costs to obtain the first candidate list.

[0164] For example, taking the case where the parameters corresponding to the first identifier include a search range, 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, and then sorts the multiple candidate BVs within the first search range based on the template matching costs of 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, and then sorts the multiple candidate BVs within the second search range based on the template matching costs of 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] Exemplarily, the decoder may determine the first candidate list according to Scheme 1 or Scheme 2 by default.

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

[0167] Exemplarily, the decoder adopts 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, the template matching costs of the multiple candidate BVs are determined; based on the template matching costs of the multiple candidate BVs, at least one candidate BV among the multiple candidate BVs is determined; the template corresponding to the candidate BV in the at least one candidate BV is filtered 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, the template matching cost of the candidate BV in the at least one candidate BV is determined; based on the template matching cost of the candidate BV in the at least one candidate BV, the at least one candidate BV is sorted to obtain the first candidate list.

[0170] Exemplarily, the template matching costs of the multiple candidate BVs include the template matching cost of each candidate BV in the multiple candidate BVs, where the template matching cost of each candidate BV refers to the matching cost between the template of the reference block corresponding to each candidate BV and the template of the current block. The matching cost can be any parameter that can be used to measure distortion cost, including but not limited to SAD, SATD, MSE, etc.

[0171] Exemplarily, when filtering the template corresponding to the first candidate BV among the at least one candidate BV, the decoder may first determine filter coefficients based on the template of the reference block corresponding to the first candidate BV and the template of the current block; then, based on the determined filter coefficients, filter the template of the reference block corresponding to the first candidate BV to obtain the filtered template corresponding to the first candidate BV. Furthermore, the decoder may determine a matching cost for the first candidate BV based on the filtered template corresponding to the first candidate BV and the template of the current block.

[0172] Exemplarily, when the decoder sorts the at least one candidate BV based on the template matching cost of the candidate BV in the at least one candidate BV, the sorting may be performed 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 process: determining the template matching cost of the multiple candidate BVs; determining at least one candidate BV among the multiple candidate BVs based on the template matching cost of the multiple candidate BVs; filtering 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; determining the template matching cost of 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; sorting the at least one candidate BV based on the template matching cost of the candidate BV in 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 their template matching costs; and determines some candidate BVs that are at the top of the sort as the at least one candidate BV.

[0175] Exemplarily, the decoder sorts the multiple candidate BVs in ascending order based on the template matching costs of the multiple candidate BVs; and then determines the candidate BV with a higher position after sorting as the at least one candidate BV.

[0176] In some embodiments, if the first identifier indicates that filtering is not to be performed, the template matching costs of the multiple candidate BVs are determined; and the multiple candidate BVs are sorted based on the template matching costs of the multiple candidate BVs to obtain the first candidate list.

[0177] In other words, if the first identifier indicates that no filtering is to be 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 costs of the multiple candidate BVs; and then determining the candidate BV with a higher 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 is necessary 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 scheme for determining the first candidate list by the decoder may include any one of the following:

[0179] Option 1:

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

[0181] For example, the decoder performs template matching on the current block according to preset parameters (such as at least one of the search range, search step, search order, and the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; if the first identifier indicates filtering, the decoder constructs the first candidate list based on the multiple candidate BVs according to construction method 1; if the first identifier indicates no filtering, 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 (for example, at least one of the search range, search step, search order, and the number of candidate BVs in the first candidate list) to obtain the multiple candidate BVs; then constructs the first candidate list based on the multiple candidate BVs according to the construction method corresponding to the first identifier (for example, construction method 1 or construction method 2).

[0184] For example, taking the case where the parameter corresponding to the first identifier includes a search range, 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, and then constructs the first candidate list based on the multiple candidate BVs within the first search range according to construction method 1; if the first 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, and 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 may be smaller than the second search range.

[0185] In some embodiments, the S310 may include:

[0186] Obtaining the first identifier;

[0187] Based on the first identifier, the first index is obtained.

[0188] Exemplarily, the decoder first decodes the code stream to obtain the first identifier, and then decodes the code stream 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 may obtain the first identifier and the first index at the same time by decoding the code stream, or the decoder may first obtain the first index by decoding the code stream and then obtain the first identifier by decoding the code stream.

[0190] In some embodiments, the first index is obtained based on a 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 to be performed, the debinarization method corresponding to the first identifier includes at least one of the following: a binarization method for variable-length codes, a binarization method for truncated unary codes; if the first identifier indicates that filtering is to be performed, the debinarization method corresponding to the first identifier includes at least one of the following: a binarization method for fixed-length codes, a binarization method for truncated binary codes.

[0193] Exemplarily, if the first flag indicates that no filtering is performed, the decoder may use 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 the binary sequence after binarization. Among them, BinIdx0, BinIdx1, and BinIdx2 represent the first, second, and third binary numbers respectively.

[0196] For example, if the first flag indicates filtering, the decoder may use the debinarization method shown in Table 4 below:

[0197] Table 4

[0198] As shown in Table 4, no matter what the value of the first index is, the length of the binary sequence after binarization is fixed to 2. Among them, BinIdx0 and BinIdx1 respectively identify the first and second binary numbers.

[0199] In some embodiments, the decoder obtains the first index based on a 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, the S330 may include:

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

[0203] If the first identifier indicates that filtering is not to be performed, 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 filters the reference block corresponding to the candidate BV indicated by the first index to obtain the prediction block, which can also be understood as: the decoder filters the first prediction block corresponding to the candidate BV indicated by the first index to obtain the second prediction 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 prediction block of the current block, and then filters the first prediction block to obtain the second prediction block. In other words, for the decoder, the technical solutions for filtering the reference block corresponding to the candidate BV indicated by the first index and filtering the prediction block of the current block are essentially the same, the difference being the different angles from which the filtering is described.

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

[0206] Obtaining a residual block of the current block;

[0207] A reconstructed block of the current block is determined based on the residual block and the prediction block.

[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 may determine the sum of the residual block and the prediction block as the reconstructed block.

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

[0210] If the first identifier indicates filtering, obtaining a first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and a second template area of ​​the current block;

[0211] A filter coefficient is determined based on the first template area and the second template area.

[0212] Exemplarily, if the first identifier indicates filtering, the decoder obtains the first template area and the second template area, and determines the filtering coefficient based on the first template area and the second template area, and then filters the reference block corresponding to the candidate BV indicated by the first index to obtain the predicted block.

[0213] In some embodiments, the decoder may determine the filter coefficients as follows:

[0214] For a first sample in the first template area, filtering the first sample with samples in an area surrounding the first sample to obtain a filtered second sample;

[0215] The filter coefficient is determined based on a difference between the second sample and a third sample within the second template area; wherein a position of the first sample within the first template area is the same as a position of the third sample within the template area.

[0216] Exemplarily, the decoder may filter each sample within the first template area to obtain a filtered sample within the first template area, and then determine the filter coefficient based on the difference between the filtered sample within the first template area and the sample within the second template area. For example, the decoder determines the filter coefficient based on the mean square error (MSE) between the filtered sample within the first template area and the sample within the second template area. For example, the decoder may adjust the current coefficient used by the filter based on the MSE between the filtered sample within the first template area and the sample within the second template area until the MSE between the filtered sample within the first template area and the sample within the second template area is less than a preset threshold or the number of adjustments exceeds a preset number, and then determine the current coefficient as the filter coefficient.

[0217] In some embodiments, when the samples in the surrounding area of ​​the first sample include samples at a first position outside the first template area, the samples at the first position are samples obtained by filling the first position with samples within the first template area.

[0218] Exemplarily, the first position is a position adjacent to a sample edge of an edge position of the first template region. For example, the first position is a position adjacent to an upper edge, a position adjacent to a lower edge, a position adjacent to a left edge, or a position adjacent to a right edge of the first template region. For example, with reference to FIG14 , when the first template region is a reference template, the second template region is a current template, and the first sample is a sample at the upper left corner of the reference template, the sample at the first position may include samples above and to the left of the sample at the upper left corner of the reference template.

[0219] In some embodiments, the filter coefficients are trained coefficients.

[0220] Of course, in other alternative embodiments, the filter coefficients may also be determined by calculating samples within the first template area and samples within the second template area, which is not limited in this application.

[0221] It should be noted that the first template area and the second template area can refer to Figure 14 and the relevant content of the intraTMP filter part mentioned above. In order to avoid repetition, they will not be described here. In addition, in other alternative embodiments, the method for determining the filter coefficient can also be simplified. For example, as a possible implementation method, the data used to determine the filter coefficient (i.e., the first template area and the second template area) can be simplified. For example, the template area shown in Figure 14 can be simplified to a template area of ​​3 rows and 3 columns. For another possible implementation method, simplification can be performed based on a training method. For example, a training method simpler than MSE can be used to train the filter coefficient. This application does not make specific limitations on this.

[0222] The following describes the details in conjunction with 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 prediction value, then:

[0227] 1. Parse intra_tmp_idx and intra_tmp_filter_flag. They are not dependent on each other and the order can be reversed.

[0228] 2. Search for possible BVs within a preset search range according to a 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, and determine the candidate list intraTmpCandList based on the template matching cost.

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

[0230] 4. If the value of intra_tmp_filter_flag is 1 or true, the reference block is filtered. One method is to determine a reference block template based on the selected BV and determine filter coefficients based on the reference block template and the current block template. The reference block is filtered using the determined filter coefficients. The values ​​at the corresponding positions in the filtered reference block are used as the values ​​at the corresponding positions in the prediction block. If the value of intra_tmp_filter_flag is 0 or false, the values ​​at the corresponding positions in the reference block are used as the values ​​at the corresponding positions in the prediction block.

[0231] The specific process of the encoder is as follows:

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

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

[0234] 3. According to 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 code stream.

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

[0236] Determine BV based on each candidate in intraTmpCandList, determine the reference block corresponding to BV, obtain the unfiltered prediction block, determine the reference block template, determine the filter coefficient based on the reference block template and the current block template, determine the filtered prediction block based on the filter coefficient and the reference block, and determine the estimated distortion cost SAD or SATD based on each candidate unfiltered prediction block and filtered prediction block compared with the current block. Use the estimated distortion cost SAD or SATD plus the estimated overhead cost to calculate the estimated coding cost. Based on these coding costs, select several candidate and filtering combinations for rate-distortion optimization RDO to determine the coding cost. The pseudo code is as follows:

[0237] Of course, it is also possible to not perform rate-distortion optimization and directly use the estimated coding cost as the coding cost. This method is generally used when the coding complexity is limited.

[0238] Of course, the encoder can be simplified. In the above example, each candidate will be checked for filtering or not. Alternatively, all candidates can be checked for filtering first, and the best one or several can be selected for filtering. The pseudo code is as follows:

[0239] In this embodiment, the encoder (or decoder) does not consider filtering when constructing the candidate list, but simply arranges the candidate list based on 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 prediction value, then:

[0244] 1. Parse intra_tmp_filter_flag and intra_tmp_idx.

[0245] 2. Construct intraTmpCandList according to intra_tmp_filter_flag.

[0246] 3. Determine the BV selected by the current block based on the candidates in intraTmpCandList[intra_tmp_idx]. Determine the reference block.

[0247] 4. If the value of intra_tmp_filter_flag is 1 or true, the reference block is filtered. One method is to determine a reference block template based on the selected BV and determine filter coefficients based on the reference block template and the current block template. The reference block is filtered using the determined filter coefficients. The values ​​at the corresponding positions in the filtered reference block are used as the values ​​at the corresponding positions in the prediction block. If the value of intra_tmp_filter_flag is 0 or false, the values ​​at the corresponding positions in the reference block are used as the values ​​at the corresponding positions in the prediction block.

[0248] The decoder can take filtering into account when constructing the list. One method 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 construct a list for the non-filtering case or a list for the filtering case based on the value of intra_tmp_filter_flag. The search methods of the two lists, including the search range, search order, etc., and the list lengths can be the same or different.

[0250] Parsing method:

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

[0252] Furthermore, the binarization and debinarization methods of intra_tmp_idx can also be different. Even if the list lengths of the two cases are the same, they may follow different probability distribution rules, so different binarization and debinarization methods can be set. To give an example that is easier to understand, in one case (such as no filtering), the probability of the first few candidates with very small indexes being selected is significantly higher than that of other candidates with larger indexes. The binarization and debinarization methods assign shorter binary symbols to the first few candidates with very small indexes, and longer binary symbols to other candidates with larger indexes. In another case (such as filtering), the probability of the first few candidates with very small indexes being selected is similar to that of other candidates with larger indexes. The difference in the length of the binary symbols assigned to them by the binarization and debinarization methods is not as large as in the previous case, or the same binary symbol length is directly used. That is to say, the codec selects a set of binarization and debinarization methods according to the value of intra_tmp_filter_flag. For example, if the value of intra_tmp_filter_flag is 0, the binarization and debinarization method 1 is selected. If the value of intra_tmp_filter_flag is 1, the binarization and debinarization method 2 is selected.

[0253] An example is as follows:

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

[0255] Binarization and debinarization method 2: The correspondence between the index and the 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. In other words, the probabilities of the binary symbols based on context coding in the two cases are accumulated and updated separately. In other words, the codec selects a set of context models based on the value of intra_tmp_filter_flag. For example, if the value of intra_tmp_filter_flag is 0, a set of context models contextModel0 is selected, and if the value of intra_tmp_filter_flag is 1, a set of context models contextModel1 is selected.

[0257] If the list length, binarization and debinarization methods, context model, etc. are the same, that is, 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, intra_tmp_idx depends on intra_tmp_filter_flag, then parse intra_tmp_filter_flag first and then parse intra_tmp_idx.

[0258] The decoder uses a debinarization method. Based on the symbol-binary symbol correspondence table, if a binary symbol is encoded using a context mode, the decoder selects the context model and reads the bitstream to determine the symbol's value. The encoder uses a binarization method. Based on the symbol-binary symbol correspondence table, if a binary symbol is encoded using a context mode, the decoder selects the context model and determines the content written to the bitstream based on the symbol's value. Symbol corresponds to intra_tmp_idx.

[0259] Candidate list construction method:

[0260] If filtering is used, when constructing the list, filter coefficients can be determined based on the reference block template corresponding to the searched BV and the current block template. The reference block template is filtered based on the determined filter coefficients. The filtered reference block template and the current block template are used to calculate the matching cost. The list is constructed based on the matching cost. A list is maintained, sorted by matching cost from smallest to largest.

[0261] One method is to perform the above-mentioned operations of deriving filter coefficients for each BV to be searched, filtering the reference block template, etc. The decoder complexity of this method is higher than that of not using filtering.

[0262] For ease of description, we refer to the above-mentioned determination of filter coefficients based on the reference block template and the current block template corresponding to the searched BV. The reference block template is filtered based on the determined filter coefficients. The operations of calculating the matching cost using the filtered reference block template and the current block template are referred to as search filtering. Complexity can be reduced by reducing the number of search filtering operations. One method is to set a search method that is different from that in the case where filtering is not used, such as a search range or search order, for example, using a smaller search range than in the case where filtering is not used.

[0263] Another method is to proceed in two steps. In the first step, search without filtering to screen out a small range of candidate BVs, and then use filtering to search and filter the small range of candidate BVs to finally determine the candidate list.

[0264] An example is as follows. Regardless of whether the value of intra_tmp_filter_flag is 0 (false) or 1 (true), the existing method is used, that is, no filtering is used, to construct a candidate list intraTmpUnfilterCandList that does not use filtering. If the value of intra_tmp_filter_flag is 1 (true), search filtering is used to construct intraTmpFilterCandList based on intraTmpUnfilterCandList. Specifically, let the length of intraTmpUnfilterCandList be N, and search filtering is performed on each candidate BV of the first M candidates in intraTmpUnfilterCandList. According to the matching cost of the search filtering, intraTmpFilterCandList[M] is constructed, and the candidates in intraTmpFilterCandList are sorted from small to large according to the matching cost of the search filtering. Where M is less than or equal to N. If the value of intra_tmp_filter_flag is 1 (true), intraTmpCandList=intraTmpFilteredCandList; otherwise, that is, the value of intra_tmp_filter_flag is 0 (false), intraTmpCandList=intraTmpUnfilteredCandList.

[0265] The above example can also be understood as whether filtering is used or not, an unfiltered candidate list is first constructed, and if filtering is required, a filtered candidate list is constructed based on the unfiltered candidate list.

[0266] The specific process of the encoder is as follows:

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

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

[0269] 3. According to 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 code stream.

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

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

[0272] Determine BV based on each candidate in intraTmpCandList, determine the reference block corresponding to BV, and if intra_tmp_filter_flag is 0, obtain the prediction block without filtering; if intra_tmp_filter_flag is 1, determine the reference block template, determine the filter coefficient based on the reference block template and the current block template, determine the prediction block to be filtered based on the filter coefficient and the reference block, determine the estimated distortion cost SAD or SATD based on the comparison between the prediction block and the current block, use the estimated distortion cost SAD or SATD plus the estimated overhead cost to calculate the estimated coding cost, select several candidate and filtering combinations based on these coding costs for rate-distortion optimization RDO, and determine the coding cost. The pseudo code 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 a prediction without filtering. If intra_tmp_filter_flag=1, Prediction is a prediction with filtering.

[0275] Of course, it is also possible to not perform rate-distortion optimization and directly use the estimated coding cost as the coding cost. This method is generally used when the coding complexity is limited.

[0276] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the embodiments mentioned above. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all fall within the scope of protection of the present application. For example, the various specific technical features described in the specific embodiments mentioned above can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will no longer describe the various possible combinations separately. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application. It should also be understood that in the various method embodiments of the present application, the size of the sequence numbers of the processes mentioned above does not mean the order of execution. The order of execution 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 the present application.

[0277] The decoding method according to the embodiment of the present application is described in detail above from the perspective of the decoder. The encoding method according to the embodiment of the present application will be described below from the perspective of the encoder in conjunction with Figure 16.

[0278] FIG16 is a schematic flow chart of an encoding method 400 provided in an embodiment of the present application. It should be understood that the encoding method 400 can be performed by an encoder. For example, it can be applied to the encoding framework 100 shown in FIG1 . For ease of description, the following description uses an encoder as an example.

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

[0280] S410 , determining at least one candidate list formed by candidate block vectors BV of the current block based on a first prediction mode corresponding to the intra template prediction;

[0281] S420, determining, based on the at least one candidate list, a first identifier for indicating whether to filter and a first index for indicating a candidate BV in a first candidate list among the at least one candidate list;

[0282] S430: Encode the first identifier and the first index.

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

[0284] Determining a prediction block of the current block based on the first identifier and the first index;

[0285] determining a second flag based on the distortion cost of the prediction block; the second flag indicating whether to use the first prediction mode to predict the current block;

[0286] Encode the second identifier.

[0287] In some embodiments, the S410 may include:

[0288] Performing template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs;

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

[0290] In some embodiments, 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 parameter corresponding to the first identifier includes at least one of the following: a search range, a search step, a 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 not 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] determining template matching costs for the plurality of candidate BVs;

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

[0297] In some embodiments, the S420 may include:

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

[0299] Filtering a reference block corresponding to the candidate BV in the first candidate list to obtain a 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 filtering, the first candidate list is the second candidate list. If the first identifier indicates not filtering, 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] determining template matching costs for the plurality of candidate BVs;

[0304] determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs;

[0305] Filtering the template corresponding to the candidate BV in the at least one candidate BV to obtain a filtered template corresponding to the candidate BV in the at least one candidate BV;

[0306] determining a template matching cost of a candidate BV in the at least one candidate BV based on a filtered template corresponding to the candidate BV in the at least one candidate BV and a template of the current block;

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

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

[0309] sorting the plurality of candidate BVs based on their template matching costs;

[0310] The candidate BVs that are at the front of the sort are determined as the 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] determining template matching costs for the plurality of candidate BVs;

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

[0314] In some embodiments, the S420 may include:

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

[0316] Filtering the reference block corresponding to the candidate BV in the third candidate list to obtain a distortion cost of the filtered reference block 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, the 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 a binarization method corresponding to the first identifier.

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

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

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

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

[0326] Determining a residual block of the current block based on a prediction block of the current block and an original block of the current block;

[0327] A reconstructed block of the current block is determined based on the residual block and the prediction block.

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

[0329] If the first identifier indicates filtering, obtaining a first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and a second template area of ​​the current block;

[0330] A filter coefficient is determined based on the first template area and the second template area.

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

[0332] In some embodiments, when the samples in the surrounding area of ​​the first sample include samples at a first position outside the first template area, the samples at the first position are samples obtained by filling the first position with samples within the first template area.

[0333] In some embodiments, the filter coefficients are trained coefficients.

[0334] It should be understood that the encoding method can be understood as the inverse process of the decoding method. Therefore, the specific scheme of the encoding method 400 can refer to the relevant content of the decoding method 300. For the sake of ease of description, this application will not be repeated here. In addition, the method embodiment of the present application is described in detail above. The following is a detailed description of the device embodiment of the present application in conjunction with Figures 17 to 19.

[0335] FIG17 is a schematic block diagram of a decoder 500 according to an embodiment of the present application.

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

[0337] An acquiring unit 510 is configured to acquire a first identifier and a first index for indicating whether to perform filtering;

[0338] A first determining unit 520 is configured to determine a first candidate list formed by candidate block vectors BV of the current block based on a first prediction mode corresponding to the intra template prediction;

[0339] The second determining unit 530 is configured to determine a prediction 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 acquiring unit 510 is specifically configured to:

[0341] Obtain a second identifier;

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

[0343] In some embodiments, the first determining unit 520 is specifically configured to:

[0344] Performing template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs;

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

[0346] In some embodiments, the first determining unit 520 is specifically configured to:

[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 parameter corresponding to the first identifier includes at least one of the following: a search range, a search step, a 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 not 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 configured to:

[0351] determining template matching costs for the plurality of candidate BVs;

[0352] The multiple 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 configured to:

[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 configured to:

[0356] If the first flag indicates to perform filtering, determining the template matching costs of the multiple candidate BVs;

[0357] determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs;

[0358] Filtering the template corresponding to the candidate BV in the at least one candidate BV to obtain a filtered template corresponding to the candidate BV in the at least one candidate BV;

[0359] determining a template matching cost of a candidate BV in the at least one candidate BV based on a filtered template corresponding to the candidate BV in the at least one candidate BV and a template of the current block;

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

[0361] In some embodiments, the first determining unit 520 is specifically configured to:

[0362] sorting the plurality of candidate BVs based on their template matching costs;

[0363] The candidate BVs that are at the front of the sort are determined as the at least one candidate BV.

[0364] In some embodiments, the first determining unit 520 is specifically configured to:

[0365] If the first flag indicates not to perform filtering, determining the template matching costs of the multiple candidate BVs;

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

[0367] In some embodiments, the acquiring unit 510 is specifically configured to:

[0368] Obtaining the first identifier;

[0369] Based on the first identifier, the first index is obtained.

[0370] In some embodiments, the acquiring unit 510 is specifically configured to:

[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 to be performed, the debinarization method corresponding to the first identifier includes at least one of the following: a binarization method for variable-length codes, a binarization method for truncated unary codes; if the first identifier indicates that filtering is to be performed, the debinarization method corresponding to the first identifier includes at least one of the following: a binarization method for fixed-length codes, a binarization method for truncated binary codes.

[0373] In some embodiments, the acquiring unit 510 is specifically configured to:

[0374] The first index is obtained based on the context model corresponding to the first identifier.

[0375] In some embodiments, the second determining unit 530 is specifically configured to:

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

[0377] If the first identifier indicates that filtering is not to be performed, 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] Obtaining a residual block of the current block;

[0380] A reconstructed block of the current block is determined based on the residual block and the prediction block.

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

[0382] If the first identifier indicates filtering, obtaining a first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and a second template area of ​​the current block;

[0383] A filter coefficient is determined based on the first template area and the second template area.

[0384] In some embodiments, the second determining unit 530 is specifically configured to:

[0385] For a first sample in the first template area, filtering the first sample with samples in an area surrounding the first sample to obtain a filtered second sample;

[0386] The filter coefficient is determined based on a difference between the second sample and a third sample within the second template area; wherein a position of the first sample within the first template area is the same as a position of the third sample within the template area.

[0387] In some embodiments, when the samples in the surrounding area of ​​the first sample include samples at a first position outside the first template area, the samples at the first position are samples obtained by filling the first position with samples within the first template area.

[0388] In some embodiments, the filter coefficients are trained coefficients.

[0389] FIG18 is a schematic block diagram of an encoder 600 according to an embodiment of the present application.

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

[0391] A first determining unit 610 is configured to determine, based on a first prediction mode corresponding to intra template prediction, at least one candidate list formed by candidate block vectors BV of the current block;

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

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

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

[0395] Determining a prediction block of the current block based on the first identifier and the first index;

[0396] determining a second flag based on the distortion cost of the prediction block; the second flag indicating whether to use the first prediction mode to predict the current block;

[0397] Encode the second identifier.

[0398] In some embodiments, the first determining unit 610 is specifically configured to:

[0399] Performing template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs;

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

[0401] In some embodiments, the first determining unit 610 is specifically configured to:

[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 parameter corresponding to the first identifier includes at least one of the following: a search range, a search step, a 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 not 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] determining template matching costs for the plurality of candidate BVs;

[0407] The multiple 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 configured to:

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

[0410] Filtering a reference block corresponding to the candidate BV in the first candidate list to obtain a 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 filtering, the first candidate list is the second candidate list. If the first identifier indicates not filtering, the first candidate list is the third candidate list.

[0413] In some embodiments, the first determining unit 610 is specifically configured to:

[0414] determining template matching costs for the plurality of candidate BVs;

[0415] determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs;

[0416] Filtering the template corresponding to the candidate BV in the at least one candidate BV to obtain a filtered template corresponding to the candidate BV in the at least one candidate BV;

[0417] determining a template matching cost of a candidate BV in the at least one candidate BV based on a filtered template corresponding to the candidate BV in the at least one candidate BV and a template of the current block;

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

[0419] In some embodiments, the first determining unit 610 is specifically configured to:

[0420] sorting the plurality of candidate BVs based on their template matching costs;

[0421] The candidate BVs that are at the front of the sort are determined as the at least one candidate BV.

[0422] In some embodiments, the first determining unit 610 is specifically configured to:

[0423] determining template matching costs for the plurality of candidate BVs;

[0424] The plurality of 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 configured to:

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

[0427] Filtering the reference block corresponding to the candidate BV in the third candidate list to obtain a distortion cost of the filtered reference block 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 configured to:

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

[0431] In some embodiments, the encoding unit 630 is specifically configured to:

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

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

[0434] In some embodiments, the encoding unit 630 is specifically configured to:

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

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

[0437] Determining a residual block of the current block based on a prediction block of the current block and an original block of the current block;

[0438] A reconstructed block of the current block is determined based on the residual block and the prediction block.

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

[0440] If the first identifier indicates filtering, obtaining a first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and a second template area of ​​the current block;

[0441] A filter coefficient is determined based on the first template area and the second template area.

[0442] In some embodiments, the second determining unit 620 is specifically configured to:

[0443] For a first sample in the first template area, filtering the first sample with samples in an area surrounding the first sample to obtain a filtered second sample;

[0444] The filter coefficient is determined based on a difference between the second sample and a third sample within the second template area; wherein a position of the first sample within the first template area is the same as a position of the third sample within the template area.

[0445] In some embodiments, when the samples in the surrounding area of ​​the first sample include samples at a first position outside the first template area, the samples at the first position are samples obtained by filling the first position with samples within the first template area.

[0446] In some embodiments, the filter coefficients are trained coefficients.

[0447] It should be understood that the device embodiment and the method embodiment can correspond to each other, and similar descriptions can refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, the decoder 500 shown in Figure 17 can correspond to the corresponding subject in the method 300 for executing the embodiment of the present application, and the aforementioned and other operations and / or functions of the various units in the decoder 500 are respectively for implementing the corresponding processes in various methods such as method 300. The encoder 600 shown in Figure 18 can correspond to the corresponding subject in the method 400 for executing the embodiment of the present application, that is, the aforementioned and other operations and / or functions of the various units in the encoder 600 are respectively for implementing the corresponding processes in 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 embodiment of the present application can be separately or all merged into one or several other units to constitute, or some (some) units therein can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effect of the embodiment of the present application. The units involved in the above are divided based on logical functions. In practical applications, the function of a unit can also be realized by multiple units, or the function of multiple units is realized by one unit. In other embodiments of the present application, the decoder 500 or encoder 600 can also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units. According to another embodiment of the present application, the decoder 500 or encoder 600 involved in the embodiment of the present application can be constructed by running a computer program (including program code) that can execute each step involved in the corresponding method on a general-purpose computing device including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), etc., to construct the decoder 500 or encoder 600 involved in the embodiment of the present application, and to implement the encoding method or decoding method of the embodiment of the present application. The computer program 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 method of the embodiment of the present application.

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

[0450] FIG19 is a schematic structural diagram of an electronic device 700 provided in an embodiment of the present 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 may be connected via a bus or other means. The computer-readable storage medium 720 is used to store a computer program 721, which includes computer instructions. The processor 710 is used to execute the computer instructions stored in the computer-readable storage medium 720. The processor 710 is the computing core and control core of the electronic device 700. It is suitable for implementing one or more computer instructions, and is specifically suitable for loading and executing one or more computer instructions to implement the corresponding method flow or corresponding function.

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

[0453] Exemplarily, the computer-readable storage medium 720 may be a high-speed RAM memory, or a non-volatile memory (Non-Volatile Memory), such as at least one disk memory; optionally, it may also be at least one computer-readable storage medium located away 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. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).

[0454] Exemplarily, the electronic device 700 may be an encoder or encoding framework involved in an embodiment of the present application; a first computer instruction is stored in the computer-readable storage medium 720; the processor 710 loads and executes the first computer instruction stored in the computer-readable storage medium 720 to implement the corresponding steps in the encoding method provided in an embodiment of the present application; in other words, the first computer instruction in the computer-readable storage medium 720 is loaded by the processor 710 and the corresponding steps are executed. To avoid repetition, they are not repeated here.

[0455] Exemplarily, the electronic device 700 may be a decoder or decoding framework involved in an embodiment of the present application; a second computer instruction is stored in the computer-readable storage medium 720; the processor 710 loads and executes the second computer instruction stored in the computer-readable storage medium 720 to implement the corresponding steps in the decoding method provided in an embodiment of the present application; in other words, the second computer instruction in the computer-readable storage medium 720 is loaded by the processor 710 and the corresponding steps are executed, which will not be repeated here to avoid repetition.

[0456] According to another aspect of the present application, the present application also provides a coding and decoding system, including the encoder and decoder mentioned above.

[0457] According to another aspect of the present application, the present application also provides a computer-readable storage medium (Memory), which is a memory device in the electronic device 700 for storing programs and data. For example, a computer-readable storage medium 720. It can be understood that the computer-readable storage medium 720 here can include both the built-in storage medium in the electronic device 700 and, of course, the extended storage medium supported by the electronic device 700. The computer-readable storage medium provides a storage space, which stores the operating system of the electronic device 700. In addition, one or more computer instructions suitable for being loaded and executed by the processor 710 are also stored in the storage space. These computer instructions can be one or more computer programs 721 (including program codes).

[0458] According to another aspect of the present application, a computer program product or computer program is provided. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. For example, computer program 721. In this case, data processing device 700 may be a computer, and processor 710 reads the computer instructions from computer-readable storage medium 720. Processor 710 executes the computer instructions, causing the computer to perform the encoding method or decoding method provided in the various optional embodiments mentioned above.

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

[0460] Those skilled in the art will appreciate that the units and process steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel 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 changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A decoding method, characterized in that: include: Obtaining a first flag and a first index for indicating whether to filter; Determine, based on a first prediction mode corresponding to the intra template prediction, a first candidate list formed by candidate block vectors BV of the current block; Determine a prediction block for the current block based on the first identifier and the candidate BV indicated by the first index in the first candidate list.

2. The method according to claim 1, characterized in that The obtaining of a first identifier and a first index for indicating whether to filter includes: Obtaining a second identifier; If the second identifier indicates that the first prediction mode is used to predict the current block, the first identifier and the first index are obtained.

3. The method according to claim 1 or 2, characterized in that The determining, based on the first prediction mode corresponding to the intra-frame template prediction, a first candidate list formed by the candidate block vectors BV of the current block includes: Performing template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs; Based on the plurality of candidate BVs, the first candidate list is determined.

4. The method according to claim 3, characterized in that The performing template matching on the current block based on the first prediction mode to obtain multiple candidate BVs includes: 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: a search range, a search step, a 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 filtering, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates not 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.

7. The method according to any one of claims 3 to 6, characterized in that The determining the first candidate list based on the multiple candidate BVs includes: determining template matching costs for the plurality of candidate BVs; The multiple 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 determining the first candidate list based on the multiple 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 determining the first candidate list based on the multiple candidate BVs and the first identifier includes: If the first flag indicates to perform filtering, determining the template matching costs of the multiple candidate BVs; determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs; Filtering the template corresponding to the candidate BV in the at least one candidate BV to obtain a filtered template corresponding to the candidate BV in the at least one candidate BV; determining a template matching cost of a candidate BV in the at least one candidate BV based on a filtered template corresponding to the candidate BV in the at least one candidate BV and a template of the current block; The at least one candidate BV is sorted based on the template matching cost of the candidate BV in the at least one candidate BV to obtain the first candidate list.

10. The method according to claim 9, characterized in that The determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs includes: sorting the plurality of candidate BVs based on their template matching costs; The candidate BVs that are at the front of the sort are determined as the at least one candidate BV.

11. The method according to claim 8, characterized in that The determining the first candidate list based on the multiple candidate BVs and the first identifier includes: If the first flag indicates not to perform filtering, determining the template matching costs of the multiple candidate BVs; The multiple 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 obtaining of a first identifier and a first index for indicating whether to filter includes: Obtaining the first identifier; Based on the first identifier, the first index is obtained.

13. The method according to claim 12, characterized in that The acquiring 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 to be performed, the debinarization method corresponding to the first identifier includes at least one of the following: a variable-length code binarization method, a truncated unary code binarization method; If the first identifier indicates filtering, the debinarization method corresponding to the first identifier includes at least one of the following: a binarization method of a fixed-length code, and a binarization method of a truncated binary code.

15. The method according to claim 12, characterized in that The acquiring the first index based on the first identifier includes: The first index is obtained based on the context model corresponding to the first identifier.

16. The method according to any one of claims 1 to 15, characterized in that The determining, based on the first identifier and the candidate BV indicated by the first index in the first candidate list, of the prediction block of the current block includes: If the first identifier indicates filtering, filtering the reference block corresponding to the candidate BV indicated by the first index to obtain the prediction block; If the first identifier indicates that filtering is not to be performed, 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 comprises: Obtaining a residual block of the current block; A reconstructed block of the current block is determined based on the residual block and the prediction block.

18. The method according to any one of claims 1 to 17, characterized in that The method further comprises: If the first identifier indicates filtering, obtaining a first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and a second template area of ​​the current block; A filter coefficient is determined based on the first template area and the second template area.

19. The method according to claim 18, characterized in that The determining of the filter coefficient based on the first template area and the second template area includes: For a first sample in the first template area, filtering the first sample with samples in an area surrounding the first sample to obtain a filtered second sample; The filter coefficient is determined based on a difference between the second sample and a third sample within the second template area; wherein a position of the first sample within the first template area is the same as a position of the third sample within the template area.

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

21. The method according to claim 18, wherein The filter coefficients are coefficients obtained through training.

22. A coding method, characterized in that include: Determine, based on a first prediction mode corresponding to intra template prediction, at least one candidate list formed by candidate block vectors BV of the current block; Based on the at least one candidate list, determining a first identifier for indicating whether to filter and a first index for indicating a candidate BV in a first candidate list among the at least one candidate list; The first identifier and the first index are encoded.

23. The method according to claim 22, characterized in that The method further comprises: Determining a prediction block of the current block based on the first identifier and the first index; determining a second flag based on the distortion cost of the prediction block; the second flag indicating whether to use the first prediction mode to predict the current block; Encode the second identifier.

24. The method according to claim 22 or 23, characterized in that The determining, based on the first prediction mode corresponding to the intra template prediction, at least one candidate list formed by the candidate block vectors BV of the current block comprises: Performing template matching on the current block based on the first prediction mode to obtain a plurality of candidate BVs; Based on the plurality of candidate BVs, the at least one candidate list is determined.

25. The method according to claim 24, characterized in that The performing template matching on the current block based on the first prediction mode to obtain multiple candidate BVs includes: 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: a search range, a search step, a 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 filtering, the parameters corresponding to the first identifier include a first search range; if the first identifier indicates not 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.

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 multiple candidate BVs includes: determining template matching costs for the plurality of candidate BVs; The multiple 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 determining, based on the at least one candidate list, a first identifier for indicating whether to filter and a first index for indicating a candidate BV in a first candidate list among the at least one candidate list comprises: Determining a distortion cost of a reference block corresponding to a candidate BV in the first candidate list; Filtering a reference block corresponding to the candidate BV in the first candidate list to obtain a 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 filtering, the first candidate list is the second candidate list. If the first identifier indicates not filtering, the first candidate list is the third candidate list.

31. The method according to claim 30, wherein The determining of the at least one candidate list based on the plurality of candidate BVs includes: determining template matching costs for the plurality of candidate BVs; determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs; Filtering the template corresponding to the candidate BV in the at least one candidate BV to obtain a filtered template corresponding to the candidate BV in the at least one candidate BV; determining a template matching cost of a candidate BV in the at least one candidate BV based on a filtered template corresponding to the candidate BV in the at least one candidate BV and a template of the current block; The at least one candidate BV is sorted based on the template matching cost of the candidate BV in the at least one candidate BV to obtain the second candidate list.

32. The method according to claim 31, characterized in that The determining at least one candidate BV from the plurality of candidate BVs based on the template matching costs of the plurality of candidate BVs includes: sorting the plurality of candidate BVs based on their template matching costs; The candidate BVs that are at the front of the sort are determined as the at least one candidate BV.

33. The method according to claim 30, wherein The determining of the at least one candidate list based on the plurality of candidate BVs includes: determining template matching costs for the plurality of candidate BVs; The plurality of 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 determining, based on the at least one candidate list, a first identifier for indicating whether to filter and a first index for indicating a candidate BV in a first candidate list among the at least one candidate list comprises: Determining a distortion cost of a reference block corresponding to a candidate BV in the second candidate list; Filtering the reference block corresponding to the candidate BV in the third candidate list to obtain a distortion cost of the filtered reference block 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 encoding of the first index based on the first identifier includes: The first index is encoded based on a binarization method corresponding to the first identifier.

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

38. The method according to claim 35, characterized in that The encoding of the first index based on the first identifier includes: The first index is encoded based on a 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 comprises: Determining a residual block of the current block based on a prediction block of the current block and an original block of the current block; A reconstructed block of the current block is determined based on the residual block and the prediction block.

40. The method according to any one of claims 22 to 39, characterized in that The method further comprises: If the first identifier indicates filtering, obtaining a first template area of ​​the reference block corresponding to the candidate BV indicated by the first index and a second template area of ​​the current block; A filter coefficient is determined based on the first template area and the second template area.

41. The method according to claim 40, wherein The determining of the filter coefficient based on the first template area and the second template area includes: For a first sample in the first template area, filtering the first sample with samples in an area surrounding the first sample to obtain a filtered second sample; The filter coefficient is determined based on a difference between the second sample and a third sample within the second template area; wherein a position of the first sample within the first template area is the same as a position of the third sample within the template area.

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

43. The method according to claim 40, wherein The filter coefficients are coefficients obtained through training.

44. A decoder, characterized in that include: An acquiring unit, configured to acquire a first identifier and a first index for indicating whether to filter; A first determining unit, configured to determine a first candidate list formed by candidate block vectors BV of the current block based on a first prediction mode corresponding to the intra template prediction; The second determining unit is configured to determine a prediction 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: a first determining unit, configured to determine, based on a first prediction mode corresponding to the intra template prediction, at least one candidate list formed by candidate block vectors BV of the current block; a second determining unit, configured to determine, based on the at least one candidate list, a first identifier for indicating whether to filter and a first index for indicating a candidate BV in a first candidate list among the at least one candidate list; An encoding unit, configured to encode the first identifier and the first index.

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

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

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

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