Decoding method, encoding method, decoder and encoder
Patent Information
- Application Number
- CN202380090265.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-03
- Publication Date
- 2025-08-19
AI Technical Summary
Existing digital video decompression technology still has shortcomings in improving compression efficiency. Especially under the demand for high video definition, the decoding performance of existing codec standards needs to be further improved.
Adopt decoding methods and encoding methods based on intra-template matching prediction mode (IntraTMP) to improve decoding performance by determining the residual block and target prediction block of the current block, and implement this technology in the encoder and decoder to improve encoding and decoding performance.
Through the application of IntraTMP mode, the decoding performance and coding efficiency of video encoding are improved, the loss of bit rate and PSNR is reduced, while maintaining low complexity and time overhead.
Smart Images

Figure CN120513634A_ABST
Abstract
Description
Decoding method, encoding method, decoder and encoder Technical Field
[0001] The embodiments of the present application relate to the field of coding and decoding technology, and more specifically, to a decoding method, an encoding method, a decoder, and an encoder. Background Art
[0002] Digital video compression technology primarily compresses large amounts of digital video data for easier transmission and storage. With the surge in Internet video usage and increasing demand for higher-quality video, while existing digital video compression standards are capable of implementing video decompression technology, there is still a need for better digital video decompression technologies to improve compression efficiency.
[0003] Summary of the Invention
[0004] The embodiments of the present application provide a decoding method, an encoding method, a decoder and an encoder, which can improve decoding performance.
[0005] In a first aspect, an embodiment of the present application provides a decoding method, comprising:
[0006] Determine a residual block of a current block in a current sequence based on a bitstream;
[0007] Predicting at least one matching block of the current block based on the intra-frame template matching prediction IntraTMP mode;
[0008] Determining a target prediction block for the current block based on the at least one matching block;
[0009] A reconstructed block of the current block is obtained based on the residual block of the current block and the target prediction block.
[0010] In a second aspect, an embodiment of the present application provides an encoding method, including:
[0011] Predicting the IntraTMP mode based on intra-frame template matching, predicting at least one matching block of the current block in the current sequence;
[0012] Determining a target prediction block for the current block based on the at least one matching block;
[0013] Obtaining a residual block of the current block based on the target prediction block and the original block of the current block;
[0014] The residual block of the current block is encoded.
[0015] In a third aspect, an embodiment of the present application provides a decoder, including:
[0016] A residual unit, configured to determine a residual block of a current block in a current sequence based on a bitstream;
[0017] A prediction unit, configured to predict at least one matching block of the current block based on an intra-frame template matching prediction IntraTMP mode;
[0018] a determining unit, configured to determine a target prediction block of the current block based on the at least one matching block;
[0019] The reconstruction unit is configured to obtain a reconstructed block of the current block based on the residual block of the current block and the target prediction block.
[0020] In a fourth aspect, an embodiment of the present application provides an encoder, including:
[0021] A prediction unit, configured to predict at least one matching block of a current block in a current sequence based on an intra-frame template matching prediction IntraTMP mode;
[0022] a determining unit, configured to determine a target prediction block of the current block based on the at least one matching block;
[0023] A residual unit, configured to obtain a residual block of the current block based on the target prediction block and an original block of the current block;
[0024] The coding unit is configured to encode the residual block of the current block.
[0025] In a fifth aspect, an embodiment of the present application provides a decoder, including:
[0026] a processor adapted to implement computer instructions; and,
[0027] A computer-readable storage medium stores computer instructions, wherein the computer instructions are suitable for being loaded by a processor and executing the decoding method in the first aspect or its various implementations mentioned above.
[0028] In one implementation, there are one or more processors and one or more memories.
[0029] In one implementation, the computer-readable storage medium may be integrated with the processor, or the computer-readable storage medium may be provided separately from the processor.
[0030] In a sixth aspect, an embodiment of the present application provides an encoder, including:
[0031] a processor adapted to implement computer instructions; and,
[0032] A computer-readable storage medium stores computer instructions, wherein the computer instructions are suitable for being loaded by a processor and executing the encoding method in the second aspect or its various implementations mentioned above.
[0033] In one implementation, there are one or more processors and one or more memories.
[0034] In one implementation, the computer-readable storage medium may be integrated with the processor, or the computer-readable storage medium may be provided separately from the processor.
[0035] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are read and executed by a processor of a computer device, the computer device executes the decoding method involved in the first aspect mentioned above or the encoding method involved in the second aspect mentioned above.
[0036] In an eighth aspect, embodiments of the present application provide a computer program product or computer program, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the decoding method of the first aspect or the encoding method of the second aspect.
[0037] In a ninth aspect, an embodiment of the present application provides a code stream, which is the code stream involved in the method described in the first aspect above or the code stream generated by the method described in the second aspect above.
[0038] Based on the above technical solution, the decoder predicts at least one matching block of the current block based on the IntraTMP mode, and then determines the target prediction block of the current block based on the at least one matching block; equivalently, the decoder can determine the target prediction block based on a single matching block selected by the IntraTMP mode, or can determine the target prediction block based on multiple matching blocks selected by the IntraTMP mode, which not only improves the prediction flexibility of the current block, but also helps the decoder select an appropriate number of matching blocks to determine the target prediction block, thereby improving the encoding and decoding performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] FIG1 is a schematic block diagram of a coding framework provided in an embodiment of the present application.
[0040] FIG2 is a schematic block diagram of a decoding framework provided in an embodiment of the present application.
[0041] FIG3 is a schematic diagram of the IntraTMP technology provided in an embodiment of the present application.
[0042] FIG4 is an example of template error values between a current block and a matching block provided by an embodiment of the present application.
[0043] FIG5 is an example of the IntraTMP adaptation technology for camera-captured content provided in an embodiment of the present application.
[0044] FIG6 is a schematic diagram of a method for dividing a region of a current block provided in an embodiment of the present application.
[0045] FIG7 is a schematic flowchart of a decoding method provided in an embodiment of the present application.
[0046] FIG8 is an example of a pruning and refining process provided by an embodiment of the present application.
[0047] FIG9 is another example of the pruning and refining process provided by an embodiment of the present application.
[0048] FIG10 is an example of determining a target prediction block based on multiple matching blocks provided by an embodiment of the present application.
[0049] FIG11 is an example of a template of a current block provided in an embodiment of the present application.
[0050] FIG12 is a schematic flowchart of the encoding method provided in an embodiment of the present application.
[0051] FIG13 is a schematic block diagram of a decoder provided in an embodiment of the present application.
[0052] FIG14 is a schematic block diagram of an encoder provided in an embodiment of the present application.
[0053] FIG15 is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0055] The solution provided in the embodiment of the present application can be applied to the field of digital video coding technology, for example, including but not limited to: image coding and decoding field, video coding and decoding field, hardware video coding and decoding field, dedicated circuit video coding and decoding field and real-time video coding and decoding field. In addition, the solution provided in the embodiment of the present application can be combined with the audio and video coding standard (Audio Video Coding Standard, AVS), the second generation AVS standard (AVS2) or the third generation AVS standard (AVS3). For example, including but not limited to: H.264 / Audio Video Coding (AVC) standard, H.265 / High Efficiency Video Coding (HEVC) standard and H.266 / Versatile Video Coding (VVC) standard. In addition, the solution provided in the embodiment of the present application can be used for lossy compression of images, and can also be used for lossless compression of images. The lossless compression can be visually lossless compression or mathematically lossless compression.
[0056] Video coding standards all use a block-based hybrid coding framework. Specifically, each image in a video is divided into square largest coding units (LCUs) or coding tree units (CTUs) of the same size (e.g., 128x128, 64x64, etc.). Each LCU or CTU can be divided into rectangular coding units (CUs) according to a rule. Coding units may also be divided into prediction units (PUs), transform units (TUs), etc. The hybrid coding framework includes modules such as prediction, transform, quantization, entropy coding, and in-loop filtering. The prediction module includes intra prediction and inter prediction. Inter prediction includes motion estimation and motion compensation. Because there is a strong correlation between adjacent pixels in a video image, intra prediction is used in video coding and decoding technology to eliminate spatial redundancy between adjacent pixels. Intra-frame prediction only references information from the same image to predict pixel information within the current block. Due to the strong similarities between adjacent images in a video, inter-frame prediction is used in video coding and decoding to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency. Inter-frame prediction can reference image information from different frames and use motion estimation to search for the motion vector information that best matches the current block. Transformation converts the predicted image block to the frequency domain, redistributing the energy. Combined with quantization, it removes information that is insensitive to the human eye, eliminating visual redundancy. Entropy coding can eliminate character redundancy based on the current context model and the probabilistic information of the binary bitstream.
[0057] During digital video encoding, the encoder may first read a black-and-white or color image from the original video sequence and then encode the black-and-white or color image. A black-and-white image may include pixels of the luminance component, while a color image may include pixels of the chrominance component. Optionally, the color image may also include pixels of the luminance component. The color format of the original video sequence may be a luminance-chrominance (YCbCr, YUV) format or a red-green-blue (RGB) format. Specifically, after reading the black-and-white or color image, the encoder divides it into blocks and uses intra-frame prediction or inter-frame prediction on the current block to generate a prediction block for the current block. The prediction block is subtracted from the original block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. The quantization coefficient matrix is entropy encoded and output to the bitstream. During digital video decoding, the decoder uses intra-frame prediction or inter-frame prediction on the current block to generate a prediction block for the current block. Furthermore, the decoder decodes the bitstream to obtain a quantization coefficient matrix, dequantizes and inversely transforms the quantization coefficient matrix to obtain a residual block, and adds the prediction block and residual block to obtain a reconstructed block. The reconstructed blocks can be used to compose a reconstructed image. The decoding end performs loop filtering on the reconstructed image based on an image or a block to obtain a decoded image.
[0058] The current block may be a current coding unit (CU) or a current prediction unit (PU), etc.
[0059] It should be noted that the encoder also performs similar operations as the decoder to obtain a decoded image. The decoded image can be used as a reference image for inter-frame prediction of subsequent images. Block partitioning information, prediction, transform, quantization, entropy coding, loop filtering, and other mode or parameter information determined by the encoder are written into the bitstream if necessary.
[0060] The decoding end determines the same block division information as the encoding end by parsing and analyzing the existing information, as well as the mode information or parameter information such as prediction, transformation, quantization, entropy coding, and loop filtering, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end. The decoded image obtained by the encoding end is also usually called a reconstructed image. The current block can be divided into prediction units during prediction, and the current block can be divided into transformation units during transformation. The division of prediction units and transformation units can be the same or different. Of course, the above is only the basic process of the video codec under the block-based hybrid coding framework. With the development of technology, some modules of the framework or some steps of the process may be optimized. The present application is applicable to the basic process of the video codec under the block-based hybrid coding framework.
[0061] To facilitate understanding, the coding framework provided in this application is briefly introduced first.
[0062] FIG1 is a schematic block diagram of a coding framework 100 provided in an embodiment of the present application.
[0063] As shown in FIG1 , the coding framework 100 may include an intra-frame prediction unit 180, an inter-frame prediction unit 170, a residual unit 110, a transform and quantization unit 120, an entropy coding unit 130, an inverse transform and inverse quantization unit 140, and a loop filter unit 150. Optionally, the coding framework 100 may further include a decoded image buffer unit 160. The coding framework 100 may also be referred to as a hybrid framework coding mode.
[0064] The intra-frame prediction unit 180 or the inter-frame prediction unit 170 may predict the image block to be encoded and output a prediction block. The residual unit 110 may calculate a residual block based on the prediction block and the image block to be encoded, i.e., the difference between the prediction block and the image block to be encoded. The transform and quantization unit 120 is configured to perform operations such as transform and quantization on the residual block to remove information that is insensitive to the human eye, thereby eliminating visual redundancy. Optionally, the residual block before transformation and quantization by the transform and quantization unit 120 may be referred to as a time-domain residual block, and the time-domain residual block after transformation and quantization by the transform and quantization unit 120 may be referred to as a frequency residual block or a frequency-domain residual block. After receiving the transform and quantization coefficients output by the transform and quantization unit 120, the entropy coding unit 130 may output a bitstream based on the transform and quantization coefficients. For example, the entropy coding unit 130 may eliminate character redundancy based on a target context model and probability information of the binary bitstream. For example, the entropy coding unit 130 may be configured for context-based adaptive binary arithmetic entropy coding (CABAC). The entropy coding unit 130 may also be referred to as a header information coding unit. Optionally, in this application, the image block to be encoded may also be referred to as an original image block or a target image block, the prediction block may also be referred to as a prediction image block or an image prediction block, or may also be referred to as a prediction signal or prediction information, and the reconstruction block may also be referred to as a reconstructed image block or an image reconstruction block, or may also be referred to as a reconstruction signal or reconstruction information. In addition, for the encoding end, the image block to be encoded may also be referred to as a coding block or a coding image block, and for the decoding end, the image block to be encoded may also be referred to as a decoding block or a decoding image block. The image block to be encoded may be a CTU or a CU.
[0065] The encoding framework 100 calculates the residual between the prediction block and the image block to be encoded, generates a residual block, and transmits the residual block to the decoder through processes such as transformation and quantization. Correspondingly, the decoder receives and decodes the bitstream, then performs inverse transformation and inverse quantization to generate a residual block. The predicted block, obtained by the decoder, is then superimposed on the residual block to create a reconstructed block.
[0066] It should be noted that the inverse transform and inverse quantization unit 140, the loop filter unit 150, and the decoded image buffer unit 160 in the coding framework 100 can be used to form a decoder. This means that the intra-frame prediction unit 180 or the inter-frame prediction unit 170 can predict the image block to be coded based on the existing reconstructed block, thereby ensuring that the encoder and decoder have a consistent understanding of the reference image. In other words, the encoder can replicate the decoder's processing loop, thereby generating the same prediction as the decoder. Specifically, the quantized transform coefficients are inversely transformed and inversely quantized by the inverse transform and inverse quantization unit 140 to replicate the approximate residual block at the decoder. This approximate residual block, after adding the prediction block, can pass through the loop filter unit 150 to smooth out block artifacts caused by block-based processing and quantization. The image block output by the loop filter unit 150 can be stored in the decoded image buffer unit 160 for use in subsequent image prediction.
[0067] It should be understood that FIG1 is merely an example of the present application and should not be construed as limiting the present application.
[0068] For example, the loop filtering unit 150 in the coding framework 100 may include a deblocking filter (DBF) and a sample adaptive offset (SAO) filter. The function of DBF is to remove the blocking effect, and the function of SAO is to remove the ringing effect. In other embodiments of the present application, the coding framework 100 may adopt a neural network-based loop filtering algorithm to improve the compression efficiency of the video. In other words, the coding framework 100 may be a video coding hybrid framework based on a deep learning neural network. In one implementation, a convolutional neural network-based model may be used to calculate the result of pixel filtering on the basis of the deblocking filter and the sample adaptive offset filter. The network structure of the loop filtering unit 150 on the luminance component and the chrominance component may be the same or different. Considering that the luminance component contains more visual information, the luminance component may also be used to guide the filtering of the chrominance component to improve the reconstruction quality of the chrominance component.
[0069] The following describes the intra-frame prediction and inter-frame prediction.
[0070] For inter-frame prediction, inter-frame prediction can refer to image information of different frames and use motion estimation to search for motion vector information that best matches the image block to be encoded to eliminate temporal redundancy; the frames used for inter-frame prediction can be P frames and / or B frames, P frames refer to forward prediction frames, and B frames refer to bidirectional prediction frames.
[0071] Intra-frame prediction only references information from the same image, predicting pixel information within the image block to be encoded to eliminate spatial redundancy. The frame used for intra-frame prediction can be an I-frame. For example, based on the left-to-right, top-to-bottom encoding order, the image block to be encoded can reference the upper left image block, the upper image block, and the left image block as reference information to predict the image block to be encoded. The image block to be encoded then serves as reference information for the next image block. In this way, the entire image can be predicted. If the input digital video is in a color format, such as YUV 4:2:0, each four pixels in each image frame of the digital video are composed of four Y components and two UV components. The encoding framework can encode the Y component (i.e., the luminance block) and the UV component (i.e., the chrominance block) separately. Similarly, the decoding end can also perform decoding according to the format.
[0072] Intra-frame prediction uses both angular and non-angular prediction modes to predict the image block to be coded. This generates a prediction block. Based on the rate-distortion information calculated between the prediction block and the image block to be coded, the optimal prediction mode for the image block to be coded is selected and transmitted to the decoder via the bitstream. The decoder parses the prediction mode, predicts the prediction block for the target decoding block, and then overlays it with the time-domain residual block obtained via the bitstream to reconstruct the block.
[0073] Throughout the development of digital video codec standards, non-angular prediction modes have remained relatively stable, including the mean and planar modes. Angular prediction modes have continued to increase with the evolution of digital video codec standards. For example, the H-series of international digital video coding standards, H.264 / AVC, has only eight angular prediction modes and one non-angular prediction mode; H.265 / HEVC has expanded this to 33 angular prediction modes and two non-angular prediction modes. In H.266 / VVC, intra-frame prediction modes have been further expanded, with a total of 67 traditional prediction modes and a non-traditional prediction mode, matrix-weighted intra-frame prediction (MIP), for luma blocks. These 67 traditional prediction modes include planar and DC modes, and 65 angular prediction modes. Planar modes are typically used for blocks with gradual texture changes, while DC modes, as the name suggests, are typically used for flat areas. Angular prediction modes are typically used for blocks with pronounced angular texture.
[0074] It should be noted that, in this application, the current block used for intra-frame prediction can be a square block or a rectangular block.
[0075] Furthermore, since intra-frame prediction blocks are all square, the probability of using each angle prediction mode is equal. When the length and width of the current block are unequal, the probability of using the reference pixel on the top of a horizontal block (width greater than height) is greater than the probability of using the reference pixel on the left, and the probability of using the reference pixel on the top of a vertical block (height greater than width) is less than the probability of using the reference pixel on the left. When predicting a rectangular block, the traditional angle prediction mode is converted to a wide-angle prediction mode. When the wide-angle prediction mode is used to predict the rectangular block, the prediction angle range of the current block is greater than the prediction angle range when the traditional angle prediction mode is used to predict the rectangular block. Optionally, when using the wide-angle prediction mode, the index of the traditional angle prediction mode can still be used to send a signal. Accordingly, the decoding end can convert the traditional angle prediction mode back to the wide-angle prediction mode after receiving the signal. As a result, the total number of intra-frame prediction modes and the encoding method of the intra-frame prediction mode can remain unchanged.
[0076] Furthermore, the intra-frame prediction mode to be performed can be determined or selected based on the size of the current block; for example, a wide-angle prediction mode can be determined or selected based on the size of the current block to perform intra-frame prediction on the current block; for example, when the current block is a rectangular block (with different sizes in width and height), the wide-angle prediction mode can be used to perform intra-frame prediction on the current block. Among them, the aspect ratio of the current block can be used to determine the angular prediction mode replaced by the wide-angle prediction mode and the angular prediction mode after the replacement. For example, when predicting the current block, any intra-frame prediction mode with an angle that does not exceed the diagonal angle of the current block (from the lower left corner to the upper right corner of the current block) can be selected as the angular prediction mode after the replacement.
[0077] FIG2 is a schematic block diagram of a decoding framework 200 provided in an embodiment of the present application.
[0078] As shown in FIG2 , the decoding framework 200 may include an entropy decoding unit 210, an inverse transform and dequantization unit 220, a residual unit 230, an intra-frame prediction unit 240, an inter-frame prediction unit 250, a loop filter unit 260, and a decoded image buffer unit 270. The entropy decoding unit 210 receives and parses the bitstream to obtain a prediction block and a frequency domain residual block. The frequency domain residual block is inversely transformed and dequantized by the inverse transform and dequantization unit 220 to obtain a time domain residual block. The residual unit 230 superimposes the prediction block obtained by the intra-frame prediction unit 240 or the inter-frame prediction unit 250 onto the time domain residual block that has been inversely transformed and dequantized by the inverse transform and dequantization unit 220 to obtain a reconstructed block.
[0079] It should be noted that the decoding method and encoding method provided in the embodiments of the present application affect the intra-frame prediction portion of the hybrid video coding framework, and are specifically applied to the IntraTMP portion of intra-frame prediction. The decoding method provided in the embodiments of the present application acts on the intra-frame prediction portion on the decoding side, and the encoding method provided in the embodiments of the present application acts on the intra-frame prediction portion on the encoding side.
[0080] In order to facilitate understanding of the technical solution of this application, the relevant contents are explained below.
[0081] (1) Intra Template Matching Prediction (IntraTMP) mode.
[0082] The IntraTMP mode is a special luminance block intra-frame prediction coding tool, which is mainly used for screen content coding.
[0083] FIG3 is a schematic diagram of the IntraTMP mode provided in an embodiment of the present application.
[0084] As shown in Figure 3, the IntraTMP mode is mainly implemented through the following process:
[0085] The encoder (or decoder) selects an L-shaped portion of reconstructed pixels adjacent to the current coding block as a template, searches for the most similar template within the reconstructed region of the given current frame, and uses the reconstructed block corresponding to the most similar template as the matching block, which is used as the prediction block for the current coding block. For example, R1 to R4 in the figure are search areas available for IntraTMP mode. For example, matching blocks can be searched point by point in R1 to R4 using a raster scan sequence.
[0086] FIG4 is an example of template error values between a current block and a matching block provided by an embodiment of the present application.
[0087] As shown in Figure 4, the template of the current block may include L columns of pixels to the left of the current block, M columns of pixels above it, and M rows and L columns of pixels in the upper left corner, where M and L are both positive integers, for example, both M and L are 4. The matching block of the current block can be represented by a block vector pointing from the current block to the matching block. The degree of similarity between the template of the current block and the template of the matching block is represented by the size of the template error value. The smaller the template error value, the higher the similarity. For example, the template error value can be calculated using the sum of absolute differences (SAD). The smaller the SAD, the more similar the templates are.
[0088] The encoder uses the flag cu_tmp_flag to indicate whether the current coded block uses the IntraTMP mode. If so, the decoder performs the same template matching process to obtain the same predicted block at the decoder. For the IntraTMP mode, no additional coded block vector information is required in the bitstream.
[0089] (2) IntraTMP adaption for camera-captured content technology.
[0090] FIG5 is an example of the IntraTMP adaptation technology for camera-captured content provided in an embodiment of the present application.
[0091] As shown in Figure 5(a), the IntraTMP technology, adapted to camera-captured content, builds upon the existing IntraTMP mode by performing template matching with a step size S (i.e., every S points in the horizontal and vertical directions, where S>1). For example, rather than searching for matching blocks point by point using a raster scan, the search area is searched at every S points in the horizontal and vertical directions. For example, if the current template matching block vector is (X0, Y0), the next horizontal template matching block vector should be (X0-S, Y0), and the next vertical template matching block vector should be Y0-S. After template matching is complete, as shown in Figure 5(b), the best matching block is refined within a certain range (i.e., template matching is performed with a smaller step size S'). For example, the matching block vector is refined within the template matching method using a smaller step size to optimize the matching result. This technology effectively reduces the complexity of the IntraTMP mode while maintaining good coding efficiency.
[0092] (3) Template-Based Intra Mode Derivation (TIMD) technology.
[0093] TIMD technology uses the reconstructed pixels of the L-shaped portion adjacent to the current coding block as a template. Specifically, the encoder can traverse the Most Probable Mode (MPM) list to calculate the predicted pixels of the template area under different intra-frame prediction modes. This then results in the template error value between the predicted and reconstructed pixels under different intra-frame prediction modes. For example, this template error value can be represented by the Sum of Absolute Transformed Difference (SATD). The encoder can then select the optimal intra-frame prediction mode based on the template error value. At the decoder, the intra-frame prediction mode is derived using the same derivation method, thereby reducing the coding bits of the mode information.
[0094] (4) Combined Inter and Intra Prediction (CIIP) mode.
[0095] The CIIP mode combines intra-frame prediction and inter-frame prediction, and uses a weighted combination of intra-frame prediction blocks and inter-frame prediction blocks to obtain the prediction block of the current coding block. The CIIP mode in the Enhanced Compression Model (ECM) reference software test platform is combined with template-based prediction technology. At the same time, different weights are designed for different regions, further improving the accuracy of the prediction. Specifically, its intra-frame prediction block pred_intra is obtained by the TIMD mode, and the inter-frame prediction block pred_inter is obtained by the template-based merge mode. The encoder determines the weight values wIntra and wInter based on the derived intra-frame prediction mode and the position of the pixel to be predicted. The final prediction block Pred is calculated as follows:
[0096] Pred=(wIntra*pred_intra+wInter*pred_inter+4)>>3
[0097] Among them, Pred represents the prediction block of the current block, pred_intra represents the intra-frame prediction block, wIntra represents the weight value of the intra-frame prediction block, winter represents the inter-frame prediction block, and pred_inter represents the weight value of the inter-frame prediction block.
[0098] wIntra and wInter can be determined based on the intra prediction mode intra_dir derived from TIMD. There are 65 intra-frame angular prediction modes in ECM (2≤intra_dir<=66). When 2≤intra_dir<34, the current coding block is divided into four equal parts vertically; when 34<=intra_dir<=66, the current coding block is divided into four equal parts horizontally. For example, the weight values wIntra and wInter of each region can be determined by referring to Table 1:
[0099] Table 1
[0100] Region index (wIntra, wInter) 0(6,2) 1(5,3) 2(3,5) 3(2,6)
[0101] As shown in Table 1, different region indexes correspond to different wIntra and wInter. That is, when the region ID is 0, wIntra is 6 and wInter is 2, when the region ID is 1, wIntra is 5 and wInter is 3, when the region ID is 2, wIntra is 3 and wInter is 5, and when the region ID is 3, wIntra is 2 and wInter is 6.
[0102] FIG6 is a schematic diagram of a method for dividing a region of a current block provided in an embodiment of the present application.
[0103] As shown in (a) of FIG6 , when the current coding block is divided into four equal parts vertically, the region indexes are 0, 1, 2, and 3 in order from left to right; as shown in (b) of FIG6 , when the current coding block is divided into four equal parts horizontally, the region indexes are 0, 1, 2, and 3 in order from top to bottom.
[0104] It should be noted that when intra_dir is equal to 0 or 1, wIntra and wInter can be determined in other ways. For example, when intra_dir is equal to 0 or 1, no sub-region is divided, and wIntra and wInter are selected from (3, 1), (2, 2), or (1, 3) based on the coding type (intra-frame or inter-frame) of the two coding blocks located on the left and above. For example, if the coding type of both coding blocks is intra-frame coding, the encoder determines (wIntra, wInter) to be (3, 1). If the coding type of one of the two coding blocks is intra-frame coding and the coding type of the other coding block is inter-frame coding, (wIntra, wInter) is determined to be (2, 2). If the coding type of both coding blocks is inter-frame coding, (wIntra, wInter) is determined to be (3, 1).
[0105] (5) Intra Block Copy (IBC) technology.
[0106] IBC technology is an intra-frame prediction technique that uses block matching to obtain predicted pixels. Similar to inter-frame prediction, prediction is achieved using a block vector pointing from the current block to a reference block. The difference is that the reference block for inter-frame prediction comes from an already coded reconstructed frame, while the reference block for IBC comes from the reconstructed portion of the current frame. Block vector information must be transmitted in the bitstream, so similar to inter-frame prediction, there are IBC-AMVP mode and IBC-Merge mode.
[0107] The IBC-AMVP mode obtains the predicted block vector by constructing a list of candidate block vectors, and obtains the reference block and the corresponding final block vector of the current block through hash search, full search, etc. The final block vector is encoded according to the predicted block vector to improve coding efficiency;
[0108] The IBC-Merge mode predicts by constructing a list of candidate block vectors. Through encoding processes such as SATD and RDO, the best block vector in the list is selected as the final block vector. The reconstructed block it points to is used as the reference block to complete the prediction. The index of the block vector in the list is encoded rather than the block vector itself, improving coding efficiency.
[0109] The candidate block vector list may be composed of coding information such as block vectors of adjacent coding blocks, historical block vectors, and average block vectors.
[0110] Since both IBC technology and IntraTMP mode are prediction technologies based on block vectors, the technical solution for improving the IntraTMP mode provided in this application can also be applied to IBC technology to a certain extent, and its corresponding extension solution also falls within the scope of protection of this application, and this application does not make specific limitations on this.
[0111] It is worth noting that, based on the above description of the IntraTMP mode, the IntraTMP mode selects a best matching block as a prediction block through a template. However, this method will produce certain prediction errors due to the noise generated during the lossy compression process and the limited correlation between the template and the corresponding block. In some cases, an accurate prediction block cannot be obtained, thereby reducing the decoding performance of the decoder. In addition, the IntraTMP mode predicts by block compensation. In scenarios such as screen content sequences where there are many repeated pixel blocks, even if the decoder selects a best matching block as a prediction block based on the IntraTMP mode through a template, the decoding performance of the decoder can be guaranteed. However, in scenarios such as natural content sequences where there are many noise signals and more complex pixel changes, if the decoder still selects a best matching block as a prediction block based on the IntraTMP mode through a template, when the difference between the current block and the best matching block selected based on the IntraTMP mode through the template is large, the IntraTMP mode may reduce the decoding performance of the decoder. In view of this, the embodiments of the present application provide a decoding method, an encoding method, a decoder, and an encoder that can improve encoding and decoding performance.
[0112] FIG7 is a schematic flow chart of a decoding method 300 provided in an embodiment of the present application. It should be understood that the decoding method 300 can be performed by a decoder or a decoding framework. For example, it can be applied to the decoding framework shown in FIG2 . For ease of description, the decoding method 300 is exemplified below using a decoder as an example.
[0113] As shown in FIG7 , the decoding method 300 may include:
[0114] S310: The decoder determines a residual block of a current block in a current sequence based on a bitstream.
[0115] Exemplarily, the decoder determines the residual block of the current block by decoding the code stream, and the code stream decoded by the decoder is the code stream of the current sequence.
[0116] S320: The decoder predicts at least one matching block of the current block based on an intra template matching prediction (IntraTMP) mode.
[0117] Exemplarily, the at least one matching block may be a single matching block.
[0118] Exemplarily, the at least one matching block may be a plurality of matching blocks.
[0119] S330: The decoder determines a target prediction block for the current block based on the at least one matching block.
[0120] Exemplarily, when the at least one matching block is a single matching block, the decoder may determine the single matching block as the target prediction block.
[0121] Exemplarily, when the at least one matching block is a plurality of matching blocks, the decoder may fuse the plurality of matching blocks to obtain the target prediction block.
[0122] Of course, in other alternative embodiments, the decoder may also fuse the at least one matching block with a prediction block obtained using another prediction mode to obtain the target prediction block, which is not specifically limited in the present embodiment. For example, the other prediction mode may be an intra-frame prediction mode or an inter-frame prediction mode.
[0123] S340: The decoder obtains a reconstructed block of the current block based on the residual block of the current block and the target prediction block.
[0124] Exemplarily, the decoder may determine the sum of the residual block of the current block and the target prediction block as the reconstructed block of the current block.
[0125] In this embodiment, the decoder predicts at least one matching block of the current block based on the IntraTMP mode, and then determines the target prediction block of the current block based on the at least one matching block; equivalently, the decoder can determine the target prediction block based on a single matching block selected by the IntraTMP mode, or can determine the target prediction block based on multiple matching blocks selected by the IntraTMP mode, which not only improves the prediction flexibility of the current block, but also helps the decoder select an appropriate number of matching blocks to determine the target prediction block, thereby improving the encoding and decoding performance.
[0126] The following, combined with Table 2, illustrates the results obtained after testing the proposed solution on the JVET test sequence under All Intra conditions on ECM6.0, which integrates IntraTMP adaptation technology for camera-captured content. End-to-End Bit Distortion (BD-rate) is a metric used to measure algorithm performance or coding performance, indicating the change in bit rate and PSNR compared to the original coding algorithm. An overall negative value indicates improved performance. Y, U, and V represent the components of the current block.
[0127] Table 2
[0128]
[0129] As shown in Table 2, the test results show that the solution provided by this application improves performance for all sequence categories, with average BD-rate changes of -0.14%, -0.13%, and -0.16% for the Y, U, and V components, respectively. This demonstrates that this technology improves encoding performance with lower complexity. Furthermore, the decoding method provided by this embodiment only increases decoding time by 3%, while the corresponding encoding method only increases encoding time by 1%.
[0130] In some embodiments, S320 may include:
[0131] The decoder determines a first identifier based on the bitstream; if the first identifier indicates to use the IntraTMP mode for fusion prediction, the decoder predicts the at least one matching block based on the IntraTMP mode.
[0132] Exemplarily, the decoder decodes the bitstream to obtain the first identifier. If the first identifier indicates to use the IntraTMP mode for fusion prediction, the decoder predicts the at least one matching block based on the IntraTMP mode; otherwise, the decoder uses other prediction modes to obtain the target prediction block.
[0133] Exemplarily, if the at least one matching block is a single matching block, the first identifier indicates the use of the IntraTMP mode and other prediction modes for fusion prediction, that is, the first identifier indicates the use of the single matching block obtained based on the IntraTMP mode and the prediction block obtained based on other prediction modes for fusion prediction, or the target prediction block is the prediction block obtained by fusing the single matching block obtained based on the IntraTMP mode and the prediction block obtained based on other prediction modes.
[0134] Exemplarily, if the at least one matching block is multiple matching blocks, the first identifier indicates that the multiple matching blocks obtained using the IntraTMP mode are used for fusion prediction, that is, the target prediction block is a prediction block obtained by fusing the multiple matching blocks obtained based on the IntraTMP mode.
[0135] Exemplarily, if the at least one matching block is multiple matching blocks, the first identifier indicates the use of the IntraTMP mode and other prediction modes for fusion prediction, that is, the first identifier indicates the use of multiple matching blocks obtained based on the IntraTMP mode and prediction blocks obtained based on other prediction modes for fusion prediction, or the target prediction block is a prediction block obtained by fusing multiple matching blocks obtained based on the IntraTMP mode and prediction blocks obtained based on other prediction modes.
[0136] It should be noted that the other prediction modes used for fusion prediction with the IntraTMP mode can be any prediction mode, for example, it can be an intra-frame prediction mode or an inter-frame prediction mode, for example, it can be an angular prediction mode or a non-angular prediction mode.
[0137] Exemplarily, the first identifier may be a sequence-level identifier, an image-level (ie, frame-level) identifier, a slice-level identifier, or an image block-level identifier.
[0138] For example, when the value of the first identifier is 0, it indicates that the IntraTMP mode is used for fusion prediction, and when the value of the first identifier is 1, it indicates that the IntraTMP mode is not used for fusion prediction. Alternatively, when the value of the first identifier is 1, it indicates that the IntraTMP mode is used for fusion prediction, and when the value of the first identifier is 0, it indicates that the IntraTMP mode is not used for fusion prediction. Of course, other numerical values can also be used for indication, and this embodiment is not limited to this.
[0139] Of course, the first identifier can also achieve the corresponding indication function through other methods, and this application does not limit this.
[0140] For example, when the value of the first identifier is "true", it indicates that the IntraTMP mode is used for fusion prediction, and when the value of the first identifier is "false", it indicates that the IntraTMP mode is not used for fusion prediction.
[0141] Exemplarily, if the first identifier indicates that the IntraTMP mode is not used for fusion prediction, the decoder can determine the prediction mode of the current block by continuing to decode the bitstream. In other words, if the first identifier indicates that the IntraTMP mode is not used for fusion prediction, the decoder does not need to predict the at least one matching block based on the IntraTMP mode, nor does it need to determine the target prediction block based on the at least one matching block.
[0142] In some embodiments, the decoder determines the second identifier based on the bitstream; if the second identifier indicates to use the IntraTMP mode for prediction, the decoder determines the first identifier based on the bitstream.
[0143] Exemplarily, the decoder decodes the bitstream to obtain the second identifier. If the second identifier indicates to use the IntraTMP mode for prediction, the decoder decodes the bitstream to obtain the first identifier; otherwise, the decoder uses other prediction modes to obtain the target prediction block.
[0144] Exemplarily, the second identifier may be a sequence-level identifier, an image-level (ie, frame-level) identifier, a slice-level identifier, or an image block-level identifier.
[0145] For example, when the value of the second flag is 0, it indicates that the IntraTMP mode is used for prediction, and when the value of the second flag is 1, it indicates that the IntraTMP mode is not used for prediction. Alternatively, when the value of the second flag is 1, it indicates that the IntraTMP mode is used for prediction, and when the value of the second flag is 0, it indicates that the IntraTMP mode is not used for prediction. Of course, other values can also be used for indication, and this embodiment is not limited to this.
[0146] Of course, the second mark can also achieve the corresponding indication function through other methods, and this application does not limit this.
[0147] For example, when the value of the second flag is "true", it indicates that the IntraTMP mode is used for prediction, and when the value of the second flag is "false", it indicates that the IntraTMP mode is not used for prediction.
[0148] Exemplarily, if the second identifier indicates that the IntraTMP mode is not used for prediction, the decoder can determine the prediction mode of the current block by continuing to decode the code stream. In other words, if the second identifier indicates that the IntraTMP mode is not used for fusion prediction, the decoder does not need to predict the at least one matching block based on the IntraTMP mode, nor does it need to determine the target prediction block based on the at least one matching block.
[0149] Exemplarily, if the second flag indicates that the IntraTMP mode is used for prediction, and the first flag indicates that the IntraTMP mode is not used for fusion prediction, the decoder predicts a best matching block based on the IntraTMP mode and determines the target prediction block based on the best matching block. For example, the decoder may directly determine the best matching block as the target prediction block.
[0150] For example, when the decoder reads the bitstream, the syntax elements used for fusion prediction using the IntraTMP can be implemented as shown in Table 3:
[0151] Table 3
[0152]
[0153]
[0154] The explanations of the elements in Table 3 are as follows:
[0155] coding_unit: Syntax elements related to coding blocks.
[0156] sps_tmp_enabled_flag: SPS flag, indicating whether the video sequence can be predicted using the IntraTMP mode. If it is equal to 1, the current video sequence can be predicted using the IntraTMP mode; if it is equal to 0, the current video sequence cannot be predicted using the IntraTMP mode; the value of the SPS flag can be set by the user.
[0157] MaxTmpSize: SPS parameter that specifies the size limit of blocks that can be predicted using the IntraTMP mode. If the width or height of a block is larger than MaxTmpSize, IntraTMP mode cannot be used for prediction. The SPS parameter can be set by the user.
[0158] intra_tmp_flag (the second flag described above): a block flag that indicates whether the current block is predicted using the IntraTMP mode. If the value of intra_tmp_flag is 1, it means that the current block is predicted using the IntraTMP mode, that is, the decoder needs to decode the flag intra_tmp_fusion_flag; if the value of intra_tmp_flag is 0, it means that the current block is not predicted using the IntraTMP mode, that is, the decoder does not need to decode the flag intra_tmp_fusion_flag.
[0159] intra_tmp_fusion_flag (the first flag described above): A block flag that indicates whether the current block uses IntraTMP for fusion prediction. If the value of intra_tmp_fusion_flag is 1, it means that the current block uses IntraTMP for fusion prediction. If the value of intra_tmp_fusion_flag is 0, it means that the current block uses IntraTMP for single matching block prediction.
[0160] Exemplarily, the decoder decodes the input bitstream, and the decoding process is performed in CTU order. The CTU is divided into different blocks for decoding according to the block division flag obtained by decoding. If the flag sps_tmp_enabled_flag in the SPS is equal to 1, and the current block size meets the limit MaxTmpSize on the IntraTMP coding block size in the SPS, the decoder can determine the intra_tmp_flag by decoding the bitstream. If intra_tmp_flag is equal to 1, it indicates that the current block is predicted using the IntraTMP mode. At this time, the decoder can determine the intra_tmp_fusion_flag by further decoding the bitstream. If intra_tmp_flag is equal to 0, it indicates that the current block is not predicted using the IntraTMP mode. At this time, the decoder does not need to determine the intra_tmp_fusion_flag by decoding the bitstream.
[0161] In some embodiments, the decoder may determine the first identifier by:
[0162] Determine the target context index;
[0163] Based on the code stream, the first identifier is determined using the target context index.
[0164] Exemplarily, the target context index is used to uniquely identify a context or a context model, so that after determining the target context index, the decoder can use the context or context model indicated by the target context index to decode the code stream and obtain the first identifier.
[0165] Of course, in other alternative embodiments, the decoder may also determine the context index used by the second identifier, and the method of determining the context index used by the second identifier may be the same as or different from the method of determining the context index used by the first identifier, and this application does not make any specific limitations on this.
[0166] In some embodiments, the decoder determines the target context index based on decoding information of neighboring decoded blocks of the current block; and / or the decoder determines the target context index based on the size of the current block.
[0167] Exemplarily, the decoding information of the adjacent decoding block includes but is not limited to: the prediction mode used by the adjacent decoding block, the context index used when decoding the block-level identifier of the adjacent decoding block, the template of the adjacent decoding block, the position of the adjacent decoding block, the decoding value of the adjacent decoding block, and other information.
[0168] Exemplarily, the size of the current block includes but is not limited to: the height of the current block, the width of the current block, the number of pixels in the current block, and other information.
[0169] Exemplarily, the decoder decodes the first identifier using a target context index CtxIdxInc, where the target context index CtxIdxInc can be determined based on information such as decoding information of adjacent decoded blocks and the size of the current block. For example, the target context index determined by the decoder based on the decoding information of the adjacent decoded blocks has Q possible values, for example, Q is equal to 3 or another value.
[0170] In some embodiments, the coordinates of the current block are (x, y), and the adjacent decoding blocks include a first decoding block with coordinates (x-1, y) and a second decoding block with coordinates (x, y-1); the decoding information of the first decoding block includes the prediction mode used by the prediction block of the first decoding block, and the decoding information of the second decoding block includes the prediction mode used by the prediction block of the second decoding block; at this time, the decoder can determine the target context index in the following manner: if the prediction mode used by the prediction block of the first decoding block is a mode for fusion prediction based on the IntraTMP mode, the first value is assigned to A; otherwise, the first value is assigned to B; A and B are both integers; if the prediction mode used by the prediction block of the second decoding block is a prediction mode for fusion prediction based on the IntraTMP mode, the second value is assigned to C; otherwise, the second value is assigned to D; C and D are both integers; the sum of the first value and the second value is determined as the target context index. Wherein,
[0171] For example, A = 1, B = 0, C = 1, and D = 0. That is, assuming the coordinates of the current block are (x, y); if there is a decoded block cuLeft at the coordinates (x-1, y) and cuLeft's intra_tmp_fusion_flag is 1, then CtxIdxInc is 1, otherwise it is 0; then, if there is a decoded block cuAbove at the coordinates (x, y-1) and cuAbove's intra_tmp_fusion_flag is 1, then CtxIdxInc is incremented by 1, otherwise it is incremented by 0.
[0172] Of course, in other alternative embodiments, A, B, C, and D may also be other values, and this application does not specifically limit this.
[0173] In some embodiments, when the decoder predicts at least one matching block of the current block based on the IntraTMP mode, it first performs template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks; and then determines the at least one matching block based on the X candidate matching blocks.
[0174] Exemplarily, the value of X is greater than or equal to the number of the at least one matching block.
[0175] Exemplarily, the X candidate matching blocks are matching blocks obtained by the decoder through template matching on the current block based on the IntraTMP mode. The at least one matching block is a matching block used by the decoder for fusion. The at least one matching block may be a candidate matching block selected by the decoder from the X candidate matching blocks.
[0176] In some embodiments, the decoder first performs intra-frame template matching within the search area of the current block based on the IntraTMP mode to obtain all candidate matching blocks of the current block; then, the matching blocks arranged in the first X positions in ascending order of template error values are determined as the X candidate matching blocks.
[0177] For example, through intra-frame template matching, the decoder can use reconstructed blocks at different positions within the search area of the current block, whose templates match the template of the current block, as candidate matching blocks for the current block. For example, the decoder can use reconstructed blocks at different positions within the search area of the current block, whose templates are the same as the template of the current block, as candidate matching blocks for the current block. After completing the template matching process, the decoder sorts all candidate matching blocks for the current block in order of template error value from small to large, and determines the candidate matching blocks in the top X positions as the X candidate matching blocks.
[0178] Of course, in other alternative embodiments, after completing the template matching process, the decoder may also sort all candidate matching blocks of the current block in descending order of template error values. In this case, the decoder may determine the candidate matching blocks ranked in the last X positions as the X candidate matching blocks.
[0179] In some embodiments, the decoder constructs a candidate matching block list based on the IntraTMP mode; the candidate matching block list is used to store X candidate matching blocks with the smallest template error values when performing intra template matching within the search area of the current block.
[0180] For example, through intra-frame template matching, the decoder can use reconstructed blocks at different locations within the search area of the current block, whose templates match the template of the current block, as candidate matching blocks for the current block. For example, the decoder can use reconstructed blocks at different locations within the search area of the current block, whose templates are the same as the template of the current block, as candidate matching blocks for the current block. During the template matching process, the decoder maintains a candidate matching block list and can update the candidate matching blocks stored in the candidate matching block list using the template error value of the current matching block to ensure that the candidate matching blocks stored in the candidate matching block list are the X candidate matching blocks with the smallest template error values. For example, when the number of candidate matching blocks in the candidate matching block list is less than X, the current candidate matching block is added to the candidate matching block list. When the number of candidate matching blocks in the candidate matching block list is equal to X, whether to update the candidate matching block list is determined based on the template error value of the current candidate matching block. For example, if the template error value of the current candidate matching block is less than the maximum template error value of the candidate matching blocks in the candidate matching block list, the candidate matching block corresponding to the maximum template error value is replaced with the current candidate matching block. If the template error value of the current candidate matching block is greater than or equal to the maximum template error value of the candidate matching blocks in the candidate matching block list, the candidate matching block list is maintained unchanged, thereby ensuring that the candidate matching blocks stored in the candidate matching block list are the X matching blocks with the smallest template error values.
[0181] Exemplarily, the candidate matching block list may also be referred to as a candidate block vector list.
[0182] Exemplarily, through intra-frame template matching, the decoder can use reconstructed blocks at different locations within the search area of the current block that match the template of the current block as candidate matching blocks for the current block. The candidate matching blocks for the current block can be represented by a block vector pointing from the current block to the candidate matching block. That is, the decoder can construct a candidate block vector list to record the block vectors with the smallest template error values during the template matching process, thereby obtaining X candidate matching blocks. Specifically, the decoder calculates the template error values (represented by the SAD between templates) for different block vectors within the search area of the current block with a step size of S (i.e., every S points horizontally and vertically). For example, if the current matching block vector is (x0, y0), the next matching block vector in the horizontal direction is (x0-S, y0), and the next matching block vector in the vertical direction is y0-S. A candidate block vector list of size X is constructed, where X can be determined by the number N of available matching blocks for fusion, for example, X equals 3*N. This candidate block vector list always stores the 3*N block vectors with the smallest template error values during the template matching process. The block vectors in the candidate block vector list are sorted according to the size of the template error value. In addition, the candidate block vector list is also used to store the template error value corresponding to each block vector in the candidate block vector list.
[0183] In some embodiments, the decoder divides the search area of the current block into Y sub-areas; based on the IntraTMP mode, intra-frame template matching is performed in each of the Y sub-areas to obtain candidate matching blocks in each sub-area; wherein the X candidate matching blocks include the candidate matching blocks in each sub-area.
[0184] Exemplarily, the Y sub-regions may be R1 to R4 as shown in FIG. 3 , or may be regions different from R1 to R4 . For example, the Y sub-regions may be more than or less than four regions.
[0185] In some embodiments, X=Y, or X is a multiple of Y.
[0186] Exemplarily, X=Y indicates that the X candidate matching blocks include the best candidate matching blocks in each sub-region. For example, the best candidate matching block in the current sub-region is the candidate matching block with the smallest template error value among all candidate matching blocks matched in the current sub-region.
[0187] Exemplarily, X is a multiple of Y, indicating that the X candidate matching blocks include multiple candidate matching blocks within each sub-region. For example, the multiple candidate matching blocks within the current sub-region are the multiple candidate matching blocks with the smallest template error values among all candidate matching blocks matched within the current sub-region.
[0188] In some embodiments, when the decoder determines the at least one matching block based on the X candidate matching blocks, it may first determine N available matching blocks based on the X candidate matching blocks; X≥N; and then determine the at least one matching block based on the N available matching blocks.
[0189] Exemplarily, the N available matching blocks refer to matching blocks that the decoder can use for fusion, the at least one matching block refers to a matching block that the decoder uses for fusion, the at least one matching block can be an available matching block selected by the decoder from the N available matching blocks, and the N available matching blocks can be candidate matching blocks selected by the decoder from the X candidate matching blocks.
[0190] In some embodiments, X is a multiple of N.
[0191] Exemplarily, X is 3 times or other multiples of N.
[0192] Of course, in other alternative embodiments, X may not be a multiple of N, as long as X is greater than or equal to N. This application does not make any specific limitation on this.
[0193] In some embodiments, the decoder prunes the X candidate matching blocks based on the spacing between the X candidate matching blocks to obtain the N available matching blocks.
[0194] Exemplarily, when the decoder prunes the X candidate matching blocks based on the spacing between the X candidate matching blocks, the decoder traverses the X candidate matching blocks and discards candidate matching blocks that are too close to the current candidate matching block, thereby pruning the X candidate matching blocks.
[0195] In some embodiments, the decoder may prune the X candidate matching blocks based on the spacing between the X candidate matching blocks in the following manner to obtain the N available matching blocks:
[0196] Determine a current candidate matching block for pruning from the X candidate matching blocks in ascending order of template error values;
[0197] Determine the pruning range of the current candidate matching block;
[0198] Remove candidate matching blocks other than the current candidate matching block within the pruning range to obtain candidate matching blocks remaining after pruning based on the current candidate matching block, until the number of prunings of the X candidate matching blocks reaches N, then determine the first N candidate matching blocks of the remaining candidate matching blocks as the N available matching blocks, or until the number of candidate matching blocks remaining after pruning based on the current candidate matching block is less than or equal to N, then determine the first N candidate matching blocks among the candidate matching blocks remaining after the last pruning as the N available matching blocks.
[0199] For example, the decoder may determine a current candidate matching block for pruning candidate matching blocks by traversing the X candidate matching blocks in ascending order of the template error values of the respective candidate matching blocks; and then obtain the N available matching blocks by discarding candidate matching blocks whose distance from the current candidate matching block is less than or equal to the pruning range.
[0200] For example, when the decoder traverses the i-th candidate matching block among the X candidate matching blocks in ascending order of template error values and selects the current candidate matching block for pruning candidate matching blocks, it determines the pruning range of the i-th candidate matching block. It then removes candidate matching blocks within the pruning range of the i-th candidate matching block, excluding the current candidate matching block, to obtain the candidate matching blocks remaining after pruning based on the i-th candidate matching block. If the number of prunings is less than N and the number of candidate matching blocks remaining after pruning based on the i-th candidate matching block is greater than N, the remaining candidate matching blocks are pruned based on the i+1-th candidate matching block as the current candidate matching block for pruning. If the number of prunings is equal to N, the first N candidate matching blocks of the remaining candidate matching blocks are determined as the N available matching blocks. If the number of candidate matching blocks remaining after pruning based on the i-th candidate matching block is less than N, the first N candidate matching blocks of the remaining candidate matching blocks after pruning based on the i-1-th candidate matching block are determined as the N available matching blocks.
[0201] In some embodiments, the decoder may determine the pruning range based on the size of the current block and the current candidate matching block.
[0202] Exemplarily, the decoder may use the block vector of the current candidate matching block as the center of the pruning range, and determine the size of the pruning range based on the size of the current block and the matching step size of the current candidate matching block.
[0203] In some embodiments, the decoder determines (S / E)*H as the pruning range, with the block vector of the current block pointing to the current candidate matching block as the center; where / represents a division operator, * represents a multiplication operator, S represents a matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and E is a positive integer.
[0204] Exemplarily, the decoder determines a rectangle with a side length of (S / E)*H as the trimming range, with the block vector of the current block pointing to the current candidate matching block as the center. Alternatively, the decoder determines a circle with a radius of (S / E)*H as the trimming range, with the block vector of the current block pointing to the current candidate matching block as the center.
[0205] Of course, in other alternative embodiments, the trimming range may also be other shapes or shapes of other sizes, and this application does not specifically limit this.
[0206] In some embodiments, the decoder may determine the pruning range based on a predefined value.
[0207] For example, the predefined value may include the size of the trimming range.
[0208] Exemplarily, the decoder determines a rectangle with a side length equal to the predefined value as the trimming range, with the block vector pointing from the current block to the current candidate matching block as the center. Alternatively, the decoder determines a circle with a radius equal to the predefined value as the trimming range, with the block vector pointing from the current block to the current candidate matching block as the center.
[0209] Of course, in other alternative embodiments, the trimming range may also be other shapes or shapes of other sizes, and this application does not specifically limit this.
[0210] Exemplarily, the predefined numerical value may be a default numerical value. For example, the predefined numerical value may be implemented by pre-saving corresponding codes, tables, or other methods that can be used to indicate relevant information in a device (e.g., including a decoder), and this application does not limit its specific implementation. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of this application, the "protocol" may refer to a standard protocol in the field of coding and decoding, and may include, for example, the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0211] In some embodiments, the decoder may refine the X candidate matching blocks to obtain the N available matching blocks.
[0212] Exemplarily, when refining the X candidate matching blocks, the decoder traverses the X candidate matching blocks and refines the candidate matching blocks among the X candidate matching blocks using a step size smaller than the matching step size of the X and the candidate matching blocks, and then can use the refined N candidate matching blocks as the N available matching blocks.
[0213] In some embodiments, the decoder may refine the X candidate matching blocks to obtain the N available matching blocks in the following manner:
[0214] Determining a refinement range of a current candidate matching block among the X candidate matching blocks;
[0215] Based on at least one matching step length, performing intra-frame template matching within the refined range to obtain a matching block within the refined range; each matching step length in the at least one matching step length is smaller than a matching step length used by the X candidate matching blocks;
[0216] Determine the matching block with the smallest template loss value among the matching blocks matched within the refining range as the candidate matching block obtained by refining the current candidate matching block;
[0217] A candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks.
[0218] Exemplarily, when refining the X candidate matching blocks, the decoder traverses the X candidate matching blocks and performs intra-frame template matching within the refined range of the current candidate matching block among the X candidate matching blocks using a step size smaller than the matching step size of the X candidate matching blocks to obtain a candidate matching block with a smaller template error value. The candidate matching block can be used as the candidate matching block obtained by refining the current candidate matching block.
[0219] For example, when the decoder traverses the i-th candidate matching block among the X candidate matching blocks in ascending order of template error values and selects it as the current candidate matching block, it determines a refinement range for the i-th candidate matching block. It then performs intra-frame template matching within the refinement range of the i-th candidate matching block using a smaller matching step size than the matching step size of the X candidate matching blocks to obtain a candidate matching block with a smaller template error value. This candidate matching block can be used as the candidate matching block obtained by refining the i-th candidate matching block and is determined as an available matching block among the N available matching blocks. If the number of available matching blocks determined is less than N, the i+1th candidate matching block is selected as the current candidate matching block and refinement continues for the current candidate matching block. If the number of available matching blocks determined is equal to N, the refinement process for the X candidate matching blocks is terminated.
[0220] In some embodiments, the decoder determines the refinement range based on the size of the current block and the current candidate matching block.
[0221] Exemplarily, the decoder may use the block vector of the current candidate matching block as the center of the refining range, and determine the size of the refining range based on the size of the current block and the matching step size of the current candidate matching block.
[0222] In some embodiments, the decoder determines (S / F)*H as the refinement range, with the block vector of the current block pointing to the current candidate matching block as the center; where / represents a division operator, * represents a multiplication operator, S represents the matching step adopted by the X candidate matching blocks, H represents the height of the current block, and F is a positive integer.
[0223] Exemplarily, the decoder determines a rectangle with a side length of (S / E)*H as the refinement range, with the block vector of the current block pointing to the current candidate matching block as the center. Alternatively, the decoder determines a circle with a radius of (S / E)*H as the refinement range, with the block vector of the current block pointing to the current candidate matching block as the center.
[0224] Of course, in other alternative embodiments, the refining range may also be other shapes or shapes of other sizes, which is not specifically limited in this application. In addition, it is worth noting that the pruning range and the refining range of the current candidate matching block may be the same or different, which is not specifically limited in this application.
[0225] In some embodiments, the decoder determines the refinement range based on predefined values.
[0226] For example, the predefined value may include the size of the trimming range.
[0227] Exemplarily, the decoder determines a rectangle with a side length equal to the predefined value as the refinement range, with the block vector pointing from the current block to the current candidate matching block as the center. Alternatively, the decoder determines a circle with a radius equal to the predefined value as the refinement range, with the block vector pointing from the current block to the current candidate matching block as the center.
[0228] Of course, in other alternative embodiments, the refining range may also be in other shapes or shapes of other sizes, and this application does not specifically limit this.
[0229] Exemplarily, the predefined numerical value may be a default numerical value. For example, the predefined numerical value may be implemented by pre-saving corresponding codes, tables, or other methods that can be used to indicate relevant information in a device (e.g., including a decoder), and this application does not limit its specific implementation. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of this application, the "protocol" may refer to a standard protocol in the field of coding and decoding, and may include, for example, the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0230] In some embodiments, if there is no overlap between the refining ranges of different candidate matching blocks in the X candidate matching blocks, and the j-th matching block matched within the refining range of the current candidate matching block is the matching block with the smallest template loss value among the first j matching blocks within the refining range of the current candidate matching block, then the j-th matching block can be directly determined as the candidate matching block obtained by refining the current candidate matching block.
[0231] Exemplarily, the refining ranges of different candidate matching blocks in the X candidate matching blocks do not overlap, which may include: the width and height of the refining range of the current candidate matching block are both less than or equal to the matching step size S used by the X candidate matching blocks.
[0232] In other words, if the width and height of the refining range of the current candidate matching block are both less than or equal to the matching step size S used by the X candidate matching blocks, then it can be indicated that there is no overlap between the refining ranges of different candidate matching blocks in the X candidate matching blocks. In this case, if the j-th matching block matched within the refining range of the current candidate matching block is the matching block with the smallest template loss value among the first j matching blocks within the refining range of the current candidate matching block, the decoder can directly determine the j-th matching block as the candidate matching block obtained by refining the current candidate matching block.
[0233] In some embodiments, if the current candidate matching block is the i-th matching block among the X candidate matching blocks, and the j-th matching block matched within the refining range is the matching block with the smallest template loss value among the first j matching blocks within the refining range, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block.
[0234] In this embodiment, when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block, thereby avoiding obtaining the same matching block in different refining processes.
[0235] In some embodiments, if there is overlap between the refining ranges of different candidate matching blocks among the X candidate matching blocks, and the j-th matching block matched within the refining range of the current candidate matching block is the matching block with the smallest template loss value among the first j matching blocks within the refining range of the current candidate matching block, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the decoder may determine the j-th matching block as the candidate matching block obtained by refining the current candidate matching block.
[0236] Exemplarily, the overlap between the refining ranges of different candidate matching blocks in the X candidate matching blocks may include: the width or height of the refining range of the current candidate matching block is greater than the matching step size S used by the X candidate matching blocks.
[0237] In other words, if the width or height of the refining range of the current candidate matching block is greater than the matching step size S used by the X candidate matching blocks, it can be indicated that there is overlap between the refining ranges of different candidate matching blocks in the X candidate matching blocks. In this case, if the j-th matching block matched within the refining range of the current candidate matching block is the matching block with the smallest template loss value among the first j matching blocks within the refining range of the current candidate matching block, then if the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the decoder may determine the j-th matching block as the candidate matching block obtained by refining the current candidate matching block.
[0238] Exemplarily, the candidate matching block list is refined N times to obtain N available block vectors. Specifically, during the i-th refinement, the block vector BV of the i-th candidate matching block in the candidate matching block list is taken. i , BV i Equal to (x i ,y i ), confirm that its refining range is L D =(S / 2)*H rectangle, where S is the matching step of X candidate matching blocks and H is the height of the current block; in other words, the refinement range of the i-th candidate matching block is the rectangle with the upper left corner (x i -L D ,y i -L D ), the lower right corner is (x i +L D ,y i +L D ) rectangular area. When refining the i-th candidate matching block, perform template matching within the refined range with a step size S′ (S′=S / 2) to obtain the block vector BV with the minimum template error value. i ′, which can be used as the block vector BV for the i-th candidate matching block i The refined block vector. Among them, the block vector BV for the i-th candidate matching block i During the refinement process, each time a matching block with a smaller template error value (the minimum template error value of the matching block determined in the i-th refinement) is obtained, it is necessary to determine whether the block vector is equal to the block vector of the available matching block that has been obtained. If there is an equal block vector, the block vector of the currently matched matching block is discarded (that is, the block vector is skipped and the refined matching block is not updated). For example, the block vectors BV1′ to BV1′ obtained in the first i-1 refinement process are i-1 ′, when refining for the i-th time, if the block vector BV of a matching block i ′ is less than the minimum value (the minimum value of the template error value of the matching block determined in the i-th refinement), and it is necessary to judge BV in turn. i'Whether BV1' to BV i-1 ′ are equal. If there are equal block vectors, skip BV i ′, continue the template matching process at the next position; if they are not equal, then BV i ′ is used as the new optimal block vector, and the corresponding template error value is used as the new minimum value to update the i-th refinement result.
[0239] Example 1:
[0240] Refine the candidate matching blocks among the X candidate matching blocks M times to obtain N available matching blocks. Where X ≥ M ≥ N, that is, the best matching block obtained in each refinement may be used as a matching block among the N available matching blocks. In other words, the decoder can try to use the best matching block obtained in each refinement to update the list of available matching blocks of size N.
[0241] Specifically, a list of available matching blocks of size N is maintained, and the matching blocks stored in the list can be updated by the template error value of the matching block to be added, so as to ensure that the matching blocks stored in the list are the N matching blocks with the smallest template error value. During the i-th refinement, the block vector BV of the i-th candidate matching block in the candidate matching block list is taken. i , BV i Equal to (x i ,y i ), confirm that its refining range is L D =(S / 2)*H rectangle, where S is the matching step of X candidate matching blocks and H is the height of the current block; in other words, the refinement range of the i-th candidate matching block is the rectangle with the upper left corner (x i -L D ,y i -L D ), the lower right corner is (x i +L D ,y i +L D ) rectangular area. When refining the i-th candidate matching block, perform template matching within the refined range with a step size S′ (S′=S / 2) to obtain the block vector BV with the minimum template error value. i ′, which can be used as the block vector BV for the i-th candidate matching block i The refined block vector. Among them, the block vector BV for the i-th candidate matching block iDuring the refinement process, each time a matching block with a smaller template error value (the minimum template error value of the matching block determined in the i-th refinement) is obtained, it is necessary to determine whether it is equal to the block vector in the available matching block list. If there is an equal block vector, the block vector of the current matching block is discarded (that is, the block vector is skipped and the refined matching block is not updated), and the template matching process is continued at the next position; if they are not equal, BV i ′ is used as the new best block vector and the corresponding template error value is used as the new minimum value to update the i-th refinement result. After completing the i-th refinement, the new best block vector BV' and the corresponding template error value are obtained, and an attempt is made to add BV' to the list of available matching blocks.
[0242] Example 2:
[0243] Refine the candidate matching blocks from the X candidate matching blocks M times to obtain N available matching blocks. Here, X ≥ M ≥ N, meaning that a matching block obtained by template matching once in each refinement may be used as a matching block in the N available matching blocks. In other words, the decoder can attempt to use a matching block obtained by template matching once in each refinement to update the list of available matching blocks of size N.
[0244] Specifically, a list of available matching blocks of size N is maintained, and the matching blocks stored in the list can be updated by the template error value of the matching block to be added, so as to ensure that the matching blocks stored in the list are the N matching blocks with the smallest template error value. During the i-th refinement, the block vector BV of the i-th candidate matching block in the candidate matching block list is taken. i , BV i Equal to (x i ,y i ), confirm that its refining range is L D =(S / 2)*H rectangle, where S is the matching step of X candidate matching blocks and H is the height of the current block; in other words, the refinement range of the i-th candidate matching block is the rectangle with the upper left corner (x i -L D ,y i -L D ), the lower right corner is (x i +L D ,y i +L D) in a rectangular area. When refining the i-th candidate matching block, perform template matching within the refined range with a step size of S′ (S′=S / 2). Each time a template match is performed, try to add the current matching block to the list of available matching blocks. Before each addition, it is necessary to determine whether the block vectors are the same as those in the list of available matching blocks. If there are equal block vectors, the block vector of the currently matched matching block is discarded (that is, the block vector is skipped and the refined matching block is not updated), and the template matching process is continued at the next position; if they are not equal, try to add the current matching block to the list of available matching blocks.
[0245] It should be noted that the difference between the above two methods is that in Example 1, only one matching block (the best matching block in the refining process) will be saved in the list after the first refinement is completed; in Example 2, after the first refinement is completed, if the number of matches in the refining process is greater than N, N matching blocks can be saved in the list.
[0246] In some embodiments, the decoder prunes and refines the X candidate matching blocks to obtain the N available matching blocks.
[0247] Exemplarily, the decoder performs N pruning and N refinement on the X candidate matching blocks to obtain the N available matching blocks.
[0248] In some embodiments, after the decoder prunes the X candidate matching blocks, it refines the pruned candidate matching blocks.
[0249] Exemplarily, after the decoder prunes the X candidate matching blocks N times, it refines the pruned candidate matching blocks N times.
[0250] In some embodiments, after the decoder refines the X candidate matching blocks, it prunes the refined candidate matching blocks.
[0251] Exemplarily, after refining the X candidate matching blocks, the decoder prunes the refined candidate matching blocks.
[0252] In some embodiments, the decoder prunes the X candidate matching blocks once based on the current candidate matching block among the X candidate matching blocks, and then refines the current candidate matching block, until the decoder performs N pruning and N refinement on the X candidate matching blocks to obtain the N available matching blocks.
[0253] Exemplarily, the decoder prunes the X candidate matching blocks based on the current candidate matching block among the X candidate matching blocks, and then refines the current candidate matching block.
[0254] That is, when the decoder can prune and refine the X candidate matching blocks, it can perform the pruning process first and then the refining process, or perform the refining process first and then the pruning process, or even perform pruning and refining alternately, which is not specifically limited in this application.
[0255] Exemplarily, N available block vectors are obtained from the candidate block vector list. The candidate matching blocks pointed to by these block vectors are used as candidate matching blocks of the current block for the subsequent weighted fusion process. For example, the candidate block vector list is pruned and refined N times to obtain N available matching blocks. The pruning step is used to avoid excessive overlap in the refining step, and the refining step is used to obtain a more accurate matching block. Specifically, during the i-th pruning and refining, the i-th block vector BV in the list is taken. i , BV i Equal to (x i ,y i ), confirm that its refining range is L D =(S / 2)*H rectangle, where S is the matching step of X candidate matching blocks and H is the height of the current block; in other words, the refinement range of the i-th candidate matching block is the rectangle with the upper left corner (x i -L D ,y i -L D ), the lower right corner is (x i +L D ,y i +L D ) rectangular area. If the block vector j (x j ,y j )satisfy:
[0256] x i -L D ≤x j ≤x i +L D &&y i -L D ≤y j ≤y i +L D ;
[0257] Then: It indicates that the block vector j is within the pruning range and the block vector j should be removed from the list. Then, template matching is performed within the refined range with a step size S′ (S′=S / 2) to obtain the block vector BV with the smallest template error value. i ′, which can be used as the block vector BV for the i-th candidate matching block i When S′ is greater than one pixel, the i-th refinement may include multiple refinement processes until S′ is equal to 1. Furthermore, the i-th pruning may also include multiple pruning processes.
[0258] FIG8 is an example of a pruning and refining process provided by an embodiment of the present application.
[0259] As shown in FIG8 , assuming that the X candidate matching blocks are arranged in ascending order of template error value, when X=6, the block vectors of the X candidate matching blocks are BV1, BV2, BV3, BV4, BV5, and BV6 respectively. Taking N=2 as an example, the decoder can prune the six candidate matching blocks twice and then refine the pruned candidate matching blocks twice.
[0260] When the decoder performs a second pruning on the six candidate matching blocks, it can determine the current candidate matching block used to prune the candidate matching blocks by traversing the six candidate matching blocks in ascending order of the template error values of each candidate matching block in the six candidate matching blocks; then, the decoder can obtain the pruned candidate matching blocks by discarding candidate matching blocks whose distance from the current candidate matching block is less than or equal to the pruning range. Specifically, the decoder first prunes the six candidate matching blocks based on the first candidate matching block, discarding BV2, and obtaining block vectors of the candidate matching blocks after the first pruning including: BV1, BV3, BV4, BV5, and BV6; then, the decoder prunes the block vectors of the candidate matching blocks after the first pruning based on the second candidate matching block, discarding BV5, and obtaining block vectors of the candidate matching blocks after the first pruning including: BV1, BV3, BV4, and BV6.
[0261] When the decoder refines the pruned candidate matching blocks, it traverses the pruned candidate matching blocks and refines the candidate matching blocks in the pruned candidate matching blocks using a step size smaller than the matching step size of X and the candidate matching blocks. The two refined candidate matching blocks can then be used as the two available matching blocks. Specifically, the decoder first performs template matching within the refinement range of BV1 with a step size S' (S'=S / 2) to obtain a block vector BV1' with the smallest template error value. This can be used as the refined block vector for BV1, resulting in the first refined candidate matching blocks including: BV1', BV3, BV4, and BV6. Then, the decoder performs template matching within the refinement range of BV3 with a step size S' (S'=S / 2) to obtain a block vector BV3' with the smallest template error value. This can be used as the refined block vector for BV3, resulting in the second refined candidate matching blocks including: BV1', BV3', BV4, and BV6. Based on this, BV1′ and BV3′ can be used as the at least one matching block. It is worth noting that when S′ is greater than one pixel, the first refinement and the second refinement may include multiple refinement processes until S′ is equal to 1.
[0262] FIG9 is another example of the pruning and refining process provided by an embodiment of the present application.
[0263] As shown in FIG9 , assuming that the X candidate matching blocks are arranged in ascending order of template error value, when X=6, the block vectors of the X candidate matching blocks are BV1, BV2, BV3, BV4, BV5, and BV6 respectively. Taking N=2 as an example, the decoder can prune the six candidate matching blocks once, refine the pruned candidate matching blocks once, prune the refined candidate matching blocks once, and then refine the pruned candidate matching blocks once.
[0264] Specifically, the decoder first performs the first pruning of the six candidate matching blocks based on the first candidate matching block, that is, discarding BV2 and BV6, and the block vectors of the candidate matching blocks after the first pruning include: BV1, BV3, BV4, BV5. Then, the decoder performs template matching within the refinement range of BV1 with a step size S' (S'=S / 2) to obtain the block vector BV1' with the smallest template error value, which can be used as the refined block vector for BV1, and the candidate matching blocks after the first refinement include: BV1', BV3, BV4, BV5; then, the decoder performs template matching on BV1', BV3, BV4, BV5 based on the block vector BV3 of the second candidate matching block among BV1', BV3, BV4, BV5. , BV4, and BV5 are pruned, that is, BV5 is discarded, and the block vectors of the candidate matching blocks after the second pruning include: BV1′, BV3, and BV4; then, the decoder performs template matching within the refinement range of BV3 with a step size S′ (S′=S / 2) to obtain a block vector BV3′ with the smallest template error value, which can be used as the refined block vector for BV1, and the candidate matching blocks after the first refinement include: BV1′, BV3′, and BV4. Based on this, BV1′ and BV3′ can be used as the at least one matching block. It is worth noting that when S′ is greater than one pixel, the first refinement and the second refinement may include multiple refinement processes until S′ is equal to 1.
[0265] In some embodiments, the decoder may determine the at least one matching block based on the N available matching blocks in the following manner:
[0266] Determine the fusion conditions used by the N available matching blocks;
[0267] An available matching block that meets the fusion condition among the N available matching blocks is determined as the at least one matching block.
[0268] Exemplarily, the fusion condition is used to select the at least one matching block for fusion from the N available matching blocks.
[0269] In some embodiments, the decoder determines the fusion condition based on at least one of the following:
[0270] The size of the template of the current block, the bit width of the pixels of the current block in the current block, and the minimum template error value of the N available matching blocks.
[0271] Of course, in other alternative embodiments, the decoder may also determine the fusion condition in other ways, for example, the fusion condition is a predefined condition.
[0272] Exemplarily, the predefined condition may be a default condition. For example, the predefined condition may be implemented by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (e.g., including a decoder), and this application does not limit its specific implementation method. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of this application, the "protocol" may refer to a standard protocol in the field of coding and decoding, and may include, for example, the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0273] In some embodiments, the fusion condition includes a first threshold, which is a threshold determined based on the size of the template of the current block and the bit width; based on this, the decoder can determine the available matching block among the N available matching blocks whose template error value is less than or equal to the first threshold as the at least one matching block.
[0274] Exemplarily, the first threshold is positively correlated with the size of the template of the current block.
[0275] Exemplarily, the first threshold is positively correlated with the bit width.
[0276] In some embodiments, the first threshold is determined according to the following formula:
[0277] T1=n1<<(b depth –n2)*n template ;
[0278] Among them, << is the left shift operator, - is the subtraction operator, * is the multiplication operator, T1 represents the first threshold, b depth Indicates the bit width, n template Represents the number of pixels in the template of the current block; n1 and n2 are both positive integers.
[0279] Exemplarily, n2 is equal to 2 or other values.
[0280] Exemplarily, n1 is equal to 1 or other values.
[0281] In some embodiments, the fusion condition includes a second threshold, which is a threshold determined based on the minimum template error value; based on this, the decoder can determine, as the at least one matching block, the available matching blocks among the N available matching blocks whose template error values are less than or equal to the second threshold.
[0282] Exemplarily, the second threshold is positively correlated with the minimum template error value.
[0283] In some embodiments, the second threshold is determined according to the following formula:
[0284] T2 = min SAD << n3;
[0285] where << is the left shift operator, T2 represents the second threshold, min SAD represents the minimum template error value, and n3 is a positive integer.
[0286] Exemplarily, n3 is equal to 1 or other values.
[0287] Of course, in other alternative embodiments, the fusion condition may include both the first threshold and the second threshold. That is to say, the decoder can determine, as the at least one matching block, the available matching blocks among the N available matching blocks whose template error values are less than or equal to the first threshold and less than or equal to the second threshold. For example, taking the template error value of the i-th available matching block among the N available matching blocks as SAD i as an example, when the template error value SAD i of the i-th available matching block i satisfies the condition SAD i ≤ T1 && SAD < T2, the i-th available matching block is determined as the matching block in the at least one matching block.
[0288] In some embodiments, the decoder may also determine the at least one matching block based on the N available matching blocks in the following manner:
[0289] Based on the code stream, determine indication information; the indication information is used to indicate the at least one matching block among the N available matching blocks;
[0290] Based on the indication information, determine the at least one matching block.
[0291] Exemplarily, the indication information may include N bits, wherein the N bits correspond one-to-one to the N available matching blocks, and each bit in the N bits is used to indicate whether the available matching block corresponding to the respective bit is used as a matching block in the at least one matching block. For example, when the value of each bit in the N bits is 0, it indicates that the available matching block corresponding to the respective bit is used as a matching block in the at least one matching block; and when the value of each bit in the N bits is 1, it indicates that the available matching block corresponding to the respective bit is not used as a matching block in the at least one matching block. For another example, when the value of each bit in the N bits is 1, it indicates that the available matching block corresponding to the respective bit is used as a matching block in the at least one matching block; and when the value of each bit in the N bits is 0, it indicates that the available matching block corresponding to the respective bit is not used as a matching block in the at least one matching block.
[0292] Of course, in other alternative embodiments, the indication information may also implement the corresponding indication function in other ways, and this application does not limit this.
[0293] In some embodiments, S330 may include:
[0294] If the at least one matching block is a plurality of matching blocks, weighted processing is performed on the plurality of matching blocks to obtain a target prediction block of the current block.
[0295] Exemplarily, the weight values of the multiple matching blocks may be equal, partially equal, or different from each other.
[0296] Exemplarily, when the weight values of the multiple matching blocks are equal, the target prediction block is the average value of the multiple matching blocks.
[0297] FIG10 is an example of determining a target prediction block based on multiple matching blocks provided by an embodiment of the present application.
[0298] As shown in FIG8 , assuming that the at least one matching block includes matching block 1, matching block 2, and matching block 3, the decoder may weight matching block 1, matching block 2, and matching block 3 based on the weight value W1 of matching block 1, the weight value W2 of matching block 2, and the weight value W3 of matching block 3 to obtain the target prediction block. Matching block 1, matching block 2, and matching block 3 are candidate matching blocks obtained by the decoder through intra-frame template matching within the search area of the current block (located within the reconstructed area of the current block). They may also be candidate matching blocks obtained by pruning and / or refining candidate matching blocks obtained based on intra-frame template matching, or even matching blocks selected from pruned and / or refined candidate matching blocks using the fusion conditions mentioned above.
[0299] In some embodiments, the decoder may perform weighted processing on the multiple matching blocks in the following manner:
[0300] Determining a weight value of each matching block in the plurality of matching blocks;
[0301] Based on the weight values of the respective matching blocks, weighted processing is performed on the multiple matching blocks to obtain the target prediction block.
[0302] Exemplarily, after the decoder determines the weight value of each matching block in the multiple matching blocks, it multiplies the weight value of each matching block by the weight value of each matching block and sums the results to obtain the target prediction block; alternatively, after the decoder determines the weight value of each matching block in the multiple matching blocks, it multiplies the weight value of each matching block by the weight value of each matching block and sums the results, and processes the obtained fusion block to obtain the target prediction block.
[0303] In some embodiments, the decoder determines the weight value of each matching block based on the template error value of each matching block, the number of the plurality of matching blocks, and the sum of the weights of the plurality of matching blocks.
[0304] Exemplarily, the weight value of each matching block is negatively correlated with the template error value of each matching block.
[0305] Exemplarily, the weight value of each matching block is negatively correlated with the number of the multiple matching blocks.
[0306] Exemplarily, the weight value of each matching block is positively correlated with the sum of the weights of the multiple matching blocks.
[0307] Of course, in other alternative embodiments, the decoder may also determine the weight value of each matching block only through the template error value or other information of each matching block, and this application does not make any specific limitation to this.
[0308] In some embodiments, the decoder determines the weight value of each matching block in the following manner:
[0309] Based on the template loss value of each matching block, a third numerical value corresponding to each matching block is determined; the third numerical values corresponding to each matching block are summed to obtain a fourth numerical value; based on the fourth numerical value and the template error value of each matching block, a weight value of each matching block is determined.
[0310] Exemplarily, the third value corresponding to each matching block is a value greater than 0.
[0311] Exemplarily, the third numerical value corresponding to each matching block can be understood as an updated value of the template error value of each matching block.
[0312] In some embodiments, if the template error value of the i-th matching block among the multiple matching blocks is 0, a preset value greater than 0 is determined as the third value corresponding to the i-th matching block; if the template error value of the i-th matching block is 0, the template error value of the i-th matching block is determined as the third value corresponding to the i-th matching block.
[0313] Exemplarily, if the template error value of the i-th matching block among the multiple matching blocks is 0, 1 is determined as the third value corresponding to the i-th matching block.
[0314] In some embodiments, the decoder determines the weight value of the i-th matching block in the multiple matching blocks in the following manner:
[0315] The third value corresponding to the i-th matching block is subtracted from the fourth value to obtain a fifth value; the fourth value is multiplied by n-1 to obtain a sixth value, where n represents the number of the multiple matching blocks; and the weight value of the i-th matching block is determined based on the fifth value and the sixth value.
[0316] Exemplarily, the weight value of the i-th matching block is positively correlated with the fifth value.
[0317] Exemplarily, the weight value of the i-th matching block is negatively correlated with the sixth value.
[0318] In some embodiments, if the i-th matching block is not the last matching block among the multiple matching blocks, the ratio of the fifth value to the sixth value is determined as the weight value of the i-th matching block; if the i-th matching block is the last matching block, the weight value of the last matching block is obtained by subtracting the weight values of the first n-1 matching blocks among the multiple matching blocks from the preset total weight value.
[0319] Exemplarily, the preset total weight value may be any integer, for example, a power of 2, such as 2, 4, 8, 16, 64, etc.
[0320] In some embodiments, the decoder determines the ratio of the fifth value to the sixth value as the weight value of the i-th matching block; wherein the sum of the weight values of the multiple matching blocks is equal to a preset total weight value.
[0321] Exemplarily, the preset total weight value may be any integer, for example, a power of 2, such as 2, 4, 8, 16, 64, etc.
[0322] In some embodiments, the ratio of the fifth value to the sixth value is a value obtained by bitwise operation, addition operation, and subtraction operation.
[0323] Exemplarily, the bit operation includes at least one of a right shift operation, a left shift operation, a logical AND operation, a logical OR operation, and a conditional operation. Of course, other operations may also be included, and this application does not limit this.
[0324] In some embodiments, the ratio of the fifth value to the sixth value is a value determined by the following formula:
[0325] W i =(D5*V*W sum +D Add )>>D Shift ;
[0326] Among them, * is the multiplication operator, + is the addition operator, >> is the right shift operator, D5 represents the fifth value, W sum Represents the total weight value, V is the value determined by looking up the table according to the seventh value, D Shift The right shift amount is calculated based on the seventh value, and the seventh value is a value determined based on the sixth value. Add Based on D Shift Determined value.
[0327] In some embodiments, V and D Shift Determined as follows:
[0328]
[0329] D7=((n-1)*D4< <4> >X)&15;
[0330] V = table[D7]|8;
[0331] X=D7==0? X:X+1;
[0332] D Shift =X+3;
[0333] in, is the upward value operator, * is the multiplication operator, << is the left shift operator, >> is the right shift operator, & is the logical AND operator, | is the logical OR operator, ? is the conditional operator, + is the addition operator, D6 represents the sixth value, D4 represents the fourth value, table[] represents the query table, and D7 represents the seventh value.
[0334] Illustratively, table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0}.
[0335] Of course, the numbers in the above formula can be adjusted based on actual needs, and this application does not make any specific limitations on this.
[0336] In some embodiments, D Add = 1 << (D Shift – 1), or D Add = 1 << D Shift ; where << is the left shift operator and – is the subtraction operator.
[0337] Of course, the 1 in the above formula can be replaced with other values, and this application does not limit this.
[0338] Taking the preset total weight value of 64 as an example, when the decoder obtains n (1 < n <= N) matching blocks, and the corresponding template error values are SAD1 to SADn respectively, the weight value W i of the matching block i (1 ≤ i ≤ n) can be determined according to the following example:
[0339] Example 1:
[0340] SAD i = (SAD i == 0)? 1 : SAD i ;
[0341]
[0342] W i = (SUM - SAD i ) / ((n - 1) * SUM);
[0343] The calculation of W i can be implemented by operations such as table lookup, bit operations, addition, subtraction, multiplication, etc. For example, if the precision of the weight value is 1 / 64, then:
[0344]
[0345] Norm = ((n - 1) * SUM << 4 >> X) & 15;
[0346] V = table[Norm] | 8;
[0347] X = norm == 0? X : X + 1;
[0348] D Shift = X + 3;
[0349] D Add = 1 << (D Shift – 1);
[0350] W i = ((SUM - SAD i ) * V * 64 + D Add ) >> D Shift , 1 ≤ i < n;
[0351]
[0352] Among them, table[]={0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.
[0353] Example 2:
[0354] SAD i =(SAD i = = 0)? 1: SAD i ;
[0355]
[0356] W i =(SUM-SAD i ) / ((n-1)*SUM);
[0357] W i The calculation can be achieved by table lookup, bitwise operation, addition, subtraction, multiplication and other operations. For example, the precision of the weight value is 1 / 64, then:
[0358]
[0359] Norm=((n-1)*SUM< <4> >X)&15;
[0360] V = table[Norm]|8;
[0361] X=norm==0? X:X+1;
[0362] D Shift =X+3;
[0363] D Add =1< <D Shift ;
[0364] W i =((SUM-SAD i )*V*64+D Add )>>D Shift , 1≤i <n;
[0365]
[0366] Among them, table[]={0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.
[0367] Example 3:
[0368] SAD i =(SAD i= = 0)? 1: SAD i ;
[0369]
[0370] W i =(SUM-SAD i ) / ((n-1)*SUM);
[0371] W i The calculation can be achieved by table lookup, bitwise operation, addition, subtraction, multiplication and other operations. For example, the precision of the weight value is 1 / 64, then:
[0372]
[0373] Norm=((n-1)*SUM< <4> >X)&15;
[0374] V = table[Norm]|8;
[0375] X=norm==0? X:X+1;
[0376] D Shift =X+3;
[0377] D Add =1< <D Shift ;
[0378] W i =((SUM-SAD i )*V*64+D Add )>>D Shift , 1≤i <n;
[0379] Among them, table[]={0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.
[0380] Furthermore, W can be adjusted by the following steps: i Make
[0381]
[0382]
[0383] Of course, the numbers in the formulas involved in Examples 1 to 3 above can be adjusted based on actual needs, and this application does not make any specific limitations on this.
[0384] In some embodiments, the decoder selects a first candidate set including weight values equal to the number of the multiple matches from multiple candidate sets based on the number of the multiple matching blocks; and then determines the weight values of the respective matching blocks based on the first candidate set.
[0385] Exemplarily, different candidate sets in the multiple candidate sets include different numbers of weight values.
[0386] In some embodiments, the template error value of each matching block is negatively correlated with the weight value of each matching block.
[0387] Exemplarily, the weight value of each matching block can be any predefined fixed value, and different weight values are assigned to each matching block according to the number of the multiple matching blocks, the template error value of each matching block, etc. For example, the weight values are set to {3 / 4, 1 / 4}, {1 / 2, 1 / 4, 1 / 4}. If there are two matching blocks pred1 and pred2, and the corresponding template error value SAD1≤SAD2, then the weight value of pred1 is set to W1=3 / 4, and the weight value of pred2 is set to W2=1 / 4; if there are three matching blocks pred1, pred2, and pred3, and the corresponding template error values SAD1≤SAD2≤SAD3, then the weight values of pred1, pred2, and pred3 are set to W1=1 / 2, W2=1 / 4, and 1 / 4.
[0388] In some embodiments, the decoder performs weighted processing on the multiple matching blocks based on the weight values of the respective matching blocks in the following manner to obtain the target prediction block:
[0389] The weight values of the matching blocks are multiplied by the weight values of the matching blocks and then summed to obtain an eighth value. The eighth value is added to C offset , get the ninth value; shift the ninth value right by C Shift , get the target prediction block; where C offset According to C Shift The determined value, C Shift is a value determined according to the sum of the weight values of the multiple matching blocks.
[0390] Exemplarily, the decoder determines the target prediction block based on the following:
[0391]
[0392] Among them, Pred represents the target prediction block, Pred i represents the i-th matching block, W i represents the weight value of the i-th matching block, n represents the number of the multiple matching blocks, C offset According to C Shift The determined value, CShift is a value determined according to the sum of the weight values of the multiple matching blocks.
[0393] In some embodiments, C offset =<<(C Shift -1), in, is the upward value operator, << is the left shift operator, W sum Represents the sum of the weight values of the multiple matching blocks.
[0394] In some embodiments, the decoder performs weighted processing on the multiple matching blocks in the following manner to obtain a target prediction block for the current block:
[0395] The current block is divided into multiple regions; for a first region among the multiple regions, a weight value of each matching block in the multiple matching blocks is determined in the first region; based on the weight value of each matching block in the first region, the multiple matching blocks are weighted in the first region to obtain a prediction value of the target prediction block in the first region; wherein the target prediction block includes the prediction value of each region in the multiple regions.
[0396] Illustratively, the weight values of the i-th matching block in the multiple matching blocks in different regions of the multiple regions may be the same or different.
[0397] Exemplarily, when the current block is divided into region 1 and region 2, for region 1, the weight value of each matching block in the multiple matching blocks in region 1 is determined; based on the weight value of each matching block in region 1, the multiple matching blocks are weighted in region 1 to obtain the prediction value of the target prediction block in region 1; similarly, for region 2, the weight value of each matching block in the multiple matching blocks in region 2 is determined; based on the weight value of each matching block in region 2, the multiple matching blocks are weighted in region 2 to obtain the prediction value of the target prediction block in region 2; wherein, the target prediction block includes the prediction value of region 1 and the prediction value of region 2.
[0398] It is worth noting that the method for determining the weight value of each matching block in the multiple matching blocks in the first area can refer to the method for determining the weight value of each matching block when the current block is not divided, and can also refer to a method similar to CIIP to determine the weight value of each matching block in the first area based on the distribution of the multiple areas. To avoid repetition, it is not repeated here.
[0399] In some embodiments, the decoder divides the current block into multiple regions in a horizontal direction or a vertical direction.
[0400] Exemplarily, the decoder divides the current block into four regions in the horizontal or vertical direction. For example, as shown in FIG6 (a), when the current block is divided into four equal regions vertically, the region indexes are 0, 1, 2, and 3 in the order from left to right; as shown in FIG6 (b), when the current block is divided into four equal regions horizontally, the region indexes are 0, 1, 2, and 3 in the order from top to bottom.
[0401] In some embodiments, S330 may include:
[0402] If the at least one matching block is a single matching block, the decoder predicts the current block using the first intra prediction mode to obtain a first prediction block; and performs weighted processing on the single matching block and the first prediction block to obtain the target prediction block.
[0403] Exemplarily, if the at least one matching block is a single matching block, the decoder may determine the target prediction block according to the following formula:
[0404] Pred=(7*Pred1+Pred2+4)>>3;
[0405] Wherein, Pred represents the target prediction block, Pred1 represents the single matching block, and Pred2 represents the first prediction block.
[0406] Of course, the numerical values in the above formula can be replaced with other numerical values according to actual needs, and this application does not make specific limitations on this.
[0407] Exemplarily, the first intra-frame prediction mode is any prediction mode different from the IntraTMP mode.
[0408] Exemplarily, the first intra-frame prediction mode may be a predefined prediction mode. The predefined prediction mode may be a default prediction mode. For example, the predefined prediction mode may be implemented by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including a decoder), and this application does not limit its specific implementation method. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of this application, the "protocol" may refer to a standard protocol in the field of coding and decoding, for example, it may include the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0409] Exemplarily, the decoder may determine the first intra-frame prediction mode by decoding the code stream.
[0410] In some embodiments, the weight value of the single matching block and the weight value of the first prediction block are both predefined weight values.
[0411] Exemplarily, the ratio of the weight value of the single matching block to the weight value of the first prediction block and the sum of the weight value of the single matching block and the weight value of the first prediction block are both predefined values.
[0412] Exemplarily, the predefined weight value may be a default weight value, and the predefined prediction mode may be a default prediction mode. For example, the predefined weight value may be implemented by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including a decoder), and this application does not limit its specific implementation method. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of this application, the "protocol" may refer to a standard protocol in the field of coding and decoding, for example, it may include the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0413] In some embodiments, the method 300 may further include:
[0414] The weight value of the single matching block and the weight value of the first prediction block are determined based on at least one of the following:
[0415] Decoding information of adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of various regions of the current block.
[0416] Exemplarily, the decoder may determine the weight value of the single matching block based on at least one of the decoding information of the adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of the various regions of the current block, and then determine the weight value of the first prediction block based on a predefined total weight value and the weight value of the single matching block. For example, the decoder may determine the weight value corresponding to at least one of the decoding information of the adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of the various regions of the current block as the weight value of the single matching block, wherein the weight value of the first prediction block is the difference between the total weight value and the weight value of the single matching block.
[0417] Of course, the weight value of the single matching block and the weight value of the first prediction block can also be determined by other means, and this application does not impose specific limitations on this. For example, the weight value of the single matching block and the weight value of the first prediction block can be determined by decoding the code stream. For another example, the weight value of the single matching block can be determined based on the template error value of the single matching block, and then the weight value of the first prediction block can be determined based on a predefined total weight value and the weight value of the single matching block. For example, the weight value of the single matching block is negatively correlated with the template error value of the single matching block, and the weight value of the first prediction block is the difference between the total weight value and the weight value of the single matching block.
[0418] In some embodiments, S330 may include:
[0419] If the at least one matching block is a plurality of matching blocks, the decoder predicts the current block using a second intra prediction mode to obtain a second predicted block;
[0420] The multiple matching blocks and the second prediction block are weighted to obtain the target prediction block.
[0421] Exemplarily, the first intra-frame prediction mode is any prediction mode different from the IntraTMP mode.
[0422] Exemplarily, the second intra-frame prediction mode may be a predefined prediction mode. The predefined prediction mode may be a default prediction mode. For example, the predefined prediction mode may be implemented by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including a decoder), and this application does not limit its specific implementation method. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of the present application, the "protocol" may refer to a standard protocol in the field of coding and decoding, for example, it may include the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0423] Exemplarily, the decoder may determine the second intra-frame prediction mode by decoding the code stream.
[0424] In some embodiments, the weight value of the second prediction block is a predefined weight value.
[0425] Exemplarily, the ratio of the sum of the weight values of the multiple matching blocks to the weight value of the second prediction block, and the sum of the weight values of the multiple matching blocks and the weight value of the second prediction block are all predefined values.
[0426] Exemplarily, the predefined weight value may be a default weight value, and the predefined prediction mode may be a default prediction mode. For example, the predefined weight value may be implemented by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including a decoder), and this application does not limit its specific implementation method. For example, predefined may refer to a definition in a protocol. It should also be understood that in the embodiments of this application, the "protocol" may refer to a standard protocol in the field of coding and decoding, for example, it may include the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding, as well as related protocols used in future coding and decoding systems, and this application does not limit this.
[0427] In some embodiments, the method 300 may further include:
[0428] Determine a weight value of the second prediction block based on at least one of the following:
[0429] Decoding information of adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the second intra prediction mode, the total weight value of the multiple matching blocks, and the positions of various regions of the current block.
[0430] Exemplarily, the decoder may determine the sum of the weight values of the multiple matching blocks based on at least one of the decoding information of the adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of the various regions of the current block, and then determine the weight value of the second prediction block based on a predefined total weight value and the sum of the weight values of the multiple matching blocks. For example, the decoder may determine the weight value corresponding to at least one of the decoding information of the adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of the various regions of the current block as the sum of the weight values of the multiple matching blocks, wherein the weight value of the second prediction block is the difference between the total weight value and the sum of the weight values of the multiple matching blocks.
[0431] Of course, the sum of the weight values of the multiple matching blocks and the weight value of the second prediction block can also be determined in other ways, and this application does not specifically limit this. For example, the sum of the weight values of the single matching block and the weight value of the second prediction block can be determined by decoding the code stream. For another example, the sum of the weight values of the multiple matching blocks can be determined based on the average value of the template error values of the multiple matching blocks, and then the weight value of the second prediction block can be determined based on the sum of the weight values of the multiple matching blocks and the predefined total weight value. For example, the weight values of the multiple matching blocks are negatively correlated with the average value of the template error values of the multiple matching blocks, and the weight value of the second prediction block is the difference between the total weight value and the sum of the weight values of the multiple matching blocks.
[0432] It is worth noting that, in the case where the sum of the weight values of the multiple matching blocks is sufficient, the decoder may determine the weight value of each matching block in the multiple matching blocks in the manner described above where the decoder only fuses the multiple matching blocks, and then determine the weight value of the second prediction block based on the ratio between the weight values of the multiple matching blocks and the weight value of the second prediction block, and a predefined total weight value. Alternatively, the decoder may determine the weight value of each matching block in the manner described above where the decoder only fuses the multiple matching blocks, wherein the weight value of the second prediction block is a predefined value.
[0433] In some embodiments, the template of the current block includes at least one of the following: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels.
[0434] Exemplarily, the left reconstructed pixel, the lower left reconstructed pixel, or the upper left reconstructed pixel includes one or more columns of reconstructed pixels.
[0435] Exemplarily, the upper left reconstructed pixels, the upper side reconstructed pixels, or the upper right reconstructed pixels include one or more rows of reconstructed pixels.
[0436] FIG11 is an example of a template of a current block provided in an embodiment of the present application.
[0437] As shown in (a) of Figure 11, the template of the current block includes: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels. As shown in (b) of Figure 11, the template of the current block includes: left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels. As shown in (c) of Figure 11, the template of the current block includes: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, and upper reconstructed pixels. As shown in (d) of Figure 11, the template of the current block includes: upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels. As shown in (e) of Figure 11, the template of the current block includes: left reconstructed pixels, lower left reconstructed pixels, and upper left reconstructed pixels.
[0438] In some embodiments, S320 may include:
[0439] Determine the restrictions for using the IntraTMP mode;
[0440] When the restriction condition is satisfied, the at least one matching block is predicted based on the IntraTMP mode.
[0441] In some embodiments, the restriction condition is obtained by at least one of the following: the size of the current block, the decoding information of the adjacent decoded blocks, the sequence level flag, the frame level flag, the macroblock level flag, the type of the slice in which the current block is located, and the frame type of the image frame in which the current block is located.
[0442] Exemplarily, when the restriction condition for using the IntraTMP mode is met, the decoder decodes the first identifier mentioned above.
[0443] Exemplarily, when the restriction conditions for using the IntraTMP mode are met, the decoder decodes the first identifier mentioned above. When the first identifier indicates that the IntraTMP mode is used, the decoder determines at least one matching block of the current block based on the IntraTMP mode.
[0444] Exemplarily, the restriction condition includes at least one of the following: the size of the current block is greater than (or equal to or less than) a predefined size; the decoding information of the adjacent decoded block is predefined decoding information; the value of the sequence-level flag is a predefined value; the value of the frame-level flag is a predefined value; the value of the macroblock-level flag is a predefined value; the type of the slice in which the current block is located is a predefined type; and the frame type of the image frame in which the current block is located is a predefined type. The various predefined information (e.g., the predefined size, predefined decoding information, predefined value, predefined type) can be implemented by pre-storing corresponding codes, tables, or other methods that can be used to indicate relevant information in a device (e.g., including a decoder). This application does not limit the specific implementation method. For example, predefined can refer to a definition in a protocol. It should also be understood that in the embodiments of the present application, the "protocol" can refer to a standard protocol in the field of codecs, for example, including the fields of image codecs, video codecs, hardware video codecs, dedicated circuit video codecs, real-time video codecs, and related protocols used in future codec systems. This application does not limit this.
[0445] For example, assuming that the constraint includes that the frame type of the image frame where the current block is located is a predefined type, in this case, the predefined type may be an I frame, that is, the constraint includes that the frame type of the image frame where the current block is located is an I frame; in other words, only when the image frame where the current block is located is an I frame used for intra-frame prediction, the decoder can determine at least one matching block of the current block based on the IntraTMP mode.
[0446] The preferred embodiments provided in this application are described below.
[0447] Example 1:
[0448] Step 1:
[0449] The decoder decodes the input bitstream, and the decoding process is performed in CTU order. The CTU is divided into different coding blocks for decoding according to the block division flag obtained by decoding. If the flag sps_tmp_enabled_flag in the SPS is equal to 1, and the current coding block size meets the limit MaxTmpSize on the IntraTMP coding block size in the SPS, then decode the intra_tmp_flag. If intra_tmp_flag is equal to 1, it indicates that the current coding block is encoded using the IntraTMP mode, and decode the intra_tmp_fusion_flag. If intra_tmp_flag is equal to 0, it indicates that the current coding block is not encoded using the IntraTMP mode, and there is no need to decode the intra_tmp_fusion_flag. The process of decoding related syntax elements is shown in Table 1.
[0450] Step 2:
[0451] Use X context models to decode the syntax element intra_tmp_fusion_flag. The index CtxIdxInc corresponding to different context models is determined based on the coding information of the adjacent coding blocks, the current coding block size, etc. For example, X is equal to 3, and the current coding block coordinates are (x, y). If there is a coding block cuLeft at the coordinates (x-1, y) and cuLeft's intra_tmp_fusion_flag is 1, then CtxIdxInc is 1, otherwise it is 0. Subsequently, if there is a coding block cuAbove at the coordinates (x, y-1) and cuAbove's intra_tmp_fusion_flag is 1, then CtxIdxInc is incremented by 1, otherwise it is incremented by 0.
[0452] Step 3:
[0453] If intra_tmp_fusion_flag is equal to 1, it indicates that the current coding block uses IntraTMP combined fusion prediction. If intra_tmp_fusion_flag is equal to 0, it indicates that the current coding block uses IntraTMP prediction of a single matching block.
[0454] Step 4:
[0455] When decoding obtains that intra_tmp_flag of the current coding block is equal to 1 and intra_tmp_fusion_flag is equal to 1, the current coding block is encoded using the IntraTMP mode and the IntraTMP combined fusion prediction is used to obtain the prediction block of the current coding block.
[0456] Step 5:
[0457] Perform intra-frame template matching within the search area based on the current coding block to obtain a list of candidate block vectors. For example, calculate the template error values (represented by the SAD between templates) under different block vectors within the search area of the current coding block with a step size of S (i.e., every S points in the horizontal and vertical directions). For example, if the block vector currently being matched is (X0, Y0), the next block vector to be matched is (X0-S, Y0), and the vertical coordinate of the block vector to be matched in the next row is Y0-4. Construct a list of candidate block vectors of size X, where X can be determined by the number of matching blocks N to be fused, for example, X is equal to 3*N. The list always saves the 3*N block vectors with the smallest template error values during the template matching process. The block vectors in the list are sorted according to the size of the template error value. In addition, the template error values corresponding to each block vector in the list are saved for subsequent steps.
[0458] Step 6:
[0459] Obtain N available block vectors through the candidate block vector list. The matching blocks pointed to by these block vectors are used as matching blocks of the current coding block for the subsequent weighted fusion process. For example, the candidate block vector list is pruned and refined N times to obtain N available block vectors. The pruning step is used to avoid excessive overlap in the refining step, and the refining step is used to obtain more accurate matching blocks. Specifically, during the i-th pruning and refining, the i-th block vector BV in the list is taken. i , BV i Equal to (X i , Y i ), confirm the pruning and refinement distance L = (S / 2) * H, where S is the template matching step size and H is the height of the current coding block. The pruning and refinement range is (X i -L,Y i -L), the lower right corner is (X i +L,Y i +L), if the block vector j (X j ,Y j )satisfy:
[0460] X i -L≤X j ≤X i +L&&Y i –L≤Y j ≤Y i +L;
[0461] This indicates that block vector j is within the pruning range and should be removed from the list. Template matching is then performed within the rectangular area with a step size of S' (S' = S / 2) to obtain the block vector i' with the smallest template error value, which is used as the i-th available block vector. When S' is greater than one pixel, the pruning and refinement process can be repeated until S' equals 1.
[0462] Step 7:
[0463] Determine whether the matching blocks corresponding to the N available block vectors obtained are used in the weighted fusion process. For example, set the thresholds threshold1 and threshold2 as follows:
[0464] threshold1 = (1 << (bitDepth – 2)) * num_template;
[0465] threshold2 = minSAD << 1;
[0466] where num_template is the number of template pixels, bitDepth is the pixel bit width, and minSAD is the minimum template error value among the N block vectors.
[0467] If the template error value SAD of block vector i i satisfies:
[0468] SAD i ≤ threshold1 && SAD i < threshold2;
[0469] then use the matching block i corresponding to block vector i for subsequent weighted fusion.
[0470] Step 8:
[0471] Calculate the weight value of each block according to the template error value of the matching block. For example, n (1 < n <= N) matching blocks are obtained, and the corresponding template error values are SAD1 to SAD n , then the weight value W i of matching block i (1 ≤ i ≤ n) is:
[0472] SAD i = (SAD i == 0)? 1 : SAD i ;
[0473]
[0474] i ) / ((n - 1) * SUM);
[0475] The calculation of Wi can be implemented by operations such as table lookup, bitwise operations, addition, subtraction, multiplication, etc. For example, if the precision of the weight value is 1 / 64, then:
[0476]
[0477] Norm = ((n - 1) * SUM << 4>> X) & 15;
[0478] V = table[Norm] | 8;
[0479] X = norm == 0? X : X + 1;
[0480] Shift = X + 3;
[0481] Add = 1 << (Shift – 1);
[0482] W i = ((SUM - SAD i ) * V * 64 + Add) >> Shift, 1 ≤ i < n;
[0483]
[0484] where table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0}.
[0485] Specifically, when only 1 matching block is obtained in step 6, the weight calculation is not performed.
[0486] Step 9:
[0487] According to the matching blocks and the weight values of each block obtained in step 8, these matching blocks are weighted and fused to obtain the final IntraTMP combined fusion prediction block. For example, in steps 16 to 19, n (1 < n <= N) matching blocks are obtained, and the corresponding weights are W1 to W n , then the final prediction block Pred is:
[0488]
[0489] where offset = 1 << (shift - 1),
[0490] Specifically, when only 1 matching block Pred1 is obtained in step 6, it is weighted and fused with the prediction block Pred_planar obtained from the planar mode to obtain the final prediction block Pred:
[0491] Pred = (7 * Pred1 + Pred_planar + 4) >> 3.
[0492] Step 10:
[0493] Decode the coefficient signal of the current coded block and obtain the residual block of the current coded block through inverse quantization and inverse transformation. Add the prediction block Pred to the residual block to obtain the reconstructed block of the current coded block, and complete the decoding of the current coded block.
[0494] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all fall within the scope of protection of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will no longer describe the various possible combinations separately. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the idea of the present application, they should also be regarded as the contents disclosed in the present application. It should also be understood that in the various method embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0495] The decoding method according to the embodiment of the present application is described in detail above from the perspective of the decoder. The encoding method according to the embodiment of the present application will be described below from the perspective of the encoder in conjunction with Figure 12.
[0496] FIG12 is a schematic flow chart of an encoding method 400 provided in an embodiment of the present application. It should be understood that the encoding method 400 can be performed by an encoder. For example, it can be applied to the encoding framework shown in FIG1 . For ease of description, the encoding method 400 is exemplarily described below using an encoder as an example.
[0497] As shown in FIG. 12 , the encoding method 400 may include:
[0498] S410, predicting at least one matching block of a current block in a current sequence based on an intra-frame template matching prediction IntraTMP mode;
[0499] S420, determining a target prediction block for the current block based on the at least one matching block;
[0500] S430, obtaining a residual block of the current block based on the target prediction block and the original block of the current block;
[0501] S440: Encode the residual block of the current block.
[0502] In some embodiments, the method 400 may further include:
[0503] encoding the first identifier;
[0504] The first identifier indicates that the IntraTMP mode is used for fusion prediction.
[0505] In some embodiments, the method 400 may further include:
[0506] encoding the second identifier;
[0507] The second flag indicates that the IntraTMP mode is used for prediction.
[0508] In some embodiments, encoding the second identifier includes:
[0509] Determine the target context index;
[0510] The first identifier is encoded using the target context index.
[0511] In some embodiments, determining the target context index includes:
[0512] Determine the target context index based on the coding information of the adjacent coding blocks of the current block: and / or
[0513] The target context index is determined based on the size of the current block.
[0514] In some embodiments, the coordinates of the current block are (x, y), the adjacent coding blocks include a first coding block with coordinates (x-1, y) and a second coding block with coordinates (x, y-1); the encoding information of the first coding block includes a prediction mode used by a prediction block of the first coding block, and the encoding information of the second coding block includes a prediction mode used by a prediction block of the second coding block;
[0515] The determining of the target context index based on coding information of adjacent coding blocks of the current block includes:
[0516] If the prediction mode used by the prediction block of the first coding block is a mode of fusion prediction based on the IntraTMP mode, the first value is assigned to A; otherwise, the first value is assigned to B; A and B are both integers;
[0517] If the prediction mode used by the prediction block of the second coding block is a prediction mode for fusion prediction based on the IntraTMP mode, the second value is assigned to C; otherwise, the second value is assigned to D; C and D are both integers;
[0518] The sum of the first value and the second value is determined as the target context index.
[0519] In some embodiments, S410 may include:
[0520] Perform template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks;
[0521] The at least one matching block is determined based on the X candidate matching blocks.
[0522] In some embodiments, template matching is performed on the current block based on the IntraTMP mode to obtain X candidate matching blocks, including:
[0523] Based on the IntraTMP mode, intra-frame template matching is performed within the search area of the current block to obtain all candidate matching blocks of the current block;
[0524] The matching blocks arranged in the first X positions in the order of template error values from small to large are determined as the X candidate matching blocks.
[0525] In some embodiments, template matching is performed on the current block based on the IntraTMP mode to obtain X candidate matching blocks, including:
[0526] Based on the IntraTMP mode, a candidate matching block list is constructed; the candidate matching block list is used to store X matching blocks with the smallest template error values when performing intra-frame template matching within the search area of the current block.
[0527] In some embodiments, template matching is performed on the current block based on the IntraTMP mode to obtain X candidate matching blocks, including:
[0528] Divide the search area of the current block into Y sub-areas;
[0529] Based on the IntraTMP mode, intra-frame template matching is performed in each of the Y sub-regions to obtain a candidate matching block in each sub-region;
[0530] The X candidate matching blocks include candidate matching blocks in each sub-region.
[0531] In some embodiments, X=Y, or X is a multiple of Y.
[0532] In some embodiments, determining the at least one matching block based on the X candidate matching blocks includes:
[0533] Based on the X candidate matching blocks, determine N available matching blocks; X ≥ N;
[0534] The at least one matching block is determined based on the N available matching blocks.
[0535] In some embodiments, X is a multiple of N.
[0536] In some embodiments, determining N available matching blocks based on the X candidate matching blocks includes:
[0537] Based on the intervals between the X candidate matching blocks, the X candidate matching blocks are pruned to obtain the N available matching blocks.
[0538] In some embodiments, pruning the X candidate matching blocks based on the spacing between the X candidate matching blocks to obtain the N available matching blocks includes:
[0539] Determine a current candidate matching block for pruning from the X candidate matching blocks in ascending order of template error values;
[0540] Determine the pruning range of the current candidate matching block;
[0541] Remove candidate matching blocks other than the current candidate matching block within the pruning range to obtain candidate matching blocks remaining after pruning based on the current candidate matching block, until the number of prunings of the X candidate matching blocks reaches N, then determine the first N candidate matching blocks of the remaining candidate matching blocks as the N available matching blocks, or until the number of candidate matching blocks remaining after pruning based on the current candidate matching block is less than or equal to N, then determine the first N candidate matching blocks among the candidate matching blocks remaining after the last pruning as the N available matching blocks.
[0542] In some embodiments, determining the pruning range of the current candidate matching block includes:
[0543] The pruning range is determined based on the size of the current block and the current candidate matching block.
[0544] In some embodiments, determining the pruning range based on the size of the current block and the current candidate matching block includes:
[0545] Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / E)*H is determined as the pruning range;
[0546] Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and E is a positive integer.
[0547] In some embodiments, determining the pruning range of the current candidate matching block includes:
[0548] The trimming range is determined based on predefined values.
[0549] In some embodiments, determining N available matching blocks based on the X candidate matching blocks includes:
[0550] The X candidate matching blocks are refined to obtain the N available matching blocks.
[0551] In some embodiments, refining the X candidate matching blocks to obtain the N available matching blocks includes:
[0552] Determining a refinement range of a current candidate matching block among the X candidate matching blocks;
[0553] Based on at least one matching step length, performing intra-frame template matching within the refined range to obtain a matching block within the refined range; each matching step length in the at least one matching step length is smaller than a matching step length used by the X candidate matching blocks;
[0554] Determine the matching block with the smallest template loss value among the matching blocks matched within the refining range as the candidate matching block obtained by refining the current candidate matching block;
[0555] A candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks.
[0556] In some embodiments, determining a refinement range of a current candidate matching block among the X candidate matching blocks includes:
[0557] The refinement range is determined based on the size of the current block and the current candidate matching block.
[0558] In some embodiments, determining the refinement range based on the size of the current block and the current candidate matching block includes:
[0559] Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / F)*H is determined as the refinement range;
[0560] Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and F is a positive integer.
[0561] In some embodiments, determining a refinement range of a current candidate matching block among the X candidate matching blocks includes:
[0562] The refining range is determined based on predefined values.
[0563] In some embodiments, the candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks, including:
[0564] If the current candidate matching block is the i-th matching block among the X candidate matching blocks, and the j-th matching block matched within the refining range is the matching block with the smallest template loss value among the first j matching blocks within the refining range, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block.
[0565] In some embodiments, determining N available matching blocks based on the X candidate matching blocks includes:
[0566] The X candidate matching blocks are pruned and refined to obtain the N available matching blocks.
[0567] In some embodiments, the X candidate matching blocks are pruned and refined to obtain the N available matching blocks, including:
[0568] After pruning the X candidate matching blocks, refining the pruned candidate matching blocks; or
[0569] After refining the X candidate matching blocks, pruning the refined candidate matching blocks; or
[0570] After pruning the X candidate matching blocks based on the current candidate matching block among the X candidate matching blocks, the current candidate matching block is refined.
[0571] In some embodiments, determining the at least one matching block based on the N available matching blocks includes:
[0572] Determine the fusion conditions used by the N available matching blocks;
[0573] An available matching block that meets the fusion condition among the N available matching blocks is determined as the at least one matching block.
[0574] In some embodiments, determining a fusion condition for the N available matching blocks includes:
[0575] The fusion condition is determined based on at least one of the following:
[0576] The size of the template of the current block, the bit width of the pixels of the current block in the current block, and the minimum template error value of the N available matching blocks.
[0577] In some embodiments, the fusion condition includes a first threshold, which is a threshold determined based on the size of the template of the current block and the bit width;
[0578] The step of determining an available matching block that satisfies the fusion condition among the N available matching blocks as the at least one matching block includes:
[0579] An available matching block having a template error value less than or equal to the first threshold among the N available matching blocks is determined as the at least one matching block.
[0580] In some embodiments, the first threshold is determined according to the following formula:
[0581] T1=n1<<(b depth –n2)*n template ;
[0582] Among them, << is the left shift operator, - is the subtraction operator, * is the multiplication operator, T1 represents the first threshold, b depth Indicates the bit width, n template Represents the number of pixels in the template of the current block; n1 and n2 are both positive integers.
[0583] In some embodiments, the fusion condition includes a second threshold value, and the second threshold value is a threshold value determined based on the minimum template error value;
[0584] The step of determining an available matching block that satisfies the fusion condition among the N available matching blocks as the at least one matching block includes:
[0585] An available matching block having a template error value less than or equal to a second threshold among the N available matching blocks is determined as the at least one matching block.
[0586] In some embodiments, the second threshold is determined according to the following formula:
[0587] T2=min SAD < <n3;
[0588] Among them, << is the left shift operator, T2 represents the second threshold, min SAD Indicates the minimum template error value, n3 is a positive integer.
[0589] In some embodiments, the method 400 may further include:
[0590] Determine indication information; the indication information is used to indicate the at least one matching block among the N available matching blocks;
[0591] The indication information is encoded.
[0592] In some embodiments, S420 may include:
[0593] If the at least one matching block is a plurality of matching blocks, weighted processing is performed on the plurality of matching blocks to obtain a target prediction block of the current block.
[0594] In some embodiments, performing weighted processing on the multiple matching blocks to obtain the target prediction block includes:
[0595] Determining a weight value of each matching block in the plurality of matching blocks;
[0596] Based on the weight values of the respective matching blocks, weighted processing is performed on the multiple matching blocks to obtain the target prediction block.
[0597] In some embodiments, determining a weight value of each matching block in the plurality of matching blocks includes:
[0598] The weight value of each matching block is determined based on the template error value of each matching block, the number of the multiple matching blocks, and the sum of the weights of the multiple matching blocks.
[0599] In some embodiments, determining the weight value of each matching block based on the template error value of each matching block, the number of the plurality of matching blocks, and the sum of the weights of the plurality of matching blocks includes:
[0600] Determining a third value corresponding to each matching block based on the template loss value of each matching block;
[0601] Summing the third values corresponding to the respective matching blocks to obtain a fourth value;
[0602] The weight values of the matching blocks are determined based on the fourth value and the template error values of the matching blocks.
[0603] In some embodiments, determining the third value corresponding to each matching block based on the template loss value of each matching block includes:
[0604] If the template error value of the i-th matching block among the multiple matching blocks is 0, a preset value greater than 0 is determined as the third value corresponding to the i-th matching block;
[0605] If the template error value of the i-th matching block is 0, the template error value of the i-th matching block is determined as the third value corresponding to the i-th matching block.
[0606] In some embodiments, determining the weight value of each matching block based on the fourth value and the template error value of each matching block includes:
[0607] The weight value of the i-th matching block among the multiple matching blocks is determined in the following manner:
[0608] Subtracting the third value corresponding to the i-th matching block from the fourth value to obtain a fifth value;
[0609] Multiplying the fourth value by n-1 to obtain a sixth value, wherein n represents the number of the plurality of matching blocks;
[0610] Based on the fifth value and the sixth value, a weight value of the i-th matching block is determined.
[0611] In some embodiments, determining the weight value of the i-th matching block based on the fifth value and the sixth value includes:
[0612] If the i-th matching block is not the last matching block among the multiple matching blocks, determining the ratio of the fifth value to the sixth value as the weight value of the i-th matching block;
[0613] If the i-th matching block is the last matching block, the weight value of the last matching block is obtained by subtracting the weight values of the first n-1 matching blocks in the multiple matching blocks from the preset total weight value.
[0614] In some embodiments, determining the weight value of the i-th matching block based on the fifth value and the sixth value includes:
[0615] Determine the ratio of the fifth value to the sixth value as the weight value of the i-th matching block;
[0616] The sum of the weight values of the multiple matching blocks is equal to a preset total weight value.
[0617] In some embodiments, the ratio of the fifth value to the sixth value is a value obtained by bitwise operation, addition operation, and subtraction operation.
[0618] In some embodiments, the ratio of the fifth value to the sixth value is a value determined by the following formula:
[0619] W i =(D5*V*W sum +D Add )>>D Shift ;
[0620] Among them, * is the multiplication operator, + is the addition operator, >> is the right shift operator, D5 represents the fifth value, W sum Represents the total weight value, V is the value determined by looking up the table according to the seventh value, D Shift The right shift amount is calculated based on the seventh value, and the seventh value is a value determined based on the sixth value. Add Based on D Shift Determined value.
[0621] In some embodiments, V and D Shift Determined as follows:
[0622]
[0623] D7=((n-1)*D4< <4> >X)&15;
[0624] V = table[D7]|8;
[0625] X=D7==0? X:X+1;
[0626] D Shift =X+3;
[0627] in, is the upward value operator, * is the multiplication operator, << is the left shift operator, >> is the right shift operator, & is the logical AND operator, | is the logical OR operator, ? is the conditional operator, + is the addition operator, D6 represents the sixth value, D4 represents the fourth value, table[] represents the query table, and D7 represents the seventh value.
[0628] In some embodiments, D Add =1<<(D Shift –1), or D Add =1< <D Shift ; Among them, << is the left shift operator and – is the subtraction operator.
[0629] In some embodiments, determining a weight value of each matching block in the plurality of matching blocks includes:
[0630] Based on the number of the plurality of matching blocks, selecting a first candidate set from the plurality of candidate sets, the first candidate set including a weight value equal to the number of the plurality of matches;
[0631] Each candidate set in the plurality of candidate sets includes at least one candidate weight value;
[0632] Based on the first candidate set, weight values of the respective matching blocks are determined.
[0633] In some embodiments, the template error value of each matching block is negatively correlated with the weight value of each matching block.
[0634] In some embodiments, the weighted processing is performed on the multiple matching blocks based on the weight values of the respective matching blocks to obtain the target prediction block, including:
[0635] Multiplying the weight values of the respective matching blocks by the respective matching blocks and summing the results to obtain an eighth value;
[0636] Using this eighth value plus C offset , and obtain the ninth value;
[0637] Shift the ninth value right by C Shift, get the target prediction block;
[0638] Among them, C offset According to C Shift The determined value, C Shift is a value determined according to the sum of the weight values of the multiple matching blocks.
[0639] In some embodiments, C offset =<<(C Shift -1), in, is the upward value operator, << is the left shift operator, W sum Represents the sum of the weight values of the multiple matching blocks.
[0640] In some embodiments, performing weighted processing on the multiple matching blocks to obtain a target prediction block for the current block includes:
[0641] Divide the current block into multiple regions;
[0642] For a first area among the multiple areas, determining a weight value of each matching block among the multiple matching blocks in the first area;
[0643] Based on the weight values of the respective matching blocks in the first region, weighted processing is performed on the plurality of matching blocks in the first region to obtain a prediction value of the target prediction block in the first region;
[0644] The target prediction block includes prediction values of each of the multiple regions.
[0645] In some embodiments, the current block is divided into a plurality of regions, including:
[0646] The current block is divided into multiple regions in a horizontal direction or a vertical direction.
[0647] In some embodiments, S420 may include:
[0648] If the at least one matching block is a single matching block, predicting the current block using a first intra prediction mode to obtain a first prediction block;
[0649] The single matching block and the first prediction block are weighted to obtain the target prediction block.
[0650] In some embodiments, the weight value of the single matching block and the weight value of the first prediction block are both predefined weight values.
[0651] In some embodiments, the method 400 may further include:
[0652] The weight value of the single matching block and the weight value of the first prediction block are determined based on at least one of the following:
[0653] Coding information of adjacent coding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of various regions of the current block.
[0654] In some embodiments, S420 may include:
[0655] If the at least one matching block is a plurality of matching blocks, predicting the current block using a second intra prediction mode to obtain a second prediction block;
[0656] The multiple matching blocks and the second prediction block are weighted to obtain the target prediction block.
[0657] In some embodiments, the weight value of the second prediction block is a predefined weight value.
[0658] In some embodiments, the method 400 may further include:
[0659] Determine a weight value of the second prediction block based on at least one of the following:
[0660] Coding information of adjacent coding blocks, size of the current block, template size of the current block, type of the second intra prediction mode, total weight values of the multiple matching blocks, and positions of various regions of the current block.
[0661] In some embodiments, the template of the current block includes at least one of the following: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels.
[0662] In some embodiments, S410 may include:
[0663] Determine the restrictions for using the IntraTMP mode;
[0664] When the restriction condition is satisfied, the at least one matching block is predicted based on the IntraTMP mode.
[0665] In some embodiments, the restriction condition is obtained by at least one of the following: the size of the current block, the coding information of the adjacent coding block, the sequence level flag, the frame level flag, the macroblock level flag, the type of the slice in which the current block is located, and the frame type of the image frame in which the current block is located.
[0666] It should be understood that the decoding method 300 is the inverse process or reverse operation of the encoding method 400 , and therefore the steps in the encoding method 400 may refer to the corresponding steps in the decoding method 300 , and for the sake of brevity, they will not be repeated here.
[0667] The preferred embodiments provided in this application are described below.
[0668] Example 2:
[0669] Step 1:
[0670] The encoder divides the input video signal into CTUs (Coding Tree Units), and then divides the CTUs into CUs (Coding Units, also known as coding blocks) of different sizes for encoding using binary trees, ternary trees, and quadtrees. For the current coding block, an available coding mode is selected based on the mode flag in the sequence parameter set (SPS) for encoding. When the IntraTMP mode flag sps_tmp_enabled_flag in the SPS is equal to 1 and the size of the current coding block meets the IntraTMP coding block size limit in the SPS, the current coding block can be encoded using the IntraTMP mode.
[0671] Step 2:
[0672] If the current coding block is encoded using the IntraTMP mode, the current coding block can use the IntraTMP prediction method of a single matching block or the IntraTMP combined fusion prediction method. The specific process of using the IntraTMP combined fusion prediction method for prediction and encoding is as follows.
[0673] Step 3:
[0674] Perform intra-frame template matching within the search area based on the current coding block to obtain a list of candidate block vectors. For example, calculate the template error values (represented by the SAD between templates) under different block vectors within the search area of the current coding block with a step size of S (i.e., every S points in the horizontal and vertical directions). For example, if the block vector currently being matched is (X0, Y0), the next block vector to be matched is (X0-S, Y0), and the vertical coordinate of the block vector to be matched in the next row is Y0-4. Construct a list of candidate block vectors of size X, where X can be determined by the number of matching blocks N to be fused, for example, X is equal to 3*N. The list always saves the 3*N block vectors with the smallest template error values during the template matching process. The block vectors in the list are sorted according to the size of the template error value. In addition, the template error values corresponding to each block vector in the list are saved for subsequent steps.
[0675] Step 4:
[0676] Obtain N available block vectors through the candidate block vector list. The matching blocks pointed to by these block vectors are used as matching blocks of the current coding block for the subsequent weighted fusion process. For example, the candidate block vector list is pruned and refined N times to obtain N available block vectors. The pruning step is used to avoid excessive overlap in the refining step, and the refining step is used to obtain more accurate matching blocks. Specifically, during the i-th pruning and refining, the i-th block vector BV in the list is taken. i , BV i Equal to (X i , Y i ), confirm the pruning and refinement distance L = (S / 2) * H, where S is the template matching step size and H is the height of the current coding block. The pruning and refinement range is (X i -L,Y i -L), the lower right corner is (X i +L,Y i +L), if the block vector j (X j ,Y j )satisfy:
[0677] X i -L≤X j ≤X i +L&&Y i –L≤Y j ≤Y i +L
[0678] This indicates that block vector j is within the pruning range and should be removed from the list. Template matching is then performed within the rectangular area with a step size of S' (S' = S / 2) to obtain the block vector i' with the smallest template error value, which is used as the i-th available block vector. When S' is greater than one pixel, the pruning and refinement process can be repeated until S' equals 1.
[0679] Step 5:
[0680] Determine whether the matching blocks corresponding to the obtained N available block vectors are used for the weighted fusion process. For example, the thresholds threshold1 and threshold2 are set as follows:
[0681] threshold1=(1<<(bitDepth–2)*num_template;
[0682] threshold2 = minSAD << 1;
[0683] Among them, num_template is the number of template pixels, bitDepth is the pixel width, and minSAD is the minimum template error value among N block vectors.
[0684] If the template error value SAD of block vector i i satisfies:
[0685] SAD i ≤threshold1 && SAD i < threshold2;
[0686] Then the matching block i corresponding to block vector i is used for subsequent weighted fusion.
[0687] Step 6:
[0688] Calculate the weight value of each block according to the template error value of the matching block. For example, if n (1 < n <= N) matching blocks are obtained, and the corresponding template error values are SAD1 to SAD n , then the weight value W i of matching block i (1 ≤ i ≤ n) is:
[0689] SAD i =(SAD i == 0)? 1 : SAD i ;
[0690]
[0691] W i =(SUM - SADi) / ((n - 1)*SUM);
[0692] The calculation of W i can be implemented by operations such as table lookup, bit operations, addition, subtraction, multiplication, etc. For example, if the precision of the weight value is 1 / 64, then:
[0693]
[0694] Norm = ((n - 1)*SUM << 4 >> X) & 15;
[0695] V = table[Norm] | 8;
[0696] X = norm == 0? X : X + 1;
[0697] Shift = X + 3;
[0698] Add = 1 << (Shift – 1);
[0699] W i = ((SUM - SADi)*V*64 + Add) >> Shift, 1 ≤ i < n;
[0700]
[0701] Among them, table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0}.
[0702] Specifically, when only 1 matching block is obtained in step 6, no weight calculation is performed.
[0703] Step 7:
[0704] According to the matching blocks and the weight values of each block obtained in step 6, these matching blocks are weighted and fused to obtain the final IntraTMP combined fusion prediction block. For example, n (1 < n <= N) matching blocks are obtained in steps 2 to 6, and the corresponding weight values are W1 to W n , and the final prediction block Pred is:[[]]END]]
[0705]
[0706] Among them, offset = 1 << (shift - 1),
[0707] Specifically, when only 1 matching block Pred1 is obtained in step 6, it is weighted and fused with the prediction block Pred_planar obtained from the planar mode to obtain the final prediction block Pred:
[0708] Pred = (7 * Pred1 + Pred_planar + 4) >> 3.
[0709] Step 8:
[0710] Generate the residual from the final prediction block Pred and the current coding block. The residual is further compressed through steps such as transformation, quantization, and entropy coding and written into the code stream to complete the coding of the current coding block; the residual after transformation and quantization is obtained by inverse quantization and inverse transformation to obtain the reconstructed residual block. Add the reconstructed residual block to the prediction block Pred to obtain the reconstructed block of the current coding block.
[0711] Step 9:
[0712] Indicate whether the current coding block performs combined fusion prediction through the flag bit intra_tmp_fusion_flag written into the code stream. For example, if the current coding block is encoded using the IntraTMP mode, the flag bit intra_tmp_flag is equal to 1. At this time, intra_tmp_fusion_flag is written.
[0713] Step 10:
[0714] The syntax element intra_tmp_fusion_flag is encoded using X context models. The index CtxIdxInc corresponding to different context models is determined based on the coding information of the adjacent coding blocks, the current coding block size, etc. For example, if X is 3 and the current coding block coordinates are (x, y). If there is a coding block cuLeft at coordinates (x-1, y) and cuLeft's intra_tmp_fusion_flag is 1, then CtxIdxInc is 1, otherwise it is 0. Subsequently, if there is a coding block cuAbove at coordinates (x, y-1) and cuAbove's intra_tmp_fusion_flag is 1, then CtxIdxInc is incremented by 1, otherwise it is incremented by 0.
[0715] Step 11:
[0716] According to steps 9 and 10, the flag information such as intra_tmp_flag and intra_tmp_fusion_flag related to the IntraTMP combined fusion prediction is encoded. According to step 8, the residual information under the IntraTMP combined fusion prediction is encoded. The above encoding process determines the number of bits required to complete the encoding of the current coding block under the IntraTMP combined fusion prediction. The rate-distortion cost is calculated based on the degree of distortion between the reconstructed block of the current coding block and the current coding block. The optimal coding mode for the current coding block is selected through rate-distortion optimization (RDO) to complete the encoding of the current coding block.
[0717] It should be understood that the explanation of each flag bit involved in Example 1 and Example 2 can refer to the description of Table 3 to avoid repetition, and will not be repeated here. In addition, Example 1 and Example 2 are only examples of the present application and should not be understood as limiting the present application. For example, in other alternative embodiments, it can be expanded based on Example 1 and Example 2 to obtain an extended solution of Example 1. For example, it includes at least the following alternative solutions:
[0718] Alternative 1:
[0719] The candidate block vector list size can be any other integer value.
[0720] Alternative 2:
[0721] The template error value can be expressed in different calculation methods, such as SATD, MSE, and MAD.
[0722] Alternative 3:
[0723] The number of pruning and refinement times can be other integer values, regardless of the size of the candidate block vector list.
[0724] Alternative 4:
[0725] The pruning range may be other shape areas obtained based on information such as a predefined value, a current coding block size, and a current block vector.
[0726] Alternative 5:
[0727] The pruning process of the candidate block vector list can be skipped.
[0728] Alternative 6:
[0729] The refined region may be a region of other shapes obtained according to information such as a predefined value, a current coding block size, a current block vector, a refinement step size, etc., and is irrelevant to the pruning range.
[0730] Alternative 7:
[0731] The refinement process of the candidate block vector list can be skipped. For example, the i-th block vector in the block vector list is directly used as the available block vector, and the matching block pointed to is used as the matching block of the current coding block.
[0732] Alternative 8:
[0733] The thresholds threshold1 and threshold2 may be other values obtained based on information such as predefined values, current coding block size, pixel width, candidate block vector template error value, and the like.
[0734] Alternative 9:
[0735] You can use only a single threshold to determine whether a matching block is available. For example, the template error value SAD of block vector i i satisfy:
[0736] SAD i ≤threshold
[0737] The matching block i corresponding to the block vector i is then used for subsequent weighted fusion. The threshold may be other values determined based on information such as a predefined value, the current coding block size, the pixel width, and the candidate block vector template error value.
[0738] Alternative 10:
[0739] The weight value of each matching block can be any predefined fixed value, and different weight values are assigned to each matching block based on the number of matching blocks, template error value, etc. For example, the weight values are set to {3 / 4, 1 / 4}, {1 / 2, 1 / 4, 1 / 4}. If there are two matching blocks pred1 and pred2, and the corresponding template error value SAD1≤SAD2, then the weight value of pred1 is set to W1 = 3 / 4, and the weight value of pred2 is set to W2 = 1 / 4. If there are three matching blocks pred1, pred2, and pred3, and the corresponding template error values SAD1≤SAD2≤SAD3, then the weight values of pred1, pred2, and pred3 are set to W1 = 1 / 2, W2 = 1 / 4, and W3 = 1 / 4.
[0740] Alternative 11:
[0741] The weight value W of each matching block may be related to the position of the pixel in the current block.
[0742] Alternative 12:
[0743] When only one matching block is obtained, it can be weightedly fused with the prediction blocks obtained in other intra prediction modes except the planar mode, or no weighted fusion can be performed.
[0744] Alternative 13:
[0745] When the template matching process generates multiple matching blocks, some of these matching blocks can be selected and weightedly fused to obtain the final prediction block. For example, steps 1 to 3 of the embodiment generate three matching blocks, pred1, pred2, and pred3. These combinations include pred1+pred2 (indicating a weighted fusion of pred1 and pred2), pred1+pred3, pred2+pred3, and pred1+pred2+pred3. The specific combination can be determined by encoding the index signal and selecting the combination with the smallest template error value.
[0746] Alternative 14:
[0747] The intra_tmp_fusion_flag flag may not be encoded or decoded. For coding blocks encoded in IntraTMP mode, IntraTMP combined fusion prediction is always used.
[0748] Alternative 15:
[0749] You can add constraints for using IntraTMP combined fusion prediction. Constraints can be derived from information such as the current coding block size, neighboring coding information, sequence-level, frame-level, and macroblock-level flags, slice type, and frame type. Only when the constraints are met will IntraTMP combined fusion prediction be used, and the syntax element intra_tmp_fusion_flag will be encoded. Otherwise, IntraTMP combined fusion prediction will not be used, and the syntax element intra_tmp_fusion_flag does not need to be encoded.
[0750] Alternative 16:
[0751] The remaining number of context modes may be used to encode the syntax element intra_tmp_fusion_flag, and the context model index to be used may be determined based on the current coding block size, adjacent coding information, etc. Alternatively, the syntax element intra_tmp_fusion_flag may be encoded using a bypass coding method.
[0752] Alternative 17:
[0753] A prediction block obtained by a prediction mode other than the IntraTMP mode can be introduced into the weighted fusion process, and the weight value of the prediction block can be determined by a predefined value, the current coding block template, the position of the pixel in the current coding block, adjacent coding information, etc.
[0754] Alternative 18:
[0755] The block vectors in the candidate block vector list can be refined first. Afterwards, the candidate block vector list can be pruned based on block vector spacing, etc. Finally, a certain number of available block vectors are selected from the candidate block vector list to obtain the corresponding matching blocks.
[0756] Alternative 19:
[0757] When only a portion of the template on the left or upper side of the current coding block is available, this portion of the template can be used to perform the template-related operation steps in each embodiment.
[0758] Alternative 20:
[0759] The template is the adjacent reconstructed pixels in L and M rows (columns) on the left and top sides of the current block, where L and M can be any integer values.
[0760] Alternative 21:
[0761] The template may include the reconstructed pixels at the upper right and lower left of the current block. For example, the template may have five conditions as shown in FIG11 .
[0762] Alternative 22:
[0763] The step size s of the search process and the step size s' of the refinement process can be any integer value, where s' is less than s. Multiple rounds of refinement can be performed, with each step size s' being less than the previous step size s. The refined area can be obtained based on the step size.
[0764] Alternative 23:
[0765] The process of obtaining multiple block vectors or matching blocks through template matching can be accomplished using methods other than constructing a list of candidate block vectors. For example, the search area can be divided into different sub-areas, and template matching can be performed within each sub-area to obtain a matching block with the minimum template error. Ultimately, multiple matching blocks can be obtained by matching multiple sub-areas.
[0766] Alternative 24:
[0767] The offset used in weighted fusion of matching blocks can be equal to 0 or other values.
[0768] Alternative 25:
[0769] The intra_tmp_fusion_flag flag may not be encoded or decoded, and the IntraTMP combined fusion prediction or the IntraTMP prediction of a single matching block may be selected based on the prediction performed on the template area of the current coding block and the comparison of the template error values.
[0770] Alternative 26:
[0771] In step 6 and step 19 of the embodiment, the calculation process of Wi may be:
[0772]
[0773] Norm=((n-1)*SUM< <4> >X)&15;
[0774] V = table[Norm]|8;
[0775] X=norm==0? X:X+1;
[0776] Shift=X+3;
[0777] Add=1< <Shift;
[0778] W i =((SUM-SAD i )*V*64+Add)>>Shift, 1≤i <n;
[0779]
[0780] Among them, table[]={0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.
[0781] or:
[0782]
[0783] Norm=((n-1)*SUM< <4> >X)&15;
[0784] V = table[Norm]|8;
[0785] X=norm==0? X:X+1;
[0786] Shift=X+3;
[0787] Add=1<<(Shift–1);
[0788] W i =((SUM-SAD i )*V*64+Add)>>Shift;
[0789] Among them, table[]={0,7,6,5,5,4,4,3,3,2,2,1,1,1,1,0}.
[0790] After that, adjust Wi by following the steps below so that
[0791]
[0792]
[0793]
[0794] Alternative 27:
[0795] Obtaining N available block vectors based on the candidate block vector list can be achieved by the following method:
[0796] The candidate block vector list is refined N times to obtain N available block vectors. Specifically, during the i-th refinement, the i-th block vector BVi in the list is taken, where BVi is equal to (Xi, Yi), and the refinement distance L = (S / 2)*H is determined, where S is the template matching step size and H is the height of the current coding block. The refinement range is a rectangular area with an upper left corner of (Xi-L, Yi-L) and a lower right corner of (Xi+L, Yi+L). Template matching is performed within this rectangular area with a step size S' (S' = S / 2), and the block vector i' with the smallest template error value is obtained as the i-th available block vector. Each time a block vector with a smaller error value (less than the minimum value of the current refinement process) is obtained, it is necessary to determine whether it is equal to the already obtained available block vector. If an equal block vector exists, the currently matched block vector is discarded (i.e., the block vector is skipped and the refined minimum value is not updated). For example, if the block vectors BV1 to BVi-1 are obtained in the first i-1 refinement processes, during the i-th refinement, if the template error value corresponding to a block vector BVi is less than the minimum value (the minimum value of this refinement process), it is necessary to determine whether BVi is equal to BV1 to BVi-1. If there is an equal BV, BVi is skipped and the template matching process continues at the next position; if they are not equal, BVi is used as the new best block vector and the corresponding template error value is used as the new minimum value.
[0797] Alternative 28: After completing the IntraTMP combined fusion prediction, the block vector corresponding to the best matching block obtained in the prediction process can be saved as the known coding information of the current block and used in the coding process of other blocks. For example, N available matching blocks are obtained for weighted fusion, corresponding to BV1 to BV n (n≥1). Save these BVs (can be saved in order by template error value) for subsequent encoding process. For example, when encoding a coding block in IBC mode, it is necessary to construct a candidate block vector list. The block vectors in the list can come from the block vector information of the adjacent coded block (if any). At this time, if there is an IntraTMP coding block in the adjacent block, BV1 can be used as the block vector of the IntraTMP block and added to the candidate block vector list; or, i (1≤i≤n) block vectors BV1 to BV i Sequentially added to the candidate block vector list. i can be a predefined value or determined according to the remaining size of the candidate block vector list at that time.
[0798] Alternative 29:
[0799] In alternative 28, whether to save multiple block vectors can be selected based on whether the IntraTMP coding block uses the fusion prediction of this solution. For example, if the current coding block uses the IntraTMP mode but does not use the combined fusion prediction of this solution, the block vector obtained by the default IntraTMP prediction mode is saved; if the IntraTMP mode is used and the fusion prediction method of this solution is used, the block vectors corresponding to the x matching blocks used for weighted fusion are saved, where x can be an integer value not greater than the maximum number of matching blocks that can be used for fusion.
[0800] Alternative 30:
[0801] In alternative 28, multiple block vectors can always be saved, regardless of whether the IntraTMP coding block uses the combined fusion prediction of this scheme.
[0802] The method embodiment of the present application is described in detail above. The following describes in detail an apparatus embodiment of the present application in conjunction with Figures 13 to 15.
[0803] FIG13 is a schematic block diagram of a decoder 500 according to an embodiment of the present application.
[0804] As shown in FIG13 , the decoder 500 may include:
[0805] A residual unit 510 is configured to determine a residual block of a current block in a current sequence based on a bitstream;
[0806] A prediction unit 520 is configured to predict at least one matching block of the current block based on an intra-frame template matching prediction IntraTMP mode;
[0807] a determining unit 530, configured to determine a target prediction block for the current block based on the at least one matching block;
[0808] The reconstruction unit 540 is configured to obtain a reconstructed block of the current block based on the residual block of the current block and the target prediction block.
[0809] In some embodiments, the prediction unit 520 is specifically configured to:
[0810] Determine a first identifier based on the code stream;
[0811] If the first flag indicates to use the IntraTMP mode for fusion prediction, the at least one matching block is predicted based on the IntraTMP mode.
[0812] In some embodiments, the prediction unit 520 is specifically configured to:
[0813] Determine a second identifier based on the code stream;
[0814] If the second flag indicates to use the IntraTMP mode for prediction, the first flag is determined based on the bitstream.
[0815] In some embodiments, the prediction unit 520 is specifically configured to:
[0816] Determine the target context index;
[0817] Based on the code stream, the first identifier is determined using the target context index.
[0818] In some embodiments, the prediction unit 520 is specifically configured to:
[0819] Determine the target context index based on decoding information of adjacent decoding blocks of the current block: and / or
[0820] The target context index is determined based on the size of the current block.
[0821] In some embodiments, the coordinates of the current block are (x, y), the adjacent decoded blocks include a first decoded block with coordinates (x-1, y) and a second decoded block with coordinates (x, y-1); the decoding information of the first decoded block includes a prediction mode used by a prediction block of the first decoded block, and the decoding information of the second decoded block includes a prediction mode used by a prediction block of the second decoded block;
[0822] The prediction unit 520 is specifically configured to:
[0823] If the prediction mode used by the prediction block of the first decoding block is a mode of fusion prediction based on the IntraTMP mode, the first value is assigned to A; otherwise, the first value is assigned to B; A and B are both integers;
[0824] If the prediction mode used by the prediction block of the second decoding block is a prediction mode for fusion prediction based on the IntraTMP mode, the second value is assigned to C; otherwise, the second value is assigned to D; C and D are both integers;
[0825] The sum of the first value and the second value is determined as the target context index.
[0826] In some embodiments, the prediction unit 520 is specifically configured to:
[0827] Perform template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks;
[0828] The at least one matching block is determined based on the X candidate matching blocks.
[0829] In some embodiments, the prediction unit 520 is specifically configured to:
[0830] Based on the IntraTMP mode, intra-frame template matching is performed within the search area of the current block to obtain all candidate matching blocks of the current block;
[0831] The matching blocks arranged in the first X positions in the order of template error values from small to large are determined as the X candidate matching blocks.
[0832] In some embodiments, the prediction unit 520 is specifically configured to:
[0833] Based on the IntraTMP mode, a candidate matching block list is constructed; the candidate matching block list is used to store X matching blocks with the smallest template error values when performing intra-frame template matching within the search area of the current block.
[0834] In some embodiments, the prediction unit 520 is specifically configured to:
[0835] Divide the search area of the current block into Y sub-areas;
[0836] Based on the IntraTMP mode, intra-frame template matching is performed in each of the Y sub-regions to obtain a candidate matching block in each sub-region;
[0837] The X candidate matching blocks include candidate matching blocks in each sub-region.
[0838] In some embodiments, X=Y, or X is a multiple of Y.
[0839] In some embodiments, the prediction unit 520 is specifically configured to:
[0840] Based on the X candidate matching blocks, determine N available matching blocks; X ≥ N;
[0841] The at least one matching block is determined based on the N available matching blocks.
[0842] In some embodiments, X is a multiple of N.
[0843] In some embodiments, the prediction unit 520 is specifically configured to:
[0844] Based on the intervals between the X candidate matching blocks, the X candidate matching blocks are pruned to obtain the N available matching blocks.
[0845] In some embodiments, the prediction unit 520 is specifically configured to:
[0846] Determine a current candidate matching block for pruning from the X candidate matching blocks in ascending order of template error values;
[0847] Determine the pruning range of the current candidate matching block;
[0848] Remove candidate matching blocks other than the current candidate matching block within the pruning range to obtain candidate matching blocks remaining after pruning based on the current candidate matching block, until the number of prunings of the X candidate matching blocks reaches N, then determine the first N candidate matching blocks of the remaining candidate matching blocks as the N available matching blocks, or until the number of candidate matching blocks remaining after pruning based on the current candidate matching block is less than or equal to N, then determine the first N candidate matching blocks among the candidate matching blocks remaining after the last pruning as the N available matching blocks.
[0849] In some embodiments, the prediction unit 520 is specifically configured to:
[0850] The pruning range is determined based on the size of the current block and the current candidate matching block.
[0851] In some embodiments, the prediction unit 520 is specifically configured to:
[0852] Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / E)*H is determined as the pruning range;
[0853] Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and E is a positive integer.
[0854] In some embodiments, the prediction unit 520 is specifically configured to:
[0855] The trimming range is determined based on predefined values.
[0856] In some embodiments, the prediction unit 520 is specifically configured to:
[0857] The X candidate matching blocks are refined to obtain the N available matching blocks.
[0858] In some embodiments, the prediction unit 520 is specifically configured to:
[0859] Determining a refinement range of a current candidate matching block among the X candidate matching blocks;
[0860] Based on at least one matching step length, performing intra-frame template matching within the refined range to obtain a matching block within the refined range; each matching step length in the at least one matching step length is smaller than a matching step length used by the X candidate matching blocks;
[0861] Determine the matching block with the smallest template loss value among the matching blocks matched within the refining range as the candidate matching block obtained by refining the current candidate matching block;
[0862] A candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks.
[0863] In some embodiments, the prediction unit 520 is specifically configured to:
[0864] The refinement range is determined based on the size of the current block and the current candidate matching block.
[0865] In some embodiments, the prediction unit 520 is specifically configured to:
[0866] Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / F)*H is determined as the refinement range;
[0867] Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and F is a positive integer.
[0868] In some embodiments, the prediction unit 520 is specifically configured to:
[0869] The refining range is determined based on predefined values.
[0870] In some embodiments, the prediction unit 520 is specifically configured to:
[0871] If the current candidate matching block is the i-th matching block among the X candidate matching blocks, and the j-th matching block matched within the refining range is the matching block with the smallest template loss value among the first j matching blocks within the refining range, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block.
[0872] In some embodiments, the prediction unit 520 is specifically configured to:
[0873] The X candidate matching blocks are pruned and refined to obtain the N available matching blocks.
[0874] In some embodiments, the prediction unit 520 is specifically configured to:
[0875] After pruning the X candidate matching blocks, refining the pruned candidate matching blocks; or
[0876] After refining the X candidate matching blocks, pruning the refined candidate matching blocks; or
[0877] After pruning the X candidate matching blocks based on the current candidate matching block among the X candidate matching blocks, the current candidate matching block is refined.
[0878] In some embodiments, the prediction unit 520 is specifically configured to:
[0879] Determine the fusion conditions used by the N available matching blocks;
[0880] An available matching block that meets the fusion condition among the N available matching blocks is determined as the at least one matching block.
[0881] In some embodiments, the prediction unit 520 is specifically configured to:
[0882] The fusion condition is determined based on at least one of the following:
[0883] The size of the template of the current block, the bit width of the pixels of the current block in the current block, and the minimum template error value of the N available matching blocks.
[0884] In some embodiments, the fusion condition includes a first threshold, which is a threshold determined based on the size of the template of the current block and the bit width;
[0885] The prediction unit 520 is specifically configured to:
[0886] An available matching block having a template error value less than or equal to the first threshold among the N available matching blocks is determined as the at least one matching block.
[0887] In some embodiments, the first threshold is determined according to the following formula:
[0888] T1=n1<<(b depth –n2)*n template ;
[0889] Among them, << is the left shift operator, - is the subtraction operator, * is the multiplication operator, T1 represents the first threshold, b depth Indicates the bit width, n template Represents the number of pixels in the template of the current block; n1 and n2 are both positive integers.
[0890] In some embodiments, the fusion condition includes a second threshold value, and the second threshold value is a threshold value determined based on the minimum template error value;
[0891] The prediction unit 520 is specifically configured to:
[0892] An available matching block having a template error value less than or equal to a second threshold among the N available matching blocks is determined as the at least one matching block.
[0893] In some embodiments, the second threshold is determined according to the following formula:
[0894] T2=min SAD < <n3;
[0895] Among them, << is the left shift operator, T2 represents the second threshold, min SAD Indicates the minimum template error value, n3 is a positive integer.
[0896] In some embodiments, the prediction unit 520 is specifically configured to:
[0897] Determining indication information based on the code stream; the indication information is used to indicate the at least one matching block among the N available matching blocks;
[0898] Based on the indication information, the at least one matching block is determined.
[0899] In some embodiments, the determining unit 530 is specifically configured to:
[0900] If the at least one matching block is a plurality of matching blocks, weighted processing is performed on the plurality of matching blocks to obtain a target prediction block of the current block.
[0901] In some embodiments, the determining unit 530 is specifically configured to:
[0902] Determining a weight value of each matching block in the plurality of matching blocks;
[0903] Based on the weight values of the respective matching blocks, weighted processing is performed on the multiple matching blocks to obtain the target prediction block.
[0904] In some embodiments, the determining unit 530 is specifically configured to:
[0905] The weight value of each matching block is determined based on the template error value of each matching block, the number of the multiple matching blocks, and the sum of the weights of the multiple matching blocks.
[0906] In some embodiments, the determining unit 530 is specifically configured to:
[0907] Determining a third value corresponding to each matching block based on the template loss value of each matching block;
[0908] Summing the third values corresponding to the respective matching blocks to obtain a fourth value;
[0909] The weight values of the matching blocks are determined based on the fourth value and the template error values of the matching blocks.
[0910] In some embodiments, the determining unit 530 is specifically configured to:
[0911] If the template error value of the i-th matching block among the multiple matching blocks is 0, a preset value greater than 0 is determined as the third value corresponding to the i-th matching block;
[0912] If the template error value of the i-th matching block is 0, the template error value of the i-th matching block is determined as the third value corresponding to the i-th matching block.
[0913] In some embodiments, the determining unit 530 is specifically configured to:
[0914] The weight value of the i-th matching block among the multiple matching blocks is determined in the following manner:
[0915] Subtracting the third value corresponding to the i-th matching block from the fourth value to obtain a fifth value;
[0916] Multiplying the fourth value by n-1 to obtain a sixth value, wherein n represents the number of the plurality of matching blocks;
[0917] Based on the fifth value and the sixth value, a weight value of the i-th matching block is determined.
[0918] In some embodiments, the determining unit 530 is specifically configured to:
[0919] If the i-th matching block is not the last matching block among the multiple matching blocks, determining the ratio of the fifth value to the sixth value as the weight value of the i-th matching block;
[0920] If the i-th matching block is the last matching block, the weight value of the last matching block is obtained by subtracting the weight values of the first n-1 matching blocks in the multiple matching blocks from the preset total weight value.
[0921] In some embodiments, the determining unit 530 is specifically configured to:
[0922] Determine the ratio of the fifth value to the sixth value as the weight value of the i-th matching block;
[0923] The sum of the weight values of the multiple matching blocks is equal to a preset total weight value.
[0924] In some embodiments, the ratio of the fifth value to the sixth value is a value obtained by bitwise operation, addition operation, and subtraction operation.
[0925] In some embodiments, the ratio of the fifth value to the sixth value is a value determined by the following formula:
[0926] W i =(D5*V*W sum +D Add )>>D Shift ;
[0927] Among them, * is the multiplication operator, + is the addition operator, >> is the right shift operator, D5 represents the fifth value, W sum Represents the total weight value, V is the value determined by looking up the table according to the seventh value, D Shift The right shift amount is calculated based on the seventh value, and the seventh value is a value determined based on the sixth value. Add Based on D Shift Determined value.
[0928] In some embodiments, V and D Shift Determined as follows:
[0929]
[0930] D7=((n-1)*D4< <4> >X)&15;
[0931] V = table[D7]|8;
[0932] X=D7==0? X:X+1;
[0933] D Shift =X+3;
[0934] in, is the upward value operator, * is the multiplication operator, << is the left shift operator, >> is the right shift operator, & is the logical AND operator, | is the logical OR operator, ? is the conditional operator, + is the addition operator, D6 represents the sixth value, D4 represents the fourth value, table[] represents the query table, and D7 represents the seventh value.
[0935] In some embodiments, D Add =1<<(D Shift –1), or D Add =1< <D Shift ; Among them, << is the left shift operator and – is the subtraction operator.
[0936] In some embodiments, the determining unit 530 is specifically configured to:
[0937] Based on the number of the plurality of matching blocks, selecting a first candidate set from the plurality of candidate sets, the first candidate set including a weight value equal to the number of the plurality of matches;
[0938] Each candidate set in the plurality of candidate sets includes at least one candidate weight value;
[0939] Based on the first candidate set, weight values of the respective matching blocks are determined.
[0940] In some embodiments, the template error value of each matching block is negatively correlated with the weight value of each matching block.
[0941] In some embodiments, the determining unit 530 is specifically configured to:
[0942] Multiplying the weight values of the respective matching blocks by the respective matching blocks and summing the results to obtain an eighth value;
[0943] Using this eighth value plus C offset , and obtain the ninth value;
[0944] Shift the ninth value right by C Shift , get the target prediction block;
[0945] Among them, C offset According to C Shift The determined value, C Shift is a value determined according to the sum of the weight values of the multiple matching blocks.
[0946] In some embodiments, C offset =<<(C Shift -1), in, is the upward value operator, << is the left shift operator, W sum Represents the sum of the weight values of the multiple matching blocks.
[0947] In some embodiments, the determining unit 530 is specifically configured to:
[0948] Divide the current block into multiple regions;
[0949] For a first area among the multiple areas, determining a weight value of each matching block among the multiple matching blocks in the first area;
[0950] Based on the weight values of the respective matching blocks in the first region, weighted processing is performed on the plurality of matching blocks in the first region to obtain a prediction value of the target prediction block in the first region;
[0951] The target prediction block includes prediction values of each of the multiple regions.
[0952] In some embodiments, the determining unit 530 is specifically configured to:
[0953] The current block is divided into multiple regions in a horizontal direction or a vertical direction.
[0954] In some embodiments, the determining unit 530 is specifically configured to:
[0955] If the at least one matching block is a single matching block, predicting the current block using a first intra prediction mode to obtain a first prediction block;
[0956] The single matching block and the first prediction block are weighted to obtain the target prediction block.
[0957] In some embodiments, the weight value of the single matching block and the weight value of the first prediction block are both predefined weight values.
[0958] In some embodiments, the determining unit 530 is further configured to:
[0959] The weight value of the single matching block and the weight value of the first prediction block are determined based on at least one of the following:
[0960] Decoding information of adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of various regions of the current block.
[0961] In some embodiments, the determining unit 530 is specifically configured to:
[0962] If the at least one matching block is a plurality of matching blocks, predicting the current block using a second intra prediction mode to obtain a second prediction block;
[0963] The multiple matching blocks and the second prediction block are weighted to obtain the target prediction block.
[0964] In some embodiments, the weight value of the second prediction block is a predefined weight value.
[0965] In some embodiments, the determining unit 530 is further configured to:
[0966] Determine a weight value of the second prediction block based on at least one of the following:
[0967] Decoding information of adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the second intra prediction mode, the total weight value of the multiple matching blocks, and the positions of various regions of the current block.
[0968] In some embodiments, the template of the current block includes at least one of the following: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels.
[0969] In some embodiments, the prediction unit 520 is specifically configured to:
[0970] Determine the restrictions for using the IntraTMP mode;
[0971] When the restriction condition is satisfied, the at least one matching block is predicted based on the IntraTMP mode.
[0972] In some embodiments, the restriction condition is obtained by at least one of the following: the size of the current block, the decoding information of the adjacent decoded blocks, the sequence level flag, the frame level flag, the macroblock level flag, the type of the slice in which the current block is located, and the frame type of the image frame in which the current block is located.
[0973] FIG14 is a schematic block diagram of an encoder 600 according to an embodiment of the present application.
[0974] As shown in FIG14 , the encoder 600 may include:
[0975] A prediction unit 610 is configured to predict at least one matching block of a current block in a current sequence based on an intra-frame template matching prediction IntraTMP mode;
[0976] a determining unit 620, configured to determine a target prediction block for the current block based on the at least one matching block;
[0977] A residual unit 630 is configured to obtain a residual block of the current block based on the target prediction block and the original block of the current block;
[0978] The encoding unit 640 is configured to encode the residual block of the current block.
[0979] In some embodiments, the encoding unit 640 is further configured to:
[0980] encoding the first identifier;
[0981] The first identifier indicates that the IntraTMP mode is used for fusion prediction.
[0982] In some embodiments, the encoding unit 640 is further configured to:
[0983] encoding the second identifier;
[0984] The second flag indicates that the IntraTMP mode is used for prediction.
[0985] In some embodiments, the encoding unit 640 is specifically configured to:
[0986] Determine the target context index;
[0987] The first identifier is encoded using the target context index.
[0988] In some embodiments, the encoding unit 640 is specifically configured to:
[0989] Determine the target context index based on the coding information of the adjacent coding blocks of the current block: and / or
[0990] The target context index is determined based on the size of the current block.
[0991] In some embodiments, the coordinates of the current block are (x, y), the adjacent coding blocks include a first coding block with coordinates (x-1, y) and a second coding block with coordinates (x, y-1); the encoding information of the first coding block includes a prediction mode used by a prediction block of the first coding block, and the encoding information of the second coding block includes a prediction mode used by a prediction block of the second coding block;
[0992] The encoding unit 640 is specifically configured to:
[0993] If the prediction mode used by the prediction block of the first coding block is a mode of fusion prediction based on the IntraTMP mode, the first value is assigned to A; otherwise, the first value is assigned to B; A and B are both integers;
[0994] If the prediction mode used by the prediction block of the second coding block is a prediction mode for fusion prediction based on the IntraTMP mode, the second value is assigned to C; otherwise, the second value is assigned to D; C and D are both integers;
[0995] The sum of the first value and the second value is determined as the target context index.
[0996] In some embodiments, the prediction unit 610 is specifically configured to:
[0997] Perform template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks;
[0998] The at least one matching block is determined based on the X candidate matching blocks.
[0999] In some embodiments, the prediction unit 610 is specifically configured to:
[1000] Based on the IntraTMP mode, intra-frame template matching is performed within the search area of the current block to obtain all candidate matching blocks of the current block;
[1001] The matching blocks arranged in the first X positions in the order of template error values from small to large are determined as the X candidate matching blocks.
[1002] In some embodiments, the prediction unit 610 is specifically configured to:
[1003] Based on the IntraTMP mode, a candidate matching block list is constructed; the candidate matching block list is used to store X matching blocks with the smallest template error values when performing intra-frame template matching within the search area of the current block.
[1004] In some embodiments, the prediction unit 610 is specifically configured to:
[1005] Divide the search area of the current block into Y sub-areas;
[1006] Based on the IntraTMP mode, intra-frame template matching is performed in each of the Y sub-regions to obtain a candidate matching block in each sub-region;
[1007] The X candidate matching blocks include candidate matching blocks in each sub-region.
[1008] In some embodiments, X=Y, or X is a multiple of Y.
[1009] In some embodiments, the prediction unit 610 is specifically configured to:
[1010] Based on the X candidate matching blocks, determine N available matching blocks; X ≥ N;
[1011] The at least one matching block is determined based on the N available matching blocks.
[1012] In some embodiments, X is a multiple of N.
[1013] In some embodiments, the prediction unit 610 is specifically configured to:
[1014] Based on the intervals between the X candidate matching blocks, the X candidate matching blocks are pruned to obtain the N available matching blocks.
[1015] In some embodiments, the prediction unit 610 is specifically configured to:
[1016] Determine a current candidate matching block for pruning from the X candidate matching blocks in ascending order of template error values;
[1017] Determine the pruning range of the current candidate matching block;
[1018] Remove candidate matching blocks other than the current candidate matching block within the pruning range to obtain candidate matching blocks remaining after pruning based on the current candidate matching block, until the number of prunings of the X candidate matching blocks reaches N, then determine the first N candidate matching blocks of the remaining candidate matching blocks as the N available matching blocks, or until the number of candidate matching blocks remaining after pruning based on the current candidate matching block is less than or equal to N, then determine the first N candidate matching blocks among the candidate matching blocks remaining after the last pruning as the N available matching blocks.
[1019] In some embodiments, the prediction unit 610 is specifically configured to:
[1020] The pruning range is determined based on the size of the current block and the current candidate matching block.
[1021] In some embodiments, the prediction unit 610 is specifically configured to:
[1022] Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / E)*H is determined as the pruning range;
[1023] Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and E is a positive integer.
[1024] In some embodiments, the prediction unit 610 is specifically configured to:
[1025] The trimming range is determined based on predefined values.
[1026] In some embodiments, the prediction unit 610 is specifically configured to:
[1027] The X candidate matching blocks are refined to obtain the N available matching blocks.
[1028] In some embodiments, the prediction unit 610 is specifically configured to:
[1029] Determining a refinement range of a current candidate matching block among the X candidate matching blocks;
[1030] Based on at least one matching step length, performing intra-frame template matching within the refined range to obtain a matching block within the refined range; each matching step length in the at least one matching step length is smaller than a matching step length used by the X candidate matching blocks;
[1031] Determine the matching block with the smallest template loss value among the matching blocks matched within the refining range as the candidate matching block obtained by refining the current candidate matching block;
[1032] A candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks.
[1033] In some embodiments, the prediction unit 610 is specifically configured to:
[1034] The refinement range is determined based on the size of the current block and the current candidate matching block.
[1035] In some embodiments, the prediction unit 610 is specifically configured to:
[1036] Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / F)*H is determined as the refinement range;
[1037] Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step size adopted by the X candidate matching blocks, H represents the height of the current block, and F is a positive integer.
[1038] In some embodiments, the prediction unit 610 is specifically configured to:
[1039] The refining range is determined based on predefined values.
[1040] In some embodiments, the prediction unit 610 is specifically configured to:
[1041] If the current candidate matching block is the i-th matching block among the X candidate matching blocks, and the j-th matching block matched within the refining range is the matching block with the smallest template loss value among the first j matching blocks within the refining range, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block.
[1042] In some embodiments, the prediction unit 610 is specifically configured to:
[1043] The X candidate matching blocks are pruned and refined to obtain the N available matching blocks.
[1044] In some embodiments, the prediction unit 610 is specifically configured to:
[1045] After pruning the X candidate matching blocks, refining the pruned candidate matching blocks; or
[1046] After refining the X candidate matching blocks, pruning the refined candidate matching blocks; or
[1047] After pruning the X candidate matching blocks based on the current candidate matching block among the X candidate matching blocks, the current candidate matching block is refined.
[1048] In some embodiments, the prediction unit 610 is specifically configured to:
[1049] Determine the fusion conditions used by the N available matching blocks;
[1050] An available matching block that meets the fusion condition among the N available matching blocks is determined as the at least one matching block.
[1051] In some embodiments, the prediction unit 610 is specifically configured to:
[1052] The fusion condition is determined based on at least one of the following:
[1053] The size of the template of the current block, the bit width of the pixels of the current block in the current block, and the minimum template error value of the N available matching blocks.
[1054] In some embodiments, the fusion condition includes a first threshold, which is a threshold determined based on the size of the template of the current block and the bit width;
[1055] The prediction unit 610 is specifically configured to:
[1056] An available matching block having a template error value less than or equal to the first threshold among the N available matching blocks is determined as the at least one matching block.
[1057] In some embodiments, the first threshold is determined according to the following formula:
[1058] T1=n1<<(b depth –n2)*n template ;
[1059] Among them, << is the left shift operator, - is the subtraction operator, * is the multiplication operator, T1 represents the first threshold, b depth Indicates the bit width, n template Represents the number of pixels in the template of the current block; n1 and n2 are both positive integers.
[1060] In some embodiments, the fusion condition includes a second threshold value, and the second threshold value is a threshold value determined based on the minimum template error value;
[1061] The prediction unit 610 is specifically configured to:
[1062] An available matching block having a template error value less than or equal to a second threshold among the N available matching blocks is determined as the at least one matching block.
[1063] In some embodiments, the second threshold is determined according to the following formula:
[1064] T2=min SAD < <n3;
[1065] Among them, << is the left shift operator, T2 represents the second threshold, min SAD Indicates the minimum template error value, n3 is a positive integer.
[1066] In some embodiments, the encoding unit 640 is further configured to:
[1067] Determine indication information; the indication information is used to indicate the at least one matching block among the N available matching blocks;
[1068] The indication information is encoded.
[1069] In some embodiments, the determining unit 620 is specifically configured to:
[1070] If the at least one matching block is a plurality of matching blocks, weighted processing is performed on the plurality of matching blocks to obtain a target prediction block of the current block.
[1071] In some embodiments, the determining unit 620 is specifically configured to:
[1072] Determining a weight value of each matching block in the plurality of matching blocks;
[1073] Based on the weight values of the respective matching blocks, weighted processing is performed on the multiple matching blocks to obtain the target prediction block.
[1074] In some embodiments, the determining unit 620 is specifically configured to:
[1075] The weight value of each matching block is determined based on the template error value of each matching block, the number of the multiple matching blocks, and the sum of the weights of the multiple matching blocks.
[1076] In some embodiments, the determining unit 620 is specifically configured to:
[1077] Determining a third value corresponding to each matching block based on the template loss value of each matching block;
[1078] Summing the third values corresponding to the respective matching blocks to obtain a fourth value;
[1079] The weight values of the matching blocks are determined based on the fourth value and the template error values of the matching blocks.
[1080] In some embodiments, the determining unit 620 is specifically configured to:
[1081] If the template error value of the i-th matching block among the multiple matching blocks is 0, a preset value greater than 0 is determined as the third value corresponding to the i-th matching block;
[1082] If the template error value of the i-th matching block is 0, the template error value of the i-th matching block is determined as the third value corresponding to the i-th matching block.
[1083] In some embodiments, the determining unit 620 is specifically configured to:
[1084] The weight value of the i-th matching block among the multiple matching blocks is determined in the following manner:
[1085] Subtracting the third value corresponding to the i-th matching block from the fourth value to obtain a fifth value;
[1086] Multiplying the fourth value by n-1 to obtain a sixth value, wherein n represents the number of the plurality of matching blocks;
[1087] Based on the fifth value and the sixth value, a weight value of the i-th matching block is determined.
[1088] In some embodiments, the determining unit 620 is specifically configured to:
[1089] If the i-th matching block is not the last matching block among the multiple matching blocks, determining the ratio of the fifth value to the sixth value as the weight value of the i-th matching block;
[1090] If the i-th matching block is the last matching block, the weight value of the last matching block is obtained by subtracting the weight values of the first n-1 matching blocks in the multiple matching blocks from the preset total weight value.
[1091] In some embodiments, the determining unit 620 is specifically configured to:
[1092] Determine the ratio of the fifth value to the sixth value as the weight value of the i-th matching block;
[1093] The sum of the weight values of the multiple matching blocks is equal to a preset total weight value.
[1094] In some embodiments, the ratio of the fifth value to the sixth value is a value obtained by bitwise operation, addition operation, and subtraction operation.
[1095] In some embodiments, the ratio of the fifth value to the sixth value is a value determined by the following formula:
[1096] W i =(D5*V*W sum +D Add )>>D Shift ;
[1097] Among them, * is the multiplication operator, + is the addition operator, >> is the right shift operator, D5 represents the fifth value, W sum Represents the total weight value, V is the value determined by looking up the table according to the seventh value, D Shift The right shift amount is calculated based on the seventh value, and the seventh value is a value determined based on the sixth value. Add Based on D Shift Determined value.
[1098] In some embodiments, V and D Shift Determined as follows:
[1099]
[1100] D7=((n-1)*D4< <4> >X)&15;
[1101] V = table[D7]|8;
[1102] X=D7==0? X:X+1;
[1103] D Shift =X+3;
[1104] in, is the upward value operator, * is the multiplication operator, << is the left shift operator, >> is the right shift operator, & is the logical AND operator, | is the logical OR operator, ? is the conditional operator, + is the addition operator, D6 represents the sixth value, D4 represents the fourth value, table[] represents the query table, and D7 represents the seventh value.
[1105] In some embodiments, D Add =1<<(D Shift –1), or D Add =1< <D Shift ; Among them, << is the left shift operator and – is the subtraction operator.
[1106] In some embodiments, the determining unit 620 is specifically configured to:
[1107] Based on the number of the plurality of matching blocks, selecting a first candidate set from the plurality of candidate sets, the first candidate set including a weight value equal to the number of the plurality of matches;
[1108] Each candidate set in the plurality of candidate sets includes at least one candidate weight value;
[1109] Based on the first candidate set, weight values of the respective matching blocks are determined.
[1110] In some embodiments, the template error value of each matching block is negatively correlated with the weight value of each matching block.
[1111] In some embodiments, the determining unit 620 is specifically configured to:
[1112] Multiplying the weight values of the respective matching blocks by the respective matching blocks and summing the results to obtain an eighth value;
[1113] Using this eighth value plus C offset , and obtain the ninth value;
[1114] Shift the ninth value right by C Shift , get the target prediction block;
[1115] Among them, C offset According to CShift The determined value, C Shift is a value determined according to the sum of the weight values of the multiple matching blocks.
[1116] In some embodiments, C offset =<<(C Shift -1), in, is the upward value operator, << is the left shift operator, W sum Represents the sum of the weight values of the multiple matching blocks.
[1117] In some embodiments, the determining unit 620 is specifically configured to:
[1118] Divide the current block into multiple regions;
[1119] For a first area among the multiple areas, determining a weight value of each matching block among the multiple matching blocks in the first area;
[1120] Based on the weight values of the respective matching blocks in the first region, weighted processing is performed on the plurality of matching blocks in the first region to obtain a prediction value of the target prediction block in the first region;
[1121] The target prediction block includes prediction values of each of the multiple regions.
[1122] In some embodiments, the determining unit 620 is specifically configured to:
[1123] The current block is divided into multiple regions in a horizontal direction or a vertical direction.
[1124] In some embodiments, the determining unit 620 is specifically configured to:
[1125] If the at least one matching block is a single matching block, predicting the current block using a first intra prediction mode to obtain a first prediction block;
[1126] The single matching block and the first prediction block are weighted to obtain the target prediction block.
[1127] In some embodiments, the weight value of the single matching block and the weight value of the first prediction block are both predefined weight values.
[1128] In some embodiments, the determining unit 620 is further configured to:
[1129] The weight value of the single matching block and the weight value of the first prediction block are determined based on at least one of the following:
[1130] Coding information of adjacent coding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of various regions of the current block.
[1131] In some embodiments, the determining unit 620 is specifically configured to:
[1132] If the at least one matching block is a plurality of matching blocks, predicting the current block using a second intra prediction mode to obtain a second prediction block;
[1133] The multiple matching blocks and the second prediction block are weighted to obtain the target prediction block.
[1134] In some embodiments, the weight value of the second prediction block is a predefined weight value.
[1135] In some embodiments, the determining unit 620 is further configured to:
[1136] Determine a weight value of the second prediction block based on at least one of the following:
[1137] Coding information of adjacent coding blocks, size of the current block, template size of the current block, type of the second intra prediction mode, total weight values of the multiple matching blocks, and positions of various regions of the current block.
[1138] In some embodiments, the template of the current block includes at least one of the following: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels.
[1139] In some embodiments, the prediction unit 610 may be specifically configured to include:
[1140] Determine the restrictions for using the IntraTMP mode;
[1141] When the restriction condition is satisfied, the at least one matching block is predicted based on the IntraTMP mode.
[1142] In some embodiments, the restriction condition is obtained by at least one of the following: the size of the current block, the coding information of the adjacent coding block, the sequence level flag, the frame level flag, the macroblock level flag, the type of the slice in which the current block is located, and the frame type of the image frame in which the current block is located.
[1143] It should be understood that the device embodiment and the method embodiment can correspond to each other, and similar descriptions can refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, the decoder 500 shown in Figure 13 can correspond to the corresponding subject in the method 300 for executing the embodiment of the present application, and the aforementioned and other operations and / or functions of the various units in the decoder 500 are respectively for implementing the corresponding processes in various methods such as the method 300. Similarly, the encoder 600 shown in Figure 14 can correspond to the corresponding subject in the method 400 for executing the embodiment of the present application, that is, the aforementioned and other operations and / or functions of the various units in the encoder 600 are respectively for implementing the corresponding processes in various methods such as the method 400.
[1144] It should also be understood that the various units in the decoder 500 or encoder 600 involved in the embodiment of the present application can be separately or all merged into one or several other units to constitute, or some (some) units therein can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of a unit can also be realized by multiple units, or the function of multiple units is realized by one unit. In other embodiments of the present application, the decoder 500 or encoder 600 can also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units. According to another embodiment of the present application, the decoder 500 or encoder 600 involved in the embodiment of the present application can be constructed by running a computer program (including program code) that can execute each step involved in the corresponding method on a general-purpose computing device including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), etc., to construct the decoder 500 or encoder 600 involved in the embodiment of the present application, and to implement the encoding method or decoding method of the embodiment of the present application. The computer program can be recorded on, for example, a computer-readable storage medium, loaded into an electronic device via the computer-readable storage medium, and run therein to implement the corresponding method of the embodiment of the present application.
[1145] In other words, the units mentioned above can be implemented in the form of hardware, can be implemented by instructions in the form of software, or can be implemented in the form of a combination of hardware and software. Specifically, the steps of the method embodiments in the embodiments of the present application can be completed by the hardware integrated logic circuit and / or software instructions in the processor, and the steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software in a decoding processor. Optionally, the software can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps in the above method embodiments in combination with its hardware.
[1146] FIG17 is a schematic structural diagram of an electronic device 700 provided in an embodiment of the present application.
[1147] As shown in Figure 17, the electronic device 700 includes at least a processor 710 and a computer-readable storage medium 720. The processor 710 and the computer-readable storage medium 720 may be connected via a bus or other means. The computer-readable storage medium 720 is used to store a computer program 721, which includes computer instructions. The processor 710 is used to execute the computer instructions stored in the computer-readable storage medium 720. The processor 710 is the computing core and control core of the electronic device 700. It is suitable for implementing one or more computer instructions, and is specifically suitable for loading and executing one or more computer instructions to implement the corresponding method flow or corresponding function.
[1148] As an example, the processor 710 may also be referred to as a central processing unit (CPU). The processor 710 may include, but is not limited to, a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, and the like.
[1149] As an example, the computer-readable storage medium 720 may be a high-speed RAM memory, or a non-volatile memory (Non-Volatile Memory), such as at least one disk storage; optionally, it may also be at least one computer-readable storage medium located away from the aforementioned processor 710. Specifically, the computer-readable storage medium 720 includes, but is not limited to: volatile memory and / or non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[1150] In one implementation, the electronic device 700 may be an encoder or encoding framework involved in an embodiment of the present application; a first computer instruction is stored in the computer-readable storage medium 720; the processor 710 loads and executes the first computer instruction stored in the computer-readable storage medium 720 to implement the corresponding steps in the encoding method provided in an embodiment of the present application; in other words, the first computer instruction in the computer-readable storage medium 720 is loaded by the processor 710 and the corresponding steps are executed. To avoid repetition, they are not repeated here.
[1151] In one implementation, the electronic device 700 may be a decoder or decoding framework involved in an embodiment of the present application; a second computer instruction is stored in the computer-readable storage medium 720; the processor 710 loads and executes the second computer instruction stored in the computer-readable storage medium 720 to implement the corresponding steps in the decoding method provided in an embodiment of the present application; in other words, the second computer instruction in the computer-readable storage medium 720 is loaded by the processor 710 and the corresponding steps are executed, which will not be repeated here to avoid repetition.
[1152] According to another aspect of the present application, an embodiment of the present application further provides a coding and decoding system, including the encoder and decoder mentioned above.
[1153] According to another aspect of the present application, an embodiment of the present application further provides a computer-readable storage medium (Memory), which is a memory device in the electronic device 700 for storing programs and data. For example, a computer-readable storage medium 720. It can be understood that the computer-readable storage medium 720 here can include both the built-in storage medium in the electronic device 700 and, of course, the extended storage medium supported by the electronic device 700. The computer-readable storage medium provides a storage space, which stores the operating system of the electronic device 700. In addition, one or more computer instructions suitable for being loaded and executed by the processor 710 are also stored in the storage space. These computer instructions can be one or more computer programs 721 (including program codes).
[1154] According to another aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. For example, computer program 721 is provided. In this case, data processing device 700 may be a computer, processor 710 may read the computer instructions from computer-readable storage medium 720, and processor 710 may execute the computer instructions, causing the computer to perform the encoding method or decoding method provided in the various optional embodiments described above.
[1155] In other words, when implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process of the embodiment of the present application is run in whole or in part or the functions of the embodiment of the present application are implemented. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode.
[1156] Those skilled in the art will appreciate that the units and process steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[1157] Finally, it should be noted that the above content is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A decoding method, characterized in that: include: Determine a residual block of a current block in a current sequence based on a bitstream; Predicting at least one matching block of the current block based on an intra-frame template matching prediction IntraTMP mode; Determining a target prediction block of the current block based on the at least one matching block; A reconstructed block of the current block is obtained based on the residual block of the current block and the target prediction block.
2. The method according to claim 1, characterized in that The predicting of at least one matching block of the current block based on the intra-frame template matching IntraTMP mode includes: Determine a first identifier based on the code stream; If the first flag indicates to use the IntraTMP mode for fusion prediction, predicting the at least one matching block based on the IntraTMP mode.
3. The method according to claim 2, characterized in that The determining the first identifier based on the code stream includes: Determine a second identifier based on the code stream; If the second flag indicates to use the IntraTMP mode for prediction, the first flag is determined based on the bitstream.
4. The method according to claim 2, characterized in that: The determining the first identifier based on the code stream includes: determining a target context index; Based on the code stream, the first identifier is determined using the target context index.
5. The method according to claim 4, characterized in that The determining of the target context index comprises: Determine the target context index based on decoding information of adjacent decoding blocks of the current block: and / or The target context index is determined based on a size of the current block.
6. The method according to claim 5, characterized in that The coordinates of the current block are (x, y), and the adjacent decoding blocks include a first decoding block with coordinates (x-1, y) and a second decoding block with coordinates (x, y-1); the decoding information of the first decoding block includes a prediction mode used by a prediction block of the first decoding block, and the decoding information of the second decoding block includes a prediction mode used by a prediction block of the second decoding block; The step of determining the target context index based on the decoding information of the adjacent decoding blocks of the current block includes: If the prediction mode used by the prediction block of the first decoding block is a mode of fusion prediction based on the IntraTMP mode, the first value is assigned to A; otherwise, the first value is assigned to B; A and B are both integers; If the prediction mode used by the prediction block of the second decoding block is a prediction mode for fusion prediction based on the IntraTMP mode, the second value is assigned to C; otherwise, the second value is assigned to D; both C and D are integers; The sum of the first value and the second value is determined as the target context index.
7. The method according to any one of claims 1 to 6, characterized in that The predicting of at least one matching block of the current block based on the intra-frame template matching IntraTMP mode includes: Performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks; The at least one matching block is determined based on the X candidate matching blocks.
8. The method according to claim 7, characterized in that The performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks includes: Based on the IntraTMP mode, performing intra-frame template matching in the search area of the current block to obtain all candidate matching blocks of the current block; The matching blocks arranged in the first X positions are determined as the X candidate matching blocks in the order of template error values from small to large.
9. The method according to claim 7, characterized in that: The performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks includes: Based on the IntraTMP mode, a candidate matching block list is constructed; the candidate matching block list is used to store X matching blocks with the smallest template error value when performing intra-frame template matching in the search area of the current block.
10. The method according to claim 9, characterized in that The performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks includes: Dividing the search area of the current block into Y sub-areas; Based on the IntraTMP mode, perform intra-frame template matching in each of the Y sub-regions to obtain a candidate matching block in each of the sub-regions; The X candidate matching blocks include candidate matching blocks in each of the sub-areas.
11. The method according to claim 10, characterized in that X=Y, or X is a multiple of Y.
12. The method according to any one of claims 7 to 11, characterized in that The determining the at least one matching block based on the X candidate matching blocks includes: Based on the X candidate matching blocks, determine N available matching blocks; X≥N; The at least one matching block is determined based on the N available matching blocks.
13. The method according to claim 12, characterized in that X is a multiple of N.
14. The method according to claim 12, characterized in that The determining N available matching blocks based on the X candidate matching blocks includes: The X candidate matching blocks are pruned based on the intervals between the X candidate matching blocks to obtain the N available matching blocks.
15. The method according to claim 14, characterized in that The pruning of the X candidate matching blocks based on the spacing between the X candidate matching blocks to obtain the N available matching blocks includes: Determine a current candidate matching block for pruning among the X candidate matching blocks according to the order of template error values from small to large; Determining a pruning range of the current candidate matching block; The candidate matching blocks other than the current candidate matching block within the pruning range are removed to obtain the candidate matching blocks remaining after pruning based on the current candidate matching block, until the number of pruning of the X candidate matching blocks is N, the first N candidate matching blocks of the remaining candidate matching blocks are determined as the N available matching blocks, or until the number of candidate matching blocks remaining after pruning based on the current candidate matching block is less than or equal to N, the first N candidate matching blocks among the candidate matching blocks remaining after the last pruning are determined as the N available matching blocks.
16. The method according to claim 15, characterized in that The determining of the pruning range of the current candidate matching block includes: The pruning range is determined based on the size of the current block and the current candidate matching block.
17. The method according to claim 16, characterized in that The determining the pruning range based on the size of the current block and the current candidate matching block includes: Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / E)*H is determined as the pruning range; Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step length adopted by the X candidate matching blocks, H represents the height of the current block, and E is a positive integer.
18. The method according to claim 15, characterized in that The determining of the pruning range of the current candidate matching block includes: The trimming range is determined based on a predefined value.
19. The method according to claim 12, characterized in that The determining N available matching blocks based on the X candidate matching blocks includes: The X candidate matching blocks are refined to obtain the N available matching blocks.
20. The method according to claim 19, characterized in that The refining the X candidate matching blocks to obtain the N available matching blocks includes: Determining a refinement range of a current candidate matching block among the X candidate matching blocks; Based on at least one matching step length, performing intra-frame template matching within the refined range to obtain a matching block matched within the refined range; each matching step length in the at least one matching step length is smaller than the matching step length adopted by the X candidate matching blocks; Determine a matching block with the smallest template loss value among the matching blocks matched within the refining range as a candidate matching block obtained by refining the current candidate matching block; A candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks.
21. The method according to claim 20, characterized in that The determining a refinement range of a current candidate matching block among the X candidate matching blocks includes: The refinement range is determined based on the size of the current block and the current candidate matching block.
22. The method according to claim 21, characterized in that The determining the refining range based on the size of the current block and the current candidate matching block includes: Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / F)*H is determined as the refining range; Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step length adopted by the X candidate matching blocks, H represents the height of the current block, and F is a positive integer.
23. The method according to claim 20, characterized in that The determining a refinement range of a current candidate matching block among the X candidate matching blocks includes: Based on predefined values, the refining range is determined.
24. The method according to claim 20, characterized in that The step of determining the matching block with the smallest template loss value among the matching blocks matched within the refining range as the candidate matching block obtained by refining the current candidate matching block includes: If the current candidate matching block is the i-th matching block among the X candidate matching blocks, and the j-th matching block matched within the refining range is the matching block with the smallest template loss value among the first j matching blocks within the refining range, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block.
25. The method according to claim 12, characterized in that The determining N available matching blocks based on the X candidate matching blocks includes: The X candidate matching blocks are pruned and refined to obtain the N available matching blocks.
26. The method according to claim 25, characterized in that The pruning and refining of the X candidate matching blocks to obtain the N available matching blocks includes: After pruning the X candidate matching blocks, refining the pruned candidate matching blocks; or After refining the X candidate matching blocks, pruning the refined candidate matching blocks; or After the X candidate matching blocks are pruned once based on the current candidate matching block among the X candidate matching blocks, the current candidate matching block is refined.
27. The method according to any one of claims 12 to 26, characterized in that The determining the at least one matching block based on the N available matching blocks comprises: Determining a fusion condition used by the N available matching blocks; An available matching block that meets the fusion condition among the N available matching blocks is determined as the at least one matching block.
28. The method according to claim 27, characterized in that The determining of the fusion conditions used by the N available matching blocks includes: The fusion condition is determined based on at least one of the following: The size of the template of the current block, the bit width of the pixels of the current block in the current block, and the minimum template error value of the N available matching blocks.
29. The method according to claim 28, characterized in that The fusion condition includes a first threshold value, which is a threshold value determined based on the size of the template of the current block and the bit width; The step of determining the available matching block satisfying the fusion condition among the N available matching blocks as the at least one matching block includes: An available matching block whose template error value is less than or equal to the first threshold among the N available matching blocks is determined as the at least one matching block.
30. The method according to claim 29, characterized in that The first threshold is determined according to the following formula: T1=n1<<(b depth –n2)*n template ; Among them, << is a left shift operator, - is a subtraction operator, * is a multiplication operator, T1 represents the first threshold, b depth Indicates the bit width, n template Represents the number of pixels in the template of the current block; n1 and n2 are both positive integers.
31. The method according to any one of claims 28 to 30, characterized in that The fusion condition includes a second threshold value, and the second threshold value is a threshold value determined based on the minimum template error value; The step of determining the available matching block satisfying the fusion condition among the N available matching blocks as the at least one matching block includes: An available matching block whose template error value is less than or equal to a second threshold among the N available matching blocks is determined as the at least one matching block.
32. The method according to claim 31, characterized in that The second threshold is determined according to the following formula: T2=min SAD < <n3; Among them, << is a left shift operator, T2 represents the second threshold, min SAD represents the minimum template error value, and n3 is a positive integer.
33. The method according to any one of claims 12 to 26, characterized in that The determining the at least one matching block based on the N available matching blocks comprises: Based on the bitstream, determining indication information; the indication information is used to indicate the at least one matching block among the N available matching blocks; Based on the indication information, the at least one matching block is determined.
34. The method according to any one of claims 1 to 33, characterized in that The determining the target prediction block based on the at least one matching block comprises: If the at least one matching block is a plurality of matching blocks, weighted processing is performed on the plurality of matching blocks to obtain a target prediction block of the current block.
35. The method according to claim 34, characterized in that The step of performing weighted processing on the multiple matching blocks to obtain the target prediction block includes: Determining a weight value of each matching block in the plurality of matching blocks; Based on the weight values of the respective matching blocks, weighted processing is performed on the multiple matching blocks to obtain the target prediction block.
36. The method according to claim 35, characterized in that The determining a weight value of each matching block in the plurality of matching blocks includes: The weight values of the respective matching blocks are determined based on the template error values of the respective matching blocks, the number of the plurality of matching blocks, and the sum of the weights of the plurality of matching blocks.
37. The method according to claim 36, characterized in that The determining the weight value of each matching block based on the template error value of each matching block, the number of the plurality of matching blocks, and the sum of the weights of the plurality of matching blocks includes: Determine a third value corresponding to each matching block based on the template loss value of each matching block; Summing the third values corresponding to the respective matching blocks to obtain a fourth value; Based on the fourth value and the template error value of each matching block, a weight value of each matching block is determined.
38. The method according to claim 37, characterized in that The determining, based on the template loss value of each matching block, a third value corresponding to each matching block includes: If the template error value of the i-th matching block among the multiple matching blocks is 0, a preset value greater than 0 is determined as the third value corresponding to the i-th matching block; If the template error value of the i-th matching block is 0, the template error value of the i-th matching block is determined as the third value corresponding to the i-th matching block.
39. The method according to claim 37, characterized in that The determining the weight value of each matching block based on the fourth value and the template error value of each matching block includes: The weight value of the i-th matching block among the multiple matching blocks is determined in the following manner: Subtracting the third value corresponding to the i-th matching block from the fourth value to obtain a fifth value; Multiplying the fourth value by n-1 to obtain a sixth value, wherein n represents the number of the plurality of matching blocks; Based on the fifth value and the sixth value, a weight value of the i-th matching block is determined.
40. The method according to claim 39, characterized in that The determining the weight value of the i-th matching block based on the fifth value and the sixth value includes: If the i-th matching block is not the last matching block among the multiple matching blocks, determining the ratio of the fifth value to the sixth value as the weight value of the i-th matching block; If the i-th matching block is the last matching block, the weight value of the last matching block is obtained by subtracting the weight values of the first n-1 matching blocks among the multiple matching blocks from the preset total weight value.
41. The method according to claim 39, characterized in that The determining the weight value of the i-th matching block based on the fifth value and the sixth value includes: Determine the ratio of the fifth value to the sixth value as the weight value of the i-th matching block; The sum of the weight values of the multiple matching blocks is equal to a preset total weight value.
42. The method according to claim 40 or 41, characterized in that The ratio of the fifth value to the sixth value is a value obtained by bit operation, addition operation and subtraction operation.
43. The method according to claim 42, characterized in that The ratio of the fifth value to the sixth value is a value determined by the following formula: W i =(D5*V*W sum +D Add )>>D Shift ; Wherein, * is a multiplication operator, + is an addition operator, >> is a right shift operator, D5 represents the fifth value, W sum represents the total weight value, V is the value determined by looking up the seventh value table, and D Shift is the right shift amount calculated and determined according to the seventh value, the seventh value is a value determined according to the sixth value, D Add According to D Shift Determined value.
44. The method according to claim 43, characterized in that V and D Shift Determined as follows: D7=((n-1)*D4< <4> >X)&15; V = table[D7]|8; X=D7==0? X:X+1; D Shift =X+3; in, is an upward value operator, * is a multiplication operator, << is a left shift operator, >> is a right shift operator, & is a logical AND operator, | is a logical OR operator, ? is a conditional operator, + is an addition operator, D6 represents the sixth value, D4 represents the fourth value, table[] represents a query table, and D7 represents the seventh value.
45. The method according to claim 43, characterized in that D Add =1<<(D Shift –1), or D Add =1< <D Shift ; Among them, << is the left shift operator and – is the subtraction operator.
46. The method according to claim 35, characterized in that The determining of the weight value of each matching block in the plurality of matching blocks comprises: Based on the number of the plurality of matching blocks, selecting a first candidate set including a weight value equal to the number of the plurality of matches from the plurality of candidate sets; Wherein, each candidate set in the plurality of candidate sets includes at least one candidate weight value; Based on the first candidate set, a weight value of each matching block is determined.
47. The method according to claim 46, characterized in that The template error values of the respective matching blocks are negatively correlated with the weight values of the respective matching blocks.
48. The method according to claim 34, characterized in that The step of performing weighted processing on the plurality of matching blocks based on the weight values of the respective matching blocks to obtain the target prediction block comprises: Multiplying the weight values of the respective matching blocks by the respective matching blocks and summing the results to obtain an eighth value; Using the eighth value plus C offset , and obtain the ninth value; Shift the ninth value right by C Shift , obtain the target prediction block; Among them, C offset According to C Shift The determined value, C Shift is a value determined according to the sum of weight values of the multiple matching blocks.
49. The method according to claim 48, characterized in that C offset =<<(C Shift -1), in, is the upward value operator, << is the left shift operator, W sum represents the sum of the weight values of the multiple matching blocks.
50. The method of claim 34, wherein: The step of performing weighted processing on the multiple matching blocks to obtain a target prediction block of the current block includes: Dividing the current block into a plurality of regions; For a first area among the multiple areas, determining a weight value of each matching block among the multiple matching blocks in the first area; Based on the weight values of the respective matching blocks in the first region, weighted processing is performed on the multiple matching blocks in the first region to obtain a prediction value of the target prediction block in the first region; The target prediction block includes prediction values of each of the multiple regions.
51. The method according to claim 50, characterized in that The dividing the current block into a plurality of regions comprises: The current block is divided into a plurality of regions in a horizontal direction or a vertical direction.
52. The method according to any one of claims 1 to 33, characterized in that The determining the target prediction block based on the at least one matching block comprises: If the at least one matching block is a single matching block, predicting the current block using a first intra prediction mode to obtain a first prediction block; The single matching block and the first prediction block are weighted to obtain the target prediction block.
53. The method according to claim 52, characterized in that The weight value of the single matching block and the weight value of the first prediction block are both predefined weight values.
54. The method according to claim 52, characterized in that The method further comprises: The weight value of the single matching block and the weight value of the first prediction block are determined based on at least one of the following: Decoding information of adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of various regions of the current block.
55. The method according to any one of claims 1 to 33, characterized in that The determining, based on the at least one matching block, a target prediction block of the current block comprises: If the at least one matching block is a plurality of matching blocks, predicting the current block using a second intra-frame prediction mode to obtain a second prediction block; The multiple matching blocks and the second prediction block are weighted to obtain the target prediction block.
56. The method according to claim 55, characterized in that The weight value of the second prediction block is a predefined weight value.
57. The method according to claim 55, characterized in that The method further comprises: Determine a weight value of the second prediction block based on at least one of the following: Decoding information of adjacent decoding blocks, the size of the current block, the template size of the current block, the type of the second intra prediction mode, the total weight value of the multiple matching blocks, and the positions of various areas of the current block.
58. The method according to any one of claims 1 to 57, characterized in that The template of the current block includes at least one of the following: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels.
59. The method according to any one of claims 1 to 58, characterized in that The predicting of at least one matching block of the current block based on the intra-frame template matching IntraTMP mode includes: Determining restrictions on the use of the IntraTMP mode; When the restriction condition is satisfied, the at least one matching block is predicted based on the IntraTMP mode.
60. The method according to claim 59, characterized in that The restriction condition is obtained by at least one of the following: the size of the current block, the decoding information of the adjacent decoded blocks, the sequence level flag, the frame level flag, the macroblock level flag, the type of the slice where the current block is located, and the frame type of the image frame where the current block is located.
61. A coding method, characterized in that include: Predicting the IntraTMP mode based on intra-frame template matching, predicting at least one matching block of the current block in the current sequence; Determining a target prediction block of the current block based on the at least one matching block; Obtaining a residual block of the current block based on the target prediction block and an original block of the current block; The residual block of the current block is encoded.
62. The method according to claim 61, characterized in that The method further comprises: encoding the first identifier; Among them, the first identifier indicates to use the IntraTMP mode for fusion prediction.
63. The method according to claim 62, characterized in that The method further comprises: encoding the second identifier; The second flag indicates that the IntraTMP mode is used for prediction.
64. The method according to claim 62, characterized in that The encoding of the second identifier includes: determining a target context index; The first identifier is encoded using the target context index.
65. The method according to claim 64, characterized in that The determining of the target context index comprises: Determine the target context index based on the coding information of the adjacent coding blocks of the current block: and / or The target context index is determined based on a size of the current block.
66. The method according to claim 65, characterized in that The coordinates of the current block are (x, y), and the adjacent coding blocks include a first coding block with coordinates (x-1, y) and a second coding block with coordinates (x, y-1); the encoding information of the first coding block includes a prediction mode used by a prediction block of the first coding block, and the encoding information of the second coding block includes a prediction mode used by a prediction block of the second coding block; The step of determining the target context index based on the coding information of the adjacent coding blocks of the current block includes: If the prediction mode used by the prediction block of the first coding block is a mode of fusion prediction based on the IntraTMP mode, the first value is assigned to A; otherwise, the first value is assigned to B; A and B are both integers; If the prediction mode used by the prediction block of the second coding block is a prediction mode for fusion prediction based on the IntraTMP mode, the second value is assigned to C; otherwise, the second value is assigned to D; both C and D are integers; The sum of the first value and the second value is determined as the target context index.
67. The method according to any one of claims 61 to 66, characterized in that The predicting IntraTMP mode based on intra-frame template matching, predicting at least one matching block of the current block in the current sequence, comprises: Performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks; The at least one matching block is determined based on the X candidate matching blocks.
68. The method according to claim 67, characterized in that The performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks includes: Based on the IntraTMP mode, performing intra-frame template matching in the search area of the current block to obtain all candidate matching blocks of the current block; The matching blocks arranged in the first X positions are determined as the X candidate matching blocks in the order of template error values from small to large.
69. The method according to claim 67, characterized in that The performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks includes: Based on the IntraTMP mode, a candidate matching block list is constructed; the candidate matching block list is used to store X matching blocks with the smallest template error value when performing intra-frame template matching in the search area of the current block.
70. The method according to claim 69, characterized in that The performing template matching on the current block based on the IntraTMP mode to obtain X candidate matching blocks includes: Dividing the search area of the current block into Y sub-areas; Based on the IntraTMP mode, perform intra-frame template matching in each of the Y sub-regions to obtain a candidate matching block in each of the sub-regions; The X candidate matching blocks include candidate matching blocks in each of the sub-areas.
71. The method according to claim 70, characterized in that X=Y, or X is a multiple of Y.
72. The method according to any one of claims 67 to 71, characterized in that The determining the at least one matching block based on the X candidate matching blocks includes: Based on the X candidate matching blocks, determine N available matching blocks; X≥N; The at least one matching block is determined based on the N available matching blocks.
73. The method according to claim 72, characterized in that X is a multiple of N.
74. The method according to claim 72, characterized in that The determining N available matching blocks based on the X candidate matching blocks includes: The X candidate matching blocks are pruned based on the intervals between the X candidate matching blocks to obtain the N available matching blocks.
75. The method according to claim 74, characterized in that The pruning of the X candidate matching blocks based on the spacing between the X candidate matching blocks to obtain the N available matching blocks includes: Determine a current candidate matching block for pruning among the X candidate matching blocks according to the order of template error values from small to large; Determining a pruning range of the current candidate matching block; The candidate matching blocks other than the current candidate matching block within the pruning range are removed to obtain the candidate matching blocks remaining after pruning based on the current candidate matching block, until the number of pruning of the X candidate matching blocks is N, the first N candidate matching blocks of the remaining candidate matching blocks are determined as the N available matching blocks, or until the number of candidate matching blocks remaining after pruning based on the current candidate matching block is less than or equal to N, the first N candidate matching blocks among the candidate matching blocks remaining after the last pruning are determined as the N available matching blocks.
76. The method according to claim 75, characterized in that The determining of the pruning range of the current candidate matching block includes: The pruning range is determined based on the size of the current block and the current candidate matching block.
77. The method according to claim 76, characterized in that The determining the pruning range based on the size of the current block and the current candidate matching block includes: Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / E)*H is determined as the pruning range; Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step length adopted by the X candidate matching blocks, H represents the height of the current block, and E is a positive integer.
78. The method according to claim 75, characterized in that The determining of the pruning range of the current candidate matching block includes: The trimming range is determined based on a predefined value.
79. The method according to claim 72, characterized in that The determining N available matching blocks based on the X candidate matching blocks includes: The X candidate matching blocks are refined to obtain the N available matching blocks.
80. The method according to claim 79, characterized in that The refining the X candidate matching blocks to obtain the N available matching blocks includes: Determining a refinement range of a current candidate matching block among the X candidate matching blocks; Based on at least one matching step length, performing intra-frame template matching within the refined range to obtain a matching block matched within the refined range; each matching step length in the at least one matching step length is smaller than the matching step length adopted by the X candidate matching blocks; Determine a matching block with the smallest template loss value among the matching blocks matched within the refining range as a candidate matching block obtained by refining the current candidate matching block; A candidate matching block obtained by refining the current candidate matching block is determined as an available matching block among the N available matching blocks.
81. The method according to claim 80, characterized in that The determining a refinement range of a current candidate matching block among the X candidate matching blocks includes: The refinement range is determined based on the size of the current block and the current candidate matching block.
82. The method according to claim 81, characterized in that The determining the refining range based on the size of the current block and the current candidate matching block includes: Taking the block vector of the current block pointing to the current candidate matching block as the center, (S / F)*H is determined as the refining range; Wherein, / represents a division operator, * represents a multiplication operator, S represents the matching step length adopted by the X candidate matching blocks, H represents the height of the current block, and F is a positive integer.
83. The method according to claim 80, characterized in that The determining a refinement range of a current candidate matching block among the X candidate matching blocks includes: Based on predefined values, the refining range is determined.
84. The method according to claim 80, characterized in that The step of determining the matching block with the smallest template loss value among the matching blocks matched within the refining range as the candidate matching block obtained by refining the current candidate matching block includes: If the current candidate matching block is the i-th matching block among the X candidate matching blocks, and the j-th matching block matched within the refining range is the matching block with the smallest template loss value among the first j matching blocks within the refining range, then when the candidate matching blocks obtained by refining the first i-1 candidate matching blocks among the X candidate matching blocks do not include the j-th matching block, the j-th matching block is determined as the candidate matching block obtained by refining the current candidate matching block.
85. The method of claim 72, wherein: The determining N available matching blocks based on the X candidate matching blocks includes: The X candidate matching blocks are pruned and refined to obtain the N available matching blocks.
86. The method according to claim 85, characterized in that The pruning and refining of the X candidate matching blocks to obtain the N available matching blocks includes: After pruning the X candidate matching blocks, refining the pruned candidate matching blocks; or After refining the X candidate matching blocks, pruning the refined candidate matching blocks; or After the X candidate matching blocks are pruned once based on the current candidate matching block among the X candidate matching blocks, the current candidate matching block is refined.
87. The method according to any one of claims 72 to 86, characterized in that The determining the at least one matching block based on the N available matching blocks comprises: Determining a fusion condition used by the N available matching blocks; An available matching block that meets the fusion condition among the N available matching blocks is determined as the at least one matching block.
88. The method according to claim 87, characterized in that The determining of the fusion conditions used by the N available matching blocks includes: The fusion condition is determined based on at least one of the following: The size of the template of the current block, the bit width of the pixels of the current block in the current block, and the minimum template error value of the N available matching blocks.
89. The method according to claim 88, characterized in that The fusion condition includes a first threshold value, which is a threshold value determined based on the size of the template of the current block and the bit width; The step of determining the available matching block satisfying the fusion condition among the N available matching blocks as the at least one matching block includes: An available matching block whose template error value is less than or equal to the first threshold among the N available matching blocks is determined as the at least one matching block.
90. The method according to claim 89, characterized in that The first threshold is determined according to the following formula: T1=n1<<(b depth –n2)*n template ; Among them, << is a left shift operator, - is a subtraction operator, * is a multiplication operator, T1 represents the first threshold, b depth Indicates the bit width, n template Represents the number of pixels in the template of the current block; n1 and n2 are both positive integers.
91. The method according to any one of claims 88 to 90, characterized in that The fusion condition includes a second threshold value, and the second threshold value is a threshold value determined based on the minimum template error value; The step of determining the available matching block satisfying the fusion condition among the N available matching blocks as the at least one matching block includes: An available matching block whose template error value is less than or equal to a second threshold among the N available matching blocks is determined as the at least one matching block.
92. The method according to claim 91, characterized in that The second threshold is determined according to the following formula: T2=min SAD < <n3; Among them, << is a left shift operator, T2 represents the second threshold, min SAD represents the minimum template error value, and n3 is a positive integer.
93. The method according to any one of claims 72 to 86, characterized in that The method further comprises: Determine indication information; the indication information is used to indicate the at least one matching block among the N available matching blocks; The indication information is encoded.
94. The method according to any one of claims 61 to 93, characterized in that The determining the target prediction block based on the at least one matching block comprises: If the at least one matching block is a plurality of matching blocks, weighted processing is performed on the plurality of matching blocks to obtain a target prediction block of the current block.
95. The method according to claim 94, characterized in that The step of performing weighted processing on the multiple matching blocks to obtain the target prediction block includes: Determining a weight value of each matching block in the plurality of matching blocks; Based on the weight values of the respective matching blocks, weighted processing is performed on the multiple matching blocks to obtain the target prediction block.
96. The method according to claim 95, characterized in that The determining a weight value of each matching block in the plurality of matching blocks includes: The weight values of the respective matching blocks are determined based on the template error values of the respective matching blocks, the number of the plurality of matching blocks, and the sum of the weights of the plurality of matching blocks.
97. The method according to claim 96, characterized in that The determining the weight value of each matching block based on the template error value of each matching block, the number of the plurality of matching blocks, and the sum of the weights of the plurality of matching blocks includes: Determine a third value corresponding to each matching block based on the template loss value of each matching block; Summing the third values corresponding to the respective matching blocks to obtain a fourth value; Based on the fourth value and the template error value of each matching block, a weight value of each matching block is determined.
98. The method according to claim 97, characterized in that The determining, based on the template loss value of each matching block, a third value corresponding to each matching block includes: If the template error value of the i-th matching block among the multiple matching blocks is 0, a preset value greater than 0 is determined as the third value corresponding to the i-th matching block; If the template error value of the i-th matching block is 0, the template error value of the i-th matching block is determined as the third value corresponding to the i-th matching block.
99. The method according to claim 97, characterized in that The determining the weight value of each matching block based on the fourth value and the template error value of each matching block includes: The weight value of the i-th matching block among the multiple matching blocks is determined in the following manner: Subtracting the third value corresponding to the i-th matching block from the fourth value to obtain a fifth value; Multiplying the fourth value by n-1 to obtain a sixth value, wherein n represents the number of the plurality of matching blocks; Based on the fifth value and the sixth value, a weight value of the i-th matching block is determined.
100. The method according to claim 99, characterized in that The determining the weight value of the i-th matching block based on the fifth value and the sixth value includes: If the i-th matching block is not the last matching block among the multiple matching blocks, determining the ratio of the fifth value to the sixth value as the weight value of the i-th matching block; If the i-th matching block is the last matching block, the weight value of the last matching block is obtained by subtracting the weight values of the first n-1 matching blocks among the multiple matching blocks from the preset total weight value.
101. The method according to claim 99, characterized in that The determining the weight value of the i-th matching block based on the fifth value and the sixth value includes: Determine the ratio of the fifth value to the sixth value as the weight value of the i-th matching block; The sum of the weight values of the multiple matching blocks is equal to a preset total weight value.
102. The method according to claim 100 or 101, characterized in that The ratio of the fifth value to the sixth value is a value obtained by bit operation, addition operation and subtraction operation.
103. The method according to claim 102, characterized in that The ratio of the fifth value to the sixth value is a value determined by the following formula: W i =(D5*V*W sum +D Add )>>D Shift ; Wherein, * is a multiplication operator, + is an addition operator, >> is a right shift operator, D5 represents the fifth value, W sum represents the total weight value, V is the value determined by looking up the seventh value table, and D Shift is the right shift amount calculated and determined according to the seventh value, the seventh value is a value determined according to the sixth value, D Add According to D Shift Determined value.
104. The method according to claim 103, characterized in that V and D Shift Determined as follows: D7=((n-1)*D4< <4> >X)&15; V = table[D7]|8; X=D7==0? X:X+1; D Shift =X+3; in, is an upward value operator, * is a multiplication operator, << is a left shift operator, >> is a right shift operator, & is a logical AND operator, | is a logical OR operator, ? is a conditional operator, + is an addition operator, D6 represents the sixth value, D4 represents the fourth value, table[] represents a query table, and D7 represents the seventh value.
105. The method according to claim 103, characterized in that D Add =1<<(D Shift –1), or D Add =1< <D Shift ; Among them, << is the left shift operator and – is the subtraction operator.
106. The method according to claim 95, characterized in that The determining a weight value of each matching block in the plurality of matching blocks includes: Based on the number of the plurality of matching blocks, selecting a first candidate set including a weight value equal to the number of the plurality of matches from the plurality of candidate sets; Wherein, each candidate set in the plurality of candidate sets includes at least one candidate weight value; Based on the first candidate set, a weight value of each matching block is determined.
107. The method according to claim 106, characterized in that The template error values of the respective matching blocks are negatively correlated with the weight values of the respective matching blocks.
108. The method according to claim 94, characterized in that The step of performing weighted processing on the plurality of matching blocks based on the weight values of the respective matching blocks to obtain the target prediction block comprises: Multiplying the weight values of the respective matching blocks by the respective matching blocks and summing the results to obtain an eighth value; Using the eighth value plus C offset , and obtain the ninth value; Shift the ninth value right by C Shift , obtain the target prediction block; Among them, C offset According to C Shift The determined value, C Shift is a value determined according to the sum of weight values of the multiple matching blocks.
109. The method according to claim 108, characterized in that C offset =<<(C Shift -1), in, is the upward value operator, << is the left shift operator, W sum represents the sum of the weight values of the multiple matching blocks.
110. The method according to claim 94, characterized in that The step of performing weighted processing on the multiple matching blocks to obtain a target prediction block of the current block includes: Dividing the current block into a plurality of regions; For a first area among the multiple areas, determining a weight value of each matching block among the multiple matching blocks in the first area; Based on the weight values of the respective matching blocks in the first region, weighted processing is performed on the multiple matching blocks in the first region to obtain a prediction value of the target prediction block in the first region; The target prediction block includes prediction values of each of the multiple regions.
111. The method according to claim 110, characterized in that The dividing the current block into a plurality of regions comprises: The current block is divided into a plurality of regions in a horizontal direction or a vertical direction.
112. The method according to any one of claims 61 to 93, characterized in that The determining the target prediction block based on the at least one matching block comprises: If the at least one matching block is a single matching block, predicting the current block using a first intra prediction mode to obtain a first prediction block; The single matching block and the first prediction block are weighted to obtain the target prediction block.
113. The method according to claim 112, characterized in that The weight value of the single matching block and the weight value of the first prediction block are both predefined weight values.
114. The method according to claim 112, characterized in that The method further comprises: The weight value of the single matching block and the weight value of the first prediction block are determined based on at least one of the following: The encoding information of the adjacent encoding blocks, the size of the current block, the template size of the current block, the type of the first intra-frame prediction mode, and the positions of various regions of the current block.
115. The method according to any one of claims 61 to 93, characterized in that The determining, based on the at least one matching block, a target prediction block of the current block comprises: If the at least one matching block is a plurality of matching blocks, predicting the current block using a second intra-frame prediction mode to obtain a second prediction block; The multiple matching blocks and the second prediction block are weighted to obtain the target prediction block.
116. The method according to claim 115, characterized in that The weight value of the second prediction block is a predefined weight value.
117. The method according to claim 115, characterized in that The method further comprises: Determine a weight value of the second prediction block based on at least one of the following: The encoding information of the adjacent encoding blocks, the size of the current block, the template size of the current block, the type of the second intra prediction mode, the total weight value of the multiple matching blocks, and the positions of each area of the current block.
118. The method according to any one of claims 61 to 117, characterized in that The template of the current block includes at least one of the following: left reconstructed pixels, lower left reconstructed pixels, upper left reconstructed pixels, upper reconstructed pixels, and upper right reconstructed pixels.
119. The method according to any one of claims 61 to 118, characterized in that The predicting IntraTMP mode based on intra-frame template matching, predicting at least one matching block of the current block in the current sequence, comprises: Determining restrictions on the use of the IntraTMP mode; When the restriction condition is satisfied, the at least one matching block is predicted based on the IntraTMP mode.
120. The method according to claim 119, characterized in that The restriction condition is obtained by at least one of the following: the size of the current block, the coding information of the adjacent coding block, the sequence level flag, the frame level flag, the macroblock level flag, the type of the slice where the current block is located, and the frame type of the image frame where the current block is located.
121. A decoder, characterized in that include: A residual unit, configured to determine a residual block of a current block in a current sequence based on a bitstream; A prediction unit, configured to predict at least one matching block of the current block based on an intra-frame template matching prediction IntraTMP mode; a determining unit, configured to determine a target prediction block of the current block based on the at least one matching block; The reconstruction unit is used to obtain a reconstructed block of the current block based on the residual block of the current block and the target prediction block.
122. An encoder, characterized in that include: A prediction unit, configured to predict at least one matching block of a current block in a current sequence based on an intra-frame template matching prediction IntraTMP mode; a determining unit, configured to determine a target prediction block of the current block based on the at least one matching block; A residual unit, configured to obtain a residual block of the current block based on the target prediction block and an original block of the current block; The encoding unit is used to encode the residual block of the current block.
123. An electronic device, characterized in that: include: a processor adapted to execute a computer program; A computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by the processor, implements the method according to any one of claims 1 to 60 or the method according to any one of claims 61 to 120.
124. A computer-readable storage medium, characterized in that Used to store a computer program, the computer program causing a computer to execute the method according to any one of claims 1 to 60 or the method according to any one of claims 61 to 120.
125. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method of any one of claims 1 to 60 or the method of any one of claims 61 to 120 is implemented.
126. A code stream, characterized in that The code stream is a code stream in the method according to any one of claims 1 to 60 or a code stream generated by the method according to any one of claims 61 to 120.