Encoding and decoding method, code stream, encoder, decoder and storage medium
Patent Information
- Application Number
- CN202380096982.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-14
- Publication Date
- 2025-11-14
AI Technical Summary
The existing technology has the problem of low prediction accuracy in intra block copy prediction, resulting in high code rate and poor encoding and decoding performance.
By determining the template and block vector candidate list of the current block, determining the block vector according to the block vector candidate list, matching the template and reference block, and using model parameters for filtering processing to improve the accuracy of the prediction value.
It improves the accuracy of intra-frame block copy prediction, saves code rate, and improves encoding and decoding performance.
Smart Images

Figure CN120958796A_ABST
Abstract
Description
Coding and decoding method, code stream, encoder, decoder and storage medium Technical Field
[0001] The present application relates to the field of video coding and decoding technology, and in particular to a coding and decoding method, a bit stream, an encoder, a decoder, and a storage medium. Background Art
[0002] Intra-block copy (IBC), a block-level coding mode, similar to inter-frame techniques, requires a motion search to find the best block vector (BV) for each coding block. This block vector is a vector that points from the current block to the reference block. However, the best BV is found by searching the reconstructed area of the frame containing the current block (i.e., the current coding frame). The reference block pointed to by the best BV is used as the prediction block for the current block.
[0003] However, in the actual encoding process, related technologies usually directly use the reconstructed pixels in the best matching reference block as the predicted pixels of the current encoding block. However, due to incomplete consideration, there will be large deviations in some scenarios, resulting in low prediction accuracy.
[0004] Summary of the Invention
[0005] The present application provides a coding and decoding method, a code stream, an encoder, a decoder and a storage medium, which can improve the accuracy of intra-frame block copy prediction, thereby saving bit rate and improving coding and decoding performance.
[0006] The technical solution of this application can be implemented as follows:
[0007] In a first aspect, an embodiment of the present application provides a decoding method, applied to a decoder, the method comprising:
[0008] Determining a first template of a current block, and determining a block vector candidate list of the current block;
[0009] Decoding the code stream, determining block vector indication information, and determining a first block vector according to the block vector indication information and the block vector candidate list;
[0010] Determine a matching template and a corresponding reference block according to the first block vector;
[0011] Determining model parameters according to the first template and the matching template, and filtering the reference block according to the model parameters to determine a filtered reference block;
[0012] The prediction value of the current block is determined based on the filtered reference block.
[0013] In a second aspect, an embodiment of the present application provides an encoding method, applied to an encoder, the method comprising:
[0014] Determining a first template of a current block, and determining a block vector candidate list of the current block;
[0015] Determine a first block vector according to the block vector candidate list;
[0016] Determine a matching template and a corresponding reference block according to the first block vector;
[0017] Determining model parameters according to the first template and the matching template, and filtering the reference block according to the model parameters to determine a filtered reference block;
[0018] The prediction value of the current block is determined based on the filtered reference block.
[0019] In a third aspect, an embodiment of the present application provides a code stream, which is generated by bit encoding based on information to be encoded; wherein the information to be encoded includes at least one of the following:
[0020] The prediction difference value of the current block, block vector indication information, the number of coefficients of the target filter, the shape of the target filter, the value of the first syntax element identification information, and the value of the second syntax element identification information; wherein the first syntax element identification information is used to indicate whether the current block applies an intra block copy, and the second syntax element identification information is used to indicate whether the current block applies a filter model.
[0021] In a fourth aspect, an embodiment of the present application provides an encoder, comprising a first determination unit, a first filtering unit, and a first prediction unit; wherein:
[0022] a first determining unit configured to determine a first template of a current block and determine a block vector candidate list of the current block;
[0023] The first determining unit is further configured to determine a first block vector according to the block vector candidate list; and determine a matching template and a corresponding reference block according to the first block vector;
[0024] a first filtering unit configured to determine model parameters according to the first template and the matching template, and filter the reference block according to the model parameters to determine a filtered reference block;
[0025] The first prediction unit is configured to determine a prediction value of a current block according to the filtered reference block.
[0026] In a fifth aspect, an embodiment of the present application provides an encoder, comprising a first memory and a first processor; wherein,
[0027] a first memory for storing a computer program capable of running on the first processor;
[0028] The first processor is configured to execute the method according to the second aspect when running a computer program.
[0029] In a sixth aspect, an embodiment of the present application provides a decoder, comprising a second determining unit, a decoding unit, a second filtering unit, and a second prediction unit; wherein:
[0030] a second determining unit configured to determine a first template of a current block and determine a block vector candidate list of the current block;
[0031] A decoding unit configured to decode the code stream and determine block vector indication information;
[0032] The second determining unit is further configured to determine a first block vector according to the block vector indication information and the block vector candidate list; and determine a matching template and a corresponding reference block according to the first block vector;
[0033] a second filtering unit configured to determine model parameters according to the first template and the matching template, and filter the reference block according to the model parameters to determine a filtered reference block;
[0034] The second prediction unit is configured to determine a prediction value of the current block according to the filtered reference block.
[0035] In a seventh aspect, an embodiment of the present application provides a decoder, comprising a second memory and a second processor; wherein,
[0036] a second memory for storing a computer program capable of running on the second processor;
[0037] The second processor is configured to execute the method according to the first aspect when running a computer program.
[0038] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed, implements the method described in the first aspect or the method described in the second aspect.
[0039] Embodiments of the present application provide a coding and decoding method, a bitstream, an encoder, a decoder, and a storage medium. At either the encoding or decoding end, a first template of a current block and a candidate list of block vectors for the current block are determined. A first block vector is determined based on the candidate list of block vectors. A matching template and a corresponding reference block are then determined based on the first block vector. Model parameters are determined based on the first template and the matching template, and the reference block is filtered based on the model parameters to determine a filtered reference block. A prediction value for the current block is determined based on the filtered reference block. At the decoding end, determining the first block vector requires decoding the bitstream to determine block vector indication information. The first block vector is then determined based on the block vector indication information and the candidate list of block vectors to determine the matching template and the corresponding reference block. Thus, model parameters are determined based on the first template and the matching template. The model parameters fully reflect the correlation between the matching template and the first template of the current block. This correlation is applied to the reference block, and the reconstructed pixels are filtered and corrected. The filtered reconstructed pixels are then used as the predicted pixels for the current block. This not only improves prediction accuracy and saves bitrate, but also effectively resolves the problem of linear variation between the reference block and the current block. Furthermore, encoding and decoding efficiency is improved, thereby enhancing encoding and decoding performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] FIG1 is a schematic diagram of a process for obtaining reconstructed pixel values;
[0041] FIG2 is a schematic diagram of a template type of an IBC mode;
[0042] FIG3 is a schematic diagram showing the positional relationship between a current block and adjacent blocks;
[0043] FIG4 is a schematic diagram of a set of block vector prediction candidates located in an IBC reference region;
[0044] FIG5 is a schematic diagram showing the relationship between the template position of a current block and the template position of a reference block;
[0045] FIG6 is a schematic diagram of clustering of block vector prediction candidates;
[0046] FIG7A is a schematic diagram of a diamond search process;
[0047] FIG7B is a schematic diagram of another diamond search process;
[0048] FIG8 is a schematic diagram showing the relationship between a block vector, a block vector prediction, and a block vector difference;
[0049] FIG9 is a schematic diagram of a reference area corresponding to a current block;
[0050] FIG10 is a schematic diagram of a reference area corresponding to a current block;
[0051] FIG11 is a schematic diagram of a reference area corresponding to a current block;
[0052] FIG12 is a schematic diagram of a structure for determining the refined chroma BV;
[0053] FIG13A is a schematic block diagram of an encoder provided in an embodiment of the present application;
[0054] FIG13B is a schematic block diagram of a decoder according to an embodiment of the present application;
[0055] FIG14 is a schematic diagram of a network architecture of a coding and decoding system provided in an embodiment of the present application;
[0056] FIG15 is a schematic diagram of a flowchart of a decoding method provided in an embodiment of the present application;
[0057] FIG16 is a schematic diagram of a template type of an IBC mode provided in an embodiment of the present application;
[0058] FIG17 is a schematic diagram of a structure of a reconstructed pixel that can be used according to an embodiment of the present application;
[0059] FIG18A is a schematic diagram of a border filling area provided in an embodiment of the present application;
[0060] FIG18B is a schematic diagram of another border filling area provided in an embodiment of the present application;
[0061] FIG19 is a schematic diagram of the shape of a filter provided in an embodiment of the present application;
[0062] FIG20A is a schematic diagram of the composition of a filter coefficient provided in an embodiment of the present application;
[0063] FIG20B is a schematic diagram of the composition of a predicted pixel provided by an embodiment of the present application;
[0064] FIG21 is a schematic diagram of a flow chart of an encoding method provided in an embodiment of the present application;
[0065] FIG22 is a schematic diagram of a prediction process based on IBC-FLM technology provided in an embodiment of the present application;
[0066] FIG23 is a schematic diagram of the structure of an encoder provided in an embodiment of the present application;
[0067] FIG24 is a schematic diagram of a specific hardware structure of an encoder provided in an embodiment of the present application;
[0068] FIG25 is a schematic diagram of the structure of a decoder provided in an embodiment of the present application;
[0069] FIG26 is a schematic diagram of a specific hardware structure of a decoder provided in an embodiment of the present application;
[0070] FIG27 is a schematic diagram of the composition structure of a coding and decoding system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0071] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0072] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0073] In the following description, reference is made to "some embodiments," which describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. It should also be noted that the terms "first, second, and third" in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that "first, second, and third" may be interchanged in a specific order or sequential order where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0074] Before further explaining the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained first. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations:
[0075] Coding Block (CB);
[0076] Coding Unit (CU);
[0077] Block Vector Difference (BVD);
[0078] Block Matching (BM);
[0079] Template Matching (TM);
[0080] Merge;
[0081] Advanced Motion Vector Prediction (AMVP)
[0082] Advanced Block Vector Prediction (ABVP)
[0083] Combined Inter and Intra Prediction (CIIP);
[0084] Geometric Partitioning Mode (GPM);
[0085] Local Illumination Compensation (LIC);
[0086] Reconstruction-Reordered IBC (RRIBC)
[0087] Sum of Absolute Difference (SAD);
[0088] Sum of Absolute Transformed Difference (SATD);
[0089] Mean Square Error (MSE);
[0090] Sum of Squared Differences (SSD);
[0091] Mean Absolute Deviation (MAD);
[0092] Mean Square Differences (MSD);
[0093] Normalized Correlation Coefficient (NCC);
[0094] Essential Video Coding (EVC);
[0095] H.265 / High Efficiency Video Coding (HEVC);
[0096] H.266 / Versatile Video Coding (VVC);
[0097] VVC Test Model (VTM), a reference software testing platform for VVC;
[0098] Beyond VVC's reference software testing platform (Enhanced Compression Model, ECM).
[0099] It can be understood that in a video image, a first color component, a second color component, and a third color component are generally used to represent a coding block. These three color components are a luminance component, a blue chrominance component, and a red chrominance component. Specifically, the luminance component is usually represented by the symbol Y, the blue chrominance component is usually represented by the symbol Cb or U, and the red chrominance component is usually represented by the symbol Cr or V. Thus, a video image can be represented in either the YCbCr format or the YUV format.
[0100] It can also be understood that intra block copy (IBC) is an extension tool of VVC for the coding of video sequences of screen content type (Screen Content Coding, SCC), which significantly improves the coding efficiency of screen content sequences. IBC is a block-level coding mode. Similar to inter-frame technology, the encoder performs motion search (block matching) to find the best block vector (Block Vector, BV) for each coding block, which can also be called a motion vector (Motion Vector, MV). The block vector is a vector pointing from the current block to the reference block. The difference from inter-frame technology is that the best block vector of IBC is obtained by searching in the reconstructed area of the frame where the current block is located (that is, the current coded frame), while the inter-frame motion vector is obtained by searching the adjacent reference frames of the current coded frame in the time domain.
[0101] IBC technology is used as a key tool for screen video coding in coding standards such as H.265 / HEVC SCC, H.266 / VVC, and AV1, AVS3, and EVC. The exploratory model ECM for the next-generation H.266 / VVC coding standard also continues to use IBC technology as a screen video coding tool, expanding it into a tool set with multiple modes. It has also been introduced to the coding of general natural video, making it a more versatile video coding tool.
[0102] On the decoding side, if the IBC mode is used, the basic decoding process includes obtaining the BV, using the BV to obtain the predicted value, and determining the reconstructed value. Specifically, Figure 1 is a schematic diagram of a process for obtaining the reconstructed pixel value. As shown in Figure 1, the process may include:
[0103] S101: Obtain BV.
[0104] It should be noted that the decoding end can obtain BV through syntax parsing. In actual implementation, BV can be obtained in multiple ways, so the bitstream can contain mode information for the BV acquisition method and corresponding parameter information. For example, if the IBC merge mode is obtained in the syntax element, the decoder constructs a merge list, parses the merge list option index, and then obtains the specific information of BV from the corresponding option in the merge list according to the index; for another example, in the ordinary IBC mode, the decoder obtains the specific information of BV by parsing the value of the syntax element that describes BV or BV prediction difference in the bitstream.
[0105] S102: Obtain prediction samples using BV.
[0106] It should also be noted that the prediction value can be obtained by using BV. The use of BV here usually involves copying the corresponding area pointed to by BV, so as to obtain the prediction value of the current block.
[0107] S103: Determine a reconstructed sample based on the predicted sample.
[0108] It should also be noted that for obtaining the reconstructed value, if there is a prediction residual, it is necessary to parse the code stream to obtain the prediction residual, and then add the prediction residual to the predicted value to obtain the final reconstructed value.
[0109] In the embodiments of this application, there are many places involving the use of templates and template matching costs, which are uniformly explained here in advance:
[0110] Figure 2 is a schematic diagram of template types in an IBC mode. As shown in Figure 2, a block filled with a grid is a current block, and the adjacent area of the current block is a template T. Six template types are shown here.
[0111] For example, refTemplateType can be used to represent the template type. The six template types are as follows:
[0112] When the upper left reference pixel, the upper reference pixel, and the left reference pixel are all available, the value of refTemplateType is 1, and the template shape is shown in (a) of Figure 2;
[0113] When only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is shown in (b) in Figure 2;
[0114] When only the upper reference pixel is available, the value of refTemplateType is 3, and the template shape is shown in (c) in Figure 2;
[0115] When only the left reference pixel and the upper left reference pixel are available, the value of refTemplateType is 4, and the template shape is shown in (d) in Figure 2;
[0116] When only the left reference pixel and the lower left reference pixel are available, the value of refTemplateType is 5, and the template shape is shown in (e) in Figure 2;
[0117] When only the upper reference pixel and the upper right reference pixel are available, the value of refTemplateType is 6, and the template shape is shown in (f) in Figure 2.
[0118] That is, there can be multiple types of templates, including but not limited to those shown in Figure 2. They can be valid at the same time, selected by the syntax element, or used individually (for example, only using type (a) in Figure 2):
[0119] In an embodiment of the present application, the preset cost function can be the sum of absolute error SAD, the sum of absolute transformation difference SATD, the mean square error MSE, the sum of squared errors SSD, the mean absolute difference MAD, the mean sum of squared errors MSD, the normalized correlation coefficient NCC, etc., which is not specifically limited here.
[0120] For example, taking absolute error and SAD as examples, the cost function at this time is as follows:
[0121] Among them, T i is the template in the search process, and M represents the number of pixels in the template.
[0122] In a specific embodiment, for step S101, deriving BV, the specific process is as follows:
[0123] (1) Luminance component:
[0124] Input: Luma position (xCb, yCb), which specifies the top left corner sample of the current block relative to the top left corner luma sample of the current image; a variable cbWidth, which specifies the width of the current block in luma samples; a variable cbHeight, which specifies the height of the current block in luma samples.
[0125] Output: Block vector bvL (Block Vector Luma) of luminance.
[0126] The IBC mode can be roughly divided into two categories: IBC merge and IBC ABVP (similar to the merge and AMVP modes of the inter-frame mode in VVC). The process of obtaining BV can be regarded as the following three steps:
[0127] (1) When deriving bvL, it is necessary to establish an IBC block vector candidate list bvCandList;
[0128] (2) determining the candidate items in the selected candidate list based on the bitstream;
[0129] (3) Finally, the final BV is determined based on the candidate.
[0130] The specific storage information of the IBC candidate includes at least one of the following information:
[0131] Prediction direction (L0 or L1, generally L0 by default);
[0132] BV information (horizontal component, vertical component);
[0133] Reference frame (default current image);
[0134] Flip type (e.g., no flip, horizontal flip, and vertical flip);
[0135] Whether to use LIC (linear model).
[0136] The following describes the process of establishing a block vector candidate list, taking the IBC merge list establishment process as an example. The basic establishment process of the IBC ABVP list is the same as that of the IBC merge, but the maximum number of candidates is different between the two (for example, the IBC merge candidate list length is defined as 6, while the IBC ABVP candidate list length is defined as 2). The specific establishment process includes:
[0137] Step 1: Derivation of airspace candidates:
[0138] When the usage conditions are met (for example, the size condition IsGt4by4 is equal to TRUE, that is, the variable IsGt4by4 is TRUE when the luma width multiplied by the height is greater than 16), the derivation process of the spatial block vector candidates from the adjacent coding units specified in the decoding specification is called using the luma coding block position (xCb, yCb), the luma coding block width cbWidth and the height cbHeight as input, and the output is the availability flags such as availableFlagA1, availableFlagB1 and the block vectors bvA1 and bvB1.
[0139] The availability check for each candidate is as follows: the following conditions are met. If all of them are met, the candidate is available:
[0140] Whether the offset position obtained by adding the current block position to the BVP does not exceed the image boundary;
[0141] Whether the current block position plus the block position pointed to by BVP does not overlap the current block;
[0142] Whether the offset position obtained by adding the current block position to the BVP does not exceed the IBC available area;
[0143] Whether the current block position plus the block position pointed to by BVP has been rebuilt.
[0144] The relative positions of the adjacent blocks A1 and B1 and the current block are shown in Figure 3. The traversal order in Figure 3 can be A1->B1->B0->A0->B2:
[0145] Step 2: Airspace candidates are added to the candidate list:
[0146] When the usage condition is met (for example, the size condition IsGt4by4 is equal to TRUE), the block vector candidate list bvCandList is constructed as follows:
[0147] i=0;
[0148] if(availableFlagA1);
[0149] bvCandList[i++]=bvA1;
[0150] if(availableFlagB1);
[0151] bvCandList[i++]=bvB1;
[0152] …
[0153] Step 3: Check the number of valid items in the candidate list:
[0154] The variable numCurrCand (the number of candidates currently obtained) is derived as follows:
[0155] If the usage condition is met (eg, the size condition IsGt4by4 is equal to TRUE), numCurrCand is set equal to the number of candidates in bvCandList; otherwise, numCurrCand is set to 0.
[0156] Step 4: If the candidate list does not reach the specified number of items (for example, the specified number of items for IBC merge mode is 6, and the specified number of items for IBC ABVP mode is 2), continue with historical candidate item derivation, availability detection, and addition:
[0157] When numCurrCand is less than MaxNumIbcMergeCand (the maximum number of candidates in IBC merge mode) and NumHmvpIbcCand (the maximum number of candidates for the historical best block vector (Hmvp) in IBC mode) is greater than 0, the derivation process of the history-based IBC block vector candidates specified in the decoding specification is called with bvCandList and numCurrCand as input and the modified bvCandList and numCurrCand as output.
[0158] Step 5: Continue to check the number of valid items in the candidate list and add other available candidates (such as pairwise average candidates, zero-valued BV candidates, etc.) until the specified number of items is reached.
[0159] For example, other available candidates are as follows:
[0160] (1) The pairwise average candidate can be constructed by using the first and second candidate items, specifically: mvAvgLX=(mvCand0LX+mvCand1LX+1)>>1.
[0161] (2) The zero value BV can be directly set to:
[0162] bvCandList[numCurrCand][0] is set equal to 0. (horizontal component of bv)
[0163] bvCandList[numCurrCand][1] is set equal to 0. (vertical component of bv)
[0164] (3) A set of BVP candidates located in the IBC reference area can also be used as candidates that can be added. The coordinates of a set of BVP candidates are determined by the width and height of the current block and the ΔX and ΔY parameters, as shown in Figure 4.
[0165] Each time an item is added, numCurrCand increases by 1.
[0166] In this way, the basic block vector candidate list bvCandList is established.
[0167] Based on this list, in the IBC merge mode, the order of the list can also be reordered using a template, the order of the candidate list can be adjusted, the high spatial correlation can be fully utilized, the coding bit transmission can be reduced, and the coding efficiency can be effectively improved. For example, for the IBC merge mode, after the intermediate candidate list is constructed according to the above list construction method (note that the length of the intermediate candidate list can be greater than or equal to the maximum number of candidates in the IBC merge mode), all candidates in the list are reordered using the template, and sorted in order from small to large according to the template matching cost, and the first N (for example, N = 6) candidates in the sorted list are selected. The specific process is as follows: the SAD of the template position of the reference block pointed to by each candidate and the template position of the current block (as shown in Figure 5) is calculated, and they are sorted in ascending order, and the first 6 candidates are selected as the candidate list for the IBC merge.
[0168] Based on this list, the IBC ABVP mode can also remove candidate redundancy based on the distance between candidates:
[0169] The number of candidates remains unchanged at two, and candidate lists are established for integer pixel and 4-pixel precision respectively.
[0170] If non-RRIBC mode is selected for IBC ABVP, if the number of valid BVP candidates exceeds two, up to six BVP candidates in the candidate list are clustered according to the Euclidean distance between them, with the radius (R) being a set of block vectors determined as a logarithmic function of the width (cbWidth) and height (cbHeight) of the current block. If the Euclidean distance between the reference positions pointed to by several BV candidates is less than R, they are clustered: R = log2((cbWidth·chHeight)>>MIN_PU_SIZE) (2)
[0171] Figure 6 is a schematic diagram of clustering of BVP candidates. As shown in Figure 6, the blocks filled with grids are coding blocks CB, and the blocks filled with white are prediction blocks PB. Among them, the three prediction blocks pointed to by BVP1, BVP2, and BVP5 constitute the first group, the two prediction blocks pointed to by BVP3 and BVP6 constitute the second group, and the prediction block pointed to by BVP4 constitutes the third group; here, the three BVP candidates in the first group are clustered, and the two BVP candidates in the second group can also be clustered. It should be noted that the clustering method is performed in the order of the candidate list. In each class, the BVP with the lowest TM cost is selected as the representative candidate of the group. Then, the representative candidates of all classes are template-sorted, and the representative candidates of the first two groups are selected for the motion estimation process.
[0172] If the RRIBC mode is selected for the IBC ABVP, the candidates can be adjusted to point to the boundaries of the valid IBC search area in the horizontal or vertical direction according to the RRIBC mode.
[0173] Furthermore, the candidate items in the selected candidate list are determined according to the bitstream, and the specific steps are as follows:
[0174] In IBV merge mode (general_merge_flag[xCb][yCb] is true) and IBC ABVP mode (general_merge_flag[xCb][yCb] is false), the candidate index bvIdx is derived as follows, where general_merge_flag indicates whether it is IBC merge mode: bvIdx = general_merge_flag[xCb][yCb]? merge_idx[xCb][yCb]: mvp_l0_flag[xCb][yCb].
[0175] Further, the final BV is determined based on the candidate.
[0176] In IBC merge mode, the specific bvL can be obtained according to the index bvIdx and the block vector candidate list bvCandList: bvL[0]=bvCandList[bvIdx][0]; bvL[1]=bvCandList[bvIdx][1];
[0177] This bvL is the final BV.
[0178] In IBC MBVD mode, similar to the MMVD in VVC's inter-frame technology, a candidate in the IBC merge list is used as the starting point, and a candidate is selected from the candidate point set corresponding to the predefined distance and direction set, and its corresponding block vector is used as the final BV.
[0179] For example, in IBC MBVD, the distance set is defined as {1-pel, 2-pel, 4-pel, 8-pel, 12pel, 16pel, 24pel, 32pel, 40pel, 48pel, 56pel, 64pel, 72pel, 80pel, 88pel, 96pel, 104pel, 112pel, 120pel, 128pel}, and the BVD directions are positive and negative horizontal directions and positive and negative vertical directions.
[0180] The base candidate can be selected from the first five candidates in the reordered IBC merge list, and all possible MBVD refinement positions (i.e., 20×4 candidates) of each base candidate are reordered based on the SAD cost between the template and its reference at each refinement position. Finally, the first 8 refinement positions with the smallest template SAD are retained for MBVD index encoding. The IBC-MBVD candidates do not inherit the flip type from the RR-IBC encoded neighboring blocks. The MBVD index is binarized using a Rice code with parameter equal to 1.
[0181] In the IBC TM merge mode, after obtaining the bvL based on the above information, the TM can also be used to locally refine the BV. The specific operation is to search within a small range centered on the obtained bvL and select the optimal BV within the range as the final BV based on the minimum template matching cost.
[0182] The TM refinement of the candidate list for the IBC merge mode is carried out. The specific implementation process is as follows:
[0183] When building a candidate, the flip type defaults to no flip;
[0184] IBC TM merge mode In IBC merge mode, the transmission syntax element specifies whether to perform integer-pixel precision TM refinement. The location of the refined motion vector and the template used in each refinement step must comply with the reference area constraints.
[0185] A search is performed near the candidate's pointed position, using the SAD between the template of the reference block and the template of the current block to determine the optimal position. This includes, but is not limited to, the following search methods: the search range is [-8, 8], and a diamond search is first performed on integer pixels, searching eight points near the center position, as shown in Figures 7A and 7B. The maximum number of searches is 375. After the optimal position is determined for the first time, the search continues, searching five points at even-numbered positions and three points at odd-numbered positions in subsequent searches.
[0186] For example, taking FIG7A as an example, a counterclockwise circle from the black point is in the order of indexes 0 to 7. Specifically, the above process is as follows: when the black point position is selected as the optimal position, the search continues for 5 points of the grid point position; and when the black point position is selected as the optimal position, the search continues for 3 points of the grid point position. This is only an example and is not a specific limitation.
[0187] After the above diamond search process, a whole-pixel cross search is performed only once. That is, after the diamond search finds the current optimal position, four positions with a distance of one pixel below, to the right, above, and to the left of the current optimal position are checked to update the final optimal position, that is, to update the refined candidate list.
[0188] For the IBC ABVP mode, the bvL obtained by indexing bvIdx and the block vector candidate list bvCandList is the predicted bvL. The actual bvL also needs to be added with the block vector difference (BVD). The generalized specific process is as follows:
[0189] Step 1: Get the horizontal and vertical components of BVD, where MvdL0 is the forward motion vector difference. bvd[0] = MvdL0[xCb][yCb][0]; bvd[1] = MvdL0[xCb][yCb][1].
[0190] Step 2: Round the predicted bvL obtained above, where the right shift parameter AmvrShift is used for rounding and the left shift parameter AmvrShift is used to improve the resolution. Specifically: offset = (AmvrShift == 0)? 0: ((1 << (AmvrShift-1))-1); bvL[0] = Sign(bvL[0])*(((Abs(bvL[0])+offset)>>AmvrShift)<<AmvrShift); bvL[1]=Sign(bvL[1])*(((Abs(bvL[1])+offset)> >AmvrShift)< <AmvrShift)。
[0191] Step 3: The true bvL is derived as follows, and its range needs to be controlled between -217 and 217–1: u[0]=(bvL[0]+bvd[0]+218)%218; bvL[0]=(u[0]>=217)?(u[0]-218):u[0]; u[1]=(bvL[1]+bvd[1]+218)%218; bvL[1]=(u[1]>=217)?(u[1]-218):u[1].
[0192] It should be noted that the method of obtaining BVD in step 1 can also be inferred from syntax elements obtained through other encoding methods. The BVD of IBC ABVP uses sub-pixels, whole pixels or 4 pixels as units. During encoding, its symbol can be predicted, and the suffix of the exponential Golomb code obtained after its binarization can also be predicted. Therefore, its syntax elements can be defined by multiple information of the BVD value: whether it is 0, prefix, symbol, and suffix. The combination and analysis of these information can obtain the actual value of BVD. The specific embodiments are as follows:
[0193] Context coding is used to identify whether BVD is 0. The value of (absolute value -1) is binarized using first-order exponential Golomb coding. The first 5 binary data (bin) of the EG1 prefix are context coded, and the remaining prefixes are bypass coded. Up to 4 bins of the EG1 suffix use context coding to transmit prediction indexes, and the other bins of the EG1 suffix use bypass coding. The two bins of the sign bit use context coding to transmit symbol prediction indexes. Figure 8 is a schematic diagram of the relationship between a block vector (BV), a block vector prediction (BVP), and a block vector difference (BVD). As shown in Figure 8, the dotted line represents BV, the dotted line represents BVP, and the bold line represents BVD. Here is the prediction process of a suffix bin that transmits a prediction index in the horizontal and vertical directions, and a bin that transmits a symbol index in the horizontal and vertical directions. The current block template and the template corresponding to the BV are sorted to derive the prediction index of the suffix and symbol.
[0194] In this way, the final derived BV should be within the specified range (coordinate range in rows and columns).
[0195] For example, in VVC, the reference area of IBC is 128×128. For a 128×128 CTU, the reference area is shown in Figure 9. In Figure 9, whether (a), (b), (c), or (d), two CTUs are included. The area filled with diagonal lines is the reference area, and the small block filled with vertical lines represents the current block of 64×64 size. "×" represents an unavailable reference area.
[0196] In ECM 7.0, as shown in Figure 10, a box represents a CTU. Boxes filled with vertical lines represent the CTU where the current block is located, and boxes filled with diagonal lines represent its reference area. Specifically, for the current block to be encoded, assuming it is located in CTU (m, n), the reference area includes CTUs with indices (m–2, n–2)…(W, n–2)…(0, n–1)…(W, n–1), (0, n)…(m, n). W represents the maximum horizontal index within the current tile, slice, or picture.
[0197] When the CTU size is 256×256, the two rows of CTUs above may require additional memory. To prevent IBC from occupying additional memory, the reference area is adjusted, as shown in Figure 11. Each box represents a CTU, a box filled with vertical lines represents the CTU where the current block is located, and a box filled with diagonal lines represents its reference area.
[0198] The range of block vector search (or local search) for each block is restricted to horizontally [–(C<<1), C>>2] and vertically [–C, C>>2] to accommodate the reference area extension, where C represents the CTU size.
[0199] (2) Chroma component:
[0200] In the IBC mode of the chroma component, the BV of the chroma can be derived based on the luma BV, and then prediction and reconstruction can be achieved based on the chroma BV. The process of deriving the chroma BV based on the luma BV is as follows:
[0201] Input: bvL of brightness (1 / 16 pixel accuracy);
[0202] Output: bvC (Block Vector Chroma) of chroma (1 / 32 pixel accuracy).
[0203] The derivation process can be either direct scaling or scaling followed by refinement using TM.
[0204] For the scaling operation, an example is as follows: bvC[0]=((bvL[0]>>(3+SubWidthC))*32); bvC[1]=((bvL[1]>>(3+SubHeightC))*32).
[0205] The variables SubWidthC and SubHeightC depend specifically on the chroma format sampling structure specified by sps_chroma_format_idc. For specific correspondence, see Table 1, which shows the correspondence between sps_chroma_format_idc and the chroma format sampling structure.
[0206] Table 1
[0207] For refinement operations, the following methods can be included:
[0208] Using TM for refinement, after obtaining the luma BV, the chroma block position and BV are used to find the offset position. A template is then used to perform a detailed search near the offset position, and the optimal BV (i.e., the refined BV) is obtained with the minimum TMcost. As shown in Figure 12, the area filled with diagonal lines represents the chroma reconstruction area. For the current block, template matching can be used to find the best matching template and the corresponding refined BV. The reference block at the optimal offset position obtained based on the refined BV is copied, and the chroma prediction value of the current block can be determined.
[0209] In a specific embodiment, for step S102, the prediction sample is obtained using BV, and the specific process is as follows:
[0210] Input: Luma position (xCb, yCb), which specifies the top-left luma sample of the current block relative to the top-left luma sample of the current image; a variable cbWidth, which specifies the width of the current block in luma samples; a variable cbHeight, which specifies the height of the current block in luma samples; a block vector bv; and a variable cIdx, which specifies the color component index of the current block.
[0211] Output: array predSamples of predicted samples.
[0212] In one implementation, an example of the derivation process of directly copying the prediction block is as follows:
[0213] When cIdx is equal to 0, that is, the luminance component, for x = xCb…xCb+cbWidth-1 and y = yCb…yCb+cbHeight–1: xVb = (x+(bvL[0]>>4))&(IbcBufWidthY-1); yVb = (y+(bvL[1]>>4))&(CtbSizeY-1); predSamples[x][y] = ibcVirBuf[0][xVb][yVb].
[0214] Among them, IbcBufWidthY is the width of the brightness pixel of the reconstructed buffer stored in IBC, CtbSizeY is the size of CTU (Coding Tree Unit), and ibcVirBuf is the reconstructed pixel stored in IBC.
[0215] When cIdx is not equal to 0, that is, when it is a chroma component, for x = xCb / SubWidthC..xCb / SubWidthC+cbWidth / SubWidthC-1 and y = yCb / SubHeightC..yCb / SubHeightC+cbHeight / SubHeightC-1: xVb = (x+(bvC[0]>>4))&(IbcBufWidthC-1); yVb = (y+(bvC[1]>>4))&((CtbSizeY / subHeightC)-1); predSamples[x][y] = ibcVirBuf[cIdx][xVb][yVb].
[0216] In addition to the basic acquisition methods described above, there is also an IBC flip mode method that requires flipping the prediction area horizontally or vertically to obtain the predicted value. For example, a syntax element indicates whether to flip the area and, if so, whether to flip it horizontally or vertically. The decoder then reversely rearranges the reference area pixels horizontally or vertically according to the syntax to obtain the predicted pixel values for the coding block.
[0217] In addition to the above acquisition process, a template can also be used to establish a model between the current block and the predicted area. The predicted block is then processed according to the model to obtain the predicted value of the current block. For example, the IBC LIC mode, applied to IBC merge and IBC ABVP, uses a linear equation to compensate for local illumination changes. Similar to the LIC for inter-frame prediction in VVC, the parameters of the linear equation can be expressed as a scaling parameter α and an offset parameter β, that is, α*p[x]+β to compensate for illumination changes, where p[x] is the reference sample pointed to by the BV at position x in the current image. The linear model parameters are derived using the least squares method.
[0218] On the basis of the above-obtained prediction values, weighted prediction with other intra-frame prediction methods can also be implemented, and the result after weighted prediction is used as the final prediction result.
[0219] The weighted prediction method includes the inter-frame and intra-frame hybrid prediction CIIP method borrowed from VVC, that is, the result obtained by the above prediction process is weightedly combined with the prediction result obtained by the ordinary intra-frame directional prediction mode at each pixel position; it also includes the inter-frame geometric prediction mode GPM method borrowed from VVC, that is, based on a wedge division, the results obtained by using different prediction modes in different wedge areas, and weighted mixing in accordance with certain rules near the wedge division line.
[0220] An example of the operation process in IBC CIIP mode: the IBC prediction value of the current block is weightedly fused with the prediction value of a certain intra-frame mode. The IBC prediction part can be obtained by applying the conventional merge, TM merge, MBVD and ABVP modes.
[0221] For the case where the IBC prediction part is the conventional IBC merge, TM merge, and MBVD mode, the weight ratio of IBC prediction and intra prediction is 13:3. The intra mode includes the TIMD mode of the current block and the intra prediction mode at the candidate BV. If the second prediction mode in the intra mode is the same as the first prediction mode, it is determined whether the first prediction mode is the PLANAR mode. If so, the second prediction mode is replaced with the horizontal prediction mode, otherwise the second prediction mode is replaced with the PLANAR mode.
[0222] For the case where the IBC prediction part is the ABVP mode, the weight ratio of the IBC prediction and the intra-frame prediction is 1:1, and the TIMD mode is obtained as the first prediction mode of the intra-frame prediction mode. If the derived prediction mode is the horizontal prediction mode, PLANAR is obtained as the second prediction mode of the intra-frame prediction mode. Otherwise, the horizontal prediction mode is obtained as the second prediction mode of the intra-frame prediction mode.
[0223] Example of the operation process in IBC GPM mode: Conventional merge and TM merge can be applied to the IBC prediction part. For a single IBC partition and one INTRA partition, the intra prediction mode (IPM) candidate list is constructed using the same method as for inter GPM, and the IPM candidate list size is predefined as 3.
[0224] In a specific implementation, there are 48 geometric partitioning patterns, which can be divided into two geometric partitioning pattern sets. Table 2 is the first geometric partitioning pattern set, and Table 3 is the second geometric partitioning pattern set.
[0225] Table 2
[0226] Table 3
[0227] When using IBC GPM, the IBC GPM geometric partitioning mode set flag is transmitted to indicate whether the first or second geometric partitioning mode set is selected, followed by the geometric partitioning mode index. The IBC-GPM frame partition flag is then transmitted to indicate whether intra prediction is used for the first sub-partition. The intra prediction portion requires the transmission of the intra prediction mode index, and the IBC prediction portion requires the transmission of the MEGRE index.
[0228] Furthermore, for step S103, a reconstruction sample is obtained. Specifically, it may be:
[0229] If there is a residual, the decoding process of the residual signal specified by the decoding specification is called.
[0230] Invokes the image reconstruction process for the specified color component as specified by the decoding specification.
[0231] That is, after obtaining the predicted value, if there is a residual, the decoding process of the residual signal specified by the decoding specification can be called to obtain the residual value; then the reconstructed value can be obtained based on the sum of the predicted value and the residual value.
[0232] It can be seen that IBC is a block-level coding mode. Similar to inter-frame technology, the encoder performs motion search (block matching) to find the best block vector for each coding block. The block vector is a vector pointing from the current block to the reference block. However, in the actual coding process, directly using the reconstructed pixels of the best matching reference block as the predicted pixels of the current block is not optimal in some cases. For example, when there is a linear illumination change between the best matching reference block and the current block, directly using the reconstructed pixels of the best matching reconstructed block as the predicted pixels of the current coding block will result in a large deviation and the optimal prediction effect cannot be achieved. In addition, when IBC is used for natural scene video coding, the limited accuracy of BV can easily lead to poor prediction results. Even if the LIC mode is applied or weighted fusion is performed with other Intra modes, good prediction accuracy cannot be achieved.
[0233] Based on this, an embodiment of the present application provides an encoding method, which determines a first template of a current block and a block vector candidate list of the current block; determines a first block vector based on the block vector candidate list; and determines a matching template and a corresponding reference block based on the first block vector;
[0234] Model parameters are determined according to the first template and the matching template, and the reference block is filtered according to the model parameters to determine a filtered reference block; and a prediction value of the current block is determined according to the filtered reference block.
[0235] An embodiment of the present application also provides a decoding method, which determines a first template of a current block and a block vector candidate list of the current block; decodes a code stream, determines block vector indication information, and determines a first block vector based on the block vector indication information and the block vector candidate list; determines a matching template and a corresponding reference block based on the first block vector; determines model parameters based on the first template and the matching template, and filters the reference block based on the model parameters to determine a filtered reference block; and determines a prediction value of the current block based on the filtered reference block.
[0236] In this way, the model parameters are determined according to the first template and the matching template. The model parameters fully reflect the correlation between the matching template and the first template of the current block, and this correlation is applied to the reference block. The reconstructed pixels are filtered and corrected, and then the filtered reconstructed pixels are used as the predicted pixels of the current block. This not only improves the prediction accuracy and saves bit rate, but also effectively solves the problem of linear change between the reference block and the current block; at the same time, it can also improve the encoding and decoding efficiency, thereby improving the encoding and decoding performance.
[0237] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0238] Referring to FIG13A , which shows a block diagram of an encoder provided in an embodiment of the present application. As shown in FIG13A , the encoder (specifically, a “video encoder”) 100 may include a transform and quantization unit 101, an intra-frame estimation unit 102, an intra-frame prediction unit 103, a motion compensation unit 104, a motion estimation unit 105, an inverse transform and inverse quantization unit 106, a filter control analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoded image cache unit 110, etc., wherein the filtering unit 108 may implement deblocking filtering and sample adaptive offset (SAO) filtering, and the encoding unit 109 may implement header information encoding and context-based adaptive binary arithmetic coding (CABAC).For the input original video signal, a video coding block can be obtained by dividing the coding tree unit (CTU). Then, the residual pixel information obtained after intra-frame or inter-frame prediction is transformed by the transformation and quantization unit 101, including transforming the residual information from the pixel domain to the transform domain and quantizing the obtained transform coefficients to further reduce the bit rate; the intra-frame estimation unit 102 and the intra-frame prediction unit 103 are used to perform intra-frame prediction on the video coding block. Specifically, the intra-frame estimation unit 102 and the intra-frame prediction unit 103 are used to determine the intra-frame prediction mode to be used to encode the video coding block; the motion compensation unit 104 and the motion estimation unit 105 are used to perform inter-frame prediction coding on the received video coding block relative to one or more blocks in one or more reference frames to provide temporal prediction information; the motion estimation performed by the motion estimation unit 105 is the process of generating a motion vector, which can estimate the motion of the video coding block. The motion compensation unit 104 then calculates the motion vector based on the motion vector determined by the motion estimation unit 105. After determining the intra-frame prediction mode, the intra-frame prediction unit 103 is further configured to provide the selected intra-frame prediction data to the encoding unit 109, and the motion estimation unit 105 also sends the calculated motion vector data to the encoding unit 109. In addition, the inverse transform and inverse quantization unit 106 is configured to reconstruct the video coding block and reconstruct a residual block in the pixel domain. The reconstructed residual block is subjected to the filter control analysis unit 107 and the filtering unit 108 to remove the block effect artifacts. The reconstructed residual block is then added to a predictive block in the frame of the decoded image buffer unit 110 to generate a reconstructed video coding block. The encoding unit 109 is configured to encode various coding parameters and quantized transform coefficients. In the CABAC-based coding algorithm, the context content can be based on adjacent coding blocks and can be used to encode information indicating the determined intra-frame prediction mode, and output the code stream of the video signal. The decoded image buffer unit 110 is configured to store the reconstructed video coding block for prediction reference. As the video image encoding proceeds, new reconstructed video encoding blocks are continuously generated, and these reconstructed video encoding blocks are stored in the decoded image buffer unit 110 .
[0239] Referring to FIG13B , which shows a block diagram of a decoder according to an embodiment of the present application, the decoder (specifically, a "video decoder") 200 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra-frame prediction unit 203, a motion compensation unit 204, a filtering unit 205, and a decoded image buffer unit 206. The decoding unit 201 can implement header information decoding and CABAC decoding, and the filtering unit 205 can implement deblocking filtering and SAO filtering. After the input video signal is coded as shown in FIG13A, a code stream of the video signal is outputted. The code stream is inputted into the decoder 200 and first passes through the decoding unit 201 to obtain decoded transform coefficients. The transform coefficients are processed by the inverse transform and inverse quantization unit 202 to generate a residual block in the pixel domain. The intra-frame prediction unit 203 can be used to generate prediction data for the current video decoding block based on the determined intra-frame prediction mode and data from the previously decoded block of the current frame or picture. The motion compensation unit 204 determines prediction information for the video decoding block by analyzing the motion vector and other associated syntax elements, and uses the prediction information to generate the residual block. The prediction information is used to generate a predictive block for the video decoding block being decoded; a decoded video block is formed by summing the residual block from the inverse transform and inverse quantization unit 202 with the corresponding predictive block generated by the intra-frame prediction unit 203 or the motion compensation unit 204; the decoded video signal passes through the filtering unit 205 to remove blocking artifacts, thereby improving video quality; the decoded video block is then stored in the decoded image buffer unit 206, which stores reference images used for subsequent intra-frame prediction or motion compensation, and is also used for outputting the video signal, thereby obtaining the restored original video signal.
[0240] Furthermore, the embodiment of the present application also provides a network architecture of a coding and decoding system including an encoder and a decoder, wherein Figure 14 shows a schematic diagram of the network architecture of a coding and decoding system provided by the embodiment of the present application. As shown in Figure 14, the network architecture includes one or more electronic devices 13 to 1N and a communication network 01, wherein the electronic devices 13 to 1N can perform video interaction through the communication network 01. During implementation, the electronic device can be various types of devices with video coding and decoding functions. For example, the electronic device can include a smart phone, a tablet computer, a personal computer, a personal digital assistant, a navigator, a digital phone, a video phone, a television, a sensing device, a server, etc., and the embodiment of the present application is not specifically limited. Here, the decoder or encoder described in the embodiment of the present application can be the above-mentioned electronic device.
[0241] It should be noted that the method of the embodiment of the present application is mainly applied to the intra-frame prediction unit 103 shown in Figure 13A and the intra-frame prediction unit 203 shown in Figure 13B. In other words, the embodiment of the present application can be applied to both the encoder and the decoder, or even to both the encoder and the decoder at the same time, but the embodiment of the present application is not specifically limited thereto.
[0242] It should also be noted that, when applied to the intra-frame prediction unit 103, the "current block" specifically refers to the coding block currently to be intra-frame predicted; when applied to the intra-frame prediction unit 203, the "current block" specifically refers to the decoding block currently to be intra-frame predicted.
[0243] In one embodiment of the present application, referring to FIG15 , a flowchart of a decoding method provided by an embodiment of the present application is shown. As shown in FIG15 , the method may include:
[0244] S1501: Determine a first template of a current block, and determine a block vector candidate list of the current block.
[0245] It should be noted that the decoding method of the embodiment of the present application is applied to the decoder. In addition, the decoding method may specifically refer to an intra-frame prediction method, more specifically, an intra-frame prediction method of an intra-block copy technology based on a linear filter model (Intra Block Copy based on Filter-based linear model, IBC-FLM), but is not limited to the IBC mode, and other modes of applying block vectors can be applied. Among them, the video image can be divided into multiple decoding blocks, and the current block in the embodiment of the present application refers to the decoding block in the video image that is currently to be intra-frame predicted. In addition, the decoding method of the embodiment of the present application can be used to predict both the luminance component and the chrominance component, which is not specifically limited here.
[0246] It should also be noted that, in the embodiments of the present application, it is first necessary to determine the first template of the current block so that a matching template and a corresponding reference block can be determined based on the first template. In some embodiments, determining the first template of the current block may include:
[0247] Determine the template type of the current block;
[0248] Determine the first template of the current block according to the template type of the current block.
[0249] The template type can be represented by refTemplateType. In some embodiments, determining the template type of the current block may include: determining the template type of the current block according to reference pixels of the current block.
[0250] The reference pixels of the current block include at least one of the following: a left adjacent reference pixel of the current block, an upper adjacent reference pixel of the current block, and an upper-left adjacent reference pixel of the current block.
[0251] For example, Figure 16 shows a schematic diagram of a template type for an IBC mode provided in an embodiment of the present application. When the upper left, upper, and left reference pixels are all available, the value of refTemplateType is 1, and the template type shape is shown in Figure 16 (a); when only the left reference pixel is available, the value of refTemplateType is 2, and the template type shape is shown in Figure 16 (b); when only the upper reference pixel is available, the value of refTemplateType is 3, and the template type shape is shown in Figure 16 (c).
[0252] That is, in an embodiment of the present application, the reference pixels of the current block are determined based on the adjacent reconstructed area of the current block. The adjacent reconstructed area of the current block includes at least one of the following: a left adjacent area, an upper adjacent area, and an upper-left adjacent area. For example, the left adjacent reference pixels of the current block may be determined by at least one column of reconstructed pixels in the left adjacent area, the upper adjacent reference pixels of the current block may be determined by at least one row of reconstructed pixels in the upper adjacent area, the upper-left adjacent reference pixels of the current block may be determined by at least one column of reconstructed pixels in the upper-left adjacent area, and so on. This is not specifically limited here.
[0253] Furthermore, the template type can be classified according to whether the adjacent reference pixels are available and the template type of the current block can be determined. In some embodiments, determining the template type of the current block can include:
[0254] If both the left adjacent reference pixels of the current block and the upper adjacent reference pixels of the current block are available, the code stream is decoded to determine the template type of the current block.
[0255] It should be noted that, in an embodiment of the present application, the template type of the current block can be preset or determined by decoding the code stream. Among them, if the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block, and the upper left adjacent reference pixels of the current block are all available, the template type of the current block is determined to be the first type value; if the left adjacent reference pixels of the current block are available, the template type of the current block is determined to be the second type value; if the upper adjacent reference pixels of the current block are available, the template type of the current block is determined to be the third type value. For example, if both the left adjacent reference pixels and the upper adjacent reference pixels are available, the second or third type templates can also be used. In this case, the code stream can be used to specify which template to use.
[0256] In the embodiment of the present application, the first type value, the second type value, and the third type value can be different. For example, the first type value can be set to 1, the second type value can be set to 2, and the third type value can be set to 3. In addition, for these three template types, please refer to (a), (b), and (c) in Figure 16 for details.
[0257] It should also be noted that, in the embodiment of the present application, the template type of the current block is generally L-type, i.e. (a) in FIG16 . For an L-type template, it can be composed of the left adjacent reference pixels of the current block and the upper adjacent reference pixels of the current block, or it can be composed of the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block, and the upper left adjacent reference pixels of the current block. Among them, the upper left adjacent reference pixels generally do not need to be specifically pointed out, because in practice, the L-type template may not include the upper left pixels; in other words, when both the left and upper pixels are available, the upper left adjacent pixels are also available.
[0258] In some embodiments, determining the first template of the current block according to the template type of the current block may include: obtaining the template pixels of the current block according to the template type of the current block and the corresponding template size; and determining the template pixels of the current block as the first template of the current block.
[0259] In the embodiment of the present application, the template size may be pre-set, or may be determined according to the size of the current block, or may even be related to the template type of the current block, which is not specifically limited here.
[0260] For example, if the template type indicates that only the left template is to be obtained, the template width templateW_size may be set to 4; if the template type indicates that only the upper template is to be obtained, the template height templateH_size may be set to 4.
[0261] In addition, the value of the template type can determine which part of the reconstructed pixels the first template obtains. For example, when the value of refTemplateType is 1, the left, upper left, and upper reconstructed pixels of the current block are obtained; when the value of refTemplateType is 2, only the left four columns of reconstructed pixels of the current block are obtained; when the value of refTemplateType is 3, only the upper four rows of reconstructed pixels of the current block are obtained.
[0262] It should also be noted that in this embodiment of the present application, the template type of the current block can also be written into the bitstream. In this way, at the decoding end, the template type of the current block can be determined by decoding the bitstream. Then, based on the template type, the first template of the current block can be determined. This is not limited to any specific method.
[0263] Understandably, in the embodiments of this application, for the IBC mode, a block vector candidate list needs to be constructed. Taking the IBC merge candidate list construction process as an example, the IBC ABVP candidate list construction process is essentially the same as the IBC merge process, but the maximum number of candidates differs. For example, the IBC merge candidate list length can be defined as 6, and the IBC ABVP candidate list length can be defined as 2.
[0264] In some embodiments, determining a block vector candidate list for a current block may include: determining at least one first candidate block vector adjacent to the current block based on a derivation method of spatial block vector candidates; adding the at least one first candidate block vector to the block vector candidate list; and if the number of candidates in the block vector candidate list meets a preset threshold, using the current block vector candidate list as the block vector candidate list for the current block.
[0265] It should be noted that in building the block vector candidate list, the spatial candidate derivation is performed first. Specifically, when the usage conditions are met (for example, the size condition IsGt4by4 is equal to TRUE: the variable IsGt4by4 is TRUE when the luma width multiplied by the height is greater than 16), the derivation process of the spatial block vector candidates from the adjacent coding units specified in the decoding specification is called using the luma coding block position (xCb, yCb), the luma coding block width cbWidth and the height cbHeight as inputs, and the output is the availability flags such as availableFlagA1, availableFlagB1 and the block vectors bvA1 and bvB1.
[0266] The availability check for each candidate is as follows: the following conditions are determined. If all of them are true, the candidate is available:
[0267] Whether the offset position obtained by adding the current block position to the BVP does not exceed the image boundary;
[0268] Whether the current block position plus the block position pointed to by BVP does not overlap the current block;
[0269] Whether the offset position obtained by adding the current block position to the BVP does not exceed the IBC available area;
[0270] Whether the current block position plus the block position pointed to by BVP has been rebuilt;
[0271] It should also be noted that, in the embodiment of the present application, taking FIG. 3 as an example, the relative positions of the adjacent blocks where A1 and B1 are located and the current block are shown in FIG. 3 , and the traversal order in FIG. 3 may be A1->B1->B0->A0->B2.
[0272] Secondly, the spatial domain candidates are added to the candidate list. When the usage conditions are met (for example, the size condition IsGt4by4 is equal to TRUE), the block vector candidate list bvCandList is constructed as follows:
[0273] i=0;
[0274] if(availableFlagA1);
[0275] bvCandList[i++]=bvA1;
[0276] if(availableFlagB1);
[0277] bvCandList[i++]=bvB1;
[0278] …
[0279] Next, check the number of valid candidates in the block vector candidate list. The variable numCurrCand (the number of candidates currently obtained) is derived as follows:
[0280] If the usage condition is met (eg, the size condition IsGt4by4 is equal to TRUE), numCurrCand is set equal to the number of candidates in bvCandList; otherwise, numCurrCand is set to 0.
[0281] Furthermore, in some embodiments, the method may also include: if the number of candidates in the block vector candidate list does not meet a preset threshold, determining at least one second candidate block vector based on the derivation method of historical block vector candidates, and continuing to add the at least one second candidate block vector to the block vector candidate list; if the number of candidates in the block vector candidate list meets a preset threshold, using the current block vector candidate list as the block vector candidate list for the current block.
[0282] It should also be noted that if the candidate list does not reach the specified number of items (for example, the specified number of items in IBC merge mode is 6, and the specified number of items in IBC ABVP mode is 2), the historical candidate item derivation, availability detection and addition will continue:
[0283] When numCurrCand is less than MaxNumIbcMergeCand (the maximum number of candidates in IBC merge mode) and NumHmvpIbcCand (the maximum number of candidates for the historical best block vector (Hmvp) in IBC mode) is greater than 0, the derivation process of the history-based IBC block vector candidates specified in the decoding specification is called with bvCandList and numCurrCand as input and the modified bvCandList and numCurrCand as output.
[0284] Furthermore, in some embodiments, the method may also include: if the number of candidates in the block vector candidate list does not meet a preset threshold, determining at least one third candidate block vector based on a derivation method of other available candidates, and continuing to add the at least one third candidate block vector to the block vector candidate list until the number of candidates in the block vector candidate list meets the preset threshold.
[0285] In an embodiment of the present application, other available candidate derivation methods may include at least one of the following: a method for deriving paired average candidates, a method for deriving zero-value block vector candidates, and a method for deriving reference area candidates corresponding to intra-frame block copies.
[0286] It should also be noted that after adding at least one second candidate block vector to the block vector candidate list, continue to check the number of valid items in the candidate list and add other available candidates (such as pairwise average candidates, zero-value BV candidates, etc.) until the specified number of items is reached.
[0287] For example, other available candidates are as follows:
[0288] (1) The pairwise average candidate can be constructed by using the first and second candidate items, specifically: mvAvgLX=(mvCand0LX+mvCand1LX+1)>>1
[0289] (2) The zero value BV can be directly set to:
[0290] bvCandList[numCurrCand][0] is set equal to 0. (horizontal component of bv)
[0291] bvCandList[numCurrCand][1] is set equal to 0. (vertical component of bv)
[0292] (3) A set of BVP candidates located in the IBC reference area can also be used as candidates that can be added. The coordinates of a set of BVP candidates are determined by the width and height of the current block and the ΔX and ΔY parameters, as shown in Figure 4.
[0293] It should also be noted that, in the embodiment of the present application, each time an item is added, numCurrCand increases by 1. In this way, until numCurrCand meets the preset threshold, the basic block vector candidate list bvCandList is established.
[0294] Furthermore, after the block vector candidate list is constructed, the method may further include: after determining the block vector candidate list of the current block, sorting the block vector candidate list.
[0295] It should be noted that in an embodiment of the present application, in the IBC merge mode, the order of the list can also be reordered using a template, the order of the candidate list can be adjusted, the high spatial correlation can be fully utilized, the coding bit transmission can be reduced, and the coding efficiency can be effectively improved. For example, for the IBC merge mode, after the intermediate candidate list is constructed according to the above list construction method (note that the length of the intermediate candidate list can be greater than or equal to the maximum number of candidates in the IBC merge mode), all the candidates in the list are reordered using the template, and sorted in order from small to large according to the template matching cost, and the first N (for example, N = 6) candidates in the sorted list are selected. The specific process is as follows: the SAD of the template position of the reference block pointed to by each candidate and the template position of the current block (as shown in Figure 5) is calculated, and they are arranged in ascending order, and the first 6 candidates are selected as the candidate list for IBC merge.
[0296] Furthermore, after the block vector candidate list is constructed, the method may further include: after determining the block vector candidate list of the current block, removing redundancy according to the distances between the candidate block vectors in the block vector candidate list.
[0297] It should be noted that, in an embodiment of the present application, removing redundancy may include: if the current block selects the non-flipped intra-frame block copy mode, then when the distance between at least two candidate block vectors in the block vector candidate list meets a preset condition, deleting at least one of the at least two candidate block vectors.
[0298] It should also be noted that in the embodiment of the present application, the IBC ABVP mode can also be used to remove candidate redundancy based on the distance of the candidate items: the number of candidates remains unchanged at two, and candidate lists are established for integer pixel and 4-pixel precision respectively.
[0299] If non-RRIBC mode is selected for IBC ABVP, and if the number of valid BVP candidates exceeds two, up to six BVP candidates in the candidate list are clustered according to the Euclidean distance between them, with the radius (R) being a set of block vectors determined as a logarithmic function of the width (cbWidth) and height (cbHeight) of the current block. If the Euclidean distance between the reference positions pointed to by several BV candidates is less than R, they are clustered: R = log2((cbWidth·cbHeight)>>MIN_PU_SIZE).
[0300] Furthermore, in some embodiments, the method may further include: if the flipped intra block copy mode is selected for the current block, adjusting the candidate block vectors in the block vector candidate list to point to a boundary of a valid block copy search area according to a preset direction of the flipped intra block copy mode. In other words, if the RRIBC mode is selected for the IBC ABVP, the candidate vectors may be adjusted to point to a boundary of a valid IBC search area according to the horizontal or vertical direction of the RRIBC mode.
[0301] In this way, the block vector candidate list is constructed.
[0302] S1502: Decode the code stream, determine block vector indication information, and determine a first block vector according to the block vector indication information and the block vector candidate list.
[0303] It should be noted that in the embodiment of the present application, the block vector indication information may be different for different prediction modes, for example, it may be a block vector index number, a block vector difference value, etc., which is not specifically limited here.
[0304] In one possible implementation, the block vector indication information may include a block vector index number. Determining the first block vector based on the block vector indication information and the block vector candidate list may include: determining a candidate block vector corresponding to the block vector index number in the block vector candidate list; and using the candidate block vector as the first block vector.
[0305] For example, in IBC merge mode, the specific bvL can be obtained according to the block vector index number bvIdx and the block vector candidate list bvCandList: bvL[0]=bvCandList[bvIdx][0]; bvL[1]=bvCandList[bvIdx][1];
[0306] This bvL is the final BV.
[0307] In another possible implementation, the block vector indication information includes a block vector index number and a block vector difference value. Determining the first block vector based on the block vector indication information and the block vector candidate list may include: determining a candidate block vector corresponding to the block vector index number in the block vector candidate list; and determining the first block vector based on the candidate block vector and the block vector difference value.
[0308] For example, for the IBC ABVP mode, the bvL obtained by the block vector index number bvIdx and the block vector candidate list bvCandList is the predicted bvL. The actual bvL also needs to be added with the block vector difference (BVD). The generalized specific process is as follows:
[0309] Step 1: Get the horizontal and vertical components of BVD, where MvdL0 is the forward motion vector difference. bvd[0] = MvdL0[xCb][yCb][0]; bvd[1] = MvdL0[xCb][yCb][1].
[0310] Step 2: Round the predicted bvL obtained above, where the right shift parameter AmvrShift is used for rounding and the left shift parameter AmvrShift is used to improve the resolution. Specifically: offset = (AmvrShift == 0)? 0: ((1 << (AmvrShift-1))-1); bvL[0] = Sign(bvL[0])*(((Abs(bvL[0])+offset)>>AmvrShift)<<AmvrShift); bvL[1]=Sign(bvL[1])*(((Abs(bvL[1])+offset)> >AmvrShift)< <AmvrShift)。
[0311] Step 3: The true bvL is derived as follows, and its range needs to be controlled between -217 and 217–1: u[0]=(bvL[0]+bvd[0]+218)%218; bvL[0]=(u[0]>=217)?(u[0]-218):u[0]; u[1]=(bvL[1]+bvd[1]+218)%218; bvL[1]=(u[1]>=217)?(u[1]-218):u[1].
[0312] It should be noted that the method of obtaining BVD in step 1 can also be inferred from syntax elements obtained through other encoding methods. The BVD of IBC ABVP uses sub-pixels, whole pixels or 4 pixels as units. During encoding, its symbol can be predicted, and the suffix of the exponential Golomb code obtained after its binarization can also be predicted. Therefore, its syntax elements can be defined by multiple information of the BVD value: whether it is 0, prefix, symbol, and suffix. The combination and analysis of these information can obtain the actual value of BVD. The specific embodiments are as follows:
[0313] It should also be noted that the identification of whether BVD is 0 uses context coding. The value of (absolute value -1) is binarized using first-order exponential Columbus, the first 5 binary data (bin) of the EG1 prefix are context coded, and the remaining prefixes are bypass coded. Up to 4 bins of the EG1 suffix use context coding to transmit the prediction index, and the other bins of the EG1 suffix use bypass coding. The two bins of the sign bit use context coding to transmit the symbol prediction index. Figure 8 is a schematic diagram of the relationship between a block vector (BV), a block vector prediction (BVP) and a block vector difference (BVD). As shown in Figure 8, here is a prediction process for a suffix bin with a transmission prediction index in the horizontal and vertical directions, and a bin with a transmission symbol index in the horizontal and vertical directions. The current block template and the template at the corresponding BV are sorted to derive the prediction index of the suffix and the symbol.
[0314] In another possible implementation, the block vector indication information includes a block vector index number. Determining the first block vector based on the block vector indication information and the block vector candidate list may include: determining a candidate block vector corresponding to the block vector index number in the block vector candidate list; determining a first candidate set based on the candidate block vectors and predefined parameters; and performing a block vector search within the first candidate set to determine the first block vector.
[0315] For example, in the IBC MBVD mode, similar to the MMVD in the inter-frame technology of VVC, a candidate in the IBC merge list is used as the starting point, and a candidate is selected from the candidate point set corresponding to the predefined distance and direction set, and its corresponding block vector is used as the final BV.
[0316] For example, in IBC MBVD, the distance set is defined as {1-pel, 2-pel, 4-pel, 8-pel, 12pel, 16pel, 24pel, 32pel, 40pel, 48pel, 56pel, 64pel, 72pel, 80pel, 88pel, 96pel, 104pel, 112pel, 120pel, 128pel}, and the BVD directions are positive and negative horizontal directions and positive and negative vertical directions.
[0317] In this way, the base candidate can be selected from the first five candidates in the reordered IBC merge list, and all possible MBVD refinement positions (i.e., 20×4 candidates) of each base candidate are reordered based on the SAD cost between the template and its reference at each refinement position. Finally, the first 8 refinement positions with the smallest template SAD are retained for MBVD index encoding. The IBC-MBVD candidates do not inherit the flip type from the RR-IBC encoded neighboring blocks. The MBVD index is binarized using a Rice code with parameter equal to 1.
[0318] In another possible implementation, the block vector indication information includes a block vector index number. Determining the first block vector based on the block vector indication information and the block vector candidate list may include: determining a candidate block vector corresponding to the block vector index number in the block vector candidate list; determining a first search area centered on the candidate block vector, and searching within the first search area based on template matching to determine the first block vector.
[0319] In the IBC TM merge mode, after obtaining the bvL based on the above information, the TM can also be used to locally refine the BV. The specific operation is to search within a small range centered on the obtained bvL and select the optimal BV within the range as the final BV based on the minimum template matching cost.
[0320] The TM refinement of the candidate list for the IBC merge mode is carried out. The specific implementation process is as follows:
[0321] When building a candidate, the flip type defaults to no flip;
[0322] IBC TM merge mode In IBC merge mode, the transmission syntax element specifies whether to perform integer-pixel precision TM refinement. The location of the refined motion vector and the template used in each refinement step must comply with the reference area constraints.
[0323] A search is performed near the candidate's pointed position, using the SAD between the template of the reference block and the template of the current block to determine the optimal position. This includes, but is not limited to, the following search methods: the search range is [-8, 8], and a diamond search is first performed on integer pixels, searching eight points near the center position, as shown in Figures 7A and 7B. The maximum number of searches is 375. After the optimal position is determined for the first time, the search continues, searching five points at even-numbered positions and three points at odd-numbered positions in subsequent searches.
[0324] After the above diamond search process, a whole-pixel cross search is performed only once. That is, after the diamond search finds the current optimal position, four positions with a distance of one pixel below, to the right, above, and to the left of the current optimal position are checked to update the final optimal position, that is, to update the refined candidate list.
[0325] It should be noted that, in the embodiment of the present application, the BV finally derived should be within the specified range (coordinate range in rows and columns), as shown in Figures 9, 10 and 11.
[0326] It is understood that in the embodiment of the present application, the first block vector can be a luminance block vector or a chrominance block vector, and is not specifically limited here. If the first block vector is a luminance block vector, the luminance block vector is used to determine the prediction value of the current block based on the luminance component; if the first block vector is a chrominance block vector, the chrominance block vector is used to determine the prediction value of the current block based on the luminance component.
[0327] Furthermore, in the IBC mode for chroma components, a chroma block vector can be derived based on the luma block vector. In one possible implementation, the first block vector is a luma block vector, and the method may further include: scaling the luma block vector according to a preset chroma sampling format to determine a chroma block vector; wherein the chroma block vector is used to determine a prediction value based on the chroma component of the current block.
[0328] In another possible implementation, the first block vector is a luminance block vector, and the method may further include: scaling the luminance block vector according to a preset chroma sampling format to determine a scaled block vector; correcting the scaled block vector to determine a chroma block vector; wherein the chroma block vector is used to determine a predicted value of the current block based on the chroma component.
[0329] In the embodiment of the present application, the process of deriving the chromaticity BV based on the luminance BV is as follows:
[0330] Input: bvL (luminance) (1 / 16 pixel accuracy); Output: bvC (Block Vector Chroma) (1 / 32 pixel accuracy).
[0331] The derivation process may be direct scaling, or scaling followed by refinement using TM, which is not specifically limited here.
[0332] For the scaling operation, an example is as follows: bvC[0]=((bvL[0]>>(3+SubWidthC))*32); bvC[1]=((bvL[1]>>(3+SubHeightC))*32).
[0333] The variables SubWidthC and SubHeightC depend specifically on the chroma format sampling structure specified by sps_chroma_format_idc. For specific correspondence, see Table 1, which shows the correspondence between sps_chroma_format_idc and the chroma format sampling structure.
[0334] The refinement operation can include the following methods: using TM for refinement, that is, after obtaining the luma BV, using the position of the chroma block and the BV to find the offset position, using a template to perform a detailed search near the offset position, and obtaining the optimal BV (i.e., the refined BV) with the minimum TMcost as the criterion. As shown in Figure 12, the area filled with diagonal lines represents the chroma reconstruction area. For the current block, template matching can be used to find the best matching template and the corresponding refined BV. The reference block at the optimal offset position obtained based on the refined BV is copied, and the chroma prediction value of the current block can be determined.
[0335] S1503: Determine a matching template and a corresponding reference block according to the first block vector.
[0336] It should be noted that, in the embodiment of the present application, after determining the first block vector, a matching template and a corresponding reference block may be determined based on the first block vector. In some embodiments, determining the matching template and the corresponding reference block based on the first block vector may include:
[0337] Determine a reference template and a corresponding reference block according to the first block vector;
[0338] If the reference template meets the first preset condition, a first process is performed on the adjacent area of the reference template to determine a matching template.
[0339] In some embodiments, determining a matching template and a corresponding reference block according to the first block vector may include:
[0340] Determine a reference template and a corresponding reference block according to the first block vector;
[0341] If the reference template meets the second preset condition, the reference template is used as the matching template.
[0342] It should also be noted that, in the embodiment of the present application, the matching template may include: sampling points in the reference template and sampling points in an adjacent area of the reference template.
[0343] It should also be noted that, in an embodiment of the present application, the available reconstructed pixels can be determined based on the template type refTemplateType of the current block. For example, when the template type refTemplateType is 1, as shown in FIG17 , it indicates that the adjacent left, upper left, and upper reconstructed pixels are available, the number of available reconstructed pixels on the left is templateW_size*nTbH, the number of available reconstructed pixels on the upper side is templateH_size*nTbW, and the number of available reconstructed pixels on the upper left is templateW_size*templateH_size.
[0344] In an embodiment of the present application, the first preset condition is different from the second preset condition. In some embodiments, the method may further include: if sampling points outside the reference template and the reference block are used, determining that the reference template meets the first preset condition.
[0345] In some embodiments, the method may further include: if no sampling points outside the reference template and the reference block are used, determining that the reference template meets a second preset condition.
[0346] It should be noted that in the embodiments of this application, considering that the filter may use reconstructed pixels outside the reference template and reference block, it is necessary to fill the boundary pixels. Depending on the filter shape, the area of the boundary that needs to be filled varies. One boundary filling area is shown in Figure 18A, and another boundary filling area is shown in Figure 18B. The grid area is the area that needs to be filled.
[0347] In some embodiments, when the reference template meets the first preset condition, performing a first process on the adjacent area of the reference template may include: if sampling points outside the reference template and the reference block are used, filling the sampling points in the adjacent area of the reference template.
[0348] In the embodiment of the present application, for the filling process, it is first necessary to determine whether the sampling points of the adjacent area of the reference template are available. In some embodiments, the filling process of the sampling points of the adjacent area of the reference template may include:
[0349] Determine whether the sampling points in the adjacent area of the reference template are available;
[0350] If the sampling points of the adjacent area of the reference template are available, the sampling points of the adjacent area of the reference template are directly used;
[0351] If the sampling points of the adjacent area of the reference template are not available, the adjacent area of the reference template is filled by copying the sampling points of the adjacent reference template or the reconstructed sampling points in the adjacent reference block to obtain the sampling points of the adjacent area of the reference template.
[0352] It should be noted that the sampling points in the adjacent area of the reference template are available and may include at least one of the following:
[0353] The sampling point does not exceed the preset search range;
[0354] The sampling points do not exceed the image boundary;
[0355] The sampling point does not exceed the tile boundary;
[0356] The sampling points have been rebuilt.
[0357] In embodiments of the present application, the filling process can also be performed directly by copying the sampling points in the adjacent area of the reference template without determining whether the sampling points in the adjacent area of the reference template are available. In some embodiments, filling the sampling points in the adjacent area of the reference template can include directly copying the reconstructed sampling points in the adjacent reference template or adjacent reference block of the sampling points to fill the adjacent area of the reference template to obtain the sampling points in the adjacent area of the reference template. It should be noted that "directly copying" here means that there is no need to determine whether the sampling points in the adjacent area of the reference template are available.
[0358] In some embodiments, for the filling process, the method may further include: if sampling points outside the reference template and the reference block are used, then the filling process is not performed on the sampling points in the adjacent area of the reference template, and the sampling points are skipped when determining the model parameters.
[0359] That is, there are also multiple different methods for filling processing in the embodiments of the present application. One filling method is to determine whether the grid area is available. If it is available, the reconstructed pixels are directly used; if it is not available, the reconstructed pixels of the adjacent reference template or reference block are copied to fill the grid area. Alternatively, another filling method is to not consider whether the grid area is available and directly copy the reconstructed pixels of the adjacent reference template or reference block to fill the grid area. Alternatively, another filling method can also not fill, but instead abandon the use of the corresponding data in the calculation when encountering the boundary position; this is not specifically limited here.
[0360] S1504: Determine model parameters according to the first template and the matching template, and perform filtering processing on the reference block according to the model parameters to determine a filtered reference block.
[0361] It should be noted that in the embodiment of the present application, after determining the number of available reconstruction pixels, the reconstruction area for calculating the filter coefficients (i.e., model parameters) is determined based on the available reconstruction pixels. This area is called R, and R usually includes all available reconstruction pixels in the template. For example, when refTemplateType is 1, R includes all available reconstruction pixels on the left, upper left, and upper sides.
[0362] It should also be noted that, in the embodiment of the present application, the model parameters may include coefficients of the target filter. In some embodiments, the method may further include: determining the coefficients of the target filter based on the pixel reference values in the first template and the pixel reference values in the matching template.
[0363] It should also be noted that, in embodiments of the present application, the coefficients of the target filter may be determined by solving an optimization problem. Accordingly, in some embodiments, the method further includes: the coefficients of the target filter are the coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after being processed by the target filter and a pixel reference value in the first template satisfies a first condition.
[0364] It should be understood that for the first error to satisfy the first condition, in one possible implementation, the first condition is that the first error is minimized. Alternatively, in another possible implementation, the first condition is that the first error is within a first preset threshold range. Alternatively, in yet another possible implementation, the first condition is that the change in the first error is within a second preset threshold range.
[0365] It should also be understood that the first preset threshold range and the second preset threshold range are both metrics preset by the decoding end for determining whether the first error satisfies the first condition. Furthermore, the first error herein may be a mean square error (MSE), or may be a sum of squared error (SSE), or may be a sum of absolute error (SAD), or may be a sum of absolute error (SATD) after a Hadamard-transformed error (HATD), or may be a mean absolute error (MAE), etc., and this embodiment of the present application does not specifically limit this.
[0366] In some embodiments, determining coefficients of a target filter based on pixel reference values in the first template and pixel reference values in the matching template may include:
[0367] Determining autocorrelation parameters based on pixel reference values in the matching template;
[0368] determining a cross-correlation parameter based on the pixel reference value in the first template and the pixel reference value in the matching template;
[0369] The coefficients of the target filter are determined according to the autocorrelation parameters and the cross-correlation parameters.
[0370] It should be noted that, in the embodiment of the present application, the pixel reference value includes at least one of the following: a pixel reconstruction value, a pixel gradient value, and pixel position information.
[0371] That is, in the embodiment of the present application, the target filter is used as the filter model of the embodiment of the present application, and the input information of the target filter is the pixel reference value in the matching template. Here, the coefficient of the target filter can be expressed as c k,l, which may also be referred to as filter coefficients in this embodiment. The input information used to calculate the filter coefficients may be the available reconstructed pixels of the matching template; or, the gradient of each reconstructed pixel in the matching template, including but not limited to horizontal gradients and vertical gradients, may be calculated, and the calculated gradients may be used as the input information for calculating the filter coefficients; or, the position information of each reconstructed pixel may be used as the input information for calculating the filter coefficients. The position information may be the absolute position information of each reconstructed pixel in the entire image, or the relative position information of each reconstructed pixel relative to a reference point; this is not specifically limited here.
[0372] In a specific embodiment, a reconstruction region R for calculating the filter coefficients is first determined, and then a set of filter coefficients can be derived by minimizing the MSE between the reconstructed pixels in the region R and the reconstructed pixels of the first template, that is: MSE = E[(predTemp[i][j]-recTemp[i][j])2] = E[(∑ k,l=-1~1 c k,l ·refTemp[i+k][j+l]-recTemp[i][j]) 2 ] (3)
[0373] Where refTemp[i][j] represents the input reconstructed pixel value, recTemp[i][j] represents the reconstructed pixel value of the current block template, (i,j) represents the coordinate position, (i,j)∈R, k,l represents the coordinate offset of the filter coefficient position relative to the filter center position, where k and l are between -1 and 1, and the values of (k,l) can include (0,0), (0,-1), (-1,0), (0,1), (1,0), c k,l Indicates the required filter coefficient. In addition, E represents the operation of calculating the average value. The calculation formula at this time is as follows:
[0374] Among them, N pos Refers to the calculation of |predTemp[i][j]-recTemp[o][j]| 2 For example, if there are 5 (i, j) pairs involved in the operation, then N pos The value of is equal to 5.
[0375] Furthermore, the process of minimizing MSE to derive the filter coefficients is as follows:
[0376] First, for c k,l Find the partial derivative and make it 0, that is:
[0377] Among them, k and l are between -1 and 1, and m and n are between -1 and 1.
[0378] Secondly, according to formula (5) and formula (6), we can get:
[0379] Once again, after determining the reconstruction region R, the obtained equation (7) is expanded into a matrix form, as follows:
[0380] Among them, for A, the pixel reference value in the matching template is represented by refTemp[i][j], and A represents the autocorrelation parameter of refTemp[i][j], as follows
[0381] For B, the pixel reference value in the first template is represented by recTemp[i][j], and B represents the cross-correlation parameter of recTemp[i][j] and refTemp[i][j], as follows:
[0382] That is to say, since the autocorrelation matrix of refTemp and the cross-correlation vector of refTemp and recTemp in the reconstruction area R are known, the filter coefficient c can be calculated by solving the equation group shown in formula (7): k,l , for the filter coefficient c k,l It can be fixed-point or not.
[0383] In the embodiment of the present application, for the target filter, it is also necessary to determine the number of coefficients of the target filter and the shape of the target filter, etc. The number of coefficients of the target filter and the shape of the target filter can be preset fixed values or directly determined by the decoded code stream.
[0384] In some embodiments, for the number of coefficients of the target filter, the method may further include: the number of coefficients of the target filter is equal to a first preset value.
[0385] In some embodiments, for the number of coefficients of the target filter, the method may further include: decoding the code stream to determine the number of coefficients of the target filter.
[0386] It should be noted that the number of coefficients of the target filter can be represented by nTap. For example, the value of nTap can be 4, 5, 6, 7, 8, 9, etc., but is not specifically limited.
[0387] It should also be noted that the number of coefficients of the target filter can also be called the target filter tap number. Here, the number of coefficients of the target filter can be a preset constant value, or it can be determined by decoding the code stream, or even determined based on the syntax element identification information of the current block.
[0388] In some embodiments, regarding the shape of the target filter, the method may further include: the target filter is a one-dimensional or two-dimensional filter of a preset shape.
[0389] In some embodiments, regarding the shape of the target filter, the method may further include: decoding the code stream to determine the shape of the target filter.
[0390] In some embodiments, regarding the shape of the target filter, the method may further include: decoding the code stream, and determining a value of a filter shape parameter, wherein the filter shape parameter indicates the shape of the target filter.
[0391] It should be noted that the filter shape parameter can be represented by FilterIdx, which is used to indicate the shape of the target filter. In the embodiment of the present application, the shape of the target filter can be diamond, rectangle, cross, stripe, or even a one-dimensional filter or a two-dimensional filter, but is not specifically limited thereto.
[0392] Exemplarily, if the value of FilterIdx is equal to 0, the shape of the target filter is determined to be a diamond; if the value of FilterIdx is equal to 1, the shape of the target filter is determined to be a cross; if the value of FilterIdx is equal to 2, the shape of the target filter is determined to be a rectangle.
[0393] For example, Figure 19 is a schematic diagram of the shape of a filter provided in an embodiment of the present application. As shown in Figure 19, the filter is cross-shaped, and the number of taps of the filter is 5. Here, the number of taps of the filter can be dynamically adjusted according to the size of the current block.
[0394] It should also be noted that the shape of the target filter may be a preset shape, or may be determined by decoding a code stream, or may even be determined according to syntax element identification information of the current block.
[0395] It should be noted that in the embodiment of the present application, after the model parameters are determined, the prediction value of the current block can be determined based on the model parameters and the reference block. Specifically, the reference block is filtered according to the model parameters, and the prediction value of the current block is determined based on the filtered reference block.
[0396] In some embodiments, filtering the reference block according to the model parameters to determine the filtered reference block may include: filtering the reference block according to the model parameters to determine the first output value of the target filter; and determining the filtered reference block based on the first output value of the target filter.
[0397] In some embodiments, filtering the reference block according to the model parameters to determine the filtered reference block may include: if sampling points of an adjacent region of the reference block are used, then padding the sampling points of the adjacent region of the reference block. In other words, in the embodiments of the present application, if sampling points of an adjacent region of the reference block are used, padding the sampling points of the adjacent region of the reference block is required.
[0398] In the embodiment of the present application, a first output value of the target filter can be calculated based on the pixel reconstruction values of the reference block and the coefficients of the target filter in the model parameters. Then, based on the first output value of the target filter, the filtered reference block can be determined. The target filter can be a linear or nonlinear filter model, without specific limitation.
[0399] In one possible implementation, filtering the reference block according to the model parameters to determine the first output value of the target filter may include:
[0400] Calculating the product of the pixel reconstruction value of the reference block and the coefficient of the corresponding target filter;
[0401] The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter and n is a positive integer.
[0402] It should be noted that the target filter in the embodiment of the present application is a linear filter model. The first output value of the target filter can be calculated by the following formula: pred [i][j]=∑ k ∑ l ref[i+k][j+l]×C k,l (11)
[0403] Where ref[i+k][j+l] represents the pixel reconstruction value of the reference block, C k,l Represents the coefficients of the target filter.
[0404] In another possible implementation, filtering the reference block according to the model parameters to determine the first output value of the target filter may include:
[0405] Determine a first value of a pixel reconstruction value of the reference block under a first mapping relationship;
[0406] Calculating the product of the first value and the coefficient of the corresponding target filter;
[0407] The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter and n is a positive integer.
[0408] It should be noted that the target filter in the embodiment of the present application is a nonlinear filter model. For example, when minimizing the MSE of the filter coefficient, the calculation formula is adjusted as follows:
[0409] Then the first output value of the target filter can be calculated by the following formula: pred [i][j]=∑ k ∑ l (ref[i+k][j+l]) 2 ×C k,l (13)
[0410] Where ref[i+k][j+l] represents the pixel reconstruction value of the reference block, C k,l Represents the coefficients of the target filter.
[0411] It should also be noted that, in the embodiment of the present application, the filtered reference block is determined based on the first output value of the target filter. The first output value of the target filter can be directly set as the filtered reference block; or the first output value of the target filter can be subjected to a first filtering to obtain the filtered reference block; the first filtering here can be a low-pass filter, an up / down sampling filter, etc., which is not specifically limited here.
[0412] It should also be noted that, in the embodiment of the present application, after determining the first output value of the target filter, a first offset value (expressed as bias) may be added to the first output value to determine a filtered reference block.
[0413] In some embodiments, determining a filtered reference block based on a first output value of a target filter may include: determining a first offset value; and performing an addition operation based on the first output value and the first offset value to determine the filtered reference block.
[0414] In a possible implementation, determining the first offset value may include: setting the first offset value to be equal to a second preset value.
[0415] In another possible implementation, determining the first offset value may include: determining the number of pixels participating in filtering corresponding to the target filter based on the shape of the target filter; if the number of pixels of the reference filter corresponding to the target filter is m, determining m+1 coefficients of the target filter, where m is a positive integer; and determining the first offset value based on one of the m+1 coefficients and the second offset value.
[0416] In this embodiment of the present application, the target filter has m pixels participating in the filtering operation. However, considering the second offset value, the target filter needs to determine m+1 coefficients. A weighted calculation is then performed on the m pixels participating in the operation and the second offset value based on these m+1 coefficients. The coefficient used for the second offset value can be the m+1th coefficient, but other coefficients are also possible, and this is not specifically limited here.
[0417] In an embodiment of the present application, for the second offset value, the method may further include: setting the second offset value equal to a third preset value; or setting the second offset value equal to the value of the pixel reconstruction value of the reference block under the second mapping relationship.
[0418] It should be noted that the second mapping relationship may be a linear mapping relationship or a nonlinear mapping relationship, and there may be multiple nonlinear mapping relationships, which are not specifically limited here.
[0419] In the embodiment of the present application, the calculated filter coefficients are used as the number of taps corresponding to the filter template, that is, the number of filter coefficients is equal to the number of taps of the filter template nTap. In addition, several bias terms bias can be added to the filter template. For example, in the embodiment of the present application, when nTap = 5, the filter coefficients are the tap coefficients c0 to c4 corresponding to the filter template. The predicted value of the position (i, j) in the filtered reference block is calculated as follows:
[0420] At this time, the bias term can be added, as shown in the following formula:
[0421] In the embodiment of this application, c n =c i,j,k,lHere, Constant can be a fixed constant, such as Constant = 1 << (BitDepth - 1), or a number related to the reconstructed pixel value at the (i, j) position in the reference block, such as Constant = f(ref[i][j]), or a number related to the reconstructed pixel value corresponding to a certain tap in the filter template except at the (i, j) position, such as Constant = f(ref[k][l]). Among them, Constant = f(ref[i][j]) or Constant = f(ref[k][l]) can be a linear mapping relationship or a non - linear mapping relationship. The bias term can be added one or more, and no specific limitation is made here.
[0422] S1505: Determine the predicted value of the current block according to the filtered reference block.
[0423] It should be noted that in the embodiments of the present application, determining the predicted value of the current block according to the filtered reference block may include: performing a second processing on the filtered reference block to obtain the predicted value of the current block.
[0424] In the embodiments of the present application, for the second processing, the second processing can be setting the predicted value of the current block to be equal to the filtered reference block; or, the second processing can be a clamping (clip) operation that limits the filtered reference block within a preset numerical range, or, the second processing can also be other operations, which are not specifically limited here.
[0425] Exemplarily, assume that the number of taps nTap of the filter is 5, and the shape of the filter is shown in Figure 20A. C0 to C4 are the respective tap coefficients of the filter. The filled dot corresponding to the tap coefficient C0 in the grid is the current pixel Y to be predicted pred [i][j] The reconstructed pixel ref[i][j] at the corresponding position in the reference block; the remaining filled white dots are the reconstructed pixels adjacent to the current spatial position in the reference block. Thus, according to the filter in Figure 20A, the finally obtained predicted pixel Y pred [i][j] is shown as the filled black dot in Figure 20B.
[0426] In addition, in the embodiments of the present application, for the clip operation, the preset numerical range here can be: between 0 and (1 << BitDepth) - 1, where BitDepth represents the bit depth. If the value of the filtered reference block exceeds the value range of this preset numerical range, then the filtered reference block needs to be corrected accordingly. Exemplarily, the filtered reference block can also be represented by Y pred [i][j], and at this time, a correction operation can be performed on Y pred [i][j] as follows:
[0427] When Y pred [i][j] is less than 0, set it to 0;
[0428] When Y pred [i][j] is greater than or equal to 0 and less than or equal to (1 << BitDepth)-1, it is equal to Y pred [i][j];
[0429] When Y pred [i][j] is greater than (1 << BitDepth)-1, set it to (1 << BitDepth)-1.
[0430] In this way, after performing the correction operation on Y pred [i][j], it can be ensured that all pixel values in the filtered reference block are between 0 and (1 << BitDepth)-1.
[0431] Furthermore, the number of filter models can be extended. In addition to only establishing one filter model, multiple filter models can also be established. Therefore, in some embodiments, the method may further include:
[0432] Determine multiple sets of model parameters according to the first template and the matching template;
[0433] Construct multiple filter models according to the multiple sets of model parameters, perform filtering processing on the reference block according to the multiple filter models respectively, and determine multiple filtered reference blocks;
[0434] Determine the predicted value of the current block according to the multiple filtered reference blocks.
[0435] In some embodiments, determining multiple sets of model parameters according to the first template and the matching template may include: classifying the reconstructed pixels in the first template and the matching template respectively according to a preset method to obtain multiple sets of sub-templates and multiple sets of sub-matching templates; determining multiple sets of model parameters according to the multiple sets of sub-templates and multiple sets of sub-matching templates.
[0436] It should be noted that in the embodiments of the present application, the preset method here may be the size of the reconstructed pixel value, or it may also be the position information of the reconstructed pixel, or it may also be the shape of the filter, etc., which is not limited thereto. Among them, after classifying according to the preset method, each set of sub-templates and the corresponding sub-matching templates can calculate a set of model parameters, and each set of model parameters can determine a filter model, so that multiple filter models can be constructed.
[0437] In a possible implementation, the method may further include: decoding the code stream to determine the target model index value; determining the corresponding target filter from multiple filter models based on the target model index value; filtering the reference block according to the target filter to determine the prediction value of the current block.
[0438] In another possible implementation, multiple filtered reference blocks may be determined by filtering the reference blocks according to multiple filter models. In some embodiments, determining the prediction value of the current block based on the multiple filtered reference blocks may include performing a weighted calculation on the multiple filtered reference blocks to determine the prediction value of the current block.
[0439] It should also be noted that if the weights of each filtered reference block are equal and equal to the inverse of the number of reference blocks, then the weighted calculation here can also be regarded as an averaging calculation. In other words, the average of multiple filtered reference blocks is calculated to determine the prediction value of the current block.
[0440] Exemplarily, the input information for calculating the filter coefficients is classified, and a filter model is established for each category of input information. For example, when using reconstruction information to establish a filter model, one possible implementation is to classify by the mean of the reconstruction information, establishing a filter model for reconstruction information greater than the mean, and establishing a filter model for reconstruction information less than the mean. Another possible implementation is to classify by the position of the reconstruction information. For example, a filter model can be established using the available reconstruction information on the left and upper sides, and a second filter model can be established using the available reconstruction information on the left and upper left sides. The encoder decides which model to use. One possible implementation is for the encoder to determine which model to use through rate-distortion optimization and transmit corresponding decoding parameters to the decoder so that the decoder clearly selects which filter model. Another possible implementation is to classify by filter shape. Multiple filters of different shapes can be used, and a filter model is established for each filter shape. The encoder decides which filter shape to use. One possible implementation is for the encoder to determine which filter to use through rate-distortion optimization and transmit corresponding decoding parameters to the decoder so that the decoder clearly selects which filter model.
[0441] It should also be noted that in an embodiment of the present application, after determining the prediction value of the current block, the reconstructed value of the current block can also be restored. In some embodiments, the method may further include: decoding the code stream to determine the prediction residual of the current block; and determining the reconstructed value of the current block based on the prediction value of the current block and the prediction residual of the current block.
[0442] In a specific embodiment, determining the reconstruction value of the current block based on the prediction value of the current block and the prediction difference value of the current block may include: adding the prediction value of the current block and the prediction difference value of the current block to determine the reconstruction value of the current block.
[0443] It should also be noted that, in the embodiment of the present application, whether the current block is applied to the intra block copy or whether it is used for the filter model can be determined by different syntax element identification information. In some embodiments, the method may further include: decoding the bitstream, determining the value of the first syntax element identification information;
[0444] If the first syntax element identification information is used to indicate that the current block applies intra block copy, decoding the code stream to determine the value of the second syntax element identification information;
[0445] If the second syntax element identification information is used to indicate that a filter model is applied to the current block, the steps of filtering the reference block according to the model parameters to determine a filtered reference block and determining a prediction value of the current block according to the filtered reference block are performed.
[0446] Furthermore, in some embodiments, the method may further include: if the second syntax element identification information is used to indicate that the filter model is not applied to the current block, using the reconstructed pixel value in the reference block as the prediction value of the current block.
[0447] In an embodiment of the present application, for the first syntax element identification information, if the value of the first syntax element identification information is a first value, it is determined that the first syntax element identification information is used to indicate that an intra block copy is applied to the current block; or, if the value of the first syntax element identification information is a second value, it is determined that the first syntax element identification information is used to indicate that an intra block copy is not applied to the current block.
[0448] In an embodiment of the present application, for the second syntax element identification information, if the value of the second syntax element identification information is a first value, it is determined that the second syntax element identification information is used to indicate that the filter model is applied to the current block; or, if the value of the second syntax element identification information is a second value, it is determined that the second syntax element identification information is used to indicate that the filter model is not applied to the current block.
[0449] It should be noted that in the embodiment of the present application, the first value and the second value are different, and the first value and the second value can be in parameter form or in numerical form. Specifically, the first syntax element identification information and the second syntax element identification information can be parameters written in the profile or the value of a flag, which is not specifically limited here.
[0450] For example, for the first value and the second value, the first value may be set to 1 and the second value may be set to 0; or, the first value may be set to true and the second value may be set to false; however, this is not specifically limited here.
[0451] It should also be noted that in the embodiment of the present application, whether the current block uses the filtered reference block as the final prediction value is determined by certain conditions, but is not limited to the following three methods. For example, these three methods can be as follows:
[0452] Method 1: Determine whether to filter the matching template by comparing the distortion of the matching template and the current block template, such as SAD, MSE, SATD, or SSE, with the threshold T_Distortion1;
[0453] Method 2: Based on the condition that the filter model is used in Method 1, the distortion between the filtered matching template and the template of the current block, such as SAD, MSE, SATD, or SSE, and the threshold T_Distortion2, is used to determine whether to filter the reference block.
[0454] Method three: The encoding end transmits a Flag to indicate whether to apply the filter model. tmpFlag indicates whether the current block applies intra-frame template matching, and filterFlag indicates whether the current block applies the filter model. When tmpFlag is 1, the encoding end decides whether to filter the reference block by comparing the distortion between the reference block and the current block before and after filtering, such as SAD, MSE, SATD, or SSE. If the distortion after filtering is less than the distortion before filtering, filterFlag is 1, and the current block uses the reference block after filtering as the prediction block; otherwise, filterFlag is 0, and the current block uses the reference block before filtering as the prediction block. The encoding end transmits filterFlag to the decoding end.
[0455] Furthermore, in some embodiments, the method may also include: determining multiple reference blocks within the second search area and model parameters of each of the multiple reference blocks; filtering the multiple reference blocks according to the model parameters of each of the multiple reference blocks to determine multiple filtered reference blocks; and determining a prediction value of the current block based on the multiple filtered reference blocks.
[0456] In a specific embodiment, determining the prediction value of the current block based on multiple filtered reference blocks may include: decoding the code stream to determine the reference block index number; and determining the filtered reference block among the multiple filtered reference blocks based on the reference block index number.
[0457] It should be noted that, in the embodiment of the present application, for the reference block to which the filter coefficient is applied, the aforementioned embodiment only calculates the filter coefficient for the best matching template after the search, and applies the filter coefficient to the best matching reference block; in addition, the filter coefficient can also be applied to all or part of the reference blocks in the search area, and certain conditions are used to determine which filtered reference block is used as the final prediction block, but this is not limited to the following methods:
[0458] Method 1: Calculate the filter coefficients for the templates within the search range and filter them, and then calculate the cost (Cost) with the current template to decide which template to use. That is, calculate the filter coefficients for part or all of the templates to be searched in the search range, then apply the filter coefficients to the template to be searched, calculate the cost of the template and the current template, select the best matching template after filtering based on the cost, and filter the reference block corresponding to the best matching template and use it as the final prediction value.
[0459] Method 2: The encoder transmits a flag indicating which filtered reference block is used as the final prediction block. tmpFlag indicates whether template matching is applied to the current coding block, and filterIdx indicates which reference block within the current search range is applied to the filter model. When tmpFlag is 1, the encoder compares the distortion (SAD, MSE, SATD, or SSE) between the reference blocks within the search range with the applied filter coefficients and the current original block, selects the optimal reference block, and transmits the corresponding index to the decoder.
[0460] Furthermore, in some embodiments, "each sampling point within the template" can be replaced by "an identified sampling point within the template"; and "each sampling point within the reconstructed block corresponding to the template" can be replaced by "an identified sampling point within the reconstructed block corresponding to the template." The identified sampling points within the template refer to one or more sampling points located at the corners of the template region, such as the upper left and lower right sampling points of the upper template region when only the upper template is available, or only the lower right sampling point. The identified sampling points within the reconstructed block corresponding to the template refer to one or more sampling points located at the corners of the reconstructed block region, such as the upper left and lower right sampling points of the reconstructed block region, or only the lower right sampling point of the reconstructed block region.
[0461] It should be noted that in the embodiment of the present application, considering that the filter may use reconstructed sampling points outside the reference template and reference block, it is necessary to fill the boundary sampling points. One way to implement boundary filling is shown in Figures 18A and 18B, and the grid area is the area that needs to be filled.
[0462] In some embodiments, the filling method is to determine whether the sampling points of the grid area are available one by one. If available, the reconstructed pixels are directly used. If not available, the reconstructed pixels of the nearest reference template or reference block are copied to fill the grid area.
[0463] The methods for determining whether it is applicable include but are not limited to the following conditions being met, or multiple conditions being met simultaneously:
[0464] The sampling point is within the image boundary;
[0465] The sampling point is within the Tile boundary;
[0466] The sampling points have been reconstructed;
[0467] In other embodiments, the filling method is to determine whether the position of the filling area exceeds the search range of the BV based on the search range of the BV. If it does not exceed the search range, the reconstructed sampling points are directly used. If it exceeds the search range, the reconstructed sampling points of the adjacent reference template or reference block are copied to fill the grid area. Specifically, the boundary needs to be filled based on the derived iVerMin, iVerMax, iHorMin, and iHorMax:
[0468] The leftPadding, rightPadding, topPadding and bottomPadding are used to indicate whether the left grid area, right grid area, upper grid area and lower grid area copy the most recently reconstructed sampling point, i.e.
[0469] leftPadding=! (pX_Best>iHorMin);
[0470] rightPadding=!(pX_Best <iHorMax);
[0471] topPadding=! (pY_Best>iVerMin);
[0472] bottomPadding=!(pY_Best <iverMax)。
[0473] Here, if leftPadding is true, it means that the pixels in the left grid area are beyond the BV search range, and the reconstructed sampling points of the nearest adjacent reference template are copied, otherwise, the reconstructed pixels at that position are used directly. If rightPadding is true, it means that the pixels in the right grid area are beyond the BV search range, and the reconstructed sampling points of the nearest adjacent reference template or reference block are copied, otherwise, the reconstructed sampling points at that position are used directly. If topPadding is true, it means that the pixels in the upper grid area are beyond the BV search range, and the reconstructed sampling points of the nearest adjacent reference template are copied, otherwise, the reconstructed sampling points at that position are used directly. If bottomPadding is true, it means that the pixels in the lower grid area are beyond the BV search range, and the reconstructed sampling points of the adjacent reference template or reference block are copied, otherwise, the reconstructed sampling points at that position are used directly.
[0474] Furthermore, in an embodiment of the present application, a relevant mode selection flag (ibcFilterFlag) is transmitted at the CU layer. The encoding method of the ibcFilterFlag can be implemented in multiple ways. One implementable method is to use equal probability coding; another implementable method is to use context coding, and the default context initial state and context update rate can be used, or the context initial state and context update rate can be determined by statistics, which is not specifically limited here.
[0475] Furthermore, in the embodiments of the present application, the decoding method can be implemented in conjunction with various sub-modes under IBC, including but not limited to ordinary IBC merge, IBC TM merge, MBVD, IBC CIIP, IBC ABVP, etc., which are not specifically limited here.
[0476] Furthermore, in the embodiments of the present application, the decoding method is not limited to the intra-frame prediction mode, nor is it limited to the IBC mode, and can be applied to other modes using BV. Alternatively, the block vector in the decoding method is not limited to the BV used by IBC, and the template is not limited to the template used by IBC, etc., and no specific limitations are made here.
[0477] This embodiment provides a decoding method, which first determines a first template for a current block and a list of block vector candidates for the current block; then decodes the bitstream, determines block vector indication information, and determines a first block vector based on the block vector indication information and the list of block vector candidates; then determines a matching template and a corresponding reference block based on the first block vector; determines model parameters based on the first template and the matching template, and filters the reference block based on the model parameters to determine a filtered reference block; and finally determines a prediction value for the current block based on the filtered reference block. In this way, the model parameters are determined based on the first template and the matching template, and the model parameters fully reflect the correlation between the matching template and the first template of the current block. This correlation is applied to the reference block, and its reconstructed pixels are filtered and corrected. The filtered reconstructed pixels are then used as the predicted pixels for the current block. This method not only improves prediction accuracy and saves bit rate, but also effectively solves the problem of linear changes between the reference block and the current block. It also improves encoding and decoding efficiency, thereby enhancing encoding and decoding performance.
[0478] In another embodiment of the present application, see Figure 21, which shows a schematic flow chart of an encoding method provided by an embodiment of the present application. As shown in Figure 21, the method may include:
[0479] S2101: Determine a first template of a current block, and determine a block vector candidate list of the current block.
[0480] It should be noted that the encoding method of the embodiment of the present application is applied to the encoder. In addition, the encoding method may specifically refer to an intra-frame prediction method, more specifically, an intra-frame prediction method of an intra-block copy technology based on a linear filter model (Intra Block Copy based on Filter-based linear model, IBC-FLM), but is not limited to the IBC mode, and other modes of applying block vectors can be applied. Among them, the video image can be divided into multiple coding blocks, and the current block in the embodiment of the present application refers to the coding block in the video image that is currently to be intra-frame predicted. In addition, the encoding method of the embodiment of the present application can be used to predict both the luminance component and the chrominance component, which is not specifically limited here.
[0481] It should also be noted that, in the embodiments of the present application, it is first necessary to determine the first template of the current block so that a matching template and a corresponding reference block can be determined based on the first template. In some embodiments, determining the first template of the current block may include:
[0482] Determine the template type of the current block;
[0483] Determine the first template of the current block according to the template type of the current block.
[0484] The template type can be represented by refTemplateType. In some embodiments, determining the template type of the current block may include: determining the template type of the current block according to reference pixels of the current block.
[0485] The reference pixels of the current block include at least one of the following: a left adjacent reference pixel of the current block, an upper adjacent reference pixel of the current block, and an upper-left adjacent reference pixel of the current block.
[0486] For example, Figure 16 shows a schematic diagram of a template type for an IBC mode provided in an embodiment of the present application. When the upper left, upper, and left reference pixels are all available, the value of refTemplateType is 1, and the template type shape is shown in Figure 16 (a); when only the left reference pixel is available, the value of refTemplateType is 2, and the template type shape is shown in Figure 16 (b); when only the upper reference pixel is available, the value of refTemplateType is 3, and the template type shape is shown in Figure 16 (c).
[0487] That is, in an embodiment of the present application, the reference pixels of the current block are determined based on the adjacent reconstructed area of the current block. The adjacent reconstructed area of the current block includes at least one of the following: a left adjacent area, an upper adjacent area, and an upper-left adjacent area. For example, the left adjacent reference pixels of the current block may be determined by at least one column of reconstructed pixels in the left adjacent area, the upper adjacent reference pixels of the current block may be determined by at least one row of reconstructed pixels in the upper adjacent area, the upper-left adjacent reference pixels of the current block may be determined by at least one column of reconstructed pixels in the upper-left adjacent area, and so on. This is not specifically limited here.
[0488] Furthermore, the template type can be classified based on the availability of adjacent reference pixels and the template type of the current block can be determined. In some embodiments, determining the template type of the current block can include: if both the left adjacent reference pixels of the current block and the top adjacent reference pixels of the current block are available, encoding the template type of the current block and writing the resulting encoded bits into the bitstream.
[0489] It should be noted that, in an embodiment of the present application, the template type of the current block can be preset, or it can be determined by writing the template type into the code stream. Among them, if the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block, and the upper left adjacent reference pixels of the current block are all available, then the template type of the current block is determined to be the first type value; if the left adjacent reference pixels of the current block are available, then the template type of the current block is determined to be the second type value; if the upper adjacent reference pixels of the current block are available, then the template type of the current block is determined to be the third type value. For example, if both the left adjacent reference pixels and the upper adjacent reference pixels are available, the second or third type templates can also be used. In this case, the code stream can be used to specify which template to use.
[0490] In the embodiment of the present application, the first type value, the second type value, and the third type value can be different. For example, the first type value can be set to 1, the second type value can be set to 2, and the third type value can be set to 3. In addition, for these three template types, please refer to (a), (b), and (c) in Figure 16 for details.
[0491] It should also be noted that, in the embodiment of the present application, the template type of the current block is generally L-type, i.e., (a) in FIG16 . For an L-type template, it can be composed of the left adjacent reference pixels of the current block and the upper adjacent reference pixels of the current block, or it can be composed of the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block, and the upper left adjacent reference pixels of the current block. Among them, the upper left adjacent pixels generally do not need to be specifically pointed out, because in practice, the L-type template may not include the upper left pixels; in other words, when both the left and upper pixels are available, the upper left adjacent pixels are also available.
[0492] In some embodiments, determining the first template of the current block according to the template type of the current block may include: obtaining the template pixels of the current block according to the template type of the current block and the corresponding template size; and determining the template pixels of the current block as the first template of the current block.
[0493] In the embodiment of the present application, the template size may be pre-set, or may be determined according to the size of the current block, or may even be related to the template type of the current block, which is not specifically limited here.
[0494] For example, if the template type indicates that only the left template is to be obtained, the template width templateW_size may be set to 4; if the template type indicates that only the upper template is to be obtained, the template height templateH_size may be set to 4.
[0495] In addition, the value of the template type can determine which part of the reconstructed pixels the first template obtains. For example, when the value of refTemplateType is 1, the left, upper left, and upper reconstructed pixels of the current block are obtained; when the value of refTemplateType is 2, only the left four columns of reconstructed pixels of the current block are obtained; when the value of refTemplateType is 3, only the upper four rows of reconstructed pixels of the current block are obtained.
[0496] It should also be noted that in this embodiment of the present application, the template type of the current block can also be written into the bitstream. In a specific embodiment, the method can further include encoding the template type of the current block and writing the resulting encoded bits into the bitstream. This allows the decoder to subsequently determine the template type of the current block by decoding the bitstream. Based on the template type, the first template for the current block can then be determined. This is not a limitation.
[0497] Understandably, in the embodiments of this application, for the IBC mode, a block vector candidate list needs to be constructed. Taking the IBC merge candidate list construction process as an example, the IBC ABVP candidate list construction process is essentially the same as the IBC merge process, but the maximum number of candidates differs. For example, the IBC merge candidate list length can be defined as 6, and the IBC ABVP candidate list length can be defined as 2.
[0498] In some embodiments, determining a block vector candidate list for a current block may include: determining at least one first candidate block vector adjacent to the current block based on a derivation method of spatial block vector candidates; adding the at least one first candidate block vector to the block vector candidate list; and if the number of candidates in the block vector candidate list meets a preset threshold, using the current block vector candidate list as the block vector candidate list for the current block.
[0499] It should be noted that in building the block vector candidate list, the spatial candidate derivation is performed first. Specifically, when the usage conditions are met (for example, the size condition IsGt4by4 is equal to TRUE: the variable IsGt4by4 is TRUE when the luma width multiplied by the height is greater than 16), the derivation process of the spatial block vector candidates from the adjacent coding units specified in the decoding specification is called using the luma coding block position (xCb, yCb), the luma coding block width cbWidth and the height cbHeight as inputs, and the output is the availability flags such as availableFlagA1, availableFlagB1 and the block vectors bvA1 and bvB1.
[0500] The availability check for each candidate is as follows: the following conditions are determined. If all of them are true, the candidate is available:
[0501] Whether the offset position obtained by adding the current block position to the BVP does not exceed the image boundary;
[0502] Whether the current block position plus the block position pointed to by BVP does not overlap the current block;
[0503] Whether the offset position obtained by adding the current block position to the BVP does not exceed the IBC available area;
[0504] Whether the current block position plus the block position pointed to by BVP has been rebuilt;
[0505] It should also be noted that, in the embodiment of the present application, taking FIG. 3 as an example, the relative positions of the adjacent blocks where A1 and B1 are located and the current block are shown in FIG. 3 , and the traversal order in FIG. 3 may be A1->B1->B0->A0->B2.
[0506] Secondly, the spatial domain candidates are added to the candidate list. When the usage conditions are met (for example, the size condition IsGt4by4 is equal to TRUE), the block vector candidate list bvCandList is constructed as follows:
[0507] i=0;
[0508] if(availableFlagA1);
[0509] bvCandList[i++]=bvA1;
[0510] if(availableFlagB1);
[0511] bvCandList[i++]=bvB1;
[0512] …
[0513] Next, check the number of valid candidates in the block vector candidate list. The variable numCurrCand (the number of candidates currently obtained) is derived as follows:
[0514] If the usage condition is met (eg, the size condition IsGt4by4 is equal to TRUE), numCurrCand is set equal to the number of candidates in bvCandList; otherwise, numCurrCand is set to 0.
[0515] Furthermore, in some embodiments, the method may also include: if the number of candidates in the block vector candidate list does not meet a preset threshold, determining at least one second candidate block vector based on the derivation method of historical block vector candidates, and continuing to add the at least one second candidate block vector to the block vector candidate list; if the number of candidates in the block vector candidate list meets a preset threshold, using the current block vector candidate list as the block vector candidate list for the current block.
[0516] It should also be noted that if the candidate list does not reach the specified number of items (for example, the specified number of items in IBC merge mode is 6, and the specified number of items in IBC ABVP mode is 2), the historical candidate item derivation, availability detection and addition will continue:
[0517] When numCurrCand is less than MaxNumIbcMergeCand (the maximum number of candidates in IBC merge mode) and NumHmvpIbcCand (the maximum number of candidates for the historical best block vector (Hmvp) in IBC mode) is greater than 0, the derivation process of the history-based IBC block vector candidates specified in the decoding specification is called with bvCandList and numCurrCand as input and the modified bvCandList and numCurrCand as output.
[0518] Furthermore, in some embodiments, the method may also include: if the number of candidates in the block vector candidate list does not meet a preset threshold, determining at least one third candidate block vector based on a derivation method of other available candidates, and continuing to add the at least one third candidate block vector to the block vector candidate list until the number of candidates in the block vector candidate list meets the preset threshold.
[0519] In an embodiment of the present application, other available candidate derivation methods may include at least one of the following: a method for deriving paired average candidates, a method for deriving zero-value block vector candidates, and a method for deriving reference area candidates corresponding to intra-frame block copies.
[0520] It should also be noted that after adding at least one second candidate block vector to the block vector candidate list, continue to check the number of valid items in the candidate list and add other available candidates (such as pairwise average candidates, zero-value BV candidates, etc.) until the specified number of items is reached.
[0521] For example, other available candidates are as follows:
[0522] (1) The pairwise average candidate can be constructed by using the first and second candidate items, specifically: mvAvgLX=(mvCand0LX+mvCand1LX+1)>>1
[0523] (2) The zero value BV can be directly set to:
[0524] bvCandList[numCurrCand][0] is set equal to 0. (horizontal component of bv)
[0525] bvCandList[numCurrCand][1] is set equal to 0. (vertical component of bv)
[0526] (3) A set of BVP candidates located in the IBC reference area can also be used as candidates that can be added. The coordinates of a set of BVP candidates are determined by the width and height of the current block and the ΔX and ΔY parameters, as shown in Figure 4.
[0527] It should also be noted that, in the embodiment of the present application, each time an item is added, numCurrCand increases by 1. In this way, until numCurrCand meets the preset threshold, the basic block vector candidate list bvCandList is established.
[0528] Furthermore, after the block vector candidate list is constructed, the method may further include: after determining the block vector candidate list of the current block, sorting the block vector candidate list.
[0529] It should be noted that in an embodiment of the present application, in the IBC merge mode, the order of the list can also be reordered using a template, the order of the candidate list can be adjusted, the high spatial correlation can be fully utilized, the coding bit transmission can be reduced, and the coding efficiency can be effectively improved. For example, for the IBC merge mode, after the intermediate candidate list is constructed according to the above list construction method (note that the length of the intermediate candidate list can be greater than or equal to the maximum number of candidates in the IBC merge mode), all the candidates in the list are reordered using the template, and sorted in order from small to large according to the template matching cost, and the first N (for example, N = 6) candidates in the sorted list are selected. The specific process is as follows: the SAD of the template position of the reference block pointed to by each candidate and the template position of the current block (as shown in Figure 5) is calculated, and they are arranged in ascending order, and the first 6 candidates are selected as the candidate list for IBC merge.
[0530] Furthermore, after the block vector candidate list is constructed, the method may further include: after determining the block vector candidate list of the current block, removing redundancy according to the distances between the candidate block vectors in the block vector candidate list.
[0531] It should be noted that, in an embodiment of the present application, removing redundancy may include: if the current block selects the non-flipped intra-frame block copy mode, then when the distance between at least two candidate block vectors in the block vector candidate list meets a preset condition, deleting at least one of the at least two candidate block vectors.
[0532] It should also be noted that in the embodiment of the present application, the IBC ABVP mode can also be used to remove candidate redundancy based on the distance of the candidate items: the number of candidates remains unchanged at two, and candidate lists are established for integer pixel and 4-pixel precision respectively.
[0533] If non-RRIBC mode is selected for IBC ABVP, and if the number of valid BVP candidates exceeds two, up to six BVP candidates in the candidate list are clustered according to the Euclidean distance between them, with the radius (R) being a set of block vectors determined as a logarithmic function of the width (cbWidth) and height (cbHeight) of the current block. If the Euclidean distance between the reference positions pointed to by several BV candidates is less than R, they are clustered: R = log2((cbWidth·cbHeight)>>MIN_PU_SIZE).
[0534] Furthermore, in some embodiments, the method may further include: if the flipped intra block copy mode is selected for the current block, adjusting the candidate block vectors in the block vector candidate list to point to a boundary of a valid block copy search area according to a preset direction of the flipped intra block copy mode. In other words, if the RRIBC mode is selected for the IBC ABVP, the candidate vectors may be adjusted to point to a boundary of a valid IBC search area according to the horizontal or vertical direction of the RRIBC mode.
[0535] In this way, the block vector candidate list is constructed.
[0536] S2102: Determine a first block vector according to the block vector candidate list.
[0537] It should be noted that, in some embodiments, determining the first block vector based on the block vector candidate list may include: performing cost calculation on at least two candidate block vectors in the block vector candidate list to determine the cost values of the at least two candidate block vectors; determining the minimum cost value based on the cost values of the at least two candidate block vectors, and using the candidate block vector corresponding to the most recent cost value as the first block vector.
[0538] It should also be noted that, in the embodiment of the present application, the cost value calculation for each candidate block vector may be performed by calculating the matching cost between the template corresponding to each candidate block vector and the first template based on a preset cost function. The preset cost function may be the sum of absolute difference (SAD), the sum of absolute transformation difference (SATD), the mean square error (MSE), the sum of squared errors (SSD), the mean absolute difference (MAD), the mean squared error (MSD), the normalized correlation coefficient (NCC), etc., and is not specifically limited herein.
[0539] In some embodiments, the method may further include: determining a block vector index number corresponding to the first block vector based on the block vector candidate list; encoding the block vector index number, and writing the resulting coded bits into the bitstream. Here, the block vector index number may be written into the bitstream as block vector indication information, i.e., encoding the block vector indication information and writing the resulting coded bits into the bitstream.
[0540] In some embodiments, the method may further include: determining a block vector index number corresponding to the first block vector based on the block vector candidate list; determining a block vector difference value based on the initial block vector of the current block and the first block vector; and encoding the block vector index number and the block vector difference value, and writing the resulting coded bits into the bitstream. Here, the block vector index number and the block vector difference value may be written into the bitstream as block vector indication information, i.e., encoding the block vector indication information and writing the resulting coded bits into the bitstream.
[0541] It should be noted that in the embodiment of the present application, the block vector indication information may be different for different prediction modes, for example, it may be a block vector index number, a block vector difference value, etc., which is not specifically limited here.
[0542] In one possible implementation, the block vector indication information may include a block vector index number. For example, in IBC merge mode, after determining the block vector index number bvIdx, the subsequent decoding end can obtain the specific bvL based on the block vector index number bvIdx and the block vector candidate list bvCandList: bvL[0] = bvCandList[bvIdx][0]; bvL[1] = bvCandList[bvIdx][1];
[0543] This bvL is the final BV.
[0544] In another possible implementation, the block vector indication information may include a block vector index number. For example, in the IBC MBVD mode, similar to the MMVD in the inter-frame technology of VVC, a candidate in the IBC merge list is used as a starting point, and a candidate is selected from a set of candidate points corresponding to a predefined distance and direction set, and the corresponding block vector is used as the final BV.
[0545] For example, in IBC MBVD, the distance set is defined as {1-pel, 2-pel, 4-pel, 8-pel, 12pel, 16pel, 24pel, 32pel, 40pel, 48pel, 56pel, 64pel, 72pel, 80pel, 88pel, 96pel, 104pel, 112pel, 120pel, 128pel}, and the BVD directions are positive and negative horizontal directions and positive and negative vertical directions.
[0546] In this way, the base candidate can be selected from the first five candidates in the reordered IBC merge list, and all possible MBVD refinement positions (i.e., 20×4 candidates) of each base candidate are reordered based on the SAD cost between the template and its reference at each refinement position. Finally, the first 8 refinement positions with the smallest template SAD are retained for MBVD index encoding. The IBC-MBVD candidates do not inherit the flip type from the RR-IBC encoded neighboring blocks. The MBVD index is binarized using a Rice code with parameter equal to 1.
[0547] In another possible implementation, the block vector indication information may include a block vector index number. For example, in IBC TM merge mode, after obtaining bvL based on the block vector index number bvIdx, TM can be used to locally refine the BV. Specifically, a search is performed within a small range centered on the obtained bvL, and the optimal BV within the range is selected as the final BV based on the minimum template matching cost.
[0548] The TM refinement of the candidate list for the IBC merge mode is carried out. The specific implementation process is as follows:
[0549] When building a candidate, the flip type defaults to no flip;
[0550] IBC TM merge mode In IBC merge mode, the transmission syntax element specifies whether to perform integer-pixel precision TM refinement. The location of the refined motion vector and the template used in each refinement step must comply with the reference area constraints.
[0551] A search is performed near the candidate's pointed position, using the SAD between the template of the reference block and the template of the current block to determine the optimal position. This includes, but is not limited to, the following search methods: the search range is [-8, 8], and a diamond search is first performed on integer pixels, searching eight points near the center position, as shown in Figures 7A and 7B. The maximum number of searches is 375. After the optimal position is determined for the first time, the search continues, searching five points at even-numbered positions and three points at odd-numbered positions in subsequent searches.
[0552] After the above diamond search process, a whole-pixel cross search is performed only once. That is, after the diamond search finds the current optimal position, four positions with a distance of one pixel below, to the right, above, and to the left of the current optimal position are checked to update the final optimal position, that is, to update the refined candidate list.
[0553] In another possible implementation, the block vector indication information may include a block vector index number and a block vector difference value. For example, for the IBC ABVP mode, the bvL obtained by using the block vector index number bvIdx and the block vector candidate list bvCandList is the predicted bvL. The actual bvL also needs to be added with the block vector difference (BVD). The generalized specific process is as follows:
[0554] Step 1: Get the horizontal and vertical components of BVD, where MvdL0 is the forward motion vector difference. bvd[0] = MvdL0[xCb][yCb][0]; bvd[1] = MvdL0[xCb][yCb][1].
[0555] Step 2: Round the predicted bvL obtained above, where the right shift parameter AmvrShift is used for rounding and the left shift parameter AmvrShift is used to improve the resolution. Specifically: offset = (AmvrShift == 0)? 0: ((1 << (AmvrShift-1))-1); bvL[0] = Sign(bvL[0])*(((Abs(bvL[0])+offset)>>AmvrShift)<<AmvrShift); bvL[1]=Sign(bvL[1])*(((Abs(bvL[1])+offset)> >AmvrShift)< <AmvrShift)。
[0556] Step 3: The true bvL is derived as follows, and its range needs to be controlled between -217 and 217–1: u[0]=(bvL[0]+bvd[0]+218)%218; bvL[0]=(u[0]>=217)?(u[0]-218):u[0]; u[1]=(bvL[1]+bvd[1]+218)%218; bvL[1]=(u[1]>=217)?(u[1]-218):u[1].
[0557] It should be noted that the method of obtaining BVD in step 1 can also be inferred from syntax elements obtained through other encoding methods. The BVD of IBC ABVP uses sub-pixels, whole pixels or 4 pixels as units. During encoding, its symbol can be predicted, and the suffix of the exponential Golomb code obtained after its binarization can also be predicted. Therefore, its syntax elements can be defined by multiple information of the BVD value: whether it is 0, prefix, symbol, and suffix. The combination and analysis of these information can obtain the actual value of BVD. The specific embodiments are as follows:
[0558] It should also be noted that the identification of whether BVD is 0 uses context coding. The value of (absolute value -1) is binarized using first-order exponential Columbus, the first 5 binary data (bin) of the EG1 prefix are context coded, and the remaining prefixes are bypass coded. Up to 4 bins of the EG1 suffix use context coding to transmit the prediction index, and the other bins of the EG1 suffix use bypass coding. The two bins of the sign bit use context coding to transmit the symbol prediction index. Figure 8 is a schematic diagram of the relationship between a block vector (BV), a block vector prediction (BVP) and a block vector difference (BVD). As shown in Figure 8, here is a prediction process for a suffix bin with a transmission prediction index in the horizontal and vertical directions, and a bin with a transmission symbol index in the horizontal and vertical directions. The current block template and the template at the corresponding BV are sorted to derive the prediction index of the suffix and the symbol.
[0559] It should be noted that, in the embodiment of the present application, the BV finally derived should be within the specified range (coordinate range in rows and columns), as shown in Figures 9, 10 and 11.
[0560] It is understood that in the embodiment of the present application, the first block vector can be a luminance block vector or a chrominance block vector, and is not specifically limited here. If the first block vector is a luminance block vector, the luminance block vector is used to determine the prediction value of the current block based on the luminance component; if the first block vector is a chrominance block vector, the chrominance block vector is used to determine the prediction value of the current block based on the luminance component.
[0561] Furthermore, in the IBC mode for chroma components, a chroma block vector can be derived based on the luma block vector. In one possible implementation, the first block vector is a luma block vector, and the method may further include: scaling the luma block vector according to a preset chroma sampling format to determine a chroma block vector; wherein the chroma block vector is used to determine a prediction value based on the chroma component of the current block.
[0562] In another possible implementation, the first block vector is a luminance block vector, and the method may further include: scaling the luminance block vector according to a preset chroma sampling format to determine a scaled block vector; correcting the scaled block vector to determine a chroma block vector; wherein the chroma block vector is used to determine a predicted value of the current block based on the chroma component.
[0563] In the embodiment of the present application, the process of deriving the chromaticity BV based on the luminance BV is as follows:
[0564] Input: bvL (luminance) (1 / 16 pixel accuracy); Output: bvC (Block Vector Chroma) (1 / 32 pixel accuracy).
[0565] The derivation process may be direct scaling, or scaling followed by refinement using TM, which is not specifically limited here.
[0566] For the scaling operation, an example is as follows: bvC[0]=((bvL[0]>>(3+SubWidthC))*32); bvC[1]=((bvL[1]>>(3+SubHeightC))*32).
[0567] The variables SubWidthC and SubHeightC depend specifically on the chroma format sampling structure specified by sps_chroma_format_idc. For specific correspondence, see Table 1, which shows the correspondence between sps_chroma_format_idc and the chroma format sampling structure.
[0568] The refinement operation can include the following methods: using TM for refinement, that is, after obtaining the luma BV, using the position of the chroma block and the BV to find the offset position, using a template to perform a detailed search near the offset position, and obtaining the optimal BV (i.e., the refined BV) with the minimum TMcost as the criterion. As shown in Figure 12, the area filled with diagonal lines represents the chroma reconstruction area. For the current block, template matching can be used to find the best matching template and the corresponding refined BV. The reference block at the optimal offset position obtained based on the refined BV is copied, and the chroma prediction value of the current block can be determined.
[0569] S2103: Determine a matching template and a corresponding reference block according to the first block vector.
[0570] It should be noted that, in the embodiment of the present application, after determining the first block vector, a matching template and a corresponding reference block may be determined based on the first block vector. In some embodiments, determining the matching template and the corresponding reference block based on the first block vector may include:
[0571] Determine a reference template and a corresponding reference block according to the first block vector;
[0572] If the reference template meets the first preset condition, a first process is performed on the adjacent area of the reference template to determine a matching template.
[0573] In some embodiments, determining a matching template and a corresponding reference block according to the first block vector may include:
[0574] Determine a reference template and a corresponding reference block according to the first block vector;
[0575] If the reference template meets the second preset condition, the reference template is used as the matching template.
[0576] It should also be noted that, in the embodiment of the present application, the matching template may include: sampling points in the reference template and sampling points in an adjacent area of the reference template.
[0577] It should also be noted that, in an embodiment of the present application, the available reconstructed pixels can be determined based on the template type refTemplateType of the current block. For example, when the template type refTemplateType is 1, as shown in FIG17 , it indicates that the adjacent left, upper left, and upper reconstructed pixels are available, the number of available reconstructed pixels on the left is templateW_size*nTbH, the number of available reconstructed pixels on the upper side is templateH_size*nTbW, and the number of available reconstructed pixels on the upper left is templateW_size*templateH_size.
[0578] In an embodiment of the present application, the first preset condition is different from the second preset condition. In some embodiments, the method may further include: if sampling points outside the reference template and the reference block are used, determining that the reference template meets the first preset condition.
[0579] In some embodiments, the method may further include: if no sampling points outside the reference template and the reference block are used, determining that the reference template meets a second preset condition.
[0580] It should be noted that in the embodiments of this application, considering that the filter may use reconstructed pixels outside the reference template and reference block, it is necessary to fill the boundary pixels. Depending on the filter shape, the area of the boundary that needs to be filled varies. One boundary filling area is shown in Figure 18A, and another boundary filling area is shown in Figure 18B. The grid area is the area that needs to be filled.
[0581] In some embodiments, when the reference template meets the first preset condition, performing a first process on the adjacent area of the reference template may include: if sampling points outside the reference template and the reference block are used, filling the sampling points in the adjacent area of the reference template.
[0582] In the embodiment of the present application, for the filling process, it is first necessary to determine whether the sampling points of the adjacent area of the reference template are available. In some embodiments, the filling process of the sampling points of the adjacent area of the reference template may include:
[0583] Determine whether the sampling points in the adjacent area of the reference template are available;
[0584] If the sampling points of the adjacent area of the reference template are available, the sampling points of the adjacent area of the reference template are directly used;
[0585] If the sampling points of the adjacent area of the reference template are not available, the adjacent area of the reference template is filled by copying the sampling points of the adjacent reference template or the reconstructed sampling points in the adjacent reference block to obtain the sampling points of the adjacent area of the reference template.
[0586] It should be noted that the sampling points in the adjacent area of the reference template are available and may include at least one of the following:
[0587] The sampling point does not exceed the preset search range;
[0588] The sampling points do not exceed the image boundary;
[0589] The sampling point does not exceed the tile boundary;
[0590] The sampling points have been rebuilt.
[0591] In embodiments of the present application, the filling process can also be performed directly by copying the sampling points in the adjacent area of the reference template without determining whether the sampling points in the adjacent area of the reference template are available. In some embodiments, filling the sampling points in the adjacent area of the reference template can include directly copying the reconstructed sampling points in the adjacent reference template or adjacent reference block of the sampling points to fill the adjacent area of the reference template to obtain the sampling points in the adjacent area of the reference template. It should be noted that "directly copying" here means that there is no need to determine whether the sampling points in the adjacent area of the reference template are available.
[0592] In some embodiments, for the filling process, the method may further include: if sampling points outside the reference template and the reference block are used, then the filling process is not performed on the sampling points in the adjacent area of the reference template, and the sampling points are skipped when determining the model parameters.
[0593] That is, there are also multiple different methods for filling processing in the embodiments of the present application. One filling method is to determine whether the grid area is available. If it is available, the reconstructed pixels are directly used; if it is not available, the reconstructed pixels of the adjacent reference template or reference block are copied to fill the grid area. Alternatively, another filling method is to not consider whether the grid area is available and directly copy the reconstructed pixels of the adjacent reference template or reference block to fill the grid area. Alternatively, another filling method can also not fill, but instead abandon the use of the corresponding data in the calculation when encountering the boundary position; this is not specifically limited here.
[0594] S2104: Determine model parameters according to the first template and the matching template, and perform filtering processing on the reference block according to the model parameters to determine a filtered reference block.
[0595] It should be noted that in the embodiment of the present application, after determining the number of available reconstruction pixels, the reconstruction area for calculating the filter coefficients (i.e., model parameters) is determined based on the available reconstruction pixels. This area is called R, and R usually includes all available reconstruction pixels in the template. For example, when refTemplateType is 1, R includes all available reconstruction pixels on the left, upper left, and upper sides.
[0596] It should also be noted that, in the embodiment of the present application, the model parameters may include coefficients of the target filter. In some embodiments, the method may further include: determining the coefficients of the target filter based on the pixel reference values in the first template and the pixel reference values in the matching template.
[0597] It should also be noted that, in embodiments of the present application, the coefficients of the target filter may be determined by solving an optimization problem. Accordingly, in some embodiments, the method further includes: the coefficients of the target filter are the coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after being processed by the target filter and a pixel reference value in the first template satisfies a first condition.
[0598] It should be understood that for the first error to satisfy the first condition, in one possible implementation, the first condition is that the first error is minimized. Alternatively, in another possible implementation, the first condition is that the first error is within a first preset threshold range. Alternatively, in yet another possible implementation, the first condition is that the change in the first error is within a second preset threshold range.
[0599] It should also be understood that the first preset threshold range and the second preset threshold range are both metrics preset by the decoding end for determining whether the first error satisfies the first condition. Furthermore, the first error herein may be a mean square error (MSE), or may be a sum of squared error (SSE), or may be a sum of absolute error (SAD), or may be a sum of absolute error (SATD) after a Hadamard-transformed error (HATD), or may be a mean absolute error (MAE), etc., and this embodiment of the present application does not specifically limit this.
[0600] In some embodiments, determining coefficients of a target filter based on pixel reference values in the first template and pixel reference values in the matching template may include:
[0601] Determining autocorrelation parameters based on pixel reference values in the matching template;
[0602] determining a cross-correlation parameter based on the pixel reference value in the first template and the pixel reference value in the matching template;
[0603] The coefficients of the target filter are determined according to the autocorrelation parameters and the cross-correlation parameters.
[0604] It should be noted that, in the embodiment of the present application, the pixel reference value includes at least one of the following: a pixel reconstruction value, a pixel gradient value, and pixel position information.
[0605] That is, in the embodiment of the present application, the target filter is used as the filter model of the embodiment of the present application, and the input information of the target filter is the pixel reference value in the matching template. Here, the coefficient of the target filter can be expressed as c k,l , which may also be referred to as filter coefficients in this embodiment. The input information used to calculate the filter coefficients may be the available reconstructed pixels of the matching template; or, the gradient of each reconstructed pixel in the matching template, including but not limited to horizontal gradients and vertical gradients, may be calculated, and the calculated gradients may be used as the input information for calculating the filter coefficients; or, the position information of each reconstructed pixel may be used as the input information for calculating the filter coefficients. The position information may be the absolute position information of each reconstructed pixel in the entire image, or the relative position information of each reconstructed pixel relative to a reference point; this is not specifically limited here.
[0606] In a specific embodiment, a reconstruction region R for calculating the filter coefficients is first determined, and then a set of filter coefficients can be derived by minimizing the MSE between the reconstructed pixels in the region R and the reconstructed pixels of the first template, as shown in the aforementioned equations (3) and (4).
[0607] Furthermore, the process of minimizing MSE to derive the filter coefficients is as follows:
[0608] First, for c k,l Find the partial derivative and make it equal to 0, which is shown in the above equations (5) and (6); where k and l are between -1 and 1, and m and n are between -1 and 1.
[0609] Next, according to equations (5) and (6), we can obtain the equation shown in equation (7).
[0610] Once again, after the reconstruction region R is determined, Equation (7) is expanded into a matrix form, as shown in Equations (8) to (10).
[0611] In this way, since the autocorrelation matrix of refTemp and the cross-correlation vector of refTemp and recTemp in the reconstruction area R are known, the filter coefficient c can be calculated by solving the equation group shown in formula (7): k,l , for the filter coefficient c k,l It can be fixed-point or not.
[0612] In addition, in the embodiment of the present application, for the target filter, it is also necessary to determine the number of coefficients of the target filter and the shape of the target filter, etc. The number of coefficients of the target filter and the shape of the target filter can be preset fixed values or have an associated relationship with the size of the current block.
[0613] In some embodiments, for the number of coefficients of the target filter, the method may further include: the number of coefficients of the target filter is equal to a first preset value.
[0614] In some embodiments, for the number of coefficients of the target filter, the method may further include: determining the number of coefficients of the target filter; encoding the number of coefficients of the target filter, and writing the obtained coded bits into the bitstream.
[0615] It should be noted that the number of coefficients of the target filter can be represented by nTap. For example, the value of nTap can be 4, 5, 6, 7, 8, 9, etc., but is not specifically limited.
[0616] It should also be noted that the number of coefficients of the target filter can also be called the number of taps of the target filter. Here, the number of coefficients of the target filter can be a preset constant value or can be determined according to the size of the current block, which is not specifically limited here.
[0617] In some embodiments, regarding the shape of the target filter, the method may further include: the target filter is a one-dimensional or two-dimensional filter of a preset shape.
[0618] In some embodiments, regarding the shape of the target filter, the method may further include: determining the shape of the target filter; encoding the shape of the target filter, and writing the obtained encoded bits into the bitstream.
[0619] In some embodiments, the method may further include: determining a value of a filter shape parameter, wherein the filter shape parameter indicates a shape of a target filter. Further, the method may further include: encoding the value of the filter shape parameter and writing the obtained encoded bits into a bitstream.
[0620] It should be noted that the filter shape parameter can be represented by FilterIdx, which is used to indicate the shape of the target filter. In the embodiment of the present application, the shape of the target filter can be diamond, rectangle, cross, stripe, or even a one-dimensional filter or a two-dimensional filter, but is not specifically limited thereto.
[0621] Exemplarily, if the value of FilterIdx is equal to 0, the shape of the target filter is determined to be a diamond; if the value of FilterIdx is equal to 1, the shape of the target filter is determined to be a cross; if the value of FilterIdx is equal to 2, the shape of the target filter is determined to be a rectangle.
[0622] For example, Figure 19 is a schematic diagram of the shape of a filter provided in an embodiment of the present application. As shown in Figure 19, the filter is cross-shaped, and the number of taps of the filter is 5. Here, the number of taps of the filter can be dynamically adjusted according to the size of the current block.
[0623] It should also be noted that the shape of the target filter can be a preset shape, or can be determined by the value of the filter shape parameter, or can even be determined according to the size of the current block, which is not specifically limited here.
[0624] It should be noted that in the embodiment of the present application, after the model parameters are determined, the prediction value of the current block can be determined based on the model parameters and the reference block. Specifically, the reference block is filtered according to the model parameters, and the prediction value of the current block is determined based on the filtered reference block.
[0625] In some embodiments, filtering the reference block according to the model parameters to determine the filtered reference block may include: filtering the reference block according to the model parameters to determine the first output value of the target filter; and determining the filtered reference block based on the first output value of the target filter.
[0626] In some embodiments, filtering the reference block according to the model parameters to determine the filtered reference block may include: if sampling points of an adjacent region of the reference block are used, then padding the sampling points of the adjacent region of the reference block. In other words, in the embodiments of the present application, if sampling points of an adjacent region of the reference block are used, padding the sampling points of the adjacent region of the reference block is required.
[0627] In the embodiment of the present application, a first output value of the target filter can be calculated based on the pixel reconstruction values of the reference block and the coefficients of the target filter in the model parameters. Then, based on the first output value of the target filter, the filtered reference block can be determined. The target filter can be a linear or nonlinear filter model, without specific limitation.
[0628] In one possible implementation, filtering the reference block according to the model parameters to determine the first output value of the target filter may include:
[0629] Calculating the product of the pixel reconstruction value of the reference block and the coefficient of the corresponding target filter;
[0630] The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter and n is a positive integer.
[0631] It should be noted that the target filter in the embodiment of the present application is a linear filter model. The first output value of the target filter can be calculated using the aforementioned formula (11).
[0632] In another possible implementation, filtering the reference block according to the model parameters to determine the first output value of the target filter may include:
[0633] Determine a first value of a pixel reconstruction value of the reference block under a first mapping relationship;
[0634] Calculating the product of the first value and the coefficient of the corresponding target filter;
[0635] The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter and n is a positive integer.
[0636] It should be noted that the target filter in the embodiment of the present application is a nonlinear filter model. For example, when minimizing the MSE of the filter coefficients, it can be calculated using the aforementioned formulas (12) and (13).
[0637] It should also be noted that, in the embodiment of the present application, the filtered reference block is determined based on the first output value of the target filter. The first output value of the target filter can be directly set as the filtered reference block; or the first output value of the target filter can be subjected to a first filtering to obtain the filtered reference block; the first filtering here can be a low-pass filter, an up / down sampling filter, etc., which is not specifically limited here.
[0638] It should also be noted that, in the embodiment of the present application, after determining the first output value of the target filter, a first offset value (expressed as bias) may be added to the first output value to determine a filtered reference block.
[0639] In some embodiments, determining a filtered reference block based on a first output value of a target filter may include: determining a first offset value; and performing an addition operation based on the first output value and the first offset value to determine the filtered reference block.
[0640] In a possible implementation, determining the first offset value may include: setting the first offset value to be equal to a second preset value.
[0641] In another possible implementation, determining the first offset value may include: determining the number of pixels participating in filtering corresponding to the target filter based on the shape of the target filter; if the number of pixels of the reference filter corresponding to the target filter is m, determining m+1 coefficients of the target filter, where m is a positive integer; and determining the first offset value based on one of the m+1 coefficients and the second offset value.
[0642] In this embodiment of the present application, the target filter has m pixels participating in the filtering operation. However, considering the second offset value, the target filter needs to determine m+1 coefficients. A weighted calculation is then performed on the m pixels participating in the operation and the second offset value based on these m+1 coefficients. The coefficient used for the second offset value can be the m+1th coefficient, but other coefficients are also possible, and this is not specifically limited here.
[0643] In an embodiment of the present application, for the second offset value, the method may further include: setting the second offset value equal to a third preset value; or setting the second offset value equal to the value of the pixel reconstruction value of the reference block under the second mapping relationship.
[0644] It should be noted that the second mapping relationship may be a linear mapping relationship or a nonlinear mapping relationship, and there may be multiple nonlinear mapping relationships, which are not specifically limited here.
[0645] In an embodiment of the present application, the calculated filter coefficients are used as the number of taps corresponding to the filter template, that is, the number of filter coefficients is equal to the number of taps nTap of the filter template. In addition, a number of bias terms bias can be added to the filter template. Exemplarily, in an embodiment of the present application, when nTap = 5, the filter coefficients at this time are the tap coefficients c0 to c4 corresponding to the filter template, and the predicted value at the (i, j) position in the filtered reference block is calculated as shown in the above formula (14). At this time, a bias term can be added, as shown in the above formula (15).
[0646] In an embodiment of the present application, c n = c i,j,k,l . Here, Constant can be a fixed constant, for example, Constant = 1 << (BitDepth - 1), or it can be a number related to the reconstructed pixel value at the (i, j) position in the reference block, for example, Constant = f(ref[i][j]), or it can be a number related to the reconstructed pixel value corresponding to a certain tap in the filter template except the (i, j) position, for example, Constant = f(ref[k][l]). Among them, Constant = f(ref[i][j]) or Constant = f(ref[k][l]) can be a linear mapping relationship or a non-linear mapping relationship. One or more bias terms can be added, and no specific limitation is made here for this.
[0647] S2105: Determine the predicted value of the current block according to the filtered reference block.
[0648] Further, in some embodiments, determining the predicted value of the current block according to the filtered reference block may include: performing a second process on the filtered reference block to obtain the predicted value of the current block.
[0649] In an embodiment of the present application, for the second process, the second process may be to set the predicted value of the current block to be equal to the filtered reference block; or, the second process may be a clamping (clip) operation that limits the filtered reference block within a preset numerical range, or, the second process may also be other operations, and no specific limitation is made here.
[0650] Here, for the clip operation, the preset numerical range here may be: between 0 and (1 << BitDepth) - 1, where BitDepth represents the bit depth. If the value of the filtered reference block exceeds the value within this preset numerical range, then the filtered reference block needs to be corrected accordingly. Exemplarily, the filtered reference block can also be represented by Y pred [i][j], and at this time, a correction operation can be performed on Y pred [i][j], as follows:[[]END]]
[0651] When Y pred [i][j] is less than 0, set it to 0;
[0652] When Y pred [i][j] is greater than or equal to 0 and less than or equal to (1 << BitDepth) - 1, it is equal to Y pred [i][j];
[0653] When Y pred [i][j] is greater than (1 << BitDepth) - 1, set it to (1 << BitDepth) - 1.
[0654] In this way, after performing the correction operation on Y pred [i][j], it can be ensured that all pixel values in the filtered reference block are between 0 and (1 << BitDepth) - 1.
[0655] Furthermore, the number of filter models can be extended. In addition to only establishing one filter model, multiple filter models can also be established. Therefore, in some embodiments, the method may further include:
[0656] [[ID=B]]Determine multiple sets of model parameters according to the first template and the matching template;
[0657] Construct multiple filter models according to the multiple sets of model parameters, perform filtering processing on the reference block according to the multiple filter models respectively, and determine multiple filtered reference blocks;
[0658] Determine the predicted value of the current block according to the multiple filtered reference blocks.
[0659] In some embodiments, determining multiple sets of model parameters according to the first template and the matching template may include: classifying the reconstructed pixels in the first template and the matching template respectively according to a preset method to obtain multiple sets of sub - templates and multiple sets of sub - matching templates; determining multiple sets of model parameters according to the multiple sets of sub - templates and multiple sets of sub - matching templates.
[0660] It should be noted that in the embodiments of the present application, the preset method here may be the magnitude of the reconstructed pixel value, or it may also be the position information of the reconstructed pixel, or it may also be the shape of the filter, etc., which is not limited herein. Among them, after classifying according to the preset method, each set of sub - templates and the corresponding sub - matching templates can calculate a set of model parameters, and each set of model parameters can determine a filter model, so that multiple filter models can be constructed.
[0661] In a possible implementation, the method may further include: determining a target filter from a plurality of filter models; and filtering a reference block according to the target filter to determine a prediction value of the current block.
[0662] Furthermore, in some embodiments, the method may also include: determining a target model index value, wherein the target model index value is used to indicate the index number of the target filter in multiple filter models; encoding the target model index value, and writing the obtained encoded bits into the bitstream.
[0663] Furthermore, in some embodiments, determining a target filter from multiple filter models may include: determining the original value of the current block; performing cost calculations based on the original value of the current block and multiple initial prediction values of the current block to determine cost values for each of the multiple initial prediction values; determining a minimum cost value from the cost values of the multiple initial prediction values; and using the filter model corresponding to the minimum cost value as the target filter. It should be noted that the cost value here can be a distortion value, a rate-distortion cost value determined based on a rate-distortion optimization method, or even other cost values, without specific limitation.
[0664] In another possible implementation, multiple filtered reference blocks may be determined by filtering the reference blocks according to multiple filter models. In some embodiments, determining the prediction value of the current block based on the multiple filtered reference blocks may include performing a weighted calculation on the multiple filtered reference blocks to determine the prediction value of the current block.
[0665] It should be noted that if the weights of each filtered reference block are equal and equal to the inverse of the number of reference blocks, then the weighted calculation here can also be regarded as an averaging calculation. In other words, the average of multiple filtered reference blocks is calculated to determine the prediction value of the current block.
[0666] Exemplarily, the input information for calculating the filter coefficients is classified, and a filter model is established for each category of input information. For example, when using reconstruction information to establish a filter model, one possible implementation is to classify by the mean of the reconstruction information, establishing a filter model for reconstruction information greater than the mean, and establishing a filter model for reconstruction information less than the mean. Another possible implementation is to classify by the position of the reconstruction information. For example, a filter model can be established using the available reconstruction information on the left and upper sides, and a second filter model can be established using the available reconstruction information on the left and upper left sides. The encoder decides which model to use. One possible implementation is for the encoder to determine which model to use through rate-distortion optimization and transmit corresponding decoding parameters to the decoder so that the decoder can subsequently clearly select which filter model. Another possible implementation is to classify by filter shape. Multiple filters of different shapes can be used, and a filter model is established for each filter shape. The encoder decides which filter shape to use. One possible implementation is for the encoder to determine which filter to use through rate-distortion optimization and transmit corresponding decoding parameters to the decoder so that the decoder can subsequently clearly select which filter model.
[0667] It should also be noted that in an embodiment of the present application, after determining the prediction value of the current block, the prediction difference value of the current block can also be calculated. In some embodiments, determining the prediction difference value of the current block based on the prediction value of the current block can include: determining the original value of the current block; and determining the prediction difference value of the current block based on the original value of the current block and the prediction value of the current block.
[0668] In a specific embodiment, determining the prediction difference value of the current block based on the original value of the current block and the prediction value of the current block may include: performing a subtraction operation on the original value of the current block and the prediction value of the current block to determine the prediction difference value of the current block.
[0669] It should also be noted that in the embodiments of the present application, whether the current block applies intra block copying or whether it is used for the filter model can be determined by different syntax element identification information. In some embodiments, the method may further include: determining a value of first syntax element identification information, where the first syntax element identification information is used to indicate whether the current block applies intra block copying; encoding the value of the first syntax element identification information, and writing the resulting coded bits into the bitstream.
[0670] In an embodiment of the present application, determining the value of the first syntax element identification information may include: if the current block applies intra block copy, determining the value of the first syntax element identification information to be a first value; or if the current block does not apply intra block copy, determining the value of the first syntax element identification information to be a second value.
[0671] Furthermore, in some embodiments, when the first syntax element identification information is used to indicate that the current block applies an intra block copy, the method may further include: determining a value of the second syntax element identification information, wherein the second syntax element identification information is used to indicate whether the current block applies a filter model; encoding the value of the second syntax element identification information, and writing the obtained coded bits into the bitstream.
[0672] In an embodiment of the present application, determining the value of the second syntax element identification information may include: if the current block applies a filter model, determining the value of the second syntax element identification information to be a first value; or if the current block does not apply a filter model, determining the value of the second syntax element identification information to be a second value.
[0673] Furthermore, in some embodiments, the method may further include:
[0674] If the current block applies a filter model, performing filtering processing on the reference block according to the model parameters to determine a filtered reference block; and determining a prediction value of the current block according to the filtered reference block;
[0675] If the filter model is not applied to the current block, the reconstructed pixel values in the reference block are used as the prediction values of the current block.
[0676] It should be noted that in the embodiment of the present application, the first value and the second value are different, and the first value and the second value can be in parameter form or in digital form. Specifically, the first syntax element identification information and the second syntax element identification information can be parameters written in the profile or the value of a flag, which is not specifically limited here. Exemplarily, for the first value and the second value, the first value can be set to 1 and the second value can be set to 0; or the first value can also be set to true and the second value can also be set to false; however, this is not specifically limited here.
[0677] It should also be noted that in the embodiment of the present application, whether the current block uses the filtered reference block as the final prediction value is determined by certain conditions, but is not limited to the following three methods. For example, these three methods can be as follows:
[0678] Method 1: Determine whether to filter the matching template by comparing the distortion of the matching template and the current block template, such as SAD, MSE, SATD, or SSE, with the threshold T_Distortion1;
[0679] Method 2: Based on the condition that the filter model is used in Method 1, the distortion between the filtered matching template and the template of the current block, such as SAD, MSE, SATD, or SSE, and the threshold T_Distortion2, is used to determine whether to filter the reference block.
[0680] Method three: The encoding end transmits a Flag to indicate whether to apply the filter model. tmpFlag indicates whether the current block applies intra-frame template matching, and filterFlag indicates whether the current block applies the filter model. When tmpFlag is 1, the encoding end decides whether to filter the reference block by comparing the distortion between the reference block and the current block before and after filtering, such as SAD, MSE, SATD, or SSE. If the distortion after filtering is less than the distortion before filtering, filterFlag is 1, and the current block uses the reference block after filtering as the prediction block; otherwise, filterFlag is 0, and the current block uses the reference block before filtering as the prediction block. The encoding end transmits filterFlag to the decoding end.
[0681] Furthermore, in some embodiments, the method may also include: determining multiple reference blocks within the second search area and model parameters of each of the multiple reference blocks; filtering the multiple reference blocks according to the model parameters of each of the multiple reference blocks to determine multiple filtered reference blocks; performing cost calculations between the multiple filtered reference blocks and the current block to determine cost values of each of the multiple filtered reference blocks; determining a minimum cost value from the cost values of the multiple filtered reference blocks, and determining the filtered reference block and the corresponding reference block index number based on the minimum cost value; encoding the reference block index number and writing the obtained coded bits into the bitstream.
[0682] It should be noted that in the embodiment of the present application, the cost value here can be a distortion value, or a rate-distortion cost value determined based on a rate-distortion optimization method, or even other cost values, and there is no specific limitation on this.
[0683] It should also be noted that, in the embodiment of the present application, for the reference block to which the filter coefficients are applied, the aforementioned embodiment only calculates the filter coefficients for the best matching template after the search, and applies the filter coefficients to the best matching reference block; in addition, the filter coefficients may also be applied to all or part of the reference blocks within the search area, and certain conditions may be used to determine which filtered reference block is used as the final prediction block, but this is not limited to the following methods:
[0684] Method 1: Calculate the filter coefficients for the templates within the search range and filter them, and then calculate the cost with the current template to decide which template to use. That is, calculate the filter coefficients for part or all of the templates to be searched in the search range, then apply the filter coefficients to the template to be searched, calculate the cost of the template and the current template, and select the best matching template after filtering based on the cost. Filter the reference block corresponding to the best matching template and use it as the final prediction value.
[0685] Method 2: The encoder transmits a flag indicating which filtered reference block is used as the final prediction block. tmpFlag indicates whether template matching is applied to the current coding block, and filterIdx indicates which reference block within the current search range is applied to the filter model. When tmpFlag is 1, the encoder compares the distortion (SAD, MSE, SATD, or SSE) between the reference blocks within the search range with the applied filter coefficients and the current original block, selects the optimal reference block, and transmits the corresponding index to the decoder.
[0686] Furthermore, in some embodiments, "each sampling point within the template" can be replaced by "an identified sampling point within the template"; and "each sampling point within the reconstructed block corresponding to the template" can be replaced by "an identified sampling point within the reconstructed block corresponding to the template." The identified sampling points within the template refer to one or more sampling points located at the corners of the template region, such as the upper left and lower right sampling points of the upper template region when only the upper template is available, or only the lower right sampling point. The identified sampling points within the reconstructed block corresponding to the template refer to one or more sampling points located at the corners of the reconstructed block region, such as the upper left and lower right sampling points of the reconstructed block region, or only the lower right sampling point of the reconstructed block region.
[0687] It should be noted that in the embodiment of the present application, considering that the filter may use reconstructed sampling points outside the reference template and reference block, it is necessary to fill the boundary sampling points. One way to implement boundary filling is shown in Figures 18A and 18B, and the grid area is the area that needs to be filled.
[0688] In some embodiments, the filling method is to determine whether the sampling points of the grid area are available one by one. If available, the reconstructed pixels are directly used. If not available, the reconstructed pixels of the nearest reference template or reference block are copied to fill the grid area.
[0689] The methods for determining whether it is applicable include but are not limited to the following conditions being met, or multiple conditions being met simultaneously:
[0690] The sampling point is within the image boundary;
[0691] The sampling point is within the Tile boundary;
[0692] The sampling points have been reconstructed;
[0693] In other embodiments, the filling method is to determine whether the position of the filling area exceeds the search range of the BV based on the search range of the BV. If it does not exceed the search range, the reconstructed sampling points are directly used. If it exceeds the search range, the reconstructed sampling points of the adjacent reference template or reference block are copied to fill the grid area. Specifically, the boundary needs to be filled based on the derived iVerMin, iVerMax, iHorMin, and iHorMax:
[0694] The leftPadding, rightPadding, topPadding and bottomPadding are used to indicate whether the left grid area, right grid area, upper grid area and lower grid area copy the most recently reconstructed sampling point, i.e.
[0695] leftPadding=! (pX_Best>iHorMin);
[0696] rightPadding=!(pX_Best <iHorMax);
[0697] topPadding=! (pY_Best>iVerMin);
[0698] bottomPadding=!(pY_Best <iverMax)。
[0699] Here, if leftPadding is true, it means that the pixels in the left grid area are beyond the BV search range, and the reconstructed sampling points of the nearest adjacent reference template are copied, otherwise, the reconstructed pixels at that position are used directly. If rightPadding is true, it means that the pixels in the right grid area are beyond the BV search range, and the reconstructed sampling points of the nearest adjacent reference template or reference block are copied, otherwise, the reconstructed sampling points at that position are used directly. If topPadding is true, it means that the pixels in the upper grid area are beyond the BV search range, and the reconstructed sampling points of the nearest adjacent reference template are copied, otherwise, the reconstructed sampling points at that position are used directly. If bottomPadding is true, it means that the pixels in the lower grid area are beyond the BV search range, and the reconstructed sampling points of the adjacent reference template or reference block are copied, otherwise, the reconstructed sampling points at that position are used directly.
[0700] Furthermore, in an embodiment of the present application, a relevant mode selection flag (ibcFilterFlag) is transmitted at the CU layer. The encoding method of the ibcFilterFlag can be implemented in multiple ways. One implementable method is to use equal probability coding; another implementable method is to use context coding, and the default context initial state and context update rate can be used, or the context initial state and context update rate can be determined by statistics, which is not specifically limited here.
[0701] Furthermore, in the embodiments of the present application, the encoding method can be implemented in conjunction with various sub-modes under IBC, including but not limited to ordinary IBC merge, IBC TM merge, MBVD, IBC CIIP, IBC ABVP, etc., which are not specifically limited here.
[0702] Furthermore, in the embodiments of the present application, the encoding method is not limited to the intra-frame prediction mode, nor is it limited to the IBC mode, and can be applied to other modes using BV. In addition, the block vector in the encoding method is not limited to the BV used by IBC, and the template is not limited to the template used by IBC, etc., and no specific limitations are given here.
[0703] Furthermore, an embodiment of the present application also provides a code stream, which is generated by bit encoding based on the information to be encoded; wherein the information to be encoded includes at least one of the following: a prediction difference value of the current block, block vector indication information, a reference block index number, the number of coefficients of the target filter, the shape of the target filter, the value of the first syntax element identification information, and the value of the second syntax element identification information.
[0704] In an embodiment of the present application, the block vector indication information may include at least one of a block vector index number and a block vector difference value. In addition, the first syntax element identification information is used to indicate whether an intra block copy is applied to the current block, and the second syntax element identification information is used to indicate whether a filter model is applied to the current block.
[0705] This embodiment provides an encoding method, which first determines a first template of a current block and a candidate list of block vectors for the current block; then, based on the candidate list of block vectors, determines a first block vector; then, based on the first block vector, determines a matching template and a corresponding reference block; determines model parameters based on the first template and the matching template, and filters the reference block based on the model parameters to determine a filtered reference block; and finally, determines a prediction value for the current block based on the filtered reference block. In this way, the model parameters are determined based on the first template and the matching template, and the model parameters fully reflect the correlation between the matching template and the first template of the current block. This correlation is applied to the reference block, and its reconstructed pixels are filtered and corrected. The filtered reconstructed pixels are then used as the predicted pixels for the current block. This method not only improves prediction accuracy and saves bit rate, but also effectively solves the problem of linear changes between the reference block and the current block. It also improves encoding and decoding efficiency, thereby improving encoding and decoding performance.
[0706] In another embodiment of the present application, based on the encoding / decoding method described in the aforementioned embodiment, during the IBC prediction process, the embodiment of the present application proposes to correct the best matching reconstructed block and use the corrected reconstructed pixels as the predicted pixels of the current coding block. Specifically, a linear filter model is established using the pixels of the matching template and the current coding block template, and the linear filter model is applied to the best matching reconstructed block, and the filtered pixels are used as the final predicted pixels. This technical solution is called Intra Block Copy based on Filter-based linear model (IBC-FLM).
[0707] The following is a detailed introduction to the prediction process of IBC-FLM technology.
[0708] The input of IBC-FLM is: the position of the current block (xTbCmp, yTbCmp), the width of the current block nTbW, and the height of the current block nTbH.
[0709] Output of IBC-FLM: predicted value predSamples[x][y] of the current block, where x = 0..nTbW-1, y = 0..nTbH–1.
[0710] The IBC-FLM prediction process can be divided into five steps: determining the current template type, obtaining the reconstructed pixels of the current template, determining the block vector within a predefined search range, establishing a linear filter model, and generating the predicted value. It is important to note that the Intra TMP-FLM technique can be used to predict both luma and chroma components, and this is not specifically limited here.
[0711] See Figure 22, which shows a schematic diagram of a prediction process based on IBC-FLM technology provided in an embodiment of the present application. As shown in Figure 22, the process may include:
[0712] S2201: Determine the current template type.
[0713] It should be noted that the IBC technology uses the adjacent reconstructed pixels of the current block as templates to search for matching templates within a predefined search area, where the adjacent reconstructed pixels can be the upper reference pixels, upper left reference pixels, and left reference pixels of the coding block. Therefore, the template type can be classified and determined based on the availability of the adjacent reference pixels. The template type is represented by refTemplateType. For example, when the upper left, upper, and left reference pixels are all available, the value of refTemplateType is 1, and the template shape is shown in (a) of Figure 16; when only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is shown in (b) of Figure 16; when only the upper reference pixel is available, the value of refTemplateType is 3, and the template shape is shown in (c) of Figure 16.
[0714] S2202: Obtain current template pixels.
[0715] The IBC template can be composed of reconstructed pixels from one or more regions in the top, left, or top-left of the coding block. The template size is pre-set. For example, when obtaining the left template, the template width templateW_size can be set to 4, and when obtaining the top template, the template height templateH_size can be set to 4.
[0716] Specifically, which part of the reconstructed pixels to obtain can be determined according to the value of refTemplateType.
[0717] For example, when the value of refTemplateType is 1, the left, upper left, and upper reconstructed pixels of the current coding block are obtained; when the value of refTemplateType is 2, only the left 4 columns of reconstructed pixels of the current coding block are obtained; when the value of refTemplateType is 3, only the upper 4 rows of reconstructed pixels of the current coding block are obtained.
[0718] S2203: Determine the block vector.
[0719] It should be noted that, in the embodiment of the present application, the block vector may be a block vector based on a luminance component and / or a block vector based on a chrominance component, which will be described in detail below.
[0720] (1) Luminance component:
[0721] Input: Luma position (xCb, yCb), which specifies the top left corner sample of the current block relative to the top left corner luma sample of the current image; a variable cbWidth, which specifies the width of the current block in luma samples; a variable cbHeight, which specifies the height of the current block in luma samples.
[0722] Output: Block vector bvL (Block Vector Luma) of luminance.
[0723] The IBC mode can be roughly divided into two categories: IBC merge and IBC ABVP (similar to the merge and AMVP modes of the inter-frame mode in VVC). The process of obtaining BV can be regarded as the following three steps:
[0724] (1) When deriving bvL, it is necessary to establish an IBC block vector candidate list bvCandList;
[0725] (2) determining the candidate items in the selected candidate list based on the bitstream;
[0726] (3) Finally, the final BV is determined based on the candidate.
[0727] The specific storage information of the IBC candidate includes at least one of the following information:
[0728] Prediction direction (L0 or L1, generally L0 by default);
[0729] BV information (horizontal component, vertical component);
[0730] Reference frame (default current image);
[0731] Flip type (e.g., no flip, horizontal flip, and vertical flip);
[0732] Whether to use LIC (linear model).
[0733] The following describes the process of establishing a block vector candidate list, taking the IBC merge list establishment process as an example. The basic establishment process of the IBC ABVP list is the same as that of the IBC merge, but the maximum number of candidates is different between the two (for example, the IBC merge candidate list length is defined as 6, while the IBC ABVP candidate list length is defined as 2). The specific establishment process includes:
[0734] Step 1: Derivation of airspace candidates:
[0735] When the usage conditions are met (for example, the size condition IsGt4by4 is equal to TRUE, that is, the variable IsGt4by4 is TRUE when the luma width multiplied by the height is greater than 16), the derivation process of the spatial block vector candidates from the adjacent coding units specified in the decoding specification is called using the luma coding block position (xCb, yCb), the luma coding block width cbWidth and the height cbHeight as input, and the output is the availability flags such as availableFlagA1, availableFlagB1 and the block vectors bvA1 and bvB1.
[0736] The availability check for each candidate is as follows: the following conditions are met. If all of them are met, the candidate is available:
[0737] Whether the offset position obtained by adding the current block position to the BVP does not exceed the image boundary;
[0738] Whether the current block position plus the block position pointed to by BVP does not overlap the current block;
[0739] Whether the offset position obtained by adding the current block position to the BVP does not exceed the IBC available area;
[0740] Whether the current block position plus the block position pointed to by BVP has been rebuilt.
[0741] The relative positions of the adjacent blocks A1 and B1 and the current block are shown in FIG3 , and the traversal order may be A1->B1->B0->A0->B2.
[0742] Step 2: Airspace candidates are added to the candidate list:
[0743] When the usage condition is met (for example, the size condition IsGt4by4 is equal to TRUE), the block vector candidate list bvCandList is constructed as follows:
[0744] i=0;
[0745] if(availableFlagA1);
[0746] bvCandList[i++]=bvA1;
[0747] if(availableFlagB1);
[0748] bvCandList[i++]=bvB1;
[0749] …
[0750] Step 3: Check the number of valid items in the candidate list:
[0751] The variable numCurrCand (the number of candidates currently obtained) is derived as follows:
[0752] If the usage condition is met (eg, the size condition IsGt4by4 is equal to TRUE), numCurrCand is set equal to the number of candidates in bvCandList; otherwise, numCurrCand is set to 0.
[0753] Step 4: If the candidate list does not reach the specified number of items (for example, the specified number of items for IBC merge mode is 6, and the specified number of items for IBC ABVP mode is 2), continue with historical candidate item derivation, availability detection, and addition:
[0754] When numCurrCand is less than MaxNumIbcMergeCand (the maximum number of candidates in IBC merge mode) and NumHmvpIbcCand (the maximum number of candidates for the historical best block vector (Hmvp) in IBC mode) is greater than 0, the derivation process of the history-based IBC block vector candidates specified in the decoding specification is called with bvCandList and numCurrCand as input and the modified bvCandList and numCurrCand as output.
[0755] Step 5: Continue to check the number of valid items in the candidate list and add other available candidates (such as pairwise average candidates, zero-valued BV candidates, etc.) until the specified number of items is reached.
[0756] For example, other available candidates are as follows:
[0757] (1) The pairwise average candidate can be constructed by using the first and second candidate items, specifically: mvAvgLX=(mvCand0LX+mvCand1LX+1)>>1.
[0758] (2) The zero value BV can be directly set to:
[0759] bvCandList[numCurrCand][0] is set equal to 0. (horizontal component of bv)
[0760] bvCandList[numCurrCand][1] is set equal to 0. (vertical component of bv)
[0761] (3) A set of BVP candidates located in the IBC reference area can also be used as candidates that can be added. The coordinates of a set of BVP candidates are determined by the width and height of the current block and the ΔX and ΔY parameters, as shown in Figure 4.
[0762] Each time an item is added, numCurrCand increases by 1.
[0763] In this way, the basic block vector candidate list bvCandList is established.
[0764] Based on this list, in the IBC merge mode, the order of the list can also be reordered using a template, the order of the candidate list can be adjusted, the high spatial correlation can be fully utilized, the coding bit transmission can be reduced, and the coding efficiency can be effectively improved. For example, for the IBC merge mode, after the intermediate candidate list is constructed according to the above list construction method (note that the length of the intermediate candidate list can be greater than or equal to the maximum number of candidates in the IBC merge mode), all candidates in the list are reordered using the template, and sorted in order from small to large according to the template matching cost, and the first N (for example, N = 6) candidates in the sorted list are selected. The specific process is as follows: the SAD of the template position of the reference block pointed to by each candidate and the template position of the current block (as shown in Figure 5) is calculated, and they are sorted in ascending order, and the first 6 candidates are selected as the candidate list for the IBC merge.
[0765] Based on this list, the IBC ABVP mode can also remove candidate redundancy based on the distance between candidates:
[0766] The number of candidates remains unchanged at two, and candidate lists are established for integer pixel and 4-pixel precision respectively.
[0767] If non-RRIBC mode is selected for IBC ABVP, if the number of valid BVP candidates exceeds two, up to six BVP candidates in the candidate list are clustered according to the Euclidean distance between them, and the radius (R) is a set of block vectors determined as a logarithmic function of the width (cbWidth) and height (cbHeight) of the current block. If the Euclidean distance between the reference positions pointed to by several BV candidates is less than R, they are clustered. R is calculated as shown in the aforementioned formula (2).
[0768] Among them, the clustering method is performed in the order of the candidate list. In each class, the BVP with the lowest TM cost is selected as the representative candidate of the group. Then the representative candidates of all classes are template-sorted, and the representative candidates of the first two groups are selected for the motion estimation process.
[0769] If the RRIBC mode is selected for the IBC ABVP, the candidates can be adjusted to point to the boundaries of the valid IBC search area in the horizontal or vertical direction according to the RRIBC mode.
[0770] Furthermore, the candidate items in the selected candidate list are determined according to the bitstream, and the specific steps are as follows:
[0771] In IBV merge mode (general_merge_flag[xCb][yCb] is true) and IBC ABVP mode (general_merge_flag[xCb][yCb] is false), the candidate index bvIdx is derived as follows, where general_merge_flag indicates whether it is IBC merge mode: bvIdx = general_merge_flag[xCb][yCb]? merge_idx[xCb][yCb]: mvp_l0_flag[xCb][yCb].
[0772] The final BV is determined based on the candidate.
[0773] In IBC merge mode, the specific bvL can be obtained according to the index bvIdx and the block vector candidate list bvCandList: bvL[0]=bvCandList[bvIdx][0]; bvL[1]=bvCandList[bvIdx][1];
[0774] This bvL is the final BV.
[0775] In IBC MBVD mode, similar to the MMVD in VVC's inter-frame technology, a candidate in the IBC merge list is used as the starting point, and a candidate is selected from the candidate point set corresponding to the predefined distance and direction set, and its corresponding block vector is used as the final BV.
[0776] For example, in IBC MBVD, the distance set is defined as {1-pel, 2-pel, 4-pel, 8-pel, 12pel, 16pel, 24pel, 32pel, 40pel, 48pel, 56pel, 64pel, 72pel, 80pel, 88pel, 96pel, 104pel, 112pel, 120pel, 128pel}, and the BVD directions are positive and negative horizontal directions and positive and negative vertical directions.
[0777] The base candidate can be selected from the first five candidates in the reordered IBC merge list, and all possible MBVD refinement positions (i.e., 20×4 candidates) of each base candidate are reordered based on the SAD cost between the template and its reference at each refinement position. Finally, the first 8 refinement positions with the smallest template SAD are retained for MBVD index encoding. The IBC-MBVD candidates do not inherit the flip type from the RR-IBC encoded neighboring blocks. The MBVD index is binarized using a Rice code with parameter equal to 1.
[0778] In the IBC TM merge mode, after obtaining the bvL based on the above information, the TM can also be used to locally refine the BV. The specific operation is to search within a small range centered on the obtained bvL and select the optimal BV within the range as the final BV based on the minimum template matching cost.
[0779] The TM refinement of the candidate list for the IBC merge mode is carried out. The specific implementation process is as follows:
[0780] When building a candidate, the flip type defaults to no flip;
[0781] IBC TM merge mode In IBC merge mode, the transmission syntax element specifies whether to perform integer-pixel precision TM refinement. The location of the refined motion vector and the template used in each refinement step must comply with the reference area constraints.
[0782] A search is performed near the candidate's pointed position, using the SAD between the template of the reference block and the template of the current block to determine the optimal position. This includes, but is not limited to, the following search methods: the search range is [-8, 8], and a diamond search is first performed on integer pixels, searching eight points near the center position, as shown in Figures 7A and 7B. The maximum number of searches is 375. After the optimal position is determined for the first time, the search continues, searching five points at even-numbered positions and three points at odd-numbered positions in subsequent searches.
[0783] For example, a circle is formed counterclockwise from the black point, which is the order of indexes 0 to 7. Specifically, when the black point position is selected as the optimal position, the search continues for 5 or 3 grid point positions. FIG. 7A and FIG. 7B are only exemplary.
[0784] After the above diamond search process, a whole-pixel cross search is performed only once. That is, after the diamond search finds the current optimal position, four positions with a distance of one pixel below, to the right, above, and to the left of the current optimal position are checked to update the final optimal position, that is, to update the refined candidate list.
[0785] For the IBC ABVP mode, the bvL obtained by indexing bvIdx and the block vector candidate list bvCandList is the predicted bvL. The real bvL also needs to be added with the block vector difference (BVD). The generalized specific process is as follows:
[0786] Step 1: Get the horizontal and vertical components of BVD, where MvdL0 is the forward motion vector difference. bvd[0] = MvdL0[xCb][yCb][0]; bvd[1] = MvdL0[xCb][yCb][1].
[0787] Step 2: Round the predicted bvL obtained above, where the right shift parameter AmvrShift is used for rounding and the left shift parameter AmvrShift is used to improve the resolution. Specifically: offset = (AmvrShift == 0)? 0: ((1 << (AmvrShift-1))-1); bvL[0] = Sign(bvL[0])*(((Abs(bvL[0])+offset)>>AmvrShift)<<AmvrShift); bvL[1]=Sign(bvL[1])*(((Abs(bvL[1])+offset)> >AmvrShift)< <AmvrShift)。
[0788] Step 3: The true bvL is derived as follows, and its range needs to be controlled between -217 and 217–1: u[0]=(bvL[0]+bvd[0]+218)%218; bvL[0]=(u[0]>=217)?(u[0]-218):u[0]; u[1]=(bvL[1]+bvd[1]+218)%218; bvL[1]=(u[1]>=217)?(u[1]-218):u[1].
[0789] It should be noted that the method of obtaining BVD in step 1 can also be inferred from syntax elements obtained through other encoding methods. The BVD of IBC ABVP uses sub-pixels, whole pixels or 4 pixels as units. During encoding, its symbol can be predicted, and the suffix of the exponential Golomb code obtained after its binarization can also be predicted. Therefore, its syntax elements can be defined by multiple information of the BVD value: whether it is 0, prefix, symbol, and suffix. The combination and analysis of these information can obtain the actual value of BVD. The specific embodiments are as follows:
[0790] Context coding is used to identify whether BVD is 0. The value of (absolute value -1) is binarized using first-order exponential Columbus. The first 5 binary data (bin) of the EG1 prefix are context coded, and the remaining prefixes are bypass coded. Up to 4 bins of the EG1 suffix use context coding to transmit the prediction index, and the other bins of the EG1 suffix use bypass coding. The two bins of the sign bit use context coding to transmit the symbol prediction index. Figure 8 shows the prediction process of a suffix bin with one transmission prediction index in the horizontal direction and one transmission symbol index in the horizontal direction and one transmission symbol index in the vertical direction. The current block template and the template at the corresponding BV are sorted to derive the prediction index of the suffix and symbol.
[0791] In this way, the final derived BV should be within the specified range (coordinate range in rows and columns).
[0792] For example, in VVC, the reference area of IBC is 128×128. For a 128×128 CTU, the reference area is shown in Figure 9. In Figure 9, whether (a), (b), (c), or (d), two CTUs are included. The area filled with diagonal lines is the reference area, and the small block filled with vertical lines represents the current block of 64×64 size. "×" represents an unavailable reference area.
[0793] In ECM 7.0, as shown in Figure 10, a box represents a CTU. Boxes filled with vertical lines represent the CTU where the current block is located, and boxes filled with diagonal lines represent its reference area. Specifically, for the current block to be encoded, assuming it is located in CTU (m, n), the reference area includes CTUs with indices (m–2, n–2)…(W, n–2)…(0, n–1)…(W, n–1), (0, n)…(m, n). W represents the maximum horizontal index within the current tile, slice, or picture.
[0794] When the CTU size is 256×256, the two rows of CTUs above may require additional memory. To prevent IBC from occupying additional memory, the reference area is adjusted, as shown in Figure 11. Each box represents a CTU, a box filled with vertical lines represents the CTU where the current block is located, and a box filled with diagonal lines represents its reference area.
[0795] The range of block vector search (or local search) for each block is restricted to horizontally [–(C<<1), C>>2] and vertically [–C, C>>2] to accommodate the reference area extension, where C represents the CTU size.
[0796] (2) Chroma component:
[0797] In the IBC mode of the chroma component, the BV of the chroma can be derived based on the luma BV, and then prediction and reconstruction can be achieved based on the chroma BV. The process of deriving the chroma BV based on the luma BV is as follows:
[0798] Input: bvL of brightness (1 / 16 pixel accuracy);
[0799] Output: bvC (Block Vector Chroma) of chroma (1 / 32 pixel accuracy).
[0800] The derivation process can be either direct scaling or scaling followed by refinement using TM.
[0801] For the scaling operation, an example is as follows: bvC[0]=((bvL[0]>>(3+SubWidthC))*32); bvC[1]=((bvL[1]>>(3+SubHeightC))*32).
[0802] Among them, the variables SubWidthC and SubHeightC specifically depend on the chroma format sampling structure specified by sps_chroma_format_idc. For specific corresponding relationships, please refer to the aforementioned Table 1.
[0803] For refinement operations, the following methods can be included:
[0804] TM is used for refinement. After obtaining the luminance BV, the offset position is found using the position of the chrominance block and the BV. A template is used to perform a detailed search near the offset position. The optimal BV (i.e., the refined BV) is obtained with the minimum TMcost as the criterion, as shown in Figure 12.
[0805] S2204: Establish a linear filtering model.
[0806] It should be noted that the linear filtering model can be established using the best matching template found in the previous step and the current coding block template. This mainly includes the following two processes: determining the reconstruction area for calculating the filter coefficients and calculating the filter coefficients.
[0807] It should also be noted that the number of filter taps is defined as nTap. nTap can be a constant or a variable, for example, the number of filter taps can be dynamically adjusted based on the block size. In the embodiments of the present application, filters of various shapes can be used. For example, a fixed-shape filter as shown in Figure 19 can be used, resulting in a filter tap number nTap of 5.
[0808] (a) Determine the reconstruction region for calculating the filter coefficients.
[0809] It should be noted that the available reconstructed pixels are determined according to the template type refTemplateType. For example, when the template type refTemplateType is 1, as shown in Figure 17, it means that the adjacent left, upper left, and upper reconstruction pixels are available, the number of available reconstructed pixels on the left is templateW_size*nTbH, the number of available reconstructed pixels on the upper side is templateH_size*nTbW, and the number of available reconstructed pixels on the upper left is templateW_size*templateH_size.
[0810] It should also be noted that filling boundary pixels is necessary because the filter may use reconstructed pixels outside the reference template and reference block. Depending on the filter shape, the area of the boundary that requires filling varies. One type of boundary filling area is shown in Figure 18A, and another type of boundary filling area is shown in Figure 18B. The grid area is the area that requires filling.
[0811] In the embodiments of the present application, there are also many different filling methods, including but not limited to:
[0812] One filling method is to determine whether the grid area is available. If it is available, the reconstructed pixels are directly used. If it is not available, the reconstructed pixels of the adjacent reference template or reference block are copied to fill the grid area.
[0813] Another filling method is to directly copy the reconstructed pixels of adjacent reference templates or reference blocks to fill the grid area.
[0814] Alternatively, another filling method is to not fill in the data, but to give up using the corresponding data in the calculation when encountering the boundary position.
[0815] In the embodiment of the present application, availability determination includes, but is not limited to, one or more of the following conditions:
[0816] The sampling point at this location has been reconstructed;
[0817] The location is within the search range of the MV / BV;
[0818] The position does not exceed the image boundaries;
[0819] The position does not exceed the Tile boundaries.
[0820] In this way, after determining the number of available reconstruction pixels, the reconstruction area used to calculate the filter coefficients is determined based on the available reconstruction pixels. This area is called R, and R usually includes all available reconstruction pixels in the template. For example, when refTemplateType is 1, R includes all available reconstruction pixels on the left, upper left, and upper sides.
[0821] (b) Calculate the filter coefficients.
[0822] After determining the reconstruction area R for calculating the filter coefficients, a set of filter coefficients is derived by minimizing the MSE of the reconstructed pixels in the area R and the reconstructed pixels of the current coding block template, that is: MSE = E[(predTemp[i][j] - recTemp[i][j]) 2 ] =E[(∑ k,l=-1~1 c k,l ·refTemp[i+k][j+l]-recTemp[i][j]) 2 ].
[0823] Where refTemp[i][j] represents the input reconstructed pixel value, recTemp[i][j] represents the reconstructed pixel value of the current coding block template, (i,j) represents the coordinate position, (i,j)∈R, k,l represents the coordinate offset of the filter coefficient position relative to the filter center position, taking Figure 11 as an example, k, l are between -1 and 1, and the values of (k,l) include (0,0), (0,-1), (-1,0), (0,1), (1,0), c k,l Indicates the required filter coefficient. E represents the operation of calculating the average value, and the calculation formula is as follows:
[0824] Among them, Npos refers to the number of nodes involved in the calculation of |predTemp[i][j]-recTemp[i][j]| 2 The number of (i,j) pairs.
[0825] The process of minimizing MSE to derive the filter coefficients is as follows:
[0826] 1) First, c k,l Find the partial derivative and make it 0:
[0827] Where m and n are between -1 and 1. E[2(∑ k,l=-1~1 c k,l ·refTemp[i+k][j+l]-recTemp[i][j])·refTemp[i+m][j+n]]=0,
[0828] After finishing, we can get:
[0829] 2) After determining the reconstruction area R, expand the equation obtained in step 1) into a matrix form:
[0830] 3) The autocorrelation matrix of refTemp in the reconstructed region R in 2) and the cross-correlation vector of refTemp and recTemp are both known quantities. Solving the equations in 2) can calculate the filter coefficient c k,l Among them, the filter coefficient c k,l Fixed-point conversion may or may not be performed, and there is no specific limitation here.
[0831] That is to say, in the process of solving the linear equations, the autocorrelation matrix of the reconstructed pixel refTemp in the reconstructed area R is first calculated, and then the cross-correlation vector between refTemp and the reconstructed pixel recTemp of the current template is calculated. Then, the autocorrelation matrix is decomposed by Cholesky or LDL, and finally, each filter coefficient c is calculated in turn by reverse recursion. n , the set of filter coefficients can be fixed-point or not.
[0832] S2205: Generate predicted value.
[0833] It should be noted that for each current block to be encoded, a set of filter coefficients can be obtained by the above method. The filter coefficients are c0, c1, c2...c nTap-1 The best matching reconstructed block is then filtered based on the filter shape and filter coefficients. This involves performing a weighted summation of the filter coefficients and the reference pixels at the corresponding position to obtain the current pixel to be predicted. Let ref be the best matching reconstructed block, which is defined as follows: ref[i][j] = recSamples[i + pX_BEST][j + pY_BEST].
[0834] Where i = 0, ..., nTbW-1, j = 0, ..., nTbH-1, recSamples are the reconstructed pixels of the current image, and pX_BEST and pY_BEST are the horizontal and vertical components of the optimal block vector.
[0835] The specific prediction value calculation process is as follows:
[0836] Assuming that the number of filter taps nTap is 5, the shape of the filter is shown in FIG20A , where c0, to c4, are the tap coefficients of the filter, respectively. The grid point corresponding to the tap coefficient C0 is the current pixel to be predicted Y pred [i][j] are the reconstructed pixels ref[i][j] at the corresponding positions in the best matching block; the other white dots are the reconstructed pixels adjacent to the current spatial position in the best matching reconstructed block. The black dots in Figure 20B are the predicted pixels Y pred [i][j].
[0837] For each current pixel to be predicted (i, j), the pixel position in the filter template is defined as (k, l), then the corresponding reconstructed pixel in the best matching block during filtering is defined as ref[i+k][j+l], and each filter coefficient at the position (k, l) in the filter template is defined as c k,l :
[0838] c k,l =c n ; where n=0,…,nTap-1, k and l are between -1 and 1.
[0839] For i = 0, ..., nTbW-1, j = 0, ..., nTbH-1, Y pred [i][j]=∑ k ∑ l ref[i+k][j+l]×C ,k,l .
[0840] The final predicted pixel is: predSamples[i][j]=Clip3(0,(1<<BitDepth)-1,Y pred [i][j]).
[0841] in,
[0842] In short, the embodiment of the present application proposes an IBC-FLM technology, which uses the template information of the matching template and the current coding block to establish a linear filtering model, fully utilizes the correlation between the matching template and the current coding block template, and filters and corrects the pixels of the best matching reconstructed block. The filtered reconstructed pixels are used as predicted pixels, which improves the prediction accuracy to a certain extent and effectively solves the problem of linear changes between the best matching reconstructed block and the current coding block.
[0843] Furthermore, in an embodiment of the present application, a linear filtering model is established between the best matching template obtained through the search and the current coding block template, the filter coefficient is obtained by minimizing the MSE calculation between the prediction template (prediction template = filter coefficient × matching template) and the current coding block template, the best matching reconstructed block is filtered and corrected, and the filtered reconstructed pixels are used as the final predicted pixels.
[0844] The input information used to calculate the filter coefficients can not only be the available reconstructed pixels of the matching template; in addition, the gradient of each pixel in the matching template can be calculated, including but not limited to the horizontal gradient and vertical gradient, and the calculated gradient can be used as the input information for calculating the filter coefficients. In addition, the position information of each pixel can also be used as the input information for calculating the filter. The position information can be the absolute position information of each pixel in the entire image, or the relative position information of each pixel relative to a reference point.
[0845] Furthermore, in the embodiment of the present application, for calculating the filter coefficients, the filter coefficients finally calculated are the tap coefficients corresponding to the filter template, that is, the number of filter coefficients is equal to the number of taps nTap of the filter template. In addition, several bias terms bias can be added to the filter template, for example:
[0846] In the main scheme, when nTap = 5, the filter coefficients are the tap coefficients c0 to c4 corresponding to the filter template, and the predicted value obtained by calculating the (i, j) position is:
[0847] At this time, a bias term can be added, specifically:
[0848] Among them, c n =c i,j,k,l . Where Constant can be a fixed constant, such as Constant = 1 << (BitDepth-1), or a number related to the reconstructed pixel value at position (i, j) in the reference block, such as Constant = f(ref[i][j]), or a number related to the reconstructed pixel value corresponding to a tap in the filter template other than position (i, j), such as Constant = f(ref[k][l]). Where Constant = f(ref[i][j]) or Constant = f(ref[k][l]) can be a linear mapping relationship or a nonlinear mapping relationship. One or more bias terms can be added.
[0849] Furthermore, in the embodiments of the present application, the number of filter models may be one linear filter model or multiple linear filter models. For example, the input information for calculating the filter coefficients is classified, and a filter model is established for each category of input information. For example, when using reconstruction information to establish a model, one achievable method is to classify the information by the mean of the reconstruction information, establishing a model for reconstruction information greater than the mean, and establishing a model for reconstruction information less than the mean.
[0850] Another feasible way is to use the position of the reconstruction information for classification. For example, a model can be established using the available reconstruction information on the left and upper sides, and a second model can be established using the available reconstruction information on the left and upper left sides. The encoder decides which model to use. One feasible decision-making method is for the encoder to decide which model to use through rate-distortion optimization and transmit the corresponding flag to the decoder.
[0851] Another feasible approach is to utilize filter shape classification. This allows for the use of multiple filters of different shapes, with filter models established for each shape. The encoder then decides which filter shape to use. One feasible approach is for the encoder to determine the filter shape through rate-distortion optimization and transmit a corresponding flag to the decoder.
[0852] Furthermore, in the embodiment of the present application, with respect to the type of filtering model, either a linear filtering model or a nonlinear filtering model may be established for filtering; no specific limitation is made here.
[0853] For example, one possible way to implement this is to introduce a quadratic term to establish a nonlinear filtering model. For example, when minimizing the MSE of the filter coefficients, the calculation method is changed to the following: MSE = E[(predTemp[i][j] - recTemp[i][j]) 2 ] =E[(∑ k,l=-1~1 c k,l (refTemp[i+k][j+l]) 2 -recTemp[i][j]) 2 ].
[0854] At the same time, for the calculation of the predicted value, the calculation method can be modified as follows: pred [i][j]=∑ k ∑ l (ref[j+k][j+l])2×C ,k,l .
[0855] Furthermore, in the embodiment of the present application, for the calculation of the prediction value, it is possible to determine whether the filtered prediction value of the current block is used as the final prediction value based on certain conditions. For example, there are the following methods:
[0856] (i) Determine whether to filter the matching template by comparing the distortion of the matching template and the current encoding template, such as SAD, MSE, SATD, or SSE, with the threshold T_Distortion1;
[0857] (ii) On the basis of satisfying the use of the filtering model in (i), the distortion between the filtered matching template and the template of the current coding block, such as SAD, MSE, SATD, or SSE, and the threshold T_Distortion2, is used to determine whether to filter the reference block.
[0858] (iii) The encoder transmits a flag to indicate whether to apply the filtering model. ibcFlag indicates whether the current coding block applies intra-block copying, and filterFlag indicates whether the current coding block applies the filtering model. When ibcFlag is 1, the encoder decides whether to filter the reference block by comparing the distortion between the reference block and the original block before and after filtering, such as SAD, MSE, SATD, or SSE. If the distortion after filtering is less than the distortion before filtering, filterFlag is 1, and the current coding block uses the reference block after filtering as the prediction block. Otherwise, filterFlag is 0, and the current coding block uses the reference block before filtering as the prediction block. The encoder transmits filterFlag to the decoder.
[0859] Furthermore, in the embodiment of the present application, for the reference block to which the filter coefficient is applied, in addition to calculating the filter coefficient only for the best matching template after the search and applying the filter coefficient to the best matching reference block, the filter coefficient can also be applied to all or part of the reference blocks in the search area, and certain conditions are used to determine which filtered reference block is used as the final prediction block. For example, there are the following methods:
[0860] (i) Calculate the filter coefficients for the templates within the search range and filter them. Calculate the cost of the template and the current template to decide which template to use. That is, calculate the filter coefficients for part or all of the templates to be searched in the search range, then apply the filter coefficients to the template to be searched, calculate the cost of the template and the current template, and select the best matching template after filtering based on the cost. Filter the reference block corresponding to the best matching template and use it as the final prediction value.
[0861] (ii) The encoder transmits a flag indicating which filtered reference block is used as the final prediction block. tmpFlag indicates whether template matching is applied to the current coding block, and filterIdx indicates which reference block within the current search range is applied to the filter model. When tmpFlag is 1, the encoder compares the distortion (SAD, MSE, SATD, or SSE) between the reference blocks within the search range that have the filter coefficients applied and the current original block, selects the optimal reference block, and transmits the corresponding index to the decoder.
[0862] Furthermore, in the embodiment of the present application, for the judgment of availability, "each sampling point in the template" may be replaced by "an identified sampling point in the template"; and "each sampling point in the reconstructed block corresponding to the template" may be replaced by "an identified sampling point in the reconstructed block corresponding to the template".
[0863] The identified sampling points in the template refer to one or more sampling points located at the corners of the template area, for example, when there is only an upper template, the upper left and lower right sampling points of the upper template area, or only the lower right sampling point.
[0864] The identified sampling points in the reconstructed block corresponding to the template refer to one or more sampling points located at the corners of the reconstructed block area, such as the sampling points at the upper left corner and the lower right corner of the reconstructed block area, or only the sampling point at the lower right corner of the reconstructed block area.
[0865] That is to say, in the embodiment of the present application, considering that the filter may use reconstructed sampling points outside the reference template and reference block, it is necessary to fill the boundary sampling points. One way to implement boundary filling is shown in Figure 26, and the grid area is the area that needs to be filled.
[0866] In one embodiment, the filling method is to determine whether the sampling points of the grid area are available one by one. If available, the reconstructed pixels are directly used. If not available, the reconstructed pixels of the nearest reference template or reference block are copied to fill the grid area.
[0867] The methods for determining whether it is applicable include but are not limited to the following conditions being met, or multiple conditions being met simultaneously:
[0868] The sampling point is within the image boundary;
[0869] The sampling point is within the Tile boundary;
[0870] The sampling points have been reconstructed;
[0871] In some embodiments, the filling method is to determine whether the position of the filling area exceeds the search range of the BV based on the search range of the BV. If it does not exceed the search range, the reconstructed sampling points are directly used. If it exceeds the search range, the reconstructed sampling points of the adjacent reference template or reference block are copied to fill the grid area. Specifically, the boundary needs to be filled based on iVerMin, iVerMax, iHorMin, and iHorMax derived in step s902:
[0872] The leftPadding, rightPadding, topPadding and bottomPadding are used to indicate whether the left grid area, right grid area, upper grid area and lower grid area copy the most recently reconstructed sampling point, i.e.
[0873] leftPadding=! (pX_Best>iHorMin)
[0874] rightPadding=!(pX_Best <iHorMax)
[0875] topPadding=! (pY_Best>iVerMin)
[0876] bottomPadding=!(pY_Best <iverMax)
[0877] In this way, if leftPadding is true, it means that the pixels in the left grid area are beyond the BV search range, and the reconstructed sampling points of the adjacent nearest reference template are copied, otherwise, the reconstructed pixels at this position are used directly. If rightPadding is true, it means that the pixels in the right grid area are beyond the BV search range, and the reconstructed sampling points of the adjacent nearest reference template or reference block are copied, otherwise, the reconstructed sampling points at this position are used directly. If topPadding is true, it means that the pixels in the upper grid area are beyond the BV search range, and the reconstructed sampling points of the adjacent nearest reference template are copied, otherwise, the reconstructed sampling points at this position are used directly. If bottomPadding is true, it means that the pixels in the lower grid area are beyond the BV search range, and the reconstructed sampling points of the adjacent reference template or reference block are copied, otherwise, the reconstructed sampling points at this position are used directly.
[0878] Furthermore, in the embodiments of the present application, the present technical solution can be implemented in conjunction with various sub-modes under IBC, including but not limited to ordinary IBC merge, IBC TM merge, MBVD, IBC CIIP, IBC ABVP, etc., without specific limitation.
[0879] In one possible implementation, in IBC flip mode, a method may be used to obtain predicted values by flipping the prediction region horizontally or vertically. For example, a syntax element may be used to indicate whether the region is flipped and, if so, whether it is flipped horizontally or vertically. The decoder, based on the syntax, reversely rearranges the pixels in the reference region horizontally or vertically to obtain predicted pixel values for the coding block.
[0880] In another possible implementation, a template can be used to establish a model between the current block and the predicted area. The predicted block is then processed according to the model to obtain the predicted value of the current block. For example, the IBC LIC mode, applied to IBC merge and IBC ABVP, uses a linear equation to compensate for local illumination changes. Similar to the LIC for inter-frame prediction in VVC, the parameters of the linear equation can be expressed as a scaling parameter α and an offset parameter β, that is, α*p[x]+β to compensate for illumination changes, where p[x] is the reference sample pointed to by the BV at position x in the current image. The linear model parameters are derived using the least squares method.
[0881] In another possible implementation, based on the above-obtained prediction value, weighted prediction with other intra-frame prediction methods can be implemented, and the result after weighted prediction is used as the final prediction result.
[0882] Among them, the weighted prediction method includes the inter-frame and intra-frame hybrid prediction CIIP method borrowed from VVC, that is, the result obtained by the above prediction process is weightedly combined with the prediction result obtained by the ordinary intra-frame directional prediction mode at each pixel position; it also includes the inter-frame geometric prediction mode GPM method borrowed from VVC, that is, based on a wedge division, the results obtained by using different prediction modes in different wedge areas, and weighted mixing in accordance with certain rules is performed near the wedge division line.
[0883] An example of the operation process in IBC CIIP mode: the IBC prediction value of the current block is weightedly fused with the prediction value of a certain intra-frame mode. The IBC prediction part can be obtained by applying the conventional merge, TM merge, MBVD and ABVP modes.
[0884] For the case where the IBC prediction part is the conventional IBC merge, TM merge, and MBVD mode, the weight ratio of IBC prediction and intra prediction is 13:3. The intra mode includes the TIMD mode of the current block and the intra prediction mode at the candidate BV. If the second prediction mode in the intra mode is the same as the first prediction mode, it is determined whether the first prediction mode is the PLANAR mode. If so, the second prediction mode is replaced with the horizontal prediction mode, otherwise the second prediction mode is replaced with the PLANAR mode.
[0885] For the case where the IBC prediction part is the ABVP mode, the weight ratio of the IBC prediction and the intra-frame prediction is 1:1, and the TIMD mode is obtained as the first prediction mode of the intra-frame prediction mode. If the derived prediction mode is the horizontal prediction mode, PLANAR is obtained as the second prediction mode of the intra-frame prediction mode. Otherwise, the horizontal prediction mode is obtained as the second prediction mode of the intra-frame prediction mode.
[0886] An example of the operation process in IBC GPM mode: Conventional merge and TM merge can be applied to the IBC prediction portion. A single IBC and INTRA partition is used. The intra prediction mode (IPM) candidate list is constructed using the same method as the inter GPM mode, and the IPM candidate list size is predefined as 3. In specific implementations, the 48 geometric partitioning modes can be divided into two geometric partitioning mode sets: Table 2 shows the first geometric partitioning mode set, and Table 3 shows the second geometric partitioning mode set.
[0887] When using IBC GPM, the IBC GPM geometric partitioning mode set flag is transmitted to indicate whether the first or second geometric partitioning mode set is selected, followed by the geometric partitioning mode index. The IBC-GPM frame partition flag is then transmitted to indicate whether intra prediction is used for the first sub-partition. The intra prediction portion requires the transmission of the intra prediction mode index, and the IBC prediction portion requires the transmission of the MEGRE index.
[0888] Furthermore, in an embodiment of the present application, a relevant mode selection flag (ibcFilterFlag) is transmitted at the CU layer. The encoding method of the ibcFilterFlag can be implemented in multiple ways. One implementable method is to use equal probability coding; another implementable method is to use context coding, and the default context initial state and context update rate can be used, or the context initial state and context update rate can be determined by statistics, and there is no specific limitation on this.
[0889] In the embodiment of the present application, the prediction value of the intra-frame block copy technology can be effectively corrected, thereby improving the prediction accuracy. Specifically, a linear filtering model is established between the best matching template obtained by searching and the current coding block template, and the filter coefficient is calculated by minimizing the MSE between the prediction template (prediction template = filter coefficient × matching template) and the current coding block template. The filter coefficient fully reflects the correlation between the matching template and the current coding block template, and this correlation is applied to the best matching reconstructed block, and its reconstructed pixels are filtered and corrected. The filtered reconstructed pixels are used as prediction pixels, which improves the prediction accuracy to a certain extent.
[0890] In another embodiment of the present application, based on the same inventive concept as the above embodiment, see Figure 23, which shows a schematic diagram of the composition structure of an encoder provided by an embodiment of the present application. As shown in Figure 23, the encoder 230 may include: a first determination unit 2301, a first filtering unit 2302 and a first prediction unit 2303; wherein,
[0891] The first determining unit 2301 is configured to determine a first template of the current block and determine a block vector candidate list of the current block; determine a first block vector according to the block vector candidate list; and determine a matching template and a corresponding reference block according to the first block vector;
[0892] A first filtering unit 2302 is configured to determine model parameters according to the first template and the matching template, and filter the reference block according to the model parameters to determine a filtered reference block;
[0893] The first prediction unit 2303 is configured to determine a prediction value of the current block according to the filtered reference block.
[0894] In some embodiments, the first determining unit 2301 is further configured to determine a template type of the current block; and determine a first template of the current block according to the template type of the current block.
[0895] In some embodiments, the first determination unit 2301 is further configured to determine the template type of the current block based on the reference pixels of the current block; wherein the reference pixels of the current block include at least one of the following: the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block, and the upper-left adjacent reference pixels of the current block.
[0896] In some embodiments, the first determining unit 2301 is further configured to encode the template type of the current block if both the left adjacent reference pixels of the current block and the upper adjacent reference pixels of the current block are available, and write the obtained encoding bits into the bitstream.
[0897] In some embodiments, the first determination unit 2301 is further configured to determine at least one first candidate block vector adjacent to the current block based on a derivation method of spatial block vector candidates; add the at least one first candidate block vector to a block vector candidate list; and if the number of candidates in the block vector candidate list meets a preset threshold, use the current block vector candidate list as a block vector candidate list for the current block.
[0898] In some embodiments, the first determination unit 2301 is further configured to determine at least one second candidate block vector based on a derivation method of historical block vector candidates if the number of candidates in the block vector candidate list does not meet a preset threshold, and continue to add the at least one second candidate block vector to the block vector candidate list; if the number of candidates in the block vector candidate list meets a preset threshold, use the current block vector candidate list as the block vector candidate list for the current block.
[0899] In some embodiments, the first determination unit 2301 is further configured to determine at least one third candidate block vector based on a derivation method of other available candidates if the number of candidates in the block vector candidate list does not meet a preset threshold, and continue to add the at least one third candidate block vector to the block vector candidate list until the number of candidates in the block vector candidate list meets the preset threshold.
[0900] In some embodiments, other available candidate derivation methods include at least one of the following: a method for deriving paired average candidates, a method for deriving zero-value block vector candidates, and a method for deriving reference area candidates corresponding to intra-frame block copies.
[0901] In some embodiments, the first determining unit 2301 is further configured to sort the block vector candidate list after determining the block vector candidate list of the current block.
[0902] In some embodiments, the first determining unit 2301 is further configured to, after determining the block vector candidate list of the current block, remove redundancy according to the distances between the candidate block vectors in the block vector candidate list.
[0903] In some embodiments, the first determining unit 2301 is further configured to, if the current block selects the non-flip intra block copy mode, delete at least one of the at least two candidate block vectors in the block vector candidate list when the distance between the at least two candidate block vectors meets a preset condition.
[0904] In some embodiments, the first determination unit 2301 is further configured to perform cost calculation on at least two candidate block vectors in the block vector candidate list to determine the cost value of each of the at least two candidate block vectors; determine the minimum cost value based on the cost values of each of the at least two candidate block vectors, and use the candidate block vector corresponding to the latest cost value as the first block vector.
[0905] In some embodiments, as shown in FIG23 , the encoder 230 may further include an encoding unit 2304, wherein:
[0906] The first determining unit 2301 is further configured to determine a block vector index number corresponding to the first block vector according to the block vector candidate list;
[0907] The encoding unit 2304 is configured to encode the block vector index sequence number and write the obtained encoding bits into the bitstream.
[0908] In some embodiments, the first determining unit 2301 is further configured to determine a block vector index number corresponding to the first block vector according to the block vector candidate list; determine a block vector difference value according to the initial block vector of the current block and the first block vector;
[0909] The encoding unit 2304 is further configured to encode the block vector index number and the block vector difference value, and write the obtained encoding bits into the bitstream.
[0910] In some embodiments, the first block vector is a luminance block vector, and the luminance block vector is used to determine a prediction value based on a luminance component of the current block.
[0911] In some embodiments, the first determination unit 2301 is further configured to scale the luminance block vector according to a preset chroma sampling format to determine a chroma block vector; wherein the chroma block vector is used to determine a prediction value of the current block based on the chroma component.
[0912] In some embodiments, the first determination unit 2301 is further configured to scale the luminance block vector according to a preset chroma sampling format to determine the scaled block vector; perform correction processing on the scaled block vector to determine the chroma block vector; wherein the chroma block vector is used to determine the predicted value of the current block based on the chroma component.
[0913] In some embodiments, the first determination unit 2301 is further configured to determine a reference template and a corresponding reference block based on the first block vector; if the reference template meets the first preset condition, perform a first processing on an adjacent area of the reference template to determine a matching template.
[0914] In some embodiments, the first determining unit 2301 is further configured to determine a reference template and a corresponding reference block according to the first block vector; if the reference template meets the second preset condition, the reference template is used as the matching template.
[0915] In some embodiments, the matching template includes: sampling points in the reference template and sampling points in an adjacent area of the reference template.
[0916] In some embodiments, the first determining unit 2301 is further configured to determine that the reference template meets the first preset condition if sampling points outside the reference template and the reference block are used.
[0917] In some embodiments, the first determining unit 2301 is further configured to determine that the reference template meets the second preset condition if no sampling points outside the reference template and the reference block are used.
[0918] In some embodiments, the first determining unit 2301 is further configured to perform a filling process on the sampling points in the adjacent area of the reference template if sampling points outside the reference template and the reference block are used.
[0919] In some embodiments, the first determining unit 2301 is further configured to determine whether the sampling points of the adjacent area of the reference template are available; if the sampling points of the adjacent area of the reference template are available, the sampling points of the adjacent area of the reference template are directly used; if the sampling points of the adjacent area of the reference template are not available, the filling unit is further configured to fill the adjacent area of the reference template by copying the reconstructed sampling points in the adjacent reference template or adjacent reference block of the sampling points to obtain the sampling points of the adjacent area of the reference template.
[0920] In some embodiments, the first determining unit 2301 is further configured to directly copy the reconstructed sampling points in the adjacent reference template or adjacent reference block of the sampling point to fill the adjacent area of the reference template to obtain the sampling points of the adjacent area of the reference template.
[0921] In some embodiments, the first determining unit 2301 is further configured to not fill in the sampling points in the adjacent area of the reference template if sampling points outside the reference template and the reference block are used, and skip the sampling points when determining the model parameters.
[0922] In some embodiments, the sampling points of the adjacent area of the reference template are available, including at least one of the following:
[0923] The sampling point does not exceed the preset search range;
[0924] The sampling points do not exceed the image boundary;
[0925] The sampling point does not exceed the tile boundary;
[0926] The sampling points have been rebuilt.
[0927] In some embodiments, the first determining unit 2301 is further configured to perform padding processing on the sampling points in the adjacent area of the reference block if the sampling points in the adjacent area of the reference block are used.
[0928] In some embodiments, the model parameters include coefficients of a target filter.
[0929] In some embodiments, the first determining unit 2301 is further configured to determine coefficients of the target filter according to the pixel reference values in the first template and the pixel reference values in the matching template.
[0930] In some embodiments, the first determination unit 2301 is further configured so that the coefficient of the target filter is the coefficient used by the target filter when the first error between the output value of the pixel reference value in the matching template after being processed by the target filter and the pixel reference value in the first template meets the first condition.
[0931] In some embodiments, the first condition is that the first error is minimized.
[0932] In some embodiments, the first condition is that the first error is within a first preset threshold range.
[0933] In some embodiments, the first condition is that the variation of the first error is within a second preset threshold range.
[0934] In some embodiments, the first determination unit 2301 is further configured to determine the autocorrelation parameters based on the pixel reference values in the matching template; determine the cross-correlation parameters based on the pixel reference values in the first template and the pixel reference values in the matching template; and determine the coefficients of the target filter based on the autocorrelation parameters and the cross-correlation parameters.
[0935] In some embodiments, the pixel reference value includes at least one of the following: a pixel reconstruction value, a pixel gradient value, and pixel position information.
[0936] In some embodiments, the number of coefficients of the target filter is equal to a first preset value.
[0937] In some embodiments, the first determining unit 2301 is further configured to determine the number of coefficients of the target filter;
[0938] The encoding unit 2304 is further configured to encode the number of coefficients of the target filter and write the obtained coded bits into the bitstream.
[0939] In some embodiments, the target filter is a one-dimensional or two-dimensional filter of a preset shape.
[0940] In some embodiments, the first determining unit 2301 is further configured to determine the shape of the target filter; the encoding unit is further configured to encode the shape of the target filter and write the obtained encoded bits into the bitstream.
[0941] In some embodiments, the first filtering unit 2302 is further configured to filter the reference block according to the model parameters to determine the first output value of the target filter; and determine the filtered reference block based on the first output value of the target filter.
[0942] In some embodiments, the first filtering unit 2302 is further configured to calculate the product of the pixel reconstruction value of the reference block and the coefficient of the corresponding target filter; and set the first output value of the target filter to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter, and n is a positive integer.
[0943] In some embodiments, the first filtering unit 2302 is further configured to determine a first value of the pixel reconstruction value of the reference block under a first mapping relationship; calculate the product of the first value and the coefficient of the corresponding target filter; and set the first output value of the target filter to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter, and n is a positive integer.
[0944] In some embodiments, the first filtering unit 2302 is further configured to determine a first offset value; and perform an addition operation based on the first output value and the first offset value to determine a filtered reference block.
[0945] In some embodiments, the first determining unit 2301 is further configured to set the first offset value to be equal to a second preset value.
[0946] In some embodiments, the first determination unit 2301 is further configured to determine the number of pixels participating in the filtering corresponding to the target filter based on the shape of the target filter; if the number of pixels of the reference filtering corresponding to the target filter is m, then determine the m+1 coefficients of the target filter, where m is a positive integer; and determine the first offset value based on one of the m+1 coefficients and the second offset value.
[0947] In some embodiments, the first determining unit 2301 is further configured to set the second offset value to be equal to a third preset value; or, set the second offset value to be equal to a value of the pixel reconstruction value of the reference block under the second mapping relationship.
[0948] In some embodiments, the first prediction unit 2303 is further configured to perform a second process on the filtered reference block to obtain a prediction value of the current block.
[0949] In some embodiments, the second process is to set the prediction value of the current block equal to the filtered reference block.
[0950] In some embodiments, the second processing is a clamping operation that limits the filtered reference block to a preset value range.
[0951] In some embodiments, the first determination unit 2301 is further configured to determine multiple sets of model parameters based on the first template and the matching template; construct multiple filter models based on the multiple sets of model parameters, filter the reference blocks according to the multiple filter models respectively, and determine multiple filtered reference blocks; and determine the prediction value of the current block based on the multiple filtered reference blocks.
[0952] In some embodiments, the first prediction unit 2303 is further configured to perform weighted calculation on multiple filtered reference blocks to determine a prediction value of the current block.
[0953] In some embodiments, the first determining unit 2301 is further configured to determine a target filter from a plurality of filter models;
[0954] The first filtering unit 2302 is further configured to perform filtering processing on the reference block according to the target filter to determine a prediction value of the current block.
[0955] In some embodiments, the first determining unit 2301 is further configured to determine a target model index value, wherein the target model index value is used to indicate an index number of a target filter in a plurality of filter models;
[0956] The encoding unit 2304 is further configured to encode the target model index value and write the obtained encoded bits into the bitstream.
[0957] In some embodiments, the first determination unit 2301 is further configured to determine the original value of the current block; and perform cost calculations based on the original value of the current block and multiple initial prediction values of the current block to determine the cost values of each of the multiple initial prediction values; determine the minimum cost value from the cost values of each of the multiple initial prediction values; and use the filter model corresponding to the minimum cost value as the target filter.
[0958] In some embodiments, the first determination unit 2301 is further configured to classify the reconstructed pixels in the first template and the matching template according to a preset method to obtain multiple groups of sub-templates and multiple groups of sub-matching templates; and determine multiple groups of model parameters based on the multiple groups of sub-templates and multiple groups of sub-matching templates.
[0959] In some embodiments, the first determining unit 2301 is further configured to determine a value of first syntax element identification information, wherein the first syntax element identification information is used to indicate whether intra block copy is applied to the current block;
[0960] The encoding unit 2304 is further configured to encode the value of the first syntax element identification information and write the obtained coded bits into the bitstream.
[0961] In some embodiments, the first determination unit 2301 is further configured to determine that the value of the first syntax element identification information is a first value if the current block applies intra-frame block copy; if the current block does not apply intra-frame block copy, determine that the value of the first syntax element identification information is a second value.
[0962] In some embodiments, the first determining unit 2301 is further configured to determine a value of second syntax element identification information, wherein the second syntax element identification information is used to indicate whether the filter model is applied to the current block;
[0963] The encoding unit 2304 is further configured to encode the value of the second syntax element identification information and write the obtained coded bits into the bitstream.
[0964] In some embodiments, the first determination unit 2301 is further configured to determine that the value of the second syntax element identification information is the first value if the current block applies the filter model; if the current block does not apply the filter model, determine that the value of the second syntax element identification information is the second value.
[0965] In some embodiments, the first determination unit 2301 is further configured to, if the current block applies a filter model, perform filtering processing on the reference block according to the model parameters to determine the filtered reference block; and determine the prediction value of the current block based on the filtered reference block; if the current block does not apply the filter model, the reconstructed pixel value in the reference block is used as the prediction value of the current block.
[0966] In some embodiments, the first determining unit 2301 is further configured to determine multiple reference blocks within the second search area and model parameters of each of the multiple reference blocks; filter the multiple reference blocks according to the model parameters of each of the multiple reference blocks to determine multiple filtered reference blocks; perform cost calculations between the multiple filtered reference blocks and the current block to determine cost values for each of the multiple filtered reference blocks; and determine a minimum cost value from the cost values of the multiple filtered reference blocks, and determine the filtered reference block and the corresponding reference block index number based on the minimum cost value.
[0967] The encoding unit 2304 is further configured to encode the reference block index sequence number and write the obtained encoding bits into the bitstream.
[0968] In some embodiments, the first determining unit 2301 is further configured to determine an original value of the current block; and determine a prediction difference value of the current block according to the original value of the current block and the prediction value of the current block.
[0969] It is understandable that in the embodiments of the present application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and of course it can also be a module, or it can be non-modular. Moreover, the various components in this embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into a single unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional modules.
[0970] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, or the portion that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0971] Therefore, an embodiment of the present application provides a computer-readable storage medium, which is applied to the encoder 230. The computer-readable storage medium stores a computer program, and when the computer program is executed by the first processor, it implements the method described in any one of the aforementioned embodiments.
[0972] Based on the composition of the encoder 230 and the computer-readable storage medium, refer to Figure 24, which shows a specific hardware structure diagram of the encoder 230 provided in an embodiment of the present application. As shown in Figure 24, the encoder 230 may include: a first communication interface 2401, a first memory 2402 and a first processor 2403; each component is coupled together through a first bus system 2404. It can be understood that the first bus system 2404 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 2404 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are labeled as the first bus system 2404 in Figure 24. Among them,
[0973] The first communication interface 2401 is used to receive and send signals when sending and receiving information with other external network elements;
[0974] A first memory 2402 is used to store computer programs that can be run on the first processor 2403;
[0975] The first processor 2403 is configured to, when running the computer program, execute:
[0976] Determining a first template of a current block, and determining a block vector candidate list of the current block;
[0977] Determine a first block vector according to the block vector candidate list; determine a matching template and a corresponding reference block according to the first block vector;
[0978] Model parameters are determined according to the first template and the matching template, and the reference block is filtered according to the model parameters to determine a filtered reference block; and a prediction value of the current block is determined according to the filtered reference block.
[0979] It is understood that the first memory 2402 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can 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 can 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 (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The first memory 2402 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0980] The first processor 2403 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in the first processor 2403. The above-mentioned first processor 2403 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the first memory 2402 , and the first processor 2403 reads the information in the first memory 2402 and completes the steps of the above method in combination with its hardware.
[0981] It is to be understood that these embodiments described in the present application can be implemented with hardware, software, firmware, middleware, microcode or its combination.For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing equipment (DSP Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field-Programmable Gate ...
Claims
1. A decoding method, applied to a decoder, the method comprising: Determine a first template of a current block, and determine a block vector candidate list of the current block; Decoding a bitstream, determining block vector indication information, and determining a first block vector according to the block vector indication information and the block vector candidate list; Determine a matching template and a corresponding reference block according to the first block vector; Determining model parameters according to the first template and the matching template, and filtering the reference block according to the model parameters to determine a filtered reference block; A prediction value of the current block is determined according to the filtered reference block.
2. The method according to claim 1, wherein: The determining of the first template of the current block comprises: Determining a template type of the current block; A first template of the current block is determined according to the template type of the current block.
3. The method according to claim 2, wherein: The determining the template type of the current block includes: Determining a template type of the current block according to a reference pixel of the current block; The reference pixels of the current block include at least one of the following: the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block and the upper left adjacent reference pixels of the current block.
4. The method according to claim 3, wherein: The determining the template type of the current block includes: If both the left adjacent reference pixels of the current block and the upper adjacent reference pixels of the current block are available, the bitstream is decoded to determine the template type of the current block.
5. The method according to claim 1, wherein: The determining of a block vector candidate list of the current block comprises: Determine at least one first candidate block vector adjacent to the current block based on a derivation method of spatial block vector candidates; adding the at least one first candidate block vector to the block vector candidate list; If the number of candidates in the block vector candidate list meets a preset threshold, the current block vector candidate list is used as the block vector candidate list of the current block.
6. The method according to claim 5, wherein: The method further comprises: If the number of candidates in the block vector candidate list does not meet a preset threshold, determining at least one second candidate block vector based on a derivation method of historical block vector candidates, and continuing to add the at least one second candidate block vector to the block vector candidate list; If the number of candidates in the block vector candidate list meets a preset threshold, the current block vector candidate list is used as the block vector candidate list of the current block.
7. The method according to claim 6, wherein: The method further comprises: If the number of candidates in the block vector candidate list does not meet the preset threshold, at least one third candidate block vector is determined based on the derivation method of other available candidates, and the at least one third candidate block vector is continuously added to the block vector candidate list until the number of candidates in the block vector candidate list meets the preset threshold.
8. The method according to claim 7, wherein: The derivation methods of the other available candidates include at least one of the following: a derivation method of a paired average candidate, a derivation method of a zero-value block vector candidate, and a derivation method of a reference area candidate corresponding to an intra-frame block copy.
9. The method according to claim 1, wherein: The method further comprises: After determining the block vector candidate list of the current block, the block vector candidate list is sorted.
10. The method according to claim 1, wherein: The method further comprises: After determining the block vector candidate list of the current block, redundancy is removed according to the distances between the candidate block vectors in the block vector candidate list.
11. The method according to claim 10, wherein: The redundancy removal includes: If the current block selects the non-flip intra block copy mode, then when the distance between at least two candidate block vectors in the block vector candidate list meets a preset condition, at least one of the at least two candidate block vectors is deleted.
12. The method according to claim 1, wherein: The block vector indication information includes a block vector index number; The determining the first block vector according to the block vector indication information and the block vector candidate list includes: Determine, in the block vector candidate list, a candidate block vector corresponding to the block vector index number; The candidate block vector is used as the first block vector.
13. The method according to claim 1, wherein: The block vector indication information includes a block vector index number and a block vector difference value; The determining the first block vector according to the block vector indication information and the block vector candidate list includes: Determine, in the block vector candidate list, a candidate block vector corresponding to the block vector index number; The first block vector is determined according to the candidate block vector and the block vector difference value.
14. The method according to claim 1, wherein: The block vector indication information includes a block vector index number; The determining the first block vector according to the block vector indication information and the block vector candidate list includes: Determine, in the block vector candidate list, a candidate block vector corresponding to the block vector index number; Determine a first candidate set according to the candidate block vector and predefined parameters; A block vector search is performed within the first candidate set to determine the first block vector.
15. The method according to claim 1, wherein: The block vector indication information includes a block vector index number; The determining the first block vector according to the block vector indication information and the block vector candidate list includes: Determine, in the block vector candidate list, a candidate block vector corresponding to the block vector index number; A first search area centered on the candidate block vector is determined, and a search is performed in the first search area based on a template matching method to determine the first block vector.
16. The method according to any one of claims 1 to 15, wherein: The first block vector is a luminance block vector, and the luminance block vector is used to determine a prediction value of the current block based on a luminance component.
17. The method according to any one of claims 1 to 15, wherein: The first block vector is a luminance block vector, and the method further comprises: The luminance block vector is scaled according to a preset chroma sampling format to determine a chroma block vector; wherein the chroma block vector is used to determine a prediction value of the current block based on the chroma component.
18. The method according to any one of claims 1 to 15, wherein: The first block vector is a luminance block vector; the method further comprises: Scaling the luminance block vector according to a preset chroma sampling format to determine a scaled block vector; The scaled block vector is corrected to determine a chrominance block vector; wherein the chrominance block vector is used to determine a prediction value of the current block based on the chrominance component.
19. The method according to claim 1, wherein: The determining, according to the first block vector, a matching template and a corresponding reference block includes: Determine a reference template and the corresponding reference block according to the first block vector; If the reference template meets the first preset condition, a first process is performed on the adjacent area of the reference template to determine the matching template.
20. The method according to claim 1, wherein: The determining, according to the first block vector, a matching template and a corresponding reference block includes: Determine a reference template and the corresponding reference block according to the first block vector; If the reference template meets the second preset condition, the reference template is used as the matching template.
21. The method according to claim 19 or 20, wherein: The matching template includes: sampling points in the reference template and sampling points in an adjacent area of the reference template.
22. The method according to claim 19, wherein: The method further comprises: If sampling points outside the reference template and the reference block are used, it is determined that the reference template meets a first preset condition.
23. The method according to claim 20, wherein: The method further comprises: If the sampling points outside the reference template and the reference block are not used, it is determined that the reference template meets the second preset condition.
24. The method according to claim 22, wherein: When the reference template meets a first preset condition, performing a first process on an adjacent area of the reference template includes: If sampling points outside the reference template and the reference block are used, the sampling points in the adjacent area of the reference template are filled.
25. The method according to claim 24, wherein: The filling process of the sampling points of the adjacent area of the reference template includes: Determining whether sampling points in an adjacent area of the reference template are available; If the sampling points of the adjacent area of the reference template are available, the sampling points of the adjacent area of the reference template are directly used; If the sampling points of the adjacent area of the reference template are not available, the adjacent area of the reference template is filled by copying the reconstructed sampling points in the adjacent reference template or adjacent reference block of the sampling points to obtain the sampling points of the adjacent area of the reference template.
26. The method according to claim 24, wherein: The filling process of the sampling points of the adjacent area of the reference template includes: The adjacent area of the reference template is directly copied to reconstruct the sampling points in the adjacent reference block or the adjacent reference block of the sampling point to perform filling processing on the adjacent area of the reference template, so as to obtain the sampling points of the adjacent area of the reference template.
27. The method of claim 22, wherein: The method further comprises: If sampling points outside the reference template and the reference block are used, the sampling points in the adjacent area of the reference template are not filled, and the sampling points are skipped when determining the model parameters.
28. The method according to claim 25, wherein: The sampling points of the adjacent area of the reference template are available, including at least one of the following: The sampling points do not exceed the preset search range; The sampling points do not exceed the image boundary; The sampling point does not exceed the tile boundary; The sampling points have been reconstructed.
29. The method according to claim 19, wherein: The filtering the reference block according to the model parameters to determine the filtered reference block includes: If the sampling points of the adjacent area of the reference block are used, the sampling points of the adjacent area of the reference block are filled.
30. The method of claim 1, wherein: The determining of the model parameters according to the first template and the matching template includes: The model parameters include coefficients of the target filter.
31. The method according to claim 30, wherein: The method further comprises: The coefficients of the target filter are determined according to the pixel reference values in the first template and the pixel reference values in the matching template.
32. The method according to claim 31, wherein: The method further comprises: The coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after being processed by the target filter and a pixel reference value in the first template satisfies a first condition.
33. The method of claim 32, wherein: The method further comprises: The first condition is that the first error is minimum.
34. The method of claim 32, wherein: The method further comprises: The first condition is that the first error is within a first preset threshold range.
35. The method of claim 32, wherein: The method further comprises: The first condition is that the change in the first error is within a second preset threshold range.
36. The method of claim 31, wherein: The step of determining the coefficient of the target filter according to the pixel reference value in the first template and the pixel reference value in the matching template comprises: Determining an autocorrelation parameter according to a pixel reference value in the matching template; Determining a cross-correlation parameter according to a pixel reference value in the first template and a pixel reference value in the matching template; The coefficients of the target filter are determined according to the autocorrelation parameters and the cross-correlation parameters.
37. The method of claim 31, wherein: The pixel reference value includes at least one of the following: a pixel reconstruction value, a pixel gradient value, and pixel position information.
38. The method of claim 30, wherein: The number of coefficients of the target filter is equal to a first preset value.
39. The method of claim 30, wherein: The method further comprises: The code stream is decoded to determine the number of coefficients of the target filter.
40. The method of claim 30, wherein: The target filter is a one-dimensional or two-dimensional filter of a preset shape.
41. The method of claim 30, wherein: The method further comprises: The code stream is decoded to determine the shape of the target filter.
42. The method of claim 30, wherein: The filtering the reference block according to the model parameters to determine the filtered reference block includes: Performing filtering processing on the reference block according to the model parameters to determine a first output value of the target filter; The filtered reference block is determined based on a first output value of the target filter.
43. The method of claim 42, wherein: The filtering process is performed on the reference block according to the model parameters to determine the first output value of the target filter, comprising: Calculating the product of the pixel reconstruction value of the reference block and the corresponding coefficient of the target filter; The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter, and n is a positive integer.
44. The method of claim 42, wherein: The filtering process is performed on the reference block according to the model parameters to determine the first output value of the target filter, comprising: Determine a first value of a pixel reconstruction value of the reference block under a first mapping relationship; Calculate the product of the first value and the corresponding coefficient of the target filter; The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter, and n is a positive integer.
45. The method of claim 42, wherein: The step of determining the filtered reference block based on the first output value of the target filter comprises: determining a first offset value; An addition operation is performed according to the first output value and the first offset value to determine the filtered reference block.
46. The method of claim 45, wherein: The determining of the first offset value comprises: The first offset value is set equal to a second preset value.
47. The method of claim 45, wherein: The determining of the first offset value comprises: Based on the shape of the target filter, determining the number of pixels participating in filtering corresponding to the target filter; If the number of pixels of the reference filter corresponding to the target filter is m, then determine m+1 coefficients of the target filter, where m is a positive integer; The first offset value is determined according to one of the m+1 coefficients and a second offset value.
48. The method of claim 47, wherein: The method further comprises: setting the second offset value to be equal to a third preset value; or, The second offset value is set to be equal to the value of the pixel reconstruction value of the reference block under the second mapping relationship.
49. The method according to any one of claims 1 to 48, wherein: The step of determining the prediction value of the current block according to the filtered reference block comprises: The filtered reference block is subjected to a second process to obtain a prediction value of the current block.
50. The method of claim 49, wherein: The method further comprises: The second process is to set the prediction value of the current block equal to the filtered reference block.
51. The method of claim 49, wherein: The method further comprises: The second processing is a clamping operation that limits the filtered reference block to a preset value range.
52. The method of claim 1, wherein: The method further comprises: Determining multiple groups of model parameters according to the first template and the matching template; Constructing a plurality of filter models according to the plurality of groups of model parameters, filtering the reference blocks respectively according to the plurality of filter models, and determining a plurality of filtered reference blocks; A prediction value of the current block is determined according to the multiple filtered reference blocks.
53. The method of claim 52, wherein: The step of determining the prediction value of the current block according to the plurality of filtered reference blocks comprises: A weighted calculation is performed on the multiple filtered reference blocks to determine a prediction value of the current block.
54. The method of claim 52, wherein: The method further comprises: Decode the code stream and determine the target model index value; Determining a corresponding target filter from the plurality of filter models according to the target model index value; The reference block is filtered according to the target filter to determine a prediction value of the current block.
55. The method of claim 52, wherein: The step of determining multiple groups of model parameters according to the first template and the matching template includes: Classifying the reconstructed pixels in the first template and the matching template respectively according to a preset method to obtain multiple groups of sub-templates and multiple groups of sub-matching templates; The multiple groups of model parameters are determined according to the multiple groups of sub-templates and the multiple groups of sub-matching templates.
56. The method of claim 1, wherein: The method further comprises: Decoding the bitstream to determine a value of the first syntax element identification information; If the first syntax element identification information is used to indicate that the current block applies an intra block copy, decoding the bitstream to determine a value of the second syntax element identification information; If the second syntax element identification information is used to indicate that a filter model is applied to the current block, the steps of filtering the reference block according to the model parameters to determine a filtered reference block; and determining a prediction value of the current block according to the filtered reference block are performed.
57. The method of claim 56, wherein: The method further comprises: If the second syntax element identification information is used to indicate that the filter model is not applied to the current block, the reconstructed pixel value in the reference block is used as the prediction value of the current block.
58. The method of claim 1, wherein: The method further comprises: Determine a plurality of reference blocks within a second search area and model parameters of each of the plurality of reference blocks; Performing filtering processing on the multiple reference blocks respectively according to the model parameters of the multiple reference blocks, and determining multiple filtered reference blocks; A prediction value of the current block is determined according to the multiple filtered reference blocks.
59. The method of claim 58, wherein: The step of determining the prediction value of the current block according to the plurality of filtered reference blocks comprises: Decode the code stream and determine the reference block index number; Among the multiple filtered reference blocks, the filtered reference block is determined according to the reference block index sequence number.
60. The method according to any one of claims 1 to 59, wherein: The method further comprises: Decoding a bitstream to determine a prediction residual of the current block; A reconstructed value of the current block is determined according to the predicted value of the current block and the predicted difference value of the current block.
61. A coding method, applied to an encoder, the method comprising: Determine a first template of a current block, and determine a block vector candidate list of the current block; Determine a first block vector according to the block vector candidate list; Determine a matching template and a corresponding reference block according to the first block vector; Determining model parameters according to the first template and the matching template, and filtering the reference block according to the model parameters to determine a filtered reference block; A prediction value of the current block is determined according to the filtered reference block.
62. The method of claim 61, wherein: The determining of the first template of the current block comprises: Determining a template type of the current block; A first template of the current block is determined according to the template type of the current block.
63. The method of claim 62, wherein: The determining the template type of the current block includes: Determining a template type of the current block according to a reference pixel of the current block; The reference pixels of the current block include at least one of the following: the left adjacent reference pixels of the current block, the upper adjacent reference pixels of the current block and the upper left adjacent reference pixels of the current block.
64. The method of claim 63, wherein: The method further comprises: If both the left adjacent reference pixels of the current block and the upper adjacent reference pixels of the current block are available, the template type of the current block is encoded, and the obtained encoding bits are written into the bitstream.
65. The method of claim 61, wherein: The determining of a block vector candidate list of the current block comprises: Determine at least one first candidate block vector adjacent to the current block based on a derivation method of spatial block vector candidates; adding the at least one first candidate block vector to the block vector candidate list; If the number of candidates in the block vector candidate list meets a preset threshold, the current block vector candidate list is used as the block vector candidate list of the current block.
66. The method of claim 65, wherein: The method further comprises: If the number of candidates in the block vector candidate list does not meet a preset threshold, determining at least one second candidate block vector based on a derivation method of historical block vector candidates, and continuing to add the at least one second candidate block vector to the block vector candidate list; If the number of candidates in the block vector candidate list meets a preset threshold, the current block vector candidate list is used as the block vector candidate list of the current block.
67. The method of claim 66, wherein: The method further comprises: If the number of candidates in the block vector candidate list does not meet the preset threshold, at least one third candidate block vector is determined based on the derivation method of other available candidates, and the at least one third candidate block vector is continuously added to the block vector candidate list until the number of candidates in the block vector candidate list meets the preset threshold.
68. The method of claim 67, wherein: The derivation methods of the other available candidates include at least one of the following: a derivation method of a paired average candidate, a derivation method of a zero-value block vector candidate, and a derivation method of a reference area candidate corresponding to an intra-frame block copy.
69. The method of claim 61, wherein: The method further comprises: After determining the block vector candidate list of the current block, the block vector candidate list is sorted.
70. The method of claim 61, wherein: The method further comprises: After determining the block vector candidate list of the current block, redundancy is removed according to the distances between the candidate block vectors in the block vector candidate list.
71. The method of claim 70, wherein: The redundancy removal includes: If the current block selects the non-flip intra block copy mode, then when the distance between at least two candidate block vectors in the block vector candidate list meets a preset condition, at least one of the at least two candidate block vectors is deleted.
72. The method of claim 61, wherein: The step of determining the first block vector according to the block vector candidate list includes: Performing cost calculation on at least two candidate block vectors in the block vector candidate list to determine respective cost values of the at least two candidate block vectors; A minimum cost value is determined according to the cost values of the at least two candidate block vectors, and the candidate block vector corresponding to the most recent cost value is used as the first block vector.
73. The method of claim 61, wherein: The method further comprises: Determine, according to the block vector candidate list, a block vector index number corresponding to the first block vector; The block vector index sequence number is encoded, and the obtained encoding bits are written into a bit stream.
74. The method of claim 61, wherein: The method further comprises: Determine, according to the block vector candidate list, a block vector index number corresponding to the first block vector; Determine a block vector difference value according to an initial block vector of the current block and the first block vector; The block vector index number and the block vector difference value are encoded, and the obtained encoding bits are written into a bit stream.
75. The method of any one of claims 61 to 74, wherein: The first block vector is a luminance block vector, and the luminance block vector is used to determine a prediction value of the current block based on a luminance component.
76. The method of any one of claims 61 to 74, wherein: The first block vector is a luminance block vector, and the method further comprises: The luminance block vector is scaled according to a preset chroma sampling format to determine a chroma block vector; wherein the chroma block vector is used to determine a prediction value of the current block based on the chroma component.
77. The method of any one of claims 61 to 74, wherein: The first block vector is a luminance block vector; the method further comprises: Scaling the luminance block vector according to a preset chroma sampling format to determine a scaled block vector; The scaled block vector is corrected to determine a chrominance block vector; wherein the chrominance block vector is used to determine a prediction value of the current block based on the chrominance component.
78. The method of claim 61, wherein: The determining, according to the first block vector, a matching template and a corresponding reference block includes: Determine a reference template and the corresponding reference block according to the first block vector; If the reference template meets the first preset condition, a first process is performed on the adjacent area of the reference template to determine the matching template.
79. The method of claim 61, wherein: The determining, according to the first block vector, a matching template and a corresponding reference block includes: Determine a reference template and the corresponding reference block according to the first block vector; If the reference template meets the second preset condition, the reference template is used as the matching template.
80. The method of claim 78 or 79, wherein: The matching template includes: sampling points in the reference template and sampling points in an adjacent area of the reference template.
81. The method of claim 78, wherein: The method further comprises: If sampling points outside the reference template and the reference block are used, it is determined that the reference template meets a first preset condition.
82. The method of claim 79, wherein: The method further comprises: If the sampling points outside the reference template and the reference block are not used, it is determined that the reference template meets the second preset condition.
83. The method of claim 81, wherein: When the reference template meets a first preset condition, performing a first process on an adjacent area of the reference template includes: If sampling points outside the reference template and the reference block are used, the sampling points in the adjacent area of the reference template are filled.
84. The method of claim 83, wherein: The filling process of the sampling points of the adjacent area of the reference template includes: Determining whether sampling points in an adjacent area of the reference template are available; If the sampling points of the adjacent area of the reference template are available, the sampling points of the adjacent area of the reference template are directly used; If the sampling points of the adjacent area of the reference template are not available, the adjacent area of the reference template is filled by copying the reconstructed sampling points in the adjacent reference template or adjacent reference block of the sampling points to obtain the sampling points of the adjacent area of the reference template.
85. The method of claim 83, wherein: The filling process of the sampling points of the adjacent area of the reference template includes: The adjacent area of the reference template is directly copied to reconstruct the sampling points in the adjacent reference block or the adjacent reference block of the sampling point to perform filling processing on the adjacent area of the reference template, so as to obtain the sampling points of the adjacent area of the reference template.
86. The method of claim 81, wherein: The method further comprises: If sampling points outside the reference template and the reference block are used, the sampling points in the adjacent area of the reference template are not filled, and the sampling points are skipped when determining the model parameters.
87. The method of claim 84, wherein: The sampling points of the adjacent area of the reference template are available, including at least one of the following: The sampling points do not exceed the preset search range; The sampling points do not exceed the image boundary; The sampling point does not exceed the tile boundary; The sampling points have been reconstructed.
88. The method of claim 78, wherein: The filtering the reference block according to the model parameters to determine the filtered reference block includes: If the sampling points of the adjacent area of the reference block are used, the sampling points of the adjacent area of the reference block are filled.
89. The method of claim 61, wherein: The determining of the model parameters according to the first template and the matching template includes: The model parameters include coefficients of the target filter.
90. The method of claim 89, wherein: The method further comprises: The coefficients of the target filter are determined according to the pixel reference values in the first template and the pixel reference values in the matching template.
91. The method of claim 90, wherein: The method further comprises: The coefficients of the target filter are coefficients used by the target filter when a first error between an output value of a pixel reference value in the matching template after being processed by the target filter and a pixel reference value in the first template satisfies a first condition.
92. The method of claim 91, wherein: The method further comprises: The first condition is that the first error is minimum.
93. The method of claim 91, wherein: The method further comprises: The first condition is that the first error is within a first preset threshold range.
94. The method of claim 91, wherein: The method further comprises: The first condition is that the change in the first error is within a second preset threshold range.
95. The method of claim 90, wherein: The step of determining the coefficient of the target filter according to the pixel reference value in the first template and the pixel reference value in the matching template comprises: Determining an autocorrelation parameter according to a pixel reference value in the matching template; Determining a cross-correlation parameter according to a pixel reference value in the first template and a pixel reference value in the matching template; The coefficients of the target filter are determined according to the autocorrelation parameters and the cross-correlation parameters.
96. The method of claim 90, wherein: The pixel reference value includes at least one of the following: a pixel reconstruction value, a pixel gradient value, and pixel position information.
97. The method of claim 89, wherein: The number of coefficients of the target filter is equal to a first preset value.
98. The method of claim 89, wherein: The method further comprises: Determining the number of coefficients of the target filter; The number of coefficients of the target filter is encoded, and the obtained encoded bits are written into a bit stream.
99. The method of claim 89, wherein: The target filter is a one-dimensional or two-dimensional filter of a preset shape.
100. The method of claim 89, wherein: The method further comprises: Determining the shape of the target filter; The shape of the target filter is encoded, and the obtained encoded bits are written into a bitstream.
101. The method of claim 89, wherein: The filtering the reference block according to the model parameters to determine the filtered reference block includes: Performing filtering processing on the reference block according to the model parameters to determine a first output value of the target filter; The filtered reference block is determined based on a first output value of the target filter.
102. The method according to claim 101, wherein: The filtering process is performed on the reference block according to the model parameters to determine the first output value of the target filter, comprising: Calculating the product of the pixel reconstruction value of the reference block and the corresponding coefficient of the target filter; The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter, and n is a positive integer.
103. The method of claim 101, wherein: The filtering process is performed on the reference block according to the model parameters to determine the first output value of the target filter, comprising: Determine a first value of a pixel reconstruction value of the reference block under a first mapping relationship; Calculate the product of the first value and the corresponding coefficient of the target filter; The first output value of the target filter is set to be equal to the sum of n products; wherein n represents the number of coefficients of the target filter, and n is a positive integer.
104. The method of claim 101, wherein: The step of determining the filtered reference block based on the first output value of the target filter comprises: determining a first offset value; An addition operation is performed according to the first output value and the first offset value to determine the filtered reference block.
105. The method of claim 104, wherein: The determining of the first offset value comprises: The first offset value is set equal to a second preset value.
106. The method of claim 104, wherein: The determining of the first offset value comprises: Based on the shape of the target filter, determining the number of pixels participating in filtering corresponding to the target filter; If the number of pixels of the reference filter corresponding to the target filter is m, then determine m+1 coefficients of the target filter, where m is a positive integer; The first offset value is determined according to one of the m+1 coefficients and a second offset value.
107. The method of claim 106, wherein: The method further comprises: setting the second offset value to be equal to a third preset value; or, The second offset value is set to be equal to the value of the pixel reconstruction value of the reference block under the second mapping relationship.
108. The method of any one of claims 61 to 107, wherein: The step of determining the prediction value of the current block according to the filtered reference block comprises: The filtered reference block is subjected to a second process to obtain a prediction value of the current block.
109. The method of claim 108, wherein: The method further comprises: The second process is to set the prediction value of the current block equal to the filtered reference block.
110. The method of claim 108, wherein: The method further comprises: The second processing is a clamping operation that limits the filtered reference block to a preset value range.
111. The method of claim 61, wherein: The method further comprises: Determining multiple groups of model parameters according to the first template and the matching template; Constructing a plurality of filter models according to the plurality of groups of model parameters, filtering the reference blocks respectively according to the plurality of filter models, and determining a plurality of filtered reference blocks; A prediction value of the current block is determined according to the multiple filtered reference blocks.
112. The method according to claim 111, wherein: The step of determining the prediction value of the current block according to the plurality of filtered reference blocks comprises: A weighted calculation is performed on the multiple filtered reference blocks to determine a prediction value of the current block.
113. The method according to claim 111, wherein: The method further comprises: determining a target filter from a plurality of filter models; The reference block is filtered according to the target filter to determine a prediction value of the current block.
114. The method of claim 113, wherein: The method further comprises: Determine a target model index value, wherein the target model index value is used to indicate an index number of the target filter in the plurality of filter models; The target model index value is encoded, and the obtained encoded bits are written into a bitstream.
115. The method of claim 113, wherein: The determining of a target filter from a plurality of filter models comprises: Determining an original value of the current block; Performing cost calculations respectively according to the original value of the current block and the multiple initial prediction values of the current block to determine the cost values of the multiple initial prediction values; determining a minimum cost value from among the cost values of the plurality of initial prediction values; The filter model corresponding to the minimum cost value is used as the target filter.
116. The method of claim 111, wherein: The step of determining multiple groups of model parameters according to the first template and the matching template includes: Classifying the reconstructed pixels in the first template and the matching template respectively according to a preset method to obtain multiple groups of sub-templates and multiple groups of sub-matching templates; The multiple groups of model parameters are determined according to the multiple groups of sub-templates and the multiple groups of sub-matching templates.
117. The method of claim 61, wherein: The method further comprises: Determine a value of first syntax element identification information, wherein the first syntax element identification information is used to indicate whether intra block copy is applied to the current block; The value of the first syntax element identification information is encoded, and the obtained encoded bits are written into a bitstream.
118. The method of claim 117, wherein: The determining a value of the first syntax element identification information includes: If the current block applies intra block copy, determine that the value of the first syntax element identification information is a first value; If intra block copy is not applied to the current block, it is determined that the value of the first syntax element identification information is a second value.
119. The method of claim 117, wherein: When the first syntax element identification information is used to indicate that the current block applies an intra block copy, the method further includes: Determine a value of second syntax element identification information, wherein the second syntax element identification information is used to indicate whether a filter model is applied to the current block; The value of the second syntax element identification information is encoded, and the obtained encoded bits are written into a bitstream.
120. The method of claim 119, wherein: The determining a value of the second syntax element identification information includes: If the current block applies a filter model, determining that the value of the second syntax element identification information is a first value; If the filter model is not applied to the current block, it is determined that the value of the second syntax element identification information is a second value.
121. The method of claim 119, wherein: The method further comprises: If the current block applies a filter model, the steps of filtering the reference block according to the model parameters to determine a filtered reference block; and determining a prediction value of the current block according to the filtered reference block; If the filter model is not applied to the current block, the reconstructed pixel value in the reference block is used as the prediction value of the current block.
122. The method of claim 61, wherein: The method further comprises: Determine a plurality of reference blocks within a second search area and model parameters of each of the plurality of reference blocks; Performing filtering processing on the multiple reference blocks respectively according to the model parameters of the multiple reference blocks, and determining multiple filtered reference blocks; Performing cost calculations between the multiple filtered reference blocks and the current block respectively to determine cost values of the multiple filtered reference blocks; Determine a minimum cost value from the cost values of the plurality of filtered reference blocks, and determine the filtered reference block and the corresponding reference block index number according to the minimum cost value; The reference block index number is encoded, and the obtained encoding bits are written into a bit stream.
123. The method according to any one of claims 61 to 122, wherein: The method further comprises: Determining an original value of the current block; A prediction difference value of the current block is determined according to the original value of the current block and the prediction value of the current block.
124. A code stream, wherein The code stream is generated by bit encoding according to the information to be encoded; wherein the information to be encoded includes at least one of the following: The prediction difference value of the current block, block vector indication information, reference block index sequence number, number of coefficients of the target filter, shape of the target filter, value of the first syntax element identification information and value of the second syntax element identification information; wherein the first syntax element identification information is used to indicate whether the current block applies intra block copy, and the second syntax element identification information is used to indicate whether the current block applies a filter model.
125. An encoder, comprising a first determining unit, a first filtering unit and a first predicting unit; wherein: The first determining unit is configured to determine a first template of a current block, and determine a block vector candidate list of the current block; The first determining unit is further configured to determine a first block vector according to the block vector candidate list; and determine a matching template and a corresponding reference block according to the first block vector; The first filtering unit is configured to determine a model parameter according to the first template and the matching template, and filter the reference block according to the model parameter to determine a filtered reference block; The first prediction unit is configured to determine a prediction value of the current block according to the filtered reference block.
126. An encoder comprising a first memory and a first processor; wherein: The first memory is used to store a computer program that can be run on the first processor; The first processor is used to execute the method as described in any one of claims 61 to 123 when running the computer program.
127. A decoder comprising a second determining unit, a decoding unit, a second filtering unit and a second prediction unit; wherein: The second determining unit is configured to determine a first template of a current block, and determine a block vector candidate list of the current block; The decoding unit is configured to decode the code stream and determine the block vector indication information; The second determining unit is further configured to determine a first block vector according to the block vector indication information and the block vector candidate list; and determine a matching template and a corresponding reference block according to the first block vector; The second filtering unit is configured to determine model parameters according to the first template and the matching template, and Performing filtering on the reference block to determine a filtered reference block; The second prediction unit is configured to determine a prediction value of the current block according to the filtered reference block.
128. A decoder comprising a second memory and a second processor; wherein: The second memory is used to store a computer program that can be run on the second processor; The second processor is configured to execute the method according to any one of claims 1 to 60 when running the computer program.
129. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed, it implements the method according to any one of claims 1 to 60, or implements the method according to any one of claims 61 to 123.