Template prediction method and apparatus, and electronic device

By selecting an appropriate filtering method based on the prediction pattern of the target image patch during template prediction, the problem of insufficient template prediction accuracy in the prior art is solved, and higher prediction accuracy is achieved.

WO2026086700A1PCT designated stage Publication Date: 2026-04-30VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
VIVO MOBILE COMM CO LTD
Filing Date
2025-10-17
Publication Date
2026-04-30

AI Technical Summary

Technical Problem

Existing template prediction techniques use a single interpolation filter, which cannot guarantee the prediction accuracy of the template.

Method used

The filtering method used for prediction is obtained by acquiring the template corresponding to the target image patch. The predicted value of the template is obtained according to the filtering method. Different filtering methods are matched with the prediction mode to improve the accuracy of template prediction.

Benefits of technology

This improved the accuracy of template prediction and ensured its precision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025128391_30042026_PF_FP_ABST
    Figure CN2025128391_30042026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of video processing, and discloses a template prediction method and apparatus, and an electronic device. The method in embodiments of the present application comprises: acquiring a filtering method used when performing prediction by a template corresponding to a target image block, wherein the filtering method is related to a prediction mode of the target image block; and according to the filtering method, acquiring a prediction value of the template.
Need to check novelty before this filing date? Find Prior Art

Description

Template prediction methods, devices and electronic equipment

[0001] Cross-references to related applications

[0002] This application claims priority to Chinese Patent Application No. 202411486666.2, filed on October 23, 2024, the entire contents of which are incorporated herein by reference. Technical Field

[0003] This application belongs to the field of video processing technology, specifically relating to a template prediction method, apparatus, and electronic device. Background Technology

[0004] In template prediction techniques, the interpolation filters used for template prediction are all 4-tap Discrete Cosine Transform (DCT) based interpolation filters (DCTIF). It can be seen that existing template prediction has the problem of using a single interpolation filter, which cannot guarantee the prediction accuracy of the template. Summary of the Invention

[0005] This application provides a template prediction method, apparatus, and electronic device to improve the prediction accuracy of templates.

[0006] Firstly, a template prediction method is provided, which includes:

[0007] The filtering method used when obtaining the template corresponding to the target image patch for prediction is related to the prediction mode of the target image patch;

[0008] Based on the filtering method, the predicted value of the template is obtained.

[0009] Secondly, a template prediction device is provided, comprising:

[0010] The first acquisition module is used to acquire the filtering method used when predicting the template corresponding to the target image block, and the filtering method is related to the prediction mode of the target image block;

[0011] The second acquisition module is used to acquire the predicted value of the template according to the filtering method.

[0012] Thirdly, an electronic device is provided, including a processor and a memory, the memory storing a program or instructions executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the method as described in the first aspect.

[0013] Fourthly, an electronic device is provided, including a processor and a communication interface, wherein the processor is used to obtain the filtering method used when predicting a template corresponding to a target image patch, and the filtering method is related to the prediction mode of the target image patch;

[0014] Based on the filtering method, the predicted value of the template is obtained.

[0015] Fifthly, a coding / decoding system is provided, comprising: a template prediction device, the template prediction device being configured to perform the steps of the method described in the first aspect.

[0016] In a sixth aspect, a readable storage medium is provided, on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0017] In a seventh aspect, a chip is provided, the chip including a processor and a communication interface coupled to the processor, the processor being used to run programs or instructions to implement the steps of the method described in the first aspect.

[0018] Eighthly, a computer program / program product is provided, the computer program / program product being stored in a storage medium, the computer program / program product being executed by at least one processor to perform the steps of the method as described in the first aspect.

[0019] In this embodiment, the filtering method used for prediction of the template corresponding to the target image block is first obtained, and then the template prediction value is obtained based on the filtering method. This embodiment determines the filtering method used for prediction of the template corresponding to the target image block based on the prediction mode of the target image block. This allows for the use of different filtering methods for the template under different prediction modes, ensuring that the filtering method used for template prediction matches the prediction mode. This improves the prediction accuracy and precision of the template. Attached Figure Description

[0020] Figure 1 is a schematic diagram of the encoding and decoding system provided in an embodiment of this application;

[0021] Figure 2 is a schematic diagram of the encoder provided in an embodiment of this application;

[0022] Figure 3 is a schematic diagram of the decoder provided in an embodiment of this application;

[0023] Figure 4 is a flowchart illustrating the template prediction method according to an embodiment of this application;

[0024] Figure 5 is a schematic diagram of the template prediction device according to an embodiment of this application;

[0025] Figure 6 is a schematic diagram of the structure of an electronic device according to an embodiment of this application;

[0026] Figure 7 is a schematic diagram of the structure of a communication device according to an embodiment of this application. Detailed Implementation

[0027] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0028] The terms "first," "second," etc., used in this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same class, without limiting the number of objects; for example, the first object can be one or more. Furthermore, "or" in this application indicates at least one of the connected objects. For example, "A or B" covers three scenarios: Scenario 1: including A but not B; Scenario 2: including B but not A; Scenario 3: including both A and B. The character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0029] Figure 1 is a schematic diagram of the encoding / decoding system provided in an embodiment of this application. The technical solution of this application embodiment relates to encoding and decoding (CODEC) video data (including encoding or decoding). The video data includes original unencoded video, encoded video, decoded (e.g., reconstructed) video, or syntax elements, etc.

[0030] As shown in Figure 1, the encoding / decoding system includes a source device 100, which provides encoded video data to be decoded and displayed by a destination device 110. Specifically, the source device 100 provides video data to the destination device 110 via a communication medium 120. The source device 100 and the destination device 110 may include any one or more of the following: desktop computer, laptop computer, tablet computer, set-top box, mobile phone, wearable device (e.g., smartwatch or wearable camera), television, camera, display device, in-vehicle device, virtual reality (VR) device, augmented reality (AR) device, mixed reality (MR) device, digital media player, video game console, video conferencing equipment, video streaming equipment, broadcast receiver equipment, broadcast transmitter equipment, spacecraft, aircraft, robot, satellite, etc.

[0031] In the example of Figure 1, source device 100 includes a data source 101, memory 102, encoder 200, and output interface 104. Destination device 110 includes an input interface 111, decoder 300, memory 113, and display device 114. Source device 100 represents an example of a video encoding device, while destination device 110 represents an example of a video decoding device. In other examples, source device 100 and destination device 110 may not include some of the components shown in Figure 1, or they may include components other than those shown in Figure 1. For example, source device 100 may receive video data from an external data source (such as an external camera). Similarly, destination device 110 may interface with an external display device instead of including an integrated display device. As another example, memory 102 and memory 113 may be external memories.

[0032] Although Figure 1 illustrates the source device 100 and the destination device 110 as separate devices, in some examples, they may be integrated into a single device. In such embodiments, the same hardware or software, separate hardware or software, or any combination thereof may be used to implement the functionality corresponding to the source device 100 and the functionality corresponding to the destination device 110.

[0033] In some examples, source device 100 and destination device 110 can perform unidirectional or bidirectional video transmission. If it is bidirectional video transmission, source device 100 and destination device 110 can operate in a substantially symmetrical manner, that is, each of source device 100 and destination device 110 includes an encoder and a decoder.

[0034] Data source 101 represents the source of video data (i.e., raw, unencoded video data) and provides encoder 200 with a series of images containing video data, which encoder 200 encodes. Data source 101 of source device 100 may include video acquisition devices (such as video cameras), video archives containing previously acquired raw video, or video feed interfaces for receiving video from video content providers. Alternatively, data source 101 may generate computer graphics-based data as source video, or combine live video, archived video, and computer-generated video. In these cases, encoder 200 encodes the acquired, pre-acquired, or computer-generated video data. Encoder 200 may rearrange the images from the received order (sometimes referred to as the "display order") according to the encoded order. Encoder 200 may generate a bitstream including the encoded video data. Source device 100 may then output the encoded video data to communication medium 120 via output interface 104 for reception or retrieval, for example, by input interface 111 of destination device 110.

[0035] The memory 102 of the source device 100 and the memory 113 of the destination device 110 represent general-purpose memory. In some examples, memory 102 may store raw video data from data source 101, and memory 113 may store decoded video data from decoder 300. Additionally or alternatively, memories 102 and 113 may respectively store software instructions executable by, for example, encoder 200 and decoder 300. Although memories 102 and 113 are shown separately from encoder 200 and decoder 300 in this example, it should be understood that encoder 200 and decoder 300 may also include internal memory for functionally similar or equivalent purposes. If encoder 200 and decoder 300 are deployed on the same hardware device, memories 102 and 113 may be the same memory. Furthermore, memories 102 and 113 may store, for example, encoded video data output from encoder 200 and input to decoder 300. In some examples, portions of memories 102 and 113 may be allocated as one or more video buffers, for example, to store raw, decoded, or encoded video data.

[0036] In some examples, source device 100 can output encoded data from output interface 104 to memory 113. Similarly, destination device 110 can access encoded data from memory 113 via input interface 111. Memory 113 or memory 102 can include any of a variety of distributed or locally accessed data storage media, such as hard drives, Blu-ray discs, digital versatile discs (DVDs), compact disc read-only memory (CD-ROMs), flash memory, volatile or non-volatile memory, or any other suitable digital storage medium for storing encoded video data.

[0037] Output interface 104 may include any type of medium or device capable of transmitting encoded video data from source device 100 to destination device 110. For example, output interface 104 may include a transmitter or transceiver, such as an antenna, configured to transmit encoded video data directly from source device 100 to destination device 110 in real time. The encoded video data may be modulated according to the communication standards of a wireless communication protocol and transmitted to destination device 110.

[0038] Communication medium 120 may include transient media, such as wireless broadcasting or wired network transmission. For example, communication medium 120 may include radio frequency (RF) spectrum or one or more physical transmission lines (e.g., cables). Communication medium 120 may form part of a packet-based network (such as a local area network, a wide area network, or a global network such as the Internet). Communication medium 120 may also take the form of a storage medium (e.g., a non-transitory storage medium), such as a hard disk, flash drive, compact disc, digital video disc, Blu-ray disc, volatile or non-volatile memory, or any other suitable digital storage medium for storing encoded video data.

[0039] In some implementations, the communication medium 120 may include a router, switch, base station, or any other device that can be used to facilitate communication from source device 100 to destination device 110. For example, a server (not shown) may receive encoded video from source device 100 and provide the encoded video data to destination device 110, for example, via network transmission. The server may include (e.g., a web server for a website), a server configured to provide file transfer protocol services (such as File Transfer Protocol (FTP) or File Delivery Over Unidirectional Transport (FLUTE) protocol), a content delivery network (CDN) device, a Hypertext Transfer Protocol (HTTP) server, a Multimedia Broadcast Multicast Services (MBMS) or Evolved Multimedia Broadcast Multicast Service (eMBMS) server, or a Network-attached storage (NAS) device, etc. The server can implement one or more HTTP streaming protocols, such as MPEG Media Transport (MMT), Dynamic Adaptive Streaming over HTTP (DASH), HTTP Live Streaming (HLS), or Real Time Streaming Protocol (RTSP).

[0040] Destination device 110 can access encoded video data from a server, for example, via a wireless channel (e.g., Wi-Fi connection) or a wired connection (e.g., digital subscriber line (DSL), cable modem, etc.) for accessing encoded video data stored on the server.

[0041] Output interface 104 and input interface 111 can represent a wireless transmitter / receiver, a modem, a wired networking component (e.g., an Ethernet card), a wireless communication component operating according to the IEEE 802.11 or IEEE 802.15 standard (e.g., ZigBee™), Bluetooth standard, or other physical components. In an example where output interface 104 and input interface 111 include wireless components, output interface 104 and input interface 111 can be configured to transmit data, such as encoded video data, via Wi-Fi, Ethernet, or cellular networks (such as 4G, LTE (Long Term Evolution), Advanced LTE, 5G, 6G, etc.).

[0042] The technology provided in this application can be applied to support video encoding and decoding in one or more multimedia applications such as video conferencing, over-the-air television broadcasting, cable television transmission, satellite television transmission, internet streaming video transmission, digital video encoded onto a data storage medium, decoding of digital video stored on a data storage medium, or other applications.

[0043] The input interface 111 of the destination device 110 receives an encoded video bitstream from the communication medium 120. The encoded video bitstream may include syntax elements and encoded data units (e.g., sequences, image groups, images, slices, blocks, etc.), where the syntax elements are used to decode the encoded data units to obtain decoded video data. The display device 114 displays the decoded video data to the user. The display device 114 may include a cathode ray tube (CRT), a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display, or other types of display devices.

[0044] The encoder 200 and decoder 300 can be implemented as one or more of various processing circuits, which may include microprocessors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), discrete logic, hardware, or any combination thereof. When the technology is implemented wholly or partially in software, the device may store instructions for the software in a suitable non-transitory computer-readable storage medium and use one or more processors to execute the instructions in hardware to perform the technology provided in the embodiments of this application.

[0045] The encoder 200 and decoder 300 can process based on the following video codec standards: H.263, H.264, H.265 (also known as High Efficiency Video Coding, HEVC), H.266 (also known as Versatile Video Coding, VVC), Moving Picture Experts Group 2 (MPEG-2), MPEG-4, VP8, VP9, ​​Alliance for Open Media Video 1 (AV1), Audio Video Coding Standard 1 (AVS1), AVS2, AVS3, or next-generation video standard protocols. This application embodiment does not specifically limit the specific implementation.

[0046] Typically, encoder 200 and decoder 300 can perform block-based encoding and decoding of images. The term "block" generally refers to a structure that includes data to be processed (e.g., encoded, decoded, or otherwise used during encoding or decoding). For example, a block can include a two-dimensional matrix of samples of luminance or chrominance data. For example, encoder 200 and decoder 300 can encode and decode video data represented in YUV format.

[0047] Referring to Figure 2, which is a schematic diagram of the encoder 200 provided in an embodiment of this application, the encoder 200 can be the encoder 200 in Figure 1. In the example of Figure 2, the encoder 200 includes a memory 201, an encoding parameter determination unit 210, a residual generation unit 202, a transform processing unit 203, a quantization unit 204, an inverse quantization unit 205, an inverse transform processing unit 206, a reconstruction unit 207, a filter unit 208, a decoded picture buffer (DPB) 209, and an entropy encoding unit 220.

[0048] The memory 201 can store video data to be encoded. For example, the encoder 200 can receive and store video data from the data source 101 shown in Figure 1. In some examples, the memory 201 can be on the same chip as other components of the encoder 200 (as shown in Figure 2), or it can be on a separate chip from those components.

[0049] The coding parameter determination unit 210 includes a mode selection unit 211, an inter-frame prediction unit 212, and an intra-frame prediction unit 213. The inter-frame prediction unit 212 is used to obtain a first prediction block for the current block using an inter-frame prediction mode. The intra-frame prediction unit 213 is used to obtain a second prediction block for the current block using an intra-frame prediction mode. The mode selection unit 211 is used to obtain a target prediction block based on the first and second prediction blocks and determine the final prediction mode. Furthermore, the coding parameter determination unit 210 may also include other functional units, such as functional units for determining the partitioning method of coding units (CUs), functional units for determining the transformation type of the residual data of the CUs, or functional units for determining the quantization parameters of the residual data of the CUs.

[0050] For ease of description and understanding, in the embodiments of this application, the CU to be processed in the current image is referred to as the current CU, and the image block to be processed in the current CU is referred to as the current block or the image block to be processed. For example, in encoding, it refers to the block currently being encoded; in decoding, it refers to the block currently being decoded.

[0051] Inter-frame prediction unit 212 may include a motion estimation unit and a motion compensation unit. For inter-frame prediction of the current block, the motion estimation unit may perform a motion search to identify one or more matching reference blocks in one or more reference pictures (e.g., one or more previously encoded / decoded pictures stored in DPB 209).

[0052] The motion estimation unit can generate one or more motion vectors (MVs) representing the position of a reference block in a reference image relative to the position of the current block in the current image. The motion compensation unit can then use interpolation to obtain a predicted value with the precision indicated by the motion vectors.

[0053] The encoding parameter determination unit 210 can provide the target prediction block to the residual generation unit 202. The residual generation unit 202 receives the raw uncoded video data of the current block from the memory 201 and calculates the residual between the current block and the target prediction block to obtain the residual block. In some examples, the function of the residual generation unit 202 can be implemented using one or more subtractor circuits that perform binary subtraction.

[0054] As an example, the encoding parameter determination unit 210 can provide the entropy encoding unit 220 with syntax elements representing encoding parameters for encoding. The encoding parameters include one or more of the following: the partitioning method of the CU, the final prediction mode, the transformation type of the residual data of the CU, or the quantization parameters of the residual data of the CU.

[0055] The transformation processing unit 203 transforms the residual block output by the residual generation unit 202 to obtain a transform coefficient block. This transformation may include Discrete Cosine Transform (DCT), integer transformation, direction transformation, or Karhunen-Loeve transformation, etc. In some examples, the encoder 200 may not include the transformation processing unit 203.

[0056] Quantization unit 204 can quantize the transform coefficients in the transform coefficient block according to the quantization parameter (QP) value associated with the current block to generate a quantized transform coefficient block.

[0057] The inverse quantization unit 205 and the inverse transform processing unit 206 can perform inverse quantization and inverse transform on the transform coefficient block, respectively, to obtain the reconstructed residual block. The reconstruction unit 207 can generate a reconstructed block corresponding to the current block based on the reconstructed residual block and the target prediction block generated by the coding parameter determination unit 210.

[0058] Filter unit 208 can perform one or more filter operations on the reconstructed block. For example, filter unit 208 can be a deblocking filter (DBF), an adaptive loop filter (ALF), a sample adaptive offset (SAO) filter, etc. In some examples, encoder 200 may not include filter unit 208.

[0059] Encoder 200 stores the reconstructed image obtained from the reconstructed blocks in DPB 209. For example, in an example where the operation of filter unit 208 is not required, reconstruction unit 207 can store the reconstructed blocks in DPB 209. In an example where the operation of filter unit 208 is required, filter unit 208 can store the filtered reconstructed blocks in DPB 209. Inter-frame prediction unit 212 retrieves the reconstructed image from DPB 209 to perform inter-frame prediction on blocks of subsequent images to be encoded. In some examples, DPB 209 can be replaced with other types of memory.

[0060] Entropy coding unit 220 can entropy code the syntax elements of other components in encoder 200 to output encoded video data. For example, entropy coding unit 220 can entropy code the quantized transform coefficient block from quantization unit 204. As another example, entropy coding unit 220 can entropy code the syntax elements (e.g., motion information for inter-frame prediction or intra-frame mode information for intra-frame prediction) from coding parameter determination unit 210.

[0061] It is understood that the composition of the encoder 200 shown in Figure 2 is only illustrative and does not constitute a limitation on the embodiments of this application.

[0062] Figure 3 is a schematic diagram of the structure of the decoder 300 provided in an embodiment of this application. The decoder 300 can be the decoder 300 described in Figure 1. In the example of Figure 3, the decoder 300 includes a coded picture buffer (CPB) 301, an entropy decoding unit 302, a prediction processing unit 310, an inverse quantization unit 303, an inverse transform processing unit 304, a reconstruction unit 305, a filter unit 306, and a DPB 307.

[0063] The entropy decoding unit 302 can receive encoded video data from the CPB 301 and perform entropy decoding on the video data to obtain syntax elements. The syntax elements indicate encoding parameters, including one or more of the following: CU partitioning method, final prediction mode, transformation type of CU residual data, or quantization parameters of CU residual data.

[0064] When the syntax element includes the final prediction mode, the prediction processing unit 310 obtains the final prediction mode. If the final prediction mode is an inter-frame prediction mode, the prediction block of the current CU can be obtained through the inter-frame prediction unit 311 of the prediction processing unit 310; if the final prediction mode is an intra-frame prediction mode, the prediction block of the current CU can be obtained through the intra-frame prediction unit 312 of the prediction processing unit 310. In some examples, the prediction processing unit 310 may also include a unit for performing prediction functions according to other prediction modes.

[0065] CPB 301 can acquire and store encoded video data from the communication medium 120 shown in Figure 1. DPB 307 is used to store decoded images. Optionally, CPB 301 and DPB 307 can be replaced with other types of memory, which are not specifically limited in this application. In some examples, CPB 301 can be on the same chip as other components of decoder 300 (as shown in the figure), or it can be on a separate chip from those components.

[0066] Decoder 300 can perform reconstruction operations on each block individually. Entropy decoding unit 302 can entropy decode the syntax elements and transform information (e.g., QP or transform mode indication) of the quantized transform coefficients to obtain the quantized transform coefficients. Dequantization unit 303 dequantizes the quantized transform coefficients to obtain a transform coefficient block including the transform coefficients. Inverse transform processing unit 304 performs an inverse transform on the transform coefficient block to generate a residual block corresponding to the current block; this inverse transform is the reverse operation of the above transform.

[0067] Reconstruction unit 305 can reconstruct the current block based on the prediction block and the residual block. For example, reconstruction unit 305 can add samples from the residual block to the corresponding samples from the prediction block to reconstruct the current block.

[0068] Filter unit 306 can perform one or more filter operations on the reconstructed block. For example, the type of filter unit 306 can be referenced to the type of filter unit 208, and will not be described again here. In some examples, the operations of filter unit 306 can be skipped.

[0069] Decoder 300 can store the reconstructed image obtained from the reconstructed blocks in DPB 307. For example, in an example where filter unit 306 is not operated, reconstruction unit 305 can store the reconstructed blocks in DPB 307. In an example where filter unit 306 is operated, filter unit 306 can store the filtered reconstructed blocks in DPB 307. Decoder 300 can output the decoded image (e.g., decoded video) from DPB 307 for subsequent rendering on a display device (such as display device 114 of FIG. 1).

[0070] The template prediction method, apparatus, and electronic device provided in the embodiments of this application are described below with reference to the accompanying drawings. The image block prediction method provided in the embodiments of this application can be executed by an encoding end, such as the encoder 200 shown in Figure 1 or Figure 2. The image block prediction method provided in the embodiments of this application can be executed by a decoding end, such as the decoder 300 shown in Figure 1 or Figure 3. The encoding end and decoding end can be implemented by software, hardware, or a combination thereof. When implemented by hardware, the encoding end can be referred to as an encoding end device or a video encoding device, and the decoding end can be referred to as a decoding end device or a video decoding device.

[0071] The technologies related to the embodiments of this application will be described below.

[0072] In video coding, a frame of image is divided into many macroblocks, and prediction blocks are obtained using intra-frame prediction or inter-frame prediction. The difference between the original block and the prediction block is the residual block, which is then transformed, quantized, and entropy-coded. During the pre-research process of next-generation standards, some template-based prediction techniques were proposed.

[0073] 1. Traditional intra-frame prediction mode

[0074] Traditional intra-frame prediction modes include DC, planar, and angular prediction modes. These modes use the already encoded or decoded reconstructed pixels adjacent to the current coding unit as reference pixels to calculate the predicted pixel using a pre-defined model. To capture arbitrary edge directions presented in natural video, the number of intra-frame modes in VVC has been expanded from 33 used in HEVC to 65.

[0075] In video standards, image types typically include I-images, P-images, and B-images. I-images can be decoded independently without referencing other images. P-images use multiple past images that precede the current image in display order as reference images. B-images can use multiple past images that precede the current image in display order and multiple future images that follow the current image in display order as reference images.

[0076] In HEVC, a 2-tap linear interpolation filter has been used to generate intra-prediction blocks in directional prediction mode (i.e., excluding PLANAR and DC modes). In VVC, two sets of 4-tap interpolation filters replace the less accurate linear interpolation in HEVC: one is a DCT-based interpolation filter (DCTIF), and the other is a 4-tap smooth interpolation filter (SIF). The DCTIF is constructed in the same way as the DCTIF used for chroma component motion compensation in HEVC and VVC. The SIF is obtained by convolving the 2-tap linear interpolation filter with a [1 2 1] / 4 filter.

[0077] 2. Decoder-side intra-mode derivation (DIMD) is exported from the decoder.

[0078] DIMD mode is a technique for implicitly deriving intra-prediction modes. At the decoder, horizontal and vertical Sobel filters are applied to pixels in a template of width N around the block to perform gradient histogram calculations. The direction of the gradients is then converted to the intra-angle prediction mode, and the gradient intensity is accumulated as the amplitude of the corresponding intra-angle mode. The intra-prediction mode is derived by comparing the amplitudes in the gradient histograms. If the DIMD mode flag of the current coding unit to be decoded is true, intra-prediction is performed using the derived intra-prediction mode; if the DIMD mode is false, the derived intra-prediction mode is used to construct a most probable mode (MPM) list.

[0079] 3. Template-based intra-mode derivation (TIMD)

[0080] TIMD is also a technique for implicitly deriving intra-prediction modes. At the decoder, if the TIMD mode is true, for each candidate mode in the MPM list, the template's predicted pixels are generated using the template's reference pixels. The template is composed of adjacent decoded reconstructed pixels of the current coded block to be decoded, and may include: one or more rows above and one or more columns to the left. The cost is calculated as the sum of the absolute transformed differences (SATDs) between the template's predicted samples and reconstructed samples. One or more intra-prediction modes with the lowest cost are selected as the intra-prediction modes for prediction.

[0081] 4. MPM

[0082] MPM is a technique for explicitly deriving intra-prediction modes. Considering the strong correlation between the current prediction block and its neighboring blocks, it uses the prediction modes of neighboring blocks to construct a list of the most probable intra-prediction mode candidates. If the optimal prediction mode is in the list, only its index needs to be written to the bitstream, saving the bits required to encode the intra-prediction mode.

[0083] The first element in the MPM list is the PLANAR mode. The remaining elements consist of intra-modes from the left (L), top (A), bottom left (BL), top right (AR), and top left (AL) adjacent blocks. For example, intra-modes obtained through DIMD-derived methods, such as non-adjacent spatial blocks, include up to five modes with the lowest cost. The cost is calculated between the template's predicted and reconstructed values. Then, the directional modes from the sorted modes are offset and added to the MPM list. Finally, a default mode is added until an MPM list containing 22 modes is constructed.

[0084] 5. Spatial Geometric Partitioning Mode (SGPM)

[0085] SGPM is an intra-frame mode, similar to the inter-frame coding tool GPM, where both prediction components are generated by an intra-frame prediction process. In this mode, a candidate list is constructed, with each entry containing a partition and two intra-frame prediction modes. 26 partition modes and 9 intra-frame prediction modes are used to form combinations. The candidate list length is set to 16. The list is reordered using a template, where the SAD between the template's predicted and reconstructed values ​​is used for sorting. The template size is fixed at 1.

[0086] 6. Template-based multiple reference line intra prediction (TMRL)

[0087] Template-based multi-reference line intra-prediction (TMRL) mode combines reference lines and prediction modes, and uses template matching to construct a candidate combination list. The indices of the candidate combination list are encoded to indicate which reference line and prediction mode were used when encoding the current block.

[0088] The TMRL candidate structure is as follows. A block has 5 × 10 = 50 extended reference lines and combinations of allowed intra-prediction modes. Since the extended reference lines start from reference line 1, the area covered by reference line 0 is used for template matching. The SAD cost of the template region is calculated between the predicted value (generated from the 50 combinations) and the reconstructed value. The 20 combinations with the lowest SAD cost are selected in ascending order to form the TMRL candidate list.

[0089] The template prediction method, apparatus, and electronic device provided in this application will be described in detail below with reference to the accompanying drawings and through some embodiments and application scenarios.

[0090] As shown in Figure 4, this application embodiment provides a template prediction method, including:

[0091] Step 401: Obtain the filtering method used when predicting the template corresponding to the target image patch. The filtering method is related to the prediction mode of the target image patch.

[0092] Optionally, the filtering method is related to the prediction mode of the target image patch, which can be understood as determining the filtering method based on the prediction mode of the target image patch; optionally, the filtering method may include, but is not limited to, at least one of the following: filtering the reference pixels of the template, using a Discrete Cosine Transform-based interpolation filter (DCTIF), or using a Smooth Interpolation Filter (SIF).

[0093] Step 402: Obtain the predicted value of the template according to the filtering method.

[0094] Optionally, in this embodiment of the application, before predicting the target image block, the filtering method used by the module corresponding to the target image block for prediction is determined based on the prediction mode of the target image block. Different filtering methods can be used based on the purpose of the template, so that the filtering method used for template prediction matches the prediction mode. This avoids the problem of inaccurate template prediction caused by using a single interpolation filter, which cannot guarantee the prediction accuracy of the target image block. This embodiment of the application can improve the prediction accuracy of the template and improve the accuracy of template prediction.

[0095] Optionally, in one implementation, the filtering method used when obtaining the template corresponding to the target image patch for prediction includes at least one of A11-A14:

[0096] A11. For Template-Based Intra-Prediction Mode (TIMD) or Spatial Geometry Partition Mode (SGPM), if the prediction mode is an angle prediction mode, the filtering method is determined based on whether the prediction mode is integer pixel precision.

[0097] It should be noted that if the prediction mode is of integer pixel precision, no interpolation is needed because the reference pixels all fall on the template pixels; if the prediction mode is not of integer pixel precision, interpolation is required to find the pixels at the fractional pixel positions. Since the two use different interpolation methods, determining the filtering method based on whether the prediction mode is of integer pixel precision can improve the accuracy of the filtering method determination.

[0098] It should be noted that in this case, the filtering method is determined based on whether the prediction mode has integer pixel precision. Optionally, the integer pixel precision mentioned in this embodiment can be understood as: all reference pixels of the template fall on the template's pixel points; otherwise, it is non-integer pixel precision. For example, the following prediction mode index values ​​indicate that the prediction mode has integer pixel precision: -14, -12, -10, -6, 2, 34, 66, 72, 76, 78, 80, etc.

[0099] Optionally, the specific implementation may include one of A111-A113:

[0100] A111. If the prediction mode is integer pixel precision, the filtering method is determined to be DCTIF.

[0101] In this case, it refers to using DCTIF to filter the template when the prediction mode is integer pixel precision. Optionally, the taps of the DCTIF used can be predefined. For example, a 4-tap or 6-tap DCTIF can be predefined to filter the template when the prediction mode is integer pixel precision. Optionally, it can also be determined based on at least one of the area of ​​the target image patch, the width and height of the target image patch, and the aspect ratio of the target image patch. For example, when the area of ​​the target image patch is greater than or equal to a set value, a DCTIF with one tap (e.g., 4 taps) is used to filter the template, and when the area of ​​the target image patch is less than the set value, a DCTIF with another tap (e.g., 6 taps) is used to filter the template. Of course, the above is only an example of how to determine the taps of the DCTIF used and does not constitute a limitation on the embodiments of this application.

[0102] A112. If the prediction mode is not of integer pixel precision, the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0103] Optionally, in this embodiment, the difference between the angle prediction mode and the horizontal mode can be understood as the difference between the mode index corresponding to the angle prediction mode and the mode index corresponding to the horizontal mode, and the difference between the angle prediction mode and the vertical mode can be understood as the difference between the mode index corresponding to the angle prediction mode and the mode index corresponding to the vertical mode. Optionally, when the angle prediction mode is closer to the horizontal mode, only the difference between the angle prediction mode and the horizontal mode can be obtained; when the angle prediction mode is closer to the vertical mode, only the difference between the angle prediction mode and the vertical mode can be obtained. When obtaining the difference between the angle prediction mode and the horizontal mode and the difference between the angle prediction mode and the vertical mode respectively, it is necessary to select the minimum value between the absolute values ​​of the difference between the angle prediction mode and the horizontal mode and the absolute values ​​of the difference between the angle prediction mode and the vertical mode to determine the filtering method. Of course, the maximum value between the absolute values ​​of the difference between the angle prediction mode and the horizontal mode and the absolute values ​​of the difference between the angle prediction mode and the vertical mode can also be selected to determine the filtering method.

[0104] Optionally, in one implementation, the specific implementation of the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode, including one of A1121 and A1122:

[0105] A1121. If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, the filtering method is determined to be SIF.

[0106] Optionally, when only the difference between the angle prediction mode and the horizontal mode is obtained, if the absolute value of the difference between the angle prediction mode and the horizontal mode is greater than or equal to a second threshold, the filtering method is determined to be using SIF; when only the difference between the angle prediction mode and the vertical mode is obtained, if the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a second threshold, the filtering method is determined to be using SIF; when both the difference between the angle prediction mode and the horizontal mode and the difference between the angle prediction mode and the vertical mode are obtained, if either the absolute value of the difference between the angle prediction mode and the horizontal mode or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a second threshold, the filtering method is determined to be using SIF. For example, if the minimum value of the absolute value of the difference between the angle prediction mode and the horizontal mode or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a second threshold, the filtering method is determined to be using SIF.

[0107] Optionally, in this case, the taps of the SIF used can be predefined. For example, it can be predefined that when the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a second threshold, a 4-tap or 6-tap SIF is used to filter the template. Optionally, it can also be determined based on at least one of the area of ​​the target image patch, the width and height of the target image patch, and the aspect ratio of the target image patch. For example, when the area of ​​the target image patch is greater than or equal to a set value, a SIF with one type of tap (e.g., 4 taps) is used to filter the template, and when the area of ​​the target image patch is less than the set value, a SIF with another type of tap (e.g., 6 taps) is used to filter the template. Of course, the above is only an example of how to determine the taps of the SIF used and does not constitute a limitation on the embodiments of this application.

[0108] A1122. If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

[0109] Optionally, when only the difference between the angle prediction mode and the horizontal mode is obtained, if the absolute value of the difference between the angle prediction mode and the horizontal mode is less than a second threshold, the filtering method is determined to be DCTIF. When only the difference between the angle prediction mode and the vertical mode is obtained, if the absolute value of the difference between the angle prediction mode and the vertical mode is less than or equal to the second threshold, the filtering method is determined to be DCTIF. When both the difference between the angle prediction mode and the horizontal mode and the difference between the angle prediction mode and the vertical mode are obtained, if either the absolute value of the difference between the angle prediction mode and the horizontal mode or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF. For example, if the minimum value of the absolute value of the difference between the angle prediction mode and the horizontal mode or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

[0110] Optionally, in this case, the taps of the DCTIF used can be predefined. For example, a 4-tap or 6-tap DCTIF can be predefined to filter the template when the prediction mode is integer pixel precision. Alternatively, it can be determined based on at least one of the area of ​​the target image patch, the width and height of the target image patch, and the aspect ratio of the target image patch. For example, when the area of ​​the target image patch is greater than or equal to a set value, a DCTIF with one type of tap (e.g., 4 taps) is used to filter the template; when the area of ​​the target image patch is less than the set value, a DCTIF with another type of tap (e.g., 6 taps) is used to filter the template. Of course, the above is only an example of how to determine the taps of the DCTIF used and does not constitute a limitation on the embodiments of this application.

[0111] A113. If the prediction mode is not integer pixel precision, the filtering method is determined based on the area of ​​the target image block and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0112] Optionally, in one implementation, determining the specific implementation of the filtering method based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode includes one of A1131 and A1132:

[0113] A1131. If the area of ​​the target image block is greater than or equal to a third preset value, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, the filtering method is determined to be SIF.

[0114] It should be noted that there are two judgment conditions in this case. One judgment condition is that the area of ​​the target image patch must be greater than or equal to the third preset value. The other judgment condition is that the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the third threshold. Both conditions must be met simultaneously to determine that the filtering method is SIF. For example, when only the difference between the angle prediction mode and the horizontal mode is obtained, if the absolute value of the difference between the angle prediction mode and the horizontal mode is greater than or equal to a third threshold, and the area of ​​the target image patch is greater than or equal to a third preset value, the filtering method is determined to be SIF. Similarly, when only the difference between the angle prediction mode and the vertical mode is obtained, if the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, and the area of ​​the target image patch is greater than or equal to a third preset value, the filtering method is determined to be SIF. Furthermore, when both the difference between the angle prediction mode and the horizontal mode and the difference between the angle prediction mode and the vertical mode are obtained, if either the absolute value of the difference between the angle prediction mode and the horizontal mode or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, and the area of ​​the target image patch is greater than or equal to a third preset value, the filtering method is determined to be SIF. For instance, if the minimum value of the absolute value of the difference between the angle prediction mode and the horizontal mode or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, and the area of ​​the target image patch is greater than or equal to a third preset value, the filtering method is determined to be SIF.

[0115] Optionally, in this case, the taps of the SIF used can be predefined. For example, it can be predefined that when the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a second threshold, a 4-tap or 6-tap SIF is used to filter the template; alternatively, the taps of the SIF used can also be determined according to the target information.

[0116] The target information includes at least one of the following:

[0117] The area of ​​the target image patch;

[0118] The width and height of the target image block;

[0119] The aspect ratio of the target image block.

[0120] For example, if the width and height of the target image patch are both greater than or equal to a specific value, then a SIF with one tap (e.g., 4 taps) is used to filter the template; otherwise, a SIF with another tap (e.g., 6 taps) is used to filter the template. Of course, the above is only an example of how to determine the taps of the SIF used and does not constitute a limitation on the embodiments of this application.

[0121] A1132. If the area of ​​the target image patch is less than a third preset value, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than a third threshold, the filtering method is determined to be using DCTIF.

[0122] Optionally, this situation refers to determining the filtering method as using DCTIF when the area of ​​the target image patch is not greater than or equal to a third preset value and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold.

[0123] Optionally, in this case, the taps of the DCTIF used can be predefined. For example, a 4-tap or 6-tap DCTIF can be predefined to filter the template when the prediction mode is integer pixel precision. Alternatively, it can be determined based on at least one of the area of ​​the target image patch, the width and height of the target image patch, and the aspect ratio of the target image patch. For example, when the area of ​​the target image patch is greater than or equal to a set value, a DCTIF with one type of tap (e.g., 4 taps) is used to filter the template; when the area of ​​the target image patch is less than the set value, a DCTIF with another type of tap (e.g., 6 taps) is used to filter the template. Of course, the above is only an example of how to determine the taps of the DCTIF used and does not constitute a limitation on the embodiments of this application.

[0124] Optionally, in this case, before determining the filtering method based on whether the prediction mode has integer pixel precision, the method further includes:

[0125] If the first condition is met, the reference pixels of the template are filtered;

[0126] The first condition includes at least one of B11-B13:

[0127] B11. The area of ​​the target image block is greater than or equal to the second preset value;

[0128] B12. The prediction mode is integer pixel precision;

[0129] B13, the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the first threshold.

[0130] In this case, it can be understood that if at least one of B11-B13 above is satisfied, the reference pixels of the template must first be filtered. For example, a [1,2,1] interpolation filter can be used to filter the reference pixels of the template. Then, the template is subjected to corresponding filtering processing based on the filtering method determined according to whether the prediction mode is of integer pixel precision.

[0131] A12. For TIMD or SGPM, if the prediction mode is PLANA mode, and if the area of ​​the target image block is greater than or equal to a first preset value, the filtering method is determined to be filtering the reference pixels of the template.

[0132] Alternatively, in this case, for PLANAR mode, if the area of ​​the target image patch is greater than or equal to the first preset value, then only the reference pixels of the template need to be filtered. For example, the reference pixels of the template can be filtered using a [1,2,1] interpolation filter.

[0133] It should be noted that if the target image block area is large, the [1,2,1] interpolation filter can be used to make the reference pixels smoother, remove noise, and obtain a flatter prediction block. However, if the target image block area is small, filtering will cause the reference pixels to lose texture details, resulting in a decrease in the quality of the prediction block. Therefore, in this case, filtering the reference pixels on the template is only performed when the area of ​​the target image block is greater than or equal to the first preset value, which can ensure that the prediction block obtained by the template is flatter.

[0134] A13. For SGPM, if the prediction mode is not PLANA mode, the filtering method is determined to be DCTIF.

[0135] Alternatively, in this case, for non-PLANAR modes (e.g., modes other than PLANAR), it is directly determined that the template is filtered using DCTIF.

[0136] It should be noted that since SGPM is applicable to situations where there are multiple texture directions in the target image patch, using DCTIF can preserve the texture characteristics of the reference pixel, ensuring that the prediction of the target image patch based on the template is more accurate.

[0137] A14. For template-based multi-reference line intra-frame prediction (TMRL) mode or SGPM, the filtering method is determined to be DCTIF.

[0138] Alternatively, in this case, for TMRL mode or SGPM, the template is directly filtered using DCTIF.

[0139] It should be noted that since SGPM or TMRL modes are suitable for situations where there are multiple texture directions in the target image patch, using DCTIF can preserve the texture characteristics of the reference pixel, ensuring that the prediction of the target image patch based on the template is more accurate.

[0140] Optionally, the first preset value, second preset value, and third preset value mentioned in the embodiments of this application can be preset. The first preset value, second preset value, and third preset value can be the same or different. For example, optionally, the first preset value, second preset value, and third preset value are all set to 32. The first threshold, second threshold, and third threshold mentioned in the embodiments of this application can be preset. The first threshold, second threshold, and third threshold can be the same or different.

[0141] It should be noted that after determining the filtering method for the template according to different modes, the template is predicted based on the corresponding filtering method to obtain the predicted value. Then, the cost is calculated between the predicted value and the reconstructed value of the template. For TIMD, one or more intra-prediction modes with the lowest cost are selected as the intra-prediction modes used for target image patch prediction. For MPM, the intra-prediction modes are sorted according to the calculated cost, and the directional modes in the sorted modes are shifted into the MPM list. Finally, the default mode is added until an MPM list containing 22 modes is constructed. For SGPM, the candidate list is reordered using the calculated cost.

[0142] The following example illustrates the specific application of this application embodiment, with all preset values ​​set to 32.

[0143] Application Scenario 1

[0144] The process includes the following:

[0145] 1. For TIMD or SGPM

[0146] 1a. If the prediction model is an angle prediction model, the following process applies:

[0147] If the first condition is met (i.e., the first condition is true), the reference pixels of the template are first filtered. For example, the reference pixels of the template can be filtered using the [1,2,1] interpolation filter.

[0148] The first condition includes: the area of ​​the target image patch is greater than or equal to 32; and the prediction mode is integer pixel precision.

[0149] After determining the first condition, if the prediction mode is integer pixel precision, determine to use 4-tap or 6-tap DCTIF to filter the template; if the prediction mode is not integer pixel precision, if the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, determine to use 4-tap or 6-tap SIF to filter the template; if the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, determine to use 4-tap or 6-tap DCTIF to filter the template.

[0150] 1b. If the prediction model is the PLANA model, the process is as follows:

[0151] If the area of ​​the target image block is greater than or equal to 32, it is determined that only the reference pixels of the template will be filtered. For example, the reference pixels of the template can be filtered using a [1,2,1] interpolation filter.

[0152] 2. For TMRL mode

[0153] In this mode, it is determined whether to use 4-tap or 6-tap DCTIF to filter the template.

[0154] Application Scenario 2

[0155] The process includes the following:

[0156] 1. Regarding TIMD

[0157] 1a. If the prediction model is an angle prediction model, the following process applies:

[0158] If the first condition is met (i.e., the first condition is true), the reference pixels of the template are first filtered. For example, the reference pixels of the template can be filtered using the [1,2,1] interpolation filter.

[0159] The first condition includes: the area of ​​the target image patch is greater than or equal to 32; and the prediction mode is integer pixel precision.

[0160] After determining the first condition, if the prediction mode is integer pixel precision, determine to use 4-tap or 6-tap DCTIF to filter the template; if the prediction mode is not integer pixel precision, if the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, determine to use 4-tap or 6-tap SIF to filter the template; if the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, determine to use 4-tap or 6-tap DCTIF to filter the template.

[0161] 1b. If the prediction model is the PLANA model, the process is as follows:

[0162] If the area of ​​the target image block is greater than or equal to 32, it is determined that only the reference pixels of the template will be filtered. For example, the reference pixels of the template can be filtered using a [1,2,1] interpolation filter.

[0163] 2. For TMRL or SGPM modes

[0164] In this mode, it is determined whether to use 4-tap or 6-tap DCTIF to filter the template.

[0165] Application Scenario 3

[0166] The process includes the following:

[0167] 1. Regarding TIMD

[0168] 1a. If the prediction model is an angle prediction model, the following process applies:

[0169] If the first condition is met (i.e., the first condition is true), the reference pixels of the template are first filtered. For example, the reference pixels of the template can be filtered using the [1,2,1] interpolation filter.

[0170] The first condition includes: the area of ​​the target image patch is greater than or equal to 32; and the prediction mode is integer pixel precision.

[0171] After determining the first condition, if the prediction mode is integer pixel precision, determine to use 4-tap or 6-tap DCTIF to filter the template; if the prediction mode is not integer pixel precision, if the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, determine to use 4-tap or 6-tap SIF to filter the template; if the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, determine to use 4-tap or 6-tap DCTIF to filter the template.

[0172] 1b. If the prediction model is the PLANA model, the process is as follows:

[0173] If the area of ​​the target image block is greater than or equal to a first preset value, it is determined that only the reference pixels of the template will be filtered. For example, the reference pixels of the template can be filtered using a [1,2,1] interpolation filter.

[0174] 2. For SGPM mode

[0175] 2a. If the prediction model is the PLANA model, the process is as follows:

[0176] If the area of ​​the target image block is greater than or equal to a first preset value, it is determined that only the reference pixels of the template will be filtered. For example, the reference pixels of the template can be filtered using a [1,2,1] interpolation filter.

[0177] 2b. If the prediction model is a non-PLANAR model, the following process applies:

[0178] In this mode, it is determined whether to use 4-tap or 6-tap DCTIF to filter the template.

[0179] 3. Regarding TMRL

[0180] In this mode, it is determined whether to use 4-tap or 6-tap DCTIF to filter the template.

[0181] Application Situation 4

[0182] The process includes the following:

[0183] 1. For TIMD or SGPM

[0184] 1a. If the prediction model is an angle prediction model, the following process applies:

[0185] If the first condition is met (i.e., the first condition is true), the reference pixels of the template are first filtered. For example, the reference pixels of the template can be filtered using the [1,2,1] interpolation filter.

[0186] The first condition includes: the area of ​​the target image patch is greater than or equal to 32; the prediction mode is integer pixel precision; and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a first threshold.

[0187] After determining the first condition, if the prediction mode is integer pixel precision, it is determined that a 4-tap or 6-tap DCTIF will be used to filter the template; if the prediction mode is not integer pixel precision, if the area of ​​the target image block is greater than or equal to 32, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the third threshold, it is determined that a SIF will be used to filter the template (the taps are determined by the width and height of the target image block, aspect ratio or area (e.g., if the width and height are both greater than or equal to 32, a 6-tap SIF is used; otherwise, a 4-tap SIF is used)); if the area of ​​the target image block is less than 32, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the third threshold, it is determined that a 6-tap DCTIF will be used to filter the template.

[0188] 1b. If the prediction model is the PLANA model, the process is as follows:

[0189] If the area of ​​the target image block is greater than or equal to 32, it is determined that only the reference pixels of the template will be filtered. For example, the reference pixels of the template can be filtered using a [1,2,1] interpolation filter.

[0190] 2. For TMRL mode

[0191] In this mode, a 6-tap DCTIF is used to filter the template.

[0192] In summary, the embodiments of this application first determine the filtering method used when predicting the template corresponding to the target image block based on the prediction mode of the target image block. Different filtering methods can be used on the template under different prediction modes, so that the filtering method used for template prediction matches the prediction mode. This can improve the prediction accuracy of the template and obtain more accurate prediction information for the target image block, thereby improving the prediction accuracy of the target image block.

[0193] The template prediction method provided in this application can be executed by a template prediction device. This application uses the example of a template prediction device executing the template prediction method to illustrate the template prediction device provided in this application.

[0194] As shown in Figure 5, the template prediction device 500 of this application embodiment includes:

[0195] The first acquisition module 501 is used to acquire the filtering method used when predicting the template corresponding to the target image block, and the filtering method is related to the prediction mode of the target image block;

[0196] The second acquisition module 502 is used to acquire the predicted value of the template according to the filtering method.

[0197] Optionally, the first acquisition module 501 is configured to implement at least one of the following:

[0198] For template-derived intra-frame prediction mode (TIMD) or spatial geometry partitioning mode (SGPM), if the prediction mode is an angle prediction mode, the filtering method is determined based on whether the prediction mode has integer pixel precision.

[0199] For TIMD or SGPM, if the prediction mode is PLANAR mode, and if the area of ​​the target image patch is greater than or equal to a first preset value, the filtering method is determined to be filtering the reference pixels of the template.

[0200] For SGPM, if the prediction mode is not PLANA mode, the filtering method is determined to be DCTIF.

[0201] For template-based multi-reference line intra-frame prediction (TMRL) mode or SGPM, the filtering method is determined to be DCTIF.

[0202] Optionally, before the first acquisition module 501 determines the filtering method based on whether the prediction mode is of integer pixel precision, the device further includes:

[0203] The processing module is used to filter the reference pixels of the template when a first condition is met;

[0204] The first condition includes at least one of the following:

[0205] The area of ​​the target image block is greater than or equal to the second preset value;

[0206] The prediction mode is accurate to integer pixels.

[0207] The absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the first threshold.

[0208] Optionally, the first acquisition module 501 is configured to implement one of the following:

[0209] If the prediction mode is integer pixel precision, the filtering method is determined to be an interpolation filter based on discrete cosine transform (DCTIF).

[0210] If the prediction mode is not of integer pixel precision, the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0211] If the prediction mode is not integer pixel precision, the filtering method is determined based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0212] Optionally, the first acquisition module 501 is configured to implement one of the following:

[0213] If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, the filtering method is determined to be using a smooth interpolation filter (SIF).

[0214] If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

[0215] Optionally, the first acquisition module 501 is configured to implement one of the following:

[0216] If the area of ​​the target image patch is greater than or equal to a third preset value, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, the filtering method is determined to be SIF.

[0217] If the area of ​​the target image patch is less than a third preset value, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than a third threshold, the filtering method is determined to be DCTIF.

[0218] Optionally, determining that the filtering method is an implementation using SIF includes:

[0219] Based on the target information, determine the taps of the SIF to be used;

[0220] The target information includes at least one of the following:

[0221] The area of ​​the target image patch;

[0222] The width and height of the target image block;

[0223] The aspect ratio of the target image block.

[0224] It should be noted that this device embodiment corresponds to the above method, and all implementation methods in the above method embodiment are applicable to this device embodiment and can achieve the same technical effect.

[0225] The template prediction device in this application embodiment can be an electronic device, such as an electronic device with an operating system, or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices besides a terminal. For example, a terminal can include, but is not limited to, mobile phones, tablet computers, laptop computers, notebook computers, personal digital assistants (PDAs), handheld computers, netbooks, ultra-mobile personal computers (UMPCs), mobile internet devices (MIDs), augmented reality (AR) devices, virtual reality (VR) devices, robots, wearable devices, flight vehicles, vehicle user equipment (VUEs), shipboard equipment, pedestrian user equipment (PUEs), smart home devices (home appliances with wireless communication capabilities, such as refrigerators, televisions, washing machines, or furniture), game consoles, personal computers (PCs), ATMs, or self-service machines, etc. Wearable devices include: smartwatches, smart bracelets, smart earphones, smart glasses, smart jewelry (smart bracelets, smart chains, smart rings, smart necklaces, smart anklets, smart anklets, etc.), smart wristbands, smart clothing, etc. Among these, in-vehicle devices can also be referred to as in-vehicle terminals, in-vehicle controllers, in-vehicle modules, in-vehicle components, in-vehicle chips, or in-vehicle units, etc.; other devices can be servers, network attached storage (NAS), etc., and this application does not specifically limit them.

[0226] The template prediction device provided in this application embodiment can implement the various processes implemented in the method embodiment of FIG4 and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0227] This application embodiment also provides an electronic device, including a processor and a communication interface, wherein the processor is used to obtain the filtering method used when predicting a template corresponding to a target image patch, and the filtering method is related to the prediction mode of the target image patch;

[0228] Based on the filtering method, the predicted value of the template is obtained.

[0229] Optionally, the processor is configured to implement at least one of the following:

[0230] For template-derived intra-frame prediction mode (TIMD) or spatial geometry partitioning mode (SGPM), if the prediction mode is an angle prediction mode, the filtering method is determined based on whether the prediction mode has integer pixel precision.

[0231] For TIMD or SGPM, if the prediction mode is PLANAR mode, and if the area of ​​the target image patch is greater than or equal to a first preset value, the filtering method is determined to be filtering the reference pixels of the template.

[0232] For SGPM, if the prediction mode is not PLANA mode, the filtering method is determined to be DCTIF.

[0233] For template-based multi-reference line intra-frame prediction (TMRL) mode or SGPM, the filtering method is determined to be DCTIF.

[0234] Optionally, the processor is further configured to implement:

[0235] If the first condition is met, the reference pixels of the template are filtered;

[0236] The first condition includes at least one of the following:

[0237] The area of ​​the target image block is greater than or equal to the second preset value;

[0238] The prediction mode is accurate to integer pixels.

[0239] The absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the first threshold.

[0240] Optionally, the processor is configured to implement one of the following:

[0241] If the prediction mode is integer pixel precision, the filtering method is determined to be an interpolation filter based on discrete cosine transform (DCTIF).

[0242] If the prediction mode is not of integer pixel precision, the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0243] If the prediction mode is not integer pixel precision, the filtering method is determined based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0244] Optionally, the processor is configured to implement one of the following:

[0245] If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, the filtering method is determined to be using a smooth interpolation filter (SIF).

[0246] If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

[0247] Optionally, the processor is configured to implement one of the following:

[0248] If the area of ​​the target image patch is greater than or equal to a third preset value, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, the filtering method is determined to be SIF.

[0249] If the area of ​​the target image patch is less than a third preset value, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than a third threshold, the filtering method is determined to be DCTIF.

[0250] Optionally, the processor is configured to implement:

[0251] Based on the target information, determine the taps of the SIF to be used;

[0252] The target information includes at least one of the following:

[0253] The area of ​​the target image patch;

[0254] The width and height of the target image block;

[0255] The aspect ratio of the target image block.

[0256] This electronic device embodiment corresponds to the above method embodiment. All implementation processes and methods of the above method embodiments can be applied to this electronic device embodiment and achieve the same technical effect. Specifically, Figure 6 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of this application.

[0257] The electronic device 600 includes, but is not limited to, at least some of the following components: radio frequency unit 601, network module 602, audio output unit 603, input unit 604, sensor 605, display unit 606, user input unit 607, interface unit 608, memory 609, and processor 610.

[0258] Those skilled in the art will understand that the electronic device 600 may also include a power supply (such as a battery) for powering various components. The power supply can be logically connected to the processor 610 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The electronic device structure shown in Figure 6 does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0259] It should be understood that, in this embodiment, the input unit 604 may include a graphics processing unit (GPU) 6041 and a microphone 6042. The GPU 6041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 606 may include a display panel 6061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 607 includes at least one of a touch panel 6071 and other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0260] In this embodiment, after receiving downlink data from the access network device, the radio frequency unit 601 can transmit it to the processor 610 for processing; in addition, the radio frequency unit 601 can send uplink data to the network-side device. Typically, the radio frequency unit 601 includes, but is not limited to, antennas, amplifiers, transceivers, couplers, low-noise amplifiers, duplexers, etc.

[0261] The memory 609 can be used to store software programs or instructions, as well as various data. The memory 609 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 609 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 609 in this embodiment includes, but is not limited to, these and any other suitable types of memory.

[0262] Processor 610 may include one or more processing units; optionally, processor 610 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 610.

[0263] The processor 610 is used for:

[0264] The filtering method used when obtaining the template corresponding to the target image patch for prediction is related to the prediction mode of the target image patch;

[0265] Based on the filtering method, the predicted value of the template is obtained.

[0266] Optionally, the processor 610 is configured to implement at least one of the following:

[0267] For template-derived intra-frame prediction mode (TIMD) or spatial geometry partitioning mode (SGPM), if the prediction mode is an angle prediction mode, the filtering method is determined based on whether the prediction mode has integer pixel precision.

[0268] For TIMD or SGPM, if the prediction mode is PLANAR mode, and if the area of ​​the target image patch is greater than or equal to a first preset value, the filtering method is determined to be filtering the reference pixels of the template.

[0269] For SGPM, if the prediction mode is not PLANA mode, the filtering method is determined to be DCTIF.

[0270] For template-based multi-reference line intra-frame prediction (TMRL) mode or SGPM, the filtering method is determined to be DCTIF.

[0271] Optionally, the processor 610 is further configured to implement:

[0272] If the first condition is met, the reference pixels of the template are filtered;

[0273] The first condition includes at least one of the following:

[0274] The area of ​​the target image block is greater than or equal to the second preset value;

[0275] The prediction mode is accurate to integer pixels.

[0276] The absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the first threshold.

[0277] Optionally, the processor 610 is configured to implement one of the following:

[0278] If the prediction mode is integer pixel precision, the filtering method is determined to be an interpolation filter based on discrete cosine transform (DCTIF).

[0279] If the prediction mode is not of integer pixel precision, the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0280] If the prediction mode is not integer pixel precision, the filtering method is determined based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

[0281] Optionally, the processor 610 is configured to implement one of the following:

[0282] If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, the filtering method is determined to be using a smooth interpolation filter (SIF).

[0283] If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

[0284] Optionally, the processor 610 is configured to implement one of the following:

[0285] If the area of ​​the target image patch is greater than or equal to a third preset value, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, the filtering method is determined to be SIF.

[0286] If the area of ​​the target image patch is less than a third preset value, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than a third threshold, the filtering method is determined to be DCTIF.

[0287] Optionally, the processor 610 is configured to implement:

[0288] Based on the target information, determine the taps of the SIF to be used;

[0289] The target information includes at least one of the following:

[0290] The area of ​​the target image patch;

[0291] The width and height of the target image block;

[0292] The aspect ratio of the target image block.

[0293] Preferably, this application embodiment also provides an electronic device, including a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the various processes of the template prediction method embodiment described above and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0294] This application also provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements the various processes of the template prediction method embodiments described above and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0295] The computer-readable storage medium mentioned above includes, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0296] Optionally, as shown in FIG7, this application embodiment also provides a communication device 700, including a processor 701 and a memory 702. The memory 702 stores a program or instructions that can be executed on the processor 701. When the program or instructions are executed by the processor 701, they implement the various steps of the above template prediction method embodiment and can achieve the same technical effect.

[0297] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above template prediction method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0298] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0299] This application also provides a computer program / program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the template prediction method embodiments described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0300] This application also provides an encoding / decoding system, including a template prediction device, which can be used to perform the steps of the template prediction method described above.

[0301] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0302] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0303] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A template prediction method, comprising: The filtering method used when obtaining the template corresponding to the target image patch for prediction is related to the prediction mode of the target image patch; Based on the filtering method, the predicted value of the template is obtained.

2. The method according to claim 1, wherein, The filtering method used when obtaining the template corresponding to the target image patch for prediction includes at least one of the following: For template-derived intra-frame prediction mode (TIMD) or spatial geometry partitioning mode (SGPM), if the prediction mode is an angle prediction mode, the filtering method is determined based on whether the prediction mode has integer pixel precision. For TIMD or SGPM, if the prediction mode is PLANAR mode, and if the area of ​​the target image patch is greater than or equal to a first preset value, the filtering method is determined to be filtering the reference pixels of the template. For SGPM, if the prediction mode is not the PLANA mode, the filtering method is determined to be the use of the Discrete Cosine Transform-based interpolation filter DCTIF. For template-based multi-reference line intra-frame prediction (TMRL) mode or SGPM, the filtering method is determined to be DCTIF.

3. The method according to claim 2, wherein, Before determining the filtering method based on whether the prediction mode has integer pixel precision, the method further includes: If the first condition is met, the reference pixels of the template are filtered; The first condition includes at least one of the following: The area of ​​the target image block is greater than or equal to the second preset value; The prediction mode is accurate to integer pixels. The absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the first threshold.

4. The method according to claim 2 or 3, wherein, The step of determining the filtering method based on whether the prediction mode has integer pixel precision includes the following: If the prediction mode is integer pixel precision, the filtering method is determined to be DCTIF. If the prediction mode is not of integer pixel precision, the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode. If the prediction mode is not integer pixel precision, the filtering method is determined based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

5. The method according to claim 4, wherein, Determining the filtering method based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode includes one of the following: If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, the filtering method is determined to be using a smooth interpolation filter (SIF). If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

6. The method according to claim 4, wherein, The step of determining the filtering method based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode includes one of the following: If the area of ​​the target image patch is greater than or equal to a third preset value, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, the filtering method is determined to be SIF. If the area of ​​the target image patch is less than a third preset value, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than a third threshold, the filtering method is determined to be DCTIF.

7. The method according to claim 6, wherein, Determining that the filtering method is SIF includes: Based on the target information, determine the taps of the SIF to be used; The target information includes at least one of the following: The area of ​​the target image patch; The width and height of the target image block; The aspect ratio of the target image block.

8. A template prediction device, comprising: The first acquisition module is used to acquire the filtering method used when predicting the template corresponding to the target image block, and the filtering method is related to the prediction mode of the target image block; The second acquisition module is used to acquire the predicted value of the template according to the filtering method.

9. The apparatus according to claim 8, wherein, The first acquisition module is configured to implement at least one of the following: For template-derived intra-frame prediction mode (TIMD) or spatial geometry partitioning mode (SGPM), if the prediction mode is an angle prediction mode, the filtering method is determined based on whether the prediction mode has integer pixel precision. For TIMD or SGPM, if the prediction mode is PLANAR mode, and if the area of ​​the target image patch is greater than or equal to a first preset value, the filtering method is determined to be filtering the reference pixels of the template. For SGPM, if the prediction mode is not the PLANA mode, the filtering method is determined to be the use of the Discrete Cosine Transform-based interpolation filter DCTIF. For template-based multi-reference line intra-frame prediction (TMRL) mode or SGPM, the filtering method is determined to be DCTIF.

10. The apparatus according to claim 9, wherein, Before the first acquisition module determines the filtering method based on whether the prediction mode has integer pixel precision, the device further includes: If the first condition is met, the reference pixels of the template are filtered; The first condition includes at least one of the following: The area of ​​the target image block is greater than or equal to the second preset value; The prediction mode is accurate to integer pixels. The absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the first threshold.

11. The apparatus according to claim 9 or 10, wherein, The first acquisition module is used to implement one of the following: If the prediction mode is integer pixel precision, the filtering method is determined to be DCTIF. If the prediction mode is not of integer pixel precision, the filtering method is determined based on the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode. If the prediction mode is not integer pixel precision, the filtering method is determined based on the area of ​​the target image patch and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode.

12. The apparatus according to claim 11, wherein, The first acquisition module is used to implement one of the following: If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to the second threshold, the filtering method is determined to be using a smooth interpolation filter (SIF). If the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than the second threshold, the filtering method is determined to be DCTIF.

13. The apparatus according to claim 11, wherein, The first acquisition module is used to implement one of the following: If the area of ​​the target image patch is greater than or equal to a third preset value, and the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is greater than or equal to a third threshold, the filtering method is determined to be SIF. If the area of ​​the target image patch is less than a third preset value, and / or the absolute value of the difference between the angle prediction mode and the horizontal mode and / or the absolute value of the difference between the angle prediction mode and the vertical mode is less than a third threshold, the filtering method is determined to be DCTIF.

14. The apparatus according to claim 13, wherein, The determination that the filtering method is an implementation using SIF includes: Based on the target information, determine the taps of the SIF to be used; The target information includes at least one of the following: The area of ​​the target image patch; The width and height of the target image block; The aspect ratio of the target image block.

15. An electronic device comprising a processor and a memory, the memory storing a program or instructions executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the template prediction method as claimed in any one of claims 1 to 7.

16. A readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the template prediction method as claimed in any one of claims 1 to 7.

17. A chip comprising a processor and a communication interface coupled to the processor, the processor being configured to run a program or instructions to implement the steps of the template prediction method as claimed in any one of claims 1 to 7.