Encoding method, decoding method, encoder, decoder, storage medium, and bitstream

By determining the block vector and reference region of the current block, the problem of insufficient intra-frame prediction accuracy is solved, thus improving the performance of video encoding and decoding.

WO2026143740A1PCT designated stage Publication Date: 2026-07-09GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
Filing Date
2025-01-06
Publication Date
2026-07-09

Smart Images

  • Figure CN2025070886_09072026_PF_FP_ABST
    Figure CN2025070886_09072026_PF_FP_ABST
Patent Text Reader

Abstract

Provided are an encoding method, a decoding method, an encoder, a decoder, a storage medium, and a bitstream. The decoding method comprises: determining a first block vector of a current block; determining a first reference region of the current block on the basis of the first block vector; determining a predicted value of the current block on the basis of the first reference region; and determining a reconstructed value of the current block on the basis of the predicted value of the current block.
Need to check novelty before this filing date? Find Prior Art

Description

Encoding / decoding methods, codecs, storage media, and bitstreams Technical Field

[0001] This application relates to the field of video encoding and decoding, and more particularly to an encoding and decoding method, an encoder and decoder, a storage medium, and a bitstream. Background Technology

[0002] Intra-frame prediction technology is widely used in video encoding and decoding. Improving the accuracy of intra-frame prediction, thereby enhancing encoding and decoding performance, is a problem that needs to be solved. Summary of the Invention

[0003] This application provides an encoding / decoding method, an encoding / decoding method, a storage medium, and a bitstream. The various aspects involved in this application are described below.

[0004] In a first aspect, a decoding method is provided, applied to a decoder, comprising: determining a first block vector of a current block; determining a first reference region of the current block based on the first block vector; determining a predicted value of the current block based on the first reference region; and determining a reconstructed value of the current block based on the predicted value of the current block.

[0005] Secondly, an encoding method is provided, applied to an encoder, comprising: determining a first block vector of a current block; determining a first reference region of the current block based on the first block vector; determining a predicted value of the current block based on the first reference region; and determining a residual value of the current block based on the predicted value of the current block.

[0006] Thirdly, a decoder is provided, comprising: a first determining unit configured to determine a first block vector of a current block; a second determining unit configured to determine a first reference region of the current block based on the first block vector; a third determining unit configured to determine a predicted value of the current block based on the first reference region; and a fourth determining unit configured to determine a reconstructed value of the current block based on the predicted value of the current block.

[0007] Fourthly, a decoder is provided, the decoder comprising: a memory for storing a computer program; and a processor for executing the method as described in the first aspect when running the computer program.

[0008] Fifthly, an encoder is provided, comprising: a first determining unit configured to determine a first block vector of a current block; a second determining unit configured to determine a first reference region of the current block based on the first block vector; a third determining unit configured to determine a predicted value of the current block based on the first reference region; and a fourth determining unit configured to determine a residual value of the current block based on the predicted value of the current block.

[0009] In a sixth aspect, an encoder is provided, the encoder comprising: a memory for storing a computer program; and a processor for executing the method as described in the second aspect when running the computer program.

[0010] In a seventh aspect, a non-volatile computer-readable storage medium is provided for storing a bit stream, the bit stream being generated by an encoding method using an encoder, or the bit stream being decoded by a decoding method using a decoder, wherein the decoding method is as described in the first aspect and the encoding method is as described in the second aspect.

[0011] Eighthly, a bitstream is provided, the bitstream comprising a bitstream generated by the method described in the second aspect.

[0012] A ninth aspect provides a computer-readable storage medium storing a computer program that, when executed, implements the method described in the first aspect or the method described in the second aspect.

[0013] In a tenth aspect, a computer program product is provided, comprising a computer program that, when executed, implements the method as described in the first or second aspect.

[0014] The first reference region determined based on the block vector has a strong correlation with the current block. The embodiments of this application determine the predicted value of the current block based on the first reference region, which helps improve the accuracy of intra-frame prediction, thereby improving encoding and decoding performance. Attached Figure Description

[0015] Figure 1 is a structural example diagram of a video encoder applicable to embodiments of this application.

[0016] Figure 2 is a structural example diagram of a video decoder applicable to embodiments of this application.

[0017] Figure 3 is a flowchart illustrating the intra-frame prediction method based on block vectors.

[0018] Figure 4 is a flowchart illustrating the construction method of the block vector list.

[0019] Figure 5 is an example diagram of a template for an coded block.

[0020] Figure 6 is another example diagram of a template for an coded block.

[0021] Figure 7 is a schematic diagram of the search area of ​​the reference template.

[0022] Figure 8 shows an example of spatially adjacent or non-adjacent positions of the current block.

[0023] Figure 9 is a flowchart illustrating the process of creating a detailed search list for block vectors.

[0024] Figure 10 shows an example of the IBC search range.

[0025] Figure 11 is another example of the IBC search orientation.

[0026] Figure 12 is an example of a fine-search method for block vectors.

[0027] Figure 13 shows another example of a fine-grained search method for block vectors.

[0028] Figure 14 is another example of a fine-grained search method for block vectors.

[0029] Figure 15 is a flowchart illustrating the method for determining block vectors.

[0030] Figure 16 is a schematic diagram of how the block vector list is constructed.

[0031] Figure 17 is an example diagram of the spatial adjacent positions of the current block.

[0032] Figure 18 is an example diagram of how block vectors are determined.

[0033] Figure 19 is a schematic diagram of the positional relationship between the current block and the reference block.

[0034] Figure 20 shows an example of the aggregation method for block vector prediction.

[0035] Figure 21 is an example diagram of the search method for block vectors.

[0036] Figure 22 is another schematic diagram of the positional relationship between the current block and the reference block.

[0037] Figure 23 shows an example of the filtering methods of the filter.

[0038] Figure 24 is a schematic flowchart of prediction based on block vectors.

[0039] Figure 25 is an example diagram of the search method for block vectors shown in Figure 21.

[0040] Figure 26 is a schematic diagram of block vector prediction and block vector difference.

[0041] Figure 27 is a flowchart illustrating the decoding method provided in an embodiment of this application.

[0042] Figure 28 is a schematic diagram of the first reference area provided in an embodiment of this application.

[0043] Figure 29 is a schematic diagram of the types of filters.

[0044] Figure 30 is a flowchart illustrating the encoding method provided in an embodiment of this application.

[0045] Figure 31 is an example diagram of the template type of the current block.

[0046] Figure 32 is a schematic diagram of the template area of ​​TIMD.

[0047] Figure 33 is a schematic diagram of the structure of a decoder provided in one embodiment of this application.

[0048] Figure 34 is a schematic diagram of the structure of a decoder provided in another embodiment of this application.

[0049] Figure 35 is a schematic diagram of the encoder provided in one embodiment of this application.

[0050] Figure 36 is a schematic diagram of the encoder provided in another embodiment of this application. Detailed Implementation

[0051] Video encoding and decoding framework

[0052] Figure 1 is a schematic block diagram of a video encoder involved in an embodiment of this application.

[0053] It should be understood that the video encoder 100 can be used for lossy compression of images or lossless compression of images. The lossless compression can be visually lossless compression or mathematically lossless compression.

[0054] This video encoder 100 can be applied to image data in luminance / chrominance (YCbCr, YUV) format. For example, the YUV ratio can be 4:2:0, 4:2:2, or 4:4:4, where Y represents luminance (Luma), Cb (U) represents blue chrominance, Cr (V) represents red chrominance, and U and V represent chrominance (Chroma) used to describe color and saturation. For example, in color format, 4:2:0 means that there are 4 luminance components and 2 chrominance components (YYYYCbCr) for every 4 samples; 4:2:2 means that there are 4 luminance components and 4 chrominance components (YYYYCbCrCbCr) for every 4 samples; and 4:4:4 means that all samples are displayed (YYYYCbCrCbCrCbCrCbCr).

[0055] For example, the video encoder 100 reads video data and, for each image (or sub-image or frame) in the video data, divides an image into several coding tree units (CTUs). In some examples, CTUs may be called "tree blocks," "largest coding unit" (LCU), or "coding tree block" (CTB). Each CTU can be associated with a sample block of equal size within the image. Each sample can correspond to one luminance (or luma) sample and two chrominance (or chroma) samples. Therefore, each CTU can be associated with one luminance sample block and two chrominance sample blocks. A CTU can be a square block (or, the shape of the CTU is square). The size of a CTU is, for example, 256×256, 128×128, 64×64, 32×32, etc. A CTU can be further divided into several coding units (CUs) for encoding. CUs can be rectangular blocks or square blocks. The CU can be further divided into prediction units (PUs) and transform units (TUs), thus separating encoding, prediction, and transformation for more flexible processing. In one example, the CTU is divided into CUs using a quadtree structure, and the CUs are further divided into TUs and PUs using a quadtree structure. In some embodiments, the division of the prediction unit and the transform unit can be different.

[0056] It's important to note that video codec standards (such as VVC and HEVC) allow encoders to determine the size and partitioning of CUs and / or PUs based on the video content. For example, regions with simple textures or motion may tend to use larger blocks, while regions with complex textures or motion may tend to use smaller blocks. The deeper the block partitioning, the more complex and closer the blocks can be to the actual texture or motion, but correspondingly, the overhead for representing these partitions is also greater.

[0057] The video encoder and decoder support various PU sizes. Assuming a specific CU size of 2N×2N, the video encoder and decoder can support PU sizes of 2N×2N or N×N for intra-frame prediction, and also support symmetric PUs of 2N×2N, 2N×N, N×2N, N×N, or similar sizes for inter-frame prediction. The video encoder and decoder can also support asymmetric PUs of 2N×nU, 2N×nD, nL×2N, and nR×2N for inter-frame prediction.

[0058] In some embodiments, as shown in FIG1, the video encoder 100 may include: a prediction unit 110, a residual unit 120, a transform / quantization unit 130, an inverse transform / quantization unit 140, a reconstruction unit 150, a loop filtering unit 160, a decoded image buffer 170, and an entropy coding unit 180. It should be noted that the video encoder 100 may include more, fewer, or different functional components.

[0059] In some embodiments, the prediction unit 110 includes an inter-frame prediction unit 111 and an intra-frame prediction unit 112. Because there is a strong correlation between adjacent samples in an image of a video, intra-frame prediction is used in video encoding and decoding techniques to eliminate spatial redundancy between adjacent samples. Because there is a strong similarity between adjacent images in a video, inter-frame prediction is used in video encoding and decoding techniques to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency.

[0060] Inter-frame prediction unit 111 can be used for inter-frame prediction, which can include motion estimation and motion compensation. Referring to image information from different images, inter-frame prediction uses motion information to find reference blocks in the reference images and generates prediction blocks based on these reference blocks to eliminate temporal redundancy. The motion information includes a list of reference images containing the reference image, the reference image index, and motion vectors. Motion vectors can be whole-sample or multi-sample. If the motion vectors are multi-sample, interpolation filtering needs to be used in the reference images to create the required multi-sample blocks. Here, the whole-sample or multi-sample block in the reference image found based on the motion vector is called a reference block. Some techniques directly use the reference block as the prediction block, while others process the reference block further to generate the prediction block. Processing the reference block further to generate the prediction block can also be understood as using the reference block as the prediction block and then processing it to generate a new prediction block.

[0061] Intra-frame prediction unit 112 refers only to information from the same image to predict sample information within the current code image block, thereby eliminating spatial redundancy.

[0062] Intra-frame prediction has multiple prediction modes. Taking the international digital video coding standards H-series as an example, the H.264 / AVC standard has 8 angular prediction modes and 1 non-angular prediction mode, while H.265 / HEVC extends this to 33 angular prediction modes and 2 non-angular prediction modes. HEVC uses Planar, DC, and 33 angular modes for a total of 35 intra-frame prediction modes. VVC uses Planar, DC, and 65 angular modes for a total of 67 intra-frame prediction modes.

[0063] It should be noted that with the increase in angle modes, intra-frame prediction will be more accurate and better meet the needs of the development of high-definition and ultra-high-definition digital video.

[0064] The residual unit 120 can generate a residual block of the CU based on the sample block of the CU and the prediction block of the PU of the CU. For example, the residual unit 120 can generate a residual block of the CU such that each sample in the residual block has a value equal to the difference between the sample in the sample block of the CU and the corresponding sample in the prediction block of the PU of the CU.

[0065] Transform / quantization unit 130 can quantize transform coefficients. Transform / quantization unit 130 can quantize transform coefficients associated with the TU of the CU based on the quantization parameter (QP) value associated with the CU. Video encoder 100 can adjust the degree of quantization applied to the transform coefficients associated with the CU by adjusting the QP value associated with the CU.

[0066] The inverse transform / quantization unit 140 can apply inverse quantization and inverse transform to the quantized transform coefficients to reconstruct the residual block from the quantized transform coefficients.

[0067] The reconstruction unit 150 can add samples of the reconstructed residual block to corresponding samples of one or more prediction blocks generated by the prediction unit 110 to produce a reconstructed image block associated with the TU. By reconstructing the sample blocks of each TU of the CU in this way, the video encoder 100 can reconstruct the sample blocks of the CU.

[0068] The loop filtering unit 160 is used to process the samples after inverse transform and inverse quantization to compensate for distorted information and provide a better reference for subsequent encoded samples. For example, it can perform deblocking filtering to reduce the block effect of sample blocks associated with the CU.

[0069] In some embodiments, the loop filtering unit 160 includes a deblocking filtering unit and a sample adaptive compensation / adaptive loop filtering (SAO / ALF) unit, wherein the deblocking filtering unit is used to remove block effects and the SAO / ALF unit is used to remove ringing effects.

[0070] The decoded image buffer 170 can store reconstructed sample blocks. The inter-frame prediction unit 111 can use a reference image containing the reconstructed sample blocks to perform inter-frame prediction on PUs in other images. In addition, the intra-frame prediction unit 112 can use the reconstructed sample blocks in the decoded image buffer 170 to perform intra-frame prediction on other PUs in the same image as the CU.

[0071] The entropy coding unit 180 can receive quantized transform coefficients from the transform / quantization unit 130. The entropy coding unit 180 can perform one or more entropy coding operations on the quantized transform coefficients to produce entropy-coded data.

[0072] Figure 2 is a schematic block diagram of the video decoder involved in the embodiments of this application.

[0073] As shown in Figure 2, the video decoder 200 includes: an entropy decoding unit 210, a prediction unit 220, an inverse quantization / transformation unit 230, a reconstruction unit 240, a loop filtering unit 250, and a decoded image buffer 260. It should be noted that the video decoder 200 may contain more, fewer, or different functional components.

[0074] Video decoder 200 can receive a bitstream. Entropy decoding unit 210 can parse the bitstream to extract syntax elements. As part of parsing the bitstream, entropy decoding unit 210 can parse the entropy-encoded syntax elements in the bitstream. Prediction unit 220, dequantization / transform unit 230, reconstruction unit 240, and loop filtering unit 250 can decode video data based on the syntax elements extracted from the bitstream, i.e., generate decoded video data.

[0075] In some embodiments, the prediction unit 220 includes an intra-frame prediction unit 222 and an inter-frame prediction unit 221.

[0076] Intra-prediction unit 222 can perform intra-prediction to generate prediction blocks for the PU. Intra-prediction unit 222 can use an intra-prediction mode to generate prediction blocks for the PU based on sample blocks of spatially adjacent PUs. Intra-prediction unit 222 can also determine the intra-prediction mode of the PU based on one or more syntax elements parsed from the bitstream.

[0077] Inter-frame prediction unit 221 can construct a first reference image list (list 0) and a second reference image list (list 1) based on the syntax elements parsed from the bitstream. Furthermore, if the PU uses inter-frame prediction coding, entropy decoding unit 210 can parse the motion information of the PU. Inter-frame prediction unit 221 can determine one or more reference blocks of the PU based on the motion information of the PU. Inter-frame prediction unit 221 can generate prediction blocks for the PU based on one or more reference blocks of the PU.

[0078] The dequantization / transformation unit 230 reversibly quantizes (i.e., dequantizes) the transform coefficients associated with the TU. The dequantization / transformation unit 230 can use the QP value associated with the CU of the TU to determine the degree of quantization.

[0079] After the inverse quantization transform coefficients, the inverse quantization / transformation unit 230 can apply one or more inverse transforms to the inverse quantization transform coefficients to generate a residual block associated with the TU.

[0080] The reconstruction unit 240 uses the residual block associated with the TU of the CU and the prediction block of the PU of the CU to reconstruct the sample block of the CU. For example, the reconstruction unit 240 can add the samples of the residual block to the corresponding samples of the prediction block to reconstruct the sample block of the CU, thereby obtaining the reconstructed image block.

[0081] The loop filter unit 250 can perform deblocking filtering operations to reduce the block effect of sample blocks associated with the CU.

[0082] The video decoder 200 can store the reconstructed image of the CU in the decoded image buffer 260. The video decoder 200 can use the reconstructed image in the decoded image buffer 260 as a reference image for subsequent prediction, or transmit the reconstructed image to a display device for presentation.

[0083] The basic process of video encoding and decoding is as follows: At the encoding end, an image is divided into blocks. For the current block, prediction unit 110 uses intra-frame prediction or inter-frame prediction to generate a prediction block for the current block. Residual unit 120 can calculate a residual block based on the prediction block and the original block of the current block, that is, the difference between the prediction block and the original block of the current block. This residual block can also be called residual information. This residual block is transformed and quantized by transform / quantization unit 130, which can remove information that is not sensitive to the human eye to eliminate visual redundancy. Optionally, the residual block before transformation and quantization by transform / quantization unit 130 can be called a temporal residual block, and the temporal residual block after transformation and quantization by transform / quantization unit 130 can be called a frequency residual block or a frequency domain residual block. Entropy coding unit 180 receives the quantized change coefficients output by transform / quantization unit 130, and can entropy code the quantized change coefficients to output a bitstream. For example, entropy coding unit 180 can eliminate character redundancy based on the target context model and the probability information of the binary bitstream.

[0084] At the decoding end, the entropy decoding unit 210 can parse the bitstream to obtain the prediction information and quantization coefficient matrix of the current block. The prediction unit 220 uses intra-frame prediction or inter-frame prediction to generate the prediction block of the current block based on the prediction information. The dequantization / transform unit 230 uses the quantization coefficient matrix obtained from the bitstream to perform dequantization and inverse transform on the quantization coefficient matrix to obtain the residual block. The reconstruction unit 240 adds the prediction block and the residual block to obtain the reconstructed block. The reconstructed blocks form the reconstructed image. The loop filtering unit 250 performs loop filtering on the reconstructed image based on the image or based on the blocks to obtain the decoded image. The encoding end also needs similar operations to the decoding end to obtain the decoded image. This decoded image can also be called the reconstructed image, which can be used as a reference image for inter-frame prediction of subsequent images.

[0085] It should be noted that the block partitioning information determined at the encoding end, as well as mode information or parameter information such as prediction, transform, quantization, entropy coding, and loop filtering, are carried in the bitstream when necessary. The decoding end determines the same block partitioning information, prediction, transform, quantization, entropy coding, and loop filtering mode information or parameter information as the encoding end by parsing the bitstream and analyzing existing information, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end.

[0086] In some embodiments, the current block may be referred to as the current coding unit (CU), the current prediction unit (PU), or the current transform unit (TU), etc. The prediction block may also be referred to as the predicted image block or the image prediction block, and the reconstructed image block may also be referred to as the reconstruction block or the image reconstruction block.

[0087] In some embodiments, images can be divided into slices or similar components to facilitate parallel processing. Slices within the same image can be processed in parallel, meaning there is no data dependency between different slices within the same image.

[0088] It should be noted that the term "frame" as used in this application can generally be understood as a frame or an image, or in other words, the term "frame" as used in this application can also be replaced with an image or a slice, etc.

[0089] The above describes the basic flow of a video codec under a block-based hybrid coding framework. With the development of technology, some modules or steps of this framework or flow may be optimized. This application is applicable to the basic flow of a video codec under this block-based hybrid coding framework, but is not limited to this framework and flow.

[0090] The foregoing has described in detail the encoding / decoding framework provided by the embodiments of this application. These embodiments can be applied to the intra-frame prediction unit within the encoding / decoding framework. The related technologies involved in the embodiments of this application will be described in detail below.

[0091] Intra-frame prediction techniques based on block vectors

[0092] Intra-prediction techniques based on block vectors can include intra-template matching prediction (IntraTMP) and intra-block copy (IBC) techniques.

[0093] IntraTMP is a special intra-frame prediction mode where both the encoder and decoder search for the template (T) of the coded block within a predefined search range in the current image, according to a preset cost function, to find the template with the minimum cost, which is then taken as the best matching template (T_BEST). The offset of the best matching template relative to the template of the current coded block is called the best block vector (BV_BEST). After determining the best matching template, the reconstructed block (ref block) corresponding to the best matching template can be used as the prediction block of the current coded block (cur block).

[0094] IBC is an encoding tool introduced by VVC for video sequences of screen content types, which significantly improves the encoding efficiency of screen content sequences.

[0095] IBC is a block-level coding mode. Similar to inter-frame techniques, the encoder performs motion search (in IBC, this motion search can be called block maching (BM)) to find the optimal block vector (BV) for each coding block. The block vector is a vector pointing from the current block to a reference block. The difference between IBC and inter-frame techniques is that the optimal block vector in IBC is obtained by searching the reconstructed region of the frame containing the current coding block (i.e., the current coding frame), while the motion vector in inter-frame techniques is obtained by searching the adjacent reference frames in the time domain of the current coding frame.

[0096] The following section details block vector prediction (BVP).

[0097] BVP inputs: the position of the current coding block (xTbCmp, yTbCmp), the width of the current coding block uiWidth, and the height of the current coding block uiHeight.

[0098] BVP output: the predicted values ​​of the current block, predSamples[x][y], where x = 0..nTbW-1, y = 0..nTbH-1.

[0099] a. Prediction process at the encoding end:

[0100] The prediction process of BVP technology at the encoding end includes three steps: obtaining the block vector, obtaining reference region samples, and determining the predicted value. After these steps, the predicted value of the current coding block can be obtained. The flowchart of this process is shown in Figure 3.

[0101] The steps in Figure 3 will be described in detail below.

[0102] S1, Obtain block vector

[0103] Input: the position of the current encoding block (xTbCmp, yTbCmp), the width of the current encoding block uiWidth, and the height of the current encoding block uiHeight.

[0104] Output: The block vector (xBv, yBv) of the current coded block.

[0105] BVP technology uses block vectors to determine the position of a reference block, thereby obtaining the current block prediction value.

[0106] S1.1 Obtaining Block Vectors under IntraTMP

[0107] The method for constructing block vectors may include: using the adjacent reconstructed samples of the current coding block as templates, searching for N (e.g., N can be 30) templates with low matching costs to the current coding block template within the reconstructed region of the current image, and using the region corresponding to the reference template that is the same size as the current coding block as the reference block. Specifically, the steps are as follows: determining the reference template, initializing the template and determining the search region of the template in the current frame, and searching and constructing a block vector list within the search region, as shown in Figure 4.

[0108] S1.1.1 Determine the reference template type

[0109] BVP technology uses adjacent reconstructed samples of the current coding block as templates to search for matching templates in a predefined search area. The adjacent reconstructed samples can be the upper reference sample, upper left reference sample, upper right reference sample, left reference sample, and lower left reference sample of the coding block. Therefore, the template can be classified and the template type can be determined based on whether the adjacent reference samples are available (the template type can be represented by refTemplateType).

[0110] For example, when the upper left, upper, and left reference samples are all available, the template shape is as shown in Figure 5(a).

[0111] For example, when only the left reference sample is available, the template shape is as shown in Figure 5(b).

[0112] For example, when only the upper reference sample is available, the template shape is as shown in (c) of Figure 5 below.

[0113] For example, when only the left and upper left reference samples are available, the template shape is as shown in (d) of Figure 5 below.

[0114] For example, when only the left and lower left reference samples are available, the template shape is as shown in Figure 5(e).

[0115] For example, when only the top and upper right reference samples are available, the template shape is as shown in (f) of Figure 5 below.

[0116] S1.1.2 Initialize the template and determine the search area of ​​the template in the current frame.

[0117] When searching for the best matching template in the search area, you can use a search strategy of first coarse search and then fine search, or you can only perform a fine search, or only a coarse search.

[0118] The coarse search here may include, for example, determining the best coarse matching template in the search region with a first preset step size (e.g., 3), or determining the best coarse matching template in the search region using a downsampled template (e.g., a downsampling factor of 3).

[0119] The fine search here may include, for example, determining the best fine matching template in the search region with a second preset step size (e.g., 1, if subsample precision is encountered, subsample interpolation of the reconstructed samples is required), or determining the best fine matching template near the best coarse matching template after the coarse search is completed.

[0120] Initialize `uiPatchWidth` to `nTbW + templateW_size` and `uiPatchHeight` to `nTbH + templateH_size`. `templateW_size` and `templateH_size` can be fixed constants or dynamically adjusted based on the code block size. `templateW_size` and `templateH_size` can be equal or unequal. For example, `templateW_size = 4` and `templateH_size = 4`. Alternatively, when the code block width is greater than 8, set `templateW_size = 4`; when the code block width is less than or equal to 8, set `templateW_size = 2`. When the code block height is greater than 8, set `templateH_size = 4`; when the code block height is less than or equal to 8, set `templateH_size = 2`. See Figure 6 for the specific meaning of these parameters.

[0121] Initialize the cost threshold `diffThreshold` between templates. For example, when the cost function is the sum of absolute differences (SAD), this threshold can be calculated using the following formula:

[0122] diffThreshold=((1<<bitDepth)> >2)*(uiPatchHeight*uiPatchWidth-nTbH*nTbW), when the image bit depth bitDepth is 10, diffThreshold means that the distortion threshold for each sample point in the template region is 256.

[0123] Initialize the position of the current coding tree block (CTB) where the CB is located: ctbRsX, ctbRsY.

[0124] Initialize the current CB's position offset within the current CTB:

[0125] offsetLCBY=yTbCmp–ctbRsY;

[0126] offsetLCBX=xTbCmp-ctbRsX.

[0127] Initialize iTemplateSizeH=templateH_size, iTemplateSizeW=templateW_size.

[0128] Initialize iBvShift. iBvShift is the precision of BV. The precision of BV can be integer pixel precision, in which case iBvShift is 0; the precision of BV can also be subpixel precision, for example, iBvShift of 1 represents 1 / 2 pixel precision, and iBvShift of 2 represents 1 / 4 pixel precision.

[0129] Initialize the template's preset search range. The preset search range of the template can be set to a fixed size, or it can be dynamically adjusted according to the code block size. For example, the preset search range of the template can be defined by the following formula:

[0130] searchRangeWidth=TMP_SEARCH_RANGE_MULT_FACTOR*nTbW;

[0131] searchRangeHeight=TMP_SEARCH_RANGE_MULT_FACTOR*nTbH;

[0132] The value of TMP_SEARCH_RANGE_MULT_FACTOR is a preset value, for example, it can be set to a fixed value of 5.

[0133] The template's search area in the current frame can be divided into two types: the surrounding rectangular search area and the extended search area.

[0134] The surrounding rectangular search area is also divided into two types: one is a region where all sampling points have been reconstructed (called the fully reconstructed region), such as the four regions R1 to R4 in Figure 7; the other is a region where it is uncertain whether all sampling points have been reconstructed (called the undetermined reconstructed region), such as the two regions R5 to R6 in Figure 7.

[0135] The extended search region is defined as the region pointed to by the BV corresponding to the spatially adjacent and non-adjacent positions PU, as shown in Figure 8. This region can be considered as part of R7.

[0136] For search points within the surrounding rectangular search area, you can either traverse all search points within the specified search area or search only a local area within the search area, balancing computational complexity and coding efficiency. For search points within an extended search area, a full search can be performed.

[0137] S1.1.3 Search within the search area and construct a list of block vectors.

[0138] bvXMins and bvXMaxs represent the minimum and maximum offsets of the block vector in the horizontal direction, respectively, while bvYMins and bvYMaxs represent the minimum and maximum offsets of the block vector in the vertical direction, respectively.

[0139] bvXMinsregionId, bvXMaxsregionId, bvYMinsregionId, and bvYMaxsregionId can be calculated from iVerMinregionId, iVerMaxregionId, iHorMinregionId, and iHorMaxregionId (iVerMinregionId, iVerMaxregionId, iHorMinregionId, and iHorMaxregionId represent the identifiers of the regions in R1 to R6 that are located at the boundaries in the horizontal and vertical directions).

[0140] bvXMinsregionId=iHorMinregionId–xTbCmp;

[0141] bvXMaxsregionId=iHorMaxregionId–xTbCmp;

[0142] bvYMinsregionId=iVerMinregionId–yTbCmp;

[0143] bvYMaxsregionId=iVerMaxregionId–yTbCmp;

[0144] bvXMinsregionId, bvXMaxsregionId, bvYMinsregionId, and bvYMaxsregionId determine the range of horizontal and vertical offsets of the search point relative to the current block, i.e., the range of the block vector.

[0145] For the fully reconstructed regions (e.g., corresponding to regions R1 to R4 in Figure 7) and the extended search regions, a matching reconstructed block of the current block can be found in the reconstructed region through the search points (iPosHor, iPoxVer) within each search region, i.e., each BV. The adjacent reconstructed samples of the matching reconstructed block are the matching templates. The matching cost between the adjacent templates of the current block and the adjacent templates of the reconstructed blocks can then be calculated, denoted as pDiff.

[0146] For the given reconstruction region (e.g., corresponding to regions R5-R6 in Figure 7), for each search point (iPosHor, iPosVer) within the search region, i.e., each BV (composed of horizontal and vertical components: (pX, pY), where pX = iPosHor - xTbCmp, pY = iPosVer - yTbCmp, pX lies between bvXMins and bvXMaxs, and pY lies between bvYMins and bvYMaxs), an availability assessment is performed. If available, a matching reconstruction block can be found in the reconstruction region, and the adjacent reconstruction samples of the matching reconstruction block are the matching templates. The matching cost between the adjacent templates of the current block and the adjacent templates of the reconstructed block can then be calculated, denoted as pDiff. If unavailable, no template matching cost calculation is performed.

[0147] The availability judgment mentioned above may include, but is not limited to, one or more of the following conditions:

[0148] Each sampling point within the template does not exceed the valid coordinate range limited by the image sampling point boundary;

[0149] The sampling points within the reconstruction block corresponding to the template do not exceed the valid coordinate range limited by the image sampling point boundary;

[0150] All sampling points within the template and all sampling points within the corresponding reconstruction block did not exceed the range specified by the search window;

[0151] Whether each sampling point within the template is on the same tile as the current encoding region;

[0152] Whether each sampling point within the reconstructed block corresponding to the template is in the same tile as the current encoding region;

[0153] All sampling points within the template have been reconstructed;

[0154] The sample points within the reconstruction block corresponding to the template are not located in the current encoding region;

[0155] All sampling points within the template-corresponding reconstruction block have been reconstructed.

[0156] Traverse all available search points in the search region and compare them to find the M (e.g., M can be 30) search points with the smallest matching cost pDiff. The corresponding matching cost is denoted as pDiff_BEST[n], n = 0, ..., M, and the corresponding BV is denoted as the optimal BV, i.e., BV_BEST[n]. Each item in BV_BEST[n] is a coordinate pair (pX_BEST, pY_BEST), n = 0, ..., M. The matching template corresponding to BV_BEST[n] is the optimal matching template T_BEST[n], n = 0, ..., M.

[0157] Within the surrounding rectangular search area, if the search strategy is to perform only a coarse search, it can be implemented as follows.

[0158] Within each region, when pX is between bvXMinsregionId and bvXMaxsregionId, and pY is between bvYMinsregionId and bvYMaxsregionId, a coarse search is performed with a step size greater than 1 (e.g., a coarse search with a step size of 2). The optimal matching cost obtained by template matching is recorded as pDiff_BEST, and its corresponding BV is denoted as the best block vector BV_BEST(pX_BEST, pY_BEST).

[0159] If the search strategy is to perform only a fine-grained search, it can be implemented as follows.

[0160] Within each region, within the search range where pX is between bvXMinsregionId and bvXMaxsregionId, and pY is between bvYMinsregionId and bvYMaxsregionId (e.g., performing a fine search with a step size of 1), the optimal matching cost obtained by template matching is recorded as pDiff_BEST, and its corresponding BV is denoted as the best block vector BV_BEST(pX_BEST, pY_BEST).

[0161] If the search strategy is to perform a coarse search first, followed by a fine search, as shown in Figure 9, it can be implemented as follows.

[0162] S1.3.1 Construct a coarse search list within the search area.

[0163] Within each region of the surrounding rectangular search area, a coarse search is performed with a step size of 3, where pX lies between bvXMinsregionId and bvXMaxsregionId, and pY lies between bvYMinsregionId and bvYMaxsregionId. During this coarse search with a step size of 3, the top P optimal matching costs obtained from template matching are recorded, denoted as pDiff1_BEST[p], where p = 0, ..., P-1. The BV corresponding to these P optimal matching costs is denoted as the best BV, i.e., BV1_BEST[p], where p = 0, ..., P-1. Here, p can be an integer value of 1 or greater than 1 as needed, and the search area containing the best matching search point is bestRegionId[p], where p = 0, ..., P-1.

[0164] After finding P reference points in the search area, a list of candidate BVs that can be referenced by the current block is constructed using multiple predefined search locations. This list is called the BVP-Merge list.

[0165] The predefined set of search positions may include, for example, the five adjacent positions in the current block space: left (xTbCmp-1, yTbCmp+nTbH-1), top (xTbCmp+nTbW-1, yTbCmp-1), top right (xTbCmp+nTbW, yTbCmp-1), bottom left (xTbCmp-1, yTbCmp+nTbH), top left (xTbCmp-1, yTbCmp-1), and 18 non-adjacent positions in the space (as shown in Figure 8).

[0166] The process of constructing the candidate BV list can be implemented, for example, as follows.

[0167] Check whether the PU corresponding to the predefined search position uses IntraTMP / IBC technology. If the PU corresponding to the predefined search position uses IntraTMP / IBC technology, check whether the following positions of the current block plus the BV of this PU are within the IBC search range: top left (xTbCmp+BVx, yTbCmp), bottom left (xTbCmp+BVx, yTbCmp+nTbH+BVy), top right (xTbCmp+nTbW+BVx, yTbCmp+BVy), and bottom right (xTbCmp+nTbW+BVx, yTbCmp+nTbH+BVy). The IBC search range can be represented as the range shown in Figure 10 (i.e., the area corresponding to the reference CTU in Figure 10). When the current CTU size is 256*256, the IBC search range is modified to the area shown in Figure 11 (i.e., the area corresponding to the reference CTU in Figure 11).

[0168] If all the above positions are within the IBC search range, the BV of this PU is stored in the IntraTMP_Merge list. If any position is outside the IBC search range, the BV is invalid, and the BV of the next position is checked until all positions have been checked, thus completing the construction of the BVP-Merge list. After constructing the BVP-Merge list, the coarse search list is updated. The specific update operation is as follows: access each item in this list sequentially, calculate the template matching cost corresponding to each BV, compare this cost with the template matching cost of the initial coarse search list, and if it is less than the maximum template matching cost in the coarse search list, replace the worse BV in the coarse search list with this BV. Specific replacement operations may include, for example, inserting this BV into the coarse search list in order of cost size and deleting the item with the highest cost in the coarse search list.

[0169] Depending on the algorithm's requirements, the coarse search phase will provide one or more (here denoted as Q, 1 <= Q <= P) fine search reference points, thus continuing to execute step S1.3.2.

[0170] S1.3.2, Determine the fine search list near the coarse search list BV with a step size of 1.

[0171] Furthermore, the optimal block vector BV1_BEST[p], p = 0, ..., M-1 obtained from the coarse search is used as the benchmark point for the fine search, and a search is performed in the vicinity of the benchmark point.

[0172] For example, for each fine-search baseline point, the position of the best matching reconstructed block obtained from the coarse search is first used as the baseline position of the fine-search region: BestPosX = xTbCmp + pX1_BEST, BestPosY = yTbCmp + pY1_BEST. Then, the fine-search ranges TmpRefineRangeHor and TmpRefineRangeVer are determined. The fine-search range can be a fixed size or related to the search region.

[0173] For example, for the reference point within the surrounding rectangular search area, both TmpRefineRangeHor and TmpRefineRangeVer can be set to 1, as shown in Figure 12. In other words, the fine-grained search range is the sample area within the range of [-R1,R1] (for example, R1 can be 1) offset from the fine-grained search starting point as [0,0] coordinates and from which the vertical and horizontal coordinates are respectively offset. A point-by-point full search is then performed within this range.

[0174] For the reference point of the expanded search area, both TmpRefineRangeHor and TmpRefineRangeVer can be set to 5, as shown in Figure 13. In other words, the fine-grained search range is the sample area within the range of [-R2,R2] (for example, R2 can be 5) offset from the fine-grained search starting point as [0,0] coordinates. A point-by-point full search is performed within this range.

[0175] Alternatively, when the current block selects to use the IntraTMP-LIC mode, the fine-search range is a 5×5 sample region with the fine-search search starting point at [0,0] coordinates and offset vertically and horizontally by [-2,2] respectively; otherwise, when the current block does not select to use the IntraTMP-LIC mode, the fine-search range is an 11×11 sample region with the fine-search search starting point at [0,0] coordinates and offset vertically and horizontally by [-5,5] respectively. A point-by-point full search is performed within this range, as shown in Figure 14.

[0176] By directly utilizing the search window, the fine search area is treated as a whole region to be reconstructed, and the fine search area is traversed directly.

[0177] The new search range is obtained based on the optimal matching block position obtained from the coarse search, including:

[0178] iHorMaxrefine=min(picWidth-nTbW,BestPosX+TmpRefineRangeHor);

[0179] iHorMinrefine=max(iTemplateSizeW,BestPosX-TmpRefineRangeHor);

[0180] iVerMaxrefine=min(picHeight-nTbH,BestPosY+TmpRefineRangeVer);

[0181] iVerMinrefine=max(iTemplateSizeH, BestPosY-TmpRefineRangeVer).

[0182] Then, the adjusted block vectors BVbvXMins, bvXMaxs, bvYMins, and bvYMaxs can be calculated using iVerMinrefine, iVerMaxrefine, iHorMinrefine, and iHorMaxrefine:

[0183] bvXMins=iHorMinrefine–xTbCmp;

[0184] bvXMaxs=iHorMaxrefine–xTbCmp;

[0185] bvYMins=iVerMinrefine–yTbCmp;

[0186] bvYMaxs=iVerMaxrefine–yTbCmp.

[0187] The fine-grained search is performed within the block vector range where pX lies between bvXMinsrefine and bvXMaxsrefine, and pY lies between bvYMinsrefine and bvYMaxsrefine. For example, all search positions within the fine-grained search window can be traversed directly, and availability can be assessed for each position sequentially. For instance, with a step size of 1, the costs of the top T optimal matches obtained from available point template matching are recorded as pDiff_BEST[t], t = 0, ..., T-1, and their corresponding BV values ​​are denoted as the best block vector BV_BEST[t], t = 0, ..., T-1. Here, T is an integer of 1 or greater than 1. For example, T = 1. This completes the construction of the block vector list.

[0188] After building the block vector list, if the block vector list length is greater than 1, the encoder iterates through the list and determines the final block vector to be used based on the prediction cost (which may be the prediction distortion cost or the rate distortion cost). The final block vector is then sent to the decoder using the appropriate syntax elements from the bitstream.

[0189] S1.2 Obtaining Block Vectors in IBC Mode

[0190] The following sections will introduce the methods for obtaining block vectors from the perspectives of luminance and chrominance components.

[0191] (1) Brightness:

[0192] Basic IBC Mode

[0193] Input: luminance position (xCb, yCb), variable cbWidth, and variable cbHeight; where (xCb, yCb) specifies the luminance sample of the top left corner of the current coding block relative to the luminance sample of the top left corner of the current image; cbWidth specifies the width of the current coding block in the luminance sample; and cbHeight specifies the height of the current coding block in the luminance sample.

[0194] Output: Block vector luma (bvL) of luminance

[0195] IBC modes can be broadly divided into two categories: IBC merge and IBC ABVP (similar to the merge and AMVP modes in VVC inter-frame modes). The process of acquiring BV can be regarded as the following two steps at both the encoding and decoding ends (see Figure 15):

[0196] ① When deriving bvL, it is necessary to establish an IBC block vector candidate list bvCandList;

[0197] ② Determine the block vector.

[0198] The IBC candidates stored in bvCandList specifically include at least one of the following:

[0199] Predict the direction (L0 or L1, L0 is usually the default);

[0200] BV information (horizontal and vertical components);

[0201] Reference frame (default is the current image);

[0202] Flip type (e.g., no flip, horizontal flip, and vertical flip);

[0203] Whether to use LIC (linear model).

[0204] S1.2.1 Establish a candidate list for block vectors

[0205] IBC merge mode:

[0206] The process of establishing the candidate list is described below, taking the IBC merge list as an example. The basic process of establishing the IBC ABVP list is the same as that of IBC merge, but the maximum number of candidates is usually different (for example, the candidate list length for IBC merge is 6, while the candidate list length for IBC ABVP is 2). The process of establishing the IBC merge list is shown in Figure 16, and the steps in Figure 16 are described below.

[0207] S1.2.1.1: Add airspace candidates

[0208] When the usage conditions are met (e.g., the size condition IsGt4by4 equals TRUE, where the variable IsGt4by4 is TRUE when the luminance width multiplied by the height is greater than 16), the derivation process of the spatial block vector candidates from adjacent coding units as specified in the decoding specification is called using the luminance coding block position (xCb, yCb), luminance coding block width cbWidth, and height cbHeight as input. The output is the availability flags, such as availableFlagA1, availableFlagB1, and block vectors bvA1 and bvB1.

[0209] For each candidate option's availability check, the following conditions can be considered: If all of the following conditions are met, then the candidate option is available:

[0210] Does the offset obtained by adding BVP to the current block position not exceed the image boundary?

[0211] Does adding the current block position to the block position pointed to by BVP prevent the current block from being overwritten?

[0212] Does the offset obtained by adding BVP to the current block position not exceed the available IBC area?

[0213] Check if the current block location plus the block location pointed to by BVP has been rebuilt.

[0214] The relative positions of adjacent blocks such as A1 and B1 with the current coded block are shown in Figure 17. The traversal order in Figure 17 can be A1->B1->B0->A0->B2.

[0215] If the adjacent block positions shown in Figure 17 satisfy the usage conditions (e.g., the size condition IsGt4by4 equals TRUE), the block vector candidate list bvCandList is constructed as follows:

[0216] i = 0;

[0217] if(availableFlagA1);

[0218] bvCandList[i++] = bvA1;

[0219] if(availableFlagB1);

[0220] bvCandList[i++] = bvB1.

[0221] During the construction of bvCandList, the number of valid items in the candidate list can be checked, i.e., the value of the variable numCurrCand. The derivation process of the variable numCurrCand (the number of candidates obtained so far) is as follows:

[0222] If the usage conditions are met (e.g., the size condition IsGt4by4 equals TRUE), numCurrCand is set to equal the candidate number in bvCandList; otherwise, numCurrCand is set to 0.

[0223] S1.2.1.2: Add historical candidates

[0224] If the candidate list does not reach the specified number of items (e.g., 6 items for IBC merge mode and 2 items for IBC ABVP mode), continue with the derivation of historical candidates, availability testing and addition, as follows.

[0225] When numCurrCand is less than MaxNumIbcMergeCand (the maximum number of candidates in IBC merge mode) and NumHmvpIbcCand (the maximum number of candidates for the historical best block vector (Hmvp) in IBC mode) is greater than 0, bvCandList and numCurrCand are used as inputs, and the modified bvCandList and numCurrCand are used as outputs, the derivation process of historical IBC block vector candidates as specified in the decoding specification is called.

[0226] S1.2.1.3: Add other candidates

[0227] Continue checking the number of valid items in the candidate list and adding other available candidates (such as pairwise average candidates) until the specified number of items is reached.

[0228] For example, a pairwise average candidate can be constructed by using the first and second candidates in the candidate list, using the following formula:

[0229] mvAvgLX=(mvCand0LX+mvCand1LX+1)>>1.

[0230] Alternatively, a set of BVP candidates located in the IBC reference area can be added to the candidate list as addable candidates. The coordinates of a set of BVP candidates are determined by the width and height of the current block, as well as the ΔX and ΔY parameters, as shown in Figure 18.

[0231] For each new candidate added to the candidate list, numCurrCand increases by 1.

[0232] Based on the above method, a basic candidate list of block vectors, bvCandList, can be established.

[0233] Based on this list, in IBC merge mode, the order of the list can be reordered using templates to adjust the order of the candidate list, making full use of the high spatial correlation, reducing the number of encoded bits, and thus effectively improving coding efficiency. For example, for IBC merge mode, after constructing an intermediate candidate list using the above list construction method (note that the length of this intermediate candidate list can be greater than or equal to the maximum number of candidates in IBC merge mode), all candidates in the list are reordered using templates, sorted in ascending order of template matching cost, and the top N (e.g., N=6) candidates are selected from the sorted list. The specific process is as follows: calculate the SAD of the template position of the reference block pointed to by each candidate and the template position of the current block (as shown in Figure 19), sort them in ascending order, and select the top 6 candidates as the candidate list for IBC merge.

[0234] IBC ABVP mode:

[0235] The candidate list construction process for IBC ABVP mode is basically the same as that for IBC Merge mode. Furthermore, based on the IBC Merge list, IBC ABVP mode can also perform a candidate redundancy removal operation based on the distance between candidates. This operation is described below.

[0236] The number of candidates remains constant at two levels, with candidate lists created for integer pixels and 4-pixel precision respectively.

[0237] If a non-RIBC mode is selected for IBC ABVP, and the number of valid BVP candidates exceeds two, up to six BVP candidates in the candidate list can be clustered based on the Euclidean distance between them. The radius (R) is a logarithmic function of the width (cbWidth) and height (cbHeight) of the current block determined by a set of block vectors. If the Euclidean distance between the reference locations pointed to by several BV candidates is less than R, they are clustered (see Figure 20).

[0238] R=log2((cbWidth·cbHeight)>>MIN_PU_SIZE);

[0239] The clustering method proceeds in the order of the candidate list. In each cluster, the BVP with the lowest TM cost is selected as the representative candidate of that group. Then, the representative candidates of all clusters are sorted by template, and the representative candidates of the first two groups are selected for the motion estimation process.

[0240] If the RRIBC mode is selected for IBC ABVP, the candidates will be adjusted to point to the boundary of the valid IBC search area according to the horizontal or vertical direction of the RRIBC mode.

[0241] S1.2.2 Determine the BV and put the corresponding information into the bitstream.

[0242] IBC merge mode:

[0243] In IBV merge mode (general_merge_flag[xCb][yCb] is true) and IBC ABVP mode (general_merge_flag[xCb][yCb] is false), after the encoder determines the final selected BV, it encodes its index bvIdx in the candidate list into the bitstream. Its relationship with the syntax element merge_idx[xCb][yCb] (IBV merge mode) or mvp_l0_flag[xCb][yCb] (IBC ABVP mode) in the bitstream is as follows:

[0244] bvIdx=general_merge_flag[xCb][yCb]? merge_idx[xCb][yCb]:mvp_l0_flag[xCb][yCb];

[0245] In IBC merge mode, the specific bvL can be obtained from the index bvIdx and the candidate list of block vectors bvCandList:

[0246] bvL[0]=bvCandList[bvIdx][0];

[0247] bvL[1]=bvCandList[bvIdx][1].

[0248] This bvL is the final BV.

[0249] IBC MBVD mode

[0250] Similar to MMVD in VVC's inter-frame technique, starting from a candidate in the IBC merge list, a candidate is selected from the candidate point set corresponding to the predefined distance and direction set, and its corresponding block vector is used as the final BV.

[0251] For example, in IBC MBVD, the distance set is defined as {1pel, 2pel, 4pel, 8pel, 12pel, 16pel, 24pel, 32pel, 40pel, 48pel, 56pel, 64pel, 72pel, 80pel, 88pel, 96pel, 104pel, 112pel, 120pel, 128pel} (pel refers to an image element, such as a pixel or sample), and the BVD direction is two positive and two negative horizontal directions and two positive and two negative vertical directions.

[0252] The base candidates are selected from the top five candidates in the reordered IBC merge list, and the refinement positions (i.e., 20×4 candidates) of all possible MBVDs for each base candidate are reordered based on the prediction cost (e.g., SAD) between the template and its reference template at each refinement position. Finally, the top 8 refinement positions with the lowest prediction cost are retained for MBVD index encoding.

[0253] The encoder selects the MBVD for final prediction based on the encoding cost (prediction distortion cost or rate distortion cost, etc.) and sends its information into the bitstream, which is then transmitted to the decoder. In related technologies, IBC-MBVD candidates do not inherit the flip type from adjacent blocks encoded by RR-IBC. The MBVD index is binarized using Rice code with a parameter equal to 1.

[0254] IBC™ merge mode

[0255] The above BV candidates can be further refined locally using TM. Specifically, a search is performed within a small range centered on each BV candidate, and the optimal BV within that range is selected as the final BV candidate based on the minimum template matching cost.

[0256] The candidate list for IBC merge modes is refined using TM (Technical Model). A specific implementation process is as follows:

[0257] When constructing candidates, the flip type is set to no flip by default;

[0258] In IBC TM merge mode, the transport syntax element specifies whether to perform TM refinement with full sample precision. The location of the refinement motion vector and the template used in each refinement step must adhere to the constraints of the reference region.

[0259] The search is performed near the indicated position of the candidate, and the optimal position is determined by the SAD value between the template of the reference block and the template of the current block. The search method includes, but is not limited to, the following: the search range is [-8,8]. First, a diamond search is performed on the whole sample, searching for eight points near the middle position, as shown in the upper left corner of Figure 21. The maximum number of searches is 375. After the optimal position is determined for the first time, the search continues. In the subsequent search process, 5 points are searched for even-numbered positions and 3 points are searched for odd-numbered positions.

[0260] Taking the top left corner of Figure 21 as an example, starting from the red point and going counterclockwise, the order is from index 0 to 7. Specifically, the process is as follows: when the red position is selected as the optimal position, continue searching for 5 or 3 points in the purple position.

[0261] After the diamond search process described above, a cross search is performed on the entire sample. This search is only performed once. That is, after the diamond search finds the current optimal position, it checks four positions below, to the right, above, and to the left of the current optimal position, which are one sample point away, and updates the final optimal position, thus obtaining the refined candidate list.

[0262] In this mode, after the encoder determines the final selected BV candidate, it encodes its index bvIdx in the candidate list into the bitstream.

[0263] IBC ABVP mode

[0264] In this mode, after the encoder selects a Block Vector (BV) based on the encoding cost, there is a block vector difference (BVD) between this BV and the candidates in the candidate list. The encoder sends the corresponding index bvIdx from the candidate block vector list bvCandList and the BVD into the bitstream.

[0265] (2) Color:

[0266] In the IBC mode for chromaticity components, the chromaticity BV can be derived from the luminance BV, and then prediction and reconstruction can be achieved based on this BV. The process of deriving the chromaticity BV from the luminance BV is as follows:

[0267] Input: bvL of brightness (1 / 16 sample precision)

[0268] Output: Block Vector Chroma (BVC) of chroma (1 / 32 sample precision)

[0269] The derivation process can involve directly scaling bvL, or scaling bvL and then refining it using TM. An example of a scaling operation is shown below:

[0270] bvC[0]=((bvL[0]>>(3+SubWidthC))*32);

[0271] bvC[1]=((bvL[1]>>(3+SubHeightC))*32).

[0272] The variables SubWidthC and SubHeightC depend on the chroma format sampling structure specified by sps_chroma_format_idc, and the specific correspondence is shown in Table 1 below.

[0273] Table 1. Correspondence between sps_chroma_format_idc and chroma format sampling structure

[0274] The TM-based refinement operations mentioned above can be implemented in the following way.

[0275] TM refinement is used, that is, after obtaining the luminance BV, the offset position is found by using the position of the chrominance block and the BV, and a template is used to perform a fine search in the vicinity of the offset position. The optimal BV is obtained by minimizing the TM cost. As shown in Figure 22.

[0276] S2. Obtain reference region sample

[0277] The reference region of BVP can contain a reference template or a reference block. The reference regions of IntraTMP mode and IBC can be different.

[0278] The input and output of the reference region sample acquisition process under IntraTMP are as follows:

[0279] Input: Width and height of the current encoding block, template type

[0280] Output: Reference region sample (including template)

[0281] A BVP template can be composed of reconstructed samples from one or more regions of the coding block, including the top, top right, left, bottom left, and top left regions. The template size is pre-set. For example, when obtaining the left template, the template width `templateW_size` can be set to 4, and when obtaining the top template, the template height `templateH_size` can be set to 4.

[0282] The type of template can be used to determine which part of the reconstructed samples to obtain. For example, when the template type is L-shaped, the left, upper left, and upper reconstructed samples of the reference coding block determined by the block vector are obtained; when the template type is Left, only the left k (e.g., k can be 4) columns of the reference coding block are obtained; when the template type is Above, only the upper k (e.g., k can be 4) rows of the reference coding block are obtained.

[0283] After obtaining the template, obtain the reconstruction sample of the region with the same size as the current block, determined by the block vector.

[0284] The input and output of the process for obtaining reference region samples under IBC are as follows:

[0285] Input: Width and height of the current encoding block

[0286] Output: Reference region sample (excluding template)

[0287] The reference region is used to obtain a reconstructed sample of the region with the same size as the current block, determined by the block vector.

[0288] S3. Determine the predicted value

[0289] The case of generating predicted values ​​directly using a BV-based prediction model:

[0290] Input: Luminance position (xCb, yCb), variable cbWidth, variable cbHeight, block vector, variable cIdx; where (xCb, yCb) specifies the luminance sample of the top left corner of the current coding block relative to the luminance sample of the top left corner of the current image, variable cbWidth specifies the width of the current coding block in the luminance sample, variable cbHeight specifies the height of the current coding block in the luminance sample, and variable cIdx specifies the color component index of the current block.

[0291] Output: An array of predicted samples, predSamples.

[0292] If the reference block is in IntraTMP mode, then:

[0293] In the normal IntraTMP mode, the reference block with the same size as the current coding block, determined by the block vector, is directly used as the prediction block of the current coding block.

[0294] In IntraTMP Fusion mode, a predicted block is calculated based on each candidate reconstruction block and its corresponding weighted fusion weight. Specifically, the value of each candidate reconstruction block is multiplied by its corresponding weight and then summed to obtain the current predicted block (i.e., weighted prediction). The calculation formula is as follows:

[0295] For x = 0…nTbW-1, y = 0…nTbH-1, the predicted value is calculated as follows:

[0296] Each predicted value predSamples x,y By performing spatial storage, the prediction block output by IntraTMP Fusion can be obtained.

[0297] In IntraTMP FLM mode, a linear filtering model is established using the best matching template obtained in the previous step and the current coding block template. This mainly includes the following two processes: determining the reconstruction region for calculating the filter coefficients, and calculating the filter coefficients. The specific prediction calculation process is as follows: Assuming the number of filter taps nTap is 5, the shape of the filter is shown in the left figure of Figure 23. C0 to C4 are the tap coefficients of the filter, where the sample point corresponding to tap coefficient C0 is the current sample Y to be predicted. pred [i][j] represents the reconstructed sample ref[i][j] at the corresponding position in the best-matching block; the remaining sample points (C1 to C4) are the reconstructed samples in the best-matching reconstructed block that are adjacent to the current spatial position. The sample point corresponding to position C0 in the right figure of Figure 23 is the obtained predicted sample Y. pred [i][j].

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

[0299] For each current sample to be predicted (i,j), the sample position in the filter template is defined as (k,l). Then, the reconstructed sample in the best-matching block during filtering is defined as ref[i+k][j+l]. Each filter coefficient at position (k,l) in the filter template is defined as c. k,l :

[0300] c k,l =c n ;

[0301] Where n = 0, ..., nTap-1, k and l are between -1 and 1.

[0302] For i = 0, ..., nTbW-1, j = 0, ..., nTbH-1:

[0303] Y pred [i][j]=∑ k ∑ l ref[i+k][j+l]×C ,k,l ;

[0304] The final predicted sample is:

[0305] predSamples[i][j]=Clip3(0,(1<<BitDepth)-1,Y pred [i][j]);

[0306] in,

[0307] In IntraTMP SubPel mode, for the optimal BV, the eight directions of 1 / 4, 1 / 2, 3 / 4 and up / down / left / right, top left, top right, bottom left, and bottom right are traversed and sorted according to the template cost. The reference block corresponding to the BV with the smallest template cost is used to calculate the predicted value using an interpolation filter.

[0308] If it is IBC mode, the derivation process of the prediction block is shown in the following example:

[0309] When cIdx equals 0, which represents the luminance component, for x = xCb..xCb + cbWidth-1 and y = yCb..yCb + cbHeight-1:

[0310] xVb=(x+(bvL[0]>>4))&(IbcBufWidthY-1);

[0311] yVb=(y+(bvL[1]>>4))&(CtbSizeY-1);

[0312] predSamples[x][y]=ibcVirBuf[0][xVb][yVb];

[0313] Where IbcBufWidthY is the width of the luminance sample in the reconstruction buffer stored in IBC, CtbSizeY is the size of CTU (Coding Tree Unit), and ibcVirBuf is the reconstruction sample stored in IBC.

[0314] When cIdx is not equal to 0 (i.e., the chromaticity component), for x = xCb / SubWidthC..xCb / SubWidthC + cbWidth / SubWidthC-1 and y = yCb / SubHeightC..yCb / SubHeightC + cbHeight / SubHeightC-1:

[0315] xVb=(x+(bvC[0]>>4))&(IbcBufWidthC-1);

[0316] yVb=(y+(bvC[1]>>4))&((CtbSizeY / subHeightC)-1);

[0317] predSamples[x][y]=ibcVirBuf[cIdx][xVb][yVb].

[0318] In addition to the basic acquisition methods mentioned above, there is also a method in IBC flip mode where the prediction region needs to be horizontally or vertically flipped before being used as the prediction value. For example, a syntax element can be used to indicate whether to flip, and if flipped, it can be further indicated whether it is a horizontal or vertical flip. The decoder performs a horizontal or vertical reverse rearrangement of the reference region samples according to the instruction of this syntax to obtain the prediction sample value of the coded block.

[0319] In addition to the above acquisition process, a model between the current block and the prediction region can be established using templates. The predicted block is then processed according to the model to obtain the predicted value of the current block. For example, the IBC LIC mode can be applied to IBC merge and IBC ABVP, using linear equations to compensate for local illumination changes. Similar to the LIC of inter-frame prediction in VVC, the parameters of the linear equation can be represented by the scaling parameter α and the offset parameter β, i.e., α*p[x]+β to compensate for illumination changes, where p[x] is the reference sample pointed to by the position x of the BV in the current image. The linear model parameters are derived using the least squares method.

[0320] In some implementations, the predicted value determined based on BV may be a partial predicted value for the current block. The inputs, outputs, and implementation process for this situation are described below.

[0321] Input: Current block width and height, multiple BV values

[0322] Output: Predicted value of the current coded block

[0323] Based on the obtained predicted values, weighted prediction can be performed with other intra-frame prediction methods, and the result of the weighted prediction can be used as the final prediction result.

[0324] The overall weighted prediction method includes the inter-frame and intra-frame hybrid prediction (CIIP) method borrowed from VVC, which combines the results obtained from the above prediction process with the prediction results obtained from the ordinary intra-frame directional prediction mode at each sample location in a weighted manner; it also includes the inter-frame geometric partitioning mode (GPM) method borrowed from VVC, which uses a wedge partition as a basis, uses different prediction modes in different wedge regions, and performs weighted mixing in accordance with certain rules near the wedge partition line.

[0325] For example, the operation process in IBC CIIP mode may include: weighted fusion of the IBC prediction value of the current block with the prediction value of a certain intra-frame mode. The IBC prediction part can be obtained by applying the conventional merge, TM merge, MBVD and ABVP modes.

[0326] For IBC prediction in the case of regular IBC merge, TM merge, or MBVD modes, the weight ratio of IBC prediction to intra-frame prediction is 13:3. The intra-frame prediction modes include the TIMD mode of the current block and the intra-frame prediction mode at the candidate BV. If the second prediction mode in the intra-frame mode is the same as the first prediction mode, it is determined whether the first prediction mode is the PLANA mode. If the first prediction mode is the PLANA mode, the second prediction mode is replaced with the horizontal prediction mode; otherwise, the second prediction mode is replaced with the PLANA mode.

[0327] For the case where the IBC prediction part is in ABVP mode, the weight ratio of IBC prediction and intra-frame prediction is 1:1. The first prediction mode with TIMD mode as the intra-frame prediction mode is obtained. If the predicted mode is horizontal prediction mode, the second prediction mode with PLANAR as the intra-frame prediction mode is obtained. Otherwise, the second prediction mode with horizontal prediction mode as the intra-frame prediction mode is obtained.

[0328] Weighted prediction methods for spatial combinations, such as SGPM, use BV-based prediction values ​​for one or more partitions. For example, the operation process in IBC GPM mode includes: regular merge and TM merge can be applied to the IBC prediction part. For a mode (IPM) with one partition as IBC and one partition as INTRA, the intra-prediction mode (IPM) candidate list is constructed using the same method as inter-frame GPM, and the IPM candidate list size is predefined as 3.

[0329] In practice, the 48 geometric partitioning patterns can be divided into two sets:

[0330] Table 2. Set of First Geometric Partition Patterns

[0331] Table 3. Set of Second Geometric Partition Patterns

[0332] When using IBC GPM, the bitstream contains the following information:

[0333] The flag of the IBC GPM geometric partitioning pattern set indicates whether the first or second geometric partitioning pattern set has been selected;

[0334] Geometric partitioning pattern index;

[0335] The intra-frame partition flag in IBC-GPM indicates whether intra-frame prediction is used for the first sub-partition. The intra-frame prediction portion contains an intra-frame prediction mode index; the IBC prediction portion contains a MEGRE index.

[0336] Decoding prediction process

[0337] The prediction process of BVP technology at the decoding end consists of three steps: obtaining the block vector, obtaining reference region samples, and determining the prediction value. After these steps, the prediction value of the current coded block can be obtained. The flowchart of this process is shown in Figure 24, and the process will be described in detail below.

[0338] Sb.1, Obtaining the block vector

[0339] At the decoding end, the mode used by the current coding block is obtained from the bitstream. If the current coding block uses IBC mode or IntraTMP mode, a block vector list can be constructed according to the method described in S1 above. Then, the index of the best BV used by the current block vector list is parsed from the bitstream, and the best BV is obtained from the block vector list based on the index.

[0340] The acquisition of block vectors in IntraTMP mode is basically the same as the description of step S1.1 above. The difference is that if there are multiple candidates, the index of the best BV used by the current block vector list is parsed from the bitstream, and the best BV is obtained from the block vector list according to the index.

[0341] The acquisition of the block vector in IBC mode is basically the same as described in step S1.2 above. The difference is that in step S1.2.2, the BV is determined based on the information transmitted in the bitstream. The process of determining the BV based on the syntax element information in the bitstream is described in detail below.

[0342] IBC merge mode:

[0343] In IBV merge mode (general_merge_flag[xCb][yCb] is true) and IBC ABVP mode (general_merge_flag[xCb][yCb] is false), the index bvIdx in the candidate list is derived as follows, where general_merge_flag indicates whether it is IBC merge mode:

[0344] bvIdx=general_merge_flag[xCb][yCb]? merge_idx[xCb][yCb]:mvp_l0_flag[xCb][yCb];

[0345] In IBC merge mode, the specific bvL can be obtained from the index bvIdx and the candidate list of block vectors bvCandList:

[0346] bvL[0]=bvCandList[bvIdx][0];

[0347] bvL[1]=bvCandList[bvIdx][1].

[0348] This bvL is the final BV.

[0349] IBC MBVD mode:

[0350] Similar to MMVD in VVC's inter-frame technique, starting from a candidate in the IBC merge list, a candidate is selected from the candidate point set corresponding to the predefined distance and direction set, and its corresponding block vector is used as the final BV.

[0351] For example, in IBC MBVD, the distance set is defined as {1pel, 2pel, 4pel, 8pel, 12pel, 16pel, 24pel, 32pel, 40pel, 48pel, 56pel, 64pel, 72pel, 80pel, 88pel, 96pel, 104pel, 112pel, 120pel, 128pel}, and the BVD directions are two positive and two negative horizontal directions and two positive and two negative vertical directions.

[0352] The base candidates are selected from the top five candidates in the reordered IBC merge list, and the refinement positions (i.e., 20 × 4 candidates) for all possible MBVDs of each base candidate are reordered based on the prediction cost (e.g., SAD) between the template and its reference at each refinement position. Finally, the top 8 refinement positions with the lowest prediction cost are retained.

[0353] The decoder determines the final BV to be used based on the IBC merge list sequence number, the MBVD candidate constructed according to the corresponding candidate, and the MBVD index information transmitted in the bitstream.

[0354] IBC™ merge mode:

[0355] Based on the IBC Merge pattern described above, the obtained bvL can be further refined locally using TM. For example, a search can be performed within a small range centered on bvL, and the optimal BV within that range can be selected as the final BV based on minimizing template matching cost.

[0356] The candidate list for the IBC merge mode is refined using TM (Transformation and Refinement). A specific implementation process is as follows: When constructing candidates, the flipping type is set to no flipping by default; in the IBC merge mode, the transmission syntax element specifies whether to perform TM refinement with full sample precision. The location of the refinement motion vector and the template used in each refinement step must comply with the constraints of the reference region. A search is performed near the pointing position of the candidate, and the optimal position is determined by the SAD (Search Aspect Ratio) between the template of the reference block and the template of the current block. This includes, but is not limited to, the following search methods: the search range is [-8, 8], a diamond search is performed on the entire sample first, searching for eight points near the middle position, as shown in the upper left corner of Figure 25. The maximum number of searches is 375. After the optimal position is determined for the first time, the search continues. In the subsequent search process, 5 points are searched for even-numbered positions and 3 points are searched for odd-numbered positions. Taking the upper left corner of Figure 25 as an example, starting from the red point and going counterclockwise, the order is from index 0 to 7. Specifically, when the red position is selected as the optimal position, the search continues for 5 or 3 points in the purple position.

[0357] After the diamond search process described above, a cross search of integer pixels is performed. This cross search is performed only once. That is, after the diamond search finds the current optimal position, it checks four positions below, to the right, above, and to the left of the current optimal position, which are one sample point away, and updates the final optimal position, thus obtaining the refined BV.

[0358] IBC ABVP mode:

[0359] In this mode, the predicted bvL is obtained by indexing bvIdx and the block vector candidate list bvCandList. The true bvL also needs to be supplemented with the block vector difference (BVD). The generalized process of the IBC ABVP mode is as follows.

[0360] Step 1: Obtain the horizontal and vertical components of BVD, where MvdL0 is the difference in the forward motion vector.

[0361] bvd[0]=MvdL0[xCb][yCb][0];

[0362] bvd[1]=MvdL0[xCb][yCb][1];

[0363] Step 2: Perform a rounding operation on the obtained predicted bvL, where the right shift parameter AmvrShift is used for rounding, and the left shift parameter AmvrShift is used to improve the resolution.

[0364] offset=(AmvrShift==0)? 0:((1<<(AmvrShift-1))-1);

[0365] bvL[0]=Sign(bvL[0])*(((Abs(bvL[0])+offset)>>AmvrShift)< <AmvrShift);

[0366] bvL[1]=Sign(bvL[1])*(((Abs(bvL[1])+offset)>>AmvrShift)< <AmvrShift)。

[0367] Step 3: The derivation of the actual bvL is as follows, and its range needs to be controlled between -217 and 217–1:

[0368] u[0]=(bvL[0]+bvd[0]+218)%218;

[0369] bvL[0]=(u[0]>=217)? (u[0]-218):u[0];

[0370] u[1]=(bvL[1]+bvd[1]+218)%218;

[0371] bvL[1]=(u[1]>=217)? (u[1]-218):u[1].

[0372] In step one, the method for obtaining the BVD can also be derived from syntax elements obtained through other encoding methods. The BVD of IBC ABVP uses units of pixels, integer pixels, or 4 pixels. During encoding, the symbol can be predicted, and the suffix of the binarized exponential Golomb code can also be predicted. Therefore, its syntax elements can be defined by multiple pieces of information related to the BVD value: whether it is 0, the prefix, the symbol, and the suffix. The actual value of the BVD can be obtained by parsing the combination of these pieces of information. A specific implementation example is as follows.

[0373] The BVD (Block Value) indicator is context-coded to indicate whether it is 0. The value of (absolute value - 1) is binarized using the first-order exponent Golomb. The first 5 bins of the EG1 prefix are context-coded, and the remaining prefixes are bypass-coded. The maximum 4 bins of the EG1 suffix use context-coded transmission prediction indices, while the other bins of the EG1 suffix use bypass coding. The two bins of the sign bit use context-coded transmission symbol prediction indices. The figure below shows the prediction process for the suffix bins with one transmission prediction index horizontally and vertically, and the bins with one transmission symbol index horizontally and vertically. The prediction indices for the suffix and symbol are derived by sorting the current block template and the template at the corresponding BV.

[0374] The final derived BV should be within the specified range (coordinate range in rows and columns).

[0375] Sb.2, Obtain reference region samples

[0376] This process is consistent with S2.

[0377] Sb.3, Generate the final predicted value for the current block.

[0378] The current block's mode is parsed in the bitstream, and the predicted value is determined based on the mode. The method for generating the predicted value is the same as that of S3.

[0379] The preceding text provided a detailed description of intra-frame techniques based on Block Value (BV) prediction. Intra-frame techniques based on BV prediction determine a reference region that is strongly correlated with the current block. However, currently, only IntraTMP and IBC techniques utilize the reference region to determine the predicted block for the current block; other intra-frame prediction modes do not fully leverage this correlation.

[0380] To address the aforementioned issues, this application provides an encoding method comprising: determining a first block vector of a current block; determining a first reference region of the current block based on the first block vector; determining a predicted value of the current block based on the first reference region; and determining a residual value of the current block based on the predicted value of the current block.

[0381] This application also provides a decoding method, including: determining a first block vector of a current block; determining a first reference region of the current block based on the first block vector; determining a predicted value of the current block based on the first reference region; and determining a reconstructed value of the current block based on the predicted value of the current block.

[0382] The first reference region determined based on the block vector has a strong correlation with the current block. The embodiments of this application determine the predicted value of the current block based on the first reference region, which helps improve encoding and decoding performance.

[0383] The decoding method provided in the embodiments of this application will be described in detail below with reference to Figure 27.

[0384] Figure 27 is a schematic flowchart of the decoding method provided in an embodiment of this application. The method shown in Figure 27 can be applied to a decoder.

[0385] Referring to Figure 27, in step S2710, the first block vector of the current block is determined. The current block mentioned here can also be called the current encoded block, the current decoded block, or the current predicted block. This current block can correspond to the luma component, i.e., the current block can be the current luma block. Alternatively, the current block can also correspond to the chroma component, i.e., the current block is the current chroma block.

[0386] There are several ways to determine the first block vector. For example, it can be determined based on the index of the block vector parsed from the bitstream. Alternatively, it can be derived based on information from already decoded blocks (in which case there's no need to transmit the block vector index in the bitstream, thus saving bitstream data). Several possible implementation methods are given below.

[0387] For example, the bitstream can be decoded to determine a first index (which can be used to indicate the position of the first block vector in the candidate block vector set); then, the first block vector can be determined from the candidate block vector set according to the first index.

[0388] For example, the bitstream can be decoded to determine the second index (which can be used to indicate the position of the second block vector in the candidate block vector set) and the difference of the first block vector; then, the second block vector can be determined from the candidate block vector set according to the second index; next, the first vector can be determined according to the second block vector and the difference of the first block vector parsed in the bitstream (such as taking the sum of the second block vector and the difference of the first block vector as the first block vector).

[0389] For example, the first block vector can be derived from the block vector of a decoded block. For instance, the first block vector can be determined by weighted summing of the block vectors of adjacent and / or non-adjacent blocks of the current block.

[0390] For example, a candidate block vector set can be constructed, and then a first block vector can be determined based on the cost of the block vectors in the candidate block vector set. This first block vector could be, for example, the block vector with the minimum cost in the candidate block vector set.

[0391] For example, the first vector can be searched within a predefined search range based on template cost.

[0392] The candidate block vector set mentioned above can be, for example, a list of candidate block vectors. There are several ways to determine the candidate block vector set. For instance, a method similar to IntraTMP can be used to search for matching templates of the current block's template within a predefined search area, and then determine the candidate block vectors based on the best-matching template found, thus forming the candidate block vector set. Alternatively, a method similar to IBC Merge or IBC ABVP can be used to construct the candidate block vector set based on one or more of the current block's spatial candidates, historical candidates, or other candidates. The construction methods of the candidate block vector set will be described in detail later with specific examples; they will not be elaborated upon here.

[0393] Referring again to Figure 27, in step S2720, a first reference region for the current block is determined based on the first block vector. The first reference region can be the region pointed to by the first vector block when the current block's position (e.g., the upper left corner) is taken as the starting point. The first reference region may include a first region and / or a second region. The first region has the same size as the current block, and the relative position between the first region and the current block is determined based on the first block vector. For example, the position pointed to by the first block vector from the upper left corner of the current block can be the upper left corner of the first region. In some implementations, the first region can be referred to as the region corresponding to the reference block of the current block.

[0394] The second region can be composed of adjacent reconstructed samples of the first region. For example, the second region may include one or more of the left-side region, top-side region, upper-left region, lower-left region, and upper-right region adjacent to the first region. In some implementations, the second region may be referred to as the template region of the reference block of the current block, or as the region where the reference template of the current block is located. It should be understood that embodiments of this application may include only the first region, only the second region, or both the first region and the second region.

[0395] In one implementation, the dimensions (width and / or height) of the second region can be predefined. For example, the width of the second region can be set to 4 (in pixels or samples), and the height of the second region can be set to 4 (in pixels or samples). Alternatively, in another implementation, the dimensions of the second region can be related to the dimensions of the current block. For example, if the width of the current block is greater than or equal to a certain threshold (e.g., 8), the width of the second region is a first value (e.g., 4); if the width of the current block is less than the threshold, the width of the second region is a second value (e.g., 2). Similarly, if the height of the current block is greater than or equal to a certain threshold (e.g., 8), the height of the second region is a first value (e.g., 4); if the height of the current block is less than the threshold, the height of the second region is a second value (e.g., 2).

[0396] As mentioned earlier, the second region can include one or more of the following adjacent regions: the left region, the top region, the top-left region, the bottom-left region, and the top-right region. The specific regions included in the second region can be determined based on the template type of the current block. For example, if the template type of the current block is L-shaped, the second region can include the left region, the top region, and the top-left region. Similarly, if the template type is Left, the second region can include the left region. And if the template type is Above, the second region can include the top region.

[0397] Let's take Figure 28 as an example. Referring to Figure 28, the block pointed to by the first block vector can be called the reference block, and the first region mentioned earlier can be the region where this reference block is located. Furthermore, the second region is the region where the template of the reference block is located, including the L-shaped template region surrounding the reference block. The size of this region can be defined by the parameters m_leftRefLength and m_topRefLength, for example, m_leftRefLength = uiHeight << 3, m_topRefLength = uiWidth << 3, where uiHeight and uiWidth represent the height and width of the current block, respectively. As can be seen from Figure 28, the reference block and the current block have the same height, uiHeight, and the same width, uiWidth.

[0398] Referring again to Figure 27, in step S2730, the predicted value of the current block is determined based on the first reference region. In some implementations, at least one intra-prediction mode can be determined first based on the first reference region, and then the predicted value of the current block can be determined based on the at least one intra-prediction mode. The at least one intra-prediction mode can be, for example, an intra-prediction mode from a set of intra-prediction modes; that is, at least one intra-prediction mode can be determined from a set of intra-candidate modes based on the first reference region. The at least one intra-prediction mode may include one intra-prediction mode, in which case intra-prediction of the current block can be performed based on the intra-prediction mode to determine the predicted value of the current block. Alternatively, the at least one intra-prediction mode may include multiple intra-prediction modes, in which case intra-prediction of the current block can be performed based on the multiple intra-prediction modes to determine multiple predicted values, and then the multiple predicted values ​​are weighted and fused to determine the predicted value of the current block.

[0399] In step S2740, the reconstructed value of the current block is determined based on the predicted value of the current block. For example, the bitstream can be parsed to determine the residual value of the current block; then, the reconstructed value of the current block is determined based on the predicted value and the residual value of the current block. Exemplarily, the sum of the predicted value and the residual value of the current block can be used to determine the reconstructed value of the current block.

[0400] The first reference region determined based on the block vector has a strong correlation with the current block. The embodiments of this application determine the predicted value of the current block based on the first reference region, which helps improve encoding and decoding performance.

[0401] As mentioned in some of the preceding embodiments, the first block vector can be determined based on a set of candidate block vectors. For example, the first block vector can be selected from the set of candidate block vectors. Alternatively, the first block vector can be derived from the block vectors selected from the candidate block vectors. In such implementations, a set of candidate block vectors can be determined or constructed first. This application does not specifically limit the method of constructing the candidate block vector set. Several possible construction methods are given below.

[0402] In one implementation, the block vectors in the candidate block vector set may include block vectors determined based on the template of the current block. For example, block vectors may be determined based on the matching cost between the template of the current block and reference templates in the reconstructed region surrounding the current block. As an example, a search region (belonging to the reconstructed region surrounding the current block) may be predefined, and then reference templates with a matching cost less than or equal to a threshold with the template of the current block may be searched within the search region. The block vectors corresponding to these reference templates may then be added to the candidate block vector set.

[0403] In another implementation, the block vectors in the candidate block vector set may include one or more of the following: block vectors based on the historical block vector prediction set, block vectors derived based on block vectors already added to the candidate block vector set (such as block vectors determined by a weighted sum of the first two block vectors in the candidate block vector set).

[0404] In another implementation, the block vectors in the candidate block vector set may include one or more of the following: block vectors corresponding to spatially adjacent positions of the current block, and block vectors corresponding to spatially non-adjacent positions of the current block (similar to the construction method of the BV Merge list in IntraTMP).

[0405] For example, you can first add the block vectors corresponding to spatially adjacent positions to the candidate block vector set.

[0406] Assuming the current block's position is (xTbCmp, yTbCmp), and its width and height are nTbW and nTbH respectively, as shown in Figure 8, a candidate block vector set can be constructed based on the five adjacent positions of the current block in space: left (xTbCmp-1, yTbCmp+nTbH-1), top left (xTbCmp-1, yTbCmp-1), top (xTbCmp+nTbW-1, yTbCmp-1), top right (xTbCmp+nTbW, yTbCmp-1), and bottom left (xTbCmp-1, yTbCmp+nTbH).

[0407] For example, it can be checked whether the predicted blocks corresponding to the above five positions use IntraTMP / IBC technology. If IntraTMP / IBC technology is used, then it is checked whether the positions of the current block plus the block vector (BVx, BVy) of this PU, namely the top left (xTbCmp+BVx, yTbCmp), bottom left (xTbCmp+BVx, yTbCmp+nTbH+BVy), top right (xTbCmp+nTbW+BVx, yTbCmp+BVy), and bottom right (xTbCmp+nTbW+BVx, yTbCmp+nTbH+BVy), are within a preset search range (for example, it can be called the IBC search orientation). This preset search range can be the range where the reference CTU is located in Figure 10. When the current CTU size is 256*256, this preset search range can be modified to the range where the reference CTU is located as shown in Figure 11.

[0408] If the block vector corresponding to any of the five positions mentioned above is unavailable, the block vector at the next position can be checked until all positions have been checked. Furthermore, if these positions are available, it can be further determined whether the available block vectors are too similar to existing candidates in the candidate block vector set (identical or similar; similarity can be determined based on a threshold). If they are too similar, they can be excluded from the candidate block vector set; otherwise, they can be added until the length of the candidate block vector set meets the requirements (e.g., the candidate block vector set contains 2 or 6 block vectors).

[0409] After processing the block vectors corresponding to the spatially adjacent positions of the current block, block vectors corresponding to the spatially non-adjacent positions can be added to the candidate block vector set. These spatially non-adjacent positions can be, for example, the 18 positions shown in Figure 8 (positions numbered 6 to 23).

[0410] For example, it can be checked whether the predicted blocks corresponding to these positions use IntraTMP / IBC technology. If IntraTMP / IBC technology is used, then it is checked whether the positions of the current block plus the block vector (BVx, BVy) of this PU, namely the top left (xTbCmp+BVx, yTbCmp), bottom left (xTbCmp+BVx, yTbCmp+nTbH+BVy), top right (xTbCmp+nTbW+BVx, yTbCmp+BVy), and bottom right (xTbCmp+nTbW+BVx, yTbCmp+nTbH+BVy), are within a preset search range (for example, it can be called the IBC search orientation). This preset search range can be the range where the reference CTU is located in Figure 10. When the current CTU size is 256*256, this preset search range can be modified to the range where the reference CTU is located as shown in Figure 11.

[0411] If the block vector corresponding to any of the 18 positions is unavailable, the block vector at the next position can be checked until all positions have been checked. Furthermore, if these positions are available, it can be further determined whether the available block vectors are too similar to existing candidates in the candidate block vector set (identical or similar; similarity can be determined based on a threshold). If they are too similar, they can be excluded from the candidate block vector set; otherwise, they can be added until the length of the candidate block vector set meets the requirements (e.g., the candidate block vector set contains 2 or 6 block vectors).

[0412] It should be noted that the block vectors in the candidate block vector set can be determined based on one or more of the implementation methods mentioned above. For example, the candidate block vector set may include block vectors determined based on the template of the current block, as well as block vectors determined based on the spatial adjacent positions of the current block.

[0413] Step S2730 mentions that the predicted value of the current block can be determined based on the first reference region. There are multiple ways to determine the predicted value of the current block based on the first reference region (or, in other words, there are multiple uses for the first reference region determined based on the block vector mentioned in the embodiments of this application). Several possible implementation methods are given below.

[0414] Implementation Method 1: The cost of using the first reference region to determine the intra-prediction modes in the first intra-prediction mode set.

[0415] In implementation method one, step S2730 may include: determining the prediction values ​​of intra-prediction modes in the first intra-prediction mode set (or intra-prediction mode list, or candidate intra-prediction mode list, for example, the most likely mode list of the current block, the first intra-prediction mode set may include up to 4, 5 or 6 prediction modes) in the first reference region; determining the cost of the intra-prediction modes in the first intra-prediction mode set based on the prediction values ​​of the intra-prediction modes in the first intra-prediction mode set in the first reference region and the reconstructed values ​​of the first reference region; and determining at least one intra-prediction mode from the first intra-prediction mode set based on the costs of the intra-prediction modes in the first intra-prediction mode set.

[0416] The embodiments of this application do not specifically limit the construction method of the prediction mode within the first frame.

[0417] In one implementation, a first intra-frame prediction mode set can be constructed based on the position of the current block. Alternatively, the first intra-frame prediction mode set includes prediction modes determined based on the position of the current block. For example, the first intra-frame prediction mode set includes one or more of the following: prediction modes of neighboring blocks of the current block, and prediction modes of non-neighboring blocks of the current block.

[0418] For example, the intra-frame prediction mode set can be determined based on one or more of the prediction modes of the left adjacent block, the lower left adjacent block, the upper right adjacent block, the upper adjacent block, and the upper left adjacent block of the current block.

[0419] In another implementation, a first intra-frame prediction mode set can be constructed based on the location of the first reference region. Alternatively, the first intra-frame prediction mode set includes prediction modes determined based on the location of the first reference region. For example, the first intra-frame prediction mode set includes one or more of the following: prediction modes of neighboring blocks of the first reference region, prediction modes of non-neighboring blocks of the first reference region, and prediction modes derived based on gradient information of the first reference region.

[0420] In another implementation, the first intra-prediction mode set includes the intra-prediction mode set corresponding to the region pointed to by the first block vector (which may include one or more block vectors).

[0421] In another implementation, a first intra-frame prediction mode set can be constructed based on the position of the current block and the position of the first reference region. Alternatively, the first intra-frame prediction mode set includes prediction modes determined based on the position of the current block and prediction modes determined based on the position of the first reference region.

[0422] As mentioned above, after determining the first intra-prediction mode set, the cost of each intra-prediction mode in the first intra-prediction mode set can be determined based on the predicted values ​​of the intra-prediction modes in the first reference region and the reconstructed values ​​of the first reference region. The cost mentioned here can refer to prediction cost (or prediction distortion cost, such as the SATD of the predicted and reconstructed values). After determining the cost of each intra-prediction mode in the first intra-prediction mode set, at least one intra-prediction mode can be determined from the first intra-prediction mode set based on its cost. For example, one or more of the following can be determined: the prediction mode with the lowest cost (iBestMode), the prediction mode with the second lowest cost (iSecondaryMode), and the non-angle prediction mode (iNonAngMode) in the first intra-prediction mode set.

[0423] After obtaining at least one intra-frame prediction mode, the current block can be predicted based on the at least one intra-frame prediction mode to determine the predicted value of the current block. Several possible methods for determining the predicted value of the current block are given below.

[0424] For example, if the intra-frame prediction mode set contains only one prediction mode (i.e., iBestMode), the prediction result of that prediction mode can be directly used as the prediction value for the current block.

[0425] For example, if the first intra-prediction mode set includes more than one intra-prediction mode, the prediction value of the current block can be determined based on the relationship between uiBestCost (the cost corresponding to iBestMode), uiSecondaryCost (the cost corresponding to iSecondaryMode), and uiNonAngCost (the cost corresponding to iNonAngMode).

[0426] For example, when uiSecondaryCost≥2×uiBestCost, iBestMode is selected for prediction, and weighted fusion is not required. The predicted value of the current block is determined by iBestMode.

[0427] For example, when uiSecondaryCost < 2 × uiBestCost and uiNonAngCost < 2.5 × uiBestCost, a weighted fusion of the three prediction modes can be used to determine the predicted value of the current block. The weighting coefficients weight1, weight2, and weight3 are related to the distortion cost of the three candidate modes, and the specific calculation formulas are as follows:

[0428] In this case, the final prediction value of the current block is obtained by weighted fusion of the three prediction values ​​(pelPred[x][y], pelPred2[x][y], and pelPred3[x][y]).

[0429] For example, when uiSecondaryCost < 2 × uiBestCost and uiNonAngCost ≥ 2.5 × uiBestCost, a dual-mode weighted fusion method can be used to predict the current block's value. In this case, the weights are calculated as follows:

[0430] weight2 = 1 - weight1;

[0431] The two prediction values ​​obtained from iBestMode and iSecondaryMode are used, and then a weighted fusion of these two prediction values ​​is performed to obtain the final prediction value predSamples[x][y] for the current block. The details are as follows:

[0432] predSamples[x][y]=pelPred[x][y]*weight1+pelPred2[x][y]*weight2+pelPred3[x][y]*weight3.

[0433] In some implementations, the first reference region mentioned above can be referred to as the template or template region of the current block. The template of the current block provided by related technologies (such as TIMD) is usually located adjacent to the current block. Unlike related technologies, the first reference region provided in this application embodiment is determined based on the block vector of the current block. Since the first reference region determined based on the block vector has a strong correlation with the current block (e.g., high texture similarity), compared to related technologies, this application embodiment can fully exploit the correlation between the first reference region and the current block, thereby providing more diverse prediction modes. By calculating the cost (e.g., SATD) between the predicted value and the reconstructed value of the first reference region for different candidate modes, this application embodiment can accurately select the prediction mode with the lowest distortion cost, thereby significantly improving prediction accuracy and encoding / decoding efficiency. This technology not only enhances the diversity of intra-frame prediction modes but also effectively improves encoding / decoding performance, especially in regions with high texture similarity, enabling more accurate prediction of the current block's content.

[0434] In some implementations, the prediction method provided in this application embodiment can exist as an independent intra-frame prediction mode. When the intra-frame prediction mode is selected, in addition to carrying the syntax element that selects this prediction mode, the bitstream can also carry information related to the first block vector. For example, the bitstream carries an index (BV_Idx) for determining the first block vector to indicate which block vector in the candidate block vector set is used for the current block.

[0435] Alternatively, in other implementations, the prediction method provided in this application embodiment can be used as a sub-mode of TIMD mode. This sub-mode can be, for example, called block vector-guided TIMD (BVG_TIMD). In this case, the bitstream can carry identification information to indicate whether the sub-mode provided in this application embodiment should be further adopted if the current block adopts TIMD mode. If the identification information indicates that the current block adopts the sub-mode provided in this application embodiment, information related to the first block vector can be carried in the bitstream, such as an index (BV_Idx) for determining the first block vector, to indicate which block vector in the candidate block vector set the current block uses.

[0436] Implementation Method 2: Derive the intra-frame prediction mode of the current block based on the gradient information of the reconstructed samples in the first reference region.

[0437] In implementation method two, step S2730 may include: determining gradient information of at least one reconstructed sample in the first reference region; and determining at least one intra-frame prediction mode based on the gradient information of the at least one reconstructed sample. For example, a gradient histogram may be determined first based on the gradient information of the at least one reconstructed sample; then, at least one intra-frame prediction mode may be determined based on the gradient histogram. As an example, the angle prediction mode corresponding to the highest one or more amplitude values ​​in the gradient histogram may be used as the at least one intra-frame prediction mode.

[0438] The method mentioned above for "determining the gradient information of at least one reconstructed sample in the first reference region" can be implemented using the DIMD technique. For example, the Sober operator can be used to calculate the horizontal and vertical gradients of at least one reconstructed sample.

[0439] To facilitate understanding, a more specific implementation method for implementation method two is given below.

[0440] Within the first reference region, a gradient histogram is constructed to obtain the top 'a' angular patterns (e.g., a can be 5) with the highest amplitude. Then, the spatially adjacent and non-adjacent block vectors determined by the Merge candidate list are compared with the Planar patterns on the first reference template in terms of matching costs to identify a non-angular pattern. Finally, a weighted sum of the angular and non-angular patterns is used to obtain the final prediction.

[0441] One method for calculating weights is:

[0442] First, the gradient direction is calculated from the reconstructed sample in the first reference region:

[0443] Orient = G y / G x

[0444] To reduce computational complexity, direction calculation can be performed using an integer-based scheme based on lookup tables (LUTs):

[0445] x = Floor(Log2(Gx));

[0446] normDiff = ((Gx<<4)>>x)&15;

[0447] x+=(3+(normDiff!=0)?1:0);

[0448] Orient=(Gy*(DivSigTable[normDiff]|8)+(1<<(x-1)))>>x.

[0449] Where DivSigTable

[0016] = {0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.

[0450] For a block of size W×H, if the magnitude of the gradient histogram on the top or left is significantly greater than that on the other side (e.g., the histogram on the top is twice that on the left), the weights are adjusted according to position.

[0451] For example, if the histogram of the upper template is twice that of the left template, then:

[0452] For example, if the histogram of the left template is twice that of the upper template, then:

[0453] Here, wDimd i This represents the weight of DIMD, with Δi pre-set to 10.

[0454] After weighted fusion of the angled and non-angled modes based on the above weights, the final prediction value predSamples[x][y] of the current block can be obtained.

[0455] Implementation Method 3: Use the first reference region to derive the filter, and then determine the predicted value of the current block.

[0456] In implementation method three, step S2730 may include: determining a first filter from a variety of filters based on a first reference region; and determining the predicted value of the current block based on the first filter. The filter mentioned here may refer to an extrapolation filter or other types of filters.

[0457] For example, different types of extrapolation filter models can be applied to the first reference region, as shown in Figure 29. The optimal extrapolation filter is selected based on the matching cost between the predicted and reconstructed values ​​and applied to the reference region to generate predicted values. The final predicted value is predSamples. x,y :

[0458] Among them, w p,x,y RefBlock represents the filter coefficients, where P represents the number of filter coefficients. p,x,y This indicates the first reference region.

[0459] Implementation Method 4: The first reference region is used to determine at least one intra-prediction mode from the second intra-prediction mode set.

[0460] In implementation mode four, step S2730 may include: determining at least one intra-prediction mode from the second intra-prediction mode set based on the first reference region; and determining the prediction value of the current block based on the at least one intra-prediction mode.

[0461] The second intra-prediction mode set mentioned in Implementation Method 4 can include one or more of the following prediction modes: a first intra-prediction mode, which determines the intra-prediction mode of the current block based on the predicted and reconstructed values ​​of the first reference region; a second intra-prediction mode, which determines the intra-prediction mode of the current block based on the gradient information of the reconstructed samples within the first reference region; a third intra-prediction mode, which determines the filter type based on the first reference region, and the filter is used to determine the predicted value of the current block; and a fourth intra-prediction mode, which determines at least one block vector based on the first reference region, and the at least one block vector is used to determine the predicted value of the current block. The first intra-prediction mode can be, for example, a TIMD mode or a mode similar to TIMD. The second intra-prediction mode can be, for example, a DIMD mode or a mode similar to DIMD. The third prediction mode can be, for example, an EIP mode or a mode similar to EIP. The fourth intra-prediction mode can include an IntraTMP mode, an IBC mode, or a mode similar to the above two modes. In addition to the above prediction modes, the prediction modes in the second intra-prediction mode set can also include other arbitrary types of intra-prediction modes, such as angle modes.

[0462] The aforementioned method of determining at least one intra-prediction mode from the second intra-prediction mode set based on the first reference region may include, for example,: determining the prediction value of an intra-prediction mode from the second intra-prediction mode set in the first reference region; determining the cost of an intra-prediction mode from the second intra-prediction mode set based on the prediction value of the intra-prediction mode from the second intra-prediction mode set in the first reference region and the reconstructed value of the first reference region; and determining at least one intra-prediction mode from the second intra-prediction mode set based on the cost of the intra-prediction mode from the second intra-prediction mode set. For example, the prediction mode with the lowest cost in the second intra-prediction mode set can be determined as the prediction mode for the current block.

[0463] Alternatively, in some implementations, the bitstream can be decoded to determine the third index; based on the third index, the intra-prediction mode for the current block can be determined from the second intra-prediction mode set. In this case, the decoder can skip the aforementioned cost calculation and directly determine the intra-prediction mode for the current block from the second intra-prediction mode set based on the third index. Of course, the prediction modes in the second intra-prediction mode set can be prediction modes ordered by cost. In this case, the decoder also needs to calculate the cost of each prediction mode in the second intra-prediction mode set to accurately determine the prediction mode indicated by the first index.

[0464] As mentioned in some previous implementations, the first block vector is determined based on a set of candidate block vectors. This set of candidate block vectors may include at least one candidate block vector, and the order of these candidate block vectors within the set is determined based on the cost of the at least one candidate block vector. During the construction of the candidate block vector set, the block vectors in the set can be ordered by prediction cost. Then, the first block vector is determined by parsing the index (such as the first or second index mentioned earlier) from the bitstream and constructing the ordered set of candidate block vectors.

[0465] This application does not specifically limit the sorting method of block vectors in the candidate block vector set. For example, the block vectors in the candidate block vector set can be sorted based on the template matching cost (such as SAD, SATD, etc.). Alternatively, the region pointed to by the candidate block vector can be predicted using an intra-frame prediction mode, and the block vectors in the candidate block vector set can be sorted by calculating the matching cost between the predicted value and the reconstructed value of that region. As a specific example, for regions pointed to by different BVs, prediction can be performed based on the TIMD prediction mode, and then the matching cost can be calculated based on the predicted value and the reconstructed value of that region, and the block vectors in the candidate block vector set can be sorted based on the matching cost.

[0466] Some of the preceding embodiments mentioned a candidate block vector set and an intra-prediction mode set (such as the first intra-prediction mode set mentioned in Implementation 1 or the second intra-prediction mode set in Implementation 2). In some implementations, both the candidate block vector set and the intra-prediction mode set can belong to a first candidate set. That is, each candidate in the first candidate set can correspond to a combination of a block vector and an intra-prediction mode. As an example, the first candidate set can be a list of combinations of candidate block vectors and candidate intra-prediction modes. In this case, the bitstream can be decoded to determine a fourth index, which can indicate a candidate in the first candidate set. Based on this candidate, the first block vector mentioned above and the intra-prediction mode of the current block can be determined.

[0467] Furthermore, in some implementations, the candidates in the first candidate set can be candidates ranked based on cost. For example, the predicted value of the region pointed to by the block vector can be determined based on the block vector and prediction mode corresponding to each candidate, and the candidates in the first candidate set can be ranked based on the matching cost between the predicted value and the reconstructed value of that region.

[0468] As a concrete example, different regions pointed to by block vectors and multiple prediction modes can be combined to obtain various combined modes, thus forming the aforementioned first candidate set. This first candidate set may include combinations such as BV1+TIMD, BV1+DIMD, BV2+TIMD, and BV2+DIMD. For these combinations, predictions are made using the prediction regions pointed to by the corresponding block vectors of each combination's prediction mode, and the regions are sorted according to the matching cost between the predicted and reconstructed values.

[0469] As mentioned in some of the preceding embodiments, at least one intra-prediction mode can be determined based on a first reference region. Further, the at least one intra-prediction mode may include multiple intra-prediction modes. After determining the multiple intra-prediction modes, the current block can be predicted based on the multiple intra-prediction modes to determine multiple predicted values; then, the multiple predicted values ​​are weighted and fused to determine the predicted value for the current block.

[0470] For example, the multiple intra-prediction modes can be intra-prediction modes in the first or second intra-prediction mode set mentioned above, whose cost is not less than a threshold. This application embodiment does not specifically limit the setting of this threshold; for example, it can be twice the minimum cost corresponding to the prediction mode. Furthermore, when the multiple prediction values ​​are weighted and fused, the weights can be determined based on the costs corresponding to each of the multiple intra-prediction modes.

[0471] For example, the multiple intra-prediction modes can be the top U prediction modes in the first intra-prediction mode set mentioned above, where the intra-prediction mode set in the first intra-prediction mode set is ordered based on its corresponding cost. Furthermore, when these multiple prediction values ​​are weighted and fused, the weights can be determined based on the costs corresponding to each of the multiple intra-prediction modes.

[0472] For example, these multiple intra-prediction modes can be the top U prediction modes in the second intra-prediction mode set mentioned above, where the intra-prediction mode set in the second intra-prediction mode set is ordered based on its corresponding cost. Furthermore, when these multiple prediction values ​​are weighted and fused, the weights can be determined based on the costs corresponding to each of the multiple intra-prediction modes.

[0473] The decoding method provided by the embodiments of this application has been described in detail above with reference to Figure 27. The encoding method provided by the embodiments of this application has been described in detail below with reference to Figure 30.

[0474] Figure 30 is a flowchart illustrating the encoding method provided in an embodiment of this application. The method shown in Figure 30 can be applied to an encoder.

[0475] Referring to Figure 30, in step S3010, the first block vector of the current block is determined. The current block mentioned here can also be called the current coded block or the current predicted block. This current block can correspond to the luma component, meaning it can be the current luma block. Alternatively, it can correspond to the chroma component, meaning it can be the current chroma block.

[0476] The first block vector can be obtained by calculating the cost based on the candidate block vectors in the candidate block vector set. This cost can refer to template matching cost or prediction cost; this embodiment does not specifically limit this. For example, the block vector with the lowest cost can be used as the first block vector. In this case, the index used to determine the first block vector can be transmitted in the bitstream. Alternatively, the first block vector can be derived based on information from already encoded blocks (in this case, there is no need to transmit the block vector index in the bitstream, thus saving bitstream space). Several possible implementation methods are given below.

[0477] For example, a first index (which can be used to indicate the position of the first block vector in the candidate block vector set) is written into the bitstream. This first index can be used to determine the first block vector from the candidate block vector set.

[0478] For example, a second index (which can be used to indicate the position of the second block vector in the candidate block vector set) and the difference between the first block vector can be written into the bitstream. The second index can be used to determine the second block vector from the candidate block vector set. The difference between the second block vector and the first vector can be used to determine the first block vector (e.g., the sum of the differences between the second and first vectors can be used as the first block vector).

[0479] For example, the first block vector can be derived from the block vectors of the coded blocks. For instance, the first block vector can be determined by weighted summation of the block vectors of the current block's adjacent and / or non-adjacent blocks.

[0480] For example, a candidate block vector set can be constructed, and then a first block vector can be determined based on the cost of the block vectors in the candidate block vector set. This first block vector could be, for example, the block vector with the minimum cost in the candidate block vector set.

[0481] For example, the first vector can be searched within a predefined search range based on template cost.

[0482] The candidate block vector set mentioned above can be, for example, a list of candidate block vectors. There are several ways to determine the candidate block vector set. For instance, a method similar to IntraTMP can be used to search for matching templates of the current block's template within a predefined search area, and then determine the candidate block vectors based on the best-matching template found, thus forming the candidate block vector set. Alternatively, a method similar to IBC Merge or IBC ABVP can be used to construct the candidate block vector set based on one or more of the current block's spatial candidates, historical candidates, or other candidates. The construction methods of the candidate block vector set will be described in detail later with specific examples; they will not be elaborated upon here.

[0483] Referring again to Figure 30, in step S3020, a first reference region for the current block is determined based on the first block vector. The first reference region can be the region pointed to by the first vector block when the current block's position (e.g., the upper left corner) is taken as the starting point. The first reference region may include a first region and / or a second region. The first region has the same size as the current block, and the relative position between the first region and the current block is determined based on the first block vector. For example, the position pointed to by the first block vector from the upper left corner of the current block can be the upper left corner of the first region. In some implementations, the first region can be referred to as the region corresponding to the reference block of the current block.

[0484] The second region can be composed of adjacent reconstructed samples of the first region. For example, the second region may include one or more of the left-side region, top-side region, upper-left region, lower-left region, and upper-right region adjacent to the first region. In some implementations, the second region may be referred to as the template region of the reference block of the current block, or as the region where the reference template of the current block is located. It should be understood that embodiments of this application may include only the first region, only the second region, or both the first region and the second region.

[0485] In one implementation, the dimensions (width and / or height) of the second region can be predefined. For example, the width of the second region can be set to 4 (in pixels or samples), and the height of the second region can be set to 4 (in pixels or samples). Alternatively, in another implementation, the dimensions of the second region can be related to the dimensions of the current block. For example, if the width of the current block is greater than or equal to a certain threshold (e.g., 8), the width of the second region is a first value (e.g., 4); if the width of the current block is less than the threshold, the width of the second region is a second value (e.g., 2). Similarly, if the height of the current block is greater than or equal to a certain threshold (e.g., 8), the height of the second region is a first value (e.g., 4); if the height of the current block is less than the threshold, the height of the second region is a second value (e.g., 2).

[0486] As mentioned earlier, the second region can include one or more of the following adjacent regions: the left region, the top region, the top-left region, the bottom-left region, and the top-right region. The specific regions included in the second region can be determined based on the template type of the current block. For example, if the template type of the current block is L-shaped, the second region can include the left region, the top region, and the top-left region. Similarly, if the template type is Left, the second region can include the left region. And if the template type is Above, the second region can include the top region.

[0487] Let's take Figure 28 as an example. Referring to Figure 28, the block pointed to by the first block vector can be called the reference block, and the first region mentioned earlier can be the region where this reference block is located. Furthermore, the second region is the region where the template of the reference block is located, including the L-shaped template region surrounding the reference block. The size of this region can be defined by the parameters m_leftRefLength and m_topRefLength, for example, m_leftRefLength = uiHeight << 3, m_topRefLength = uiWidth << 3, where uiHeight and uiWidth represent the height and width of the current block, respectively. As can be seen from Figure 28, the reference block and the current block have the same height, uiHeight, and the same width, uiWidth.

[0488] Referring again to Figure 30, in step S3030, the predicted value of the current block is determined based on the first reference region. In some implementations, at least one intra-prediction mode can be determined first based on the first reference region, and then the predicted value of the current block can be determined based on the at least one intra-prediction mode. The at least one intra-prediction mode can be, for example, an intra-prediction mode from a set of intra-prediction modes; that is, at least one intra-prediction mode can be determined from a set of intra-candidate modes based on the first reference region. The at least one intra-prediction mode may include one intra-prediction mode, in which case intra-prediction of the current block can be performed based on the intra-prediction mode to determine the predicted value of the current block. Alternatively, the at least one intra-prediction mode may include multiple intra-prediction modes, in which case intra-prediction of the current block can be performed based on the multiple intra-prediction modes to determine multiple predicted values, and then the multiple predicted values ​​are weighted and fused to determine the predicted value of the current block.

[0489] In step S3040, the residual value of the current block is determined based on the predicted value of the current block. For example, the residual value of the current block can be determined based on the original value and the predicted value of the current block.

[0490] The first reference region determined based on the block vector has a strong correlation with the current block. The embodiments of this application determine the predicted value of the current block based on the first reference region, which helps improve encoding and decoding performance.

[0491] As mentioned in some of the preceding embodiments, the first block vector can be determined based on a set of candidate block vectors. For example, the first block vector can be selected from the set of candidate block vectors. Alternatively, the first block vector can be derived from the block vectors selected from the candidate block vectors. In such implementations, a set of candidate block vectors can be determined or constructed first. This application does not specifically limit the method of constructing the candidate block vector set. Several possible construction methods are given below.

[0492] In one implementation, the block vectors in the candidate block vector set may include block vectors determined based on the template of the current block. For example, block vectors may be determined based on the matching cost between the template of the current block and reference templates in the reconstructed region surrounding the current block. As an example, a search region (belonging to the reconstructed region surrounding the current block) may be predefined, and then reference templates with a matching cost less than or equal to a threshold with the template of the current block may be searched within the search region. The block vectors corresponding to these reference templates may then be added to the candidate block vector set.

[0493] In another implementation, the block vectors in the candidate block vector set may include one or more of the following: block vectors based on the historical block vector prediction set, block vectors derived based on block vectors already added to the candidate block vector set (such as block vectors determined by a weighted sum of the first two block vectors in the candidate block vector set).

[0494] In another implementation, the block vectors in the candidate block vector set may include one or more of the following: block vectors corresponding to spatially adjacent positions of the current block, and block vectors corresponding to spatially non-adjacent positions of the current block (similar to the construction method of the BV Merge list in IntraTMP).

[0495] For example, you can first add the block vectors corresponding to spatially adjacent positions to the candidate block vector set.

[0496] Assuming the current block's position is (xTbCmp, yTbCmp), and its width and height are nTbW and nTbH respectively, as shown in Figure 8, a candidate block vector set can be constructed based on the five adjacent positions of the current block in space: left (xTbCmp-1, yTbCmp+nTbH-1), top left (xTbCmp-1, yTbCmp-1), top (xTbCmp+nTbW-1, yTbCmp-1), top right (xTbCmp+nTbW, yTbCmp-1), and bottom left (xTbCmp-1, yTbCmp+nTbH).

[0497] For example, it can be checked whether the predicted blocks corresponding to the above five positions use IntraTMP / IBC technology. If IntraTMP / IBC technology is used, then it is checked whether the positions of the current block plus the block vector (BVx, BVy) of this PU, namely the top left (xTbCmp+BVx, yTbCmp), bottom left (xTbCmp+BVx, yTbCmp+nTbH+BVy), top right (xTbCmp+nTbW+BVx, yTbCmp+BVy), and bottom right (xTbCmp+nTbW+BVx, yTbCmp+nTbH+BVy), are within a preset search range (for example, it can be called the IBC search orientation). This preset search range can be the range where the reference CTU is located in Figure 10. When the current CTU size is 256*256, this preset search range can be modified to the range where the reference CTU is located as shown in Figure 11.

[0498] If the block vector corresponding to any of the five positions mentioned above is unavailable, the block vector at the next position can be checked until all positions have been checked. Furthermore, if these positions are available, it can be further determined whether the available block vectors are too similar to existing candidates in the candidate block vector set (identical or similar; similarity can be determined based on a threshold). If they are too similar, they can be excluded from the candidate block vector set; otherwise, they can be added until the length of the candidate block vector set meets the requirements (e.g., the candidate block vector set contains 2 or 6 block vectors).

[0499] After processing the block vectors corresponding to the spatially adjacent positions of the current block, block vectors corresponding to the spatially non-adjacent positions can be added to the candidate block vector set. These spatially non-adjacent positions can be, for example, the 18 positions shown in Figure 8 (positions numbered 6 to 23).

[0500] For example, it can be checked whether the predicted blocks corresponding to these positions use IntraTMP / IBC technology. If IntraTMP / IBC technology is used, then it is checked whether the positions of the current block plus the block vector (BVx, BVy) of this PU, namely the top left (xTbCmp+BVx, yTbCmp), bottom left (xTbCmp+BVx, yTbCmp+nTbH+BVy), top right (xTbCmp+nTbW+BVx, yTbCmp+BVy), and bottom right (xTbCmp+nTbW+BVx, yTbCmp+nTbH+BVy), are within a preset search range (for example, it can be called the IBC search orientation). This preset search range can be the range where the reference CTU is located in Figure 10. When the current CTU size is 256*256, this preset search range can be modified to the range where the reference CTU is located as shown in Figure 11.

[0501] If the block vector corresponding to any of the 18 positions is unavailable, the block vector at the next position can be checked until all positions have been checked. Furthermore, if these positions are available, it can be further determined whether the available block vectors are too similar to existing candidates in the candidate block vector set (identical or similar; similarity can be determined based on a threshold). If they are too similar, they can be excluded from the candidate block vector set; otherwise, they can be added until the length of the candidate block vector set meets the requirements (e.g., the candidate block vector set contains 2 or 6 block vectors).

[0502] It should be noted that the block vectors in the candidate block vector set can be determined based on one or more of the implementation methods mentioned above. For example, the candidate block vector set may include block vectors determined based on the template of the current block, as well as block vectors determined based on the spatial adjacent positions of the current block.

[0503] Step S3030 mentions that the predicted value of the current block can be determined based on the first reference region. There are multiple ways to determine the predicted value of the current block based on the first reference region (or, in other words, there are multiple uses for the first reference region determined based on the block vector mentioned in the embodiments of this application). Several possible implementation methods are given below.

[0504] Implementation Method 1: The cost of using the first reference region to determine the intra-prediction modes in the first intra-prediction mode set.

[0505] In implementation method one, step S3030 may include: determining the prediction value of the intra-prediction mode in the first intra-prediction mode set (or intra-prediction mode list, or candidate intra-prediction mode list, for example, the most likely mode list of the current block, the first intra-prediction mode set may include up to 4, 5 or 6 prediction modes) in the first reference region; determining the cost of the intra-prediction mode in the first intra-prediction mode set based on the prediction value of the intra-prediction mode in the first reference region and the reconstructed value of the first reference region; and determining at least one intra-prediction mode from the first intra-prediction mode set based on the cost of the intra-prediction mode in the first intra-prediction mode set.

[0506] The embodiments of this application do not specifically limit the construction method of the prediction mode within the first frame.

[0507] In one implementation, a first intra-frame prediction mode set can be constructed based on the position of the current block. Alternatively, the first intra-frame prediction mode set includes prediction modes determined based on the position of the current block. For example, the first intra-frame prediction mode set includes one or more of the following: prediction modes of neighboring blocks of the current block, and prediction modes of non-neighboring blocks of the current block.

[0508] For example, the intra-frame prediction mode set can be determined based on one or more of the prediction modes of the left adjacent block, the lower left adjacent block, the upper right adjacent block, the upper adjacent block, and the upper left adjacent block of the current block.

[0509] In another implementation, a first intra-frame prediction mode set can be constructed based on the location of the first reference region. Alternatively, the first intra-frame prediction mode set includes prediction modes determined based on the location of the first reference region. For example, the first intra-frame prediction mode set includes one or more of the following: prediction modes of neighboring blocks of the first reference region, prediction modes of non-neighboring blocks of the first reference region, and prediction modes derived based on gradient information of the first reference region.

[0510] In another implementation, the first intra-prediction mode set includes the intra-prediction mode set corresponding to the region pointed to by the first block vector (which may include one or more block vectors).

[0511] In another implementation, a first intra-frame prediction mode set can be constructed based on the position of the current block and the position of the first reference region. Alternatively, the first intra-frame prediction mode set includes prediction modes determined based on the position of the current block and prediction modes determined based on the position of the first reference region.

[0512] As mentioned above, after determining the first intra-prediction mode set, the cost of each intra-prediction mode in the first intra-prediction mode set can be determined based on the predicted values ​​of the intra-prediction modes in the first reference region and the reconstructed values ​​of the first reference region. The cost mentioned here can refer to prediction cost (or prediction distortion cost, such as the SATD of the predicted and reconstructed values). After determining the cost of each intra-prediction mode in the first intra-prediction mode set, at least one intra-prediction mode can be determined from the first intra-prediction mode set based on its cost. For example, one or more of the following can be determined: the prediction mode with the lowest cost (iBestMode), the prediction mode with the second lowest cost (iSecondaryMode), and the non-angle prediction mode (iNonAngMode) in the first intra-prediction mode set.

[0513] After obtaining at least one intra-frame prediction mode, the current block can be predicted based on the at least one intra-frame prediction mode to determine the predicted value of the current block. Several possible methods for determining the predicted value of the current block are given below.

[0514] For example, if the intra-frame prediction mode set contains only one prediction mode (i.e., iBestMode), the prediction result of that prediction mode can be directly used as the prediction value for the current block.

[0515] For example, if the first intra-prediction mode set includes more than one intra-prediction mode, the prediction value of the current block can be determined based on the relationship between uiBestCost (the cost corresponding to iBestMode), uiSecondaryCost (the cost corresponding to iSecondaryMode), and uiNonAngCost (the cost corresponding to iNonAngMode).

[0516] For example, when uiSecondaryCost≥2×uiBestCost, iBestMode is selected for prediction, and weighted fusion is not required. The predicted value of the current block is determined by iBestMode.

[0517] For example, when uiSecondaryCost < 2 × uiBestCost and uiNonAngCost < 2.5 × uiBestCost, a weighted fusion of the three prediction modes can be used to determine the predicted value of the current block. The weighting coefficients weight1, weight2, and weight3 are related to the distortion cost of the three candidate modes, and the specific calculation formulas are as follows:

[0518] In this case, the final prediction value of the current block is obtained by weighted fusion of the three prediction values ​​(pelPred[x][y], pelPred2[x][y], and pelPred3[x][y]).

[0519] For example, when uiSecondaryCost < 2 × uiBestCost and uiNonAngCost ≥ 2.5 × uiBestCost, a dual-mode weighted fusion method can be used to predict the current block's value. In this case, the weights are calculated as follows:

[0520] weight2 = 1 - weight1;

[0521] The two prediction values ​​obtained from iBestMode and iSecondaryMode are used, and then a weighted fusion of these two prediction values ​​is performed to obtain the final prediction value predSamples[x][y] for the current block. The details are as follows:

[0522] predSamples[x][y]=pelPred[x][y]*weight1+pelPred2[x][y]*weight2+pelPred3[x][y]*weight3.

[0523] In some implementations, the first reference region mentioned above can be referred to as the template or template region of the current block. The template of the current block provided by related technologies (such as TIMD) is usually located adjacent to the current block. Unlike related technologies, the first reference region provided in this application embodiment is determined based on the block vector of the current block. Since the first reference region determined based on the block vector has a strong correlation with the current block (e.g., high texture similarity), compared to related technologies, this application embodiment can fully exploit the correlation between the first reference region and the current block, thereby providing more diverse prediction modes. By calculating the cost (e.g., SATD) between the predicted value and the reconstructed value of the first reference region for different candidate modes, this application embodiment can accurately select the prediction mode with the lowest distortion cost, thereby significantly improving prediction accuracy and encoding / decoding efficiency. This technology not only enhances the diversity of intra-frame prediction modes but also effectively improves encoding / decoding performance, especially in regions with high texture similarity, enabling more accurate prediction of the current block's content.

[0524] In some implementations, the prediction method provided in this application embodiment can exist as an independent intra-frame prediction mode. When the intra-frame prediction mode is selected, in addition to carrying the syntax element that selects this prediction mode, the bitstream can also carry information related to the first block vector. For example, the bitstream carries an index (BV_Idx) for determining the first block vector to indicate which block vector in the candidate block vector set is used for the current block.

[0525] Alternatively, in other implementations, the prediction method provided in this application embodiment can be used as a sub-mode of TIMD mode. This sub-mode can be, for example, called block vector-guided TIMD (BVG_TIMD). In this case, the bitstream can carry identification information to indicate whether the sub-mode provided in this application embodiment should be further adopted if the current block adopts TIMD mode. If the identification information indicates that the current block adopts the sub-mode provided in this application embodiment, information related to the first block vector can be carried in the bitstream, such as an index (BV_Idx) for determining the first block vector, to indicate which block vector in the candidate block vector set the current block uses.

[0526] Implementation Method 2: Derive the intra-frame prediction mode of the current block based on the gradient information of the reconstructed samples in the first reference region.

[0527] In implementation method two, step S3030 may include: determining gradient information of at least one reconstructed sample in the first reference region; and determining at least one intra-frame prediction mode based on the gradient information of the at least one reconstructed sample. For example, a gradient histogram may be determined first based on the gradient information of the at least one reconstructed sample; then, at least one intra-frame prediction mode may be determined based on the gradient histogram. As an example, the angle prediction mode corresponding to the highest one or more amplitude values ​​in the gradient histogram may be used as the at least one intra-frame prediction mode.

[0528] The method mentioned above for "determining the gradient information of at least one reconstructed sample in the first reference region" can be implemented using the DIMD technique. For example, the Sober operator can be used to calculate the horizontal and vertical gradients of at least one reconstructed sample.

[0529] To facilitate understanding, a more specific implementation method for implementation method two is given below.

[0530] Within the first reference region, a gradient histogram is constructed to obtain the top 'a' angular patterns (e.g., a can be 5) with the highest amplitude. Then, the spatially adjacent and non-adjacent block vectors determined by the Merge candidate list are compared with the Planar patterns on the first reference template in terms of matching costs to identify a non-angular pattern. Finally, a weighted sum of the angular and non-angular patterns is used to obtain the final prediction.

[0531] One method for calculating weights is:

[0532] First, the gradient direction is calculated from the reconstructed sample in the first reference region:

[0533] Orient = G y / G x

[0534] To reduce computational complexity, direction calculation can be performed using an integer-based scheme based on lookup tables (LUTs):

[0535] x = Floor(Log2(Gx));

[0536] normDiff = ((Gx<<4)>>x)&15;

[0537] x+=(3+(normDiff!=0)?1:0);

[0538] Orient=(Gy*(DivSigTable[normDiff]|8)+(1<<(x-1)))>>x.

[0539] Where DivSigTable

[0016] = {0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.

[0540] For a block of size W×H, if the magnitude of the gradient histogram on the top or left is significantly greater than that on the other side (e.g., the histogram on the top is twice that on the left), the weights are adjusted according to position.

[0541] For example, if the histogram of the upper template is twice that of the left template, then:

[0542] For example, if the histogram of the left template is twice that of the upper template, then:

[0543] Here, wDimd i This represents the weight of DIMD, with Δi pre-set to 10.

[0544] After weighted fusion of the angled and non-angled modes based on the above weights, the final prediction value predSamples[x][y] of the current block can be obtained.

[0545] Implementation Method 3: Use the first reference region to derive the filter, and then determine the predicted value of the current block.

[0546] In implementation method three, step S3030 may include: determining a first filter from a variety of filters based on a first reference region; and determining the predicted value of the current block based on the first filter. The filter mentioned here may refer to an extrapolation filter or other types of filters.

[0547] For example, different types of extrapolation filter models can be applied to the first reference region, as shown in Figure 29. The optimal extrapolation filter is selected based on the matching cost between the predicted and reconstructed values ​​and applied to the reference region to generate predicted values. The final predicted value is predSamples. x,y :

[0548] Among them, w p,x,y RefBlock represents the filter coefficients, where P represents the number of filter coefficients. p,x,y This indicates the first reference region.

[0549] Implementation Method 4: The first reference region is used to determine at least one intra-prediction mode from the second intra-prediction mode set.

[0550] In implementation mode four, step S3030 may include: determining at least one intra-prediction mode from the second intra-prediction mode set based on the first reference region; and determining the prediction value of the current block based on the at least one intra-prediction mode.

[0551] The second intra-prediction mode set mentioned in Implementation Method 4 can include one or more of the following prediction modes: a first intra-prediction mode, which determines the intra-prediction mode of the current block based on the predicted and reconstructed values ​​of the first reference region; a second intra-prediction mode, which determines the intra-prediction mode of the current block based on the gradient information of the reconstructed samples within the first reference region; a third intra-prediction mode, which determines the filter type based on the first reference region, and the filter is used to determine the predicted value of the current block; and a fourth intra-prediction mode, which determines at least one block vector based on the first reference region, and the at least one block vector is used to determine the predicted value of the current block. The first intra-prediction mode can be, for example, a TIMD mode or a mode similar to TIMD. The second intra-prediction mode can be, for example, a DIMD mode or a mode similar to DIMD. The third prediction mode can be, for example, an EIP mode or a mode similar to EIP. The fourth intra-prediction mode can include an IntraTMP mode, an IBC mode, or a mode similar to the above two modes. In addition to the above prediction modes, the prediction modes in the second intra-prediction mode set can also include other arbitrary types of intra-prediction modes, such as angle modes.

[0552] The aforementioned method of determining at least one intra-prediction mode from the second intra-prediction mode set based on the first reference region may include, for example,: determining the prediction value of an intra-prediction mode from the second intra-prediction mode set in the first reference region; determining the cost of an intra-prediction mode from the second intra-prediction mode set based on the prediction value of the intra-prediction mode from the second intra-prediction mode set in the first reference region and the reconstructed value of the first reference region; and determining at least one intra-prediction mode from the second intra-prediction mode set based on the cost of the intra-prediction mode from the second intra-prediction mode set. For example, the prediction mode with the lowest cost in the second intra-prediction mode set can be determined as the prediction mode for the current block.

[0553] Alternatively, in some implementations, a third index can be written into the bitstream, which can be used to determine the intra-prediction mode of the current block from the second intra-prediction mode set.

[0554] As mentioned in some previous implementations, the first block vector is determined based on a set of candidate block vectors. This set of candidate block vectors may include at least one candidate block vector, and the order of these candidate block vectors within the set is determined based on the cost of the at least one candidate block vector. During the establishment of the candidate block vector set, the block vectors in the set can be ordered based on the predicted cost.

[0555] This application does not specifically limit the sorting method of block vectors in the candidate block vector set. For example, the block vectors in the candidate block vector set can be sorted based on the template matching cost (such as SAD, SATD, etc.). Alternatively, the region pointed to by the candidate block vector can be predicted using an intra-frame prediction mode, and the block vectors in the candidate block vector set can be sorted by calculating the matching cost between the predicted value and the reconstructed value of that region. As a specific example, for regions pointed to by different BVs, prediction can be performed based on the TIMD prediction mode, and then the matching cost can be calculated based on the predicted value and the reconstructed value of that region, and the block vectors in the candidate block vector set can be sorted based on the matching cost.

[0556] Some of the preceding embodiments mentioned a candidate block vector set and an intra-prediction mode set (such as the first intra-prediction mode set mentioned in Implementation 1 or the second intra-prediction mode set in Implementation 2). In some implementations, both the candidate block vector set and the intra-prediction mode set can belong to a first candidate set. That is, each candidate in the first candidate set can correspond to a combination of a block vector and an intra-prediction mode. As an example, the first candidate set can be a list of combinations of candidate block vectors and candidate intra-prediction modes. In this case, a fourth index can be written into the bitstream, which can indicate a candidate in the first candidate set. Based on this candidate, the first block vector mentioned above and the intra-prediction mode of the current block can be determined.

[0557] Furthermore, in some implementations, the candidates in the first candidate set can be candidates ranked based on cost. For example, the predicted value of the region pointed to by the block vector can be determined based on the block vector and prediction mode corresponding to each candidate, and the candidates in the first candidate set can be ranked based on the matching cost between the predicted value and the reconstructed value of that region.

[0558] As a concrete example, different regions pointed to by block vectors and multiple prediction modes can be combined to obtain various combined modes, thus forming the aforementioned first candidate set. This first candidate set may include combinations such as BV1+TIMD, BV1+DIMD, BV2+TIMD, and BV2+DIMD. For these combinations, predictions are made using the prediction regions pointed to by the corresponding block vectors of each combination's prediction mode, and the regions are sorted according to the matching cost between the predicted and reconstructed values.

[0559] As mentioned in some of the preceding embodiments, at least one intra-prediction mode can be determined based on a first reference region. Further, the at least one intra-prediction mode may include multiple intra-prediction modes. After determining the multiple intra-prediction modes, the current block can be predicted based on the multiple intra-prediction modes to determine multiple predicted values; then, the multiple predicted values ​​are weighted and fused to determine the predicted value for the current block.

[0560] For example, the multiple intra-prediction modes can be intra-prediction modes in the first or second intra-prediction mode set mentioned above, whose cost is not less than a threshold. This application embodiment does not specifically limit the setting of this threshold; for example, it can be twice the minimum cost corresponding to the prediction mode. Furthermore, when the multiple prediction values ​​are weighted and fused, the weights can be determined based on the costs corresponding to each of the multiple intra-prediction modes.

[0561] For example, the multiple intra-prediction modes can be the top U prediction modes in the first intra-prediction mode set mentioned above, where the intra-prediction mode set in the first intra-prediction mode set is ordered based on its corresponding cost. Furthermore, when these multiple prediction values ​​are weighted and fused, the weights can be determined based on the costs corresponding to each of the multiple intra-prediction modes.

[0562] For example, these multiple intra-prediction modes can be the top U prediction modes in the second intra-prediction mode set mentioned above, where the intra-prediction mode set in the second intra-prediction mode set is ordered based on its corresponding cost. Furthermore, when these multiple prediction values ​​are weighted and fused, the weights can be determined based on the costs corresponding to each of the multiple intra-prediction modes.

[0563] The embodiments of this application are described in more detail below with specific examples. It should be noted that the examples below are merely to help those skilled in the art understand the embodiments of this application, and are not intended to limit the embodiments of this application to the specific numerical values ​​or scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or variations based on the given examples, and such modifications or variations also fall within the scope of the embodiments of this application.

[0564] Example 1:

[0565] This example proposes a method called BV-guided intra-frame prediction (BVGP). This prediction mode uses the region pointed to by the block vector or the block vector list as the reference region to construct a set of prediction modes, calculates the reference region prediction value of each candidate prediction mode, calculates the distortion cost (such as SATD) between the reconstructed value and the reference region, and determines the final prediction value of the current coding block based on the magnitude of the distortion cost.

[0566] One feasible method for constructing prediction values ​​is to obtain the best or best and second-best pattern, or the best, second-best, and non-angular pattern, and then calculate the final prediction value for the current coded block. The BV pointing region can be the same as the current block size, or it can be the coded block size after downsampling.

[0567] The prediction process of the proposed method is described in detail below, with differences from existing methods highlighted in red text on a yellow background:

[0568] BVGP inputs: the position of the current coding block (xTbCmp, yTbCmp), the width of the current coding block uiWidth, and the height of the current coding block uiHeight.

[0569] The output of BVGP is the predicted value of the current block, predSamples[x][y], where x = 0..nTbW-1 and y = 0..nTbH-1.

[0570] a. Prediction process at the encoding end:

[0571] The prediction process in BVGP technology at the encoding end consists of three steps: obtaining the block vector, obtaining the reference region pixels, and determining the prediction value. After these steps, the prediction value for the current coding block can be obtained. The flowchart of this process is shown below:

[0572] The following is a detailed introduction:

[0573] S1, Obtain block vector

[0574] Taking the IntraTMP method as an example, in this mode, the same method of searching and selecting candidate regions of BV is used directly as IntraTMP, and the BV with the lowest prediction template cost is selected as the BV used. The block vector list index of the BV is put into the bitstream in an appropriate manner.

[0575] Taking the IBC Merge method as an example, in this mode, a candidate list of BVs is established, and the Idx information of the block vector list where the BV is located is put into the bitstream.

[0576] Taking the IBC ABVP method as an example, in this mode, a candidate list of BVs is established, and the BV to be used is determined at the decoding end based on the Idx information and block vector difference information transmitted in the bitstream.

[0577] S2, Obtain reference area pixels

[0578] A BVGP reference region can be composed of a reference template and a reference block. One type of reference region is shown in Figure 28, which includes a reference block and a reference template (corresponding to the first and second regions mentioned above, respectively).

[0579] A BVGP template can be composed of reconstructed pixels from one or more regions of the coding block, including the top, top right, left, bottom left, and top left. The template size is pre-set; for example, when obtaining the left template, the template width `templateW_size` can be set to 4, and when obtaining the top template, the template height `templateH_size` can be set to 4.

[0580] Specifically, you can determine which part of the pixels to reconstruct based on the template type.

[0581] For example, when the template type is L-shaped, the left, top-left, and top reconstructed pixels of the reference coding block determined by the block vector are obtained; when the template type is Left, only the left k (e.g., k can be 4) columns of reconstructed pixels of the reference coding block are obtained; when the template type is Above, only the top k (e.g., k can be 4) rows of reconstructed pixels of the reference coding block are obtained.

[0582] The reference block obtains the pixels of the region with the same size as the current block, determined by the block vector.

[0583] S3. Determine the predicted value

[0584] BVGP determines the predicted value in two main steps: candidate prediction mode selection and prediction value determination.

[0585] S3.1. Selection of Candidate Prediction Mode

[0586] Input: Luminance position (xCb, yCb), specifying the luminance sample of the top-left corner of the current coding block relative to the top-left corner of the current image; a variable cbWidth, specifying the width of the current coding block in the luminance sample; and a variable cbHeight, specifying the height of the current coding block in the luminance sample. If a prediction mode using multiple block vectors is required, obtain multiple block vectors (bvs); if a prediction mode using only one block vector is required, obtain one block vector (bv) from the block vector candidate list.

[0587] Output: BVGP prediction mode

[0588] The reference region for the current block can be determined by S2. One way to determine the prediction mode for BVGP selection for this reference region is to construct a list of possible prediction modes (methods). First, a list of possible prediction modes (methods) is constructed, containing one or more intra-frame prediction modes (prediction methods). Specific modes (methods) may include, but are not limited to, TIMD, DIMD, EIP, IntraTMP, and IBC. For each prediction mode (method) in the candidate mode (method) list, a predicted value is generated using the reference region. These predicted values ​​are calculated using the prediction of the selected mode (method) and compared with the actual reconstructed values. The candidate modes are ranked by calculating the matching cost (e.g., SAD) between the predicted values ​​and reconstructed values ​​of the reference region. Finally, the prediction mode (method) with the lowest matching cost is selected as the final prediction mode (method) for the current coding block.

[0589] The specific calculation of the predicted value for the reference area can be as follows:

[0590] When traversing the candidate pattern (method) list over the reference region, if the pattern is TIMD, then:

[0591] In predicting TIMD patterns in the reference area, if there is only one candidate TIMD pattern, the prediction result of that pattern is directly adopted without weighted fusion, and the final prediction value is determined by iBestMode.

[0592] If there is more than one candidate TIMD pattern, then the decision on whether to apply weighted fusion is based on the relative values ​​of uiBestCost, uiSecondaryCost, and uiNonAngCost. The specific steps are as follows:

[0593] 1. No weighted fusion:

[0594] When uiSecondaryCost≥2×uiBestCost, the prediction mode is selected as iBestMode, no weighted fusion is required, and the final prediction value is determined by iBestMode.

[0595] 2. Weighted fusion of three modes:

[0596] When uiSecondaryCost < 2 × uiBestCost and uiNonAngCost < 2.5 × uiBestCost, a three-mode weighted fusion is applied. The weighting coefficients weight1, weight2, and weight3 are related to the distortion costs of the three candidate modes, and the specific calculation formulas are as follows:

[0597] In this case, the final predicted value predSamples[x][y] of the reference area is obtained by weighted fusion of the three predicted values ​​(pelPred[x][y], pelPred2[x][y] and pelPred3[x][y]).

[0598] 3. Dual-mode weighted fusion:

[0599] When uiNonAngCost ≥ 2.5 × uiBestCost, a dual-mode weighted fusion is used. In this case, the weights are calculated as follows:

[0600] weight2 = 1 - weight1;

[0601] The two predicted values ​​obtained by iBestMode and iSecondaryMode are weighted and fused to obtain the final predicted value predSamples[x][y] for the reference area.

[0602] When traversing the candidate pattern (method) list over the reference region, if the pattern is the DIMD pattern, then:

[0603] Within the reference region, a gradient histogram is constructed to obtain the 'a' angular patterns (e.g., a can be 5) with the highest amplitude. The spatially adjacent and non-adjacent block vectors determined by the Merge candidate list are then compared with the Planar patterns on the reference template in terms of matching costs to identify a non-angular pattern. The final prediction value is obtained by weighting the angular and non-angular patterns.

[0604] One method for calculating weights is:

[0605] First, the direction is calculated from the gradient:

[0606] Orient = G y / G x ;

[0607] To reduce computational complexity, direction calculation employs an integerization scheme based on lookup tables (LUTs):

[0608] x = Floor(Log2(Gx));

[0609] normDiff = ((Gx<<4)>>x)&15;

[0610] x+=(3+(normDiff!=0)?1:0);

[0611] Orient=(Gy*(DivSigTable[normDiff]|8)+(1<<(x-1)))>>x;

[0612] Here, DivSigTable

[0016] = {0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.

[0613] For a block of size W×H, if the magnitude of the gradient histogram on the top or left is significantly greater than that on the other side (e.g., the histogram on the top is twice that on the left), then the weights are adjusted according to position:

[0614] If the histogram of the upper template is twice that of the left template, then:

[0615] If the histogram of the left template is twice that of the upper template, then:

[0616] Here, wDimd i This represents the weight of DIMD, with Δi pre-set to 10.

[0617] After applying weighted fusion, the final predicted value of the reference region, predSamples[x][y], is obtained.

[0618] When traversing the candidate pattern (method) list over the reference region, if the pattern is the EIP pattern, then:

[0619] Different extrapolation filter models are applied to the reference region, as shown in Figure 29.

[0620] The optimal extrapolation filter is selected based on the matching cost between the predicted and reconstructed values, and applied to the reference region to generate predicted values. The final predicted value is:

[0621] When traversing the candidate mode (method) list over the reference region, if the mode (method) is IntraTMP mode or IBC mode, the method for determining the predicted value can be found in the previous introduction to "Intra-frame Prediction Technology Based on Block Vector".

[0622] For each prediction mode in the candidate mode list, a prediction value is generated using a reference region. These prediction values ​​are calculated using the prediction of the selected mode and compared with the actual reconstructed value. The candidate modes are ranked by calculating the coding cost (such as matching cost SAD, MSE, or coding rate distortion cost RDcost) between the predicted value and the reconstructed value in the reference region. Finally, the prediction mode with the lowest matching cost is selected as the final prediction mode for the current coding block. When the number of candidate modes in the candidate mode list is greater than one, the index of the final prediction mode in the candidate mode list is sent to the bitstream and transmitted to the decoder.

[0623] S3.2 Generate predicted values ​​based on the selected pattern.

[0624] The mode (method) determined by S3.1 generates a prediction value in the current coding block according to the method for generating prediction values ​​in the corresponding mode (method) in S3.1.

[0625] b. Decoding end prediction process

[0626] The BVGP technology's prediction process at the decoding end consists of three steps: obtaining the optimal block vector, obtaining reference region pixels, and generating the final prediction value for the current block. After these steps, the prediction value for the current coded block can be obtained. The flowchart of this process is shown below:

[0627] The following is a detailed introduction:

[0628] Sb.1, Obtaining the block vector

[0629] At the decoding end, the mode used by the current encoded block is obtained from the bitstream, and a block vector list is constructed according to the method in S1. Then, the index of the BV used by the current block vector list is parsed in the bitstream, and the BV is retrieved from the block vector list according to the index.

[0630] Taking the IntraTMP method as an example, in this mode, the same method as IntraTMP is used to search and determine the candidate region of BV, and the BV to be used is determined based on the search results and / or the corresponding syntax elements transmitted in the bitstream.

[0631] Taking the IBC Merge method as another example, in this mode, a candidate BV list is established, and the BV to be used is determined based on the Idx information transmitted in the bitstream.

[0632] Taking the IBC ABVP method as an example, in this mode, a candidate BV list is established, and the BV to be used is determined based on the Idx information and block vector difference information transmitted in the bitstream.

[0633] Sb.2, Obtain reference area pixels

[0634] This process is consistent with S2 in this example.

[0635] Sb.3, Determine the predicted value

[0636] The current block's mode is parsed in the bitstream, and the predicted value of the current block is determined based on the mode. The method for determining the predicted value is the same as S3 in this patent.

[0637] BVGP mode can exist as a mode alongside other intra prediction modes. It is an optional intra prediction mode alongside DIMD, TIMD, EIP, and other different intra prediction modes. When selected, in addition to providing the syntax information for selecting this mode, information about the BV used and the specific prediction method used must also be provided. For example, a BV_Idx syntax element is used to indicate which BV in the candidate BV list is being used; and a Mod_Idx syntax element is used to indicate which prediction mode (prediction method) among the candidate prediction modes (prediction methods) is being used.

[0638] This example effectively improves the mode diversity of intra-frame prediction and enhances prediction accuracy by using reference block regions pointed to by block vectors, which have higher similarity to the current block than traditional template matching methods. The core idea of ​​this scheme is to construct a list of block vectors and calculate the distortion cost of the prediction mode using the reference block regions located by the block vectors, thereby selecting the optimal prediction mode. Since the reference block is determined by the block vectors and is more similar to the texture features of the current block, the prediction mode derived from the reference block can more accurately reflect the directionality of the current block, thus improving coding performance.

[0639] Example 2:

[0640] TIMD is an intra-frame prediction mode that can be used for luma or chroma. The encoder and decoder use the same operation to obtain the final prediction value. Specifically, for an intra-frame prediction mode in a given set of prediction modes (e.g., the MPM list), a template prediction value is calculated for the template region of the current coding block based on that mode. The template prediction value and the template reconstructed value are compared to obtain the prediction distortion (e.g., the sum of absolute transform differences (SATD)). Based on the magnitude of the prediction distortion, a certain number (e.g., one or two) of candidate prediction modes are selected. Based on the magnitude of the SATD, the best or best and second-best mode or the best, second-best and non-angular mode are obtained to calculate the final prediction value of the current coding block.

[0641] During the TIMD prediction process, the region pointed to by the block vector with the same size as the current CU can be used as the TIMD template. The prediction distortion cost (such as SATD) of the current template's predicted value and the reconstructed value is calculated using the prediction mode set. Based on the size of SATD, the best or best and second-best mode or best, second-best and non-angle mode is obtained to calculate the final prediction value of the current coding block.

[0642] The prediction process of the proposed method is described in detail below, with differences from existing methods highlighted in red text on a yellow background:

[0643] The inputs to TIMD are: the position of the current encoding block (xTbCmp, yTbCmp), the width of the current encoding block uiWidth, and the height of the current encoding block uiHeight.

[0644] The output of TIMD is the prediction values ​​of the current block, predSamples[x][y], where x = 0..nTbW-1 and y = 0..nTbH-1.

[0645] The TIMD prediction process consists of five steps: determining the current template type and size, the current block size, obtaining the block vector, obtaining reference region pixels, obtaining TIMD candidate prediction modes, and generating the final prediction value for the current block. Through these steps, the prediction value for the current coded block can be obtained.

[0646] The following is a detailed introduction:

[0647] S1. Determine the current template type, size, and current block size.

[0648] TIMD technology can utilize the upper adjacent reconstructed pixel region and the left adjacent reconstructed pixel region as template regions. The template type (eTempType) is determined based on the position of the current coding block. For example:

[0649] If the adjacent reconstructed pixels on the left and top are unavailable, then eTempType is NO_NEIGHBOR, indicating a region without a template.

[0650] If the adjacent reconstructed pixels on the left and top are available, then eTempType is LEFT_ABOVE_NEIGHBOR, and the template area is shown in Figure 31(a).

[0651] If only the left adjacent reconstructed pixels are available, then eTempType is LEFT_NEIGHBOR, and the template area is shown in Figure 31(b).

[0652] If only the adjacent reconstructed pixels above are available, then eTempType is ABOVE_NEIGHBOR, and the template area is shown in (c) of Figure 31.

[0653] The template size used in TIMD technology is related to the size of the current coding block. For example:

[0654] If the height (uiHeight) of the current encoding block is greater than or equal to 8, the template height (iTempHeight) is 4; otherwise, the template height is 2.

[0655] If the width (uiWidth) of the current encoding block is greater than or equal to 8, the template width (iTempWidth) is 4; otherwise, the template width is 2.

[0656] or:

[0657] If the height (uiHeight) of the current encoding block is greater than or equal to 8, the template height (iTempHeight) is 8; otherwise, the template height is 4.

[0658] If the width (uiWidth) of the current encoding block is greater than or equal to 8, the template width (iTempWidth) is 8; otherwise, the template width is 4.

[0659] Get the current CU's width and height, i.e., uiWidth and uiHeight.

[0660] S2, Obtain block vector

[0661] Similar to the main approach, this method can also have multiple sources for BV. Here, we will use the IntraTMP Merge list construction method as an example:

[0662] The spatially adjacent and non-adjacent CUs of the current CU can be used to construct the merge list of the block vector (BV). The process of constructing this merge list is described in detail below.

[0663] S2.1, Add BV at adjacent spatial positions.

[0664] Use the five adjacent positions in the current block space: left (xTbCmp-1, yTbCmp+nTbH-1), top left (xTbCmp-1, yTbCmp-1), top (xTbCmp+nTbW-1, yTbCmp-1), top right (xTbCmp+nTbW, yTbCmp-1), and bottom left (xTbCmp-1, yTbCmp+nTbH) (as shown in Figure 8).

[0665] Example of the construction process: Check whether the PUs corresponding to these positions use IntraTMP / IBC technology. If so, check whether the following positions of the current CU plus the BV of this PU are within the IBC search range: top left (xTbCmp+BVx, yTbCmp), bottom left (xTbCmp+BVx, yTbCmp+nTbH+BVy), top right (xTbCmp+nTbW+BVx, yTbCmp+BVy), and bottom right (xTbCmp+nTbW+BVx, yTbCmp+nTbH+BVy). The IBC search range can be represented as shown in Figure 10. When the current CTU size is 256*256, its search range is modified to the area shown in Figure 11.

[0666] If unavailable, check the BV at the next location until all locations have been checked. If these locations are available, check if the available BV information is too similar to an existing item in the IntraTMP-Merge list (same or similar, similarity is determined by a threshold). If too similar, do not add it to the list; otherwise, add it to the list until the list length meets the requirement.

[0667] S2.2, Add BV at non-adjacent locations in space.

[0668] Use 18 non-adjacent locations (as shown in Figure 8).

[0669] Example of the construction process: Check whether the PUs corresponding to these locations use IntraTMP / IBC technology. If so, check the availability of their stored BV information (availability includes, but is not limited to, whether each location after adding the BV of this PU to the current CU is within the IBC search range). The IBC search range can be represented as shown in Figure 10. When the current CTU size is 256*256, its search range is modified to the range shown in Figure 11.

[0670] If unavailable, check the BV at the next location until all locations have been checked. If these locations are available, check if the available BV information is too similar to existing items in the IntraTMP-Merge list (same or similar, similarity is determined by a threshold). If too similar, do not add it to the list; otherwise, add it to the list until the list length meets the requirement or all locations have been checked, thus completing the construction of the IntraTMP-Merge list.

[0671] S3, Obtain reference area pixels

[0672] As shown in Figure 32, in related technologies, the reference regions that can be utilized in the TIMD mode are the adjacent reconstructed pixel regions on the left and top of the template. Let the length of the adjacent reconstructed pixel region on the left be m_leftRefLength, and the length of the adjacent reconstructed pixel region on the top be m_topRefLength, then:

[0673] m_leftRefLength=(uiHeight+iTempHeight)<<3;

[0674] m_topRefLength=(uiWidth+iTempWidth)<<3;

[0675] Unlike TIMD techniques in related technologies, as shown in Figure 28, the BVG_TIMD technique can utilize the reference regions adjacent to the left and top of the reference block for reconstructed pixels. Let the length of the left adjacent reconstructed pixel region be m_leftRefLength, and the length of the top adjacent reconstructed pixel region be m_topRefLength, then:

[0676] m_leftRefLength=uiHeight<<3 m_topRefLength=uiWidth<<3

[0677] S4. Obtain TIMD candidate prediction patterns

[0678] To obtain TIMD candidate prediction modes, a set of prediction modes is first needed. Then, the set of prediction modes is traversed, and prediction values ​​are calculated for the template regions. By calculating the prediction distortion cost, a TIMD candidate prediction mode is selected for the current coding block.

[0679] S4.1 Obtain the set of prediction patterns

[0680] TIMD technology selects a set of prediction modes based on the prediction modes of the adjacent blocks (left, bottom left, top right, top, top left) of the current coding block, and / or the prediction modes of the region pointed to by the BV. Specifically:

[0681] If there is no angular prediction pattern in the adjacent block and / or the area pointed to by the BV, the prediction pattern set includes the Planar pattern and the DC pattern.

[0682] If an angle prediction pattern exists in the adjacent block and / or the area pointed to by the BV, the prediction pattern set includes the MPM list and the wide-angle prediction pattern. If there is no DC / HOR / VER pattern in the MPM column, it is added to the end of the MPM list.

[0683] S4.2 Obtaining TIMD candidate prediction patterns

[0684] In the original TIMD mode, the various modes in the candidate mode list are traversed in the template region, and the mode with the smallest prediction distortion cost (iBestMode), the mode with the second smallest prediction distortion cost (iSecondaryMode), and the non-angle prediction mode (iNonAngMode) are obtained based on the prediction distortion cost.

[0685] If it is BVG_TIMD mode, then traverse the candidate mode list in the reference block region pointed to by BV. Obtain the mode with the minimum prediction distortion cost (iBestMode), the mode with the second minimum prediction distortion cost (iSecondaryMode), and the non-angle prediction mode (iNonAngMode).

[0686] Let the prediction distortion costs of iBestMode, iSecondaryMode, and iNonAngMode be uiBestCost, uiSecondaryCost, and uiNonAngCost, respectively.

[0687] If the TIMD fusion conditions are met, calculate the TIMD fusion weights.

[0688] S5. Generate the final predicted value for the current block.

[0689] In predicting TIMD patterns in the reference area, if there is only one candidate TIMD pattern, the prediction result of that pattern is directly adopted without weighted fusion, and the final prediction value is determined by iBestMode.

[0690] If there is more than one candidate TIMD pattern, then the decision on whether to apply weighted fusion is based on the relative values ​​of uiBestCost, uiSecondaryCost, and uiNonAngCost. The specific steps are as follows:

[0691] 1. No weighted fusion:

[0692] When uiSecondaryCost≥2×uiBestCost, the prediction mode is selected as iBestMode, no weighted fusion is required, and the final prediction value is determined by iBestMode.

[0693] 2. Weighted fusion of three modes:

[0694] When uiSecondaryCost < 2 × uiBestCost and uiNonAngCost < 2.5 × uiBestCost, a three-mode weighted fusion is applied. The weighting coefficients weight1, weight2, and weight3 are related to the distortion costs of the three candidate modes, and the specific calculation formulas are as follows:

[0695] In this case, the final predicted value predSamples[x][y] of the reference area is obtained by weighted fusion of the three predicted values ​​(pelPred[x][y], pelPred2[x][y] and pelPred3[x][y]).

[0696] 3. Dual-mode weighted fusion:

[0697] When uiNonAngCost ≥ 2.5 × uiBestCost, a dual-mode weighted fusion is used. In this case, the weights are calculated as follows:

[0698] The two predicted values ​​obtained by iBestMode and iSecondaryMode are weighted and fused to obtain the final predicted value predSamples[x][y] for the reference area.

[0699] Specifically as follows:

[0700] predSamples[x][y]=pelPred[x][y]*weight1+pelPred2[x][y]*weight2+pelPre d3[x][y]*weight3;

[0701] In the bitstream, the BVG_TIMD mode can be used as a sub-mode of the TIMD mode. The bitstream uses a flag to indicate whether it is the BVG_TIMD sub-mode when it is the TIMD mode, and gives the information of the BV used in the sub-mode, such as a BV_Idx syntax element to indicate which BV in the candidate BV list is used.

[0702] The BVG_TIMD mode can also exist as a mode alongside other intra-prediction modes. Similar to the main scheme, it is an optional intra-prediction mode alongside DIMD, TIMD, EIP, and other intra-prediction modes. When it is selected, in addition to providing the syntax information for selecting this mode, information about the BV used must also be provided, such as a BV_Idx syntax element to indicate which BV in the candidate BV list is being used.

[0703] The method embodiments of this application have been described in detail above with reference to Figures 1 to 32. The apparatus embodiments of this application will be described in detail below with reference to Figures 33 to 36. It should be understood that the descriptions of the method embodiments correspond to the descriptions of the apparatus embodiments; therefore, any parts not described in detail can be referred to the preceding method embodiments.

[0704] Figure 33 is a schematic diagram of the structure of a decoder provided in one embodiment of this application. The decoder 3300 in Figure 33 includes a first determining unit 3310, a second determining unit 3320, a third determining unit 3330, and a fourth determining unit 3340. The first determining unit 3310 is configured to determine a first block vector of the current block; the second determining unit 3320 is configured to determine a first reference region of the current block based on the first block vector; the third determining unit 3330 is configured to determine a predicted value of the current block based on the first reference region; and the fourth determining unit 3340 is configured to determine a reconstructed value of the current block based on the predicted value of the current block.

[0705] In some implementations, the third determining unit 3330 is further configured to: determine at least one intra-frame prediction mode based on the first reference region; and determine the prediction value of the current block based on the at least one intra-frame prediction mode.

[0706] In some implementations, the third determining unit 3330 is further configured to: determine the prediction value of an intra-prediction mode in the first intra-prediction mode set in the first reference region; determine the cost of an intra-prediction mode in the first intra-prediction mode set based on the prediction value of the intra-prediction mode in the first reference region and the reconstructed value of the first reference region; and determine the at least one intra-prediction mode from the first intra-prediction mode set based on the cost of the intra-prediction mode in the first intra-prediction mode set.

[0707] In some implementations, the first intra-frame prediction mode set includes prediction modes determined based on the position of the current block.

[0708] In some implementations, the prediction mode determined based on the position of the current block includes one or more of the following: prediction modes of adjacent blocks of the current block, and prediction modes of non-adjacent blocks of the current block.

[0709] In some implementations, the first intra-frame prediction mode set includes prediction modes determined based on the position of the first reference region.

[0710] In some implementations, the prediction mode determined based on the position of the first reference region includes one or more of the following: a prediction mode for reconstructed blocks in the first reference region, a prediction mode for adjacent blocks in the first reference region, a prediction mode for non-adjacent blocks in the first reference region, and a prediction mode derived based on gradient information of the first reference region.

[0711] In some implementations, the at least one prediction mode includes one or more of the following:

[0712] The prediction mode with the lowest cost in the first intra-frame prediction mode set;

[0713] The prediction mode with the second lowest cost in the first intra-frame prediction mode set;

[0714] The non-angular prediction modes in the first intra-frame prediction mode set.

[0715] In some implementations, the third determining unit 3330 is further configured to: determine gradient information of at least one reconstructed sample in the first reference region; and determine the at least one intra-frame prediction mode based on the gradient information of the at least one reconstructed sample.

[0716] In some implementations, the third determining unit 3330 is further configured to: determine a gradient histogram based on the gradient information of the at least one reconstructed sample; and determine the at least one intra-frame prediction mode based on the gradient histogram.

[0717] In some implementations, the third determining unit 3330 is further configured to: determine a first filter from a plurality of filters based on the first reference region; and determine the predicted value of the current block based on the first filter.

[0718] In some implementations, the first reference region includes one or more of the following:

[0719] A first region, the first region having the same size as the current block, and the relative position between the first region and the current block being determined based on the vector of the first block;

[0720] The second region includes one or more of the following: the left-side region, the upper-side region, the upper-left region, the lower-left region, and the upper-right region adjacent to the first region.

[0721] In some implementations, the first determining unit 3310 is further configured to: decode the bitstream, determine a first index, and determine the first block vector from the candidate block vector set according to the first index.

[0722] In some implementations, the first determining unit 3310 is further configured to: decode the bitstream, determine a second index and a first block vector difference; determine a second block vector from a set of candidate block vectors based on the second index; and determine the first block vector based on the difference between the second block vector and the first block vector.

[0723] In some implementations, the first block vector is determined based on a candidate block vector set, which includes one or more of the following: block vectors determined based on the matching cost between the template of the current block and a reference template in the reconstructed region surrounding the current block; block vectors corresponding to spatially adjacent positions of the current block; block vectors corresponding to spatially non-adjacent positions of the current block; block vectors based on a historical block vector prediction set; and block vectors derived based on block vectors already added to the candidate block vector set.

[0724] In some implementations, the first determining unit 3310 is further configured to: determine the first block vector based on the information of the decoded block.

[0725] In some implementations, the third determining unit 3330 is further configured to: determine at least one intra-prediction mode from the second intra-prediction mode set based on the first reference region; and determine the prediction value of the current block based on the at least one intra-prediction mode.

[0726] In some implementations, the second intra-prediction mode set includes one or more of the following prediction modes: a first intra-prediction mode, which determines the intra-prediction mode of the current block based on the predicted and reconstructed values ​​of the first reference region; a second intra-prediction mode, which determines the intra-prediction mode of the current block based on the gradient information of the reconstructed samples in the first reference region; a third intra-prediction mode, which determines the type of filter based on the first reference region, the filter being used to determine the predicted value of the current block; and a fourth intra-prediction mode, which determines at least one block vector based on the first reference region, the at least one block vector being used to determine the predicted value of the current block.

[0727] In some implementations, the third determining unit 3330 is further configured to: determine the prediction value of an intra-prediction mode in the second intra-prediction mode set in the first reference region; determine the cost of an intra-prediction mode in the second intra-prediction mode set based on the prediction value of the intra-prediction mode in the second intra-prediction mode set in the first reference region and the reconstructed value of the first reference region; and determine the at least one intra-prediction mode from the second intra-prediction mode set based on the cost of the intra-prediction mode in the second intra-prediction mode set.

[0728] In some implementations, the decoder 3300 further includes: a decoding unit configured to decode the bitstream, determining a third index; and determining the intra-prediction mode of the current block from a second intra-prediction mode set based on the third index.

[0729] In some implementations, the candidate block vector set includes at least one candidate block vector, and the order of the at least one candidate block vector in the candidate block vector set is determined based on the cost of the at least one candidate block vector.

[0730] In some implementations, the cost of the at least one candidate block vector is determined based on the predicted and reconstructed values ​​of at least one reconstructed region, and the relative position between the at least one reconstructed region and the current block is determined based on the at least one candidate block vector.

[0731] In some implementations, the first determining unit 3310 is further configured to: decode the bitstream and determine a fourth index; determine the intra-prediction mode of the first block vector and the current block from a first candidate set according to the fourth index; wherein each candidate in the first candidate set corresponds to a combination of a block vector and an intra-prediction mode.

[0732] In some implementations, the first determining unit 3310 is further configured to: predict the current block according to the at least one intra-frame prediction mode, determine at least one prediction value; and perform weighted fusion on the at least one prediction value to determine the prediction value of the current block.

[0733] In some implementations, the at least one intra-frame prediction mode is a prediction mode in the first intra-frame prediction mode set whose cost is less than a first threshold; or, the at least one intra-frame prediction mode is the top U prediction modes in the first intra-frame prediction mode set, wherein the prediction modes in the first intra-frame prediction mode set are ordered based on their respective costs.

[0734] Understandably, in the embodiments of this application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular one. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional module.

[0735] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0736] Therefore, embodiments of this application provide a computer-readable storage medium for use with a decoder, wherein the computer-readable storage medium stores a computer program that, when executed by a processor, implements the decoding method described in the first embodiment.

[0737] Based on the composition of the decoder 3300 described above and the computer-readable storage medium, refer to Figure 34, which shows a schematic diagram of the specific hardware structure of the decoder 3400 provided in this embodiment of the application. As shown in Figure 34, the decoder 3400 may include: a communication interface 3410, a memory 3420, and a processor 3430; the various components are coupled together through a bus system 3440. It is understood that the bus system 3440 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 3440 also includes a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as bus system 3440 in Figure 34.

[0738] The communication interface 3410 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;

[0739] Memory 3420 is used to store computer programs;

[0740] Processor 3430, when running the computer program, performs the following:

[0741] Determine the first block vector of the current block;

[0742] The first reference region of the current block is determined based on the first block vector;

[0743] The predicted value of the current block is determined based on the first reference region;

[0744] The reconstruction value of the current block is determined based on the predicted value of the current block.

[0745] It is understood that the memory 3420 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 3420 of the systems and methods described in this application is intended to include, but is not limited to, these and any other suitable types of memory.

[0746] The processor 3430 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 3430 or by software instructions. The processor 3430 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 3420. Processor 3430 reads the information in memory 3420 and completes the steps of the above method in conjunction with its hardware.

[0747] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0748] Alternatively, as another embodiment, the processor 3430 is also configured to execute the decoding method described in the foregoing embodiments when running the computer program.

[0749] Figure 35 is a schematic diagram of an encoder provided in one embodiment of this application. The encoder 3500 of Figure 35 includes a first determining unit 3510, a second determining unit 3520, a third determining unit 3530, and a fourth determining unit 3540. The first determining unit 3510 is configured to determine a first block vector of the current block; the second determining unit 3520 is configured to determine a first reference region of the current block based on the first block vector; the third determining unit 3530 is configured to determine a predicted value of the current block based on the first reference region; and the fourth determining unit 3540 is configured to determine a residual value of the current block based on the predicted value of the current block.

[0750] In some implementations, the third determining unit 3530 is further configured to: determine at least one intra-prediction mode based on the first reference region; and determine the prediction value of the current block based on the at least one intra-prediction mode.

[0751] In some implementations, the third determining unit 3530 is further configured to: determine the prediction value of an intra-prediction mode in the first intra-prediction mode set in the first reference region; determine the cost of an intra-prediction mode in the first intra-prediction mode set based on the prediction value of the intra-prediction mode in the first reference region and the reconstructed value of the first reference region; and determine the at least one intra-prediction mode from the first intra-prediction mode set based on the cost of the intra-prediction mode in the first intra-prediction mode set.

[0752] In some implementations, the first intra-frame prediction mode set includes prediction modes determined based on the position of the current block.

[0753] In some implementations, the prediction mode determined based on the position of the current block includes one or more of the following: prediction modes of adjacent blocks of the current block, and prediction modes of non-adjacent blocks of the current block.

[0754] In some implementations, the first intra-frame prediction mode set includes prediction modes determined based on the position of the first reference region.

[0755] In some implementations, the prediction mode determined based on the position of the first reference region includes one or more of the following: a prediction mode for reconstructed blocks in the first reference region, a prediction mode for adjacent blocks in the first reference region, a prediction mode for non-adjacent blocks in the first reference region, and a prediction mode derived based on gradient information of the first reference region.

[0756] In some implementations, the at least one prediction mode includes one or more of the following:

[0757] The prediction mode with the lowest cost in the first intra-frame prediction mode set;

[0758] The prediction mode with the second lowest cost in the first intra-frame prediction mode set;

[0759] The non-angular prediction modes in the first intra-frame prediction mode set.

[0760] In some implementations, the third determining unit 3530 is further configured to: determine gradient information of at least one reconstructed sample in the first reference region; and determine the at least one intra-frame prediction mode based on the gradient information of the at least one reconstructed sample.

[0761] In some implementations, the third determining unit 3530 is further configured to: determine a gradient histogram based on the gradient information of the at least one reconstructed sample; and determine the at least one intra-frame prediction mode based on the gradient histogram.

[0762] In some implementations, the third determining unit 3530 is further configured to: determine a first filter from a plurality of filters based on the first reference region; and determine the predicted value of the current block based on the first filter.

[0763] In some implementations, the first reference region includes one or more of the following:

[0764] A first region, the first region having the same size as the current block, and the relative position between the first region and the current block being determined based on the vector of the first block;

[0765] The second region includes one or more of the following: the left-side region, the upper-side region, the upper-left region, the lower-left region, and the upper-right region adjacent to the first region.

[0766] In some implementations, the encoder 3500 further includes an encoding unit configured to write a first index into the bitstream, the first index being used to determine the first block vector from a set of candidate block vectors.

[0767] In some implementations, the encoder 3500 further includes an encoding unit that writes a second index and a first block vector difference into the bitstream, wherein the second index is used to determine a second block vector from a set of candidate block vectors, and the second block vector and the first block vector difference are used to determine the first block vector.

[0768] In some implementations, the first block vector is determined based on a candidate block vector set, which includes one or more of the following: block vectors determined based on the matching cost between the template of the current block and a reference template in the reconstructed region surrounding the current block; block vectors corresponding to spatially adjacent positions of the current block; block vectors corresponding to spatially non-adjacent positions of the current block; block vectors based on a historical block vector prediction set; and block vectors derived based on block vectors already added to the candidate block vector set.

[0769] In some implementations, the first determining unit 3310 is further configured to: determine the first block vector based on information of the encoded block.

[0770] In some implementations, the third determining unit 3530 is further configured to: determine at least one intra-prediction mode from the second intra-prediction mode set based on the first reference region; and determine the prediction value of the current block based on the at least one intra-prediction mode.

[0771] In some implementations, the second intra-prediction mode set includes one or more of the following prediction modes: a first intra-prediction mode, which determines the intra-prediction mode of the current block based on the predicted and reconstructed values ​​of the first reference region; a second intra-prediction mode, which determines the intra-prediction mode of the current block based on the gradient information of the reconstructed samples in the first reference region; a third intra-prediction mode, which determines the type of filter based on the first reference region, the filter being used to determine the predicted value of the current block; and a fourth intra-prediction mode, which determines at least one block vector based on the first reference region, the at least one block vector being used to determine the predicted value of the current block.

[0772] In some implementations, the third determining unit 3530 is further configured to: determine the prediction value of an intra-prediction mode in the second intra-prediction mode set in the first reference region; determine the cost of an intra-prediction mode in the second intra-prediction mode set based on the prediction value of the intra-prediction mode in the second intra-prediction mode set in the first reference region and the reconstructed value of the first reference region; and determine the at least one intra-prediction mode from the second intra-prediction mode set based on the cost of the intra-prediction mode in the second intra-prediction mode set.

[0773] In some implementations, the encoder 3500 further includes an encoding unit that writes a third index into the bitstream, the third index being used to determine the intra-prediction mode of the current block from a second set of intra-prediction modes.

[0774] In some implementations, the candidate block vector set includes at least one candidate block vector, and the order of the at least one candidate block vector in the candidate block vector set is determined based on the cost of the at least one candidate block vector.

[0775] In some implementations, the cost of the at least one candidate block vector is determined based on the predicted and reconstructed values ​​of at least one reconstructed region, and the relative position between the at least one reconstructed region and the current block is determined based on the at least one candidate block vector.

[0776] In some implementations, the encoder 3500 further includes: an encoding unit that writes a fourth index into the bitstream, the fourth index being used to determine the intra-prediction mode of the first block vector and the current block from a first candidate set; wherein each candidate in the first candidate set corresponds to a combination of a block vector and an intra-prediction mode.

[0777] In some implementations, the third determining unit 3530 is further configured to: predict the current block according to the at least one intra-frame prediction mode, determine at least one prediction value; and perform weighted fusion on the at least one prediction value to determine the prediction value of the current block.

[0778] In some implementations, the at least one intra-frame prediction mode is a prediction mode in the first intra-frame prediction mode set whose cost is less than a first threshold; or, the at least one intra-frame prediction mode is the top U prediction modes in the first intra-frame prediction mode set, wherein the prediction modes in the first intra-frame prediction mode set are ordered based on their respective costs.

[0779] Understandably, in the embodiments of this application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular one. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional module.

[0780] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0781] Therefore, embodiments of this application provide a computer-readable storage medium applied to an encoder, wherein the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the decoding method described in any of the foregoing embodiments.

[0782] Based on the composition of the encoder 3500 described above and the computer-readable storage medium, refer to Figure 36, which shows a schematic diagram of the specific hardware structure of the encoder 3600 provided in this embodiment of the application. As shown in Figure 36, the encoder 3600 may include: a communication interface 3610, a memory 3620, and a processor 3630; the various components are coupled together through a bus system 3640. It is understood that the bus system 3640 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 3640 also includes a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as bus system 3640 in Figure 36.

[0783] The communication interface 3610 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;

[0784] Memory 3620 is used to store computer programs;

[0785] Processor 3630, when running the computer program, performs the following:

[0786] Determine the first block vector of the current block;

[0787] The first reference region of the current block is determined based on the first block vector;

[0788] The predicted value of the current block is determined based on the first reference region;

[0789] The residual value of the current block is determined based on the predicted value of the current block.

[0790] It is understood that the memory 3620 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 3620 of the systems and methods described in this application is intended to include, but is not limited to, these and any other suitable types of memory.

[0791] The processor 3630 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 3630 or by software instructions. The processor 3630 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 3620. Processor 3630 reads the information in memory 3620 and completes the steps of the above method in conjunction with its hardware.

[0792] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0793] Alternatively, as another embodiment, the processor 3630 is also configured to execute the encoding method in the foregoing embodiments when running the computer program.

[0794] It should be noted that, in this application, 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 limitation, 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.

[0795] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0796] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0797] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0798] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.

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

Claims

1. A decoding method applied to a decoder, comprising: determining a first block vector of a current block; determining a first reference region of the current block according to the first block vector; determining a prediction value of the current block according to the first reference region; determining a reconstructed value of the current block according to the prediction value of the current block. The determining the prediction value of the current block according to the first reference region comprises: determining at least one intra prediction mode according to the first reference region; determining the prediction value of the current block according to the at least one intra prediction mode. The determining the at least one intra prediction mode according to the first reference region comprises: determining a prediction value of an intra prediction mode in a first intra prediction mode set at the first reference region; determining a cost of the intra prediction mode in the first intra prediction mode set according to the prediction value of the intra prediction mode in the first intra prediction mode set at the first reference region and a reconstructed value of the first reference region; determining the at least one intra prediction mode from the first intra prediction mode set according to the cost of the intra prediction mode in the first intra prediction mode set. The first intra prediction mode set comprises a prediction mode determined based on a position of the current block. The prediction mode determined based on the position of the current block comprises one or more of: a prediction mode of a neighboring block of the current block, a prediction mode of a non-neighboring block of the current block. The first intra prediction mode set comprises a prediction mode determined based on a position of the first reference region. The prediction mode determined based on the position of the first reference region comprises one or more of: a prediction mode of a reconstructed block in the first reference region, a prediction mode of a neighboring block of the first reference region, a prediction mode of a non-neighboring block of the first reference region, a prediction mode derived based on gradient information of the first reference region. The at least one prediction mode comprises one or more of: a prediction mode with a minimum cost in the first intra prediction mode set; a prediction mode with a second minimum cost in the first intra prediction mode set; a non-angular prediction mode in the first intra prediction mode set. The determining the at least one intra prediction mode according to the first reference region comprises: determining gradient information of at least one reconstructed sample in the first reference region; determining the at least one intra prediction mode according to the gradient information of the at least one reconstructed sample. The determining the at least one intra prediction mode according to the gradient information of the at least one reconstructed samples comprises: determining a gradient histogram according to the gradient information of the at least one reconstructed sample; determining the at least one intra prediction mode according to the gradient histogram. The determining the prediction value of the current block according to the first reference region comprises: determining a first filter from a plurality of filters according to the first reference region; determining the prediction value of the current block according to the first filter. The first reference region comprises one or more of: ​ ​ ​ ​ 2. The method of claim 1, wherein, ​ ​ ​ 3. The method of claim 2, wherein, ​ ​ ​ ​ 4. The method of claim 3, wherein, ​ 5. The method of claim 4, wherein, ​ 6. The method of claim 3, wherein, ​ 7. The method of claim 6, wherein, ​ 8. The method of any one of claims 3 to 7, wherein, ​ ​ ​ ​ 9. The method of claim 2, wherein, ​ ​ ​ 10. The method of claim 9, wherein, ​ ​ ​ 11. The method of claim 1, wherein, ​ ​ ​ 12. The method of any one of claims 1 to 11, wherein, ​ a first region, the first region being the same size as the current block, and a relative position between the first region and the current block being determined based on the first block vector; a second region, the second region including one or more of a left region, an above region, a top-left region, a bottom-left region, and a top-right region adjacent to the first region.

13. The method of any one of claims 1 to 12, wherein, The determining of the first block vector of the current block comprises: decoding a bitstream to determine a first index; determining the first block vector from a candidate block vector set according to the first index.

14. The method of any one of claims 1 to 12, wherein, The determining of the first block vector of the current block comprises: decoding a bitstream to determine a second index and a first block vector difference; determining a second block vector from a candidate block vector set according to the second index; determining the first block vector according to the second block vector and the first block vector difference.

15. The method of any one of claims 1 to 12, wherein, The first block vector is determined based on a candidate block vector set, and a block vector in the candidate block vector set comprises one or more of: a block vector determined based on a matching cost between a template of the current block and a reference template in a reconstructed region around the current block, a block vector corresponding to a spatially neighboring position of the current block, a block vector corresponding to a spatially non-neighboring position of the current block, a block vector in a history-based block vector prediction set, and a block vector derived based on a block vector already added to the candidate block vector set.

16. The method of any one of claims 1 to 12, wherein, The determining of the first block vector of the current block comprises: determining the first block vector according to information of a decoded block.

17. The method of claim 1, wherein, The determining of the prediction value of the current block according to the first reference region comprises: determining at least one intra prediction mode from a second intra prediction mode set according to the first reference region; determining the prediction value of the current block according to the at least one intra prediction mode.

18. The method of claim 17, wherein, The second intra prediction mode set comprises one or more of: a first intra prediction mode, the first intra prediction mode being used to determine an intra prediction mode of the current block based on a prediction value and a reconstructed value of the first reference region; a second intra prediction mode, the second intra prediction mode being used to determine an intra prediction mode of the current block based on gradient information of reconstructed samples in the first reference region; a third intra prediction mode, the third intra prediction mode being used to determine a type of filter used to determine the prediction value of the current block based on the first reference region; a fourth intra prediction mode, the fourth intra prediction mode being used to determine at least one block vector used to determine the prediction value of the current block based on the first reference region.

19. The method of claim 17 or 18, wherein, The determining of the at least one intra prediction mode from the second intra prediction mode set according to the first reference region comprises: determining a prediction value of an intra prediction mode in the second intra prediction mode set in the first reference region; determining a cost of the intra prediction mode in the second intra prediction mode set based on the prediction value of the intra prediction mode in the second intra prediction mode set in the first reference region and a reconstructed value of the first reference region; determining the at least one intra prediction mode from the second intra prediction mode set based on the cost of the intra prediction mode in the second intra prediction mode set.

20. The method of claim 1, wherein, The method further includes: decoding the bitstream to determine a third index; determining, according to the third index, an intra prediction mode of the current block from a second set of intra prediction modes.

21. The method of any one of claims 13 to 15, wherein, The candidate block vector set includes at least one candidate block vector, and an order of the at least one candidate block vector in the candidate block vector set is determined based on a cost of the at least one candidate block vector.

22. The method of claim 21, wherein, The cost of the at least one candidate block vector is determined based on a prediction value and a reconstructed value of at least one reconstructed region, and a relative position between the at least one reconstructed region and the current block is determined based on the at least one candidate block vector.

23. The method of claim 1, wherein, The determining the first block vector of the current block includes: decoding the bitstream to determine a fourth index; determining, according to the fourth index, the first block vector and an intra prediction mode of the current block from a first candidate set; wherein each candidate in the first candidate set corresponds to a combination of a block vector and an intra prediction mode.

24. The method of claim 2, wherein, The determining the prediction value of the current block according to the at least one intra prediction mode includes: predicting the current block according to the at least one intra prediction mode to determine at least one prediction value; performing weighted fusion on the at least one prediction value to determine the prediction value of the current block.

25. The method of claim 24, wherein, The at least one intra prediction mode is a prediction mode in a first set of intra prediction modes with a cost less than a first threshold; or, the at least one intra prediction mode is a first U prediction modes in the first set of intra prediction modes, wherein the prediction modes in the first set of intra prediction modes are ordered based on respective costs.

26. An encoding method applied to an encoder, comprising: determining a first block vector of a current block; determining a first reference region of the current block according to the first block vector; determining a prediction value of the current block according to the first reference region; determining a residual value of the current block according to the prediction value of the current block.

27. The method of claim 26, wherein, The determining the prediction value of the current block according to the first reference region includes: determining at least one intra prediction mode according to the first reference region; determining the prediction value of the current block according to the at least one intra prediction mode.

28. The method of claim 27, wherein, The determining the at least one intra prediction mode according to the first reference region includes: determining a prediction value of an intra prediction mode in a first set of intra prediction modes at the first reference region; determining a cost of the intra prediction mode in the first set of intra prediction modes according to the prediction value of the intra prediction mode at the first reference region and a reconstructed value of the first reference region; determining the at least one intra prediction mode from the first set of intra prediction modes according to the cost of the intra prediction mode in the first set of intra prediction modes.

29. The method of claim 28, wherein, The first set of intra prediction modes includes prediction modes determined based on a position of the current block.

30. The method of claim 29, wherein, The prediction modes determined based on the position of the current block include one or more of the following: a prediction mode of a neighboring block of the current block, a prediction mode of a non-neighboring block of the current block.

31. The method of claim 28, wherein, The first set of intra prediction modes includes prediction modes determined based on a position of the first reference region.

32. The method of claim 31, wherein, The prediction mode determined based on the position of the first reference region comprises one or more of the following: a prediction mode of a reconstructed block in the first reference region, a prediction mode of a neighboring block of the first reference region, a prediction mode of a non-neighboring block of the first reference region, a prediction mode derived based on gradient information of the first reference region.

33. The method of any one of claims 28-32, wherein, The at least one prediction mode comprises one or more of the following: a prediction mode with a minimum cost in the first set of intra prediction modes; a prediction mode with a second minimum cost in the first set of intra prediction modes; a non-angular prediction mode in the first set of intra prediction modes.

34. The method of claim 27, wherein, The determining at least one intra prediction mode according to the first reference region comprises: determining gradient information of at least one reconstructed sample in the first reference region; determining the at least one intra prediction mode according to the gradient information of the at least one reconstructed sample.

35. The method of claim 34, wherein, The determining the at least one intra prediction mode according to the gradient information of the at least one reconstructed sample comprises: determining a gradient histogram according to the gradient information of the at least one reconstructed sample; determining the at least one intra prediction mode according to the gradient histogram.

36. The method of claim 26, wherein, The determining the prediction value of the current block according to the first reference region comprises: determining a first filter from a plurality of filters according to the first reference region; determining the prediction value of the current block according to the first filter.

37. The method of any one of claims 26 to 36, wherein, The first reference region comprises one or more of the following: a first region, the first region has a same size as the current block, and a relative position between the first region and the current block is determined based on the first block vector; a second region, the second region comprises one or more of a left region, an upper region, a top-left region, a top-right region adjacent to the first region.

38. The method of any one of claims 26 to 37, wherein, The method further comprises: writing a first index into a bitstream, the first index is used to determine the first block vector from a candidate block vector set.

39. The method of any one of claims 26 to 37, wherein, The method further comprises: writing a second index and a first block vector difference into a bitstream, the second index is used to determine a second block vector from a candidate block vector set, and the second block vector and the first block vector difference are used to determine the first block vector.

40. The method of any one of claims 26 to 37, wherein, The first block vector is determined based on a candidate block vector set, and a block vector in the candidate block vector set comprises one or more of the following: a block vector determined based on a matching cost between a template of the current block and a reference template in a reconstructed region around the current block, a block vector corresponding to a spatial neighboring position of the current block, a block vector corresponding to a spatial non-neighboring position of the current block, a block vector in a history-based block vector prediction set, and a block vector derived based on a block vector already added into the candidate block vector set.

41. The method of any one of claims 26 to 37, wherein, The determining the first block vector of the current block comprises: determining the first block vector according to information of a coded block.

42. The method of claim 26, wherein, The determining the prediction value of the current block according to the first reference region comprises: determination of at least one intra prediction mode from a second set of intra prediction modes according to the first reference region; determination of the prediction value of the current block according to the at least one intra prediction mode.

43. The method of claim 42, wherein, The second intra prediction mode set includes one or more of the following prediction modes: A first intra prediction mode, which determines an intra prediction mode of the current block based on a prediction value and a reconstructed value of the first reference region; A second intra prediction mode, which determines an intra prediction mode of the current block based on gradient information of reconstructed samples in the first reference region; A third intra prediction mode, which determines a type of filter used to determine a prediction value of the current block based on the first reference region; A fourth intra prediction mode, which determines at least one block vector used to determine a prediction value of the current block based on the first reference region.

44. The method of claim 42 or 43, wherein, The determining of the at least one intra prediction mode from the second intra prediction mode set based on the first reference region comprises: determining a prediction value of an intra prediction mode in the second intra prediction mode set in the first reference region; determining a cost of the intra prediction mode in the second intra prediction mode set based on the prediction value of the intra prediction mode in the second intra prediction mode set in the first reference region and a reconstructed value of the first reference region; determining the at least one intra prediction mode from the second intra prediction mode set based on the cost of the intra prediction mode in the second intra prediction mode set.

45. The method of claim 26, wherein, The method further comprises: writing a third index into a bitstream, the third index being used to determine the intra prediction mode of the current block from the second intra prediction mode set.

46. The method of any one of claims 38-40, wherein, The candidate block vector set includes at least one candidate block vector, and an order of the at least one candidate block vector in the candidate block vector set is determined based on a cost of the at least one candidate block vector.

47. The method of claim 46, wherein, The cost of the at least one candidate block vector is determined based on a prediction value and a reconstructed value of at least one reconstructed region, and a relative position between the at least one reconstructed region and the current block is determined based on the at least one candidate block vector.

48. The method of claim 26, wherein, The method further comprises: writing a fourth index into a bitstream, the fourth index being used to determine the first block vector and the intra prediction mode of the current block from the first candidate set; wherein each candidate in the first candidate set corresponds to a combination of a block vector and an intra prediction mode.

49. The method of claim 27, wherein, The determining of the prediction value of the current block based on the at least one intra prediction mode comprises: predicting the current block based on the at least one intra prediction mode to determine at least one prediction value; performing weighted fusion on the at least one prediction value to determine the prediction value of the current block.

50. The method of claim 49, wherein, The at least one intra prediction mode is a prediction mode in the first intra prediction mode set whose cost is less than a first threshold; or, the at least one intra prediction mode is a first U prediction modes in the first intra prediction mode set, wherein the prediction modes in the first intra prediction mode set are ordered based on respective costs.

51. A decoder, comprising: a first determining unit configured to determine a first block vector of a current block; a second determining unit, configured to determine a first reference region of the current block according to the first block vector; a third determining unit, configured to determine a prediction value of the current block according to the first reference region; a fourth determining unit, configured to determine a reconstructed value of the current block according to the prediction value of the current block.

52. A decoder, comprising: a memory, configured to store a computer program; a processor, configured to execute the method in any one of claims 1 to 25 when running the computer program.

53. An encoder, comprising: a first determining unit, configured to determine a first block vector of a current block; a second determining unit, configured to determine a first reference region of the current block according to the first block vector; a third determining unit, configured to determine a prediction value of the current block according to the first reference region; a fourth determining unit, configured to determine a residual value of the current block according to the prediction value of the current block.

54. An encoder, comprising: a memory, configured to store a computer program; a processor, configured to execute the method in any one of claims 26 to 50 when running the computer program.

55. A non-transitory computer readable storage medium storing a bitstream, the bitstream generated by an encoding method with an encoder or the bitstream decoded by a decoding method with a decoder, wherein, The decoding method is the method in any one of claims 1 to 25, and the encoding method is the method in any one of claims 26 to 50.

56. A bitstream, comprising the bitstream generated by the method in any one of claims 26 to 50.

57. A computer readable storage medium, wherein, The computer readable storage medium stores a computer program, and the computer program is executed to implement the method in any one of claims 1 to 25, or the method in any one of claims 26 to 50.