A video encoding method, a video decoding method, a device, a medium and a product

CN123035299APending Publication Date: 2026-11-03MALANSHAN AUDIO & VIDEO LABORATORY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611353267.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-02
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Existing video coding technologies struggle to effectively control coding overhead and complexity when processing image patches containing multi-directional textures or spanning edges, resulting in limited prediction accuracy and coding efficiency and quality that fail to meet practical requirements.

Method used

Multiple templates from a shared dictionary are used to assign prediction weights to each pixel position within a block. By adaptively fusing different predictors, the optimal prediction block is generated. The activation of the mode field is controlled in explicit or implicit coding mode to reduce syntax overhead.

Benefits of technology

While controlling coding overhead and complexity, it improves coding efficiency and prediction accuracy, ensures image reconstruction quality, and avoids edge blurring and block artifacts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123035299A_ABST
    Figure CN123035299A_ABST
Patent Text Reader

Abstract

The application discloses a video coding and decoding method, device, medium and product in the computer technology field. In the application, a shared dictionary is shared by an encoding end and a decoding end, and a plurality of templates are preset in the shared dictionary. Each template directly specifies a prediction weight for each pixel position in a block. The prediction weight can make different pixel positions adopt different prediction fuser fusion ratios, can solve an edge blur problem, and can take into account prediction accuracy. In addition, when a fusion scheme of a first prediction fuser and a second prediction fuser has a rate-distortion cost lower than a fusion scheme of only using the first prediction fuser, and the fusion scheme has the lowest distortion cost, the encoding end confirms an enabling mode field, and in an explicit coding mode, only a small amount of index information and necessary residual data need to be transmitted in an encoded code stream. It can be seen that the scheme can control syntax overhead and coding complexity, and can also improve intra-frame prediction accuracy and reconstructed image quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a video encoding and decoding method, device, medium, and product. Background Technology

[0002] In video coding, common intra-frame block prediction modes struggle to effectively describe image blocks containing multi-directional textures or spanning edges, resulting in limited prediction accuracy. To improve prediction quality, different prediction methods can be used for different regions within a block, or multiple predictors can be fused. However, the resulting weight map introduces unacceptable coding overhead, reducing coding efficiency. Simply averaging two predictors to generate a fused prediction can easily lead to blurring at block edges, failing to meet the practical requirements for both coding efficiency and quality.

[0003] Therefore, how to achieve adaptive fusion of different predictors at different positions within a block, while controlling coding overhead and coding complexity, and improve coding efficiency and quality, is a problem that needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a video encoding and video decoding method, device, medium and product, so as to achieve adaptive fusion of different predictors at different positions within a block and improve encoding efficiency and quality while controlling encoding overhead and encoding complexity.

[0005] Firstly, this application provides a video encoding method applied at the encoding end, including: Determine the first predictor and N second predictors for the current block to be encoded in the target video frame; Based on a preset shared dictionary, the prediction weights corresponding to each pixel in the current block are determined. The shared dictionary is shared by the encoder and decoder and includes: M templates corresponding to different textures, each template setting a prediction weight for each pixel in the current block; the prediction weight represents the ratio of the first predictor to any second predictor used at the corresponding position. Based on the prediction weights, generate M×N candidate prediction blocks for the current block; Among the M×N candidate prediction blocks and the first prediction block generated by the first predictor for the current block, the optimal prediction block with the minimum determination rate distortion cost; If the optimal prediction block is any candidate prediction block, then the mode field is enabled, and in the explicit coding mode, the predictor index of the target second predictor and the template index of the target template corresponding to the optimal prediction block are determined; the mode field enable flag, predictor index, template index, and residual data between the current block and the optimal prediction block are determined as the coding data of the current block.

[0006] Optionally, it also includes: If the best prediction block is the first prediction block, then enable the mode field; The mode field disable flag and residual data are used as the encoding data for the current block.

[0007] Optionally, it also includes: In implicit encoding mode, N is set to 1, and the template index is determined; The pattern field enable flag, template index, and residual data are used as the encoding data for the current block.

[0008] Optionally, the M templates include at least two of the following forms: zero-fusion form, diagonal division form, diagonal gradient form, horizontal division form, vertical division form, and center-periphery division form.

[0009] Optionally, among the M×N candidate prediction blocks and the first prediction block generated by the first predictor for the current block, the optimal prediction block with the minimum determination rate-distortion cost includes: Calculate the first rate distortion cost of the first prediction block and the second rate distortion cost of each candidate prediction block; Compare the minimum value in the second rate distortion cost with the first rate distortion cost; If the minimum value is less than the first rate distortion cost, then the optimal prediction block is the candidate prediction block corresponding to the minimum value; If the minimum value is not less than the first rate distortion cost, then the optimal prediction block is the first prediction block.

[0010] Optionally, before determining the first predictor and N second predictors for the current block to be encoded in the target video frame, the method further includes: Determine whether the current block meets the preset conditions. The preset conditions include at least one of the following: the current component is a luminance component, the width and height of the current block are not less than a preset threshold, the aspect ratio of the current block does not exceed a preset ratio, and the reference sample of the current block is available. If the preset conditions are met, the steps of determining the first predictor and N second predictors of the current block to be encoded in the target video frame, as well as other subsequent steps, are executed. If the preset conditions are not met, the target intra-frame prediction mode will be used to encode the current block.

[0011] Secondly, this application provides a video decoding method applied at the decoding end, including: Obtain the encoded data of the current block to be decoded in the target video frame; If the encoded data includes a mode field enable flag, then the first predictor for the current block is determined; The target second predictor is determined based on the predictor index in the encoded data; Based on the template index in the encoded data, the target template is determined from the preset shared dictionary. The shared dictionary is shared by the encoder and decoder and includes M templates. Each template sets a prediction weight for each pixel in the current block. The prediction weight represents the ratio of the first predictor to any second predictor used at the corresponding position. Determine the prediction weights for each pixel in the current block based on the target template; Based on the prediction weights, the first predictor, and the target second predictor, generate the target prediction block for the current block; The current block is reconstructed based on the target prediction block and the residual data in the encoded data.

[0012] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor for executing the computer program to implement the aforementioned disclosed method.

[0013] Fourthly, this application provides a non-volatile storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned disclosed method.

[0014] Fifthly, this application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the aforementioned disclosed method.

[0015] As can be seen in this application, the shared dictionary is shared by both the encoder and decoder, and it contains multiple pre-defined templates. Each template directly specifies the prediction weights for each pixel position within a block. The encoder only needs to transmit a template index to represent the complete weight field within the block, eliminating the need to transmit weight information pixel by pixel, thereby reducing syntax overhead. Simultaneously, the prediction weights set the ratio of the first predictor to any second predictor at the corresponding position, allowing different predictor fusion ratios to be used at different pixel positions. This solves the edge blurring problem and maintains prediction accuracy while controlling syntax overhead. Furthermore, this application compares the rate-distortion cost of the fusion scheme of the first predictor and the second predictor as well as the scheme using only the first predictor. For example, when the rate-distortion cost of all fusion schemes is not lower than the rate-distortion cost of using only the first predictor, the encoder can turn off the mode field and omit the relevant syntax, thereby ensuring that the coding performance will not degrade due to the activation of the mode field. When there is a fusion scheme among all fusion schemes with a rate-distortion cost lower than the fusion scheme using only the first predictor, and the distortion cost of the fusion scheme is the lowest, the encoder confirms the mode field is enabled, and in the explicit coding mode, determines the predictor index of the target second predictor and the template index of the target template corresponding to the optimal prediction block. The mode field enable flag, predictor index, template index, and residual data between the current block and the optimal prediction block are determined as the coding data of the current block, so that only a small amount of index information and necessary residual data need to be transmitted in the coding bitstream. This can further control the syntax overhead and coding complexity, and can also effectively improve the intra-frame prediction accuracy and reconstructed image quality.

[0016] Accordingly, the video encoding device, medium and program product, and the video decoding device, medium and program product provided in this application also have the above-mentioned technical effects. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0018] Figure 1 This is a flowchart of a video coding method disclosed in this application; Figure 2 This is a flowchart of a video decoding method disclosed in this application; Figure 3 This is a schematic diagram of a video encoding and decoding process disclosed in this application; Figure 4 This is a schematic diagram of an electronic device disclosed in this application; Figure 5A server architecture diagram provided in this application; Figure 6 A terminal structure diagram provided for this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0020] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0021] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0022] See Figure 1 As shown in the figure, this application discloses a video encoding method applied at the encoding end, including: S101. Determine the first predictor and N second predictors for the current block to be encoded in the target video frame.

[0023] The first predictor is generated from the main intra-prediction mode of the current block. This main intra-prediction mode is the optimal mode selected by the encoder during the regular intra-prediction decision-making stage, after traversing the planar mode, DC mode, and multiple angular direction modes, based on rate-distortion cost. The second predictor comes from one or more of the following: modes in the Most Probable Mode (MPM) list, intra-prediction modes used by spatially adjacent blocks, directional modes adjacent to the angle number of the main intra-prediction mode, planar mode, and DC mode. By collecting candidate modes from the above sources, removing duplicates, sorting them by fixed priority, and truncating them, N second predictors can be obtained.

[0024] S102. Based on a preset shared dictionary, determine the prediction weights corresponding to each pixel in the current block. The shared dictionary is shared by the encoder and decoder and includes: M templates corresponding to different textures, each template having a prediction weight for each pixel in the current block. The prediction weight represents the ratio of the first predictor to any second predictor used at the corresponding position.

[0025] In other words, for the same template, different weight values ​​may be assigned to pixels at different positions within the current block, thus forming a spatial weight distribution pattern within the block. The encoding and decoding ends each store the same dictionary independently. Each template in the dictionary has a unique index number. The encoding end only needs to write the index number into the bitstream, and the decoding end can find the corresponding template based on the index number and recover the complete weight pattern.

[0026] S103. Generate M×N candidate prediction blocks for the current block based on the prediction weights.

[0027] Specifically, for each of the N second predictors and each of the M templates, a candidate prediction block is generated for this combination based on the prediction value of the second predictor and the prediction weight specified by the template, resulting in a total of M×N candidate prediction blocks.

[0028] When generating candidate prediction blocks, for each pixel within the current block, the fusion method is determined based on the weight value specified by the template at that pixel's position. If the prediction weight of the pixel indicates the use of the first predictor, then the value of that pixel in the candidate prediction block is the prediction value of the first predictor; if the prediction weight of the pixel indicates the use of the second predictor, then the value of that pixel in the candidate prediction block is the prediction value of the target second predictor; if the prediction weight of the pixel indicates proportional fusion, then the value of that pixel in the candidate prediction block is a weighted combination of the prediction value of the first predictor and the prediction value of the target second predictor. The weighted combination can be calculated as follows: Let the weight specified by the template at the current pixel position be w, the fixed-point precision be S (e.g., S=64), the prediction value of the first predictor at that position be P1, and the prediction value of the second predictor at that position be P2, then the fused prediction value is: (w×P1 + (Sw)×P2 + (S>>1)) >> log2(S), where ">>" indicates a right shift operation. This calculation method uses all fixed-point integer arithmetic, avoiding the problem of inconsistent rounding errors at both ends of the encoding and decoding that may be caused by floating-point arithmetic.

[0029] S104. Among the M×N candidate prediction blocks and the first prediction block generated by the first predictor for the current block, the optimal prediction block with the minimum determination rate distortion cost.

[0030] Specifically, the first rate-distortion cost of the first prediction block and the second rate-distortion cost of each candidate prediction block are first calculated. The rate-distortion cost can be calculated as J = D + λ × R, where D represents distortion, which can be measured by methods such as absolute difference sum, transform domain absolute difference sum, or square difference sum; R represents the code rate, including estimates of residual coding bits and syntax bits; λ is a Lagrange multiplier used to convert distortion and code rate to the same dimension for comparison. Then, the minimum value among the second rate-distortion costs is compared with the first rate-distortion cost. If the minimum value is less than the first rate-distortion cost, the optimal prediction block is the candidate prediction block corresponding to the minimum value; if the minimum value is not less than the first rate-distortion cost, the optimal prediction block is the first prediction block. Therefore, in one implementation, determining the optimal prediction block with the minimum rate-distortion cost among M×N candidate prediction blocks and the first prediction block generated by the first predictor for the current block includes: calculating the first rate-distortion cost of the first prediction block and the second rate-distortion cost of each candidate prediction block; comparing the minimum value of the second rate-distortion cost with the first rate-distortion cost; if the minimum value is less than the first rate-distortion cost, the optimal prediction block is the candidate prediction block corresponding to the minimum value; if the minimum value is not less than the first rate-distortion cost, the optimal prediction block is the first prediction block.

[0031] S105. If the optimal prediction block is any candidate prediction block, then the enabled mode field is confirmed, and in the explicit coding mode, the predictor index of the target second predictor and the template index of the target template corresponding to the optimal prediction block are determined; the mode field enable flag, predictor index, template index, and residual data between the current block and the optimal prediction block are determined as the coding data of the current block.

[0032] In explicit coding mode, the encoder explicitly transmits the predictor index through the bitstream to inform the decoder of the position of the target second predictor in the candidate list. Conversely, in implicit coding mode, the encoder does not transmit the predictor index; the target second predictor is determined by both the encoder and decoder according to the same agreed-upon rules, such as agreeing that the target second predictor is always a candidate from the most probable pattern list. Accordingly, in implicit coding mode, N is 1, meaning there is only one second predictor. In this case, the encoder does not need to choose from multiple second predictor candidates; it only needs to determine the optimal template from M templates and determine the template index. Accordingly, the encoder uses the pattern field enable flag, the template index, and the residual data between the current block and the fused prediction block as the encoded data for the current block, without including the predictor index.

[0033] It should be noted that when the prediction performance using only the first predictor is not inferior to any fusion scheme, the mode field tool is not enabled at the encoding end, thereby avoiding the additional syntax overhead caused by transmitting the predictor index and template index. Therefore, in one implementation, if the optimal prediction block is the first prediction block, the mode field is disabled; the mode field disable flag and residual data are determined as the encoded data of the current block.

[0034] In one implementation, the M templates include at least two of the following forms: zero-fusion form, diagonal partitioning form, diagonal gradient form, horizontal partitioning form, vertical partitioning form, and center-periphery partitioning form. Specifically, the zero-fusion form indicates that the prediction weights of all pixels in the entire block indicate the use of the first predictor; the diagonal partitioning form divides the current block into two regions along the diagonal direction, with different regions indicating the use of different predictors; the diagonal gradient form continuously changes the prediction weights along the diagonal normal direction, from indicating the use of the first predictor to indicating the use of the second predictor; the horizontal partitioning form divides the current block into an upper and lower half along the horizontal direction, with different regions indicating the use of different predictors; the vertical partitioning form divides the current block into a left and right half along the vertical direction, with different regions indicating the use of different predictors; and the center-periphery partitioning form indicates that the center and peripheral regions of the current block each indicate the use of different predictors.

[0035] Before determining the first predictor and N second predictors for the current block to be encoded in the target video frame, the process includes determining the admission criteria. Specifically, it determines whether the current block meets preset conditions, which include at least one of the following: the current component is a luma component, meaning this method is only enabled for the luma component and not for the chroma component; the width and height of the current block are not less than preset thresholds to avoid increasing unnecessary coding complexity due to insufficient gains on excessively small blocks; the aspect ratio of the current block does not exceed a preset ratio to exclude excessively long and narrow blocks; and the reference samples for the current block are available, meaning that the reference pixels in the top row and left column of the current block exist and have been reconstructed; otherwise, intra-frame prediction cannot be performed normally. If the current block meets the above preset conditions, the steps of determining the first predictor and N second predictors, as well as other subsequent steps, are executed. If the current block does not meet the above preset conditions, the current block is encoded using the conventional intra-frame prediction mode. Therefore, in one embodiment, before determining the first predictor and N second predictors of the current block to be encoded in the target video frame, the method further includes: determining whether the current block meets preset conditions, the preset conditions including at least one of the following: the current component is a luminance component, the width and height of the current block are not less than a preset threshold, the aspect ratio of the current block does not exceed a preset ratio, and the reference sample of the current block is available; if the preset conditions are met, the step of determining the first predictor and N second predictors of the current block to be encoded in the target video frame and subsequent other steps are executed; if the preset conditions are not met, the current block is encoded using the target frame intra-prediction mode.

[0036] As can be seen in this application, since the shared dictionary pre-constructs multiple templates, each template directly specifies the prediction weights for each position within a block. The encoder only needs to transmit a short index to represent the complete intra-block weight field, thus avoiding the syntax overhead caused by transmitting weight information pixel by pixel. Simultaneously, the dictionary templates support both hard selection (i.e., two-way selection) and soft fusion (i.e., proportional mixing). Hard selection templates allow different predictors to be used in different regions to maintain edge clarity, while soft fusion templates allow predicted values ​​to transition smoothly along the edges to reduce block artifacts, thus balancing prediction accuracy while controlling syntax overhead. Furthermore, the encoder performs joint rate-distortion selection on the second predictor and templates, avoiding the excessive complexity caused by independent searches. When the rate-distortion cost of all fusion schemes is not lower than that of using only the first predictor, the encoder can disable the mode field and omit related syntax, ensuring that encoding performance is not degraded by enabling this application. Therefore, this method effectively improves intra-frame prediction accuracy and reconstructed image quality while controlling syntax overhead and encoding complexity.

[0037] The following describes a video decoding method provided by an embodiment of this application. The video decoding method described below can be referred to in conjunction with other embodiments described herein.

[0038] See Figure 2 As shown in the figure, this application discloses a video decoding method, applied at the decoding end, including: S201. Obtain the encoded data of the current block to be decoded in the target video frame.

[0039] S202. If the encoded data includes a mode field enable flag, then determine the first predictor for the current block.

[0040] S203. Determine the target second predictor based on the predictor index in the encoded data.

[0041] S204. Determine the target template from the preset shared dictionary based on the template index in the encoded data. The shared dictionary is shared by the encoding end and the decoding end and includes M templates. Each template sets a prediction weight for each pixel in the current block. The prediction weight represents the ratio of the first predictor to any second predictor used at the corresponding position.

[0042] S205. Determine the prediction weights corresponding to each pixel in the current block based on the target template.

[0043] S206. Based on the prediction weights, the first predictor, and the target second predictor, generate the target prediction block (i.e., the aforementioned optimal prediction block) for the current block.

[0044] S207. Reconstruct the current block based on the target prediction block and the residual data in the encoded data.

[0045] S208. If the encoded data includes a mode field disable flag, then the current block is decoded using the regular intra-frame prediction mode.

[0046] If the encoded data does not contain a predictor index, the target second predictor is determined according to the implicit rules agreed upon by both the encoder and decoder.

[0047] For detailed implementation of each step in this embodiment, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.

[0048] As can be seen, this embodiment provides a video decoding method that can recover the intra-block weight field through a shared template index, eliminating the need to receive pixel-by-pixel weights and reducing syntax overhead. The decoder performs hard selection or soft fusion based on the template type to restore the encoding end's prediction intent, ensuring sharp edges or smooth transitions. Implicit modes eliminate the need for predictor index transmission, further saving transmission bits. Disabling the mode field reverts to conventional decoding, maintaining compatibility.

[0049] Please see Figure 3 The related processes for encoding and decoding can include: Step S1: Determine whether pattern field prediction is allowed.

[0050] Based on information such as block size, component type (e.g., luma or chroma), reference sample availability, and whether it's sequence-level or image-level, the system determines whether the current block allows the use of the mode field tool. If the current block does not meet the preset conditions, basic intra-frame prediction is used, and the process does not proceed to the next step; if the current block meets the preset conditions, the process proceeds to the next step. The reference samples refer to the reconstructed neighboring pixels in the row above and column to the left of the current block; these pixels are the basic data source for intra-frame prediction. If the current block is located at the image boundary, causing the row above or column to be missing, the reference samples are unavailable.

[0051] Step S2: Generate the first prediction block P1 using the first predictor.

[0052] Perform a basic intra-frame mode search on the current block, or use the already obtained optimal master mode m1 to generate the first prediction block P1. P1 usually corresponds to the main direction or main prediction characteristic of the current block and is the basic predictor in subsequent fusion. The master mode m1 is the optimal mode selected by the encoder during the regular intra-frame prediction decision stage, after traversing the planar mode, DC mode and multiple angular direction modes, based on the rate-distortion cost.

[0053] Step S3: Establish a second predictor candidate and generate candidate prediction block P2.

[0054] A second predictor candidate list is constructed from the MPM list, neighboring block patterns, directional patterns adjacent to m1, TIMD results, IntraTMP results, or a fixed set of low-complexity patterns (e.g., planar and DC patterns). A corresponding prediction block P2 is generated for each candidate pattern. To control coding complexity, the source range of P2 can be limited, or previously generated prediction results can be reused to avoid redundant computation.

[0055] Step S4: Obtain the available pattern field dictionary template.

[0056] The template Dj that is allowed to be tested in the current block is retrieved from the shared dictionary. Each template specifies a corresponding weight value wj(x,y) for each position within the current block. This weight value represents the selection or fusion ratio of the first predictor and the second predictor at the corresponding position. Specifically, the encoder can first select a subset from all dictionary templates based on the edge direction of the current block, the block aspect ratio, and the relationship between the first predictor and the second predictor, thereby avoiding traversing the entire dictionary and reducing encoding complexity.

[0057] Step S5: Generate hard selection or soft fusion predictions by combining the predictor and template.

[0058] For each allowed (P1, P2, Dj) combination, a corresponding prediction block is generated according to the weights specified in the template. Hard switching refers to the pixel at the corresponding position directly selecting P1 or P2 when the weight value takes only the two endpoints, without any mixing operation. Integer soft fusion refers to the pixel at the corresponding position weighting the first and second predictors according to the weight value when the weight value takes the middle integer value. The fusion process uses fixed shift, rounding, and truncation rules to ensure pixel-by-pixel consistency between the encoding and decoding ends.

[0059] Specifically, for each pixel position within the current block, if the weight w at that position is equal to S, then the fused prediction value is equal to the prediction value of P1 at that position; if w is equal to 0, then the fused prediction value is equal to the prediction value of P2 at that position; if w takes an integer value between 0 and S, then the fused prediction value can be calculated as follows: Phat = (w × P1 + (Sw) × P2 + (S>>1))>> log2(S), where S is the fixed-point precision, and >> indicates a right shift operation.

[0060] In this design, the hard template uses only weights of 0 and S, with the corresponding pixel being directly selected as P1 or P2. The soft template uses integer weights between 0 and S, allowing for smooth transitions in the predicted values ​​near edges. Templates can include various forms such as horizontal division, vertical division, diagonal division, center-periphery division, edge bands, and phase patterns. The second predictor can be implicitly derived, thus eliminating the need to transmit the second predictor index.

[0061] For the soft fusion template, the fusion prediction value is calculated as follows: Phat_j = (wj × P1 + (S-wj)× P2 + S / 2) / S. The joint selection of the optimal second predictor and the dictionary template can be expressed as follows: (m2_best, j_best) = argmin_(m2, j) [D(m2, j) + λ × R(m2, j)]. Regarding the weight values, wj ∈ {0, S} for hard selection, and 0 ≤ wj ≤ S for soft fusion.

[0062] Step S6: Calculate the rate-distortion cost, which includes syntax and residuals.

[0063] For each combination, estimate the prediction distortion, residual coding cost, and syntax costs such as the mode field enable flag, second predictor information, and template index, and compare them with the cost when the mode field is not enabled and only basic prediction is used. The rate-distortion cost can be calculated as J = D + λ × R, where D represents the distortion, which can be measured by absolute difference sum, transform domain absolute difference sum, or square difference sum, etc.; R represents the code rate, including estimates of residual coding bits and syntax bits; λ is a Lagrange multiplier used to convert the distortion and code rate to the same dimension for comparison.

[0064] Step S7: Select the optimal second predictor and template index and encode them.

[0065] The encoder selects the rate-distortion-optimal second predictor and dictionary template, and accordingly writes the mode field enable flag, the second predictor index or derivation method, the template index, and the residual data. Information that can be consistently deduced by the encoder and decoder according to the same rules is not written to the bitstream to save bit overhead. If the rate-distortion-optimal second predictor and dictionary template are insufficient to compensate for syntax overhead, the mode field is turned off, and the first prediction block generated by the first predictor is used.

[0066] For example, suppose combination A is (P1, P2=40, Dj=2), combination B is (P1, P2=23, Dj=1), and the base scheme is to use only P1 and not merge them.

[0067] Step 1: For combination A, generate prediction block Phat_A according to the template, and calculate residual = original block - Phat_A; perform Hadamard transformation on the residual and take the sum of absolute values ​​to obtain SATD_A; estimate the syntax and residual bits R_A; obtain J_A = SATD_A + λ·R_A.

[0068] Step 2: For combination B, obtain J_B using the same aperture.

[0069] Step 3: For the base scheme, we get J_base = SATD_base + λ·R_base. Here, R_base does not include the pattern field syntax overhead.

[0070] Step 4: Compare the three values. If J_A is less than both J_B and J_base, then select combination A.

[0071] The comparison object is the rate-distortion cost under the same λ, rather than comparing distortion or bit rate separately.

[0072] Step S8: The decoder recovers and reconstructs the predictor and weight field.

[0073] The decoder parses the mode field enable flag. If the flag indicates that the mode field is enabled, P1 and P2 are generated. The weight field wj(x,y) is recovered according to the template index to complete hard selection or soft fusion prediction. The prediction is then added to the decoding residual to obtain the reconstructed block. Since the dictionary is shared by the encoder and decoder and the generation rules are fixed, the decoder does not need to receive the pixel-by-pixel weight map.

[0074] In one example, mode_field_flag is defined to indicate whether the current block uses the intra-block mode field, second_mode_idx represents the second predictor index or derivation method, dict_idx represents the mode field dictionary template index, and residual_data represents the residual data.

[0075] For example, the entire process of 16x16 block diagonal soft fusion includes: In the predictor generation stage, basic intra-frame rate-distortion optimization (RDO) yields the main mode m1=24, generating the first predictor P1. Second predictor candidates are drawn from the MPM list, including modes 23, 40, and 0, generating candidate P2 for each. The edge histogram shows higher energy in the main diagonal direction; therefore, the dictionary subset only tests three templates: main diagonal hard partitioning, main diagonal soft gradation, and zero fusion. In the fusion and rate-distortion stage, the fixed-point accuracy S=64 for the soft gradation template is used, and a linear transition near the diagonal using normalized coordinates yields the weight value wj. For each (P2, Dj) combination, the sum of distortion, syntax cost, and residual cost is calculated. If the cost of the soft gradation template combined with P2=mode 40 is the lowest and lower than the cost of the zero fusion scheme, then the mode field is confirmed to be enabled. During the bitstream writing and decoding reconstruction stages, the syntax values ​​written by the encoder are as follows: mode_field_flag is 1, indicating that the mode field is enabled; second_mode_idx is 1, indicating that it corresponds to mode 40 in the MPM list; dict_idx is 2, indicating that the main diagonal soft gradient template is selected. The decoder generates identical P1 and P2, and recovers the weight field wj by looking up the table according to template index 2. It is then fused according to the fusion formula Phat = ((wj × P1 + (64-wj) × P2 + 32) >> 6), and finally added to the decoding residual to obtain the reconstructed block. Since the dictionary is shared by both the encoder and decoder and the index length is short, there is no need to transmit pixel-by-pixel weights.

[0076] Insufficient Revenue to Shut Down Mode Field: If the rate-distortion cost of all fusion schemes in the current block is not less than the cost of using only the basic single prediction, then `mode_field_flag` is set to 0, `second_mode_idx` and `dict_idx` are not transmitted, and intra-block prediction reverts to the normal single mode. This indicates that this tool is optional on a block-by-block basis and does not forcibly increase syntax overhead.

[0077] Implicit derivation of the second predictor: The second predictor is fixed to take the second candidate or the a posteriori second candidate from the MPM list, thus omitting the transmission of `second_mode_idx` and only requiring the transmission of the mode field enable flag and template index. This method has less syntactic overhead, but the degrees of freedom of the second predictor are reduced. It is suitable for encoding configurations with a high frequency of mode field switching and where further syntactic compression is desired.

[0078] Hard partitioning of center and periphery: For blocks with texture concentrated in the center, a hard template is tested around the center. The central region uses P1, and the periphery region uses P2 (planar mode). Weight values ​​are only 0 or S. On the hardware side, a selector can be used to switch the position-level predictor without performing multiplication operations. The rate-distortion optimization process is the same as in Example 1, only the dictionary entries are different.

[0079] Complexity Constraints and Boundary Handling: The pattern field tool is enabled only when the width and height of the current block are both at least 16. The number of second predictor candidates is limited to no more than 4, and a maximum of 3 templates are tested in the dictionary subset. For blocks located at image boundaries, if a predictor is unavailable due to insufficient neighborhood, the pattern field is disabled or only the zero-fusion scheme is tested. These constraints keep the additional coding complexity and failure paths within acceptable limits. The complexity constraints and their purposes are shown in Table 1.

[0080] Table 1

[0081] In addition to the weight generation rules, each template entry in the dictionary can also include semantic tags, such as hard or soft templates, diagonal partitioning or center-periphery partitioning, etc., for use by the encoder for template subset selection, but these tags are not included in the bitstream. The fusion process uses the fixed-point formula Phat = ((wj × P1 + (S-wj) × P2 + (S>>1)) >> log2(S)) for calculation, prohibiting the use of floating-point intermediate results to avoid inconsistencies between the encoder and decoder due to rounding precision differences. If other fusion tools already exist in the standard, this method uses the template index to select the intra-block weight field as the independent contribution point.

[0082] In alternative implementations, candidate objects can be replaced by intra-frame orientation patterns, template matching displacements, reference lines, predictor categories, or their combined parameters. Distortion metrics can be absolute difference sums, squared difference sums, transform domain absolute difference sums, or rate-distortion costs. The processing can be implemented in software, hardware, or a combination of both.

[0083] In this embodiment, since the shared dictionary contains multiple pre-set templates, each template directly specifies the prediction weights for each position within a block. The encoder only needs to transmit a short index to represent the complete intra-block weight field, thus enabling pixel-level or region-level pattern field distributions with low bit overhead. Simultaneously, two directions or two types of predictors can be used for position-level selection or fusion within a block. The hard selection method supported by the dictionary templates allows different predictors to be used for different regions, maintaining clear edges even when obvious edges exist; the soft fusion method allows predicted values ​​to transition smoothly along edges, reducing block artifacts. Furthermore, the encoder performs joint rate-distortion selection on the second predictor and the dictionary templates, avoiding the excessive complexity caused by independent searches. When the rate-distortion cost of all fusion schemes is not lower than using only the first predictor, the encoder can disable the pattern field and omit related syntax, ensuring that encoding performance is not degraded by enabling this tool. Since the dictionary is shared by both the encoder and decoder, the decoder only needs to receive a short index to recover the complete intra-block weight field, without needing to receive a pixel-by-pixel weight map.

[0084] The following describes an electronic device provided by an embodiment of this application. The electronic device described below can be referred to in conjunction with other embodiments described herein.

[0085] See Figure 4 As shown in the figure, an embodiment of this application discloses an electronic device, including: Memory 401 is used to store computer programs; Processor 402 is configured to execute the computer program to implement the method disclosed in any of the above embodiments.

[0086] Furthermore, embodiments of this application also provide an electronic device. The aforementioned electronic device can be, for example,... Figure 5 The server shown can also be as follows: Figure 6 The terminal shown. Figure 5 and Figure 6 These are all diagrams illustrating the structure of an electronic device according to an exemplary embodiment. The content in the diagrams should not be considered as any limitation on the scope of this application.

[0087] Figure 5 This is a schematic diagram of a server provided in an embodiment of this application. The server may specifically include: at least one processor, at least one memory, a power supply, a communication interface, an input / output interface, and a communication bus. The memory stores a computer program, which is loaded and executed by the processor to implement the relevant steps in the video encoding disclosed in any of the foregoing embodiments.

[0088] In this embodiment, the power supply is used to provide operating voltage for each hardware device on the server; the communication interface can create a data transmission channel between the server and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0089] In addition, the memory, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system, computer programs and data, etc., and the storage method can be temporary storage or permanent storage.

[0090] The operating system is used to manage and control the various hardware devices and computer programs on the server, enabling the processor to perform operations and processes on the data in the memory. It can be Windows Server, Netware, Unix, Linux, etc. The computer programs, in addition to those capable of performing the video encoding method disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data may include application update information and application developer information.

[0091] Figure 6 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. The terminal may include, but is not limited to, a smartphone, tablet computer, laptop computer, or desktop computer.

[0092] Typically, the terminal in this embodiment includes a processor and a memory.

[0093] The processor may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor can be implemented using at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor may also include a main processor and coprocessors. The main processor, also known as the CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor may also include an AI (Artificial Intelligence) processor, which handles computational operations related to machine learning.

[0094] The memory may include one or more computer non-volatile storage media, which may be non-transitory. The memory may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory is used to store at least the following computer program, which, after being loaded and executed by the processor, is capable of implementing the relevant steps in the video encoding method executed on the terminal side as disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory may also include operating systems and data, and the storage method may be temporary or permanent storage. The operating system may include Windows, Unix, Linux, etc. The data may include, but is not limited to, application update information.

[0095] In some embodiments, the terminal may further include a display screen, an input / output interface, a communication interface, a sensor, a power supply, and a communication bus.

[0096] Those skilled in the art will understand that Figure 6 The structure shown does not constitute a limitation on the terminal and may include more or fewer components than illustrated.

[0097] The following describes a non-volatile storage medium provided in an embodiment of this application. The non-volatile storage medium described below can be referred to in conjunction with other embodiments described herein.

[0098] A non-volatile storage medium is provided for storing a computer program, wherein the computer program, when executed by a processor, implements the video encoding method disclosed in the foregoing embodiments. The non-volatile storage medium is a computer-readable non-volatile storage medium, which, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon include an operating system, computer programs, and data, and the storage method can be temporary storage or permanent storage.

[0099] The following describes a computer program product provided by an embodiment of this application. The computer program product described below can be referred to in conjunction with other embodiments described herein.

[0100] A computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of the aforementioned disclosed video encoding method.

[0101] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium for storing a computer program that, when executed by a processor, implements the steps in any of the above embodiments.

[0102] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0103] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of non-volatile storage medium known in the art.

[0104] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only intended to help understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A video encoding method, characterized in that, Applied to the encoding end, including: Determine the first predictor and N second predictors for the current block to be encoded in the target video frame; Based on a preset shared dictionary, the prediction weights corresponding to each pixel in the current block are determined; the shared dictionary is shared by the encoding end and the decoding end, and includes: M templates corresponding to different textures, each template having the prediction weights for each pixel in the current block; the prediction weights represent the ratio of the first predictor to any second predictor used at the corresponding position; Based on the prediction weights, M×N candidate prediction blocks are generated for the current block; Among the M×N candidate prediction blocks and the first prediction block generated by the first predictor for the current block, the optimal prediction block with the minimum rate-distortion cost is determined. If the optimal prediction block is any candidate prediction block, then the mode field is enabled, and in the explicit encoding mode, the predictor index of the target second predictor and the template index of the target template corresponding to the optimal prediction block are determined; the mode field enable flag, the predictor index, the template index, and the residual data between the current block and the optimal prediction block are determined as the encoding data of the current block.

2. The method according to claim 1, characterized in that, Also includes: If the optimal prediction block is the first prediction block, then the mode field is deenabled; The mode field disable flag and the residual data are determined as the encoded data of the current block.

3. The method according to claim 1, characterized in that, After confirming the enabled mode field, the following is also included: In implicit encoding mode, N is set to 1, and the template index is determined; The pattern field enable flag, the template index, and the residual data are determined as the encoded data of the current block.

4. The method according to claim 1, characterized in that, The M templates include at least two of the following forms: zero-fusion form, diagonal division form, diagonal gradient form, horizontal division form, vertical division form, and center-periphery division form.

5. The method according to claim 1, characterized in that, Among the M×N candidate prediction blocks and the first prediction block generated by the first predictor for the current block, the optimal prediction block with the minimum rate-distortion cost is determined, including: Calculate the first rate-distortion cost of the first prediction block and the second rate-distortion cost of each candidate prediction block; The minimum value in the second rate distortion cost is compared with the first rate distortion cost; If the minimum value is less than the first rate distortion cost, then the optimal prediction block is the candidate prediction block corresponding to the minimum value; If the minimum value is not less than the first rate distortion cost, then the optimal prediction block is the first prediction block.

6. The method according to any one of claims 1 to 5, characterized in that, Before determining the first predictor and N second predictors for the current block to be encoded in the target video frame, the process also includes: Determine whether the current block meets the preset conditions, the preset conditions include at least one of the following: the current component is a luminance component, the width and height of the current block are not less than a preset threshold, the aspect ratio of the current block does not exceed a preset ratio, and the reference sample of the current block is available; If the preset conditions are met, then the steps of determining the first predictor and N second predictors of the current block to be encoded in the target video frame, as well as other subsequent steps, are executed. If the preset conditions are not met, the current block is encoded using the target intra-frame prediction mode.

7. A video decoding method, characterized in that, Applied to the decoding end, including: Obtain the encoded data of the current block to be decoded in the target video frame; If the encoded data includes a pattern field enable flag, then the first predictor for the current block is determined; The target second predictor is determined based on the predictor index in the encoded data; Based on the template index in the encoded data, the target template is determined from a preset shared dictionary; the shared dictionary is shared by the encoding end and the decoding end, and includes M templates, each template having a prediction weight for each pixel in the current block, the prediction weight representing the ratio of the first predictor to any second predictor used at the corresponding position; The prediction weights corresponding to each pixel in the current block are determined based on the target template. Based on the prediction weights, the first predictor, and the target second predictor, a target prediction block for the current block is generated. The current block is reconstructed based on the target prediction block and the residual data in the encoded data.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method as described in any one of claims 1 to 7.

9. A non-volatile storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the method as described in any one of claims 1 to 7.

10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the method described in any one of claims 1 to 7.