Encoding and decoding method, code stream, encoder, decoder and storage medium
Patent Information
- Application Number
- CN202380098141.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2025-12-19
AI Technical Summary
Common intra-template matching prediction technology in video encoding and decoding results in low encoding and decoding efficiency and performance.
By introducing a predetermined parameter, such as matching cost thresholds, controlling the search process, selectively ending early or continuing the search, the computational complexity is reduced.
It improves the encoding and decoding efficiency and performance, solves the problem of high computational complexity, and improves the processing efficiency of intra-template matching prediction.
Smart Images

Figure CN121176014A_ABST
Abstract
Description
Coding and decoding method, code stream, encoder, decoder and storage medium Technical Field
[0001] The embodiments of the present application relate 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 Template Matching Prediction (Intra TMP) technology uses the template of the coding block to search for the matching template with the minimum cost according to a preset cost function within a predefined search range in the current image, and uses the best matching reconstructed block corresponding to the matching template as the prediction block of the current coding block.
[0003] However, common search strategies often suffer from high computational complexity, which reduces encoding and decoding efficiency and performance.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a coding and decoding method, a code stream, an encoder, a decoder, and a storage medium, which can reduce computational complexity and thus improve coding and decoding efficiency and performance.
[0006] The technical solution of the embodiment of the present 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] When the prediction mode of the current block is an intra-frame prediction mode based on template matching, determining a first template corresponding to the current block, and determining a preset search area according to the first template;
[0009] Searching within the preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process;
[0010] A prediction value of the current block is determined according to the block vector of the current block.
[0011] In a second aspect, an embodiment of the present application provides an encoding method, applied to an encoder, the method comprising:
[0012] When the prediction mode of the current block is an intra-frame prediction mode based on template matching, determining a first template corresponding to the current block, and determining a preset search area according to the first template;
[0013] Searching within the preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process;
[0014] A prediction value of the current block is determined according to the block vector of the current block.
[0015] In a third aspect, an embodiment of the present application provides a code stream, wherein the code stream is generated by bit encoding based on information to be encoded; wherein the information to be encoded includes at least one of the following:
[0016] The prediction difference of the current block, the first parameter, the second parameter, the size of the template, and the template type indication information.
[0017] In a fourth aspect, an embodiment of the present application provides an encoder, comprising a first determining unit; wherein,
[0018] The first determination unit is configured to, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, determine a first template corresponding to the current block, and determine a preset search area based on the first template; search within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determine a prediction value of the current block based on the block vector of the current block.
[0019] In a fifth aspect, an embodiment of the present application provides an encoder, comprising a first memory and a first processor; wherein,
[0020] The first memory is used to store a computer program that can be run on the first processor;
[0021] The first processor is configured to execute the method according to the second aspect when running the computer program.
[0022] In a sixth aspect, an embodiment of the present application provides a decoder, comprising a second determining unit; wherein,
[0023] The second determination unit is configured to, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, determine a first template corresponding to the current block, and determine a preset search area based on the first template; search within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determine a prediction value of the current block based on the block vector of the current block.
[0024] In a seventh aspect, an embodiment of the present application provides a decoder, comprising a second memory and a second processor; wherein,
[0025] The second memory is used to store a computer program that can be run on the second processor;
[0026] The second processor is configured to execute the method according to the first aspect when running the computer program.
[0027] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the method as described in the first aspect or the method as described in the second aspect is implemented.
[0028] The embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder and a storage medium. When the prediction mode of the current block is an intra-frame template matching-based prediction mode, the codec determines the first template corresponding to the current block, and determines a preset search area based on the first template; searches within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block; wherein the first parameter is used to control the search process; and determines the prediction value of the current block based on the block vector of the current block. It can be seen that in the embodiment of the present application, based on the IntraTMP mode, a predetermined first parameter, such as a matching cost threshold, can be used to control the search process, so that the search process can be terminated early or continued based on the first parameter. In other words, the coding and decoding method proposed in the embodiment of the present application can solve the problem of high computational complexity caused by traversing all search points in the search area by introducing the first parameter for controlling the search process, and can improve coding and decoding efficiency and performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a schematic diagram of the prediction of Intra TMP;
[0030] FIG2 is a schematic diagram of the prediction process based on the IntraTMP technology;
[0031] FIG3 is a schematic diagram of template types for the Intra TMP technology;
[0032] FIG4 is a schematic diagram of a search process based on the IntraTMP technology;
[0033] FIG5 is a schematic diagram of parameter definition of the current block and its template;
[0034] FIG6 is a schematic diagram of a template search area;
[0035] FIG7 is a schematic diagram showing the division of the search area into different sub-areas;
[0036] FIG8 is a schematic diagram of the search area determination process 1;
[0037] FIG9 is a schematic diagram of the search process;
[0038] FIG10A is a schematic block diagram of the encoder;
[0039] FIG10B is a schematic block diagram of the encoder;
[0040] FIG11 is a schematic diagram of the network architecture of the encoding and decoding system;
[0041] FIG12 is a schematic diagram of a flow chart of a decoding method proposed in an embodiment of the present application;
[0042] FIG13 is a schematic diagram of at least one search area;
[0043] FIG14 is a second schematic diagram of at least one search area;
[0044] FIG15 is a schematic diagram of a flow chart of an encoding method proposed in an embodiment of the present application;
[0045] FIG16 is a schematic diagram of the composition structure of the encoder;
[0046] Figure 17 is a schematic diagram of the encoder hardware structure;
[0047] FIG18 is a schematic diagram of the composition structure of a decoder;
[0048] FIG19 is a schematic diagram of the decoder hardware structure;
[0049] FIG20 is a schematic diagram showing the composition structure of the encoding and decoding system. DETAILED DESCRIPTION
[0050] 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.
[0051] 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.
[0052] 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.
[0053] 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:
[0054] Coding Block (CB);
[0055] Block Maching (BM);
[0056] Coding Unit (CU);
[0057] Block Vector (BV);
[0058] Sum of Absolute Difference (SAD);
[0059] Sum of Absolute Transformed Difference (SATD);
[0060] Mean Square Error (MSE);
[0061] Sum of Squared Differences (SSD);
[0062] Mean Absolute Deviation (MAD);
[0063] Mean Square Differences (MSD);
[0064] Normalized Correlation Coefficient (NCC);
[0065] H.266 / Versatile Video Coding (VVC);
[0066] VVC Test Model (VTM), a reference software testing platform for VVC;
[0067] Intra Template Matching Prediction (Intra TMP);
[0068] Beyond VVC's reference software testing platform (Enhanced Compression Model, ECM).
[0069] 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.
[0070] It can also be understood that Intra TMP is a special intra-frame prediction mode. Both the encoder and decoder use the template (T) of the coding block to search for the matching template (T_BEST) with the minimum cost within a predefined search range in the current image according to a preset cost function. The offset of the best matching template relative to the current coding block template is the best block vector (BEST Block Vector, BV_BEST). The reconstructed block (Ref Block) corresponding to the matching template is then used as the prediction block for the current coding block (Cur Block). The template of the coding block is usually selected from the adjacent reconstructed area of the current coding block.
[0071] For example, taking the adjacent reconstructed area of the current block as an example, FIG1 is a prediction diagram of Intra TMP. As shown in FIG1 , the area filled with dark color represents the reconstructed area, the block filled with grid is the current block, and the adjacent area of the current block is the first template (T); the block filled with slashes is the reference block, and the adjacent area of the reference block is the second template (i.e., the best matching template, T_BEST); wherein, the offset of the second template relative to the first template is the best block vector (BV_BEST). At this time, the reference block can be block-copied as the prediction block of the current block.
[0072] 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.
[0073] For example, taking absolute error and SAD as examples, the cost function at this time is as follows:
[0074] Among them, T i is the template in the search process, and M represents the number of pixels in the template.
[0075] The following is a detailed introduction to the prediction process of the Intra TMP technology in the related art.
[0076] Input of IntraTMP: the position of the current block (xTbCmp, yTbCmp), the width of the current block nTbW, and the height of the current block nTbH.
[0077] Output of IntraTMP: predicted value predSamples[x][y] of the current block, where x = 0..nTbW-1, y = 0..nTbH–1.
[0078] Specifically, the IntraTMP prediction process can be divided into four steps: determining the current template type, obtaining the reconstructed pixels of the current template, determining the block vector within a predefined search range, and generating the predicted value. This process yields the predicted value for the current block. It's important to note that the IntraTMP technique can be used to predict both luma and chroma components, and this is not specifically limited here.
[0079] See Figure 2, which shows a schematic diagram of a prediction process based on the IntraTMP technology. As shown in Figure 2, the process may include:
[0080] S201: Determine the current template type.
[0081] It should be noted that the Intra TMP 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 pixel, upper left reference pixel, upper right reference pixel, left reference pixel, lower left reference pixel, etc. of the current block. Therefore, the template type can be classified and the corresponding template type can be determined based on the availability of the adjacent reconstructed pixels.
[0082] It should also be noted that refTemplateType can be used to represent a template type. Figure 3 shows a schematic diagram of template types for the Intra TMP technology. As shown in Figure 3, the block filled with a grid is the current block, and the adjacent area of the current block is the template T. Six template types are shown here.
[0083] For example, the six template types are as follows:
[0084] 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 as shown in (a) of Figure 3;
[0085] When only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is shown in (b) in Figure 3;
[0086] When only the upper reference pixel is available, the value of refTemplateType is 3, and the template shape is shown in (c) in Figure 3;
[0087] 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 3;
[0088] 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) of Figure 3;
[0089] 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 3.
[0090] S202: Obtain current template pixels.
[0091] It should be noted that the Intra TMP template can be composed of reconstructed pixels from one or more of the following regions: the top, upper right, left, lower left, or upper left of the current block. Furthermore, the template size can be 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.
[0092] It should also be noted that the portion of the reconstructed pixels to be obtained can be determined by the value of refTemplateType. For example, when the value of refTemplateType is 1, the reconstructed pixels of the left, upper-left, and upper sides of the current block are obtained; or, when the value of refTemplateType is 2, only the reconstructed pixels of the four left columns of the current block are obtained; or, when the value of refTemplateType is 3, only the reconstructed pixels of the four upper rows of the current block are obtained.
[0093] S203: Determine a block vector within a predefined search range.
[0094] It should be noted that the search process of the Intra TMP technology is mainly divided into an initialization process, determining a search area of the template in the current frame, and searching and determining the best block vector in the search area.
[0095] It should also be noted that when searching for the best matching template in the search area, a search strategy of coarse search first and then fine search may be adopted, or only fine search or only coarse search may be performed, which is not specifically limited here.
[0096] In an embodiment of the present application, the coarse search here can specifically be: determining the best coarse matching template in the search area with a first preset step size (for example, 2), or using a downsampled template (for example, a downsampling factor of 2) to determine the best coarse matching template in the search area.
[0097] In the embodiment of the present application, the fine search here may specifically be: determining the best fine matching template in the search area with a second preset step size (eg, 1), or determining the best fine matching template near the best coarse matching template after completing the coarse search.
[0098] Refer to Figure 4, which shows a schematic diagram of a search process based on the IntraTMP technology provided by an embodiment of the present application. As shown in Figure 4, the process may include:
[0099] S401: Initialize parameters.
[0100] It should be noted that, taking the L-shaped template as an example, uiPatchWidth is initialized to nTbW + templateW_size, and uiPatchHeight is initialized to nTbH + templateH_size. Among them, templateW_size and templateH_size can be fixed constants, or they can be dynamically adjusted according to the size of the current block; in addition, templateW_size and templateH_size can be equal or unequal. For example, templateW_size = 4, templateH_size = 4; or, when the width of the current block is greater than 8, set templateW_size = 4; when the width of the current block is less than or equal to 8, set templateW_size = 2; when the height of the current block is greater than 8, set templateH_size = 4; when the height of the current block is less than or equal to 8, set templateH_size = 2.
[0101] For example, Figure 5 shows a schematic diagram of the parameter definition of the current block and its template. As shown in Figure 5, the specific meanings of the parameters are: nTbW and nTbH represent the size of the current block, templateW_size and templateH_size represent the template size, and uiPatchWidth and uiPatchHeight represent the size of the block containing the current block and its template.
[0102] Furthermore, the cost threshold between the initialization templates is represented by diffThreshold. For example, when the cost function is SAD, the threshold can be: diffThreshold = ((1 <<bitDepth)> >2)×(uiPatchHeight×uiPatchWidth-nTbH×nTbW). When the image bit depth bitDepth is 10, diffThreshold indicates that the distortion threshold of each pixel in the template area is 256.
[0103] Furthermore, the position of the coding tree block CTB where the current block CB is located is initialized: ctbRsX, ctbRsY.
[0104] Furthermore, the position offset of the current block CB in the current CTB is initialized: offsetLCBY=yTbCmp−ctbRsY, offsetLCBX=xTbCmp−ctbRsX.
[0105] Furthermore, initialize iTemplateSizeH=templateH_size and iTemplateSizeW=templateW_size.
[0106] Furthermore, iBvShift is initialized, where iBvShift is the precision of the block vector BV. For example, the precision of BV can be integer pixel precision, in which case iBvShift is 0; the precision of BV can also be sub-pixel precision, for example, iBvShift of 1 indicates 1 / 2 pixel precision, and iBvShift of 2 indicates 1 / 4 pixel precision. This is not specifically limited here.
[0107] Furthermore, the preset search range of the template is initialized. The preset search range of the template can be set to a fixed size or dynamically adjusted according to the encoding block size. For example, searchRangeWidth = TMP_SEARCH_RANGE_MULT_FACTOR × nTbW, searchRangeHeight = TMP_SEARCH_RANGE_MULT_FACTOR × nTbH; where the value of TMP_SEARCH_RANGE_MULT_FACTOR can be a preset value, such as 5.
[0108] S402: Determine a search area of the template in the current frame.
[0109] It should be noted that the Intra TMP technique's search area is the reconstructed portion of the current image and is limited by the search range. Figure 6 shows a schematic diagram of the template search area. As shown in Figure 6, the dark-filled background area represents the reconstructed area, the black-filled background block represents the current block, and the dashed box represents the search range window. Therefore, the IntraTMP technique's search area is no larger than the overlap between the reconstructed area represented by the dark background and the area indicated by the dashed box.
[0110] As can be seen, the search area for the current block template can be the reconstructed portion of the CTB where the current block resides, or it can be another reconstructed CTB area. The search area here is actually the set of all search points. Because the shape of this area is often not representable by a single rectangular region, in practice, multiple rectangular regions can be searched, and the search results from these different regions can be combined to obtain the final best matching block and best block vector.
[0111] For example, see Figure 7, which shows a schematic diagram of different sub-region divisions of a search area. As shown in Figure 7, eight different sub-region division methods are shown. The black-filled background block is the current block; the five division methods (a), (b), (c), (d), and (f) all divide the search area into four sub-search areas, and the three division methods (e), (g), and (h) all divide the search area into three sub-search areas. Here, different fill patterns represent a sub-search area.
[0112] In Figure 7, (a), (b), (c), and (d) consider all available search ranges, and (e), (f), (g), and (h) do not search the area directly above and to the left.
[0113] For example, assuming that different sub-search regions are represented by regionId, and considering that the template pixels of the current block need to be retrieved in the image reconstruction region and the pixels of the reconstructed block corresponding to the template also need to be retrieved in the reconstruction region, it is necessary to further determine the positions that can be searched within the sub-search regions represented by different regionIds based on the current block position (xTbCmp, yTbCmp), the current block size (nTbW, nTbH), the current image size (picWidth, picHeight), the size of the CTB in which the current block is located (CtbSizeW, CtbSizeH), the preset search range of the template (searchRangeWidth, searchRangeHeight), and the position offset of the current block within the current CTB (offsetLCBY, offsetLCBX), thereby determining the block vector BV. Specifically, iVerMin and iVerMax represent the absolute coordinate positions that can be searched at least and at most in the vertical direction, respectively, and iHorMin and iHorMax represent the absolute coordinate positions that can be searched at least and at most in the horizontal direction, respectively. The values of iVerMin, iVerMax, iHorMin, and iHorMax are different in the search areas represented by different regionIds.
[0114] Taking (f) in Figure 7 as an example, the search area is divided into four sub-search areas, which are implemented as follows:
[0115] When regionId is equal to 0, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMax0=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin0=max((iTemplateSizeW)<<iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMax0=(yTbCmp-nTbH-offsetLCBY)<<iBvShift; iVerMin0=max(((iTemplateSizeH)<<iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。
[0116] When regionId is equal to 1, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMin1 = max((iTemplateSizeW) < <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax1=(xTbCmp-offsetLCBX-nTbW)<<iBvShift; iVerMin1=(yTbCmp+1)<<iBvShift; iVerMax1=min((picHeight-nTbH)<<iBvShift,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)<< iBvShift)。
[0117] When regionId is equal to 2, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMax2 = (xTbCmp - offsetLCBX - nTbW) < <iBvShift; iHorMin2=max((iTemplateSizeW)<<iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMin2=max((iTemplateSizeH)<<iBvShift,(yTbCmp-nTbH-offsetLCBY)<<iBvShift); iVerMax2=(yTbCmp)<<iBvShift。
[0118] When regionId is equal to 3, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMin3 = max((iTemplateSizeW) < <iBvShift,(xTbCmp-offsetLCBX-nTbW+1)<<iBvShift); iHorMax3=(xTbCmp-nTbW)<<iBvShift; iVerMin3=max(((iTemplateSizeH)<<iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift); iVerMax3=(yTbCmp-nTbH)<<iBvShift。
[0119] In practical applications, the iHorMin regionId 、iHorMax regionId 、iVerMinregionId 、iVerMax regionId Represent the left edge, right edge, top edge and bottom edge of different sub-search areas respectively.
[0120] To intuitively illustrate the different sub-search regions corresponding to different regionIds, see Figure 8, which shows a schematic diagram of the specific search region determination process. As shown in Figure 8, R1, R2, R3, and R4 represent four different sub-search regions. Note that Figure 8 represents the pixel range aligned with the top-left corner pixel of the block.
[0121] S403: Search and determine the best block vector BV in the search area.
[0122] It should be noted that bvXMins and bvXMaxs represent the minimum offset and maximum offset of the block vector in the horizontal direction respectively; bvYMins and bvYMaxs represent the minimum offset and maximum offset of the block vector in the vertical direction respectively.
[0123] bvXMins regionId 、bvXMaxs regionId 、bvYMins regionId 、bvYMaxs regionId iVerMin determined in step S402 regionId 、iVerMax regionId 、iHorMin regionId 、iHorMax regionId Calculated: bvXMins regionId =iHorMin regionId –xTbCmp; bvXMaxs regionId =iHorMax regionId –xTbCmp; bvYMins regionId =iVerMin regionId –yTbCmp; bvYMaxs regionId =iVerMax regionId –yTbCmp;
[0124] Among them, bvXMins regionId 、bvXMaxs regionId 、bvYMins regionId and bvYMaxs regionId The horizontal and vertical offset ranges of the search point relative to the current block, ie, the range of the block vector BV, are determined.
[0125] It should also be noted that, through the search points (iPosHor, iPoxVer) in each search area, that is, each block vector BV (composed of horizontal and vertical components: (pX, pY), where pX = iPosHor-xTbCmp, pY = iPosVer-yTbCmp, then pX is between bvXMins and bvXMaxs, and pY is between bvYMins and bvYMaxs; in this way, a matching reconstructed block of the current block can be found in the reconstructed area, and the adjacent reconstructed pixels of the matching reconstructed block are the matching template (that is, the second template mentioned above). Therefore, the matching cost value of the adjacent template of the current block and the adjacent template of the matching reconstructed block can be calculated, which is recorded as pDiff.
[0126] Furthermore, all search points in all search ranges (regionId=0, 1, 2, 3) are traversed, and the search point with the smallest matching cost pDiff is obtained by comparison. Its corresponding matching cost is recorded as pDiff_BEST, its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST), and its corresponding matching template is the best matching template T_BEST.
[0127] In one possible implementation, if the search strategy is to perform only a coarse search, the specific implementation is as follows:
[0128] In each region at pX within bvXMins regionId with bvXMaxs regionId Between, pY is in bvYMins regionId with bvYMaxs regionId Within the search range between , a coarse search is performed with a step size greater than 1, for example, a coarse search is performed with a step size of 2. The best matching cost value obtained by recording template matching is pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST).
[0129] In another possible implementation, if the search strategy is to perform only detailed search, the specific implementation is as follows:
[0130] In each region at pX within bvXMins regionId with bvXMaxs regionId Between, pY is in bvYMins regionId with bvYMaxs regionId Within the search range between, for example, a fine search is performed with a step size of 1 to record the optimal matching cost value obtained by template matching, pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST).
[0131] In another possible implementation, if the search strategy is: perform a coarse search first and then a fine search; FIG9 is a schematic diagram of the search process, as shown in FIG9. The specific process is as follows:
[0132] S901: Determine the best coarse matching template in the search area with a step size of 2.
[0133] S902: Determine the best fine matching template near the best coarse matching template with a step size of 1.
[0134] It should be noted that, for step S901, in the coarse search phase:
[0135] In each region at pX within bvXMins regionId with bvXMaxs regionId Between, pY is in bvYMins regionId with bvYMaxs regionId Within the search range between , a coarse search is performed with a step size greater than 1. For example, the best matching cost obtained by performing a coarse search with a step size of 2 is recorded as pDiff1_BEST, and its corresponding block vector BV is recorded as the best block vector BV1_BEST (pX1_BEST, pY1_BEST), and the search region where the best matching search point is located is bestRegionId.
[0136] It should also be noted that, for step S902, in the detailed search phase:
[0137] A further search is performed near the best block vector BV1_BEST obtained from the coarse search. Specifically, a refined search range TmpRefineRange is first determined. The refined search range can be a fixed size or related to the current block size, for example, min(nTbW, nTbH) / 2. The position of the best matching reconstructed block obtained from the coarse search is then calculated as the reference position of the fine search area: BestPosX = xTbCmp + pX1_BEST, BestPosY = yTbCmp + pY1_BEST.
[0138] According to the value of bestRegionId, first obtain the calculated values of iVerMinbestRegionId, iVerMaxbestRegionId, iHorMinbestRegionId, and iHorMaxbestRegionId, and then obtain the new search range iVerMin according to the optimal matching block position obtained by the rough search. refine 、iVerMax refine 、iHorMin refine 、iHorMax refine, the acquisition method is as follows: iHorMin refine =max(iHorMinbestRegionId, BestPosX-TmpRefineRange); iHorMax refine =min(iHorMaxbestRegionId, BestPosX+TmpRefineRange); iVerMin refine =max(iVerMinbestRegionId, BestPosY-TmpRefineRange); iVerMax refine =min(iVerMaxbestRegionId, BestPosY+TmpRefineRange);
[0139] Then, the adjusted block vectors BVbvXMins, bvXMaxs, bvYMins, bvYMaxs can be obtained by iVerMin refine 、iVerMax refine 、iHorMin refine 、iHorMax refine Calculation: bvXMins = iHorMin refine –xTbCmp; bvXMaxs=iHorMax refine –xTbCmp; bvYMins=iVerMin refine –yTbCmp; bvYMaxs=iVerMax refine –yTbCmp;
[0140] Thus, the fine search is performed at pX within bvXMins refine with bvXMaxs refine Between, pY is in bvYMins refine with bvYMaxs refine For example, the search is performed with a step size of 1, and the best matching cost obtained by template matching is recorded as pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST).
[0141] After completing the above operations, the best block vector BV_BEST (pX_BEST, pY_BEST) can be obtained, where pX_BEST and pY_BEST are the horizontal offset and vertical offset of the best matching template relative to the current block template, respectively, and are also the horizontal offset and vertical offset of the best matching reconstructed block relative to the current block.
[0142] S204: Generate a predicted value.
[0143] Here, we can use simple translation copy to achieve it. The specific operation is:
[0144] For x=0...nTbW-1, y=0...nTbH-1; predSamples[x][y]=recSamples[x+pX_BEST][y+pY_BEST] (2)
[0145] Among them, recSamples represents the reconstructed pixels of the current frame.
[0146] It can be understood that in the IntraTMP mode, in addition to the above basic copying method to obtain the predicted value, it is also possible to use a method of filtering and fusing the corresponding positions of multiple BVs to obtain the predicted value, as well as a method of fusing the prediction with the ordinary Intra mode.
[0147] For example, during the region search process at the decoding end, after obtaining the BV candidate list by template matching, the first N items (eg, N=3) can be selected for weighted fusion. This method can be called IntraTMP Fusion mode.
[0148] For example, after obtaining an optimal BV, multiple points around the BV are selected and the predicted values corresponding to the multiple points are weighted and fused to obtain the predicted value. This method can be called the IntraTMP FLM mode.
[0149] For example, after obtaining an optimal BV, a weighted combination of the predicted value obtained using the BV and the predicted value obtained using the normal intra mode is performed to obtain the final predicted value. The normal intra mode can be a planar mode or a directional mode, for example. The directional mode can be inferred from the TIMD or located in the intra candidate table using an index transmitted in the bitstream. This method can be referred to as the IntraTMP CIIP mode.
[0150] In simple terms, the Intra TMP technique, as used in related technologies, uses the template of the current block to search for the matching template with the lowest cost within a predefined search range in the current image according to a preset cost function. The best matching reconstructed block (Ref Block) corresponding to the matching template is used as the prediction block for the current block (Cur Block). The template of the current block can usually be selected from the reconstructed area adjacent to the current block.
[0151] However, the search strategy in the actual implementation process needs to traverse all search points in the search area, which has high computational complexity.
[0152] In summary, common search strategies often have the problem of high computational complexity, thereby reducing encoding and decoding efficiency and performance.
[0153] In order to solve the above problems, the embodiments of the present application provide a coding and decoding method, a code stream, an encoder, a decoder and a storage medium. When the prediction mode of the current block is an intra-frame template matching-based prediction mode, the codec determines the first template corresponding to the current block, and determines a preset search area based on the first template; searches within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block; wherein the first parameter is used to control the search process; and determines the prediction value of the current block based on the block vector of the current block. It can be seen that in the embodiments of the present application, based on the IntraTMP mode, a predetermined first parameter, such as a matching cost threshold, can be used to control the search process, so that the search process can be terminated early or continued based on the first parameter. In other words, the coding and decoding method proposed in the embodiments of the present application can solve the problem of high computational complexity caused by traversing all search points in the search area by introducing the first parameter for controlling the search process, and can improve coding and decoding efficiency and performance.
[0154] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0155] Referring to Figure 10A, which shows a schematic block diagram of the composition of an encoder provided in an embodiment of the present application. As shown in Figure 10A, 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 can implement deblocking filtering and sample adaptive offset (SAO) filtering, and the encoding unit 109 can 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 .
[0156] Referring to FIG10B , which shows a block diagram of a decoder provided in an embodiment of the present application, as shown in FIG10B , 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 encoded as shown in FIG10A, a code stream of the video signal is output; the code stream is input to the decoder 30 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 the prediction information for the video decoding block by analyzing the motion vector and other associated syntax elements, and uses 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.
[0157] 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 11 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 11, 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.
[0158] 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 10A and the intra-frame prediction unit 203 shown in Figure 10B. 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.
[0159] 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.
[0160] An embodiment of the present application provides a decoding method, which is applied to a decoder. FIG12 is a flowchart of the decoding method provided in the embodiment of the present application. As shown in FIG12 , the decoding method performed by the decoder may include the following steps:
[0161] Step 101: When the prediction mode of the current block is an intra-frame prediction mode based on template matching, a first template corresponding to the current block is determined, and a preset search area is determined according to the first template.
[0162] In an embodiment of the present application, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, a first template corresponding to the current block may be determined first. When acquiring the first template, the template type corresponding to the current block may be determined first, and then the first template corresponding to the current block may be further determined based on the template type.
[0163] It can be understood that, in the embodiment of the present application, the intra-frame template matching-based prediction mode may be a prediction mode using template matching, for example, the intra-frame template matching-based prediction mode may be an IntraTMP mode.
[0164] Furthermore, in an embodiment of the present application, after determining the first template corresponding to the current block, a preset search area corresponding to the current block may be further determined based on the first template.
[0165] It should be noted that the decoding method in the embodiment of the present application is applied to a decoder. Furthermore, the decoding method may include an intra-frame prediction method, more specifically, a color component prediction method. A video image may be divided into multiple decoding blocks, each of which may include a first color component, a second color component, and a third color component. The current block in the embodiment of the present application refers to a decoding block in the video image that is currently to be intra-frame predicted.
[0166] Here, when the first color component needs to be predicted, the component to be predicted is the first color component; when the second color component needs to be predicted, the component to be predicted is the second color component; when the third color component needs to be predicted, the component to be predicted is the third color component. In addition, assuming that the current block predicts the first color component and the first color component is the luminance component, that is, the component to be predicted is the luminance component, then the current block can also be called a luminance block; or assuming that the current block predicts the second color component and the second color component is the chrominance component, that is, the component to be predicted is the chrominance component, then the current block can also be called a chrominance block.
[0167] It should also be noted that, in the embodiments of the present application, the reference pixels (Reference Sample) of the current block may refer to reference pixels adjacent to the current block; wherein, adjacent here may be spatially adjacent, but is not limited to this. For example, adjacent may also mean temporally adjacent, spatially and temporally adjacent, or even the reference pixels of the current block may be obtained by performing some processing on spatially adjacent, temporally adjacent, or spatially and temporally adjacent reference pixels, etc., and the embodiments of the present application do not impose any limitations thereon.
[0168] Furthermore, in an embodiment of the present application, the template type of the current block may be determined based on indication information in the code stream; or the template type of the current block may be determined based on the size of the current block.
[0169] Furthermore, in an embodiment of the present application, the template type of the current block can be determined 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, the upper left adjacent reference pixels of the current block, the lower left adjacent reference pixels of the current block, and the upper right adjacent reference pixels of the current block.
[0170] It is understandable that in the embodiment of the present application, the reference pixels of the current block may include the adjacent reconstructed pixels of the current block, that is, the adjacent reconstructed pixels of the current block may be selected as a template to search for a matching template in a predefined search area.
[0171] It should be noted that, in an embodiment of the present application, the reference pixels of the current block, that is, the adjacent reconstructed pixels of the current block may include the upper reference pixel, the upper left reference pixel, the upper right reference pixel, the left reference pixel and the lower left reference pixel of the current block.
[0172] It can be understood that in the embodiment of the present application, when the template type of the current block is determined using the reference pixels of the current block, the template type can be classified and determined according to whether the adjacent reference pixels are available.
[0173] It is understandable that, in the embodiment of the present application, when determining the template type of the current block, the template type may be classified and determined according to an indication in the code stream.
[0174] Further, in an embodiment of the present application, when determining the template type of the current block based on the reference pixels of the current block, 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 a first value; if the left adjacent reference pixels of the current block are available, the template type of the current block is determined to be a second value; if the upper adjacent reference pixels of the current block are available, the template type of the current block is determined to be a third value; if the left adjacent reference pixels of the current block and the upper-left adjacent reference pixels of the current block are both available, the template type of the current block is determined to be a fourth value; if the left adjacent reference pixels of the current block and the lower-left adjacent reference pixels of the current block are both available, the template type of the current block is determined to be a fifth value; if the upper adjacent reference pixels of the current block and the upper-right adjacent reference pixels of the current block are both available, the template type of the current block is determined to be a sixth value.
[0175] It should be noted that in the embodiments of the present application, the first value, the second value, the third value, the fourth value, the fifth value, and the sixth value can be any values and are not specifically limited in this application. For example, the first value, the second value, the third value, the fourth value, the fifth value, and the sixth value can be 1, 2, 3, 4, 5, and 6, respectively.
[0176] For example, in an embodiment of the present application, refTemplateType can be used to represent the template type. Accordingly, as shown in FIG3 above, the block filled with the grid is the current block, and the adjacent area of the current block is the template T. Six template types are shown here.
[0177] Exemplarily, these six template types are as follows: 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) in Figure 3; when only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is shown in (b) in Figure 3; when only the upper reference pixel is available, the value of refTemplateType is 3, and the template shape is shown in (c) in Figure 3; 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 3; 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 3; 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 3.
[0178] In some embodiments, the IntraTMP template type can be selected based on the aforementioned reference pixel availability information and instructions in the bitstream. For example, a sequence number for each template type can be agreed upon, and the actual template sequence number information used can be transmitted in the bitstream, so that the template type can be determined at the decoding end.
[0179] That is, in the embodiments of the present application, the template type can be determined based on the availability information of the reference pixels of the current block, or based on information indicated in the bitstream, or based on a combination of the availability information of the reference pixels and information indicated in the bitstream. This application does not make any specific limitations.
[0180] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block based on the template type, the template reference pixels of the current block can be determined first based on the template type and the template size corresponding to the template type, and then the first template of the current block can be determined based on the template reference pixels.
[0181] It should be noted that, in an embodiment of the present application, the first template of the current block may include template reference pixels of the current block, wherein the template reference pixels of the current block may be determined by the template type of the current block and the template size corresponding to the template type.
[0182] It should be noted that, in an embodiment of the present application, the first template of the current block can be composed of reconstructed pixels of one or more areas above, upper right, left, lower left, and upper left of the current block, that is, it can be composed of reference pixels of the current block.
[0183] It should be noted that in the embodiments of the present application, the template size corresponding to the template type can be pre-set, can be indicated by a codestream syntax element, or can be adaptively selected based on the block size or other information. For example, when obtaining the left template, the template width templateW_size can be set to 4, and when obtaining the upper template, the template height templateH_size can be set to 4.
[0184] Accordingly, in the embodiment of the present application, by combining the value of the template type refTemplateType of the current block and the template size corresponding to the refTemplateType, it is possible to determine which part of the reconstructed pixels to obtain as the template reference pixels of the current block, and then determine the corresponding first template.
[0185] Exemplarily, in an embodiment of the present application, when the value of refTemplateType is 1, you can choose to obtain the left, upper left and upper reconstructed pixels of the current block; when the value of refTemplateType is 2, only the left 4 columns of reconstructed pixels of the current 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.
[0186] Of course, the value of the preset template size can be any integer greater than 0, and is not limited to 4, and this application does not make any specific limitation on this.
[0187] It can be understood that in the embodiment of the present application, in combination with the template type and the corresponding template size of the current block, the template reference pixel of the current block determined from the reference pixels of the current block can be the first template corresponding to the current block.
[0188] It should be noted that, in an embodiment of the present application, the block vector search process may include an initialization process, determining a search area (preset search area) of the first template in the current frame, searching and determining one or a pair of optimal block vectors in the search area. Therefore, when performing the search process, the initialization operation needs to be completed first.
[0189] Exemplarily, as shown in FIG5 , nTbW and nTbH represent the size of the current block, templateW_size and templateH_size represent the size of the template, and uiPatchWidth and uiPatchHeight represent the size of the block including the current block and its template.
[0190] Accordingly, during initialization, uiPatchWidth can be initialized to nTbW + templateW_size, and uiPatchHeight can be initialized to nTbH + templateH_size, where templateW_size and templateH_size can be fixed constants, or indicated by codestream syntax elements, or dynamically adjusted according to the coding block size or other information. TemplateW_size and templateH_size can be equal or unequal. For example, templateW_size = 4, templateH_size = 4; or when the width of the coding block is greater than 8, set templateW_size = 4, when the width of the coding block is less than or equal to 8, set templateW_size = 2, when the height of the coding block is greater than 8, set templateH_size = 4, when the height of the coding block is less than or equal to 8, set templateH_size = 2.
[0191] Furthermore, the cost threshold between the initialization templates is represented by diffThreshold. For example, when the cost function is SAD, the threshold can be: diffThreshold = ((1 <<bitDepth)> >2)×(uiPatchHeight×uiPatchWidth-nTbH×nTbW). When the image bit depth bitDepth is 10, diffThreshold indicates that the distortion threshold of each pixel in the template area is 256.
[0192] Furthermore, the position of the coding tree block CTB where the current block CB is located is initialized: ctbRsX, ctbRsY.
[0193] Furthermore, the position offset of the current block CB in the current CTB is initialized: offsetLCBY=yTbCmp−ctbRsY, offsetLCBX=xTbCmp−ctbRsX.
[0194] Furthermore, initialize iTemplateSizeH=templateH_size and iTemplateSizeW=templateW_size.
[0195] Furthermore, iBvShift is initialized, where iBvShift is the precision of the block vector BV. For example, the precision of BV can be integer pixel precision, in which case iBvShift is 0; the precision of BV can also be sub-pixel precision, for example, iBvShift of 1 indicates 1 / 2 pixel precision, and iBvShift of 2 indicates 1 / 4 pixel precision. This is not specifically limited here.
[0196] Furthermore, the preset search range of the template is initialized. The preset search range of the template can be set to a fixed size or dynamically adjusted according to the coding block size. For example, searchRangeWidth = TMP_SEARCH_RANGE_MULT_FACTOR × nTbW, searchRangeHeight = TMP_SEARCH_RANGE_MULT_FACTOR × nTbH; where the value of TMP_SEARCH_RANGE_MULT_FACTOR can be a preset value, can be indicated by a bitstream syntax element, or can be adaptively adjusted according to information such as the coding block size, for example, set to 5.
[0197] It should be noted that in the embodiments of the present application, the preset search area can be the reconstructed portion of the current image and is limited by the size of the search range. As shown in Figure 6 above, the dark-filled background area is the reconstructed area, the black-filled background block is the current block, and the dashed box is the search range window. Therefore, the preset search area of the IntraTMP technology is no larger than the overlap between the reconstructed area represented by the dark background and the area indicated by the dashed box.
[0198] As can be seen, the preset search area for the current block template can be the reconstructed portion of the CTB where the current block is located, or it can be another reconstructed CTB area. The preset search area here is actually the set of all search points. Because the shape of this area is often not representable by a single rectangular area, in a specific implementation, it is also possible to search in multiple rectangular areas and then combine the search results from different areas to obtain the final best matching block and best block vector.
[0199] For example, see Figure 7 above, which shows eight different sub-region division methods. The black-filled background block is the current block; (a), (b), (c), (d), and (f) all divide the preset search area into four sub-search areas; (e), (g), and (h) all divide the preset search area into three sub-search areas. Here, different fill patterns represent a sub-search area.
[0200] In Figure 7, (a), (b), (c), and (d) consider all available search ranges, and (e), (f), (g), and (h) do not search the area directly above and to the left.
[0201] For example, assuming that different sub-search regions are represented by regionId, and considering that the template pixels of the current block need to be retrieved in the image reconstruction region and the pixels of the reconstructed block corresponding to the template also need to be retrieved in the reconstruction region, it is necessary to further determine the positions that can be searched within the sub-search regions represented by different regionIds based on the current block position (xTbCmp, yTbCmp), the current block size (nTbW, nTbH), the current image size (picWidth, picHeight), the size of the CTB in which the current block is located (CtbSizeW, CtbSizeH), the preset search range of the template (searchRangeWidth, searchRangeHeight), and the position offset of the current block within the current CTB (offsetLCBY, offsetLCBX), thereby determining the block vector BV. Specifically, iVerMin and iVerMax represent the absolute coordinate positions that can be searched at least and at most in the vertical direction, respectively, and iHorMin and iHorMax represent the absolute coordinate positions that can be searched at least and at most in the horizontal direction, respectively. The values of iVerMin, iVerMax, iHorMin, and iHorMax are different in the search areas represented by different regionIds.
[0202] In some embodiments, taking (f) in FIG. 7 as an example, the preset search area is divided into four sub-search areas, which are implemented as follows:
[0203] When regionId is equal to 0, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMax0=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin0=max((iTemplateSizeW)<<iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMax0=(yTbCmp-nTbH-offsetLCBY)<<iBvShift; iVerMin0=max(((iTemplateSizeH)<<iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。
[0204] When regionId is equal to 1, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMin1 = max((iTemplateSizeW) < <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax1=(xTbCmp-offsetLCBX-nTbW)<<iBvShift; iVerMin1=(yTbCmp+1)<<iBvShift; iVerMax1=min((picHeight-nTbH)<<iBvShift,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)<< iBvShift)。
[0205] When regionId is equal to 2, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMax2 = (xTbCmp - offsetLCBX - nTbW) < <iBvShift; iHorMin2=max((iTemplateSizeW)<<iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMin2=max((iTemplateSizeH)<<iBvShift,(yTbCmp-nTbH-offsetLCBY)<<iBvShift); iVerMax2=(yTbCmp)<<iBvShift。
[0206] When regionId is equal to 3, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMin3 = max((iTemplateSizeW) < <iBvShift,(xTbCmp-offsetLCBX-nTbW+1)<<iBvShift); iHorMax3=(xTbCmp-nTbW)<<iBvShift; iVerMin3=max(((iTemplateSizeH)<<iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift); iVerMax3=(yTbCmp-nTbH)<<iBvShift。
[0207] It is understandable that in practical applications, the iHorMin regionId 、iHorMax regionId 、iVerMinregionId 、iVerMax regionId Represent the left edge, right edge, top edge and bottom edge of different sub-search areas respectively.
[0208] To intuitively illustrate the different sub-search regions corresponding to different regionIds, see Figure 8, which shows a schematic diagram of the process for determining a preset search region. As shown in Figure 8, R1, R2, R3, and R4 represent four different sub-search regions. Note that Figure 8 represents the pixel range aligned with the top-left corner pixel of the block.
[0209] It is understood that in some embodiments, the preset search area can also be divided into two types: one is a region where all sampling points have been reconstructed (referred to as a full reconstruction search area), and the other is a region where it is uncertain whether all sampling points have been reconstructed (referred to as a pending reconstruction search area). This application does not impose specific limitations.
[0210] Step 102: Search in a preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process.
[0211] In an embodiment of the present application, after determining a preset search area based on the first template, a search may be further performed in the preset search area based on a first parameter corresponding to the current block, thereby determining a block vector of the current block. The first parameter is used to control the search process.
[0212] It should be noted that, in the embodiment of the present application, the first parameter can be used to control the search process. For example, based on the first parameter, you can choose to continue the search process or end the search process early.
[0213] For example, in an embodiment of the present application, the first parameter may be a matching cost threshold corresponding to the matching cost value. Accordingly, when the search process is controlled based on the first parameter, if the matching cost value and the first parameter (matching cost threshold) satisfy the search stop condition, the search process may be terminated prematurely; otherwise, the search process may continue.
[0214] It is understood that in the embodiments of the present application, if the first parameter is a matching cost threshold corresponding to the matching cost value, then the first parameter can be understood as a cost upper threshold. Therefore, the corresponding stopping condition can be the relative magnitude between the matching cost value and the first parameter.
[0215] For example, in an embodiment of the present application, if the matching cost value is less than or equal to the first parameter, then it can be considered that the stop search condition is met, and the search process can be ended early; if the matching cost value is greater than the first parameter, then it can be considered that the stop search condition is not met, and the search process can continue.
[0216] It can be seen that in the embodiment of the present application, when searching based on the first parameter, if the search obtains a search point with a matching cost value less than or equal to the first parameter, the search can be ended, thereby achieving control over the search process.
[0217] That is, in the embodiment of the present application, since calculating the matching cost for all search points in the preset search area will greatly increase the complexity, in order to ensure the coding efficiency while taking into account the complexity, it is possible to choose to use the template matching cost threshold corresponding to the current block, that is, the first parameter SAD thre To control the search process and terminate the search early.
[0218] Furthermore, in an embodiment of the present application, the first parameter is used to limit the matching cost between different templates according to a preset matching criterion.
[0219] It should be noted that, in the embodiment of the present application, the preset matching criteria include any one of the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC.
[0220] Exemplarily, in some embodiments, when the preset matching criterion is SSE, MSE, or SATD, the first parameter for early exiting the search is also correspondingly set to SSEthre, MSEthre, or SATDthre.
[0221] That is to say, in this application, the first parameter corresponds to the preset matching criterion.
[0222] Furthermore, in an embodiment of the present application, the preset matching criteria may also include a first matching criterion and a second matching criterion. The first matching criterion includes any one of the sum of absolute difference (SAD), the sum of transformed absolute difference (SATD), the sum of squared differences (SSE), the mean absolute difference (MAD), the mean absolute error (MAE), the mean squared error (MSE), and the normalized correlation coefficient (NCC). The second matching criterion includes any one of the vector length of the block vector, the sum of the component lengths of the block vector, and a block vector cost parameter.
[0223] It can be understood that, in the embodiment of the present application, the first matching criterion can be understood as including a cost function related to pixel differences, and the second matching criterion can be understood as including a cost function related to the size of the block vector (BV).
[0224] It should be noted that in the embodiments of the present application, in combination with the use of the first matching criterion and the second matching criterion, in the process of determining the block vector of the current block, it is necessary to refer to both the cost function related to the pixel difference and the cost function related to the size of the block vector (BV). In other words, a cost function related to both the pixel difference and the BV size can be used.
[0225] It can be understood that, in the embodiment of the present application, the block vector cost parameter included in the second matching criterion can be understood as a cost parameter related to the block vector.
[0226] Exemplarily, in some embodiments, the block vector cost parameter may include but is not limited to any of the following forms: the vector length of the block vector BV multiplied by a coefficient λ, or the sum of the component lengths of the block vector BV multiplied by a coefficient λ.
[0227] It should be noted that, in the embodiment of the present application, corresponding to the preset matching criteria including the first matching criteria and the second matching criteria, in the process of searching the block vector of the current block, the matching cost value determined for any search point can also correspondingly include two parts: a cost value corresponding to the first matching criteria and related to the pixel difference, and a cost value corresponding to the second matching criteria and related to the BV size.
[0228] For example, in some embodiments, it is assumed that the cost value associated with the pixel difference corresponding to the first matching criterion is expressed as cost Dpel The cost value corresponding to the second matching criterion and related to the BV size is expressed as cost BV , then the matching cost value cost determined for a search point in the preset search area can be expressed as cost = cost BV +cost Dpel .
[0229] Among them, cost BV A quantity related to the size of BV, such as the vector length of BV, or the sum of the lengths of the components of BV, or the vector length of BV multiplied by a coefficient λ, or the sum of the lengths of the components of BV multiplied by a coefficient λ, or a table defining the relationship between BV size and cost BV The relationship between, or define different areas, different areas have different costs BV For example, define a diamond or square multi-layer area centered on a certain value BV (such as zero value BV), and each area takes a fixed costBV value.
[0230] For example, in some embodiments, it is assumed that the cost value associated with the pixel difference corresponding to the first matching criterion is expressed as cost Dpel The cost value corresponding to the second matching criterion and related to the BV size is expressed as cost BV , then the matching cost value cost determined for a search point in the preset search area can be expressed as cost = cost Dpel ×costFactor BV .
[0231] Among them, costFactor BV A quantity related to the size of the BV, such as the vector length of the BV multiplied by a coefficient λ, or the sum of the component lengths of the BV multiplied by a coefficient λ, or a table defining the BV size and costFactor BV The relationship, or define different areas, different areas have different costFactor BV For example, define a diamond or square multi-layer area centered on a certain value BV (such as zero value BV), and each area takes a fixed costFactor BV value.
[0232] Furthermore, in the embodiment of the present application, taking the preset matching criterion as SAD as an example, the first parameter SAD corresponding to the current block can be determined first. thre .
[0233] It should be noted that, in the embodiment of the present application, the first parameter may be determined according to the bit depth information corresponding to the current image and the pixel parameter corresponding to the first template.
[0234] It is understandable that, in the embodiment of the present application, when a first parameter SAD is used thre To jump out of the search process in advance, the first parameter SAD can be determined according to the bit depth information of the current image. thre , wherein the first parameter determined based on the bit depth information of the current image can be a predefined fixed threshold.
[0235] For example, in some embodiments, the first parameter SAD may be defined as thre =((1<<bitDepth)> >3)×Num Temp , where bitDepth is the image bit depth, that is, the bit depth information corresponding to the current image, Num Temp is the number of pixels of the reference template, that is, the pixel parameter of the first template corresponding to the current block.
[0236] It should be noted that, in the embodiment of the present application, if the prediction mode of the adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, then the first parameter can be determined according to the adjacent reconstructed block.
[0237] It can be understood that in an embodiment of the present application, if the prediction mode of the adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, then when determining the first parameter based on the adjacent reconstructed block, the first threshold can be first determined based on the matching cost value corresponding to the block vector of the adjacent reconstructed block and the pixel parameters of the reference template corresponding to the adjacent reconstructed block; at the same time, the second threshold can be determined based on the pixel parameters corresponding to the first template and the maximum average pixel value difference between the current block and the adjacent reconstructed block; finally, the first parameter can be determined based on the first threshold and the second threshold.
[0238] It should be noted that, in an embodiment of the present application, when determining the first parameter based on the first threshold and the second threshold, if the first threshold is less than or equal to the second threshold, the first threshold is determined as the first parameter; if the first threshold is greater than the second threshold, the second threshold is determined as the first parameter.
[0239] It is understandable that, in the embodiment of the present application, when a first parameter SAD is used thre To jump out of the search process in advance, the first parameter SAD can also be determined based on the best template matching cost of the adjacent IntraTMP coding block of the current block thre , wherein the first parameter determined based on the matching cost value corresponding to the adjacent reconstructed block of the current block whose prediction mode is the intra-frame template matching-based prediction mode can be an adaptive threshold.
[0240] For example, in some embodiments, it is assumed that the upper adjacent block of the current block selects IntraTMP as its coding mode, that is, the prediction mode of the adjacent reconstructed block on the upper side of the current block is the intra-frame template matching-based prediction mode, and the block vector (optimal block vector) of the adjacent reconstructed block is BV neighbor , the corresponding matching cost (optimal matching cost) is Diff neighbor , the pixel parameter of the reference template corresponding to the adjacent reconstructed block (the number of pixels of the adjacent block reference template) is Num TempNei , the pixel parameter of the first template corresponding to the current block (the number of pixels of the reference template) is Num Temp , then, according to the matching cost value Diff corresponding to the block vector of the adjacent reconstructed block neighbor Pixel parameter Num of the reference template corresponding to the adjacent reconstructed block TempNei The first threshold determined can be expressed as Diff neighbor / Num TempNei ×Num Temp .
[0241] For example, in some embodiments, the maximum average pixel SAD difference between the current block and the adjacent reconstructed block on one pixel can be recorded as offsetDiff regionId , a can be used to represent the maximum average pixel value difference on a pixel. Wherein, a can be a predefined fixed factor that can be transmitted through high-level syntax. Accordingly, according to the pixel parameter Num corresponding to the first template Temp , and the second threshold determined by the maximum average pixel value difference a between the current block and the adjacent reconstructed block can be expressed as a×Num Temp .
[0242] For example, in some embodiments, when determining the first parameter based on the first threshold and the second threshold, a smaller threshold value of the first threshold and the second threshold value can be selected as the first parameter, that is, the first parameter SAD is defined as thre =min(Diff neighbor / Num TempNei ×Num Temp , a×Num Temp ).
[0243] That is, in the embodiment of the present application, it is assumed that the upper adjacent block of the current unit to be coded selects IntraTMP as its coding mode, and the optimal block vector of the adjacent block is BV neighbor , the corresponding optimal matching cost Diff neighbor , Num TempNei is the number of pixels of the reference template of the adjacent block, based on a maximum offset, SAD thre The value should not be greater than a×Num Temp , where a is the maximum average pixel value difference on a pixel. At this time, the template matching threshold of the current unit to be encoded is set to SAD thre =min(Diff neighbor / Num TempNei ×Num Temp , a×Num Temp ).
[0244] Furthermore, in an embodiment of the present application, when determining the first parameter, if the prediction mode of at least one adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, a first threshold is determined based on at least one matching cost value corresponding to the at least one adjacent reconstructed block, at least one pixel parameter corresponding to the at least one adjacent reconstructed block, and the pixel parameters corresponding to the first template; a second threshold is determined based on the pixel parameters corresponding to the first template and the maximum average pixel value difference between the current block and the adjacent reconstructed block; and the first parameter is determined based on the first threshold and the second threshold.
[0245] It can be understood that in an embodiment of the present application, if the prediction mode of at least one adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, then when determining the first threshold, it is necessary to refer to at least one matching cost value corresponding to at least one adjacent reconstructed block, and it is also necessary to refer to at least one pixel parameter corresponding to at least one adjacent reconstructed block.
[0246] For example, in some embodiments, if at least two of the multiple adjacent positions of the current block are encoded using the IntraTMP mode, that is, the current block has more than two adjacent reconstructed blocks using the IntraTMP mode, the matching cost value SAD of the adjacent positions (adjacent reconstructed blocks) can be recorded as SAD Idx (Idx=0,1,…,N,N≥1), then we can define Then we can define the first parameter SAD thre =min(Diff neighbor / Num TempNei ×Num Temp , a×Num Temp ). Among them, Num TempNei It can be determined by at least one pixel parameter corresponding to at least one adjacent reconstructed block, for example, the sum of at least one pixel parameter corresponding to at least one adjacent reconstructed block is determined as Num TempNei Alternatively, the mean value of at least one pixel parameter corresponding to at least one adjacent reconstructed block is determined as Num TempNei Alternatively, the pixel parameter corresponding to one of the at least one adjacent reconstructed blocks is determined as Num TempNei .
[0247] Furthermore, in an embodiment of the present application, the preset search area includes at least one search area (ie, at least one sub-search area). Accordingly, different first parameters may be set for different search areas.
[0248] That is, in the present application, at least one first parameter corresponding to at least one search area may be determined, wherein the first parameters corresponding to different search areas may be the same or different.
[0249] Furthermore, in an embodiment of the present application, when determining at least one first parameter corresponding to at least one search area, if there is an adjacent reconstructed block corresponding to the current block in a current search area of the at least one search area, and the prediction mode of the adjacent reconstructed block is an intra-frame template matching-based prediction mode, then the first parameter corresponding to the current search area is determined based on the adjacent reconstructed block.
[0250] For example, in some embodiments, different thresholds SADThre are set for different search areas. RegionId (RegionId=0,1,2,3,…),SADThre regionId DiffNeI of the corresponding area of the block encoded by the adjacent reconstructed blocks using the IntraTMP mode regionId The number of reference template pixels of adjacent reconstructed blocks is Num TempNei , the number of pixels of the reference template of the current block is recorded as Num Temp The maximum average pixel SAD difference between the current block and the adjacent reconstructed block on one pixel is recorded as a(offsetDiff regionId ), then we can define the first parameter SAD thre =min(DiffNei regionId / Num TempNei ×Num Temp , a×Num Temp ).
[0251] It is understood that in the embodiment of the present application, if there is no adjacent reconstructed block corresponding to the current block in one of the at least one search areas, or the prediction mode of the adjacent reconstructed block in the search area is not an intra-frame template matching-based prediction mode, then the first parameter corresponding to the search area can be determined according to the preset first parameter. For example, the first parameter corresponding to the search area is determined based on the bit depth information corresponding to the current image and the pixel parameters corresponding to the first template.
[0252] Furthermore, in an embodiment of the present application, when searching within a preset search area based on a first parameter corresponding to the current block to determine the block vector of the current block, the search points in the preset search area can be traversed sequentially according to a preset scanning order, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template can be determined based on a preset matching criterion; if the first matching cost value and the first parameter meet a stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0253] It is understood that in the embodiments of the application, if the first parameter is a matching cost threshold corresponding to the matching cost value, then the first parameter can be understood as a cost upper threshold. Therefore, the corresponding stopping condition can be the relative magnitude between the matching cost value and the first parameter.
[0254] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the first matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the first matching cost value is greater than the first parameter.
[0255] Accordingly, in an embodiment of the present application, if the first matching cost value is greater than the first parameter, then the next search point in the preset search area may be traversed in the preset scanning order.
[0256] It should be noted that, in the embodiment of the present application, for a block vector, bvXMins and bvXMaxs can be selected to represent the minimum offset and maximum offset of the block vector in the horizontal direction, respectively; bvYMins and bvYMaxs can be selected to represent the minimum offset and maximum offset of the block vector in the vertical direction, respectively.
[0257] bvXMinsregionId, bvXMaxsregionId, bvYMinsregionId, bvYMaxsregionId can be calculated using the already determined iVerMinregionId, iVerMaxregionId, iHorMinregionId, iHorMaxregionId:
[0258] bvXMinsregionId=iHorMinregionId-xTbCmp;
[0259] bvXMaxsregionId=iHorMaxregionId-xTbCmp;
[0260] bvYMinsregionId=iVerMinregionId-yTbCmp;
[0261] bvYMaxsregionId=iVerMaxregionId-yTbCmp;
[0262] bvXMinsregionId, bvXMaxsregionId, bvYMinsregionId, and bvYMaxsregionId determine the horizontal and vertical offset ranges of the search point relative to the current block, that is, the range of the block vector BV.
[0263] It should also be noted that, in the embodiments of the present application, through the search points (iPosHor, iPoxVer) in each search area, that is, each block vector BV (consisting of horizontal and vertical components: (pX, pY), where pX = iPosHor-xTbCmp, pY = iPosVer-yTbCmp, then pX is between bvXMins and bvXMaxs, and pY is between bvYMins and bvYMaxs), a matching reconstructed block of the current block can be found in the reconstruction area, and the adjacent reconstructed pixels of the matching reconstructed block are the matching template.
[0264] It can be understood that in the embodiment of the present application, when traversing the search points (iPosHor, iPoxVer) within the current search range (preset search area) in a preset scanning order, each search point can find a matching reconstructed block of the current block in the reconstruction area, and the adjacent reconstructed pixels of the matching reconstructed block are the matching template.
[0265] Furthermore, in the embodiment of the present application, the matching cost between the adjacent template of the current block and the adjacent template of the reconstructed block is recorded as pDiff. If the pDiff of the current search point satisfies pDiff<=SAD thre , that is, the first matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then the matching template obtained by the search can be considered as a reconstructed template that meets the conditions, and then the search can be stopped, and its corresponding first matching cost pDiff is recorded as pDiff_BEST, its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST), and its corresponding matching template is recorded as the best matching template T_BEST.
[0266] It should be noted that in the embodiments of the present application, when performing search processing, the search strategies that can be adopted include but are not limited to search methods based on different search step sizes, for example, a coarse search based on a first search step size and / or a fine search based on a second search step size, wherein the first search step size is larger than the second search step size.
[0267] Furthermore, in an embodiment of the present application, the block vector and candidate template can be determined by traversing the search points in the preset search area according to a preset scan order and a first search step size. Alternatively, the block vector and candidate template can be determined by traversing the search points in the preset search area according to a preset scan order and a second search step size.
[0268] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed according to a preset scanning order and a first search step size to determine an initial block vector and an initial matching template corresponding to the initial block vector; then, a first search area can be determined based on the initial matching template; wherein the first search area is smaller than the preset search area; finally, the search points in the first search area can be traversed according to the preset scanning order and a second search step size to determine a block vector and a candidate template; wherein the first search step size is larger than the second search step size.
[0269] That is, in the embodiment of the present application, when searching for the best matching template in the search area, a search strategy of coarse search first and then fine search may be adopted, or only fine search may be performed, or only coarse search may be performed.
[0270] Exemplarily, in an embodiment of the present application, the coarse search may specifically include: determining the best coarse matching template in the search area with a first preset step size (i.e., a first search step size, such as 2 or 3, etc.), that is, obtaining the final candidate template, or using a downsampled template (e.g., a downsampling factor of 2 or 3, etc.) to determine the best coarse matching template in the search area, that is, obtaining the final candidate template.
[0271] Exemplarily, in an embodiment of the present application, the fine search may specifically include: determining the best fine matching template in the search area with a second preset step size (i.e., the second search step size, such as 1 or 1 / 2, etc.), that is, obtaining the final candidate template, or, after completing the coarse search, determining the best fine matching template near the best coarse matching template, that is, obtaining the final candidate template.
[0272] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed sequentially according to a preset scanning order and a first search step size, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion. If the first matching cost value and the first parameter meet the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0273] It can be understood that, in the embodiment of the application, satisfying the stop search condition may include that the first matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the first matching cost value is greater than the first parameter.
[0274] For example, in an embodiment of the present application, if the search strategy is to perform only a coarse search, then it is possible to select a region in which pX is between bvXMinsregionId and bvXMaxsregionId and pY is between bvYMinsregionId and bvYMaxsregionId, and perform a coarse search with a step size greater than 1 (e.g., a step size of 2 or 3). If the pDiff of the current search point satisfies pDiff<=SAD thre , that is, the first matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then the matching template obtained by the search can be considered as a reconstructed template that meets the conditions, and then the search can be stopped, and the matching cost pDiff obtained by template matching is recorded as pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST, and each item is a coordinate pair (pX_BEST, pY_BEST).
[0275] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed sequentially according to a preset scanning order and a second search step size, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion. If the first matching cost value and the first parameter meet the stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0276] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the first matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the first matching cost value is greater than the first parameter.
[0277] For example, in an embodiment of the present application, if the search strategy is to perform only fine search, then it is possible to select a search range in each region where pX is between bvXMinsregionId and bvXMaxsregionId and pY is between bvYMinsregionId and bvYMaxsregionId, and perform fine search with a smaller step size (for example, a step size of 1 or 1 / 2, when the step size is less than 1, sub-pixel interpolation is required), and if the pDiff of the current search point satisfies pDiff<=SAD thre , that is, the first matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then the matching template obtained by the search can be considered as a reconstructed template that meets the conditions, and then the search can be stopped, and the matching cost pDiff obtained by template matching is recorded as pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST, and each item is a coordinate pair (pX_BEST, pY_BEST).
[0278] Furthermore, in an embodiment of the present application, a search may be performed in a preset search area according to a preset scanning order and a first search step size, and a second matching cost value between a matching template corresponding to a search point in the preset search area and the first template is determined according to a preset matching criterion; if the second matching cost value and the first parameter satisfy a stop search condition, the search of the preset search area is terminated, and a block vector corresponding to the second matching cost value is determined as a reference block vector of the current block; a first search area is determined based on a matched reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; a search is performed in the first search area according to a preset scanning order and a second search step size, and a third matching cost value between a matching template corresponding to a search point in the first search area and the first template is determined according to a preset matching criterion; wherein the first search step size is greater than the second search step size; and if the third matching cost value and the first parameter satisfy the stop search condition, the search of the first search area is terminated, and the block vector corresponding to the third matching cost value is determined as the block vector of the current block.
[0279] It is understood that in the embodiments of the application, if the first parameter is a matching cost threshold corresponding to the matching cost value, then the first parameter can be understood as a cost upper threshold. Therefore, the corresponding stopping condition can be the relative magnitude between the matching cost value and the first parameter.
[0280] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the second matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the second matching cost value is greater than the first parameter.
[0281] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the third matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the third matching cost value is greater than the first parameter.
[0282] That is, in an embodiment of the present application, the conditions for stopping the search are met, including: the first matching cost value is less than or equal to the first parameter; and / or the second matching cost value is less than or equal to the first parameter; and / or the third matching cost value is less than or equal to the first parameter.
[0283] Exemplarily, in an embodiment of the present application, if the search strategy is to perform a coarse search first and then a fine search, a coarse search record template matching can be performed with a step size of 2 (i.e., the first search step size is 2) to obtain the best coarse matching template (initial matching template), and then the best fine matching template can be determined near the best coarse matching template with a step size of 1 (i.e., the second search step size is 1), thereby obtaining the final candidate template.
[0284] In the coarse search phase, it is possible to select a search range within each region where pX is between bvXMinsregionId and bvXMaxsregionId and pY is between bvYMinsregionId and bvYMaxsregionId, and perform a coarse search with a step size greater than 1. For example, if the coarse search is performed with a step size of 2, and the current search point pDiff satisfies pDiff <= SAD during the coarse search traversal, thre , that is, the second matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then it can be determined that the matching template obtained by the search is a reconstruction template that meets the conditions, then the search is stopped and the optimal matching cost obtained by template matching is recorded as pDiff1_BEST=pDiff refine , and its corresponding block vector BV is recorded as the best block vector BV1_BEST (pX1_BEST, pY1_BEST), that is, the reference block vector, and its corresponding matching template is the initial matching template. At this time, the search area where the best matching search point is located is bestRegionId.
[0285] Next, in the fine search stage, you can choose to search near the best block vector BV1_BEST (reference block vector) obtained in the coarse search, that is, search in the first search area. Therefore, you first need to determine the refined search range TmpRefineRange, that is, you need to determine the first search area TmpRefineRange. Among them, the refined search range (first search area TmpRefineRange) can be a fixed size or related to the current block size. For example, it can be set to min(nTbW, nTbH) / 2, and then calculate the position of the best matching reconstructed block obtained in the coarse search as the reference position of the fine search area: BestPosX=xTbCmp+pX1_BEST, BestPosY=yTbCmp+pY1_BEST.
[0286] In one embodiment, the calculated values of iVerMinbestRegionId, iVerMaxbestRegionId, iHorMinbestRegionId, and iHorMaxbestRegionId may be first obtained according to the value of bestRegionId, and then new search ranges iVerMinrefine, iVerMaxrefine, iHorMinrefine, and iHorMaxrefine may be obtained according to the optimal matching block position obtained by the coarse search. The obtaining method is as follows: iHorMinrefine = max(iHorMinbestRegionId, BestPosX - TmpRefineRange) iHorMaxrefine = min(iHorMaxbestRegionId, BestPosX + TmpRefineRange) iVerMinrefine = max(iVerMinbestRegionId, BestPosY - TmpRefineRange) iVerMaxrefine = min(iVerMaxbestRegionId, BestPosY + TmpRefineRange)
[0287] Then, the adjusted block vectors BVbvXMins, bvXMaxs, bvYMins, bvYMaxs can be calculated by iVerMinrefine, iVerMaxrefine, iHorMinrefine, iHorMaxrefine: bvXMins=iHorMinrefine-xTbCmp; bvXMaxs=iHorMaxrefine-xTbCmp; bvYMins=iVerMinrefine-yTbCmp; bvYMaxs=iVerMaxrefine-yTbCmp;
[0288] The fine search is performed within the block vector range where pX is between bvXMinsrefine and bvXMaxsrefine and pY is between bvYMinsrefine and bvYMaxsrefine. For example, if the search is performed with a step size of 1, and the current search point pDiff is refine Satisfy pDiff <= SAD thre , that is, the third matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then it can be determined that the matching template obtained by the search is a reconstruction template that meets the conditions, then the search is stopped and the best matching cost obtained by template matching is recorded as pDiff_BEST=pDiff refine, and its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST), that is, the final block vector of the current block, and its corresponding matching template is the candidate template of the current block.
[0289] After completing the above operations, the optimal block vector BV_BEST (pX_BEST, pY_BEST) can be obtained, where pX_BEST and pY_BEST are the horizontal offset and vertical offset of the best matching template relative to the current coding block template, respectively, and are also the horizontal offset and vertical offset of the best matching reconstructed block relative to the current coding block.
[0290] It should be noted that in the embodiment of the present application, by combining the results of the coarse search and the fine search process (wherein the fine search process includes one or more reference point searches), one or more optimal block vectors BV_BEST for different algorithm requirements can be obtained, where BV_BEST is a coordinate pair (pX_BEST, pY_BEST).
[0291] It can be seen that in the embodiment of the present application, the process of searching and determining one or more block vectors in the search area may include three search strategies: only coarse search, only fine search, and coarse search first and then fine search.
[0292] Furthermore, in an embodiment of the present application, for at least one search area included in the preset search area, when searching within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block, a first search order corresponding to the at least one search area can be first determined based on the positional relationship between the current block and the at least one search area; and then, based on the first search order, the at least one search area is traversed in sequence, and a search is performed within the at least one search area based on the first parameter to determine the block vector of the current block.
[0293] It should be noted that in the embodiment of the present application, the first search order may be an order of distance from the current block from closest to farthest. This is because when searching multiple sub-search areas, searching in a near-to-far order can more quickly determine the block vector of the current block.
[0294] Exemplarily, in some embodiments, different search areas may also be defined in different ways. FIG13 is a schematic diagram of at least one search area. As shown in FIG13 , the areas closer to the current block may be defined as R1, R2, and R3, and the areas farthest away may be defined as R4, R5, and R6, and the search may be performed in the order of R1, R2, and R3, and then R4, R5, and R6.
[0295] That is, in the embodiment of the present application, the search order corresponding to different search areas may be determined according to the positional relationship between the search area and the current block.
[0296] It should be noted that, in the embodiments of the present application, the order of R1 and R2 can be swapped, and the order of R4 and R5 can be swapped.
[0297] Furthermore, in an embodiment of the present application, for at least one search area included in the preset search area, when searching within the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block, the at least one search area can be merged according to the positional relationship between the current block and the at least one search area to obtain at least one merged search area; then, based on the positional relationship between the current block and the at least one merged search area, a second search order corresponding to the at least one merged search area is determined; and based on the second search order, the at least one merged search area is traversed sequentially, and a search is performed within the at least one merged search area according to the first parameter to determine the block vector of the current block.
[0298] It should be noted that in the embodiment of the present application, the second search order may be an order of distance from the current block from closest to farthest. This is because when searching multiple sub-search areas, searching in a near-to-far order can more quickly determine the block vector of the current block.
[0299] For example, in some embodiments, as shown in FIG13 , R1 and R3 may be merged into one region; or R2 and R3 may be merged into one region; or R5 and R6 may be merged into one region; or R4 and R6 may be merged into one region, etc.
[0300] For example, in some embodiments, different search areas may be defined in different ways. FIG14 is a second schematic diagram of at least one search area. As shown in FIG14 , when searching for a predetermined reconstruction area within a preset search area, the search may be performed in the order of R1, R2, R3, R7, R8, and then R4, R5, and R6. The order of R1 and R2 may be swapped, the order of R7 and R8 may be swapped, and the order of R4 and R5 may be swapped.
[0301] Furthermore, in an embodiment of the present application, the preset scanning order includes any one of the following scanning orders: raster scanning order, longitudinal reverse raster scanning order, transverse reverse raster scanning order, full reverse raster scanning order, diagonal scanning order, horizontal scanning order, vertical scanning order, and Z-shaped scanning order.
[0302] That is to say, in an embodiment of the present application, when traversing the search points within a preset search area, a raster scanning order from top to bottom and from left to right may be adopted, or a longitudinal reverse raster scanning order from bottom to top and from left to right may be adopted, or a transverse reverse raster scanning order from top to bottom and from right to left may be adopted, or a full reverse raster scanning order from bottom to top and from right to left may be adopted, or a diagonal scanning, horizontal scanning, vertical scanning, Z-shaped scanning and other orders may be adopted.
[0303] Furthermore, in an embodiment of the present application, for at least one search area included in the preset search area, when traversing the at least one search area in sequence based on the first search order, for a current search area in the at least one search area, the search points in the current search area are traversed in sequence according to the preset scanning order corresponding to the current search area to determine the block vector of the current block.
[0304] That is, for each search area, the same scanning method and scanning order may be adopted, or different scanning methods or the same scanning method but different scanning orders may be adopted.
[0305] It should be noted that, in an embodiment of the present application, for a first area in at least one search area that is located above the current block, the longitudinal reverse raster scanning order is determined as the preset scanning order corresponding to the first area; for a second area in at least one search area that is located on the left side of the current block, the horizontal reverse raster scanning order is determined as the preset scanning order corresponding to the second area; and for a third area in at least one search area that is located on the upper left side of the current block, the full reverse raster scanning order is determined as the preset scanning order corresponding to the third area.
[0306] Exemplarily, in some embodiments, as shown in FIG14 , R1 and R5 may be searched in a longitudinal reverse raster scan order, R2 and R4 may be searched in a transverse reverse raster scan order, and R3 and R6 may be searched in a full reverse raster scan order.
[0307] It should be noted that, in an embodiment of the present application, for the fourth area in at least one search area, which is located on the upper side and / or upper right side of the current block, the longitudinal reverse raster scanning order is determined as the preset scanning order corresponding to the fourth area; for the fifth area in at least one search area, which is located on the left side and / or lower left side of the current block, the horizontal reverse raster scanning order is determined as the preset scanning order corresponding to the fifth area; for the third area in at least one search area, which is located on the upper left side of the current block, the full reverse raster scanning order is determined as the preset scanning order corresponding to the third area.
[0308] Exemplarily, in some embodiments, as shown in FIG14 , R1, R5, and R7 can be searched in a longitudinal reverse raster scan order, R2, R4, and R8 can be searched in a transverse reverse raster scan order, and R3 and R6 can be searched in a full reverse raster scan order.
[0309] Furthermore, in an embodiment of the present application, the first parameter corresponding to the current block can also be determined by decoding the code stream. The first parameter can be transmitted through any one of the following syntax information: SPS layer syntax information, PPS layer syntax information, APS layer syntax information, SH layer syntax information, and CU layer syntax information.
[0310] That is, in the embodiment of the present application, the threshold condition (first parameter) of the early cutoff can be identified in the SPS, PPS, APS or SH layer to control the complexity of the decoding end.
[0311] Furthermore, in an embodiment of the present application, when searching within a preset search area based on a first parameter corresponding to the current block to determine the block vector of the current block, the search points in the preset search area can also be traversed according to a preset search method, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion; if the first matching cost value and the first parameter meet the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0312] It should be noted that, in the embodiment of the present application, the preset search method includes any one of the following search methods: a cross search method, a square search method, a diamond search method, and a hash search method.
[0313] That is, in the embodiments of the present application, you can choose to search in each area in a preset scanning order, such as a raster order, from top to bottom and left to right, or from bottom to top and right to left. You can also choose to perform a fast iterative search in a preset search area according to a preset search method, where the preset search method includes but is not limited to a cross search, a square search, a diamond search, etc. Alternatively, you can adopt a hash search method similar to IBC. This application does not specifically limit this.
[0314] Furthermore, in an embodiment of the present application, when performing search processing according to a preset search method, the search strategies that can be adopted include but are not limited to search methods based on different search steps, for example, a coarse search based on a third search step and / or a fine search based on a fourth search step, wherein the third search step is larger than the fourth search step.
[0315] Exemplarily, in some embodiments, it is possible to choose to traverse the search points in the preset search area according to a preset search method and a third search step, and determine the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; or, it is possible to choose to traverse the search points in the preset search area according to a preset search method and a fourth search step, and determine the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; wherein the third search step is greater than the fourth search step.
[0316] Exemplarily, in some embodiments, a search may be performed in a preset search area according to a preset search method and a third search step size, and a second matching cost value between a matching template corresponding to a search point in the preset search area and the first template may be determined according to a preset matching criterion; if the second matching cost value and the first parameter satisfy a stop search condition, the search of the preset search area is terminated, and a block vector corresponding to the second matching cost value is determined as a reference block vector of the current block; a first search area is determined based on a matching reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; a search is performed in the first search area according to a preset search method and a fourth search step size, and finally, a third matching cost value between a matching template corresponding to a search point in the first search area and the first template may be determined according to the preset matching criterion; wherein the third search step size is greater than the fourth search step size; if the third matching cost value and the first parameter satisfy the stop search condition, the search of the first search area is terminated, and a block vector corresponding to the third matching cost value is determined as a block vector of the current block.
[0317] That is, in the embodiment of the present application, when searching for the best matching template in the search area according to the preset search method, a search strategy of coarse search first and then fine search may be adopted, or only fine search may be performed, or only coarse search may be performed.
[0318] Furthermore, in an embodiment of the present application, if a fast iterative search is performed according to a preset search method, in addition to using a first parameter to control the search process, a second parameter may also be used to control the search process.
[0319] It should be noted that, in the embodiment of the present application, the second parameter is used to limit the matching cost difference between different templates according to a preset matching criterion.
[0320] That is, in an embodiment of the present application, after determining a preset search area according to the first template, it is possible to select to search within the preset search area according to the first parameter and / or second parameter corresponding to the current block, thereby determining the block vector of the current block.
[0321] Furthermore, in an embodiment of the present application, when searching within a preset search area according to a second parameter corresponding to the current block, an iterative search can be first performed on the search points in the preset search area according to a preset search method, and the iterative cost difference between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion; if the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the preset search area is terminated, and the block vector corresponding to the iterative cost difference is determined as the block vector of the current block; wherein the second parameter is used to limit the matching cost difference between different templates according to the preset matching criterion.
[0322] It should be noted that, in the embodiment of the present application, the second parameter can be used to control the search process. For example, based on the second parameter, you can choose to continue the fast iterative search process, or you can choose to end the fast iterative search process early.
[0323] For example, in an embodiment of the present application, the second parameter may be an iteration cost difference threshold corresponding to the iteration cost difference. Accordingly, when controlling the search process based on the second parameter, if the iteration cost difference and the second parameter (iteration cost difference) satisfy a stop search condition, the fast iterative search process may be terminated prematurely; otherwise, the fast iterative search process may continue.
[0324] It is understood that in the embodiment of the present application, if the second parameter is an iteration cost difference corresponding to the iteration cost difference, then the second parameter can be understood as a difference upper threshold. Therefore, the corresponding stopping search condition can be the magnitude relationship between the iteration cost difference and the second parameter.
[0325] Exemplarily, in an embodiment of the present application, if the iterative cost difference is less than or equal to the second parameter, then it can be considered that the stop search condition is met, and the fast iterative search process can be ended early; if the matching cost value is greater than the second parameter, then it can be considered that the stop search condition is not met, and the fast iterative search process can continue.
[0326] It can be seen that in an embodiment of the present application, when searching based on the second parameter, if the difference in iterative cost before and after the search is less than or equal to the search point of the second parameter, you can choose to end the fast iterative search, thereby achieving control over the search process.
[0327] That is to say, in the embodiments of the present application, in addition to the threshold value (and the first parameter) for the size of the cost itself, the cost difference before and after the iteration can also be taken as the cutoff threshold (i.e., the second parameter). If the cost difference before and after the iteration (iteration cost difference) is less than a certain threshold value (the second parameter), the iteration is stopped.
[0328] It should be noted that in the embodiments of the present application, during the search process, the first parameter and the second parameter can be used simultaneously to control the search process, or the first parameter or the second parameter can be selectively used to control the search process. That is, the iterative cost difference threshold (the second parameter) and the cost size threshold (the first parameter) can be used independently or in combination.
[0329] Furthermore, in an embodiment of the present application, an iterative search can be first performed in a first sub-area of a preset search area according to a preset search method, and the iterative cost difference between the matching template corresponding to the search point in the first sub-area and the first template is determined according to a preset matching criterion; if the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the first sub-area is terminated, and the current matching cost value between the matching template corresponding to the search point in the first sub-area and the first template is determined according to the preset matching criterion; if the current matching cost value and the first parameter meet the stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0330] Furthermore, in an embodiment of the present application, an iterative search can be first performed in the first sub-area of the preset search area according to a preset search method, and the iterative cost difference between the matching template corresponding to the search point in the first sub-area and the first template is determined according to a preset matching criterion; if the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the first sub-area is terminated, and the current matching cost value between the matching template corresponding to the search point in the first sub-area and the first template is determined according to the preset matching criterion; if the current matching cost value and the first parameter do not meet the stop search condition, the iterative search is continued in other sub-areas in the preset search area other than the first sub-area according to the preset search method.
[0331] Exemplarily, in some embodiments, for each sub-area in the preset search area, you can choose to perform a fast iterative search in each sub-area, and when the iterative cost difference (iterative cost difference value) is less than a certain threshold (second parameter), the iterative search process in the sub-area is stopped; if the current cost size (current matching cost value) is less than the cutoff threshold (second parameter), then you can choose to stop the entire search process of the preset search area, that is, end the search process in the preset search area in advance; otherwise, you can choose to continue the iterative search process in other sub-areas.
[0332] Furthermore, in an embodiment of the present application, the second parameter corresponding to the current block can also be determined by decoding the code stream. The second parameter can be transmitted through any one of the following syntax information: SPS layer syntax information, PPS layer syntax information, APS layer syntax information, SH layer syntax information, and CU layer syntax information.
[0333] That is, in the embodiment of the present application, the threshold condition (second parameter) of the early cutoff can be identified in the SPS, PPS, APS or SH layer to control the complexity of the decoding end.
[0334] Step 103: Determine a prediction value of the current block according to the block vector of the current block.
[0335] In an embodiment of the present application, after searching in a preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block, a prediction value of the current block may be further determined according to the block vector of the current block.
[0336] Furthermore, in an embodiment of the present application, when determining the prediction value of the current block based on the block vector of the current block, the reference block of the current block can be first determined based on the block vector of the current block; and then the prediction value of the current block can be determined based on the reference block of the current block.
[0337] For example, in the embodiment of the present application, when determining the reference block of the current block, a simple translation copy can be used to achieve it. The specific operation is: for x=0...nTbW-1, y=0...nTbH-1, through RefBlock n [x][y]=recSamples[x+pX n ][y+pY n ]Determine the reconstructed pixels recSamples of the current frame (i.e., the reference block of the current block).
[0338] It should be noted that, in an embodiment of the present application, when determining the reference block of the current block based on the block vector of the current block, the initial reconstructed block of the current block can be determined based on the block vector of the current block; and then the initial reconstructed block is corrected to determine the reference block of the current block.
[0339] That is to say, in the embodiments of the present application, other methods may be used to obtain candidate reconstructed blocks (reference blocks), for example, first correcting the initial reconstructed block corresponding to the obtained candidate template, and then determining the corresponding reference block.
[0340] It should be noted that, in the embodiment of the present application, the prediction value determined by the block vector of the current block can be used as the final prediction value, and can also be further processed to obtain the final prediction value of the current block.
[0341] Furthermore, in an embodiment of the present application, when determining the prediction value of the current block based on the block vector of the current block, at least one reference block corresponding to the current block can be first determined based on the block vector of the current block; and then the prediction value of the current block can be determined based on the at least one reference block.
[0342] It should be noted that, in an embodiment of the present application, when determining the prediction value of the current block based on at least one reference block, it is possible to first determine the prediction value of the current block based on at least one prediction block corresponding to the at least one reference block; then, weighted fusion is performed on the at least one prediction block to determine the prediction value of the current block.
[0343] Exemplarily, in some embodiments, after determining the block vector of the current block, multiple points may be taken around the block vector, i.e., multiple reference blocks may be obtained, and then the corresponding prediction values of the multiple points may be weightedly fused to obtain the prediction value of the current block.
[0344] Furthermore, in an embodiment of the present application, when determining the prediction value of the current block based on the block vector of the current block, a first prediction value of the current block can be first determined based on the block vector of the current block; then a second prediction value of the current block can be determined based on a preset prediction mode; wherein the preset prediction mode includes a planar mode and / or a directional mode; finally, the prediction value of the current block can be determined based on the first prediction value and the second prediction value.
[0345] For example, in some embodiments, after determining the block vector of the current block, a prediction value obtained using the block vector can be weighted and combined with prediction values obtained from other intra modes to obtain a final prediction value. Other intra modes can be prediction modes other than IntraTMP, such as Planar mode or Directional mode. The Directional mode can be derived from TIMD or located in the Intra candidate table using an index transmitted in the bitstream. This method can be referred to as the IntraTMP CIIP mode.
[0346] It can be understood that in the IntraTMP mode, in addition to the basic copying method to obtain the prediction value, there is also a method of obtaining the prediction value by filtering and fusing the corresponding positions of multiple BVs, as well as a method of fusion prediction with the ordinary Intra mode.
[0347] Furthermore, in an embodiment of the present application, after the prediction value of the current block is determined according to the block vector of the current block, the reconstructed value of the current block may be further determined according to the prediction value of the current block.
[0348] It should be noted that, in the embodiment of the present application, the code stream may be decoded first to determine the prediction residual corresponding to the current block; and then the reconstructed value of the current block may be further determined based on the prediction residual and the prediction value.
[0349] To sum up, through the decoding method proposed in the above steps 101 to 103, the current image information (such as depth information) or the Diff information of the adjacent positions of the current block to be encoded (such as the matching cost value corresponding to the adjacent reconstructed block) can be effectively utilized to derive a first parameter for template matching. During the search process, if it is determined that the matching cost value corresponding to the search point satisfies the first parameter, the search process of the current coding block can be exited in advance, thereby reducing the IntraTMP search complexity to a certain extent.
[0350] It should be noted that in the embodiments of the present application, the first parameter determined by the current image information (such as depth information) can be a predefined fixed threshold, while the first parameter determined based on the adjacent reference blocks using the IntraTMP mode can be an adaptive threshold. Different first parameters can be set for different sub-search areas within the preset search area to control the search process.
[0351] For example, in some embodiments, a search scheme based on the reference template SAD matching cost can be proposed for the IntraTMP technology to exit early. This search scheme can use a reference template matching cost threshold (first parameter) to control the search process and can terminate the search early when the first parameter is met, thereby ensuring algorithm effectiveness while taking into account complexity.
[0352] Exemplarily, in some embodiments, a template matching cost threshold (first parameter) can be derived using the current image information or the Diff information of the adjacent positions of the current block to be encoded. When the threshold of the current search point does not exceed the threshold, the BV of the search point is recorded as the best block vector BV_BEST, and the search process is exited early.
[0353] The Intra TMP-BV function takes as input the position (xTbCmp, yTbCmp) of the current coding block (current block), its width nTbW, and its height nTbH. It also outputs the current block's BV and the corresponding prediction block's prediction value, predSamples[x][y], where x = 0..nTbW-1 and y = 0..nTbH-1. This prediction block's prediction value can be used as the final prediction value or further processed to obtain the final prediction value for the current block.
[0354] It is understood that the specific process for acquiring the intra TMP-BV proposed in this embodiment is divided into three steps: determining the current template type, acquiring the reconstructed pixels of the current template, and determining the block vector within a predefined search range. For each acquired BV, a set of predicted values for the current block can be obtained.
[0355] An embodiment of the present application provides a decoding method, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, the decoder determines the first template corresponding to the current block, and determines a preset search area based on the first template; searches within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block; wherein the first parameter is used to control the search process; and determines the prediction value of the current block based on the block vector of the current block. It can be seen that in an embodiment of the present application, based on the IntraTMP mode, a predetermined first parameter, such as a matching cost threshold, can be used to control the search process, so that the search process can be terminated early or continued based on the first parameter. In other words, the encoding and decoding method proposed in an embodiment of the present application can solve the problem of high computational complexity caused by traversing all search points in the search area by introducing the first parameter for controlling the search process, and can improve encoding and decoding efficiency and performance.
[0356] An embodiment of the present application provides an encoding method, which is applied to an encoder. FIG15 is a flow chart of the encoding method provided in the embodiment of the present application. As shown in FIG15 , the encoding method performed by the encoder may include the following steps:
[0357] Step 201: When the prediction mode of the current block is the intra-frame template matching-based prediction mode, determine a first template corresponding to the current block, and determine a preset search area according to the first template.
[0358] In an embodiment of the present application, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, a first template corresponding to the current block may be determined first. When acquiring the first template, the template type corresponding to the current block may be determined first, and then the first template corresponding to the current block may be further determined based on the template type.
[0359] It can be understood that, in the embodiment of the present application, the intra-frame template matching-based prediction mode may be a prediction mode using template matching. For example, the intra-frame template matching-based prediction mode may be an IntraTMP mode.
[0360] Furthermore, in an embodiment of the present application, after determining the first template corresponding to the current block, a preset search area corresponding to the current block may be further determined based on the first template.
[0361] It should be noted that the encoding method of the embodiment of the present application is applied to an encoder. In addition, the encoding method may include an intra-frame prediction method, more specifically, a color component prediction method. The video image can be divided into multiple coding blocks, each coding block may include a first color component, a second color component, and a third color component, 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.
[0362] Here, when the first color component needs to be predicted, the component to be predicted is the first color component; when the second color component needs to be predicted, the component to be predicted is the second color component; when the third color component needs to be predicted, the component to be predicted is the third color component. In addition, assuming that the current block predicts the first color component and the first color component is the luminance component, that is, the component to be predicted is the luminance component, then the current block can also be called a luminance block; or assuming that the current block predicts the second color component and the second color component is the chrominance component, that is, the component to be predicted is the chrominance component, then the current block can also be called a chrominance block.
[0363] It should also be noted that, in the embodiments of the present application, the reference pixel (Reference Sample) of the current block may refer to a reference pixel point adjacent to the current block; wherein, adjacent here may be spatially adjacent, but is not limited to this. For example, adjacent may also mean temporal adjacent, spatially and temporally adjacent, or even the reference pixel of the current block may be a reference pixel obtained by performing some processing on spatially adjacent, temporally adjacent, or spatially and temporally adjacent reference pixels, etc., and the embodiments of the present application do not impose any limitation thereto.
[0364] Furthermore, in an embodiment of the present application, the template type of the current block may be determined based on indication information in the code stream; or the template type of the current block may be determined based on the size of the current block.
[0365] Furthermore, in an embodiment of the present application, the template type of the current block can be determined 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, the upper left adjacent reference pixels of the current block, the lower left adjacent reference pixels of the current block, and the upper right adjacent reference pixels of the current block.
[0366] It is understandable that in the embodiment of the present application, the reference pixels of the current block may include the adjacent reconstructed pixels of the current block, that is, the adjacent reconstructed pixels of the current block may be selected as a template to search for a matching template in a predefined search area.
[0367] It should be noted that, in an embodiment of the present application, the reference pixels of the current block, that is, the adjacent reconstructed pixels of the current block may include the upper reference pixel, the upper left reference pixel, the upper right reference pixel, the left reference pixel and the lower left reference pixel of the current block.
[0368] It can be understood that in the embodiment of the present application, when the template type of the current block is determined using the reference pixels of the current block, the template type can be classified and determined according to whether the adjacent reference pixels are available.
[0369] It is understandable that, in the embodiment of the present application, when determining the template type of the current block, the template type may be classified and determined according to an indication in the code stream.
[0370] Further, in an embodiment of the present application, when determining the template type of the current block based on the reference pixels of the current block, 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 a first value; if the left adjacent reference pixels of the current block are available, the template type of the current block is determined to be a second value; if the upper adjacent reference pixels of the current block are available, the template type of the current block is determined to be a third value; if the left adjacent reference pixels of the current block and the upper-left adjacent reference pixels of the current block are both available, the template type of the current block is determined to be a fourth value; if the left adjacent reference pixels of the current block and the lower-left adjacent reference pixels of the current block are both available, the template type of the current block is determined to be a fifth value; if the upper adjacent reference pixels of the current block and the upper-right adjacent reference pixels of the current block are both available, the template type of the current block is determined to be a sixth value.
[0371] It should be noted that in the embodiments of the present application, the first value, the second value, the third value, the fourth value, the fifth value, and the sixth value can be any values and are not specifically limited in this application. For example, the first value, the second value, the third value, the fourth value, the fifth value, and the sixth value can be 1, 2, 3, 4, 5, and 6, respectively.
[0372] For example, in an embodiment of the present application, refTemplateType can be used to represent the template type. Accordingly, as shown in FIG3 above, the block filled with the grid is the current block, and the adjacent area of the current block is the template T. Six template types are shown here.
[0373] Exemplarily, these six template types are as follows: 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) in Figure 3; when only the left reference pixel is available, the value of refTemplateType is 2, and the template shape is shown in (b) in Figure 3; when only the upper reference pixel is available, the value of refTemplateType is 3, and the template shape is shown in (c) in Figure 3; 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 3; 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 3; 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 3.
[0374] In some embodiments, the IntraTMP template type can be selected based on the aforementioned reference pixel availability information and instructions in the bitstream. For example, a sequence number for each template type can be agreed upon, and the actual template sequence number information used can be transmitted in the bitstream, so that the template type can be determined at the decoding end.
[0375] That is, in the embodiments of the present application, the template type can be determined based on the availability information of the reference pixels of the current block, or based on information indicated in the bitstream, or based on a combination of the availability information of the reference pixels and information indicated in the bitstream. This application does not make any specific limitations.
[0376] Furthermore, in an embodiment of the present application, when determining the first template corresponding to the current block based on the template type, the template reference pixels of the current block can be determined first based on the template type and the template size corresponding to the template type, and then the first template of the current block can be determined based on the template reference pixels.
[0377] It should be noted that, in an embodiment of the present application, the first template of the current block may include template reference pixels of the current block, wherein the template reference pixels of the current block may be determined by the template type of the current block and the template size corresponding to the template type.
[0378] It should be noted that, in an embodiment of the present application, the first template of the current block can be composed of reconstructed pixels of one or more areas above, upper right, left, lower left, and upper left of the current block, that is, it can be composed of reference pixels of the current block.
[0379] It should be noted that in the embodiments of the present application, the template size corresponding to the template type can be pre-set, can be indicated by a codestream syntax element, or can be adaptively selected based on the block size or other information. For example, when obtaining the left template, the template width templateW_size can be set to 4, and when obtaining the upper template, the template height templateH_size can be set to 4.
[0380] Accordingly, in an embodiment of the present application, by combining the value of the template type refTemplateType of the current block and the template size corresponding to the refTemplateType, it is possible to determine which part of the reconstructed pixels to obtain as the template reference pixels of the current block, and then determine the corresponding first template.
[0381] Exemplarily, in an embodiment of the present application, when the value of refTemplateType is 1, you can choose to obtain the left, upper left and upper reconstructed pixels of the current block; when the value of refTemplateType is 2, only the left 4 columns of reconstructed pixels of the current 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.
[0382] Of course, the value of the preset template size can be any integer greater than 0, and is not limited to 4, and this application does not make any specific limitation on this.
[0383] It can be understood that in the embodiment of the present application, in combination with the template type and the corresponding template size of the current block, the template reference pixel of the current block determined from the reference pixels of the current block can be the first template corresponding to the current block.
[0384] It should be noted that, in an embodiment of the present application, the block vector search process may include an initialization process, determining a search area (preset search area) of the first template in the current frame, searching and determining one or a pair of optimal block vectors in the search area. Therefore, when performing the search process, the initialization operation needs to be completed first.
[0385] Exemplarily, as shown in FIG5 , nTbW and nTbH represent the size of the current block, templateW_size and templateH_size represent the size of the template, and uiPatchWidth and uiPatchHeight represent the size of the block including the current block and its template.
[0386] Accordingly, during initialization, uiPatchWidth can be initialized to nTbW + templateW_size, and uiPatchHeight can be initialized to nTbH + templateH_size, where templateW_size and templateH_size can be fixed constants, or indicated by codestream syntax elements, or dynamically adjusted according to the coding block size or other information. TemplateW_size and templateH_size can be equal or unequal. For example, templateW_size = 4, templateH_size = 4; or when the width of the coding block is greater than 8, set templateW_size = 4, when the width of the coding block is less than or equal to 8, set templateW_size = 2, when the height of the coding block is greater than 8, set templateH_size = 4, when the height of the coding block is less than or equal to 8, set templateH_size = 2.
[0387] Furthermore, the cost threshold between the initialization templates is represented by diffThreshold. For example, when the cost function is SAD, the threshold can be: diffThreshold = ((1 <<bitDepth)> >2)×(uiPatchHeight×uiPatchWidth-nTbH×nTbW). When the image bit depth bitDepth is 10, diffThreshold indicates that the distortion threshold of each pixel in the template area is 256.
[0388] Furthermore, the position of the coding tree block CTB where the current block CB is located is initialized: ctbRsX, ctbRsY.
[0389] Furthermore, the position offset of the current block CB in the current CTB is initialized: offsetLCBY=yTbCmp−ctbRsY, offsetLCBX=xTbCmp−ctbRsX.
[0390] Furthermore, initialize iTemplateSizeH=templateH_size and iTemplateSizeW=templateW_size.
[0391] Furthermore, iBvShift is initialized, where iBvShift is the precision of the block vector BV. For example, the precision of BV can be integer pixel precision, in which case iBvShift is 0; the precision of BV can also be sub-pixel precision, for example, iBvShift of 1 indicates 1 / 2 pixel precision, and iBvShift of 2 indicates 1 / 4 pixel precision. This is not specifically limited here.
[0392] Furthermore, the preset search range of the template is initialized. The preset search range of the template can be set to a fixed size or dynamically adjusted according to the coding block size. For example, searchRangeWidth = TMP_SEARCH_RANGE_MULT_FACTOR × nTbW, searchRangeHeight = TMP_SEARCH_RANGE_MULT_FACTOR × nTbH; where the value of TMP_SEARCH_RANGE_MULT_FACTOR can be a preset value, can be indicated by a bitstream syntax element, or can be adaptively adjusted according to information such as the coding block size, for example, set to 5.
[0393] It should be noted that in the embodiments of the present application, the preset search area can be the reconstructed portion of the current image and is limited by the size of the search range. As shown in Figure 6 above, the dark-filled background area is the reconstructed area, the black-filled background block is the current block, and the dashed box is the search range window. Therefore, the preset search area of the IntraTMP technology is no larger than the overlap between the reconstructed area represented by the dark background and the area indicated by the dashed box.
[0394] As can be seen, the preset search area for the current block template can be the reconstructed portion of the CTB where the current block is located, or it can be another reconstructed CTB area. The preset search area here is actually the set of all search points. Because the shape of this area is often not representable by a single rectangular area, in a specific implementation, it is also possible to search in multiple rectangular areas and then combine the search results from different areas to obtain the final best matching block and best block vector.
[0395] For example, see Figure 7 above, which shows eight different sub-region division methods. The black-filled background block is the current block; (a), (b), (c), (d), and (f) all divide the preset search area into four sub-search areas; (e), (g), and (h) all divide the preset search area into three sub-search areas. Here, different fill patterns represent a sub-search area.
[0396] In Figure 7, (a), (b), (c), and (d) consider all available search ranges, and (e), (f), (g), and (h) do not search the area directly above and to the left.
[0397] For example, assuming that different sub-search regions are represented by regionId, and considering that the template pixels of the current block need to be retrieved in the image reconstruction region and the pixels of the reconstructed block corresponding to the template also need to be retrieved in the reconstruction region, it is necessary to further determine the positions that can be searched within the sub-search regions represented by different regionIds based on the current block position (xTbCmp, yTbCmp), the current block size (nTbW, nTbH), the current image size (picWidth, picHeight), the size of the CTB in which the current block is located (CtbSizeW, CtbSizeH), the preset search range of the template (searchRangeWidth, searchRangeHeight), and the position offset of the current block within the current CTB (offsetLCBY, offsetLCBX), thereby determining the block vector BV. Specifically, iVerMin and iVerMax represent the absolute coordinate positions that can be searched at least and at most in the vertical direction, respectively, and iHorMin and iHorMax represent the absolute coordinate positions that can be searched at least and at most in the horizontal direction, respectively. The values of iVerMin, iVerMax, iHorMin, and iHorMax are different in the search areas represented by different regionIds.
[0398] In some embodiments, taking (f) in FIG. 7 as an example, the preset search area is divided into four sub-search areas, which are implemented as follows:
[0399] When regionId is equal to 0, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMax0=min((xTbCmp+searchRangeWidth)< <iBvShift,((picWidth-nTbW)<<iBvShift)); iHorMin0=max((iTemplateSizeW)<<iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMax0=(yTbCmp-nTbH-offsetLCBY)<<iBvShift; iVerMin0=max(((iTemplateSizeH)<<iBvShift),((yTbCmp-searchRangeHeight)<<iBvShift))。
[0400] When regionId is equal to 1, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMin1 = max((iTemplateSizeW) < <iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iHorMax1=(xTbCmp-offsetLCBX-nTbW)<<iBvShift; iVerMin1=(yTbCmp+1)<<iBvShift; iVerMax1=min((picHeight-nTbH)<<iBvShift,(yTbCmp-offsetLCBY+CtbSizeH-nTbH)<< iBvShift)。
[0401] When regionId is equal to 2, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMax2 = (xTbCmp - offsetLCBX - nTbW) < <iBvShift; iHorMin2=max((iTemplateSizeW)<<iBvShift,(xTbCmp-searchRangeWidth)<<iBvShift); iVerMin2=max((iTemplateSizeH)<<iBvShift,(yTbCmp-nTbH-offsetLCBY)<<iBvShift); iVerMax2=(yTbCmp)<<iBvShift。
[0402] When regionId is equal to 3, iVerMin, iVerMax, iHorMin, and iHorMax can be calculated as follows: iHorMin3 = max((iTemplateSizeW) < <iBvShift,(xTbCmp-offsetLCBX-nTbW+1)<<iBvShift); iHorMax3=(xTbCmp-nTbW)<<iBvShift; iVerMin3=max(((iTemplateSizeH)<<iBvShift),(yTbCmp-offsetLCBY-nTbH+1)<<iBvShift); iVerMax3=(yTbCmp-nTbH)<<iBvShift。
[0403] It is understandable that in practical applications, the iHorMin regionId 、iHorMax regionId 、iVerMinregionId 、iVerMax regionId Represent the left edge, right edge, top edge and bottom edge of different sub-search areas respectively.
[0404] To intuitively illustrate the different sub-search regions corresponding to different regionIds, see Figure 8, which shows a schematic diagram of the process for determining a preset search region. As shown in Figure 8, R1, R2, R3, and R4 represent four different sub-search regions. Note that Figure 8 represents the pixel range aligned with the top-left corner pixel of the block.
[0405] It is understood that in some embodiments, the preset search area can also be divided into two types: one is a region where all sampling points have been reconstructed (referred to as a full reconstruction search area), and the other is a region where it is uncertain whether all sampling points have been reconstructed (referred to as a pending reconstruction search area). This application does not impose specific limitations.
[0406] Step 202: Search within a preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process.
[0407] In an embodiment of the present application, after determining a preset search area based on the first template, a search may be further performed in the preset search area based on a first parameter corresponding to the current block, thereby determining a block vector of the current block. The first parameter is used to control the search process.
[0408] It should be noted that, in the embodiment of the present application, the first parameter can be used to control the search process. For example, based on the first parameter, you can choose to continue the search process or end the search process early.
[0409] For example, in an embodiment of the present application, the first parameter may be a matching cost threshold corresponding to the matching cost value. Accordingly, when the search process is controlled based on the first parameter, if the matching cost value and the first parameter (matching cost threshold) satisfy the search stop condition, the search process may be terminated prematurely; otherwise, the search process may continue.
[0410] It is understood that in the embodiments of the present application, if the first parameter is a matching cost threshold corresponding to the matching cost value, then the first parameter can be understood as a cost upper threshold. Therefore, the corresponding stopping condition can be the relative magnitude between the matching cost value and the first parameter.
[0411] For example, in an embodiment of the present application, if the matching cost value is less than or equal to the first parameter, then it can be considered that the stop search condition is met, and the search process can be ended early; if the matching cost value is greater than the first parameter, then it can be considered that the stop search condition is not met, and the search process can continue.
[0412] It can be seen that in the embodiment of the present application, when searching based on the first parameter, if the search obtains a search point with a matching cost value less than or equal to the first parameter, the search can be ended, thereby achieving control over the search process.
[0413] That is, in the embodiment of the present application, since calculating the matching cost for all search points in the preset search area will greatly increase the complexity, in order to ensure the coding efficiency while taking into account the complexity, it is possible to choose to use the template matching cost threshold corresponding to the current block, that is, the first parameter SAD thre To control the search process and terminate the search early.
[0414] Furthermore, in an embodiment of the present application, the first parameter is used to limit the matching cost between different templates according to a preset matching criterion.
[0415] It should be noted that, in the embodiment of the present application, the preset matching criteria include any one of the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC.
[0416] Exemplarily, in some embodiments, when the preset matching criterion is SSE, MSE, or SATD, the first parameter for early exiting the search is also correspondingly set to SSEthre, MSEthre, or SATDthre.
[0417] That is to say, in this application, the first parameter corresponds to the preset matching criterion.
[0418] Furthermore, in an embodiment of the present application, the preset matching criteria may also include a first matching criterion and a second matching criterion. The first matching criterion includes any one of the sum of absolute difference (SAD), the sum of transformed absolute difference (SATD), the sum of squared differences (SSE), the mean absolute difference (MAD), the mean absolute error (MAE), the mean squared error (MSE), and the normalized correlation coefficient (NCC). The second matching criterion includes any one of the vector length of the block vector, the sum of the component lengths of the block vector, and a block vector cost parameter.
[0419] It can be understood that, in the embodiment of the present application, the first matching criterion can be understood as including a cost function related to pixel differences, and the second matching criterion can be understood as including a cost function related to the size of the block vector (BV).
[0420] It should be noted that in the embodiments of the present application, in combination with the use of the first matching criterion and the second matching criterion, in the process of determining the block vector of the current block, it is necessary to refer to both the cost function related to the pixel difference and the cost function related to the size of the block vector (BV). In other words, a cost function related to both the pixel difference and the BV size can be used.
[0421] It can be understood that, in the embodiment of the present application, the block vector cost parameter included in the second matching criterion can be understood as a cost parameter related to the block vector.
[0422] Exemplarily, in some embodiments, the block vector cost parameter may include but is not limited to any of the following forms: the vector length of the block vector BV multiplied by a coefficient λ, or the sum of the component lengths of the block vector BV multiplied by a coefficient λ.
[0423] It should be noted that, in the embodiment of the present application, corresponding to the preset matching criteria including the first matching criteria and the second matching criteria, in the process of searching the block vector of the current block, the matching cost value determined for any search point can also correspondingly include two parts: a cost value corresponding to the first matching criteria and related to the pixel difference, and a cost value corresponding to the second matching criteria and related to the BV size.
[0424] For example, in some embodiments, it is assumed that the cost value associated with the pixel difference corresponding to the first matching criterion is expressed as cost Dpel The cost value corresponding to the second matching criterion and related to the BV size is expressed as cost BV , then the matching cost value cost determined for a search point in the preset search area can be expressed as cost = cost BV +cost Dpel .
[0425] Among them, cost BV A quantity related to the size of BV, such as the vector length of BV, or the sum of the lengths of the components of BV, or the vector length of BV multiplied by a coefficient λ, or the sum of the lengths of the components of BV multiplied by a coefficient λ, or a table defining the relationship between BV size and cost BV The relationship between, or define different areas, different areas have different costs BV For example, define a diamond or square multi-layer area centered on a certain value BV (such as zero value BV), and each area takes a fixed costBV value.
[0426] For example, in some embodiments, it is assumed that the cost value associated with the pixel difference corresponding to the first matching criterion is expressed as cost Dpel The cost value corresponding to the second matching criterion and related to the BV size is expressed as cost BV , then the matching cost value cost determined for a search point in the preset search area can be expressed as cost = cost Dpel ×costFactor BV .
[0427] Among them, costFactor BV A quantity related to the size of the BV, such as the vector length of the BV multiplied by a coefficient λ, or the sum of the component lengths of the BV multiplied by a coefficient λ, or a table defining the BV size and costFactor BV The relationship, or define different areas, different areas have different costFactor BV For example, define a diamond or square multi-layer area centered on a certain value BV (such as zero value BV), and each area takes a fixed costFactor BV value.
[0428] Furthermore, in the embodiment of the present application, taking the preset matching criterion as SAD as an example, the first parameter SAD corresponding to the current block can be determined first. thre .
[0429] It should be noted that, in the embodiment of the present application, the first parameter may be determined according to the bit depth information corresponding to the current image and the pixel parameter corresponding to the first template.
[0430] It is understandable that, in the embodiment of the present application, when a first parameter SAD is used thre To jump out of the search process in advance, the first parameter SAD can be determined according to the bit depth information of the current image. thre , wherein the first parameter determined based on the bit depth information of the current image can be a predefined fixed threshold.
[0431] For example, in some embodiments, the first parameter SAD may be defined as thre =((1<<bitDepth)> >3)×Num Temp , where bitDepth is the image bit depth, that is, the bit depth information corresponding to the current image, Num Temp is the number of pixels of the reference template, that is, the pixel parameter of the first template corresponding to the current block.
[0432] It should be noted that, in the embodiment of the present application, if the prediction mode of the adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, then the first parameter can be determined according to the adjacent reconstructed block.
[0433] It can be understood that in an embodiment of the present application, if the prediction mode of the adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, then when determining the first parameter based on the adjacent reconstructed block, the first threshold can be first determined based on the matching cost value corresponding to the block vector of the adjacent reconstructed block and the pixel parameters of the reference template corresponding to the adjacent reconstructed block; at the same time, the second threshold can be determined based on the pixel parameters corresponding to the first template and the maximum average pixel value difference between the current block and the adjacent reconstructed block; finally, the first parameter can be determined based on the first threshold and the second threshold.
[0434] It should be noted that, in an embodiment of the present application, when determining the first parameter based on the first threshold and the second threshold, if the first threshold is less than or equal to the second threshold, the first threshold is determined as the first parameter; if the first threshold is greater than the second threshold, the second threshold is determined as the first parameter.
[0435] It is understandable that, in the embodiment of the present application, when a first parameter SAD is used thre To jump out of the search process in advance, the first parameter SAD can also be determined based on the best template matching cost of the adjacent IntraTMP coding block of the current block thre , wherein the first parameter determined based on the matching cost value corresponding to the adjacent reconstructed block of the current block whose prediction mode is the intra-frame template matching-based prediction mode can be an adaptive threshold.
[0436] For example, in some embodiments, it is assumed that the upper adjacent block of the current block selects IntraTMP as its coding mode, that is, the prediction mode of the adjacent reconstructed block on the upper side of the current block is the intra-frame template matching-based prediction mode, and the block vector (optimal block vector) of the adjacent reconstructed block is BV neighbor , the corresponding matching cost (optimal matching cost) is Diff neighbor , the pixel parameter of the reference template corresponding to the adjacent reconstructed block (the number of pixels of the adjacent block reference template) is Num TempNei , the pixel parameter of the first template corresponding to the current block (the number of pixels of the reference template) is Num Temp , then, according to the matching cost value Diff corresponding to the block vector of the adjacent reconstructed block neighbor Pixel parameter Num of the reference template corresponding to the adjacent reconstructed block TempNei The first threshold determined can be expressed as Diff neighbor / Num TempNei ×Num Temp .
[0437] For example, in some embodiments, the maximum average pixel SAD difference between the current block and the adjacent reconstructed block on one pixel can be recorded as offsetDiff regionId , a can be used to represent the maximum average pixel value difference on a pixel. Wherein, a can be a predefined fixed factor that can be transmitted through high-level syntax. Accordingly, according to the pixel parameter Num corresponding to the first template Temp , and the second threshold determined by the maximum average pixel value difference a between the current block and the adjacent reconstructed block can be expressed as a×Num Temp .
[0438] For example, in some embodiments, when determining the first parameter based on the first threshold and the second threshold, a smaller threshold value of the first threshold and the second threshold value can be selected as the first parameter, that is, the first parameter SAD is defined as thre =min(Diff neighbor / Num TempNei ×Num Temp , a×Num Temp ).
[0439] That is, in the embodiment of the present application, it is assumed that the upper adjacent block of the current unit to be coded selects IntraTMP as its coding mode, and the optimal block vector of the adjacent block is BV neighbor , the corresponding optimal matching cost Diff neighbor , Num TempNei is the number of pixels of the reference template of the adjacent block, based on a maximum offset, SAD thre The value should not be greater than a×Num Temp , where a is the maximum average pixel value difference on a pixel. At this time, the template matching threshold of the current unit to be encoded is set to SAD thre =min(Diff neighbor / Num TempNei ×Num Temp , a×Num Temp ).
[0440] Furthermore, in an embodiment of the present application, when determining the first parameter, if the prediction mode of at least one adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, a first threshold is determined based on at least one matching cost value corresponding to the at least one adjacent reconstructed block, at least one pixel parameter corresponding to the at least one adjacent reconstructed block, and the pixel parameters corresponding to the first template; a second threshold is determined based on the pixel parameters corresponding to the first template and the maximum average pixel value difference between the current block and the adjacent reconstructed block; and the first parameter is determined based on the first threshold and the second threshold.
[0441] It can be understood that in an embodiment of the present application, if the prediction mode of at least one adjacent reconstructed block corresponding to the current block is an intra-frame template matching-based prediction mode, then when determining the first threshold, it is necessary to refer to at least one matching cost value corresponding to at least one adjacent reconstructed block, and it is also necessary to refer to at least one pixel parameter corresponding to at least one adjacent reconstructed block.
[0442] For example, in some embodiments, if at least two of the multiple adjacent positions of the current block are encoded using the IntraTMP mode, that is, the current block has more than two adjacent reconstructed blocks using the IntraTMP mode, the matching cost value SAD of the adjacent positions (adjacent reconstructed blocks) can be recorded as SAD Idx (Idx=0,1,…,N,N≥1), then we can define Then we can define the first parameter SAD thre =min(Diff neighbor / Num TempNei ×Num Temp , a×Num Temp ). Among them, Num TempNei It can be determined by at least one pixel parameter corresponding to at least one adjacent reconstructed block, for example, the sum of at least one pixel parameter corresponding to at least one adjacent reconstructed block is determined as Num TempNei Alternatively, the mean value of at least one pixel parameter corresponding to at least one adjacent reconstructed block is determined as Num TempNei Alternatively, the pixel parameter corresponding to one of the at least one adjacent reconstructed blocks is determined as Num TempNei .
[0443] Furthermore, in an embodiment of the present application, the preset search area includes at least one search area (ie, at least one sub-search area). Accordingly, different first parameters may be set for different search areas.
[0444] That is, in the present application, at least one first parameter corresponding to at least one search area may be determined, wherein the first parameters corresponding to different search areas may be the same or different.
[0445] Furthermore, in an embodiment of the present application, when determining at least one first parameter corresponding to at least one search area, if there is an adjacent reconstructed block corresponding to the current block in a current search area of the at least one search area, and the prediction mode of the adjacent reconstructed block is an intra-frame template matching-based prediction mode, then the first parameter corresponding to the current search area is determined based on the adjacent reconstructed block.
[0446] For example, in some embodiments, different thresholds SADThre are set for different search areas. RegionId (RegionId=0,1,2,3,…),SADThre regionId DiffNeI of the corresponding area of the block encoded by the adjacent reconstructed blocks using the IntraTMP mode regionId The number of reference template pixels of adjacent reconstructed blocks is Num TempNei , the number of pixels of the reference template of the current block is recorded as Num Temp The maximum average pixel SAD difference between the current block and the adjacent reconstructed block on one pixel is recorded as a(offsetDiff regionId ), then we can define the first parameter SAD thre =min(DiffNei regionId / Num TempNei ×Num Temp , a×Num Temp ).
[0447] It is understood that in the embodiment of the present application, if there is no adjacent reconstructed block corresponding to the current block in one of the at least one search areas, or the prediction mode of the adjacent reconstructed block in the search area is not an intra-frame template matching-based prediction mode, then the first parameter corresponding to the search area can be determined according to the preset first parameter. For example, the first parameter corresponding to the search area is determined based on the bit depth information corresponding to the current image and the pixel parameters corresponding to the first template.
[0448] Furthermore, in an embodiment of the present application, when searching within a preset search area based on a first parameter corresponding to the current block to determine the block vector of the current block, the search points in the preset search area can be traversed sequentially according to a preset scanning order, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template can be determined based on a preset matching criterion; if the first matching cost value and the first parameter meet a stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0449] It is understood that in the embodiments of the application, if the first parameter is a matching cost threshold corresponding to the matching cost value, then the first parameter can be understood as a cost upper threshold. Therefore, the corresponding stopping condition can be the relative magnitude between the matching cost value and the first parameter.
[0450] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the first matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the first matching cost value is greater than the first parameter.
[0451] Accordingly, in an embodiment of the present application, if the first matching cost value is greater than the first parameter, then the next search point in the preset search area may be traversed in the preset scanning order.
[0452] It should be noted that, in the embodiment of the present application, for a block vector, bvXMins and bvXMaxs can be selected to represent the minimum offset and maximum offset of the block vector in the horizontal direction, respectively; bvYMins and bvYMaxs can be selected to represent the minimum offset and maximum offset of the block vector in the vertical direction, respectively.
[0453] bvXMinsregionId, bvXMaxsregionId, bvYMinsregionId, and bvYMaxsregionId can be calculated using the already determined iVerMinregionId, iVerMaxregionId, iHorMinregionId, and iHorMaxregionId: bvXMinsregionId = iHorMinregionId - xTbCmp; bvXMaxsregionId = iHorMaxregionId - xTbCmp; bvYMinsregionId = iVerMinregionId - yTbCmp; bvYMaxsregionId = iVerMaxregionId - yTbCmp;
[0454] bvXMinsregionId, bvXMaxsregionId, bvYMinsregionId, and bvYMaxsregionId determine the horizontal and vertical offset ranges of the search point relative to the current block, that is, the range of the block vector BV.
[0455] It should also be noted that, in the embodiments of the present application, through the search points (iPosHor, iPoxVer) in each search area, that is, each block vector BV (consisting of horizontal and vertical components: (pX, pY), where pX = iPosHor-xTbCmp, pY = iPosVer-yTbCmp, then pX is between bvXMins and bvXMaxs, and pY is between bvYMins and bvYMaxs), a matching reconstructed block of the current block can be found in the reconstruction area, and the adjacent reconstructed pixels of the matching reconstructed block are the matching template.
[0456] It can be understood that in the embodiment of the present application, when traversing the search points (iPosHor, iPoxVer) within the current search range (preset search area) in a preset scanning order, each search point can find a matching reconstructed block of the current block in the reconstruction area, and the adjacent reconstructed pixels of the matching reconstructed block are the matching template.
[0457] Furthermore, in the embodiment of the present application, the matching cost between the adjacent template of the current block and the adjacent template of the reconstructed block is recorded as pDiff. If the pDiff of the current search point satisfies pDiff<=SAD thre , that is, the first matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then the matching template obtained by the search can be considered as a reconstructed template that meets the conditions, and then the search can be stopped, and its corresponding first matching cost pDiff is recorded as pDiff_BEST, its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST), and its corresponding matching template is recorded as the best matching template T_BEST.
[0458] It should be noted that in the embodiments of the present application, when performing search processing, the search strategies that can be adopted include but are not limited to search methods based on different search step sizes, for example, a coarse search based on a first search step size and / or a fine search based on a second search step size, wherein the first search step size is larger than the second search step size.
[0459] Furthermore, in an embodiment of the present application, the block vector and candidate template can be determined by traversing the search points in the preset search area according to a preset scan order and a first search step size. Alternatively, the block vector and candidate template can be determined by traversing the search points in the preset search area according to a preset scan order and a second search step size.
[0460] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed according to a preset scanning order and a first search step size to determine an initial block vector and an initial matching template corresponding to the initial block vector; then, a first search area can be determined based on the initial matching template; wherein the first search area is smaller than the preset search area; finally, the search points in the first search area can be traversed according to the preset scanning order and a second search step size to determine a block vector and a candidate template; wherein the first search step size is larger than the second search step size.
[0461] That is, in the embodiment of the present application, when searching for the best matching template in the search area, a search strategy of coarse search first and then fine search may be adopted, or only fine search may be performed, or only coarse search may be performed.
[0462] Exemplarily, in an embodiment of the present application, the coarse search may specifically include: determining the best coarse matching template in the search area with a first preset step size (i.e., a first search step size, such as 2 or 3, etc.), that is, obtaining the final candidate template, or using a downsampled template (e.g., a downsampling factor of 2 or 3, etc.) to determine the best coarse matching template in the search area, that is, obtaining the final candidate template.
[0463] Exemplarily, in an embodiment of the present application, the fine search may specifically include: determining the best fine matching template in the search area with a second preset step size (i.e., the second search step size, such as 1 or 1 / 2, etc.), that is, obtaining the final candidate template, or, after completing the coarse search, determining the best fine matching template near the best coarse matching template, that is, obtaining the final candidate template.
[0464] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed sequentially according to a preset scanning order and a first search step size, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion. If the first matching cost value and the first parameter meet the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0465] It can be understood that, in the embodiment of the application, satisfying the stop search condition may include that the first matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the first matching cost value is greater than the first parameter.
[0466] For example, in an embodiment of the present application, if the search strategy is to perform only a coarse search, then it is possible to select a region in which pX is between bvXMinsregionId and bvXMaxsregionId and pY is between bvYMinsregionId and bvYMaxsregionId, and perform a coarse search with a step size greater than 1 (e.g., a step size of 2 or 3). If the pDiff of the current search point satisfies pDiff<=SAD thre , that is, the first matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then the matching template obtained by the search can be considered as a reconstructed template that meets the conditions, and then the search can be stopped, and the matching cost pDiff obtained by template matching is recorded as pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST, and each item is a coordinate pair (pX_BEST, pY_BEST).
[0467] Furthermore, in an embodiment of the present application, the search points in the preset search area can be traversed sequentially according to a preset scanning order and a second search step size, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion. If the first matching cost value and the first parameter meet the stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0468] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the first matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the first matching cost value is greater than the first parameter.
[0469] For example, in an embodiment of the present application, if the search strategy is to perform only fine search, then it is possible to select a search range in each region where pX is between bvXMinsregionId and bvXMaxsregionId and pY is between bvYMinsregionId and bvYMaxsregionId, and perform fine search with a smaller step size (for example, a step size of 1 or 1 / 2, when the step size is less than 1, sub-pixel interpolation is required), and if the pDiff of the current search point satisfies pDiff<=SAD thre , that is, the first matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then the matching template obtained by the search can be considered as a reconstructed template that meets the conditions, and then the search can be stopped, and the matching cost pDiff obtained by template matching is recorded as pDiff_BEST, and its corresponding block vector BV is recorded as the best block vector BV_BEST, and each item is a coordinate pair (pX_BEST, pY_BEST).
[0470] Furthermore, in an embodiment of the present application, a search may be performed in a preset search area according to a preset scanning order and a first search step size, and a second matching cost value between a matching template corresponding to a search point in the preset search area and the first template is determined according to a preset matching criterion; if the second matching cost value and the first parameter satisfy a stop search condition, the search of the preset search area is terminated, and a block vector corresponding to the second matching cost value is determined as a reference block vector of the current block; a first search area is determined based on a matched reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; a search is performed in the first search area according to a preset scanning order and a second search step size, and a third matching cost value between a matching template corresponding to a search point in the first search area and the first template is determined according to a preset matching criterion; wherein the first search step size is greater than the second search step size; and if the third matching cost value and the first parameter satisfy the stop search condition, the search of the first search area is terminated, and the block vector corresponding to the third matching cost value is determined as the block vector of the current block.
[0471] It is understood that in the embodiments of the application, if the first parameter is a matching cost threshold corresponding to the matching cost value, then the first parameter can be understood as a cost upper threshold. Therefore, the corresponding stopping condition can be the relative magnitude between the matching cost value and the first parameter.
[0472] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the second matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the second matching cost value is greater than the first parameter.
[0473] Illustratively, in an embodiment of the present application, satisfying the stop search condition may include that the third matching cost value is less than or equal to the first parameter, and not satisfying the stop search condition may include that the third matching cost value is greater than the first parameter.
[0474] That is, in an embodiment of the present application, the conditions for stopping the search are met, including: the first matching cost value is less than or equal to the first parameter; and / or the second matching cost value is less than or equal to the first parameter; and / or the third matching cost value is less than or equal to the first parameter.
[0475] Exemplarily, in an embodiment of the present application, if the search strategy is to perform a coarse search first and then a fine search, a coarse search record template matching can be performed with a step size of 2 (i.e., the first search step size is 2) to obtain the best coarse matching template (initial matching template), and then the best fine matching template can be determined near the best coarse matching template with a step size of 1 (i.e., the second search step size is 1), thereby obtaining the final candidate template.
[0476] In the coarse search phase, it is possible to select a search range within each region where pX is between bvXMinsregionId and bvXMaxsregionId and pY is between bvYMinsregionId and bvYMaxsregionId, and perform a coarse search with a step size greater than 1. For example, if the coarse search is performed with a step size of 2, and the current search point pDiff satisfies pDiff <= SAD during the coarse search traversal, thre , that is, the second matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then it can be determined that the matching template obtained by the search is a reconstruction template that meets the conditions, then the search is stopped and the optimal matching cost obtained by template matching is recorded as pDiff1_BEST=pDiff refine , and its corresponding block vector BV is recorded as the best block vector BV1_BEST (pX1_BEST, pY1_BEST), that is, the reference block vector, and its corresponding matching template is the initial matching template. At this time, the search area where the best matching search point is located is bestRegionId.
[0477] Next, in the fine search stage, you can choose to search near the best block vector BV1_BEST (reference block vector) obtained in the coarse search, that is, search in the first search area. Therefore, you first need to determine the refined search range TmpRefineRange, that is, you need to determine the first search area TmpRefineRange. Among them, the refined search range (first search area TmpRefineRange) can be a fixed size or related to the current block size. For example, it can be set to min(nTbW, nTbH) / 2, and then calculate the position of the best matching reconstructed block obtained in the coarse search as the reference position of the fine search area: BestPosX=xTbCmp+pX1_BEST, BestPosY=yTbCmp+pY1_BEST.
[0478] In one embodiment, the calculated values of iVerMinbestRegionId, iVerMaxbestRegionId, iHorMinbestRegionId, and iHorMaxbestRegionId may be first obtained according to the value of bestRegionId, and then new search ranges iVerMinrefine, iVerMaxrefine, iHorMinrefine, and iHorMaxrefine may be obtained according to the optimal matching block position obtained by the coarse search. The obtaining method is as follows: iHorMinrefine = max(iHorMinbestRegionId, BestPosX - TmpRefineRange) iHorMaxrefine = min(iHorMaxbestRegionId, BestPosX + TmpRefineRange) iVerMinrefine = max(iVerMinbestRegionId, BestPosY - TmpRefineRange) iVerMaxrefine = min(iVerMaxbestRegionId, BestPosY + TmpRefineRange)
[0479] Then, the adjusted block vectors BVbvXMins, bvXMaxs, bvYMins, bvYMaxs can be calculated by iVerMinrefine, iVerMaxrefine, iHorMinrefine, iHorMaxrefine: bvXMins=iHorMinrefine-xTbCmp; bvXMaxs=iHorMaxrefine-xTbCmp; bvYMins=iVerMinrefine-yTbCmp; bvYMaxs=iVerMaxrefine-yTbCmp;
[0480] The fine search is performed within the block vector range where pX is between bvXMinsrefine and bvXMaxsrefine and pY is between bvYMinsrefine and bvYMaxsrefine. For example, if the search is performed with a step size of 1, and the current search point pDiff is refine Satisfy pDiff <= SAD thre , that is, the third matching cost between the matching template corresponding to the search point and the first template is less than or equal to the first parameter, then it can be determined that the matching template obtained by the search is a reconstruction template that meets the conditions, then the search is stopped and the best matching cost obtained by template matching is recorded as pDiff_BEST=pDiff refine, and its corresponding block vector BV is recorded as the best block vector BV_BEST (pX_BEST, pY_BEST), that is, the final block vector of the current block, and its corresponding matching template is the candidate template of the current block.
[0481] After completing the above operations, the optimal block vector BV_BEST (pX_BEST, pY_BEST) can be obtained, where pX_BEST and pY_BEST are the horizontal offset and vertical offset of the best matching template relative to the current coding block template, respectively, and are also the horizontal offset and vertical offset of the best matching reconstructed block relative to the current coding block.
[0482] It should be noted that in the embodiment of the present application, by combining the results of the coarse search and the fine search process (wherein the fine search process includes one or more reference point searches), one or more optimal block vectors BV_BEST for different algorithm requirements can be obtained, where BV_BEST is a coordinate pair (pX_BEST, pY_BEST).
[0483] It can be seen that in the embodiment of the present application, the process of searching and determining one or more block vectors in the search area may include three search strategies: only coarse search, only fine search, and coarse search first and then fine search.
[0484] Furthermore, in an embodiment of the present application, for at least one search area included in the preset search area, when searching within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block, a first search order corresponding to the at least one search area can be first determined based on the positional relationship between the current block and the at least one search area; and then, based on the first search order, the at least one search area is traversed in sequence, and a search is performed within the at least one search area based on the first parameter to determine the block vector of the current block.
[0485] It should be noted that in the embodiment of the present application, the first search order may be an order of distance from the current block from closest to farthest. This is because when searching multiple sub-search areas, searching in a near-to-far order can more quickly determine the block vector of the current block.
[0486] Exemplarily, in some embodiments, different search areas may also be defined in different ways. FIG13 is a schematic diagram of at least one search area. As shown in FIG13 , the areas closer to the current block may be defined as R1, R2, and R3, and the areas farthest away may be defined as R4, R5, and R6, and the search may be performed in the order of R1, R2, and R3, and then R4, R5, and R6.
[0487] That is, in the embodiment of the present application, the search order corresponding to different search areas may be determined according to the positional relationship between the search area and the current block.
[0488] It should be noted that, in the embodiments of the present application, the order of R1 and R2 can be swapped, and the order of R4 and R5 can be swapped.
[0489] Furthermore, in an embodiment of the present application, for at least one search area included in the preset search area, when searching within the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block, the at least one search area can be merged according to the positional relationship between the current block and the at least one search area to obtain at least one merged search area; then, based on the positional relationship between the current block and the at least one merged search area, a second search order corresponding to the at least one merged search area is determined; and based on the second search order, the at least one merged search area is traversed sequentially, and a search is performed within the at least one merged search area according to the first parameter to determine the block vector of the current block.
[0490] It should be noted that in the embodiment of the present application, the second search order may be an order of distance from the current block from closest to farthest. This is because when searching multiple sub-search areas, searching in a near-to-far order can more quickly determine the block vector of the current block.
[0491] For example, in some embodiments, as shown in FIG13 , R1 and R3 may be merged into one region; or R2 and R3 may be merged into one region; or R5 and R6 may be merged into one region; or R4 and R6 may be merged into one region, etc.
[0492] For example, in some embodiments, different search areas may be defined in different ways. FIG14 is a second schematic diagram of at least one search area. As shown in FIG14 , when searching for a predetermined reconstruction area within a preset search area, the search may be performed in the order of R1, R2, R3, R7, R8, and then R4, R5, and R6. The order of R1 and R2 may be swapped, the order of R7 and R8 may be swapped, and the order of R4 and R5 may be swapped.
[0493] Furthermore, in an embodiment of the present application, the preset scanning order includes any one of the following scanning orders: raster scanning order, longitudinal reverse raster scanning order, transverse reverse raster scanning order, full reverse raster scanning order, diagonal scanning order, horizontal scanning order, vertical scanning order, and Z-shaped scanning order.
[0494] That is to say, in an embodiment of the present application, when traversing the search points within a preset search area, a raster scanning order from top to bottom and from left to right may be adopted, or a longitudinal reverse raster scanning order from bottom to top and from left to right may be adopted, or a transverse reverse raster scanning order from top to bottom and from right to left may be adopted, or a full reverse raster scanning order from bottom to top and from right to left may be adopted, or a diagonal scanning, horizontal scanning, vertical scanning, Z-shaped scanning and other orders may be adopted.
[0495] Furthermore, in an embodiment of the present application, for at least one search area included in the preset search area, when traversing the at least one search area in sequence based on the first search order, for a current search area in the at least one search area, the search points in the current search area are traversed in sequence according to the preset scanning order corresponding to the current search area to determine the block vector of the current block.
[0496] That is, for each search area, the same scanning method and scanning order may be adopted, or different scanning methods or the same scanning method but different scanning orders may be adopted.
[0497] It should be noted that, in an embodiment of the present application, for a first area in at least one search area that is located above the current block, the longitudinal reverse raster scanning order is determined as the preset scanning order corresponding to the first area; for a second area in at least one search area that is located on the left side of the current block, the horizontal reverse raster scanning order is determined as the preset scanning order corresponding to the second area; and for a third area in at least one search area that is located on the upper left side of the current block, the full reverse raster scanning order is determined as the preset scanning order corresponding to the third area.
[0498] Exemplarily, in some embodiments, as shown in FIG14 , R1 and R5 may be searched in a longitudinal reverse raster scan order, R2 and R4 may be searched in a transverse reverse raster scan order, and R3 and R6 may be searched in a full reverse raster scan order.
[0499] It should be noted that, in an embodiment of the present application, for the fourth area in at least one search area, which is located on the upper side and / or upper right side of the current block, the longitudinal reverse raster scanning order is determined as the preset scanning order corresponding to the fourth area; for the fifth area in at least one search area, which is located on the left side and / or lower left side of the current block, the horizontal reverse raster scanning order is determined as the preset scanning order corresponding to the fifth area; for the third area in at least one search area, which is located on the upper left side of the current block, the full reverse raster scanning order is determined as the preset scanning order corresponding to the third area.
[0500] Exemplarily, in some embodiments, as shown in FIG14 , R1, R5, and R7 can be searched in a longitudinal reverse raster scan order, R2, R4, and R8 can be searched in a transverse reverse raster scan order, and R3 and R6 can be searched in a full reverse raster scan order.
[0501] Furthermore, in an embodiment of the present application, after determining the first parameter corresponding to the current block, the first parameter can be written into the bitstream and transmitted to the decoding end. The first parameter can be transmitted through any of the following syntax information: SPS layer syntax information, PPS layer syntax information, APS layer syntax information, SH layer syntax information, and CU layer syntax information.
[0502] That is, in the embodiment of the present application, the threshold condition (first parameter) of the early cutoff can be identified in the SPS, PPS, APS or SH layer to control the complexity of the decoding end.
[0503] Furthermore, in an embodiment of the present application, when searching within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block, the search points in the preset search area can also be traversed according to a preset search method, and a first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion; if the first matching cost value and the first parameter meet the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0504] It should be noted that, in the embodiment of the present application, the preset search method includes any one of the following search methods: a cross search method, a square search method, a diamond search method, and a hash search method.
[0505] That is, in the embodiments of the present application, you can choose to search in each area in a preset scanning order, such as a raster order, from top to bottom and left to right, or from bottom to top and right to left. You can also choose to perform a fast iterative search in a preset search area according to a preset search method, where the preset search method includes but is not limited to a cross search, a square search, a diamond search, etc. Alternatively, you can adopt a hash search method similar to IBC. This application does not specifically limit this.
[0506] Furthermore, in an embodiment of the present application, when performing search processing according to a preset search method, the search strategies that can be adopted include but are not limited to search methods based on different search steps, for example, a coarse search based on a third search step and / or a fine search based on a fourth search step, wherein the third search step is larger than the fourth search step.
[0507] Exemplarily, in some embodiments, it is possible to choose to traverse the search points in the preset search area according to a preset search method and a third search step, and determine the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template according to a preset matching criterion; or, it is possible to choose to traverse the search points in the preset search area according to a preset search method and a fourth search step, and determine the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; wherein the third search step is greater than the fourth search step.
[0508] Exemplarily, in some embodiments, a search may be performed in a preset search area according to a preset search method and a third search step size, and a second matching cost value between a matching template corresponding to a search point in the preset search area and the first template may be determined according to a preset matching criterion; if the second matching cost value and the first parameter satisfy a stop search condition, the search of the preset search area is terminated, and a block vector corresponding to the second matching cost value is determined as a reference block vector of the current block; a first search area is determined based on a matching reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; a search is performed in the first search area according to a preset search method and a fourth search step size, and finally, a third matching cost value between a matching template corresponding to a search point in the first search area and the first template may be determined according to the preset matching criterion; wherein the third search step size is greater than the fourth search step size; if the third matching cost value and the first parameter satisfy the stop search condition, the search of the first search area is terminated, and a block vector corresponding to the third matching cost value is determined as a block vector of the current block.
[0509] That is, in the embodiment of the present application, when searching for the best matching template in the search area according to the preset search method, a search strategy of coarse search first and then fine search may be adopted, or only fine search may be performed, or only coarse search may be performed.
[0510] Furthermore, in an embodiment of the present application, if a fast iterative search is performed according to a preset search method, in addition to using a first parameter to control the search process, a second parameter may also be used to control the search process.
[0511] It should be noted that, in the embodiment of the present application, the second parameter is used to limit the matching cost difference between different templates according to a preset matching criterion.
[0512] That is, in an embodiment of the present application, after determining a preset search area according to the first template, it is possible to select to search within the preset search area according to the first parameter and / or second parameter corresponding to the current block, thereby determining the block vector of the current block.
[0513] Furthermore, in an embodiment of the present application, when searching within a preset search area according to a second parameter corresponding to the current block, an iterative search can be first performed on the search points in the preset search area according to a preset search method, and the iterative cost difference between the matching template corresponding to the search point in the preset search area and the first template is determined according to a preset matching criterion; if the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the preset search area is terminated, and the block vector corresponding to the iterative cost difference is determined as the block vector of the current block; wherein the second parameter is used to limit the matching cost difference between different templates according to the preset matching criterion.
[0514] It should be noted that, in the embodiment of the present application, the second parameter can be used to control the search process. For example, based on the second parameter, you can choose to continue the fast iterative search process, or you can choose to end the fast iterative search process early.
[0515] For example, in an embodiment of the present application, the second parameter may be an iteration cost difference threshold corresponding to the iteration cost difference. Accordingly, when controlling the search process based on the second parameter, if the iteration cost difference and the second parameter (iteration cost difference) satisfy a stop search condition, the fast iterative search process may be terminated prematurely; otherwise, the fast iterative search process may continue.
[0516] It is understood that in the embodiment of the present application, if the second parameter is an iteration cost difference corresponding to the iteration cost difference, then the second parameter can be understood as a difference upper threshold. Therefore, the corresponding stopping search condition can be the magnitude relationship between the iteration cost difference and the second parameter.
[0517] Exemplarily, in an embodiment of the present application, if the iterative cost difference is less than or equal to the second parameter, then it can be considered that the stop search condition is met, and the fast iterative search process can be ended early; if the matching cost value is greater than the second parameter, then it can be considered that the stop search condition is not met, and the fast iterative search process can continue.
[0518] It can be seen that in an embodiment of the present application, when searching based on the second parameter, if the difference in iterative cost before and after the search is less than or equal to the search point of the second parameter, you can choose to end the fast iterative search, thereby achieving control over the search process.
[0519] That is to say, in the embodiments of the present application, in addition to the threshold value (and the first parameter) for the size of the cost itself, the cost difference before and after the iteration can also be taken as the cutoff threshold (i.e., the second parameter). If the cost difference before and after the iteration (iteration cost difference) is less than a certain threshold value (the second parameter), the iteration is stopped.
[0520] It should be noted that in the embodiments of the present application, during the search process, the first parameter and the second parameter can be used simultaneously to control the search process, or the first parameter or the second parameter can be selectively used to control the search process. That is, the iterative cost difference threshold (the second parameter) and the cost size threshold (the first parameter) can be used independently or in combination.
[0521] Furthermore, in an embodiment of the present application, an iterative search can be first performed in a first sub-area of a preset search area according to a preset search method, and the iterative cost difference between the matching template corresponding to the search point in the first sub-area and the first template is determined according to a preset matching criterion; if the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the first sub-area is terminated, and the current matching cost value between the matching template corresponding to the search point in the first sub-area and the first template is determined according to the preset matching criterion; if the current matching cost value and the first parameter meet the stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
[0522] Furthermore, in an embodiment of the present application, an iterative search can be first performed in the first sub-area of the preset search area according to a preset search method, and the iterative cost difference between the matching template corresponding to the search point in the first sub-area and the first template is determined according to a preset matching criterion; if the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the first sub-area is terminated, and the current matching cost value between the matching template corresponding to the search point in the first sub-area and the first template is determined according to the preset matching criterion; if the current matching cost value and the first parameter do not meet the stop search condition, the iterative search is continued in other sub-areas in the preset search area other than the first sub-area according to the preset search method.
[0523] Exemplarily, in some embodiments, for each sub-area in the preset search area, you can choose to perform a fast iterative search in each sub-area, and when the iterative cost difference (iterative cost difference value) is less than a certain threshold (second parameter), the iterative search process in the sub-area is stopped; if the current cost size (current matching cost value) is less than the cutoff threshold (second parameter), then you can choose to stop the entire search process of the preset search area, that is, end the search process in the preset search area in advance; otherwise, you can choose to continue the iterative search process in other sub-areas.
[0524] Furthermore, in an embodiment of the present application, after determining the first parameter corresponding to the current block, the first parameter can be written into the bitstream and transmitted to the decoding end. The second parameter can be transmitted via any one of the following syntax information: SPS layer syntax information, PPS layer syntax information, APS layer syntax information, SH layer syntax information, and CU layer syntax information.
[0525] That is, in the embodiment of the present application, the threshold condition (second parameter) of the early cutoff can be identified in the SPS, PPS, APS or SH layer to control the complexity of the decoding end.
[0526] Step 203: Determine the prediction value of the current block according to the block vector of the current block.
[0527] In an embodiment of the present application, after searching in a preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block, a prediction value of the current block may be further determined according to the block vector of the current block.
[0528] Furthermore, in an embodiment of the present application, when determining the prediction value of the current block based on the block vector of the current block, the reference block of the current block can be first determined based on the block vector of the current block; and then the prediction value of the current block can be determined based on the reference block of the current block.
[0529] For example, in the embodiment of the present application, when determining the reference block of the current block, a simple translation copy can be used to achieve it. The specific operation is: for x=0...nTbW-1, y=0...nTbH-1, through RefBlock n [x][y]=recSamples[x+pX n ][y+pY n ]Determine the reconstructed pixels recSamples of the current frame (i.e., the reference block of the current block).
[0530] It should be noted that, in an embodiment of the present application, when determining the reference block of the current block based on the block vector of the current block, the initial reconstructed block of the current block can be determined based on the block vector of the current block; and then the initial reconstructed block is corrected to determine the reference block of the current block.
[0531] That is to say, in the embodiments of the present application, other methods may be used to obtain candidate reconstructed blocks (reference blocks), for example, first correcting the initial reconstructed block corresponding to the obtained candidate template, and then determining the corresponding reference block.
[0532] It should be noted that, in the embodiment of the present application, the prediction value determined by the block vector of the current block can be used as the final prediction value, and can also be further processed to obtain the final prediction value of the current block.
[0533] Furthermore, in an embodiment of the present application, when determining the prediction value of the current block based on the block vector of the current block, at least one reference block corresponding to the current block can be first determined based on the block vector of the current block; and then the prediction value of the current block can be determined based on the at least one reference block.
[0534] It should be noted that, in an embodiment of the present application, when determining the prediction value of the current block based on at least one reference block, it is possible to first determine the prediction value of the current block based on at least one prediction block corresponding to the at least one reference block; then, weighted fusion is performed on the at least one prediction block to determine the prediction value of the current block.
[0535] Exemplarily, in some embodiments, after determining the block vector of the current block, multiple points may be taken around the block vector, i.e., multiple reference blocks may be obtained, and then the corresponding prediction values of the multiple points may be weightedly fused to obtain the prediction value of the current block.
[0536] Furthermore, in an embodiment of the present application, when determining the prediction value of the current block based on the block vector of the current block, a first prediction value of the current block can be first determined based on the block vector of the current block; then a second prediction value of the current block can be determined based on a preset prediction mode; wherein the preset prediction mode includes a planar mode and / or a directional mode; finally, the prediction value of the current block can be determined based on the first prediction value and the second prediction value.
[0537] For example, in some embodiments, after determining the block vector of the current block, a prediction value obtained using the block vector can be weighted and combined with prediction values obtained from other intra modes to obtain a final prediction value. Other intra modes can be prediction modes other than IntraTMP, such as Planar mode or Directional mode. The Directional mode can be derived from TIMD or located in the Intra candidate table using an index transmitted in the bitstream. This method can be referred to as the IntraTMP CIIP mode.
[0538] It can be understood that in the IntraTMP mode, in addition to the basic copying method to obtain the prediction value, there is also a method of obtaining the prediction value by filtering and fusing the corresponding positions of multiple BVs, as well as a method of fusion prediction with the ordinary Intra mode.
[0539] Furthermore, in an embodiment of the present application, after the prediction value of the current block is determined according to the block vector of the current block, the reconstructed value of the current block may be further determined according to the prediction value of the current block.
[0540] It should be noted that, in the embodiment of the present application, the prediction residual corresponding to the current block may be determined first; and then the reconstructed value of the current block may be further determined based on the prediction residual and the prediction value.
[0541] In summary, through the encoding method proposed in the above steps 201 to 203, the current image information (such as depth information) or the Diff information of the adjacent positions of the current block to be encoded (such as the matching cost value corresponding to the adjacent reconstructed block) can be effectively utilized to derive a first parameter for template matching. During the search process, if it is determined that the matching cost value corresponding to the search point meets the first parameter, the search process of the current coding block can be exited in advance, thereby reducing the IntraTMP search complexity to a certain extent.
[0542] It should be noted that in the embodiments of the present application, the first parameter determined by the current image information (such as depth information) can be a predefined fixed threshold, while the first parameter determined based on the adjacent reference blocks using the IntraTMP mode can be an adaptive threshold. Different first parameters can be set for different sub-search areas within the preset search area to control the search process.
[0543] For example, in some embodiments, a search scheme based on the reference template SAD matching cost can be proposed for the IntraTMP technology to exit early. This search scheme can use a reference template matching cost threshold (first parameter) to control the search process and can terminate the search early when the first parameter is met, thereby ensuring algorithm effectiveness while taking into account complexity.
[0544] Exemplarily, in some embodiments, a template matching cost threshold (first parameter) can be derived using the current image information or the Diff information of the adjacent positions of the current block to be encoded. When the threshold of the current search point does not exceed the threshold, the BV of the search point is recorded as the best block vector BV_BEST, and the search process is exited early.
[0545] The Intra TMP-BV function takes as input the position (xTbCmp, yTbCmp) of the current coding block (current block), its width nTbW, and its height nTbH. It also outputs the current block's BV and the corresponding prediction block's prediction value, predSamples[x][y], where x = 0..nTbW-1 and y = 0..nTbH-1. This prediction block's prediction value can be used as the final prediction value or further processed to obtain the final prediction value for the current block.
[0546] It is understood that the specific process for acquiring the intra TMP-BV proposed in this embodiment is divided into three steps: determining the current template type, acquiring the reconstructed pixels of the current template, and determining the block vector within a predefined search range. For each acquired BV, a set of predicted values for the current block can be obtained.
[0547] An embodiment of the present application provides a coding method, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, the encoder determines the first template corresponding to the current block, and determines a preset search area based on the first template; searches within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block; wherein the first parameter is used to control the search process; and determines the prediction value of the current block based on the block vector of the current block. It can be seen that in an embodiment of the present application, based on the IntraTMP mode, a predetermined first parameter, such as a matching cost threshold, can be used to control the search process, so that the search process can be terminated early or continued based on the first parameter. In other words, the coding and decoding method proposed in an embodiment of the present application can solve the problem of high computational complexity caused by traversing all search points in the search area by introducing the first parameter for controlling the search process, and can improve coding and decoding efficiency and performance.
[0548] In another embodiment of the present application, see FIG16 , which shows a schematic diagram of the structure of an encoder provided by an embodiment of the present application. As shown in FIG16 , the encoder 20 may include: a first determining unit 211, wherein:
[0549] The first determination unit 211 is configured to, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, determine a first template corresponding to the current block, and determine a preset search area based on the first template; search within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determine a prediction value of the current block based on the block vector of the current block.
[0550] 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.
[0551] 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.
[0552] Therefore, an embodiment of the present application provides a computer-readable storage medium, which is applied to the encoder 20. 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.
[0553] Based on the composition of the encoder 20 and the computer-readable storage medium, refer to Figure 17, which shows a specific hardware structure diagram of the encoder 20 provided in an embodiment of the present application. As shown in Figure 17, the encoder 20 may include: a first memory 221 and a first processor 222, a first communication interface 223 and a first bus system 224. The first memory 221, the first processor 222, and the first communication interface 223 are coupled together through the first bus system 224. It can be understood that the first bus system 224 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 224 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 224. Among them,
[0554] The first communication interface 223 is used to receive and send signals during the process of sending and receiving information between other external network elements;
[0555] The first memory 221 is used to store computer programs that can be run on the first processor;
[0556] The first processor 222, when running the computer program, determines a first template corresponding to the current block and determines a preset search area based on the first template when the prediction mode of the current block is an intra-frame template matching-based prediction mode; searches within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determines a prediction value of the current block based on the block vector of the current block.
[0557] It is understood that the first memory 221 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 221 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0558] The first processor 222 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 222. The above-mentioned first processor 222 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. 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 221 , and the first processor 222 reads the information in the first memory 221 and completes the steps of the above method in combination with its hardware.
[0559] 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 Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other electronic units for performing functions described in the present application or its combination.For software implementation, the technology described in the present application can be realized by the module (such as process, function etc.) that performs functions described in the present application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0560] Optionally, as another embodiment, the first processor 222 is further configured to execute the method described in any one of the aforementioned embodiments when running the computer program.
[0561] In another embodiment of the present application, see FIG18 , which shows a schematic diagram of the structure of a decoder provided by an embodiment of the present application. As shown in FIG18 , the decoder 30 may include: a second determining unit 311; wherein,
[0562] The second determination unit 311 is configured to, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, determine a first template corresponding to the current block, and determine a preset search area based on the first template; search within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determine a prediction value of the current block based on the block vector of the current block.
[0563] It is understood that in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular system. Furthermore, the various components in this embodiment can be integrated into a single processing unit, or each unit can exist physically separately, or two or more units can be integrated into a single unit. The aforementioned integrated units can be implemented in the form of hardware or software functional modules.
[0564] 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, this embodiment provides a computer-readable storage medium, which is applied to the decoder 30 and stores a computer program. When the computer program is executed by the second processor, it implements any of the methods in the aforementioned embodiments.
[0565] Based on the composition of the decoder 30 and the computer-readable storage medium, refer to Figure 19, which shows a specific hardware structure diagram of the decoder 30 provided in an embodiment of the present application. As shown in Figure 19, the decoder 30 may include: a second memory 321 and a second processor 322, a second communication interface 323 and a second bus system 324. The second memory 321 and the second processor 322, and the second communication interface 323 are coupled together through the second bus system 324. It can be understood that the second bus system 324 is used to realize the connection and communication between these components. In addition to the data bus, the second bus system 324 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 second bus system 324. Among them,
[0566] The second communication interface 323 is used to receive and send signals during the process of sending and receiving information between other external network elements;
[0567] The second memory 321 is used to store computer programs that can be run on the second processor;
[0568] The second processor 322 is configured to, when running the computer program, determine a first template corresponding to the current block and determine a preset search area based on the first template when the prediction mode of the current block is an intra-frame template matching-based prediction mode; search within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determine a prediction value of the current block based on the block vector of the current block.
[0569] Optionally, as another embodiment, the second processor 322 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.
[0570] It can be understood that the hardware functions of the second memory 321 and the first memory 221 are similar, and the hardware functions of the second processor 322 and the first processor 222 are similar; they will not be described in detail here.
[0571] The present embodiment provides a codec, when the prediction mode of the current block is an intra-frame template matching-based prediction mode, the codec determines a first template corresponding to the current block, and determines a preset search area based on the first template; searches within the preset search area based on a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determines a prediction value of the current block based on the block vector of the current block. It can be seen that in the embodiment of the present application, based on the IntraTMP mode, a predetermined first parameter, such as a matching cost threshold, can be used to control the search process, so that the search process can be terminated early or continued based on the first parameter. In other words, the coding and decoding method proposed in the embodiment of the present application can solve the problem of high computational complexity caused by traversing all search points in the search area by introducing a first parameter for controlling the search process, and can improve coding efficiency and performance.
[0572] In yet another embodiment of the present application, referring to FIG20 , a schematic diagram of the structure of a coding and decoding system provided by an embodiment of the present application is shown. As shown in FIG20 , the coding and decoding system 230 may include an encoder 2301 and a decoder 2302 .
[0573] In the embodiment of the present application, the encoder 2301 may be the encoder described in any one of the aforementioned embodiments, and the decoder 2302 may be the decoder described in any one of the aforementioned embodiments.
[0574] Furthermore, an embodiment of the present application also provides a code stream, wherein the code stream 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, a first parameter, a second parameter, a size of the template, and template type indication information.
[0575] It should be noted that, in this application, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0576] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0577] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0578] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0579] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0580] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims. Industrial Applicability
[0581] The embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder and a storage medium. When the prediction mode of the current block is an intra-frame template matching-based prediction mode, the codec determines the first template corresponding to the current block, and determines a preset search area based on the first template; searches within the preset search area based on the first parameter corresponding to the current block to determine the block vector of the current block; wherein the first parameter is used to control the search process; and determines the prediction value of the current block based on the block vector of the current block. It can be seen that in the embodiment of the present application, based on the IntraTMP mode, a predetermined first parameter, such as a matching cost threshold, can be used to control the search process, so that the search process can be terminated early or continued based on the first parameter. In other words, the coding and decoding method proposed in the embodiment of the present application can solve the problem of high computational complexity caused by traversing all search points in the search area by introducing the first parameter for controlling the search process, and can improve coding and decoding efficiency and performance.
Claims
1. A decoding method, applied to a decoder, the method comprising: When the prediction mode of the current block is an intra-frame prediction mode based on template matching, determining a first template corresponding to the current block, and determining a preset search area according to the first template; Searching in the preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; A prediction value of the current block is determined according to the block vector of the current block.
2. The method according to claim 1, wherein: The method further comprises: The first parameter is determined according to the bit depth information corresponding to the current image and the pixel parameter corresponding to the first template.
3. The method according to claim 1, wherein: The method further comprises: If the prediction mode of the adjacent reconstructed block corresponding to the current block is an intra-frame prediction mode based on template matching, the first parameter is determined according to the adjacent reconstructed block.
4. The method according to claim 3, wherein: The determining the first parameter according to the adjacent reconstructed blocks comprises: Determine a first threshold value according to a matching cost value corresponding to a block vector of the adjacent reconstructed block and a pixel parameter of a reference template corresponding to the adjacent reconstructed block; Determining a second threshold value according to a pixel parameter corresponding to the first template and a maximum average pixel value difference between the current block and the adjacent reconstructed block; The first parameter is determined based on the first threshold and the second threshold.
5. The method according to claim 4, wherein: The determining the first parameter based on the first threshold and the second threshold includes: If the first threshold is less than or equal to the second threshold, determining the first threshold as the first parameter; If the first threshold is greater than the second threshold, the second threshold is determined as the first parameter.
6. The method according to claim 5, wherein: The method further comprises: If the prediction mode of at least one adjacent reconstructed block corresponding to the current block is an intra-frame prediction mode based on template matching, determining the first threshold according to at least one matching cost value corresponding to the at least one adjacent reconstructed block, at least one pixel parameter corresponding to the at least one adjacent reconstructed block, and a pixel parameter corresponding to the first template; Determining a second threshold value according to a pixel parameter corresponding to the first template and a maximum average pixel value difference between the current block and the adjacent reconstructed block; The first parameter is determined based on the first threshold and the second threshold.
7. The method according to claim 3, wherein: The preset search area includes at least one search area; and the method further includes: At least one first parameter corresponding to the at least one search area is determined.
8. The method according to claim 7, wherein: The determining at least one first parameter corresponding to the at least one search area includes: If there is an adjacent reconstructed block corresponding to the current block in a current search area of the at least one search area, and a prediction mode of the adjacent reconstructed block is an intra-frame template matching-based prediction mode, the first parameter corresponding to the current search area is determined according to the adjacent reconstructed block.
9. The method according to claim 1, wherein: The first parameter is used to limit the matching cost between different templates according to a preset matching criterion; wherein the preset matching criterion includes any one of the absolute error and SAD, the transformed absolute error and SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean square error MSE, and the normalized correlation coefficient NCC.
10. The method according to claim 1, wherein: The first parameter is used to limit the matching cost between different templates according to a preset matching criterion; wherein the preset matching criterion includes a first matching criterion and a second matching criterion; The first matching criterion includes: any one of the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC; The second matching criterion includes: any one of a vector length of a block vector, a component length of a block vector, and a block vector cost parameter.
11. The method according to claim 9 or 10, wherein: The step of searching within the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block includes: The search points in the preset search area are traversed in sequence according to the preset scanning order, and the preset search points are determined according to the preset matching criteria. a first matching cost value between a matching template corresponding to a search point in a search area and the first template; If the first matching cost value and the first parameter satisfy the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
12. The method according to claim 11, wherein: The method further comprises: sequentially traverse the search points in the preset search area according to the preset scanning order and the first search step length, and determine the first matching cost between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; or The search points in the preset search area are traversed in sequence according to the preset scanning order and the second search step size, and the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to the preset matching criterion; wherein the first search step size is greater than the second search step size.
13. The method according to claim 11, wherein: The method further comprises: Searching in the preset search area according to the preset scanning order and the first search step length, and determining the second matching cost value between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the second matching cost value and the first parameter satisfy a stop search condition, ending the search for the preset search area, and determining the block vector corresponding to the second matching cost value as a reference block vector of the current block; Determine a first search area according to the matching reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; Searching in the first search area according to the preset scanning order and the second search step length, and determining the third matching cost value between the matching template corresponding to the search point in the first search area and the first template according to the preset matching criterion; wherein the first search step length is greater than the second search step length; If the third matching cost value and the first parameter satisfy the search stop condition, the search of the first search area is terminated, and the block vector corresponding to the third matching cost value is determined as the block vector of the current block.
14. The method according to claim 13, wherein: The stopping search condition is satisfied, including: The first matching cost value is less than or equal to the first parameter; and / or, The second matching cost value is less than or equal to the first parameter; and / or, The third matching cost value is less than or equal to the first parameter.
15. The method according to claim 14, wherein: The preset search area includes at least one search area; searching in the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block includes: Determining a first search order corresponding to the at least one search area according to a positional relationship between the current block and the at least one search area; The at least one search area is traversed in sequence based on the first search order, and a search is performed in the at least one search area according to the first parameter to determine a block vector of the current block.
16. The method according to claim 15, wherein: The preset scanning order includes any one of the following scanning orders: raster scanning order, longitudinal reverse raster scanning order, transverse reverse raster scanning order, full reverse raster scanning order, diagonal scanning order, horizontal scanning order, vertical scanning order, and Z-shaped scanning order.
17. The method according to claim 16, wherein: The method further comprises: When traversing the at least one search area in sequence based on the first search order, for a current search area in the at least one search area, traverse the search points in the current search area in sequence according to the preset scanning order corresponding to the current search area to determine the block vector of the current block.
18. The method according to claim 17, wherein: The method further comprises: For a first area located above the current block in the at least one search area, determining the longitudinal reverse raster scanning order as the preset scanning order corresponding to the first area; For a second area in the at least one search area and located on the left side of the current block, determining the horizontal reverse raster scanning order as the preset scanning order corresponding to the second area; For a third area in the at least one search area and located at the upper left side of the current block, the full reverse raster scanning order is determined as the preset scanning order corresponding to the third area.
19. The method according to claim 17, wherein: The method further comprises: For a fourth area in the at least one search area and located at the upper side and / or the upper right side of the current block, determining the longitudinal reverse raster scanning order as the preset scanning order corresponding to the fourth area; For a fifth area in the at least one search area and located on the left side and / or the lower left side of the current block, determining the horizontal reverse raster scanning order as the preset scanning order corresponding to the fifth area; For a third area in the at least one search area located at the upper left side of the current block, the full reverse raster scan sequence is determined The preset scanning order corresponding to the third area is determined.
20. The method according to claim 9 or 10, wherein: The step of searching within the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block includes: Traversing the search points in the preset search area according to a preset search method, and determining a first matching cost value between a matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the first matching cost value and the first parameter satisfy the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
21. The method according to claim 20, wherein: The method further comprises: Traversing the search points in the preset search area according to the preset search mode and the third search step length, and determining the first matching cost between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; or The search points in the preset search area are traversed according to the preset search method and the fourth search step, and the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to the preset matching criteria; wherein the third search step is greater than the fourth search step.
22. The method according to claim 20, wherein: The method further comprises: Searching in the preset search area according to the preset search mode and the third search step length, and determining the second matching cost between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the second matching cost value and the first parameter satisfy a stop search condition, ending the search for the preset search area, and determining the block vector corresponding to the second matching cost value as a reference block vector of the current block; Determine a first search area according to the matching reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; Searching in the first search area according to the preset search mode and the fourth search step length, and determining the third matching cost value between the matching template corresponding to the search point in the first search area and the first template according to the preset matching criterion; wherein the third search step length is greater than the fourth search step length; If the third matching cost value and the first parameter satisfy the search stop condition, the search of the first search area is terminated, and the block vector corresponding to the third matching cost value is determined as the block vector of the current block.
23. The method according to claim 20, wherein: The preset search method includes any one of the following search methods: a cross search method, a square search method, a diamond search method, and a hash search method.
24. The method according to claim 23, wherein: The method further comprises: Iteratively searching the search points in the preset search area according to the preset search method, and determining the iterative cost difference between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the preset search area is terminated, and the block vector corresponding to the iterative cost difference is determined as the block vector of the current block; wherein the second parameter is used to limit the matching cost difference between different templates according to the preset matching criteria.
25. The method according to claim 24, wherein: The method further comprises: Performing an iterative search in a first sub-region of the preset search region according to the preset search method, and determining an iterative cost difference between a matching template corresponding to a search point in the first sub-region and the first template according to the preset matching criterion; If the iterative cost difference and the second parameter satisfy the stop search condition, the iterative search of the first sub-region is terminated, and a current matching cost value between the matching template corresponding to the search point in the first sub-region and the first template is determined according to the preset matching criterion; If the current matching cost value and the first parameter satisfy the stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
26. The method according to claim 24, wherein: The method further comprises: If the current matching cost value and the first parameter do not satisfy the search stop condition, then the iterative search is continued in other sub-areas in the preset search area except the first sub-area according to the preset search method.
27. The method of claim 1, wherein: The method further comprises: Decode the code stream and determine the first parameter.
28. The method according to claim 27, wherein: The first parameter is transmitted through any one of the following grammatical information: sps layer grammatical information, pps layer grammatical information, aps layer grammatical information, sh layer grammatical information, and cu layer grammatical information.
29. The method of claim 24, wherein: The method further comprises: The code stream is decoded to determine the second parameter.
30. The method of claim 29, wherein: The second parameter is transmitted through any one of the following grammatical information: sps layer grammatical information, pps layer grammatical information, aps layer grammatical information, sh layer grammatical information, and cu layer grammatical information.
31. The method of claim 1, wherein: The determining the prediction value of the current block according to the block vector of the current block includes: Determine a reference block of the current block according to a block vector of the current block; A prediction value of the current block is determined according to a reference block of the current block.
32. The method according to claim 31, wherein: The determining a reference block of the current block according to the block vector of the current block comprises: Determine an initial reconstructed block of the current block according to the block vector of the current block; The initial reconstructed block is corrected to determine a reference block of the current block.
33. The method of claim 1, wherein: The determining the prediction value of the current block according to the block vector of the current block includes: Determine at least one reference block corresponding to the current block according to the block vector of the current block; A prediction value of the current block is determined according to the at least one reference block.
34. The method of claim 33, wherein: The determining, according to the at least one reference block, a prediction value of the current block comprises: at least one prediction block corresponding to the at least one reference block; The at least one prediction block is weightedly integrated to determine a prediction value of the current block.
35. The method of claim 1, wherein: The determining the prediction value of the current block according to the block vector of the current block includes: Determine a first prediction value of the current block according to the block vector of the current block; Determining a second prediction value of the current block according to a preset prediction mode; wherein the preset prediction mode includes a planar mode and / or a directional mode; A prediction value of the current block is determined according to the first prediction value and the second prediction value.
36. The method of claim 1, wherein: The determining the first template corresponding to the current block includes: A template type corresponding to the current block is determined, and a first template corresponding to the current block is determined according to the template type.
37. The method of claim 36, wherein: The determining of the template type corresponding to the current block includes: Determine the template type of the current block according to the reference pixels of the current block; or, Determine the template type of the current block according to indication information in the bitstream; or, Determining a template type of the current block according to the size of the current block; Among them, 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, the upper left adjacent reference pixels of the current block, the lower left adjacent reference pixels of the current block, and the upper right adjacent reference pixels of the current block.
38. The method of claim 37, wherein: The determining, according to the reference pixel of the current block, the template type of the current block comprises: If the left adjacent reference pixel of the current block, the upper adjacent reference pixel of the current block, and the upper left adjacent reference pixel of the current block are all available, determining that the template type of the current block is a first value; If the left adjacent reference pixel of the current block is available, determining the template type of the current block to be a second value; If the upper adjacent reference pixel of the current block is available, determining the template type of the current block to be a third value; If both the left adjacent reference pixel of the current block and the upper left adjacent reference pixel of the current block are available, determining that the template type of the current block is a fourth value; If both the left adjacent reference pixel of the current block and the lower left adjacent reference pixel of the current block are available, determining that the template type of the current block is a fifth value; If both the upper neighboring reference pixels of the current block and the upper right neighboring reference pixels of the current block are available, the template type of the current block is determined to be a sixth value.
39. The method of claim 1, wherein: The determining, according to the template type, a first template corresponding to the current block includes: Determining a template reference pixel of the current block according to the template type and a template size corresponding to the template type; A first template of the current block is determined according to the template reference pixels.
40. The method of claim 1, wherein: The method further comprises: Decoding the bitstream to determine a prediction difference corresponding to the current block; A reconstructed value of the current block is determined according to the prediction difference value and the prediction value of the current block.
41. A coding method, applied to an encoder, the method comprising: When the prediction mode of the current block is an intra-frame prediction mode based on template matching, determining a first template corresponding to the current block, and determining a preset search area according to the first template; Searching in the preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; A prediction value of the current block is determined according to the block vector of the current block.
42. The method according to claim 41, wherein: The method further comprises: The first parameter is determined according to the bit depth information corresponding to the current image and the pixel parameter corresponding to the first template.
43. The method of claim 41, wherein: The method further comprises: If the prediction mode of the adjacent reconstructed block corresponding to the current block is an intra-frame prediction mode based on template matching, the first parameter is determined according to the adjacent reconstructed block.
44. The method of claim 43, wherein: The determining the first parameter according to the adjacent reconstructed blocks comprises: Determine a first threshold value according to a matching cost value corresponding to a block vector of the adjacent reconstructed block and a pixel parameter of a reference template corresponding to the adjacent reconstructed block; Determining a second threshold value according to a pixel parameter corresponding to the first template and a maximum average pixel value difference between the current block and the adjacent reconstructed block; The first parameter is determined based on the first threshold and the second threshold.
45. The method of claim 44, wherein: The determining the first parameter based on the first threshold and the second threshold includes: If the first threshold is less than or equal to the second threshold, determining the first threshold as the first parameter; If the first threshold is greater than the second threshold, the second threshold is determined as the first parameter.
46. The method of claim 45, wherein: The method further comprises: If the prediction mode of at least one adjacent reconstructed block corresponding to the current block is an intra-frame prediction mode based on template matching, determining the first threshold according to at least one matching cost value corresponding to the at least one adjacent reconstructed block, at least one pixel parameter corresponding to the at least one adjacent reconstructed block, and a pixel parameter corresponding to the first template; Determining a second threshold value according to a pixel parameter corresponding to the first template and a maximum average pixel value difference between the current block and the adjacent reconstructed block; The first parameter is determined based on the first threshold and the second threshold.
47. The method of claim 43, wherein: The preset search area includes at least one search area; and the method further includes: At least one first parameter corresponding to the at least one search area is determined.
48. The method of claim 47, wherein: The determining at least one first parameter corresponding to the at least one search area includes: If there is an adjacent reconstructed block corresponding to the current block in a current search area of the at least one search area, and a prediction mode of the adjacent reconstructed block is an intra-frame template matching-based prediction mode, the first parameter corresponding to the current search area is determined according to the adjacent reconstructed block.
49. The method of claim 41, wherein: The first parameter is used to limit the matching cost between different templates according to a preset matching criterion; wherein the preset matching criterion includes any one of the absolute error and SAD, the transformed absolute error and SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean square error MSE, and the normalized correlation coefficient NCC.
50. The method of claim 41, wherein: The first parameter is used to limit the matching cost between different templates according to a preset matching criterion; wherein the preset matching criterion includes a first matching criterion and a second matching criterion; The first matching criterion includes: any one of the sum of absolute error SAD, the sum of transformed absolute error SATD, the sum of squared differences SSE, the mean absolute difference MAD, the mean absolute error MAE, the mean squared error MSE, and the normalized correlation coefficient NCC; The second matching criterion includes: any one of a vector length of a block vector, a component length of a block vector, and a block vector cost parameter.
51. The method of claim 49 or 50, wherein: The step of searching within the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block includes: The search points in the preset search area are traversed in sequence according to the preset scanning order, and the preset search points are determined according to the preset matching criteria. a first matching cost value between a matching template corresponding to a search point in a search area and the first template; If the first matching cost value and the first parameter satisfy the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
52. The method of claim 51, wherein: The method further comprises: sequentially traverse the search points in the preset search area according to the preset scanning order and the first search step length, and determine the first matching cost between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; or The search points in the preset search area are traversed in sequence according to the preset scanning order and the second search step size, and the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to the preset matching criterion; wherein the first search step size is greater than the second search step size.
53. The method of claim 51, wherein: The method further comprises: Searching in the preset search area according to the preset scanning order and the first search step length, and determining the second matching cost value between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the second matching cost value and the first parameter satisfy a stop search condition, ending the search for the preset search area, and determining the block vector corresponding to the second matching cost value as a reference block vector of the current block; Determine a first search area according to the matching reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; Searching in the first search area according to the preset scanning order and the second search step length, and determining the third matching cost value between the matching template corresponding to the search point in the first search area and the first template according to the preset matching criterion; wherein the first search step length is greater than the second search step length; If the third matching cost value and the first parameter satisfy the search stop condition, the search of the first search area is terminated, and the block vector corresponding to the third matching cost value is determined as the block vector of the current block.
54. The method of claim 53, wherein: The stopping search condition is satisfied, including: The first matching cost value is less than or equal to the first parameter; and / or, The second matching cost value is less than or equal to the first parameter; and / or, The third matching cost value is less than or equal to the first parameter.
55. The method of claim 54, wherein: The preset search area includes at least one search area; searching in the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block includes: Determining a first search order corresponding to the at least one search area according to a positional relationship between the current block and the at least one search area; The at least one search area is traversed in sequence based on the first search order, and a search is performed in the at least one search area according to the first parameter to determine a block vector of the current block.
56. The method of claim 55, wherein: The preset scanning order includes any one of the following scanning orders: raster scanning order, longitudinal reverse raster scanning order, transverse reverse raster scanning order, full reverse raster scanning order, diagonal scanning order, horizontal scanning order, vertical scanning order, and Z-shaped scanning order.
57. The method of claim 56, wherein: The method further comprises: When traversing the at least one search area in sequence based on the first search order, for a current search area in the at least one search area, traverse the search points in the current search area in sequence according to the preset scanning order corresponding to the current search area to determine the block vector of the current block.
58. The method of claim 57, wherein: The method further comprises: For a first area located above the current block in the at least one search area, determining the longitudinal reverse raster scanning order as the preset scanning order corresponding to the first area; For a second area in the at least one search area and located on the left side of the current block, determining the horizontal reverse raster scanning order as the preset scanning order corresponding to the second area; For a third area in the at least one search area and located at the upper left side of the current block, the full reverse raster scanning order is determined as the preset scanning order corresponding to the third area.
59. The method of claim 57, wherein: The method further comprises: For a fourth area in the at least one search area and located at the upper side and / or the upper right side of the current block, determining the longitudinal reverse raster scanning order as the preset scanning order corresponding to the fourth area; For a fifth area in the at least one search area and located on the left side and / or the lower left side of the current block, determining the horizontal reverse raster scanning order as the preset scanning order corresponding to the fifth area; For a third area in the at least one search area located at the upper left side of the current block, the full reverse raster scan sequence is determined The preset scanning order corresponding to the third area is determined.
60. The method of claim 49 or 50, wherein: The step of searching within the preset search area according to the first parameter corresponding to the current block to determine the block vector of the current block includes: Traversing the search points in the preset search area according to a preset search method, and determining a first matching cost value between a matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the first matching cost value and the first parameter satisfy the search stop condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
61. The method of claim 60, wherein: The method further comprises: Traversing the search points in the preset search area according to the preset search mode and the third search step length, and determining the first matching cost between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; or The search points in the preset search area are traversed according to the preset search method and the fourth search step, and the first matching cost value between the matching template corresponding to the search point in the preset search area and the first template is determined according to the preset matching criteria; wherein the third search step is greater than the fourth search step.
62. The method of claim 60, wherein: The method further comprises: Searching in the preset search area according to the preset search mode and the third search step length, and determining the second matching cost between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the second matching cost value and the first parameter satisfy a stop search condition, ending the search for the preset search area, and determining the block vector corresponding to the second matching cost value as a reference block vector of the current block; Determine a first search area according to the matching reconstructed block corresponding to the reference block vector; wherein the first search area is smaller than the preset search area; Searching in the first search area according to the preset search mode and the fourth search step length, and determining the third matching cost value between the matching template corresponding to the search point in the first search area and the first template according to the preset matching criterion; wherein the third search step length is greater than the fourth search step length; If the third matching cost value and the first parameter satisfy the search stop condition, the search of the first search area is terminated, and the block vector corresponding to the third matching cost value is determined as the block vector of the current block.
63. The method of claim 60, wherein: The preset search method includes any one of the following search methods: a cross search method, a square search method, a diamond search method, and a hash search method.
64. The method of claim 63, wherein: The method further comprises: Iteratively searching the search points in the preset search area according to the preset search method, and determining the iterative cost difference between the matching template corresponding to the search point in the preset search area and the first template according to the preset matching criterion; If the iterative cost difference and the second parameter meet the stop search condition, the iterative search of the preset search area is terminated, and the block vector corresponding to the iterative cost difference is determined as the block vector of the current block; wherein the second parameter is used to limit the matching cost difference between different templates according to the preset matching criteria.
65. The method of claim 64, wherein: The method further comprises: Performing an iterative search in a first sub-region of the preset search region according to the preset search method, and determining an iterative cost difference between a matching template corresponding to a search point in the first sub-region and the first template according to the preset matching criterion; If the iterative cost difference and the second parameter satisfy the stop search condition, the iterative search of the first sub-region is terminated, and a current matching cost value between the matching template corresponding to the search point in the first sub-region and the first template is determined according to the preset matching criterion; If the current matching cost value and the first parameter satisfy the stop search condition, the search of the preset search area is terminated, and the block vector corresponding to the first matching cost value is determined as the block vector of the current block.
66. The method of claim 64, wherein: The method further comprises: If the current matching cost value and the first parameter do not satisfy the search stop condition, then the iterative search is continued in other sub-areas in the preset search area except the first sub-area according to the preset search method.
67. The method of claim 41, wherein: The method further comprises: The first parameter is written into the bitstream.
68. The method of claim 67, wherein: The first parameter is transmitted through any one of the following grammatical information: sps layer grammatical information, pps layer grammatical information, aps layer grammatical information, sh layer grammatical information, and cu layer grammatical information.
69. The method of claim 64, wherein: The method further comprises: The second parameter is written into the bitstream.
70. The method of claim 69, wherein: The second parameter is transmitted through any one of the following grammatical information: sps layer grammatical information, pps layer grammatical information, aps layer grammatical information, sh layer grammatical information, and cu layer grammatical information.
71. The method of claim 41, wherein: The determining the prediction value of the current block according to the block vector of the current block includes: Determine a reference block of the current block according to a block vector of the current block; A prediction value of the current block is determined according to a reference block of the current block.
72. The method of claim 71, wherein: The determining a reference block of the current block according to the block vector of the current block comprises: Determine an initial reconstructed block of the current block according to the block vector of the current block; The initial reconstructed block is corrected to determine a reference block of the current block.
73. The method of claim 41, wherein: The determining the prediction value of the current block according to the block vector of the current block includes: Determine at least one reference block corresponding to the current block according to the block vector of the current block; A prediction value of the current block is determined according to the at least one reference block.
74. The method of claim 73, wherein: The determining, according to the at least one reference block, a prediction value of the current block comprises: at least one prediction block corresponding to the at least one reference block; The at least one prediction block is weightedly integrated to determine a prediction value of the current block.
75. The method of claim 41, wherein: The determining the prediction value of the current block according to the block vector of the current block includes: Determine a first prediction value of the current block according to the block vector of the current block; Determining a second prediction value of the current block according to a preset prediction mode; wherein the preset prediction mode includes a planar mode and / or a directional mode; A prediction value of the current block is determined according to the first prediction value and the second prediction value.
76. The method of claim 41, wherein: The determining the first template corresponding to the current block includes: A template type corresponding to the current block is determined, and a first template corresponding to the current block is determined according to the template type.
77. The method of claim 76, wherein: The determining of the template type corresponding to the current block includes: Determine the template type of the current block according to the reference pixels of the current block; or, Determine the template type of the current block according to indication information in the bitstream; or, Determining a template type of the current block according to the size of the current block; Among them, 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, the upper left adjacent reference pixels of the current block, the lower left adjacent reference pixels of the current block, and the upper right adjacent reference pixels of the current block.
78. The method of claim 77, wherein: The determining, according to the reference pixel of the current block, the template type of the current block comprises: If the left adjacent reference pixel of the current block, the upper adjacent reference pixel of the current block, and the upper left adjacent reference pixel of the current block are all available, determining that the template type of the current block is a first value; If the left adjacent reference pixel of the current block is available, determining the template type of the current block to be a second value; If the upper adjacent reference pixel of the current block is available, determining the template type of the current block to be a third value; If both the left adjacent reference pixel of the current block and the upper left adjacent reference pixel of the current block are available, determining that the template type of the current block is a fourth value; If both the left adjacent reference pixel of the current block and the lower left adjacent reference pixel of the current block are available, determining that the template type of the current block is a fifth value; If both the upper neighboring reference pixels of the current block and the upper right neighboring reference pixels of the current block are available, the template type of the current block is determined to be a sixth value.
79. The method of claim 41, wherein: The determining, according to the template type, a first template corresponding to the current block includes: Determining a template reference pixel of the current block according to the template type and a template size corresponding to the template type; A first template of the current block is determined according to the template reference pixels.
80. The method of claim 41, wherein: The method further comprises: Determine a prediction difference value corresponding to the current block, and write the prediction difference value into a bitstream; A reconstructed value of the current block is determined according to the prediction difference value and the prediction value of the current block.
81. 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 of the current block, the first parameter, the second parameter, the size of the template, and the template type indication information.
82. An encoder, comprising a first determining unit; wherein, The first determination unit is configured to determine a first template corresponding to the current block when the prediction mode of the current block is an intra-frame template matching-based prediction mode, and determine a preset search area according to the first template; Searching in the preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and determining a prediction value of the current block according to the block vector of the current block.
83. 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 configured to execute the method according to any one of claims 41 to 80 when running the computer program.
84. A decoder comprising a second determination unit; wherein: The second determination unit is configured to determine a first template corresponding to the current block when the prediction mode of the current block is an intra-frame template matching-based prediction mode, and determine a preset search area according to the first template; A search is performed in the preset search area according to a first parameter corresponding to the current block to determine a block vector of the current block; wherein the first parameter is used to control the search process; and a prediction value of the current block is determined according to the block vector of the current block.
85. 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 40 when running the computer program.
86. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 40 is implemented, or the method according to any one of claims 41 to 80 is implemented.