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

WO2026193712A1PCT designated stage Publication Date: 2026-09-24GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/083282
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-03-18
Publication Date
2026-09-24

Smart Images

  • Figure CN2025083282_24092026_PF_FP_ABST
    Figure CN2025083282_24092026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are an encoding method, a decoding method, an encoder, a decoder and a storage medium. The decoding method comprises: on the basis of a plurality of sets of hypothesized reconstructed sample values of a boundary region of a current block and a first cost formula, determining a plurality of costs, wherein the plurality of sets of hypothesized reconstructed sample values are determined on the basis of a plurality of sets of hypothesized signs corresponding to at least one transform coefficient of the current block; and on the basis of the plurality of costs, determining a target set of hypothesized signs from among the plurality of sets of hypothesized signs, wherein the first cost formula comprises a first parameter, the first parameter is associated with a reconstructed sample value of a first position in a reference region of the current block, and the first position is determined on the basis of a first angle.
Need to check novelty before this filing date? Find Prior Art

Description

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

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

[0002] When encoding and decoding the transform coefficients of the current block, it is necessary to predict the sign of the transform coefficients. How to improve the accuracy of the predicted sign of the transform coefficients to improve 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, and a storage medium. The various aspects covered in this application are described below.

[0004] In a first aspect, a decoding method is provided, which is applied to a decoder. The decoding method includes: determining multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transform coefficient of the current block; and determining the positive and negative signs of a target set of hypotheses from the multiple sets of hypothetical positive and negative signs based on the multiple costs; wherein the first cost formula includes a first parameter, which is associated with the reconstructed sample value of a first position in the reference region of the current block, and the first position is determined based on a first angle.

[0005] Secondly, an encoding method is provided, which is applied to an encoder. The encoding method includes: determining multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transform coefficient of the current block; and determining the positive and negative signs of a target group hypothesis from the multiple sets of hypothesis positive and negative signs based on the multiple costs; wherein the first cost formula includes a first parameter, the first parameter being associated with the reconstructed sample value of a first position in the reference region of the current block, and the first position being determined based on a first angle.

[0006] Thirdly, a decoder is provided, comprising: a first determining unit configured to determine multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transform coefficient of the current block; and a second determining unit configured to determine the positive and negative signs of a target set of hypotheses from the multiple sets of hypothetical positive and negative signs based on the multiple costs; wherein the first cost formula includes a first parameter, the first parameter being associated with the reconstructed sample value of a first position in the reference region of the current block, and the first position being determined based on a first angle.

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

[0008] Fifthly, an encoder is provided, comprising: a first determining unit configured to determine multiple costs based on multiple sets of hypothesis reconstruction sample values ​​of a boundary region of a current block and a first cost formula, wherein the multiple sets of hypothesis reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transform coefficient of the current block; and a second determining unit configured to determine the positive and negative signs of a target set of hypotheses from the multiple sets of hypothesis positive and negative signs based on the multiple costs; wherein the first cost formula includes a first parameter, the first parameter being associated with a reconstruction sample value at a first position in a reference region of the current block, the first position being determined based on a first angle.

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

[0010] In a seventh aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program that, when executed, implements the method as described in the first or second aspect.

[0011] Eighthly, 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.

[0012] Ninth aspect, a computer-readable storage medium is provided, which stores a bitstream generated according to the method of the second aspect.

[0013] When predicting the sign of transform coefficients, related techniques use a cost formula to calculate the cost, which indicates the continuity cost between the boundary region of the current block and the reference region in the horizontal (or vertical) direction. However, the actual texture direction of the region where the current block is located may not be horizontal or vertical. This means that the cost calculated by the cost formula cannot reflect the true continuity cost between the boundary region and the reference region, thus reducing the accuracy of the predicted sign of the transform coefficients.

[0014] In this embodiment of the application, the reconstructed sample value of the first position in the reference region is introduced into the first cost formula to calculate the continuity cost between the boundary region and the surrounding region of the current block. Since the reconstructed sample value of the first position is determined by the first angle (including the texture direction), the cost calculated by the first cost formula can better reflect the continuity cost between the boundary region and the reference region in the texture direction. Therefore, it can improve the accuracy of the sign of the predicted transform coefficients, thereby improving the 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 3A is an example diagram of the transformation coefficient block.

[0018] Figure 3B is an example diagram of the transform coefficient block obtained by splitting the transform coefficient block.

[0019] Figure 4A is an example diagram of the coefficient block after inverse transformation.

[0020] Figure 4B is an example diagram of the coefficient blocks obtained by splitting the coefficient blocks based on the inverse transformation.

[0021] Figure 5 is a schematic diagram of the hypothetical reconstruction values ​​of the boundary region containing the current block and the reconstruction values ​​of the surrounding region.

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

[0023] Figure 7 is a schematic diagram of the area surrounding the current block provided in an embodiment of this application.

[0024] Figure 8 is a schematic diagram of the area surrounding the boundary region of the current block provided in an embodiment of this application.

[0025] Figure 9 is a schematic diagram of the surrounding area of ​​a sub-region of a boundary region provided in an embodiment of this application.

[0026] Figure 10 is a schematic diagram of the surrounding area of ​​a sub-region of a boundary region provided in another embodiment of this application.

[0027] Figure 11 is a schematic diagram of the traditional 65 angle modes.

[0028] Figure 12 is a schematic diagram of limiting the angle range of the first angle provided in an embodiment of this application.

[0029] Figure 13 is a schematic diagram of the mapping under angle mode 66.

[0030] Figure 14A is a schematic diagram of a mapping under angle mode 34.

[0031] Figure 14B is another mapping diagram under angle mode 34.

[0032] Figure 15 is a schematic diagram of the extended position of the reconstructed row at the first angle provided in the embodiments of this application.

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

[0034] Figure 17 is a schematic diagram of the angular directions of the boundary region of the current block containing multiple first angles provided in the embodiment of this application.

[0035] Figure 18 is a schematic diagram of the structure of a decoder provided in an embodiment of this application.

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

[0037] Figure 20 is a schematic diagram of the encoder provided in an embodiment of this application.

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

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

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

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

[0042] 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).

[0043] For example, the video encoder 100 reads video data and, for each image in the video data, divides the 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 (luma) sample and two chrominance (chroma) samples. Therefore, each CTU can be associated with one luminance sample block and two chrominance sample blocks. The size of a CTU is, for example, 128×128, 64×64, 32×32, etc. A CTU can be further divided into several coding units (CUs) for encoding. CUs can be rectangular or square blocks. CUs can correspond to prediction units (PUs) and transform units (TUs).

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

[0045] Optionally, in this application, the current block can be referred to as the current coding unit (CU). A prediction block can also be referred to as a prediction image block or image prediction block, and a reconstructed image block can also be referred to as a reconstruction block or image reconstruction block. Due to the need for parallel processing, an image can be divided into slices. Slices within the same image can be processed in parallel, meaning there is no data dependency between them. A "frame" is a commonly used term, generally understood as one image. In this document, "frame" can also be replaced with "image" or "slice," etc.

[0046] In some embodiments, the prediction module 110 includes an inter-frame prediction module 111 and an intra-frame prediction module 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.

[0047] The inter-frame prediction module 111 can be used for inter-frame prediction, which can include motion estimation and motion compensation. It can reference 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, 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 the 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.

[0048] The intra-frame prediction module 112 refers only to information from the same image to predict sample information within the current code image block, thereby eliminating spatial redundancy.

[0049] 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. High Efficiency Video Coding (HEVC) uses Planar, DC, and 33 angular modes, for a total of 35 prediction modes. Versatile Video Coding (VVC) uses Planar, DC, and 65 angular modes, for a total of 67 prediction modes.

[0050] 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.

[0051] The residual module 120 can generate a residual block of the CU based on the sample block of the CU and the prediction block of the CU. For example, the residual module 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 CU.

[0052] Transform / quantization module 130 quantizes transform coefficients. Transform / quantization module 130 quantizes transform coefficients associated with the CU based on quantization parameter (QP) values ​​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 values ​​associated with the CU.

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

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

[0055] The loop filtering module 160 is used to process the samples after inverse transformation 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 CU.

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

[0057] The decoded image buffer 170 can store reconstructed sample blocks. The inter-frame prediction module 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 module 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.

[0058] The entropy encoding module 180 can receive quantized transform coefficients from the transform / quantization module 130. The entropy encoding module 180 can perform one or more entropy encoding operations on the quantized transform coefficients to produce entropy-encoded data.

[0059] Figure 2 is a schematic block diagram of a video decoder involved in an embodiment of this application.

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

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

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

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

[0064] Inter-frame prediction module 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 module 210 can parse the motion information of the PU. Inter-frame prediction module 221 can determine one or more reference blocks of the PU based on the motion information of the PU. Inter-frame prediction module 221 can generate prediction blocks for the PU based on one or more reference blocks of the PU.

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

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

[0067] The reconstruction module 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 module 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.

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

[0069] 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.

[0070] 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, the prediction module 110 uses intra-frame prediction or inter-frame prediction to generate a prediction block for the current block. The residual module 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 the transform / quantization module 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 the transform / quantization module 130 can be called a temporal residual block, and the temporal residual block after transformation and quantization by the transform / quantization module 130 can be called a frequency residual block or a frequency domain residual block. The entropy coding module 180 receives the quantized change coefficients output by the transform / quantization module 130, and can perform entropy coding on the quantized change coefficients to output a bitstream. For example, the entropy coding module 180 can eliminate character redundancy based on the target context model and the probability information of the binary bitstream.

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

[0072] 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.

[0073] It is understandable that the "inverse transformation" of the transform coefficients at the decoding end can also be referred to as "transformation" in standard texts. In the embodiments of this application, "transformation" and "inverse transformation" correspond to two opposite processes. For example, "transformation" converts spatial domain values ​​to frequency domain coefficients, while "inverse transformation" converts frequency domain coefficients back to spatial domain values. If the standard only specifies decoding, then "transformation" in the standard text refers to the decoding part, specifically the "inverse transformation" in this document. The "inverse transformation" of the transform coefficients at the decoding end can also be referred to as "transformation" in standard texts.

[0074] 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 the video codec under this block-based hybrid coding framework, but is not limited to this framework and flow.

[0075] The encoding / decoding framework provided in the embodiments of this application has been described in detail above. In a bitstream, the transmission of quantized transform coefficients typically incurs significant bit overhead. For example, some statistical data shows that the sign information of these transform coefficients constitutes a considerable proportion of the bitstream. Therefore, effectively predicting the signs of these transform coefficients can greatly reduce the bit overhead of this sign information in the bitstream. Based on the above reasons, related technologies propose a transform coefficient sign prediction technique to save on the bit overhead of transform coefficient sign information in the bitstream. The transform coefficient sign prediction technique will be described in detail below.

[0076] The ratio of positive to negative signs in transform coefficients typically follows a pattern, statistically roughly 50:50. Therefore, in traditional techniques, the signs of transform coefficients are encoded and decoded using a single binary symbol with equal probability. However, by introducing transform coefficient sign prediction technology, the signs can be predicted correctly with a high probability; that is, the probability of correct sign prediction far outweighs the probability of incorrect prediction. In this case, instead of directly encoding and decoding the signs of transform coefficients in the bitstream, we encode and decode whether the predicted signs are correct. The prediction results can then be encoded and decoded using a binary symbol based on a context probability model, significantly reducing bit overhead.

[0077] In transform coefficient sign prediction technology, the efficiency and accuracy of sign prediction directly impacts the cost of sign encoding and decoding. In related technologies, the sign prediction process first relies on the decomposable transform coefficient characteristic, splitting the current block's transform coefficient block into multiple transform coefficient blocks. For example, Figure 3A shows a schematic diagram of transform coefficient block A of the current block, and Figure 3B shows transform coefficient blocks B and C obtained by splitting transform coefficient block A. As shown in Figure 3A, transform coefficient block A contains two non-zero coefficients, 2 and -1, and can be represented as the superposition of transform coefficient blocks B and C, i.e., A = 2 × B - C. Referring to Figures 4A and 4B, when we perform inverse transform on transform coefficient blocks A, B, and C, we obtain inverse transformed coefficient blocks invA, invB, and invC, which still satisfy the superposition characteristic between transform coefficient blocks, i.e., invA = 2 × invB - invC.

[0078] Based on the aforementioned transformation characteristics, when predicting the sign of the transform coefficients, we can enumerate all the hypothetical signs of the transform coefficients and perform an inverse transform to obtain the inverse transform block. For example, continuing with transform coefficient block A, if we do not know the signs of the non-zero transform coefficients in transform coefficient block A, we can enumerate the following four hypothetical results based on the inverse transform of transform coefficient block A: InvA0 = 2 × invB + invC, InvA1 = -2 × invB + invC, InvA2 = 2 × invB - invC, InvA3 = -2 × invB - invC.

[0079] Adding the residuals obtained from the inverse transformations of the four hypotheses above to the predicted values ​​of the current block yields four sets of hypothetical reconstructed values. The continuity of these four sets of reconstructed values ​​is calculated with the reconstructed blocks surrounding the current block. The combination of positive and negative signs of the hypothesis with the best continuity is taken as the prediction result, i.e., the sign of the predicted transformation coefficients. In related technologies, the quality of continuity can be measured by cost. The following is an exemplary cost formula for calculating the continuity of block boundary regions.

[0080] For example, the cost formula can be expressed as:

[0081] As shown in Figure 5, p (i.0) and p (0 , j ) represents the hypothetical reconstructed values ​​for the first row and first column within the current block; r (i,-1) and r (-1,j) The reconstructed values ​​are the outermost first row and first column of the current block; r (i,-2) and r (-2,j) The value represents the reconstruction value of the second row and second column adjacent to the outside of the current block; width is the width of the current block, and height is the height of the current block.

[0082] Based on the assumed reconstruction value p and the surrounding reconstructed values ​​r, the cost of measuring the boundary continuity of the current block can be obtained according to the cost formula (1). If the reconstruction values ​​of the four sets of assumptions introduced above are substituted into the cost formula (1), the cost values ​​of the four assumptions can be obtained. The sign of the reconstruction value of the set of assumptions with the smallest cost value is the sign of the predicted transformation coefficient.

[0083] It should be understood that a transform block can predict the signs of a maximum of N transform coefficients. If there are more than N non-zero transform coefficients in a transform block, then the signs of N transform coefficients should be predicted. In addition, N identification information indicating whether each sign has been correctly predicted will be parsed from the bitstream. Then, the signs of these predicted transform coefficients, combined with the N identification information, will determine the final signs of the N transform coefficients.

[0084] As can be seen from the above description of the calculation method of cost formula (1), the related technology considers the continuity between the boundary region and the reference region in the horizontal (or vertical) direction when calculating the continuity cost of the boundary region of the current block. Specifically, for the upper boundary region of the current block, the cost between the assumed reconstruction value and the reconstruction value of the surrounding region in the vertical direction is calculated, that is, the continuity cost between the current block and the neighboring block in the vertical direction is calculated. For the left boundary region of the current block, the cost between the assumed reconstruction value and the reconstruction value of the reference region in the horizontal direction is calculated, that is, the continuity between the current block and the neighboring block in the horizontal direction is calculated. However, the actual texture direction of the region where the current block is located may not be horizontal or vertical, which causes the cost calculated by cost formula (1) to not reflect the real continuity cost between the boundary region and the reference region, reducing the accuracy of the positive and negative signs of the predicted transformation coefficients.

[0085] To address the aforementioned issues, this application provides an encoding method comprising: determining multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of a current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transform coefficient of the current block; determining the positive and negative signs of a target set of hypotheses from the multiple sets of hypothetical positive and negative signs based on the multiple costs; wherein the first cost formula includes a first parameter, the first parameter being associated with the reconstruction sample values ​​of a first position in the surrounding region of the current block, the first position being determined based on a first angle.

[0086] Furthermore, embodiments of this application also provide a decoding method, comprising: determining multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transform coefficient of the current block; determining the positive and negative signs of a target set of hypotheses from the multiple sets of hypothetical positive and negative signs based on the multiple costs; wherein the first cost formula includes a first parameter, the first parameter being associated with the reconstruction sample values ​​of a first position in the surrounding region of the current block, the first position being determined based on a first angle.

[0087] In this embodiment of the application, the reconstructed sample value of the first position in the reference region is introduced into the first cost formula to calculate the continuity cost between the boundary region and the surrounding region of the current block. Since the reconstructed sample value of the first position is determined by the first angle (including the texture direction), the cost calculated by the first cost formula can better reflect the continuity cost between the boundary region and the reference region in the texture direction. Therefore, it can improve the accuracy of the sign of the predicted transform coefficients, thereby improving the encoding and decoding performance.

[0088] The decoding method of this application will be described in detail below with examples.

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

[0090] Referring to Figure 6, in step S610, multiple costs are determined by reconstructing sample values ​​based on multiple sets of assumptions about the boundary region of the current block and the first cost formula. The current block can refer to the current block to be decoded. The current block can also be understood as the current transform block, the current transform coefficient block, or the current coefficient block.

[0091] In some implementations, the boundary region of the current block may include one or more items from the top N rows and left M columns of the current block. M and N are positive integers greater than or equal to 1. For example, the boundary region may include the first row above the current block and the first column to the left of the current block.

[0092] The reconstructed sample values ​​for the boundary region can be determined based on the signs of multiple hypotheses corresponding to at least one transform coefficient of the current block. The signs of the multiple hypotheses corresponding to the transform coefficients can be understood as the transform coefficients of multiple hypotheses (with different signs).

[0093] In some implementations, the determination of the multi-set hypothesis reconstruction sample values ​​for the boundary region may include: performing inverse quantization and inverse transformation on the transformation coefficients of the multi-set hypotheses for the current block to determine the multi-set hypothesis residual values ​​for the current block; then, determining the multi-set hypothesis reconstruction sample values ​​for the boundary region based on the multi-set hypothesis residual values ​​and the predicted values ​​for the boundary region. For example, the sum of the multi-set hypothesis residual values ​​and the predicted values ​​for the boundary region can be used as the multi-set hypothesis reconstruction sample values ​​for the boundary region.

[0094] The first cost formula is used to calculate the cost between the hypothetical reconstructed sample values ​​of the boundary region and the reconstructed sample values ​​of the reference region. Multiple sets of hypothetical reconstructed sample values ​​of the boundary region can be input as parameters into the first cost formula to determine multiple costs. The first cost formula includes a first parameter, which is associated with the reconstructed sample value at a first position in the reference region of the current block. Alternatively, the reconstructed sample value at the first position is input as a parameter into the first cost formula to determine multiple costs. Here, the first position is determined based on a first angle. The first angle pattern can also be understood as a first angle mode.

[0095] For example, the first cost formula can be expressed as:

[0096] Where, p (i,0) and p (0,j)Represents multiple sets of hypothetical reconstructed sample values ​​for the boundary region; r1, r2, r3, r4 represent the reconstructed sample values ​​at the first position in the reference region, 2×r1-r2 and / or 2×r3-r4 represent the first parameter; width is the width of the current block, and height is the height of the current block.

[0097] As mentioned earlier, when predicting the sign of transform coefficients, the cost calculated by the cost formula indicates the continuity cost between the boundary region of the current block and the reference region in the horizontal (or vertical) direction. However, the actual texture direction of the region where the current block is located may not be horizontal or vertical. This means that the cost calculated by the cost formula cannot reflect the true continuity cost between the boundary region and the reference region, thus reducing the accuracy of the predicted sign of the transform coefficients.

[0098] In this embodiment, the reconstructed sample value at a first location in the reference region is incorporated into a first cost formula to calculate the continuity cost between the boundary region and the surrounding region of the current block. Since the reconstructed sample value at the first location is determined by a first angle (including the texture direction), the cost calculated by the first cost formula better reflects the continuity cost between the boundary region and the reference region in the texture direction. In other words, the first cost formula uses the continuity cost of the boundary region in the texture direction as an indicator. Therefore, the accuracy of the sign of the predicted transform coefficients can be improved, thereby improving encoding and decoding performance.

[0099] The decoder can always decode the current block in the manner shown in Figure 6, or it can decode the current block only in the manner shown in Figure 6 if the current block meets certain conditions (hereinafter referred to as the first condition).

[0100] In some implementations, the first condition may include one or more of the following: the current block is a luminance block; the number of samples in the first region of the current block is greater than or equal to a first threshold, the first region being the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the number of samples in the second region of the current block is greater than or equal to a second threshold, the second region being any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the current block is not allowed to skip transformations in the vertical and / or horizontal directions; the current block uses an indivisible transformation.

[0101] In other words, the current block will not be decoded in the manner shown in Figure 6 if certain conditions are met (hereinafter referred to as the second condition).

[0102] In some implementations, the second condition may include one or more of the following: the current block is a chroma block; the number of samples in the first region of the current block is less than or equal to a first threshold, the first region being the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the number of samples in the second region of the current block is less than or equal to a second threshold (e.g., equal to 0), the second region being any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the current block skips using transformations in the vertical and / or horizontal directions; the prediction mode of the current block includes at least one or more of the following: PLANAR mode, DC mode, matrix-based intra prediction (MIP) mode, spatial geometric partition mode (SGPM) mode, template-based intra mode derivation (TIMD) mode, decoder-side intra mode derivation (DIMD) mode, and enhanced intra prediction (EIP) mode. It should be understood that the number of samples mentioned in the first and second conditions above can be interpreted as the number of non-zero transformation coefficients.

[0103] When transforming blocks into chroma blocks, the texture features of chroma are usually not obvious, so calculating the boundary continuity cost based on angle is not very effective. Therefore, by setting the first condition (or the second condition) described above, the decoding method in Figure 6 can be omitted from the chroma blocks to reduce the complexity of the decoder.

[0104] Residual transform typically concentrates low-frequency signals in the upper left corner of the transform block. For example, in DCT2 transform, the transform coefficients in the upper left corner are DC coefficients. Although changes in the DC coefficients affect the residual of the entire block, they do not exhibit any texture characteristics. Besides the DC coefficients, most low-frequency signals also have similar characteristics. Therefore, when only the (low-frequency) coefficients in the upper left corner of the transform block are non-zero, angle-based sign prediction of the transform coefficients can be omitted from this type of transform block to reduce the complexity of the encoder and decoder. Thus, by setting the first condition (or second condition) described above, the decoding method in Figure 6 can be omitted from blocks with a sample number in the second region that is less than or equal to the second threshold, reducing the complexity of the decoder.

[0105] In some cases, since the predicted sign always comes from the N×N region in the upper left corner of the transform block, if there are too few signs to be predicted in this region, the residual often does not have complex texture characteristics. Therefore, by setting the first condition (or the second condition) described above, the decoding method in Figure 6 can be omitted on blocks where the number of samples in the first region is less than or equal to the first threshold, thus reducing the complexity of the decoder.

[0106] In basic transforms, some transform modes allow transform skipping in the horizontal or vertical directions. Transform blocks using transform skipping often have transform coefficients that don't accurately affect the continuity of the transform block boundaries. Therefore, when transform skipping is used on one or both sides in the horizontal or vertical direction, angle-based sign prediction can be omitted. Thus, by setting the first (or second) condition described above, the decoding method in Figure 6 can be omitted on blocks using transform skipping in the vertical and / or horizontal directions, reducing the decoder's complexity.

[0107] The choice of the transform kernel for the Indivisible Transform (LFNST, NSPT) is related to the angular direction of the current transform block texture. Therefore, blocks using the Indivisible Transform are more likely to have directional texture features. Thus, when the current transform block is not an Indivisible Transform, the sign prediction technique based on angular direction can be omitted. Therefore, by setting the first (or second) condition described above, the decoding method in Figure 6 can be omitted on blocks that do not use the Indivisible Transform, reducing the complexity of the decoder.

[0108] For blocks using intra-frame prediction, the selected intra-frame prediction mode can be an angle prediction mode. Such blocks typically possess angular characteristics. However, blocks selecting PLANA or DC modes often lack texture features. Therefore, by setting the second condition described above, the decoding method in Figure 6 can be omitted from blocks using prediction modes that lack angular features, reducing the decoder's complexity. For example, prediction modes lacking angular features include at least one or more of the following: PLANA mode, DC mode, MIP mode, SGPM mode, TIMD mode, DIMD mode, and EIP mode.

[0109] The embodiments of this application can save the additional encoding and decoding time required for angle derivation and sub-pixel position interpolation by setting a first condition (or a second condition), which helps to improve encoding and decoding efficiency.

[0110] Referring again to Figure 6, in step S620, the target set of hypothesis signs is determined from multiple sets of hypothesis signs based on multiple costs.

[0111] In some implementations, the signs of the set of hypotheses corresponding to the minimum cost among multiple costs can be used as the signs of the target hypotheses. Here, the signs of the target hypotheses can be understood as the signs of the predicted transformation coefficients.

[0112] There are several ways to determine the first angle. For example, the first angle can be determined based on gradient information of the surrounding region of the current block. Alternatively, the first angle can be determined based on the intra-prediction mode of the current block. For instance, if the prediction mode of the current block is intra-prediction mode, then the angle corresponding to that intra-prediction mode can be used as the first angle. Another example is that the first angle can be determined based on the intra-prediction modes of the current block's neighboring blocks. For instance, if the prediction mode of a neighboring block is intra-prediction mode, then the angle corresponding to that intra-prediction mode can be used as the first angle.

[0113] The method of determining the first angle based on intra-frame prediction mode has lower computational overhead, which is beneficial to improving the efficiency of encoding and decoding.

[0114] For methods that determine the first angle based on gradient information, one or more first angles can be determined at multiple locations in the boundary region. Since the current block may have multiple different texture directions at multiple locations in the boundary region, that is, the boundary region may correspond to multiple angles. This method enables the first cost formula to take into account the continuity cost of the boundary region in different texture directions, making it more adaptive and further improving the accuracy of the sign of the predicted transform coefficients, thereby improving encoding and decoding performance.

[0115] In some implementations, determining the first angle based on gradient information can be understood as determining the first angle based on the gradient histogram.

[0116] The first angle determined based on the gradient information can correspond to the angle of the current block. In other words, a first angle can be determined for the current block to execute step S610.

[0117] For example, a first angle can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding region of the current block. The surrounding region can include one or more of the following: the adjacent reconstructed region above the current block, the adjacent reconstructed region to the left of the current block, and the adjacent reconstructed region to the upper left of the current block. This application does not specifically limit the size of the surrounding region of the current block. For example, Figure 7 shows a schematic diagram of the surrounding region of the current block. As shown in Figure 7, the length of the adjacent reconstructed region above the current block can be the same as the length of the current block, and its height is M, where M is a positive integer greater than or equal to 1. Similarly, as shown in Figure 7, the height of the adjacent reconstructed region to the left of the current block can be the same as the height of the current block, and its length is L, where L is a positive integer greater than or equal to 1.

[0118] For example, as shown in FIG7, if the surrounding area of ​​the current block includes the adjacent reconstruction area above the current block, the adjacent reconstruction area to the left of the current block, and the adjacent reconstruction area to the upper left of the current block, a gradient histogram can be constructed in the surrounding area to determine a first angle to perform step S610.

[0119] Alternatively, the first angle determined based on the gradient information can correspond to the angle of the boundary region. That is, an angle can be determined for each boundary region of the current block to execute step S610.

[0120] For example, a first angle can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding area of ​​the left boundary region. This surrounding area can include the adjacent reconstructed area to the left of the current block. Similarly, a first angle can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding area of ​​the upper boundary region. This surrounding area can include the adjacent reconstructed area above the current block. This application embodiment does not specifically limit the size of the surrounding area of ​​the boundary region. For example, Figure 8 shows a schematic diagram of the surrounding area of ​​the boundary region. As shown in Figure 8, the height of the adjacent reconstructed area to the left of the current block can be the same as the height of the current block, and its length is L, where L is a positive integer greater than or equal to 1. Similarly, the length of the adjacent reconstructed area above the current block can be the same as the length of the current block, and its height is M, where M is a positive integer greater than or equal to 1.

[0121] For example, as shown in FIG8, if the surrounding area of ​​the upper boundary region includes the adjacent reconstructed region above the current block, a gradient histogram can be constructed in the surrounding area to determine a first angle; if the surrounding area of ​​the left boundary region includes the adjacent reconstructed region to the left of the current block, a gradient histogram can be constructed in the surrounding area to determine a first angle; then, the two first angles are substituted into the first cost formula to perform step S610.

[0122] Alternatively, the first angle determined based on the gradient information can correspond to the angle of a sub-region of the boundary region. That is, an angle can be determined for each sub-region of the boundary region to execute step S610. The boundary region can be divided into multiple sub-regions. For example, the upper boundary region of the current block can be divided into P sub-regions, where P is a positive integer greater than 1. The dimensions of the P sub-regions can be the same or different. For example, the size of each sub-region can be set to N, where N is a positive integer greater than or equal to 1.

[0123] For example, the left boundary region of the current block can be divided into Q sub-regions, where Q is a positive integer greater than 1. The dimensions of the Q sub-regions can be the same or different; for instance, the size of each sub-region can be set to N, where N is a positive integer greater than or equal to 1.

[0124] Multiple first angles can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding areas of multiple sub-regions. Taking multiple sub-regions including a third sub-region as an example, the surrounding areas of the third sub-region can include the first adjacent reconstructed region of the third sub-region.

[0125] This application does not specifically limit the size of the first adjacent reconstructed region in its embodiments. In some implementations, if the third sub-region is located in the upper boundary region of the current block, the length of the first adjacent reconstructed region is greater than or equal to the length of the third sub-region; or, if the third sub-region is located in the left boundary region of the current block, the height of the first adjacent reconstructed region is greater than or equal to the height of the third sub-region. For example, Figure 9 shows a schematic diagram of the surrounding area of ​​a sub-region. As shown in Figure 9, for a sub-region in the upper boundary region, the length of the adjacent reconstructed region can be the same as the length of the sub-region, both being N, and the height is M, where M and N are positive integers greater than or equal to 1. As another example, as shown in Figure 9, for a sub-region in the left boundary region, the height of the adjacent reconstructed region can be the same as the height of the sub-region, both being N, and the length is L, where N and L are positive integers greater than or equal to 1.

[0126] For example, Figure 10 shows another schematic diagram of the surrounding area of ​​a sub-region. As shown in Figure 10, for a sub-region of the upper boundary region, the length of the adjacent reconstructed region can be greater than the length of the sub-region, where the length of the sub-region is N, the length of the adjacent reconstructed region is P+N+O, and the height is M; M, N, P, and O are positive integers greater than or equal to 1. Similarly, as shown in Figure 10, for a sub-region of the left boundary region, the height of the adjacent reconstructed region can be greater than the height of the sub-region, where the height of the sub-region is N, the height of the adjacent reconstructed region is Q+N+R, and the length is L; L, N, Q, and R are positive integers greater than or equal to 1.

[0127] Next, the method for determining the first angle based on gradient information from the surrounding area will be described in detail.

[0128] In some implementations, at least one set of horizontal and vertical gradients can be determined based on reconstructed sample values ​​at at least one location in the surrounding region of the current block; then, at least one angle and at least one magnitude can be determined based on the at least one set of horizontal and vertical gradients; finally, a first angle can be determined based on the at least one angle and at least one magnitude.

[0129] For example, determining the horizontal and vertical gradients can include: calculating the horizontal and vertical gradients by traversing the reconstructed sample values ​​of the locations in the surrounding region using the horizontal gradient operator and the vertical gradient operator, respectively. This application does not specifically limit the type of gradient operator; for example, the Sobel operator, Robert operator, Prevet operator, Schmidt operator, etc., can be used.

[0130] For example, determining the angle based on the gradient can include mapping a set of horizontal and vertical gradients proportionally (e.g., by looking up a table) to the 65 angles of traditional intra-frame prediction.

[0131] For example, methods for determining the magnitude value based on the gradient can include using the sum of the absolute values ​​of the horizontal and vertical gradients as the magnitude value.

[0132] The first angle is one of at least one angles determined based on gradient information. Each of these at least one angles corresponds to a first amplitude value, which is the sum of the amplitude values ​​corresponding to the same angle among the at least one amplitude values. In other words, the amplitude values ​​corresponding to the same angle can be accumulated, and the first amplitude value corresponding to the first angle is the maximum among the first amplitude values ​​corresponding to at least one angle. Alternatively, a gradient histogram can be constructed, and the angle corresponding to the accumulated maximum amplitude value can be used as the first angle.

[0133] In some cases, such as when the gradient value of the surrounding area is 0, the angle corresponding to the boundary region can be assumed to be either horizontal or vertical. For example, the angle corresponding to the upper boundary region is vertical, and the angle corresponding to the left boundary region is horizontal.

[0134] As mentioned earlier, when determining the angular direction based on horizontal and vertical gradients, the gradient information can be mapped to an angle by looking up a table. The following section introduces the aforementioned solution in related technologies.

[0135] Step 1: Solve for the absolute value and sign of the gradient: absG x =|G x |,absG y =|G y | signG x =G x <0?1:0,signG y =G y <0?1:0

[0136] Among them, G x and G y These represent the horizontal and vertical gradients at each location in the surrounding region, respectively; signG x The identifier information representing the horizontal gradient, and if G x If <0, then signG x The value of G is 1. x If > 0, then signG x The value of signG is 0; y The identifier information representing the vertical gradient, and if G y If <0, then signG y The value of G is 1.y If > 0, then signG y The value of is 0.

[0137] Step 2: Determine whether the reference direction of the derived angle is horizontal or vertical. If absG x >absG y If absG, then the reference direction is horizontal; x <absG y Therefore, the reference direction is vertical. It's important to understand that in angle modes 2-66, angle mode 18 is horizontal, and angle mode 50 is vertical. This step can be represented as: offset = absG x >absG y 18:50

[0138] Here, offset is the angle mode for the reference direction.

[0139] Step 3: Determine the offset angle pattern in the reference direction where the derived angle is located. Mathematically, the offset angle can be obtained by calculating the arctan of the ratio of the gradient values ​​in the horizontal and vertical directions. In actual implementation, this step is replaced by a lookup table method. Below is a piece of pseudocode illustrating the lookup process.

[0140] Table 1

[0141] In practical implementation, it is not necessary to solve for the specific angle value of arctan; instead, it can be directly obtained through... A ratio is obtained, and the corresponding angle direction is obtained by looking up a table based on the ratio. The table angTable

[0017] defines 17 angle direction lookup values, where each direction is the angle below the specified value. Approximate values, by comparison The direction can be derived from the size of each lookup table value. The pseudocode snippet above illustrates how to calculate the index idx corresponding to the angle direction using a lookup table.

[0142] Step 4: Based on the reference direction and offset value, export the final angle pattern. Below is a piece of pseudocode illustrating the process of exporting the angle pattern.

[0143] Table 2

[0144] In Table 2, dirs[], mapXgrY1[], and mapXgrY0[] are three predefined tables used to look up the angle pattern that differs from the reference angle.

[0145] intraDir is the final value range of angle mode 2 to angle mode 66 (inclusive of angle mode 2 and angle mode 66).

[0146] As mentioned above, the first angle determined based on the gradient information can be any angle direction, such as the angle directions corresponding to angle patterns 2 through 66. For example, Figure 11 shows a schematic diagram of 65 conventional angle patterns, where angle pattern 2 is the -45° direction, angle pattern 18 is the horizontal direction, angle pattern 34 is the 45° direction, angle pattern 50 is the vertical direction, and angle pattern 66 is the 135° direction; the first angle can be any one or more of the above 65 angle patterns.

[0147] Of course, in some scenarios, certain restrictions can be set on the direction of the first angle. In some implementations, for the upper boundary region of the current block, the corresponding first angle can be within a certain range. The first angle range includes 45° to 135°; for the left boundary region of the current block, the corresponding first angle can be within a certain range. The second angle range includes -45° to 45°. By setting a certain angle range for the first angle, some angles with inaccurate computational costs can be filtered out, thereby improving the accuracy of the sign of the predicted transformation coefficients.

[0148] For example, Figure 12 shows a schematic diagram of the angle direction that limits the first angle. As shown in Figure 12, in the upper boundary region of the current block, the corresponding first angle can be in angle mode 34 to angle mode 66; in the left boundary region of the current block, the corresponding first angle can be in angle mode 2 to angle mode 34.

[0149] In the above scheme of mapping gradient information to angles using a lookup table, before deriving the angle pattern, it is necessary to determine the reference direction corresponding to the angle pattern (the scheme in step two). In scenarios where the angle direction of the first angle is subject to certain constraints, the scheme in step two described above can be adjusted as follows: determine the reference direction of the angle (or angle pattern) based on the position information of the boundary region. For example, if the boundary region is the upper boundary region, the reference direction of the corresponding angle is the vertical direction; or, if the boundary region is the left boundary region, the reference direction of the corresponding angle is the horizontal direction. The adjusted step two can be expressed as: offset = isLeft? 18:50

[0150] Here, offset is the angle mode of the reference direction; when exporting the angle mode corresponding to the left boundary region, the reference direction is set to the horizontal direction (i.e., angle mode 18); when exporting the angle mode corresponding to the upper boundary region, the reference direction is set to the vertical direction (i.e., angle mode 50).

[0151] After determining the first angle, the first position can be determined based on the second position in the boundary region and the first angle. For example, the first position in the reference region can be determined by mapping from the second position in the boundary region to the reference region at the angular direction of the first angle.

[0152] For example, Figure 13 shows a mapping diagram of angle pattern 66. As shown in Figure 13, the reference region includes a first reference row adjacent to the current block and a second reference row next to the current block, and the first angle is angle pattern 66. At a location in the boundary region of the current block (i.e., the second location), mapping according to angle pattern 66 can determine the first position in the first cost formula in the first reference row and the second reference row.

[0153] After determining the first position, the first parameter can be determined based on the reconstructed sample value of the first position. The first position is a position within a reference region. If the reference region includes a first reference region and a second reference region, and the first position is located within the first reference region, the reconstructed sample value of the first position can be associated with one of the following: the reconstructed sample value of the reference block where the first position is located; a reconstructed sample value determined by filling in the reconstructed sample value of the reference block where the first reference region is located; or the reconstructed sample value of the reference block where the second reference region is located. It should be understood that the first reference region can be a region including the upper reference row of the current block, and the second reference region can be a region including the left reference column of the current block, or the first reference region can be a region including the left reference column of the current block, and the second reference region can be a region including the upper reference row of the current block.

[0154] For some angle patterns, the reconstructed sample values ​​provided by the reference row and reference column of the current block may not be sufficient. For example, for angle patterns 34-49, since the reference region pointed to by the angle direction may be located to the left of the reference row of the current block, it is necessary to determine the reconstructed sample values ​​for the extended position of the reference row.

[0155] For the reasons mentioned above, the reconstructed sample value of the first position can be associated with the reconstructed sample value of the reference block where the second reference region is located. In other words, the reconstructed sample value of the second reference region can be mapped to the first position (i.e., the extended position of the reference row or reference column).

[0156] For example, for angle modes 34-49, the reconstructed sample values ​​of the first reference column and the second reference column adjacent to the left are first mapped upwards as extensions of the first and second reference rows, and then the extended first and second reference rows are mapped to the positions within the current block; for angle modes 19-33, the reconstructed sample values ​​of the first and second reference rows are first mapped as extensions of the first and second reference columns, and then the extended first and second reference columns are mapped to the positions within the current block.

[0157] In addition, for angle patterns 50 to 66, only the reconstructed sample values ​​of the first reference row above and the second reference row below need to be used, and no extension is required; for angle patterns 2 to 18, only the reconstructed sample values ​​of the first reference column to the left and the second reference column below need to be used, and no extension is required.

[0158] For example, Figures 14A and 14B illustrate a mapping diagram under angle mode 34. As shown in Figure 14A, for angle mode 34, the reconstructed sample values ​​of the first reference column and the second reference column adjacent to the left can be mapped upwards as extensions of the first and second reference rows; then, as shown in Figure 14B, the reconstructed sample value of the first position in the reference area is determined by mapping according to the extended first and second reference rows and the first angle.

[0159] Alternatively, the reconstructed sample value at the first position can be associated with the reconstructed sample value of the reference block where the first position is located, or with a reconstructed sample value determined by filling in the reconstructed sample value of the reference block where the first reference region is located. That is, for some angle patterns, during mapping based on the first angle, if it is necessary to extend the reference row or reference column, if the block where the extension position is located has already been reconstructed, the reconstructed sample value of that block at that position can be directly used as the reconstructed sample value of the extension position; or, if the block where the extension position is located has not been reconstructed, it can be filled in based on the reconstructed sample values ​​of already reconstructed positions in the reference region (such as reference rows). The advantage of this approach is that, for the upper reference region, when calculating the cost based on the first cost formula, the reconstructed sample values ​​used, or in other words, the reconstructed sample value at the first position substituted into the first cost formula, all come from the reconstructed sample values ​​of the block above the current block. In this way, the cost calculated by the first cost formula can better reflect the continuity cost of the upper boundary region of the current block, thus improving the accuracy of the sign of the predicted transform coefficients and consequently improving encoding and decoding performance. The same principle applies to the left reference region, which will not be elaborated here.

[0160] For example, Figure 15 shows a schematic diagram of the extended position of the reconstructed row at the first angle. As shown in Figure 15, at the first angle, the upper reference region includes the reference row (i.e., the reconstructed row) of the current block and the extended region of that reference row. If the block containing the extended region has been reconstructed, the reconstructed sample value at the extended position can be directly used as the reconstructed sample value used when calculating the cost using the first cost formula; if the block containing the extended region has not been reconstructed, the reconstructed sample value in the reference row can be used to fill the extended region, and the filled reconstructed sample value can be used as the reconstructed sample value used when calculating the cost using the first cost formula.

[0161] During the mapping process, the position of the mapping direction may not correspond to the integer point position of the current source pixel. Therefore, in some implementations, the reconstructed sample value of the first position is determined by interpolation based on the reconstructed sample values ​​of the surrounding positions. The interpolation filter used can be, for example, an N-tap filter, such as a 2-tap, 4-tap, 6-tap, or 8-tap filter.

[0162] In some implementations, before performing step S610, the decoding method shown in Figure 6 may further include: determining multiple sets of predicted reconstructed sample values ​​for the boundary region of the current block based on multiple sets of hypothesis signs corresponding to at least one transform coefficient of the current block. For example, multiple hypothesis residual blocks of the current block can be determined based on the multiple sets of hypothesis signs; then, multiple sets of hypothesis reconstructed sample values ​​can be determined based on the multiple hypothesis residual blocks and the prediction blocks of the current block.

[0163] For example, determining the residual block of multiple hypotheses for the current block can include: determining the transformation coefficients of multiple hypotheses for the current block based on the signs of multiple sets of hypotheses; and then performing an inverse transformation on the transformation coefficients of the multiple sets of hypotheses to determine the residual block of multiple hypotheses.

[0164] In some implementations, after executing step S620, the decoding method shown in Figure 6 may further include: determining the reconstructed block of the current block based on the sign of the target group assumption. For example, at least one transform coefficient can be determined based on the sign of the target group assumption; then, the at least one transform coefficient is inversely transformed to determine the residual block of the current block; finally, the reconstructed block is determined based on the residual block and the predicted block of the current block. For example, the sum of the residual block and the predicted block can be used as the reconstructed block.

[0165] In some implementations, the decoding method shown in Figure 6 may further include: decoding the bitstream to determine first identification information; and then determining at least one transform coefficient based on the first identification information and the target group's assumed sign. The first identification information is used to indicate whether the assumed sign corresponding to the transform coefficient is correct. For example, if the first identification information indicates that the assumed sign corresponding to the transform coefficient is correct, the target assumed sign is used to determine the transform coefficient; if the first identification information indicates that the assumed sign corresponding to the transform coefficient is incorrect, the opposite sign of the target assumed sign is used to determine the transform coefficient.

[0166] The decoding method provided by the embodiments of this application has been described in detail above with reference to Figure 6. The encoding method provided by the embodiments of this application will be described in detail below with reference to Figure 16.

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

[0168] Referring to Figure 16, in step S1610, multiple costs are determined by reconstructing sample values ​​based on multiple sets of assumptions about the boundary region of the current block and the first cost formula. The current block can refer to the current block to be encoded. The current block can also be understood as the current transform block, the current transform coefficient block, or the current coefficient block.

[0169] In some implementations, the boundary region of the current block may include one or more items from the top N rows and left M columns of the current block. M and N are positive integers greater than or equal to 1. For example, the boundary region may include the first row above the current block and the first column to the left of the current block.

[0170] The reconstructed sample values ​​for the boundary region can be determined based on the signs of multiple hypotheses corresponding to at least one transform coefficient of the current block. The signs of the multiple hypotheses corresponding to the transform coefficients can be understood as the transform coefficients of multiple hypotheses (with different signs).

[0171] In some implementations, the determination of the multi-set hypothesis reconstruction sample values ​​for the boundary region may include: performing inverse quantization and inverse transformation on the transformation coefficients of the multi-set hypotheses for the current block to determine the multi-set hypothesis residual values ​​for the current block; then, determining the multi-set hypothesis reconstruction sample values ​​for the boundary region based on the multi-set hypothesis residual values ​​and the predicted values ​​for the boundary region. For example, the sum of the multi-set hypothesis residual values ​​and the predicted values ​​for the boundary region can be used as the multi-set hypothesis reconstruction sample values ​​for the boundary region.

[0172] The first cost formula is used to calculate the cost between the hypothetical reconstructed sample values ​​of the boundary region and the reconstructed sample values ​​of the reference region. Multiple sets of hypothetical reconstructed sample values ​​of the boundary region can be input as parameters into the first cost formula to determine multiple costs. The first cost formula includes a first parameter, which is associated with the reconstructed sample value at a first position in the reference region of the current block. Alternatively, the reconstructed sample value at the first position is input as a parameter into the first cost formula to determine multiple costs. Here, the first position is determined based on a first angle. The first angle pattern can also be understood as a first angle mode.

[0173] For example, the first cost formula can be expressed as:

[0174] Where, p (i,0) and p (0,j) Represents multiple sets of hypothetical reconstructed sample values ​​for the boundary region; r1, r2, r3, r4 represent the reconstructed sample values ​​at the first position in the reference region, 2×r1-r2 and / or 2×r3-r4 represent the first parameter; width is the width of the current block, and height is the height of the current block.

[0175] As mentioned earlier, when predicting the sign of transform coefficients, the cost calculated by the cost formula indicates the continuity cost between the boundary region of the current block and the reference region in the horizontal (or vertical) direction. However, the actual texture direction of the region where the current block is located may not be horizontal or vertical. This means that the cost calculated by the cost formula cannot reflect the true continuity cost between the boundary region and the reference region, thus reducing the accuracy of the predicted sign of the transform coefficients.

[0176] In this embodiment, the reconstructed sample value at a first location in the reference region is incorporated into a first cost formula to calculate the continuity cost between the boundary region and the surrounding region of the current block. Since the reconstructed sample value at the first location is determined by a first angle (including the texture direction), the cost calculated by the first cost formula better reflects the continuity cost between the boundary region and the reference region in the texture direction. In other words, the first cost formula uses the continuity cost of the boundary region in the texture direction as an indicator. Therefore, the accuracy of the sign of the predicted transform coefficients can be improved, thereby improving encoding and decoding performance.

[0177] The encoder can always encode the current block according to the method in Figure 16, or it can encode the current block according to the method in Figure 16 only if the current block meets certain conditions (hereinafter referred to as the first condition).

[0178] In some implementations, the first condition may include one or more of the following: the current block is a luminance block; the number of samples in the first region of the current block is greater than or equal to a first threshold, the first region being the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the number of samples in the second region of the current block is greater than or equal to a second threshold, the second region being any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the current block is not allowed to skip transformations in the vertical and / or horizontal directions; the current block uses an indivisible transformation.

[0179] In other words, the current block will not be encoded in the way shown in Figure 16 if certain conditions are met (hereinafter referred to as the second condition).

[0180] In some implementations, the second condition may include one or more of the following: the current block is a chroma block; the number of samples in the first region of the current block is less than or equal to a first threshold, the first region being the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the number of samples in the second region of the current block is less than or equal to a second threshold (e.g., equal to 0), the second region being any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1; the current block skips using transformations in the vertical and / or horizontal directions; the prediction mode of the current block includes at least one or more of the following: PLANAR mode, DC mode, matrix-based intra prediction (MIP) mode, spatial geometric partition mode (SGPM) mode, template-based intra mode derivation (TIMD) mode, decoder-side intra mode derivation (DIMD) mode, and enhanced intra prediction (EIP) mode. It should be understood that the number of samples mentioned in the first and second conditions above can be interpreted as the number of non-zero transformation coefficients.

[0181] When transforming blocks into chroma blocks, the texture features of chroma are usually not obvious, so calculating the boundary continuity cost based on angle is not effective. Therefore, by setting the first condition (or the second condition) described above, the encoding method in Figure 16 can be omitted from the chroma blocks to reduce the complexity of the encoder.

[0182] Residual transforms typically concentrate low-frequency signals in the upper left corner of the transform block. For example, in the DCT2 transform, the transform coefficients in the upper left corner are DC coefficients. Although changes in the DC coefficients affect the residual of the entire block, they do not exhibit any texture characteristics. Besides the DC coefficients, most low-frequency signals also have similar characteristics. Therefore, when only the (low-frequency) coefficients in the upper left corner of the transform block are non-zero, angle-based sign prediction of the transform coefficients can be omitted from this type of transform block to reduce encoder complexity. Thus, by setting the first condition (or second condition) described above, the encoding method in Figure 16 can be omitted from blocks with a sample number in the second region that is less than or equal to the second threshold, reducing encoder complexity.

[0183] In some cases, since the predicted sign always comes from the N×N region in the upper left corner of the transform block, if there are too few signs to be predicted in this region, the residual often does not have complex texture characteristics. Therefore, by setting the first condition (or the second condition) described above, the encoding method in Figure 16 can be omitted on blocks where the number of samples in the first region is less than or equal to the first threshold to reduce the complexity of the encoder.

[0184] In basic transforms, some transform modes allow transform skipping in the horizontal or vertical directions. Transform blocks using transform skipping often have transform coefficients that don't accurately affect the continuity of the transform block boundaries. Therefore, when transform skipping is used on one or both sides in the horizontal or vertical direction, angle-based sign prediction can be omitted. Thus, by setting the first (or second) condition described above, the encoding method in Figure 16 can be omitted on blocks using transform skipping in the vertical and / or horizontal directions, reducing encoder complexity.

[0185] The choice of the transform kernel for the Indivisible Transform (LFNST, NSPT) is related to the angular direction of the current transform block texture. Therefore, blocks using the Indivisible Transform are more likely to have directional texture features. Thus, when the current transform block is not an Indivisible Transform, the sign prediction technique based on angular direction can be omitted. Therefore, by setting the first (or second) condition described above, the encoding method in Figure 16 can be omitted on blocks that do not use the Indivisible Transform, reducing the encoder complexity.

[0186] For blocks using intra-frame prediction, the selected intra-frame prediction mode can be an angle prediction mode. Such blocks typically possess angular characteristics. However, blocks selecting PLANA or DC modes often lack texture features. Therefore, by setting the second condition described above, the encoding method in Figure 16 can be omitted from blocks using prediction modes without angular features, reducing encoder complexity. For example, prediction modes without angular features include at least one or more of the following: PLANA mode, DC mode, MIP mode, SGPM mode, TIMD mode, DIMD mode, and EIP mode.

[0187] The embodiments of this application can save the additional encoding and decoding time required for angle derivation and sub-pixel position interpolation by setting a first condition (or a second condition), which helps to improve encoding and decoding efficiency.

[0188] Referring again to Figure 16, in step S1620, the target set of hypothesis signs is determined from multiple sets of hypothesis signs based on multiple costs.

[0189] In some implementations, the signs of the set of hypotheses corresponding to the minimum cost among multiple costs can be used as the signs of the target hypotheses. Here, the signs of the target hypotheses can be understood as the signs of the predicted transformation coefficients.

[0190] There are several ways to determine the first angle. For example, the first angle can be determined based on gradient information of the surrounding region of the current block. Alternatively, the first angle can be determined based on the intra-prediction mode of the current block. For instance, if the prediction mode of the current block is intra-prediction mode, then the angle corresponding to that intra-prediction mode can be used as the first angle. Another example is that the first angle can be determined based on the intra-prediction modes of the current block's neighboring blocks. For instance, if the prediction mode of a neighboring block is intra-prediction mode, then the angle corresponding to that intra-prediction mode can be used as the first angle.

[0191] The method of determining the first angle based on intra-frame prediction mode has lower computational overhead, which is beneficial to improving the efficiency of encoding and decoding.

[0192] For methods that determine the first angle based on gradient information, one or more first angles can be determined at multiple locations in the boundary region. Since the current block may have multiple different texture directions at multiple locations in the boundary region, that is, the boundary region may correspond to multiple angles. This method enables the first cost formula to take into account the continuity cost of the boundary region in different texture directions, making it more adaptive and further improving the accuracy of the sign of the predicted transform coefficients, thereby improving encoding and decoding performance.

[0193] In some implementations, determining the first angle based on gradient information can be understood as determining the first angle based on the gradient histogram.

[0194] The first angle determined based on the gradient information can correspond to the angle of the current block. In other words, a first angle can be determined for the current block to execute step S1610.

[0195] For example, a first angle can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding region of the current block. The surrounding region can include one or more of the following: the adjacent reconstructed region above the current block, the adjacent reconstructed region to the left of the current block, and the adjacent reconstructed region to the upper left of the current block. This application does not specifically limit the size of the surrounding region of the current block. For example, Figure 7 shows a schematic diagram of the surrounding region of the current block. As shown in Figure 7, the length of the adjacent reconstructed region above the current block can be the same as the length of the current block, and its height is M, where M is a positive integer greater than or equal to 1. Similarly, as shown in Figure 7, the height of the adjacent reconstructed region to the left of the current block can be the same as the height of the current block, and its length is L, where L is a positive integer greater than or equal to 1.

[0196] For example, as shown in FIG7, if the surrounding area of ​​the current block includes the adjacent reconstruction area above the current block, the adjacent reconstruction area to the left of the current block, and the adjacent reconstruction area to the upper left of the current block, a gradient histogram can be constructed in the surrounding area to determine a first angle to perform step S1610.

[0197] Alternatively, the first angle determined based on the gradient information can correspond to the angle of the boundary region. That is, an angle can be determined for each boundary region of the current block to execute step S1610.

[0198] For example, a first angle can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding area of ​​the left boundary region. This surrounding area can include the adjacent reconstructed area to the left of the current block. Similarly, a first angle can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding area of ​​the upper boundary region. This surrounding area can include the adjacent reconstructed area above the current block. This application embodiment does not specifically limit the size of the surrounding area of ​​the boundary region. For example, Figure 8 shows a schematic diagram of the surrounding area of ​​the boundary region. As shown in Figure 8, the height of the adjacent reconstructed area to the left of the current block can be the same as the height of the current block, and its length is L, where L is a positive integer greater than or equal to 1. Similarly, the length of the adjacent reconstructed area above the current block can be the same as the length of the current block, and its height is M, where M is a positive integer greater than or equal to 1.

[0199] For example, as shown in FIG8, if the surrounding area of ​​the upper boundary region includes the adjacent reconstructed region above the current block, a gradient histogram can be constructed in the surrounding area to determine a first angle; if the surrounding area of ​​the left boundary region includes the adjacent reconstructed region to the left of the current block, a gradient histogram can be constructed in the surrounding area to determine a first angle; then, the two first angles are substituted into the first cost formula to perform step S1610.

[0200] Alternatively, the first angle determined based on the gradient information can correspond to the angle of a sub-region of the boundary region. That is, an angle can be determined for each sub-region of the boundary region to execute step S1610. The boundary region can be divided into multiple sub-regions. For example, the upper boundary region of the current block can be divided into P sub-regions, where P is a positive integer greater than 1. The dimensions of the P sub-regions can be the same or different. For example, the size of each sub-region can be set to N, where N is a positive integer greater than or equal to 1.

[0201] For example, the left boundary region of the current block can be divided into Q sub-regions, where Q is a positive integer greater than 1. The dimensions of the Q sub-regions can be the same or different; for instance, the size of each sub-region can be set to N, where N is a positive integer greater than or equal to 1.

[0202] Multiple first angles can be determined based on the gradient information of the reconstructed sample values ​​of the surrounding areas of multiple sub-regions. Taking multiple sub-regions including a third sub-region as an example, the surrounding areas of the third sub-region can include the first adjacent reconstructed region of the third sub-region.

[0203] This application does not specifically limit the size of the first adjacent reconstructed region in its embodiments. In some implementations, if the third sub-region is located in the upper boundary region of the current block, the length of the first adjacent reconstructed region is greater than or equal to the length of the third sub-region; or, if the third sub-region is located in the left boundary region of the current block, the height of the first adjacent reconstructed region is greater than or equal to the height of the third sub-region. For example, Figure 9 shows a schematic diagram of the surrounding area of ​​a sub-region. As shown in Figure 9, for a sub-region in the upper boundary region, the length of the adjacent reconstructed region can be the same as the length of the sub-region, both being N, and the height is M, where M and N are positive integers greater than or equal to 1. As another example, as shown in Figure 9, for a sub-region in the left boundary region, the height of the adjacent reconstructed region can be the same as the height of the sub-region, both being N, and the length is L, where N and L are positive integers greater than or equal to 1.

[0204] For example, Figure 10 shows another schematic diagram of the surrounding area of ​​a sub-region. As shown in Figure 10, for a sub-region of the upper boundary region, the length of the adjacent reconstructed region can be greater than the length of the sub-region, where the length of the sub-region is N, the length of the adjacent reconstructed region is P+N+O, and the height is M; M, N, P, and O are positive integers greater than or equal to 1. Similarly, as shown in Figure 10, for a sub-region of the left boundary region, the height of the adjacent reconstructed region can be greater than the height of the sub-region, where the height of the sub-region is N, the height of the adjacent reconstructed region is Q+N+R, and the length is L; L, N, Q, and R are positive integers greater than or equal to 1.

[0205] Next, the method for determining the first angle based on gradient information from the surrounding area will be described in detail.

[0206] In some implementations, at least one set of horizontal and vertical gradients can be determined based on reconstructed sample values ​​at at least one location in the surrounding region of the current block; then, at least one angle and at least one magnitude can be determined based on the at least one set of horizontal and vertical gradients; finally, a first angle can be determined based on the at least one angle and at least one magnitude.

[0207] For example, determining the horizontal and vertical gradients can include: calculating the horizontal and vertical gradients by traversing the reconstructed sample values ​​of the locations in the surrounding region using the horizontal gradient operator and the vertical gradient operator, respectively. This application does not specifically limit the type of gradient operator; for example, the Sobel operator, Robert operator, Prevet operator, Schmidt operator, etc., can be used.

[0208] For example, determining the angle based on the gradient can include mapping a set of horizontal and vertical gradients proportionally (e.g., by looking up a table) to the 65 angles of traditional intra-frame prediction.

[0209] For example, methods for determining the magnitude value based on the gradient can include using the sum of the absolute values ​​of the horizontal and vertical gradients as the magnitude value.

[0210] The first angle is one of at least one angles determined based on gradient information. Each of these at least one angles corresponds to a first amplitude value, which is the sum of the amplitude values ​​corresponding to the same angle among the at least one amplitude values. In other words, the amplitude values ​​corresponding to the same angle can be accumulated, and the first amplitude value corresponding to the first angle is the maximum among the first amplitude values ​​corresponding to at least one angle. Alternatively, a gradient histogram can be constructed, and the angle corresponding to the accumulated maximum amplitude value can be used as the first angle.

[0211] In some cases, such as when the gradient value of the surrounding area is 0, the angle corresponding to the boundary region can be assumed to be either horizontal or vertical. For example, the angle corresponding to the upper boundary region is vertical, and the angle corresponding to the left boundary region is horizontal.

[0212] As mentioned earlier, when determining the angular direction based on horizontal and vertical gradients, the gradient information can be mapped to an angle by looking up a table. The following section introduces the aforementioned solution in related technologies.

[0213] Step 1: Solve for the absolute value and sign of the gradient: absG x =|G x |,absG y =|G y | signG x =G x <0?1:0,signG y =G y <0?1:0

[0214] Among them, G x and G y These represent the horizontal and vertical gradients at each location in the surrounding region, respectively; signG x The identifier information representing the horizontal gradient, and if G x If <0, then signG x The value of G is 1. x If > 0, then signG x The value of signG is 0; y The identifier information representing the vertical gradient, and if G y If <0, then signG y The value of G is 1. y If > 0, then signG y The value of is 0.

[0215] Step 2: Determine whether the reference direction of the derived angle is horizontal or vertical. If absG x >absG y If absG, then the reference direction is horizontal; x <absG y Therefore, the reference direction is vertical. It's important to understand that in angle modes 2-66, angle mode 18 is horizontal, and angle mode 50 is vertical. This step can be represented as: offset = absG x >absG y 18:50

[0216] Here, offset is the angle mode for the reference direction.

[0217] Step 3: Determine the offset angle pattern in the reference direction where the derived angle is located. Mathematically, the offset angle can be obtained by calculating the arctan of the ratio of the gradient values ​​in the horizontal and vertical directions. In actual implementation, this step is replaced by a lookup table method. Below is a piece of pseudocode illustrating the lookup process.

[0218] Table 3

[0219] In practical implementation, it is not necessary to solve for the specific angle value of arctan; instead, it can be directly obtained through... A ratio is obtained, and the corresponding angle direction is obtained by looking up a table based on the ratio. The table angTable

[0017] defines 17 angle direction lookup values, where each direction is the angle below the specified value. Approximate values, by comparison The direction can be derived from the size of each lookup table value. The pseudocode snippet above illustrates how to calculate the index idx corresponding to the angle direction using a lookup table.

[0220] Step 4: Based on the reference direction and offset value, export the final angle pattern. Below is a piece of pseudocode illustrating the process of exporting the angle pattern.

[0221] Table 4

[0222] In Table 4, dirs[], mapXgrY1[], and mapXgrY0[] are three predefined tables used to look up the angle pattern that differs from the reference angle.

[0223] intraDir is the final value range of angle mode 2 to angle mode 66 (inclusive of angle mode 2 and angle mode 66).

[0224] As mentioned above, the first angle determined based on the gradient information can be any angle direction, such as the angle directions corresponding to angle patterns 2 through 66. For example, Figure 11 shows a schematic diagram of 65 conventional angle patterns, where angle pattern 2 is the -45° direction, angle pattern 18 is the horizontal direction, angle pattern 34 is the 45° direction, angle pattern 50 is the vertical direction, and angle pattern 66 is the 135° direction; the first angle can be any one or more of the above 65 angle patterns.

[0225] Of course, in some scenarios, certain restrictions can be set on the direction of the first angle. In some implementations, for the upper boundary region of the current block, the corresponding first angle can be within a certain range. The first angle range includes 45° to 135°; for the left boundary region of the current block, the corresponding first angle can be within a certain range. The second angle range includes -45° to 45°. By setting a certain angle range for the first angle, some angles with inaccurate computational costs can be filtered out, thereby improving the accuracy of the sign of the predicted transformation coefficients.

[0226] For example, Figure 12 shows a schematic diagram of the angle direction that limits the first angle. As shown in Figure 12, in the upper boundary region of the current block, the corresponding first angle can be in angle mode 34 to angle mode 66; in the left boundary region of the current block, the corresponding first angle can be in angle mode 2 to angle mode 34.

[0227] In the above scheme of mapping gradient information to angles using a lookup table, before deriving the angle pattern, it is necessary to determine the reference direction corresponding to the angle pattern (the scheme in step two). In scenarios where the angle direction of the first angle is subject to certain constraints, the scheme in step two described above can be adjusted as follows: determine the reference direction of the angle (or angle pattern) based on the position information of the boundary region. For example, if the boundary region is the upper boundary region, the reference direction of the corresponding angle is the vertical direction; or, if the boundary region is the left boundary region, the reference direction of the corresponding angle is the horizontal direction. The adjusted step two can be expressed as: offset = isLeft? 18:50

[0228] Here, offset is the angle mode of the reference direction; when exporting the angle mode corresponding to the left boundary region, the reference direction is set to the horizontal direction (i.e., angle mode 18); when exporting the angle mode corresponding to the upper boundary region, the reference direction is set to the vertical direction (i.e., angle mode 50).

[0229] After determining the first angle, the first position can be determined based on the second position in the boundary region and the first angle. For example, the first position in the reference region can be determined by mapping from the second position in the boundary region to the reference region at the angular direction of the first angle.

[0230] For example, Figure 13 shows a mapping diagram of angle pattern 66. As shown in Figure 13, the reference region includes a first reference row adjacent to the current block and a second reference row next to the current block, and the first angle is angle pattern 66. At a location in the boundary region of the current block (i.e., the second location), mapping according to angle pattern 66 can determine the first position in the first cost formula in the first reference row and the second reference row.

[0231] After determining the first position, the first parameter can be determined based on the reconstructed sample value of the first position. The first position is a position within a reference region. If the reference region includes a first reference region and a second reference region, and the first position is located within the first reference region, the reconstructed sample value of the first position can be associated with one of the following: the reconstructed sample value of the reference block where the first position is located; a reconstructed sample value determined by filling in the reconstructed sample value of the reference block where the first reference region is located; or the reconstructed sample value of the reference block where the second reference region is located. It should be understood that the first reference region can be a region including the upper reference row of the current block, and the second reference region can be a region including the left reference column of the current block, or the first reference region can be a region including the left reference column of the current block, and the second reference region can be a region including the upper reference row of the current block.

[0232] For some angle patterns, the reconstructed sample values ​​provided by the reference row and reference column of the current block may not be sufficient. For example, for angle patterns 34-49, since the reference region pointed to by the angle direction may be located to the left of the reference row of the current block, it is necessary to determine the reconstructed sample values ​​for the extended position of the reference row.

[0233] For the reasons mentioned above, the reconstructed sample value of the first position can be associated with the reconstructed sample value of the reference block where the second reference region is located, or in other words, the reconstructed sample value of the second reference region can be mapped to the first position (i.e., the extended position of the reference row or reference column).

[0234] For example, for angle modes 34-49, the reconstructed sample values ​​of the first reference column and the second reference column adjacent to the left are first mapped upwards as extensions of the first and second reference rows, and then the extended first and second reference rows are mapped to the positions within the current block; for angle modes 19-33, the reconstructed sample values ​​of the first and second reference rows are first mapped as extensions of the first and second reference columns, and then the extended first and second reference columns are mapped to the positions within the current block.

[0235] In addition, for angle patterns 50 to 66, only the reconstructed sample values ​​of the first reference row above and the second reference row below need to be used, and no extension is required; for angle patterns 2 to 18, only the reconstructed sample values ​​of the first reference column to the left and the second reference column below need to be used, and no extension is required.

[0236] For example, Figures 14A and 14B illustrate a mapping diagram under angle mode 34. As shown in Figure 14A, for angle mode 34, the reconstructed sample values ​​of the first reference column and the second reference column adjacent to the left can be mapped upwards as extensions of the first and second reference rows; then, as shown in Figure 14B, the reconstructed sample value of the first position in the reference area is determined by mapping according to the extended first and second reference rows and the first angle.

[0237] Alternatively, the reconstructed sample value at the first position can be associated with the reconstructed sample value of the reference block where the first position is located, or with a reconstructed sample value determined by filling in the reconstructed sample value of the reference block where the first reference region is located. In other words, for some angle patterns, during mapping based on the first angle, if it is necessary to extend the reference row or column, if the block where the extension position is located has already been reconstructed, the reconstructed sample value of that block at that position can be directly used as the reconstructed sample value of the extension position; or, if the block where the extension position is located has not been reconstructed, it can be filled in based on the reconstructed sample values ​​of already reconstructed positions in the reference region (such as reference rows). The advantage of this approach is that, for the upper reference region, the reconstructed sample values ​​used when calculating the cost based on the first cost formula, or in other words, the reconstructed sample value at the first position substituted into the first cost formula, all come from the reconstructed sample values ​​of the block above the current block. In this way, the cost calculated by the first cost formula can better reflect the continuity cost of the upper boundary region of the current block, thus improving the accuracy of the sign of the predicted transform coefficients and consequently improving encoding and decoding performance. The same principle applies to the left reference region, which will not be elaborated here.

[0238] For example, Figure 15 shows a schematic diagram of the extended position of the reconstructed row at the first angle. As shown in Figure 15, at the first angle, the upper reference region includes the reference row (i.e., the reconstructed row) of the current block and the extended region of that reference row. If the block containing the extended region has been reconstructed, the reconstructed sample value at the extended position can be directly used as the reconstructed sample value used when calculating the cost using the first cost formula; if the block containing the extended region has not been reconstructed, the reconstructed sample value in the reference row can be used to fill the extended region, and the filled reconstructed sample value can be used as the reconstructed sample value used when calculating the cost using the first cost formula.

[0239] During the mapping process, the position of the mapping direction may not correspond to the integer point position of the current source pixel. Therefore, in some implementations, the reconstructed sample value of the first position is determined by interpolation based on the reconstructed sample values ​​of the surrounding positions. The interpolation filter used can be, for example, an N-tap filter, such as a 2-tap, 4-tap, 6-tap, or 8-tap filter.

[0240] In some implementations, before performing step S1610, the encoding method shown in FIG16 may further include: determining multiple sets of predicted reconstructed sample values ​​for the boundary region of the current block based on multiple sets of hypothesis signs corresponding to at least one transform coefficient of the current block. For example, multiple hypothesis residual blocks of the current block can be determined based on multiple sets of hypothesis signs; then, multiple sets of hypothesis reconstructed sample values ​​are determined based on the multiple hypothesis residual blocks and the prediction blocks of the current block.

[0241] For example, determining the residual block of multiple hypotheses for the current block can include: determining the transformation coefficients of multiple hypotheses for the current block based on the signs of multiple sets of hypotheses; and then performing an inverse transformation on the transformation coefficients of the multiple sets of hypotheses to determine the residual block of multiple hypotheses.

[0242] In some implementations, after executing step S1620, the encoding method shown in Figure 16 may further include: determining the reconstructed block of the current block based on the sign of the target group assumption. For example, at least one transform coefficient can be determined based on the sign of the target group assumption; then, the at least one transform coefficient is inversely transformed to determine the residual block of the current block; finally, the reconstructed block is determined based on the residual block and the predicted block of the current block. For example, the sum of the residual block and the predicted block can be used as the reconstructed block.

[0243] In some implementations, the encoding method shown in Figure 16 may further include: writing first identification information into the bitstream. The first identification information is used to indicate whether the sign of the hypothesis corresponding to the transform coefficient is correct. For example, if the target hypothesis sign is correct, the first identification information indicates that the sign of the hypothesis corresponding to the transform coefficient is correct; if the target hypothesis sign is incorrect, the first identification information indicates that the sign of the hypothesis corresponding to the transform coefficient is incorrect.

[0244] 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 examples given below, and such modifications or variations also fall within the scope of the embodiments of this application.

[0245] Example 1

[0246] In this example, when determining the first angle, a first angle is derived based on the gradient information of the surrounding area for the entire current block, and the cost is calculated based on this first angle. Example 1 includes steps one through three, which are described in detail below.

[0247] Step 1: Construct a gradient histogram to derive the first angle.

[0248] As shown in Figure 7, the horizontal and vertical gradients are calculated by traversing the reconstructed regions surrounding the current block using horizontal and vertical gradient operators. Gradient operators such as the Sobel operator, Robert operator, Prevert operator, and Schmidt operator can be used to calculate the horizontal and vertical gradients.

[0249] The surrounding region (reconstructed region) of the current block can include one or more of the adjacent reconstructed regions above, to the left, and to the upper left of the current block. The horizontal gradient g at each location... x and vertical gradient g y The proportional relationships are mapped to the 65 angles of traditional intra-frame prediction (as shown in Figure 11), and the amplitude value Amp = abs(g) at each position is calculated. x )+abs(g y The algorithm iterates through the positions in each reconstructed region, accumulating the amplitude value of each position to the corresponding angle category. Finally, it calculates the angle with the largest amplitude value as the derived angle direction used to calculate edge continuity (i.e., the first angle). When the gradient value of a position in an adjacent reconstructed region is 0, and the angle cannot be derived from the gradient histogram, the first angle can be set to a default angle, such as the horizontal or vertical direction (the vertical direction is used for positions in the upper boundary region, and the horizontal direction is used for positions in the left boundary region).

[0250] Step 2: Determine the reconstructed sample at the first position based on the exported first angle.

[0251] Based on the exported first angle, the first row and first column within the current block are mapped using the first reference row adjacent to the current block and the second reference row adjacent to the current block, respectively. Figures 13, 14A, and 14B are mapping examples for angle mode 66 and angle mode 34, respectively.

[0252] For angle modes 34-49, the reconstructed sample values ​​of the first and second adjacent reference columns on the left are first mapped upwards as extensions of the first and second reference rows. Only then can the extended first and second reference rows be mapped to their positions within the current block. For angle modes 19-33, the reconstructed sample values ​​of the first and second reference rows are first used as extensions of the first and second reference columns. Only then can the extended first and second reference columns be mapped to their positions within the current block. Furthermore, for angle modes 50-66, the mapping process only requires the reconstructed sample values ​​from the first and second adjacent reference rows above. For angle modes 2-18, the mapping only requires the reconstructed sample values ​​from the first and second adjacent reference columns on the left.

[0253] During the mapping process, there may be instances where the mapped position does not correspond to the integer point position of the current source pixel. In such cases, interpolation is required, and then the interpolated pixel value is mapped. The interpolation filter used for interpolation can be N-tap, such as 2-tap, 4-tap, 6-tap, 8-tap, etc.

[0254] Step 3: Based on the multiple costs calculated using the first cost formula, determine the sign of the predicted transformation coefficients.

[0255] As shown in Figure 14B, the mapping value of the first reference row at the gray position is taken as r. 0(x,0) ,r 0(0,y) The mapping value of the second reference row at the gray position is used as r. 1(x,0) ,r 0(0,y) Substitute the values ​​of r0 and r1 into the following first cost formula:

[0256] The cost corresponding to each set of hypothetical reconstructed values ​​is calculated according to the first cost formula, and the sign of the transformation coefficients corresponding to the set of hypothetical reconstructed values ​​with the lowest cost is taken as the predicted value.

[0257] Example 2

[0258] In this example, when determining the first angle, two first angles are derived based on the gradient information of the surrounding area, taking the entire boundary region (left boundary region or upper boundary region) as the unit, and the cost is calculated based on these two first angles.

[0259] Example 2 includes steps one through three. The difference from Example 1 is that in step one, a first angle is determined based on the gradient information of the reconstructed sample values ​​of the surrounding area of ​​the left boundary region; and a first angle is also determined based on the gradient information of the reconstructed sample values ​​of the surrounding area of ​​the upper boundary region. The content of the other steps is similar to that of the corresponding steps in Example 1, and will not be repeated here.

[0260] Example 3

[0261] In this example, when determining the first angle, multiple first angles are derived based on the gradient information of the surrounding area, taking the entire boundary region as a unit. The cost is then calculated based on these multiple first angles.

[0262] Example 2 includes steps one through three. The difference from Example 1 is that in step one, the boundary region can be divided into multiple sub-regions.

[0263] For example, the upper boundary region of the current block can be divided into P sub-regions, where P is a positive integer greater than 1. The sub-regions can have the same size; for example, each sub-region can have a size of N, where N is a positive integer greater than or equal to 1. The left boundary region of the current block can be divided into Q sub-regions, where Q is a positive integer greater than 1. The sub-regions can also have the same size; for example, each sub-region can have a size of N, where N is a positive integer greater than or equal to 1. Then, a first angle is derived for each sub-region.

[0264] Steps two and three are similar to those in Example one, except that the first angle derived from each sub-region may be different, and the mapping direction will also be different, as shown in Figure 17.

[0265] The surrounding region corresponding to the first sub-region can be implemented in two ways. In the first implementation, as shown in Figure 9, for the sub-region of the upper boundary region, the length of the corresponding surrounding region can be the same as the length of the sub-region, both being N, and the height is M, where M and N are positive integers greater than or equal to 1. For the sub-region of the left boundary region, the height of the corresponding surrounding region can be the same as the height of the sub-region, both being N, and the length is L, where N and L are positive integers greater than or equal to 1.

[0266] In the second implementation, as shown in Figure 10, for the sub-region of the upper boundary region, the length of the corresponding surrounding region can be greater than the length of the sub-region. Here, the length of the sub-region is N, the length of the surrounding region is P+N+O, and the height is M; M, N, P, and O are positive integers greater than or equal to 1. For the sub-region of the left boundary region, the height of the corresponding surrounding region can be greater than the height of the sub-region. Here, the height of the sub-region is N, the height of the surrounding region is Q+N+R, and the length is L; L, N, Q, and R are positive integers greater than or equal to 1. For example, M = L = 3, N = 4, P = O = Q = R = 2. The content of other steps is similar to the corresponding steps in Example 1 and will not be repeated here.

[0267] Based on the encoding and decoding method provided in the embodiments of this application, a set of test results were obtained by applying it to the reference software of ECM to verify its performance improvement.

[0268] Table 5

[0269] Table 5 shows the test results obtained when implementing the scheme in Example 3 (second implementation method) on the ECM reference software, with M=L=3, N=4, P=O=Q=R=2, and in the configuration of all frames within the frame. According to the test results in Table 5, a decrease in BD-rates can be achieved in multiple categories of test sequences, with overall average objective performance improvements of 0.02%, 0.01%, and 0.05% in the Y, U, and V components, respectively.

[0270] The method embodiments of this application have been described in detail above with reference to Figures 1 to 17. The apparatus embodiments of this application will be described in detail below with reference to Figures 18 to 21. 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.

[0271] Figure 18 is a schematic diagram of the structure of a decoder provided in an embodiment of this application. As shown in Figure 18, the decoder 1800 includes: a first determining unit 1810 and a second determining unit 1820.

[0272] The first determining unit 1810 is configured to determine multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block.

[0273] The second determining unit 1820 is configured to determine the target set of hypothesis signs from the plurality of sets of hypothesis signs based on the plurality of costs;

[0274] The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle.

[0275] In some implementations, the first angle includes any of the following:

[0276] The angle is determined based on the gradient information of the surrounding area of ​​the current block;

[0277] The angle is determined based on the intra-prediction mode of the current block;

[0278] The angle is determined by the intra-prediction mode of the adjacent blocks of the current block.

[0279] In some implementations, where:

[0280] The first angle corresponds to the angle of the current block; or,

[0281] The first angle corresponds to the angle of the boundary region, or,

[0282] The first angle corresponds to the angle of the sub-region of the boundary region.

[0283] In some implementations, the boundary region includes the left boundary region of the current block and / or the upper boundary region of the current block.

[0284] In some implementations, the sub-regions of the boundary region include:

[0285] The first sub-region is any one of multiple sub-regions of the upper boundary region of the current block, and the length of the first sub-region is N; and / or,

[0286] The second sub-region is any one of the multiple sub-regions of the left boundary region of the current block, and the height of the second sub-region is N;

[0287] Where N is an integer greater than or equal to 1.

[0288] In some implementations, if the first angle corresponds to the angle of the current block, then the surrounding region includes one or more of the following:

[0289] The adjacent reconstruction area above the current block;

[0290] The adjacent reconstruction area to the left of the current block;

[0291] The adjacent reconstruction area on the upper left side of the current block.

[0292] In some implementations, where:

[0293] If the first angle corresponds to the angle of the upper boundary region of the current block, then the surrounding region is the adjacent reconstructed region on the upper side of the current block; or,

[0294] If the first angle corresponds to the angle of the left boundary region of the current block, then the surrounding region is the adjacent reconstruction region on the left side of the current block.

[0295] In some implementations, the sub-region of the boundary region includes a third sub-region, and if the first angle corresponds to the angle of the third sub-region, then the surrounding region is the first adjacent reconstructed region of the third sub-region.

[0296] In some implementations, where:

[0297] If the third sub-region is located on the upper boundary of the current block, then the length of the first adjacent reconstructed region is greater than or equal to the length of the third sub-region; or,

[0298] If the third sub-region is located in the left boundary region of the current block, then the height of the first adjacent reconstructed region is greater than or equal to the height of the third sub-region.

[0299] In some implementations, where:

[0300] If the boundary region is the upper boundary region of the current block, then the first angle is within a first angle range, which includes 45° to 135°; or,

[0301] If the boundary region is the left boundary region of the current block, then the first angle is within the range of the second angle, which includes -45° to 45°.

[0302] In some implementations, if the boundary region is the upper boundary region of the current block, then the first angle mode is located within a first angle range, the first angle range including angle mode 34 to angle mode 66; or,

[0303] If the boundary region is the left boundary region of the current block, then the first angle mode is within the second angle range, which includes angle mode 2 to angle mode 34.

[0304] In some implementations, the decoder 1800 further includes:

[0305] The third determining unit is configured to determine at least one set of horizontal and vertical gradients based on reconstructed sample values ​​at at least one location in the surrounding area.

[0306] The fourth determining unit is configured to determine at least one angle and at least one magnitude based on the at least one set of horizontal and vertical gradients.

[0307] The fifth determining unit is configured to determine the first angle based on the at least one angle and the at least one amplitude.

[0308] In some implementations, the first angle is one of the at least one angles, the at least one angles respectively correspond to a first amplitude value, the first amplitude value is the sum of the amplitude values ​​corresponding to the same angle among the at least one amplitudes, and the first amplitude value corresponding to the first angle is the maximum value among the first amplitude values ​​corresponding to the at least one angle.

[0309] In some implementations, the decoder 1800 further includes:

[0310] The sixth determining unit is configured to determine the reference direction of the at least one angle based on the position information of the boundary region;

[0311] The seventh determining unit is configured to determine the at least one angle based on the reference direction and the at least one set of horizontal and vertical gradients.

[0312] In some implementations, where:

[0313] If the boundary region is the upper boundary region, then the reference direction is the vertical direction; or,

[0314] If the boundary region is the left boundary region, then the reference direction is the horizontal direction.

[0315] In some implementations, the decoder 1800 further includes:

[0316] The eighth determining unit is configured to determine the first position based on the second position in the boundary region and the first angle;

[0317] The ninth determining unit is configured to determine the first parameter based on the reconstructed sample value at the first position.

[0318] In some implementations, the reference region includes a first reference region and a second reference region, the first position is located within the first reference region, and the reconstructed sample value at the first position is associated with any of the following:

[0319] The reconstructed sample value of the reference block where the first position is located;

[0320] The determined reconstructed sample values ​​are filled based on the reconstructed sample values ​​of the reference block where the first reference region is located;

[0321] The reconstructed sample values ​​of the reference block where the second reference region is located;

[0322] Wherein, the first reference area is the area including the upper reference row of the current block, and the second reference area is the area including the left reference column of the current block, or the first reference area is the area including the left reference column of the current block, and the second reference area is the area including the upper reference row of the current block.

[0323] In some implementations, the first determining unit 1810 is configured to determine the plurality of costs based on the plurality of sets of hypothetical reconstruction sample values ​​and the first cost formula if the current block satisfies the first condition;

[0324] The first condition includes one or more of the following:

[0325] The current block is a brightness block;

[0326] The number of samples in the first region of the current block is greater than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1.

[0327] The number of samples in the second region of the current block is greater than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1.

[0328] The current block is not allowed to be transformed or skipped in the vertical and / or horizontal directions;

[0329] The current block uses an indivisible transformation.

[0330] In some implementations, the decoder 1800 further includes a first processing unit configured to, if the current block satisfies a second condition, not perform the following steps: reconstructing sample values ​​and a first cost formula based on multiple sets of assumptions about the boundary region of the current block, and determining multiple costs;

[0331] The second condition includes one or more of the following:

[0332] The current block is a chroma block;

[0333] The number of samples in the first region of the current block is less than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1.

[0334] The number of samples in the second region of the current block is less than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1.

[0335] The current block is skipped using a transformation in the vertical and / or horizontal directions;

[0336] The prediction mode of the current block includes at least one or more of the following: PLANA mode, DC mode, MIP mode, SGPM mode, TIMD mode, DIMD mode, and EIP mode.

[0337] 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.

[0338] 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.

[0339] Therefore, embodiments of this application provide a computer-readable storage medium applied to a decoder 1800, the computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned decoding method.

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

[0341] The communication interface 1910 is used for receiving and sending signals during the process of sending and receiving information with other external network elements.

[0342] Memory 1920 is used to store computer programs.

[0343] Processor 1930, when running the computer program, is configured to perform:

[0344] Multiple costs are determined based on the reconstructed sample values ​​of multiple sets of hypotheses of the current block's boundary region and the first cost formula. The reconstructed sample values ​​of multiple sets of hypotheses are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block.

[0345] Based on the multiple costs, determine the target set of hypothesis signs from the multiple sets of hypothesis signs;

[0346] The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle.

[0347] It is understood that the memory 1920 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 1920 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.

[0348] The processor 1930 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 1930 or by instructions in software form. The processor 1930 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 can be 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 1920. Processor 1930 reads the information in memory 1920 and, in conjunction with its hardware, completes the steps of the above method.

[0349] 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.

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

[0351] Figure 20 is a schematic diagram of the structure of an encoder provided in an embodiment of this application. As shown in Figure 20, the encoder 2000 includes: a first determining unit 2010 and a second determining unit 2020.

[0352] The first determining unit 2010 is configured to determine multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block.

[0353] The second determining unit 2020 is configured to determine the target set of hypothesis positive and negative signs from the plurality of sets of hypothesis positive and negative signs based on the plurality of costs;

[0354] The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle.

[0355] In some implementations, the first angle includes any of the following:

[0356] The angle is determined based on the gradient information of the surrounding area of ​​the current block;

[0357] The angle is determined based on the intra-prediction mode of the current block;

[0358] The angle is determined by the intra-prediction mode of the adjacent blocks of the current block.

[0359] In some implementations, where:

[0360] The first angle corresponds to the angle of the current block; or,

[0361] The first angle corresponds to the angle of the boundary region, or,

[0362] The first angle corresponds to the angle of the sub-region of the boundary region.

[0363] In some implementations, the boundary region includes the left boundary region of the current block and / or the upper boundary region of the current block.

[0364] In some implementations, the sub-regions of the boundary region include:

[0365] The first sub-region is any one of multiple sub-regions of the upper boundary region of the current block, and the length of the first sub-region is N; and / or,

[0366] The second sub-region is any one of the multiple sub-regions of the left boundary region of the current block, and the height of the second sub-region is N;

[0367] Where N is an integer greater than or equal to 1.

[0368] In some implementations, if the first angle corresponds to the angle of the current block, then the surrounding region includes one or more of the following:

[0369] The adjacent reconstruction area above the current block;

[0370] The adjacent reconstruction area to the left of the current block;

[0371] The adjacent reconstruction area on the upper left side of the current block.

[0372] In some implementations, where:

[0373] If the first angle corresponds to the angle of the upper boundary region of the current block, then the surrounding region is the adjacent reconstructed region on the upper side of the current block; or,

[0374] If the first angle corresponds to the angle of the left boundary region of the current block, then the surrounding region is the adjacent reconstruction region on the left side of the current block.

[0375] In some implementations, the sub-region of the boundary region includes a third sub-region, and if the first angle corresponds to the angle of the third sub-region, then the surrounding region is the first adjacent reconstructed region of the third sub-region.

[0376] In some implementations, where:

[0377] If the third sub-region is located on the upper boundary of the current block, then the length of the first adjacent reconstructed region is greater than or equal to the length of the third sub-region; or,

[0378] If the third sub-region is located in the left boundary region of the current block, then the height of the first adjacent reconstructed region is greater than or equal to the height of the third sub-region.

[0379] In some implementations, where:

[0380] If the boundary region is the upper boundary region of the current block, then the first angle is within a first angle range, which includes 45° to 135°; or,

[0381] If the boundary region is the left boundary region of the current block, then the first angle is within the range of the second angle, which includes -45° to 45°.

[0382] In some implementations, if the boundary region is the upper boundary region of the current block, then the first angle mode is located within a first angle range, the first angle range including angle mode 34 to angle mode 66; or,

[0383] If the boundary region is the left boundary region of the current block, then the first angle mode is within the second angle range, which includes angle mode 2 to angle mode 34.

[0384] In some implementations, the encoder 2000 further includes:

[0385] The third determining unit is configured to determine at least one set of horizontal and vertical gradients based on reconstructed sample values ​​at at least one location in the surrounding area.

[0386] The fourth determining unit is configured to determine at least one angle and at least one magnitude based on the at least one set of horizontal and vertical gradients.

[0387] The fifth determining unit is configured to determine the first angle based on the at least one angle and the at least one amplitude.

[0388] In some implementations, the first angle is one of the at least one angles, the at least one angles respectively correspond to a first amplitude value, the first amplitude value is the sum of the amplitude values ​​corresponding to the same angle among the at least one amplitudes, and the first amplitude value corresponding to the first angle is the maximum value among the first amplitude values ​​corresponding to the at least one angle.

[0389] In some implementations, the encoder 2000 further includes:

[0390] The sixth determining unit is configured to determine the reference direction of the at least one angle based on the position information of the boundary region;

[0391] The seventh determining unit is configured to determine the at least one angle based on the reference direction and the at least one set of horizontal and vertical gradients.

[0392] In some implementations, where:

[0393] If the boundary region is the upper boundary region, then the reference direction is the vertical direction; or,

[0394] If the boundary region is the left boundary region, then the reference direction is the horizontal direction.

[0395] In some implementations, the encoder 2000 further includes:

[0396] The eighth determining unit is configured to determine the first position based on the second position in the boundary region and the first angle;

[0397] The ninth determining unit is configured to determine the first parameter based on the reconstructed sample value at the first position.

[0398] In some implementations, the reference region includes a first reference region and a second reference region, the first position is located within the first reference region, and the reconstructed sample value at the first position is associated with any of the following:

[0399] The reconstructed sample value of the reference block where the first position is located;

[0400] The determined reconstructed sample values ​​are filled based on the reconstructed sample values ​​of the reference block where the first reference region is located;

[0401] The reconstructed sample values ​​of the reference block where the second reference region is located;

[0402] Wherein, the first reference area is the area including the upper reference row of the current block, and the second reference area is the area including the left reference column of the current block, or the first reference area is the area including the left reference column of the current block, and the second reference area is the area including the upper reference row of the current block.

[0403] In some implementations, the first determining unit 2010 is configured to determine the plurality of costs based on the plurality of sets of hypothetical reconstruction sample values ​​and the first cost formula if the current block satisfies the first condition;

[0404] The first condition includes one or more of the following:

[0405] The current block is a brightness block;

[0406] The number of samples in the first region of the current block is greater than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1.

[0407] The number of samples in the second region of the current block is greater than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1.

[0408] The current block is not allowed to be transformed or skipped in the vertical and / or horizontal directions;

[0409] The current block uses an indivisible transformation.

[0410] In some implementations, the encoder 2000 further includes a first processing unit configured to, if the current block satisfies a second condition, not perform the following steps: reconstructing sample values ​​and a first cost formula based on multiple sets of assumptions about the boundary region of the current block, and determining multiple costs;

[0411] The second condition includes one or more of the following:

[0412] The current block is a chroma block;

[0413] The number of samples in the first region of the current block is less than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1.

[0414] The number of samples in the second region of the current block is less than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1.

[0415] The current block is skipped using a transformation in the vertical and / or horizontal directions;

[0416] The prediction mode of the current block includes at least one or more of the following: PLANA mode, DC mode, MIP mode, SGPM mode, TIMD mode, DIMD mode, and EIP mode. 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 non-modular. 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 can be implemented in hardware or as a software functional module.

[0417] 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.

[0418] Therefore, this application provides a computer-readable storage medium for use in an encoder 2000. The computer-readable storage medium stores a computer program that, when executed by a processor, implements the encoding method described in the foregoing embodiments.

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

[0420] The communication interface 2110 is used for receiving and sending signals during the process of sending and receiving information with other external network elements.

[0421] Memory 2120 is used to store computer programs.

[0422] Processor 2130, when running the computer program, performs the following:

[0423] Multiple costs are determined based on the reconstructed sample values ​​of multiple sets of hypotheses of the current block's boundary region and the first cost formula. The reconstructed sample values ​​of multiple sets of hypotheses are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block.

[0424] Based on the multiple costs, determine the target set of hypothesis signs from the multiple sets of hypothesis signs;

[0425] The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle.

[0426] It is understood that the memory 2120 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 2120 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.

[0427] The processor 2130 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 2130 or by instructions in software form. The processor 2130 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 2120. Processor 2130 reads the information in memory 2120 and completes the steps of the above method in conjunction with its hardware.

[0428] 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.

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

[0430] 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.

[0431] 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.

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

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

[0434] 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.

[0435] 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

A decoding method, applied to a decoder, includes: Multiple costs are determined based on the reconstructed sample values ​​of multiple sets of hypotheses for the boundary region of the current block and the first cost formula. The reconstructed sample values ​​of multiple sets of hypotheses are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block. Based on the multiple costs, determine the target set of hypothesis signs from the multiple sets of hypothesis signs; The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle. The method of claim 1, wherein, The first angle includes any of the following: The angle is determined based on the gradient information of the surrounding area of ​​the current block; The angle is determined based on the intra-prediction mode of the current block; The angle is determined by the intra-prediction mode of the adjacent blocks of the current block. The method according to claim 1 or 2, wherein: The first angle corresponds to the angle of the current block; or, The first angle corresponds to the angle of the boundary region, or, The first angle corresponds to the angle of the sub-region of the boundary region. According to the method of claim 3, the boundary region includes the left boundary region of the current block and / or the upper boundary region of the current block. The method according to claim 3 or 4, wherein The sub-regions of the boundary region include: The first sub-region is any one of multiple sub-regions of the upper boundary region of the current block, and the length of the first sub-region is N; and / or, The second sub-region is any one of the multiple sub-regions of the left boundary region of the current block, and the height of the second sub-region is N; Where N is an integer greater than or equal to 1. The method of any one of claims 3 to 5, wherein, If the first angle corresponds to the angle of the current block, then the surrounding area includes one or more of the following: The adjacent reconstruction area above the current block; The adjacent reconstruction area to the left of the current block; The adjacent reconstruction area on the upper left side of the current block. The method according to any one of claims 3 to 5, wherein: If the first angle corresponds to the angle of the upper boundary region of the current block, then the surrounding region is the adjacent reconstructed region on the upper side of the current block; or, If the first angle corresponds to the angle of the left boundary region of the current block, then the surrounding region is the adjacent reconstruction region on the left side of the current block. The method according to any one of claims 3 to 5, wherein The sub-region of the boundary region includes a third sub-region. If the first angle corresponds to the angle of the third sub-region, then the surrounding region is the first adjacent reconstructed region of the third sub-region. The method according to claim 8, wherein: If the third sub-region is located on the upper boundary of the current block, then the length of the first adjacent reconstructed region is greater than or equal to the length of the third sub-region; or, If the third sub-region is located in the left boundary region of the current block, then the height of the first adjacent reconstructed region is greater than or equal to the height of the third sub-region. The method according to any one of claims 1 to 9, wherein: If the boundary region is the upper boundary region of the current block, then the first angle is within a first angle range, which includes 45° to 135°; or, If the boundary region is the left boundary region of the current block, then the first angle is within the range of the second angle, which includes -45° to 45°. The method according to any one of claims 1 to 9, wherein: If the boundary region is the upper boundary region of the current block, then the first angle pattern is within a first angle range, which includes angle pattern 34 to angle pattern 66; or, If the boundary region is the left boundary region of the current block, then the first angle mode is within the second angle range, which includes angle mode 2 to angle mode 34. The method of any one of claims 2-11, wherein The method further includes: Based on the reconstructed sample values ​​at at least one location in the surrounding area, determine at least one set of horizontal and vertical gradients; Based on the at least one set of horizontal and vertical gradients, determine at least one angle and at least one magnitude; The first angle is determined based on the at least one angle and the at least one magnitude. The method of claim 12, wherein, The first angle is one of the at least one angles, and the at least one angle corresponds to a first amplitude value. The first amplitude value is the sum of the amplitude values ​​corresponding to the same angle among the at least one amplitudes, and the first amplitude value corresponding to the first angle is the maximum value among the first amplitude values ​​corresponding to the at least one angle. The method according to claim 12 or 13, wherein The method further includes: Based on the location information of the boundary region, determine the reference direction of the at least one angle; The at least one angle is determined based on the reference direction and the at least one set of horizontal and vertical gradients. The method according to claim 14, wherein: If the boundary region is the upper boundary region, then the reference direction is the vertical direction; or, If the boundary region is the left boundary region, then the reference direction is the horizontal direction. The method of claim 1, wherein, The method further includes: The first position is determined based on the second position in the boundary region and the first angle; The first parameter is determined based on the reconstructed sample value at the first location. The method of claim 16, wherein, The reference region includes a first reference region and a second reference region, the first position is located in the first reference region, and the reconstructed sample value at the first position is associated with any of the following: The reconstructed sample value of the reference block where the first position is located; The determined reconstructed sample values ​​are filled based on the reconstructed sample values ​​of the reference block where the first reference region is located; The reconstructed sample values ​​of the reference block where the second reference region is located; Wherein, the first reference area is the area including the upper reference row of the current block, and the second reference area is the area including the left reference column of the current block, or the first reference area is the area including the left reference column of the current block, and the second reference area is the area including the upper reference row of the current block. The method of any one of claims 1 to 17, wherein, The process involves reconstructing sample values ​​based on multiple sets of assumptions about the boundary region of the current block and determining multiple costs using a first cost formula, including: If the current block satisfies the first condition, then the multiple costs are determined based on the multiple sets of hypotheses to reconstruct sample values ​​and the first cost formula; The first condition includes one or more of the following: The current block is a brightness block; The number of samples in the first region of the current block is greater than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1. The number of samples in the second region of the current block is greater than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1. The current block is not allowed to be transformed or skipped in the vertical and / or horizontal directions; The current block uses an indivisible transformation. The method of any one of claims 1 to 18, wherein, The method further includes: If the current block satisfies the second condition, the following steps are not performed: reconstructing sample values ​​and the first cost formula based on multiple sets of assumptions about the boundary region of the current block, and determining multiple costs; The second condition includes one or more of the following: The current block is a chroma block; The number of samples in the first region of the current block is less than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1. The number of samples in the second region of the current block is less than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1. The current block is skipped using a transformation in the vertical and / or horizontal directions; The prediction mode of the current block includes at least one or more of the following: Planar mode, DC mode, matrix-based intra-prediction MIP mode, spatial geometry partitioning mode (SGPM mode), template-based intra-prediction TIMD mode, intra-prediction DIMD mode derived from intra-prediction mode, and enhanced intra-prediction EIP mode. An encoding method, applied to an encoder, includes: Multiple costs are determined based on the reconstructed sample values ​​of multiple sets of hypotheses for the boundary region of the current block and the first cost formula. The reconstructed sample values ​​of multiple sets of hypotheses are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block. Based on the multiple costs, determine the target set of hypothesis signs from the multiple sets of hypothesis signs; The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle. The method of claim 20, wherein, The first angle includes any of the following: The angle is determined based on the gradient information of the surrounding area of ​​the current block; The angle is determined based on the intra-prediction mode of the current block; The angle is determined by the intra-prediction mode of the adjacent blocks of the current block. The method according to claim 20 or 21, wherein: The first angle corresponds to the angle of the current block; or, The first angle corresponds to the angle of the boundary region, or, The first angle corresponds to the angle of the sub-region of the boundary region. According to the method of claim 22, the boundary region includes the left boundary region of the current block and / or the upper boundary region of the current block. The method according to claim 22 or 23, wherein The sub-regions of the boundary region include: The first sub-region is any one of multiple sub-regions of the upper boundary region of the current block, and the length of the first sub-region is N; and / or, The second sub-region is any one of the multiple sub-regions of the left boundary region of the current block, and the height of the second sub-region is N; Where N is an integer greater than or equal to 1. The method of any one of claims 22 to 24, wherein, If the first angle corresponds to the angle of the current block, then the surrounding area includes one or more of the following: The adjacent reconstruction area above the current block; The adjacent reconstruction area to the left of the current block; The adjacent reconstruction area on the upper left side of the current block. The method according to any one of claims 22 to 24, wherein: If the first angle corresponds to the angle of the upper boundary region of the current block, then the surrounding region is the adjacent reconstructed region on the upper side of the current block; or, If the first angle corresponds to the angle of the left boundary region of the current block, then the surrounding region is the adjacent reconstruction region on the left side of the current block. The method of any one of claims 22 to 24, wherein The sub-region of the boundary region includes a third sub-region. If the first angle corresponds to the angle of the third sub-region, then the surrounding region is the first adjacent reconstructed region of the third sub-region. The method according to claim 27, wherein: If the third sub-region is located on the upper boundary of the current block, then the length of the first adjacent reconstructed region is greater than or equal to the length of the third sub-region; or, If the third sub-region is located in the left boundary region of the current block, then the height of the first adjacent reconstructed region is greater than or equal to the height of the third sub-region. The method according to any one of claims 20 to 28, wherein: If the boundary region is the upper boundary region of the current block, then the first angle is within a first angle range, which includes 45° to 135°; or, If the boundary region is the left boundary region of the current block, then the first angle is within the range of the second angle, which includes -45° to 45°. The method according to any one of claims 20 to 28, wherein: If the boundary region is the upper boundary region of the current block, then the first angle pattern is within a first angle range, which includes angle pattern 34 to angle pattern 66; or, If the boundary region is the left boundary region of the current block, then the first angle mode is within the second angle range, which includes angle mode 2 to angle mode 34. The method of any one of claims 21 to 30, wherein The method further includes: Based on the reconstructed sample values ​​at at least one location in the surrounding area, determine at least one set of horizontal and vertical gradients; Based on the at least one set of horizontal and vertical gradients, determine at least one angle and at least one magnitude; The first angle is determined based on the at least one angle and the at least one magnitude. The method of claim 31, wherein, The first angle is one of the at least one angles, and the at least one angle corresponds to a first amplitude value. The first amplitude value is the sum of the amplitude values ​​corresponding to the same angle among the at least one amplitudes, and the first amplitude value corresponding to the first angle is the maximum value among the first amplitude values ​​corresponding to the at least one angle. The method of claim 31 or 32, wherein, The method further includes: Based on the location information of the boundary region, determine the reference direction of the at least one angle; The at least one angle is determined based on the reference direction and the at least one set of horizontal and vertical gradients. The method according to claim 33, wherein: If the boundary region is the upper boundary region, then the reference direction is the vertical direction; or, If the boundary region is the left boundary region, then the reference direction is the horizontal direction. The method of claim 20, wherein, The method further includes: The first position is determined based on the second position in the boundary region and the first angle; The first parameter is determined based on the reconstructed sample value at the first location. The method of claim 35, wherein, The reference region includes a first reference region and a second reference region, the first position is located in the first reference region, and the reconstructed sample value at the first position is associated with any of the following: The reconstructed sample value of the reference block where the first position is located; The determined reconstructed sample values ​​are filled based on the reconstructed sample values ​​of the reference block where the first reference region is located; The reconstructed sample values ​​of the reference block where the second reference region is located; Wherein, the first reference area is the area including the upper reference row of the current block, and the second reference area is the area including the left reference column of the current block, or the first reference area is the area including the left reference column of the current block, and the second reference area is the area including the upper reference row of the current block. The method of any one of claims 20-36, wherein The process involves reconstructing sample values ​​based on multiple sets of assumptions about the boundary region of the current block and determining multiple costs using a first cost formula, including: If the current block satisfies the first condition, then the multiple costs are determined based on the multiple sets of hypotheses to reconstruct sample values ​​and the first cost formula; The first condition includes one or more of the following: The current block is a brightness block; The number of samples in the first region of the current block is greater than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1. The number of samples in the second region of the current block is greater than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1. The current block is not allowed to be transformed or skipped in the vertical and / or horizontal directions; The current block uses an indivisible transformation. The method of any one of claims 20-37, wherein The method further includes: If the current block satisfies the second condition, the following steps are not performed: reconstructing sample values ​​and the first cost formula based on multiple sets of assumptions about the boundary region of the current block, and determining multiple costs; The second condition includes one or more of the following: The current block is a chroma block; The number of samples in the first region of the current block is less than or equal to a first threshold. The first region is the N×N region in the upper left corner of the current block, where N is a positive integer greater than or equal to 1. The number of samples in the second region of the current block is less than or equal to the second threshold. The second region is any region other than the N×N region at the top left corner of the current block, where N is a positive integer greater than or equal to 1. The current block is skipped using a transformation in the vertical and / or horizontal directions; The prediction mode of the current block includes at least one or more of the following: Planar mode, DC mode, matrix-based intra-prediction MIP mode, spatial geometry partitioning mode (SGPM mode), template-based intra-prediction TIMD mode, intra-prediction DIMD mode derived from intra-prediction mode, and enhanced intra-prediction EIP mode. A decoder, comprising: The first determining unit is configured to determine multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block. The second determining unit is configured to determine the target set of hypothesis signs from the plurality of sets of hypothesis signs based on the plurality of costs; The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle. A decoder, comprising: Memory, used to store computer programs; A processor, configured to perform the method as described in any one of claims 1 to 19 when running the computer program. An encoder, comprising: The first determining unit is configured to determine multiple costs based on multiple sets of hypothetical reconstruction sample values ​​of the boundary region of the current block and a first cost formula, wherein the multiple sets of hypothetical reconstruction sample values ​​are determined based on the positive and negative signs of multiple sets of hypotheses corresponding to at least one transformation coefficient of the current block. The second determining unit is configured to determine the target set of hypothesis signs from the plurality of sets of hypothesis signs based on the plurality of costs; The first cost formula includes a first parameter, which is associated with a reconstructed sample value at a first position in the reference region of the current block, and the first position is determined based on a first angle. An encoder, comprising: Memory, used to store computer programs; A processor, configured to perform the method as described in any one of claims 20 to 38 when running the computer program. A non-transitory computer readable storage medium storing a bitstream generated by utilizing an encoding method of an encoder, or the bitstream decoded by utilizing a decoding method of a decoder, wherein, The decoding method is the method as described in any one of claims 1 to 19, and the encoding method is the method as described in any one of claims 20 to 38. A computer-readable storage medium storing a bitstream generated by the method of any one of claims 20 to 38. A computer-readable storage medium, wherein, The computer-readable storage medium stores a computer program that, when executed, implements the method as described in any one of claims 1 to 19, or 20 to 38.