Method and device for video processing and medium

By introducing intra-block copy and merging mode, template matching mode and sample reordering mode in video processing, the encoding and decoding process of video blocks is optimized, and the problem of low encoding and decoding efficiency in the prior art is solved, and more efficient video encoding and decoding is achieved.

CN120380759APending Publication Date: 2025-07-25DOUYIN VISION CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380033445.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-04-11
Filing Date
2023-04-11
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

The encoding and decoding efficiency of existing video encoding and decoding technologies is generally low, and it is difficult to meet the needs of efficient video processing.

Method used

By using intra-block copy and merging mode, template matching mode and sample reordering mode in video processing, motion information and reference templates are updated, and the encoding and decoding process of video blocks is optimized.

Benefits of technology

Improve the efficiency and effectiveness of video encoding and decoding, and improve the performance of the encoding and decoding process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120380759A_ABST
    Figure CN120380759A_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a solution for video processing. A method for video processing is presented. The method includes determining motion information for a current video block of a video for a transition between the current video block and a bitstream of the video, the current video block being encoded and decoded using at least one of: an Intra Block Copy (IBC) merge mode, an IBC mode with template matching, or an Intra template matching mode; updating the motion information based on a constraint indicating a target value of a component of the motion information; and performing a conversion based on the updated motion information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure generally relate to video encoding and decoding technologies, and more particularly, to reference template determination. Background Art

[0002] Nowadays, digital video capabilities are being applied to all aspects of people's lives. A variety of video compression technologies, such as MPEG-2, MPEG-4, ITU-T H.263, ITU-T H.264 / MPEG-4 Part 10 Advanced Video Coding (AVC), ITU-T H.265 High Efficiency Video Coding (HEVC) standard, and Versatile Video Coding (VVC) standard have been proposed for video encoding / decoding. However, the encoding / decoding efficiency of conventional video encoding / decoding technologies is generally very low, which is undesirable. Summary of the Invention

[0003] Embodiments of the present disclosure provide a solution for video processing.

[0004] In a first aspect, a method for video processing is proposed. The method includes: determining motion information of a current video block for conversion between the current video block of a video and a bitstream of the video, where the current video block is encoded / decoded using at least one of: an Intra Block Copy (IBC) merge mode, an IBC mode with template matching, or an intra-template matching mode; updating the motion information based on a constraint, where the constraint indicates a target value of a component of the motion information; and performing the conversion based on the updated motion information. The method according to the first aspect of the present disclosure updates the motion information for the current video block encoded / decoded using IBC merge or IBC with template matching based on a constraint, and thus can improve the encoding / decoding efficiency and encoding / decoding effectiveness.

[0005] In a second aspect, another method for video processing is proposed. The method includes: determining a reference template of a current video block for conversion between the current video block of a video and a bitstream of the video based on encoding / decoding information of the current video block, where the current video block is encoded / decoded using a sample reordering mode; and performing the conversion based on the reference template. The method according to the second aspect of the present disclosure determines the reference template for the current video block encoded / decoded using the sample reordering mode, and thus can improve the encoding / decoding efficiency and encoding / decoding effectiveness.

[0006] In a third aspect, another method for video processing is provided. The method includes: determining a first set of a plurality of samples in a first template associated with a current video block for conversion between the current video block of a video and a bitstream of the video, where the current video block is encoded and decoded using a sample reordering pattern; reordering the first set of the plurality of samples; determining a cost by comparing the first set of the plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; and performing the conversion based on the cost. The method according to the third aspect of the present disclosure reorders the plurality of samples before determining the cost, and thus can improve the encoding and decoding efficiency and encoding and decoding effectiveness.

[0007] In a fourth aspect, another method for video processing is provided. The method includes: determining a sample reordering pattern for a current video block of a video for conversion between the current video block and a bitstream of the video based on at least one of the following: a syntax element in the bitstream, or a template cost of the current video block; and performing the conversion based on the sample reordering pattern. The method according to the fourth aspect of the present disclosure determines the sample reordering pattern for the current video block based on the syntax element or the template cost, and thus can improve the encoding and decoding efficiency and encoding and decoding effectiveness.

[0008] In a fifth aspect, a device for video processing is provided. The device includes a processor and a non-transitory memory having instructions thereon. The instructions, when executed by the processor, cause the processor to perform the method according to the first aspect, the second aspect, the third aspect, or the fourth aspect of the present disclosure.

[0009] In a sixth aspect, a non-transitory computer-readable storage medium is provided. The non-transitory computer-readable storage medium stores instructions that cause a processor to perform the method according to the first aspect, the second aspect, the third aspect, or the fourth aspect of the present disclosure.

[0010] In a seventh aspect, another non-transitory computer-readable recording medium is provided. The non-transitory computer-readable recording medium stores a bitstream of a video generated by a method executed by a video processing device. The method includes: determining motion information of a current video block of the video, where the current video block is encoded and decoded using at least one of the following: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint, where the constraint indicates a target value of a component of the motion information; and generating the bitstream based on the updated motion information.

[0011] In an eighth aspect, a method for storing a bitstream of a video is provided. The method includes: determining motion information of a current video block of the video, where the current video block is encoded and decoded using at least one of the following: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint, where the constraint indicates a target value of a component of the motion information; generating a bitstream based on the updated motion information; and storing the bitstream in a non-transitory computer-readable recording medium.

[0012] In a ninth aspect, another non-transitory computer-readable recording medium is provided. The non-transitory computer-readable recording medium stores a bitstream of a video generated by a method executed by a video processing device. The method includes: determining a reference template of a current video block of the video based on encoding and decoding information of the current video block, where the current video block is encoded and decoded using a sample reordering mode; and generating a bitstream based on the reference template.

[0013] In a tenth aspect, a method for storing a bitstream of a video is provided. The method includes: determining a reference template of a current video block of the video based on encoding and decoding information of the current video block, where the current video block is encoded and decoded using a sample reordering mode; generating a bitstream based on the reference template; and storing the bitstream in a non-transitory computer-readable recording medium.

[0014] In an eleventh aspect, another non-transitory computer-readable recording medium is provided. The non-transitory computer-readable recording medium stores a bitstream of a video generated by a method executed by a device for video processing. The method includes: determining a first set of a plurality of samples in a first template associated with a current video block of the video, where the current video block is encoded and decoded using a sample reordering mode; reordering the first set of a plurality of samples; determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; and generating a bitstream based on the cost.

[0015] In a twelfth aspect, a method for storing a bitstream of a video is provided. The method includes: determining a first set of a plurality of samples in a first template associated with a current video block of the video, where the current video block is encoded and decoded using a sample reordering mode; reordering the first set of a plurality of samples; determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; generating a bitstream based on the cost; and storing the bitstream in a non-transitory computer-readable recording medium.

[0016] In a thirteenth aspect, another non-transitory computer-readable recording medium is proposed. The non-transitory computer-readable recording medium stores a bitstream generated by a method executed by a video processing device. The method includes: determining a sample reordering pattern for a current video block of a video based on at least one of the following: a syntax element in the bitstream, or a template cost of the current video block; and generating the bitstream based on the sample reordering pattern.

[0017] In a fourteenth aspect, a method for storing a bitstream of a video is proposed. The method includes: determining a sample reordering pattern for a current video block of a video based on at least one of the following: a syntax element in the bitstream, or a template cost of the current video block; generating the bitstream based on the sample reordering pattern; and storing the bitstream in a non-transitory computer-readable recording medium.

[0018] This disclosure is provided to introduce a selection of concepts in a simplified form, which will be further described in the following detailed description. This disclosure is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The above and other objects, features, and advantages of the exemplary embodiments of the present disclosure will become more apparent from the following detailed description with reference to the accompanying drawings. In the exemplary embodiments of the present disclosure, the same reference numerals generally refer to the same components.

[0020] Figure 1 A block diagram of an exemplary video codec system according to some embodiments of the present disclosure is shown;

[0021] Figure 2 A block diagram of a first exemplary video encoder according to some embodiments of the present disclosure is shown;

[0022] Figure 3 A block diagram of an exemplary video decoder according to some embodiments of the present disclosure is shown;

[0023] Figures 4A to 4D The current CTU processing order and available samples in the current CTU and the left CTU are shown respectively;

[0024] Figure 5 The transform skip residual coding process is shown;

[0025] Figure 6 An example of a block encoded in palette mode is shown;

[0026] Figure 7 An example of sub-block-based index map scanning for a palette is shown, with horizontal scanning on the left and vertical scanning on the right;

[0027] Figure 8 shows an example decoding flowchart with ACT;

[0028] Figure 9 shows an example intra-frame template matching search area used;

[0029] Figures 10A - 10H show examples of template matching based on sample reordering respectively;

[0030] Figure 11 shows a flowchart of a method for video processing according to some embodiments of the present disclosure;

[0031] Figure 12 shows another flowchart of a method for video processing according to some embodiments of the present disclosure;

[0032] Figure 13 shows another flowchart of a method for video processing according to some embodiments of the present disclosure;

[0033] Figure 14 shows another flowchart of a method for video processing according to some embodiments of the present disclosure; and

[0034] Figure 15 shows a block diagram of a computing device in which various embodiments of the present disclosure can be implemented.

[0035] Throughout the drawings, the same or similar reference numerals generally refer to the same or similar elements. Detailed Description

[0036] The principles of the present disclosure will now be described with reference to some embodiments. It should be understood that the description of these embodiments is for illustrative purposes only and to assist those skilled in the art in understanding and implementing the present disclosure, and does not imply any limitation on the scope of the present disclosure. The disclosure described herein can be implemented in various ways other than those described below.

[0037] In the following description and claims, unless otherwise defined, all scientific and technical terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present disclosure pertains.

[0038] As used herein, the terms "one embodiment", "an embodiment", "an example embodiment", etc. indicate that the described embodiment may include a particular feature, structure, or characteristic, but not every embodiment necessarily includes the particular feature, structure, or characteristic. Moreover, these phrases do not necessarily refer to the same embodiment. Further, when a particular feature, structure, or characteristic is described in connection with an example embodiment, it is considered within the knowledge of those skilled in the art to affect such feature, structure, or characteristic in relation to other embodiments, whether or not explicitly described.

[0039] It should be understood that although terms such as "first" and "second" may be used to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another. For example, a first element may be referred to as a second element, and similarly, a second element may be referred to as a first element, without departing from the scope of the example embodiments. As used herein, the term "and / or" includes any and all combinations of one or more of the listed terms.

[0040] The terms used herein are for the purpose of describing particular embodiments only and are not intended to limit the example embodiments. As used herein, the singular forms "a", "an", and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "comprises", "comprising", and / or "having", when used herein, specify the presence of the stated features, elements, and / or components, etc., but do not preclude the presence or addition of one or more other features, elements, components, and / or combinations thereof. Example environment

[0041] Figure 1 is a block diagram showing an example video coding and decoding system 100 that can utilize the techniques of the present disclosure. As shown, the video coding and decoding system 100 may include a source device 110 and a destination device 120. The source device 110 may also be referred to as a video encoding device, and the destination device 120 may also be referred to as a video decoding device. In operation, the source device 110 may be configured to generate encoded video data, and the destination device 120 may be configured to decode the encoded video data generated by the source device 110. The source device 110 may include a video source 112, a video encoder 114, and an input / output (I / O) interface 116.

[0042] The video source 112 may include sources such as a video capture device. Examples of video capture devices include, but are not limited to, an interface for receiving video data from a video content provider, a computer graphics system for generating video data, and / or combinations thereof.

[0043] Video data can include one or more pictures. The video encoder 114 encodes the video data from the video source 112 to generate a bitstream. The bitstream can include a sequence of bits that form an encoded representation of the video data. The bitstream can include encoded pictures and associated data. The encoded pictures are the encoded representations of the pictures. The associated data can include sequence parameter sets, picture parameter sets, and other syntax structures. The I / O interface 116 can include a modulator / demodulator and / or a transmitter. The encoded video data can be directly transmitted to the destination device 120 via the I / O interface 116 over the network 130A. The encoded video data can also be stored on the storage medium / server 130B for access by the destination device 120.

[0044] The destination device 120 can include an I / O interface 126, a video decoder 124, and a display device 122. The I / O interface 126 can include a receiver and / or a modulator. The I / O interface 126 can obtain the encoded video data from the source device 110 or the storage medium / server 130B. The video decoder 124 can decode the encoded video data. The display device 122 can display the decoded video data to the user. The display device 122 can be integrated with the destination device 120 or can be external to the destination device 120, which is configured to interface with an external display device.

[0045] The video encoder 114 and the video decoder 124 can operate according to video compression standards, such as the High Efficiency Video Coding (HEVC) standard, the Versatile Video Coding (VVC) standard, and other existing and / or future standards.

[0046] Figure 2 is a block diagram showing an example of a video encoder 200 according to some embodiments of the present disclosure. The video encoder 200 can be Figure 1 an example of the video encoder 114 in the system 100 shown.

[0047] The video encoder 200 can be configured to implement any or all of the techniques of the present disclosure. In Figure 2 the example, the video encoder 200 includes multiple functional components. The techniques described in the present disclosure can be shared among the various components of the video encoder 200. In some examples, a processor can be configured to execute any or all of the techniques described in the present disclosure.

[0048] In some embodiments, the video encoder 200 may include a partitioning unit 201, a prediction unit 202, a residual generation unit 207, a transformation unit 208, a quantization unit 209, an inverse quantization unit 210, an inverse transformation unit 211, a reconstruction unit 212, a buffer 213, and an entropy encoding unit 214. The prediction unit 202 may include a mode selection unit 203, a motion estimation unit 204, a motion compensation unit 205, and an intra prediction unit 206.

[0049] In other examples, the video encoder 200 may include more, fewer, or different functional components. In one example, the prediction unit 202 may include an in-block copy (IBC) unit. The IBC unit may perform prediction in the IBC mode, where at least one reference picture is the picture in which the current video block is located.

[0050] Furthermore, although some components (such as the motion estimation unit 204 and the motion compensation unit 205) may be integrated, for explanatory purposes, these components are shown separately in the Figure 2 example.

[0051] The partitioning unit 201 may partition a picture into one or more video blocks. The video encoder 200 and the video decoder 300 may support various video block sizes.

[0052] The mode selection unit 203 may select, for example, one coding mode (intra coding or inter coding) from a plurality of coding modes based on an error result, and provide the resulting intra-coded or inter-coded block to the residual generation unit 207 to generate residual block data, and provide it to the reconstruction unit 212 to reconstruct the coded block for use as a reference picture. In some examples, the mode selection unit 203 may select a combination of intra and inter prediction (CIIP) modes, where the prediction is based on an inter prediction signal and an intra prediction signal. In the case of inter prediction, the mode selection unit 203 may also select a resolution for the motion vector for the block (e.g., sub-pixel accuracy or integer pixel accuracy).

[0053] To perform inter prediction on the current video block, the motion estimation unit 204 may generate motion information for the current video block by comparing one or more reference frames from the buffer 213 with the current video block. The motion compensation unit 205 may determine a predicted video block for the current video block based on the motion information and decoded samples of a picture from the buffer 213 other than the picture associated with the current video block.

[0054] The motion estimation unit 204 and the motion compensation unit 205 may perform different operations on a current video block, e.g., depending on whether the current video block is in an I slice, a P slice, or a B slice. As used herein, an "I slice" may refer to a portion of a picture composed of macroblocks, all of which are based on macroblocks within the same picture. Additionally, as used herein, in some aspects, a "P slice" and a "B slice" may refer to portions of a picture composed of macroblocks that are independent of macroblocks within the same picture.

[0055] In some examples, the motion estimation unit 204 may perform uni - directional prediction on the current video block, and the motion estimation unit 204 may search the reference pictures in list 0 or list 1 to find a reference video block for the current video block. The motion estimation unit 204 may then generate a reference index and a motion vector, where the reference index indicates the reference picture in list 0 or list 1 that contains the reference video block, and the motion vector indicates the spatial displacement between the current video block and the reference video block. The motion estimation unit 204 may output the reference index, the prediction direction indicator, and the motion vector as the motion information of the current video block. The motion compensation unit 205 may generate a predicted video block for the current video block based on the reference video block indicated by the motion information of the current video block.

[0056] Alternatively, in other examples, the motion estimation unit 204 may perform bi - directional prediction on the current video block. The motion estimation unit 204 may search the reference pictures in list 0 to find a reference video block for the current video block, and may also search the reference pictures in list 1 to find another reference video block for the current video block. The motion estimation unit 204 may then generate multiple reference indices and multiple motion vectors, where the multiple reference indices indicate the multiple reference pictures in list 0 and list 1 that contain the multiple reference video blocks, and the multiple motion vectors indicate the multiple spatial displacements between the multiple reference video blocks and the current video block. The motion estimation unit 204 may output the multiple reference indices and the multiple motion vectors of the current video block as the motion information of the current video block. The motion compensation unit 205 may generate a predicted video block for the current video block based on the multiple reference video blocks indicated by the motion information of the current video block.

[0057] In some examples, the motion estimation unit 204 may output a complete set of motion information for use in the decoder's decoding process. Alternatively, in some embodiments, the motion estimation unit 204 may signal the motion information of the current video block by referring to the motion information of another video block. For example, the motion estimation unit 204 may determine that the motion information of the current video block is similar enough to the motion information of a neighboring video block.

[0058] In one example, the motion estimation unit 204 may indicate a value in a syntax structure associated with the current video block to the video decoder 300, where the value indicates that the current video block has the same motion information as another video block.

[0059] In another example, the motion estimation unit 204 may identify another video block and a motion vector difference (MVD) in a syntax structure associated with the current video block. The motion vector difference indicates the difference between the motion vector of the current video block and the motion vector of the indicated video block. The video decoder 300 may use the motion vector of the indicated video block and the motion vector difference to determine the motion vector of the current video block.

[0060] As discussed above, the video encoder 200 may signal motion vectors in a predictive manner. Two examples of predictive signaling techniques that may be implemented by the video encoder 200 include advanced motion vector prediction (AMVP) and merge mode signaling.

[0061] The intra prediction unit 206 may perform intra prediction on the current video block. When the intra prediction unit 206 performs intra prediction on the current video block, the intra prediction unit 206 may generate prediction data for the current video block based on the decoded samples of other video blocks in the same picture. The prediction data for the current video block may include a predicted video block and various syntax elements.

[0062] The residual generation unit 207 may generate residual data for the current video block by subtracting (e.g., indicated by a minus sign) the (multiple) predicted video blocks of the current video block from the current video block. The residual data of the current video block may include residual video blocks corresponding to different sample portions of the samples in the current video block.

[0063] In other examples, such as in the skip mode, there may be no residual data for the current video block, and the residual generation unit 207 may not perform the subtraction operation.

[0064] The transform processing unit 208 may generate one or more transform coefficient video blocks for the current video block by applying one or more transforms to the residual video block associated with the current video block.

[0065] After the transform processing unit 208 generates the transform coefficient video block associated with the current video block, the quantization unit 209 may quantize the transform coefficient video block associated with the current video block based on one or more quantization parameter (QP) values associated with the current video block.

[0066] The inverse quantization unit 210 and the inverse transform unit 211 can apply inverse quantization and inverse transform to the transform coefficient video block respectively to reconstruct the residual video block from the transform coefficient video block. The reconstruction unit 212 can add the reconstructed residual video block to the corresponding samples of one or more predicted video blocks generated by the prediction unit 202 to generate a reconstructed video block associated with the current video block for storage in the buffer 213.

[0067] After the reconstruction unit 212 reconstructs the video block, a loop filtering operation can be performed to reduce the video block effect artifacts in the video block.

[0068] The entropy encoding unit 214 can receive data from other functional components of the video encoder 200. When the entropy encoding unit 214 receives data, the entropy encoding unit 214 can perform one or more entropy encoding operations to generate entropy encoded data and output a bitstream including the entropy encoded data.

[0069] Figure 3 is a block diagram showing an example of a video decoder 300 according to some embodiments of the present disclosure. The video decoder 300 can be Figure 1 an example of the video decoder 124 in the system 100 shown.

[0070] The video decoder 300 can be configured to perform any or all of the techniques of the present disclosure. In Figure 3 the example, the video decoder 300 includes a plurality of functional components. The techniques described in the present disclosure can be shared among the various components of the video decoder 300. In some examples, a processor can be configured to perform any or all of the techniques described in the present disclosure.

[0071] In Figure 3 the example, the video decoder 300 includes an entropy decoding unit 301, a motion compensation unit 302, an intra prediction unit 303, an inverse quantization unit 304, an inverse transform unit 305, and a reconstruction unit 306 and a buffer 307. In some examples, the video decoder 300 can perform a decoding process generally opposite to the encoding process described with respect to the video encoder 200.

[0072] The entropy decoding unit 301 may retrieve the encoded bitstream. The encoded bitstream may include entropy-encoded video data (e.g., encoded video data blocks). The entropy decoding unit 301 may decode the entropy-coded video data, and the motion compensation unit 302 may determine motion information from the entropy-decoded video data, the motion information including motion vectors, motion vector precision, reference picture list indices, and other motion information. The motion compensation unit 302 may determine this information, for example, by performing AMVP and merge mode. AMVP is used, including deriving several most likely candidates based on neighboring PB data and reference pictures. Motion information generally includes horizontal and vertical motion vector displacement values, one or two reference picture indices, and in the case of a prediction region in a B slice, also an indication of which reference picture list is associated with each index. As used herein, in some aspects, "merge mode" may refer to deriving motion information from spatially or temporally neighboring blocks.

[0073] The motion compensation unit 302 may generate a motion-compensated block, possibly performing interpolation based on an interpolation filter. An identifier for the interpolation filter used at sub-pixel precision may be included in the syntax element.

[0074] The motion compensation unit 302 may use the interpolation filter used by the video encoder 200 during the encoding of a video block to calculate interpolation values for sub-integer pixels of a reference block. The motion compensation unit 302 may determine the interpolation filter used by the video encoder 200 according to received syntax information, and the motion compensation unit 302 may use the interpolation filter to generate a prediction block.

[0075] The motion compensation unit 302 may use at least part of the syntax information to determine the size of the blocks for encoding the (multiple) frames and / or (multiple) slices of the encoded video sequence, the partitioning information describing how each macroblock of a picture of the encoded video sequence is partitioned, the mode indicating how each partition is encoded, one or more reference frames (and reference frame lists) for each inter-coded block, and other information for decoding the encoded video sequence. As used herein, in some aspects, a "slice" may refer to a data structure that can be decoded independently of other slices of the same picture in terms of entropy coding / decoding, signal prediction, and residual signal reconstruction. A slice may be the entire picture, or it may also be a region of the picture.

[0076] The intra prediction unit 303 may use, for example, the intra prediction mode received in the bitstream to form a prediction block from spatially adjacent blocks. The inverse quantization unit 304 inverse quantizes (i.e., dequantizes) the quantized video block coefficients provided in the bitstream and decoded by the entropy decoding unit 301. The inverse transform unit 305 applies an inverse transform.

[0077] The reconstruction unit 306 may obtain the decoded block, for example, by adding the residual block to the corresponding prediction block generated by the motion compensation unit 302 or the intra prediction unit 303. If necessary, a deblocking filter may also be applied to filter the decoded block to remove block effect artifacts. The decoded video block is then stored in the buffer 307, which provides reference blocks for subsequent motion compensation / intra prediction, and the buffer 307 also generates the decoded video for presentation on a display device.

[0078] Some example embodiments of the present disclosure will be described in detail below. It should be noted that the use of section headings in this document is for ease of understanding and does not limit the embodiments disclosed in the section. In addition, although some embodiments are described with reference to general video coding or other specific video codecs, the disclosed techniques are also applicable to other video coding techniques. In addition, although some embodiments describe the video coding steps in detail, it should be understood that the corresponding decoding steps for decoding are implemented by the decoder. In addition, the term video processing includes video coding or compression, video decoding or decompression, and video transcoding, in which video pixels are represented from one compression format to another or at different compression rates. 1 Brief Overview The present disclosure relates to video coding techniques. Specifically, it relates to prediction, signaling, and reordering in image / video coding. It can be applied to existing video coding standards such as HEVC, VVC, etc. It is also applicable to future video coding standards or video codecs. 2 Introduction Video coding standards have evolved mainly through the development of well-known ITU-T and ISO / IEC standards. ITU-T developed H.261 and H.263, ISO / IEC developed MPEG-1 and MPEG-4 Visual, and the two organizations jointly developed H.262 / MPEG-2 Video, H.264 / MPEG-4 Advanced Video Coding (AVC), and H.265 / HEVC standards. Since H.262, video coding standards have been based on a hybrid video coding structure, in which temporal prediction and transform coding are used. To explore future video coding techniques beyond HEVC, VCEG and MPEG jointly founded the Joint Video Exploration Team (JVET) in 2015. JVET meetings are held quarterly simultaneously, and the new video coding standard was officially named Versatile Video Coding (VVC) at the JVET meeting in April 2018, when the first version of the VVC Test Model (VTM) was released. The VVC working draft and the test model VTM are updated after each meeting. The VVC project achieved Final Draft International Standard (FDIS) at the meeting in July 2020. 2.1 Existing Screen Content Coding and Decoding Tools 2.1.1 Intra Block Copy (IBC) Intra Block Copy (IBC) is a tool adopted in the HEVC extension on SCC. As is well known, it significantly improves the coding and decoding efficiency of screen content materials. Since the IBC mode is implemented as a block-level coding mode, block matching (BM) is performed at the encoder to find the best block vector (or motion vector) for each CU. Here, the block vector is used to indicate the displacement from the current block to the reference block that has been reconstructed within the current picture. The luminance block vector of the IBC-encoded CU has integer precision. The chrominance block vector is also rounded to integer precision. When used in combination with AMVR, the IBC mode can switch between 1-pixel and 4-pixel motion vector precisions. The IBC-encoded CU is regarded as a third prediction mode in addition to the intra or inter prediction modes. The IBC mode is applicable to CUs with a width and height both less than or equal to 64 luminance samples. On the encoder side, hash-based motion estimation is performed on IBC. The encoder performs an RD check on blocks with a width or height not greater than 16 luminance samples. For non-merge modes, a block vector search is first performed using hash-based search. If the hash search does not return a valid candidate, a block-matching based local search will be performed. In the hash-based search, the hash key match (32-bit CRC) between the current block and the reference block is extended to all allowed block sizes. The hash key calculation for each position in the current picture is based on 4×4 sub-blocks. For a larger current block, it is determined that the hash key matches the hash key of the reference block when all hash keys of all 4×4 sub-blocks match the hash keys in the corresponding reference positions. If the hash keys of multiple reference blocks are found to match the hash key of the current block, the block vector cost of each matching reference is calculated, and the one with the minimum cost is selected. In the block-matching search, the search range is set to cover the previous CTU and the current CTU. At the CU level, the IBC mode is signaled by a flag and can be signaled as the IBC AMVP mode or the IBC skip / merge mode, as follows: – IBC skip / merge mode: The merge candidate index is used to indicate which block vector from the list of neighboring candidate IBC-encoded / decoded blocks is used to predict the current block. The merge list includes spatial candidates, HMVP candidates, and pairwise candidates. – IBC AMVP mode: The block vector difference is coded and decoded in the same way as the motion vector difference. The block vector prediction method uses two candidates as predictors, one from the left neighbor and one from the upper neighbor (if it is IBC-encoded). When either neighbor is not available, the default block vector is used as the predictor. A flag is signaled to indicate the block vector predictor index. 2.1.1.1 IBC Reference Regions To reduce memory consumption and decoder complexity, IBC in VVC only allows the reconstructed parts of predefined regions, which include the region of the current CTU and certain regions of the left neighboring CTU. Figures 4A to 4D Example diagrams 410, 430, 450, and 470 showing the reference regions for the IBC mode are presented, where each block represents a 64×64 luma sample unit respectively. Figures 4A to 4D The current CTU processing order and its available reference samples in the current and left neighboring CTUs are shown. Depending on the position of the current encoding / decoding CU position within the current CTU, the following applies: – If the current block falls within the upper left 64×64 block of the current CTU, in addition to the samples already reconstructed in the current CTU, the CPR mode can be used to reference the reference samples in the lower right 64x64 block of the left neighboring CTU. The current block can also use the CPR mode to reference the reference samples in the lower left 64×64 block and the upper right 64×64 block of the left neighboring CTU. – If the current block falls within the upper right 64×64 block of the current CTU, in addition to the samples already reconstructed in the current CTU, if the luma position (0, 64) relative to the current CTU has not been reconstructed, the current block can also use the CPR mode to reference the reference samples in the lower left 64×64 block and the lower right 64×64 block of the left neighboring CTU; otherwise, the current block can reference the reference samples in the lower right 64×64 block of the left neighboring CTU. – If the current block falls within the lower left 64×64 block of the current CTU, in addition to the samples already reconstructed in the current CTU, if the luma position (64, 0) relative to the current CTU has not been reconstructed, the current block can also use the CPR mode to reference the reference samples in the upper right 64×64 block and the lower right 64×64 block of the left neighboring CTU. Otherwise, the current block can use the CPR mode to reference the reference samples in the lower right 64×64 block of the left neighboring CTU. – If the current block falls within the lower right 64×64 block of the current CTU, only the CPR mode can be used to reference the samples already reconstructed in the current CTU. This limitation allows the use of local on-chip memory for hardware implementation to implement the IBC mode. 2.1.1.2 Interaction between IBC and Other Coding Tools The interaction between the IBC mode and other inter-frame coding / decoding tools in VVC is as follows, such as paired merge candidates, history-based motion vector predictor (HMVP), intra / inter prediction mode combination (CIIP), merge mode with motion vector difference (MMVD), and geometric partitioning model (GPM): – IBC can be used together with paired merge candidates and HMVP. New paired IBC merge candidates can be generated by averaging two IBC merge candidates. For HMVP, IBC motion is inserted into the history buffer for future reference. – IBC cannot be combined with the following inter-frame tools: affine motion, CIIP, MMVD, and GPM. – When using DUAL_TREE partitioning, IBC is not allowed for chrominance coding blocks. Different from the HEVC screen content coding extension, the current picture is no longer included as a reference picture in reference picture list 0 for IBC prediction. The motion vector derivation process of the IBC mode excludes all neighboring blocks in the inter-frame mode and vice versa. The following IBC design aspects are applied: – IBC shares the same process with regular MV merge, including paired merge candidates and history-based motion predictors, but TMVP and zero vectors are not allowed as they are not valid for the IBC mode. – Separate HMVP buffers (5 candidates each) are used for regular MVs and IBCs. – Block vector constraints are implemented in the form of bitstream consistency constraints. The encoder needs to ensure that there are no invalid vectors in the bitstream and that merging should not be used if the merge candidate is invalid (out of range or 0). This bitstream consistency constraint is represented by a virtual buffer as described below. – For deblocking, IBC is treated as an inter-frame mode. – If the current block is coded using the IBC prediction mode, AMVR does not use quarter pixels; instead, a signal is transmitted to indicate that AMVR only indicates whether the MV is an inter-frame pixel or a 4-integer pixel. – The number of IBC merge candidates can be signaled in the slice header, separately from the number of regular, sub-block, and geometric merge candidates. The virtual buffer concept is used to describe the admissible reference regions for the IBC prediction mode and the valid block vectors. Denote the CTU size as ctbSize. The width of the virtual buffer ibcBuf is wIbcBuf = 128×128 / ctbSize, and the height hIbcBuf = ctbSize. For example, for a CTU size of 128×128, the size of ibcBuf is also 128×128; for a CTU of size 64×64, the size of ibcBuf is 256×64; for a CTU size of 32×32, the size of ibcBuf is 512×32. The size of each dimension of the VPDU is min(ctbSize, 64), and W v = min(ctbSize, 64). The virtual IBC buffer ibcBuf is maintained as follows. – At the start of decoding each CTU row, the entire ibcBuf is flushed with invalid value -1. – When starting to decode the VPDU (xVPDU, yVPDU) relative to the top - left corner of the picture, set ibcBuf[x][y] = -1, where x = xVPDU % wIbcBuf,..., xVPDU % wIbcBuf + Wv - 1; y = yVPDU % ctbSize,..., yVPDU % ctbSize + Wv - 1. – After decoding, the CU contains (x, y) relative to the top - left corner of the picture, set ibcBuf[x % wIbcBuf][y % ctbSize] = recSample[x][y] For a block covering the coordinates (x, y), it is valid if the following holds for the block vector bv = (bv[0], bv[1]); otherwise, it is invalid: ibcBuf[(x + bv[0]) % wIbcBuf][(y + bv[1]) % ctbSize] should not be equal to -1. 2.1.2 Block - Differential Pulse - Code - Modulation (BDPCM) VVC supports Block - Differential Pulse - Code - Modulation (BDPCM) for picture content coding and decoding. At the sequence level, the BDPCM enable flag is signaled in the SPS; this flag is signaled only when the transform skip mode (described in the next section) is enabled in the SPS. When BDPCM is enabled, if the CU size is less than or equal to MaxTsSize×MaxTsSize in terms of luminance samples and if the CU is intra-coded, a flag is sent at the CU level, where MaxTsSize is the maximum block size allowing the transform skip mode. This flag indicates whether to use regular intra-coding or BDPCM. If BDPCM is used, a BDPCM prediction direction flag is sent to indicate whether the prediction is horizontal or vertical. Then, a regular horizontal or vertical intra-prediction process with unfiltered reference samples is used to predict the block. The residuals are quantized, and the difference between each quantized residual and its predicted value, i.e., the previously decoded residual at the horizontal or vertical (depending on the BDPCM prediction direction) neighboring position, is coded. For a block of size M (height)×N (width), let r i,j , 0≤i≤M - 1, 0≤j≤N - 1 be the prediction residuals. Let Q(r i,j ), 0≤i≤M - 1, 0≤j≤N - 1 denote the quantized version of the residual r i,j . BDPCM is applied to the quantized residual values, resulting in a modified M×N array with elements where is predicted according to its neighboring quantized residual values. For the vertical BDPCM prediction mode, for 0≤j≤(N - 1), the following is used to derive For the horizontal BDPCM prediction mode, for 0≤j≤(N - 1), the following is used to derive On the decoder side, the above process is reversed to compute Q(r i,j ), 0≤i≤M - 1, 0≤j≤N - 1, as follows: If vertical BDPCM is used (2 - 3) If horizontal BDPCM is used (2 - 4) The inverse-quantized residuals Q -1 (Q(r i,j )) are added to the intra-block prediction values to produce the reconstructed sample values. The predicted quantized residual values are coded using the same residual coding process as in the transform skip mode residual coding Sent to the decoder. For lossless coding / decoding, if slice_ts_residual_coding_disabled_flag is set to 1, the quantized residual values are sent to the decoder using the regular transform residual coding described in 2.2.2. In terms of the MPM mode used for future intra mode coding / decoding, if the BDPCM prediction directions are horizontal or vertical respectively, the horizontal or vertical prediction modes are stored respectively for the CUs coded with BDPCM. For deblocking, if two blocks on both sides of a block boundary are coded with BDPCM, then the specific block boundary is not deblocked. 2.1.3 Residual Coding for Transform Skip Mode VVC allows the transform skip mode for luma blocks of size up to MaxTsSize × MaxTsSize, where the value of MaxTsSize is signaled in the PPS and can be at most 32. When a CU is coded in the transform skip mode, its prediction residual is quantized and coded using the transform skip residual coding process. This process is modified from the transform coefficient coding process described in 2.2.2. In the transform skip mode, the residual of the TU is also coded in non - overlapping sub - blocks of size 4×4. For better coding efficiency, some modifications are made to customize the residual coding process for the residual signal characteristics. The differences between transform skip residual coding and regular transform residual coding are summarized as follows: – The forward scan order is applied to scan the sub - blocks within the transform block and also the positions within the sub - blocks; – There is no signaling of the last (x,y) position; – When all previous flags are equal to 0, coded_sub_block_flag is coded for each sub - block except the last one; – The sig_coeff_flag context modeling uses a simplified template, and the context model of sig_coeff_flag depends on the top and left neighboring values; – The context model of abs_level_gt1 flag also depends on the left sig_coeff_flag value and the upper sig_coeff_flag value; – Only one context model of par_level_flag is used; – Additional flags more than 3, 5, 7, 9 are signaled to indicate the coefficient levels, and one context is used for one flag; – The Rice parameter with a fixed order = 1 is used for the binning of the residue values; – A context model for determining a sign flag based on left and above neighboring values, and parsing the sign flag after sig_coeff_flag to keep all context - decoded binary bits (bins) together. For each sub - block, if coded_subblock_flag equals 1 (i.e., there is at least one non - zero quantized residual in the sub - block), then decoding at the quantized residual level is performed in three scan passes (see Figure 5 ): – First scan pass: Decode the significance flag (sig_coeff_flag), sign flag (coeff_sign_flag), absolute level greater than 1 flag (abs_level_gtx_flag[0]), and parity flag (par_level_flag). For a given scan position, if sig_coeff_flag equals 1, then coeff_sign_flag is decoded, followed by abs_level_gtx_flag[0] (which specifies whether the absolute level is greater than 1). If abs_level_gtx_flag[0] equals 1, then par_level_flag is additionally decoded to specify the parity of the absolute level. – Scan passes greater than x: For each scan position with an absolute level greater than 1, for i = 1 ··· 4, up to four abs_level_gtx_flag[i] are decoded to indicate whether the absolute level at the given position is greater than 3, 5, 7, or 9, respectively. – Remainder scan pass: The remainder of the absolute level abs_remainder is decoded in bypass mode. The remainder of the absolute level is binary - ized using a fixed Rice parameter value of 1. The bits in scan passes #1 and #2 (the first scan pass and scan passes greater than x) are context - decoded until the maximum number of context - decoded bits in the TU is exhausted. The maximum number of context - decoded bits in the residual block is limited to 1.75×block_width×block_height, or equivalently, 1.75 context - decoded bits per sample position. The bits in the last scan pass (the remaining scan passes) are bypass - decoded. The variable RemCbs is first set to the maximum number of context - decoded bits of the block and is decremented by 1 whenever a context - decoded bit is decoded. When RemCcbs is greater than or equal to 4, the context - decoded bits are used to decode the syntax elements including sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag in the first decoding pass. If RemCcbs becomes less than 4 during the decoding of the first pass, then the remaining coefficients not decoded in the first pass are decoded in the residual scan pass (pass #3). After the first - pass decoding is completed, if RemCcbs is greater than or equal to 4, the context - decoded bits are used to decode the syntax elements including abs_level_gt3_flag, abs_level_gt5_flag, abs_level_gt7_flag, and abs_level_gt9_flag in the second decoding pass. If RemCcbs becomes less than 4 during the decoding of the second pass, then the remaining coefficients not decoded in the second pass are decoded in the residual scan pass (pass #3). Figure 5 The transform - skip residual decoding process is shown. The star marks the position when the context - decoded bits are exhausted, at which point bypass - decoding is used for all remaining bits. In addition, for blocks not decoded in the BDPCM mode, a level - mapping mechanism is applied to the transform - skip residual decoding until the maximum number of context - decoded bits has been reached. The level mapping uses the top and left - hand neighboring coefficient levels to predict the current coefficient level in order to reduce the signaling cost. For a given residual position, let absCoeff represent the absolute coefficient level before mapping and absCoeffMod represent the coefficient level after mapping. Let X0 represent the absolute coefficient level of the left - hand neighboring position and let X1 represent the absolute coefficient level of the upper neighboring position. The level mapping is performed as follows: pred = max(X0,X1); if(absCoeff == pred) absCoeffMod = 1; else absCoeffMod = (absCoeff < pred)? absCoeff + 1 : absCoeff; Then, the absCoeffMod value is encoded and decoded as described above. After all the context-encoded bits have been exhausted, the level mapping is disabled for all the remaining scan positions in the current block. 2.1.4 Palette Mode In VVC, the palette mode is used for picture content encoding and decoding in all chroma formats supported in the 4:4:4 profile (i.e., 4:4:4, 4:2:0, 4:2:2, and monochrome). When the palette mode is enabled, if the CU size is less than or equal to 64×64, then a flag is sent at the CU level, and the number of samples in the CU is greater than 16 to indicate whether the palette mode is used. Considering that applying the palette mode on small CUs introduces insignificant encoding and decoding gains and brings additional complexity on small blocks, the palette mode is disabled for CUs with less than or equal to 16 samples. The encoded and decoded coding unit (CU) by the palette is regarded as a prediction mode different from the intra prediction, inter prediction, and intra block copy (IBC) modes. If the palette mode is utilized, then the sample values in the CU are represented by a set of representative color values. This set is called a palette. For positions with sample values close to the palette colors, the palette index is signaled. Samples outside the palette can also be specified by signaling an escape symbol. For samples within the CU encoded with the escape symbol, their component values are signaled directly using the (possibly) quantized component values. This is shown in Figure 6 which is shown in. Figure 6 An example diagram 600 of a block encoded in the palette mode is shown. The quantized escape symbol is binary-coded using a fifth-order exponential Golomb binary process (EG5). For the encoding and decoding of the palette, the palette predictor is maintained. For non-wavefront cases, the palette predictor is initialized to 0 at the start of each slice. For WPP cases, the palette predictor at the start of each CTU row is initialized to the predictor derived from the first CTU in the previous CTU row, such that the initialization scheme between the palette predictor and CABAC synchronization is unified. For each entry in the palette predictor, the reuse flag is signaled to indicate whether it is part of the current palette in the CU. The run-length encoding with zeros is used to send the reuse flag. Thereafter, the number of new palette entries and the component values of the new palette entries are signaled. After encoding the CU that decodes the palette, the palette predictor is updated using the current palette, and the entries from the previous palette predictor that are not reused in the current palette are added at the end of the new palette predictor until the maximum allowed size is reached. The escape flag is signaled for each CU to indicate whether there is an escape symbol in the current CU. If there is an escape symbol, the palette table is augmented by one, and the last index is assigned to the escape symbol. In a manner similar to the coefficient groups (CGs) used in transform coefficient encoding, the CUs encoded with the palette mode are partitioned into multiple line-based coefficient groups, each coefficient group consisting of m samples (i.e., m = 16), where the index run of the escape mode, the palette index value, and the quantized colors are encoded / parsed sequentially for each CG. As in HEVC, a horizontal or vertical traversal scan can be applied to scan the samples, as Figure 7 shown. Figure 7 FIG. 700 shows a schematic diagram of a sub-block-based index map scan for the palette, with the left side for horizontal scan and the right side for vertical scan. The encoding and decoding order for palette run encoding and decoding in each slice is as follows: For each sample position, a context - encoded single - bit run_copy_flag = 0 is signaled to indicate whether the pixel has the same pattern as the previous sample position, i.e., whether the previously scanned sample and the current sample are both of run type COPY_ABOVE, or whether the previously scanned sample and the current sample are both of run type INDEX and the same index value. Otherwise, run_copy_flag = 1 is signaled. If the current sample has a different pattern from the previous sample, then a context - encoded single - bit copy_above_palette_indices_flag is signaled to indicate the run type of the current sample, i.e., INDEX or COPY_ABOVE. Here, if the sample is in the first row (horizontal traversal scan) or the first column (vertical traversal scan), the decoder does not have to parse the run type because the INDEX mode is used by default. In the same way, if the previously parsed run type is COPY_ABOVE, the decoder does not have to parse the run type. After the palette run encoding and decoding of the samples in one encoding and decoding pass, the index values (for INDEX mode) and the quantized escape colors are grouped and encoded using CABAC bypass encoding in another encoding and decoding pass. This separation of context - encoded bits and bypass - encoded bits can improve the throughput within each line of the CG. For a slice with a dual - luma / chroma tree, the palette is applied separately to the luma (Y component) and chroma (Cb and Cr components), where the luma palette entries contain only Y values, and the chroma palette entries contain both Cb and Cr values. For a slice with a single tree, the palette is applied jointly over the Y, Cb, Cr components, i.e., each entry in the palette contains Y, Cb, Cr values unless when using local dual - tree encoding / decoding of CUs, in which case the encoding and decoding of luma and chroma are handled separately. In this case, if the palette mode is used to encode or decode the corresponding luma block or chroma block, their palettes are applied in a way similar to the dual - tree case (this is related to non - 4:4:4 coding and will be further explained in 2.1.4.1). For a slice encoded / decoded with a dual - tree, the maximum palette predictor size is 63, and the maximum palette table size for the encoding / decoding of the current CU is 31. For a slice encoded / decoded with a dual - tree, the maximum predictor and palette table sizes are halved, i.e., for each of the luma palette and chroma palette, the maximum predictor size is 31 and the maximum table size is 15. For de - blocking, the palette - encoded blocks on the sides of the block boundary are not de - blocked. 2.1.4.1 Palette Mode for Non - 4:4:4 Content The palette mode in VVC is supported for all chroma formats in a similar way to the palette mode in HEVC SCC. For non-4:4:4 content, the following customizations are applied: 1. When signaling the escape value for a given sample position, if the sample position has only a luma component but no chroma component due to chroma subsampling, then only the luma escape value is signaled. This is the same as in HEVC SCC. 2. For local dual-tree blocks, the palette mode is applied to the block in the same way as the palette mode applied to single-tree blocks with two exceptions: a. The process of palette predictor update is slightly modified as follows. Since the local dual-tree block contains only luma (or chroma) components, the predictor update process uses the values signaled for the luma (or chroma) components and fills in the "missing" chroma (or luma) components by setting them to the default value (1<<(component bit depth - 1)). b. The maximum palette predictor size remains 63 (since single-tree is used to encode / decode the strip), but the maximum palette table size for luma / chroma blocks remains 15 (since separate palettes are used to encode / decode the blocks). 3. For the palette mode in monochrome format, the number of color components in the palette-encoded block is set to 1 instead of 3. 2.1.4.2 Encoder Algorithm for Palette Mode On the encoder side, the following steps are used to generate the palette table for the current CU. 1. First, to derive the initial entries in the palette table for the current CU, a simplified K-means clustering is applied. Initialize the palette table for the current CU as an empty table. For each sample position in the CU, calculate the SAD between this sample and each palette table entry, and obtain the minimum SAD among all palette table entries. If the minimum SAD is less than a predefined error limit errorLimit, then the current sample and the palette table entry with the minimum SAD are clustered together. Otherwise, a new palette table entry is created. The threshold errorLimit is QP-dependent and is retrieved from a lookup table containing 57 elements covering the entire QP range. After all samples in the current CU have been processed, the initial palette entries are sorted according to the number of samples clustered with each palette entry, and any entries after the 31st entry are discarded. 2. In the second step, the initial palette table colors are adjusted by considering two options: using the centroid of each cluster from step 1 or using one of the palette colors in the palette predictor. The option with the lower rate-distortion cost is selected as the final color of the palette table. If a cluster has only a single sample and the corresponding palette entry is not in the palette predictor, then the corresponding sample is converted to an escape symbol in the next step. 3. The resulting palette table contains some new entries from the centroids of the clusters in step 1, as well as some entries from the palette predictor. Therefore, the table is re-ordered again so that all new entries (i.e., the centroids) are placed at the start of the table, followed by the entries from the palette predictor. Given the palette table of the current CU, the encoder selects the palette index for each sample position in the CU. For each sample position, the encoder checks the RD cost for all index values corresponding to the palette table entries, as well as the index representing the escape symbol, and selects the index with the minimum RD cost using the following equation: RD cost = distortion × (isChroma? 0.8 : 1) + lambda × bypass codedbits (2-5) After determining the index map of the current CU, each entry in the palette table is checked to see if it is used by at least one sample position in the CU. Any unused palette entries are removed. After determining the index map of the current CU, by comparing the RD costs of three options: the same as the previously scanned position, run type COPY_ABOVE or run type INDEX, grid RD optimization is applied to find the best values of run_copy_flag and the run type for each sample position. When calculating the SAD value, the sample values are scaled down to 8 bits, unless the CU is encoded and decoded in lossless mode, in which case the actual input bit depth is used to calculate the SAD. Additionally, in the case of lossless encoding and decoding, only the rate is used in the above rate-distortion optimization step (since lossless encoding and decoding does not cause distortion). 2.1.5 Adaptive Color Transformation In the HEVC SCC extension, Adaptive Color Transformation (ACT) is applied to reduce the redundancy between the three color components in the 444 chroma format. ACT is also adopted in the VVC standard to enhance the coding efficiency of 444 chroma format coding and decoding. Similar to HEVC SCC, ACT performs in-loop color space transformation in the prediction residual domain by adaptively transforming the residual from the input color space to the YCgCo space. Figure 8FIG. 800 shows a decoding flow chart of applying ACT. Two color spaces are adaptively selected by signaling an ACT flag at the CU level. When the flag equals 1, the residual of the CU is coded / decoded in the YCgCo space; otherwise, the residual of the CU is coded / decoded in the original color space. Additionally, the same as the HEVC ACT design, for inter and IBc CUs, ACT is enabled only when there is at least one non-zero coefficient in the CU. When the chrominance component selects the same intra prediction mode as the luminance component (i.e., DM mode), ACT is enabled only. 2.1.5.1 ACT Mode In the HEVC SCC extension, ACT supports both lossless coding / decoding and lossy coding / decoding based on a lossless flag (i.e., cu_transquant_bypass_flag). However, there is no flag in the bitstream indicating whether to apply lossy or lossless coding / decoding. Therefore, the YCgCo-R transform is applied as ACT to support both lossy and lossless cases. The YCgCo-R reversible color transform is shown as follows. Since the YCgCo-R transform is not normalized. To compensate for the dynamic range change of the residual signal before and after the color transform, QP adjustments of (-5, 1, 3) are applied to the transform residuals of the Y, Cg, and Co components respectively. The adjusted quantization parameter only affects the quantization and inverse quantization of the residuals in the CU. For other coding / decoding processes (e.g., deblocking), the original QP is still applied. Additionally, because the forward and reverse color transforms need to access the residuals of all three components, the ACT mode is always disabled for split tree partitioning and ISP modes where the prediction block sizes of different color components are different. When ACT is applied, the transform skip (TS) extended to the coded chrominance residuals and the block differential pulse coded modulation (BDPCM) are also enabled. 2.1.5.2 ACT Fast Coding Algorithm To avoid brute-force R-D search in both the original color space and the transformed color space, the following fast coding algorithm is applied in the VTM reference software to reduce the encoder complexity when ACT is enabled. – The order of the RD check for enabling / disabling ACT depends on the original color space of the input video. For RGB videos, the RD cost of the ACT mode is checked first; for YCbCr videos, the RD cost of the non-ACT mode is checked first. The RD cost of the second color space is checked only if there is at least one non-zero coefficient in the first color space. – When a CU is obtained through different partitioning paths, reuse the same ACT enable / disable decision. Specifically, when encoding / decoding a CU for the first time, the selected color space used for encoding / decoding the residuals of a CU is stored. Then, when the same CU is obtained by another partitioning path, the stored color space decision is directly reused without checking the RD cost of the two spaces. – The RD cost of the parent CU is used to decide whether to check the RD cost of the second color space of the current CU. For example, if for the parent CU, the RD cost of the first color space is less than the RD cost of the second color space, then for the current CU, the second color space is not checked. To reduce the number of tested encoding / decoding modes, share the selected encoding / decoding modes between the two color spaces. Specifically, for intra modes, the preselected intra mode candidates based on SATD-based intra mode selection are shared between the two color spaces. For inter and IBC modes, perform the block vector search or motion estimation only once. The block vectors and motion vectors are shared by the two color spaces. 2.1.6 Intra Template Matching Intra Template Matching Prediction (Intra TMP) is a special intra prediction mode that copies the best prediction block from the reconstructed part of the current frame, and its L-shaped template matches the current template. For a predefined search range, the encoder searches in the reconstructed part of the current frame for the template that is most similar to the current template and uses the corresponding block as the prediction block. The encoder then signals the use of this mode, and the same prediction operation is performed on the decoder side. Figure 9 Fig. 900 shows a schematic diagram illustrating the intra template matching region used. By matching the L-shaped causal neighborhood of the current block with Figure 9 another block in the predefined search region in R1: the current CTU, R2: the top-left CTU, R3: above the CTU, R4: the left CTU. SAD is used as the cost function. Within each region, the decoder searches for the template with the minimum SAD relative to the current region and uses its corresponding block as the prediction block. The sizes of all regions (Search Range_w, SearchRange_h) are proportional to the block sizes (BlkW, BlkH) with a fixed number of SADs per pixel. That is: SearchRange_w = a * BlkW, SearchRange_h = a * BlkH. Where 'a' is a constant that controls the gain / complexity trade-off. In fact, 'a' is equal to 5. Enable the intra-template matching tool in terms of width and height for CUs with a size less than or equal to 64. The maximum CU size for intra-template matching is configurable. When DIMD is not used for the current CU, signal the intra-template matching prediction mode at the CU level via a dedicated flag. 2.2 Adaptive Motion Vector Resolution (AMVR) In HEVC, when the use_integer_mv_flag in the slice header is equal to 0, the motion vector difference (MVD) (between the motion vector of the CU and the predicted motion vector) is signaled in units of quarter luminance samples. In VVC, a CU-level Adaptive Motion Vector Resolution (AMVR) scheme is introduced. AMVR allows the MVD of a CU to be decoded with different precisions. Depending on the mode for the current CU (normal AMVP mode or affine AVMP mode), the MVD of the current CU can be adaptively selected as follows: – Normal AMVP mode: quarter-luminance-sample, half-luminance-sample, integer-luminance-sample, or quadruple-luminance-sample. – Affine AMVP mode: quarter-luminance-sample, integer-luminance-sample, or 1 / 16 luminance-sample. If the current CU has at least one non-zero MVD component, the CU-level MVD resolution indication is conditionally signaled. If all MVD components (i.e., both the horizontal and vertical MVDs for reference list L0 and reference list L1) are zero, a quarter-luminance-sample MVD resolution is inferred. For a CU having at least one non-zero MVD component, a first flag is signaled to indicate whether quarter-luma-sample MVD precision is used for the CU. If the first flag is 0, no further signaling is required and quarter-luma-sample MVD precision is used for the current CU. Otherwise, a second flag is signaled to indicate whether half-luma-sample or other MVD precision (integer or quarter-luma sample) is used for normal AMVP CUs. In the case of half-luma-sample, a 6-tap interpolation filter instead of the default 8-tap interpolation filter is used for the half-luma sample position. Otherwise, a third flag is signaled to indicate whether integer-luma-sample MVD precision or quarter-luma-sample MVD precision is used for normal AMVP CUs. In the case of affine AMVP CUs, the second flag is used to indicate whether integer-luma-sample MVD precision or 1 / 16 luma-sample MVD precision is used. To ensure that the reconstructed MVs have the expected precision (quarter-luma-sample, half-luma-sample, integer-luma-sample or quarter-luma-sample), the motion vector predictor for the CU is rounded to the same precision as the precision of the MVD before adding the MVD. The motion vector predictor rounds towards zero (i.e., a negative motion vector predictor rounds towards positive infinity and a positive motion vector predictor rounds towards negative infinity). The encoder uses RD checking to determine the motion vector resolution for the current CU. To avoid always performing four CU-level RD checks for each MVD resolution, in VTM11, the RD check for MVD precision other than quarter-luma-sample is only conditionally invoked. For the normal AVMP mode, first the RD costs for quarter-luma-sample MVD precision and integer-luma-sample MV precision are calculated. Then, the RD cost for integer-luma-sample MVD precision is compared with the RD cost for quarter-luma-sample MVD precision to decide whether to further check the RD cost for four-luma-sample MVD precision. When the RD cost for quarter-luma-sample MVD precision is much smaller than that for integer-luma-sample MVD precision, the RD check for four-luma-sample MVD precision is skipped. Then, if the RD cost for integer-luma-sample MVD precision is significantly greater than the best RD cost of the previously tested MVD precision, the check for half-luma-sample MVD precision is skipped. For the affine AMVP mode, if the affine inter mode is not selected after checking the rate-distortion costs of the affine merge / skip mode, merge / skip mode, quarter-luma-sample MVD precision normal AMVP mode, and quarter-luma-sample MVD precision affine AMVP mode, the 1 / 16 luma-sample MV precision and 1-pixel MV precision affine inter modes are not checked. In addition, the affine parameters obtained in the quarter-luma-sample MV precision affine inter mode are used as the starting search points for the 1 / 16 luma-sample and quarter-luma-sample MV precision affine inter modes. In VVC, if a block is encoded or decoded using the IBC AMVP mode and AMVR is enabled, the IBC AMVP supports two MV precisions of 1 pixel and 4 pixels. The AMVR precision index is signaled only when L0-MVDx or L0-MVDy is not equal to zero. 2.3 Related Solutions 2.3.1 Reordering of Reconstructed Samples The following detailed solutions should be considered as examples to explain the general concepts. These solutions should not be interpreted in a narrow way. In addition, these solutions can be combined in any way. In the following disclosure, a block may refer to a coding block (CB), coding unit (CU), prediction block (PB), prediction unit (PU), transform block (TB), transform unit (TU), sub-block, sub-CU, codec tree unit (CTU), codec tree block (CTB), or codec group (CG). In the following disclosure, a region may refer to any video unit, such as a picture, a stripe, or a block. A region may also refer to a non-rectangular region, such as a triangle. In the following disclosure, W and H represent the width and height of the mentioned rectangular region. 1. It is proposed that samples in a region can be reordered. a. The reordering of samples can be defined as follows: Assume that the sample at position (x, y) in the region before reordering is represented as S(x, y), and the sample at position (x, y) in the region after reordering is represented as R(x, y). It is required that R(x, y) = S(f(x, y), g(x, y)), where (f(x, y), g(x, y)) is a position in the region, and f and g are two functions. i. For example, it is required that there exists at least one position (x, y) such that (f(x, y), g(x, y)) is not equal to (x, y). b. The samples in the region to be reordered can be i. The original samples before encoding. ii. Predicted samples. iii. Reconstructed samples. iv. Transformed samples (transformation coefficients). v. Samples before inverse transformation (coefficients before inverse transformation). vi. Samples before deblocking filtering. vii. Samples after deblocking filtering. viii. Samples before SAO processing. ix. Samples after SAO processing. x. Samples before ALF processing. xi. Samples after ALF processing. xii. Samples before post-processing. xiii. Samples after post-processing. c. In one example, reordering can be applied in more than one stage. i. For example, at least two of the samples listed in item 1.b above can be reordered. 1) For example, different reordering methods can be applied to these two types of samples. 2) For example, the same reordering method can be applied to these two types of samples. d. In one example, the reordering can be a horizontal flip. For example, f(x, y) = P - x, g(x, y) = y. For example, P = W - 1. e. In one example, the reordering can be a vertical flip. For example, f(x,y) = x, g(x,y) = Q - y. For example, Q = H - 1. f. In one example, the reordering can be a horizontal and vertical flip. For example, f(x,y) = P - x, g(x,y) = Q - y. For example, P = W - 1 and Q = H - 1. g. In one example, the reordering can be a shift. For example, f(x,y) = (P + x) % W, g(x,y) = (Q + y) % H, where P and Q are integers. h. In one example, the reordering can be a rotation. i. In one example, there is at least one (x,y) such that (x,y) is equal to (f(x,y), g(x,y)). j. In one example, whether and / or how to reorder the samples can be signaled from the encoder to the decoder, e.g., in the SPS / Sequence Header / PPS / Picture Header / APS / Strip Header / Slice / Tile / CTU Row / CTU / CU / PU / TU. i. For example, a first flag is signaled to indicate whether reordering is applied. 1) For example, the first flag can be coded / decoded using context coding. ii. For example, a second syntax element (e.g., a flag) is signaled to indicate which reordering method (e.g., horizontal flip or vertical flip) is used. 1) For example, the second syntax element is signaled only if reordering is indicated to be applied. 2) For example, context coding can be used to code / decode the second syntax element. 2. It is proposed that whether and / or how to reorder the samples can depend on the coding / decoding information. a. In one example, whether and / or how to reorder the samples can be derived depending on the coding / decoding information at the picture level / strip level / CTU level / CU level / PU level / TU level. b. In one example, the coding / decoding information can include: i. The size of the region. ii. The coding / decoding mode of the region (e.g., inter, intra, or IBC). iii. Motion information (such as motion vectors and reference indices). iv. The intra prediction mode (e.g., angular intra prediction mode, planar, or DC). v. Inter - frame prediction modes (such as affine prediction, bidirectional prediction / uni - directional prediction, merge mode, combined inter - intra prediction (CIIP), merge with motion vector difference (MMVD), temporal motion vector prediction (TMVP), sub - TMVP). vi. Quantization parameter (QP). vii. Coding tree partition information such as coding tree depth. viii. Color format and / or color component. 3. It is proposed that at least one parsing or decoding process other than the re - ordering process can depend on whether and / or how the samples are re - ordered. a. For example, syntax elements can be signaled conditionally based on whether re - ordering is applied. b. For example, different scan orders can be used based on whether and / or how the samples are re - ordered. c. For example, de - blocking filtering / SAO / ALF can be used based on whether and / or how the samples are re - ordered. 4. In one example, samples can be processed by at least one auxiliary procedure before or after the resampling process. Some possible auxiliary procedures can include: (combinations are allowed) a. For example, at least one sample can be added by an offset. b. For example, at least one sample can be multiplied by a factor. c. For example, at least one sample can be cropped. d. For example, at least one sample can be filtered. e. For example, at least one sample X can be modified to T(X), where T is a function. 5. In one example, for blocks coded in IBC mode. a. For example, a first flag is signaled to indicate whether reconstructed samples should be re - ordered. i. For example, the first flag can be coded using context - based coding. b. For example, a second flag is signaled to indicate whether the reconstructed samples should be horizontally or vertically flipped. i. For example, the second flag is signaled only when the first flag is true. ii. For example, the second flag can be coded using context - based coding. 2.3.2 Regarding Sample Re - ordering - Application Conditions and Interaction with Other Processes The following detailed solutions should be considered as examples to illustrate general concepts. These solutions should not be interpreted in a narrow sense. Additionally, these solutions can be combined in any way. The term "video unit" or "codec unit" may represent a picture, slice, tile, coding tree block (CTB), coding tree unit (CTU), coding block (CB), CU, PU, TU, PB, TB. The term "block" may represent a coding tree block (CTB), coding tree unit (CTU), coding block (CB), CU, PU, TU, PB, TB. Note that the terms mentioned below are not limited to the specific terms defined in the existing standards. Any changes to the coding tools are also applicable. 1. Regarding the application conditions of sample reordering (e.g., the first and related issues), the following methods are proposed: a. Whether the reordering process is applied to the reconstructed / original / predicted block may depend on the coded information of the video unit. a. For example, it may depend on the prediction method. b. For example, if the video unit is coded with one or more of the modes / techniques listed below, then the reordering process may be applied to the video unit. Otherwise, the reordering process is not allowed. i. Intra block copy (also known as IBC). ii. Current picture reference (also known as CPR). iii. Intra template matching (also known as intra TM). iv. IBC template matching (or IBC mode based on template matching). v. Merge-based coding. vi. AMVP-based coding. c. For example, it may depend on the block size (such as block width and / or height). d. For example, if the size W×H of the video unit meets one or more of the rules listed below, then the reordering process may be applied to the video unit. Otherwise, the reordering process is not allowed. i. If W >= T1 and / or H >= T2. ii. If W <= T1 and / or H <= T2s. iii. If W > T1 and / or H > T2s. iv. If W < T1 and / or H < T2s. v. If W×H >= T. vi. If W×H > T. vii. If W×H <= T. viii. If W×H < T. 2. Regarding which kinds of samples are reordered and the interaction with other processes (e.g., the second and related issues), the following methods are proposed: a. A possible sample reordering method may refer to one or more of the following processes: a. The samples in the luma domain of the video unit (e.g., obtained based on the LMCS method) can be reordered. i. For example, the luma samples in the luma domain of the video unit (e.g., obtained based on the luma mapping of the LMCS method) can be reordered. b. The samples in the original domain (instead of the LMCS luma domain) of the video unit can be reordered. i. For example, the chroma samples in the original domain of the video unit can be reordered. ii. For example, the luma samples in the original domain of the video unit can be reordered. c. The reconstructed samples of the video unit can be reordered. i. For example, the reconstructed samples of the video unit can be reordered immediately after adding the decoded residuals to the prediction. ii. For example, the luma reconstructed samples in the luma domain of the video unit can be reordered. iii. For example, the luma reconstructed samples in the original domain of the video unit can be reordered. iv. For example, the chroma reconstructed samples in the original domain of the video unit can be reordered. d. The inverse luma mapping of the LMCS process can be applied based on the reordered reconstructed samples. e. The loop filter process (e.g., luma / chroma bilateral filter, luma / chroma SAO, CCSAO, luma / chroma ALF, CCALF, etc.) can be applied based on the reordered reconstructed samples. i. For example, the loop filter process can be applied based on the reconstructed samples reordered in the original domain (instead of the LMCS luma domain). f. The distortion calculation (e.g., SSE calculation between the original samples and the reconstructed samples) can be based on the reordered reconstructed samples. i. For example, the distortion calculation can be based on the reconstructed samples reordered in the original domain. g. The original samples of the video unit can be reordered. i. For example, the original luma samples in the luma domain of the video unit can be reordered. ii. For example, the original luma samples in the original domain of the video unit can be reordered. iii. For example, the original chroma samples in the original domain of the video unit can be reordered. iv. For example, the residual can be generated by subtracting the prediction from the reordered original samples. h. The prediction samples of a video unit can be reordered. i. For example, the process for reordering the prediction samples can be performed immediately after the motion compensation process. ii. For example, symbol prediction can be applied based on the reordered prediction samples of the video unit. General aspects 3. Whether and / or how to apply the methods disclosed above can be signaled at the sequence level / group of pictures level / picture level / strip level / group of tiles level, for example, in the sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / strip header / group of tiles header. 4. Whether and / or how to apply the methods disclosed above can be signaled in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / strip / tile / sub - picture / other types of regions containing more than one sample or pixel. 5. Whether and / or how to apply the methods disclosed above may depend on the decoded information, such as block size, color format, single - tree partition / double - tree partition, color component, strip / picture type. 2.3.3 Regarding sample reordering - Sample reordering, signaling, and storage The following detailed embodiments should be considered as examples to explain the general concepts. These embodiments should not be interpreted in a narrow way. In addition, these embodiments can be combined in any way. The term "video unit" or "coding unit" may represent a picture, a strip, a tile, a coding tree block (CTB), a coding tree unit (CTU), a coding block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may represent a coding tree block (CTB), a coding tree unit (CTU), a coding block (CB), a CU, a PU, a TU, a PB, a TB. Note that the terms mentioned below are not limited to the specific terms defined in the existing standards. Any change in the coding tools is also applicable. 1. Regarding the signaling of sample reordering (e.g., the first question and related questions), the following methods are proposed. a. For example, at least one new syntax element (e.g., flag, index, variable, parameter, etc.) can be signaled to specify the use of sample reordering for a video unit. a. For example, given that a specific prediction method is used for a video unit, then at least one new syntax element (e.g., flag) can be further signaled to specify the use of sample reordering. b. For example, given that an intra-template matching usage flag specifies that a video unit is coded by intra-template matching, a first new syntax element (e.g., a flag) can be further signaled to specify the use of reordering of samples of the video unit coded by intra-template matching. c. For example, given that an IBC amvp flag specifies that a video unit is coded by IBC amvp, a first new syntax element (e.g., a flag) can be further signaled to specify the use of reordering of samples of the video unit coded by IBC amvp. d. For example, given that an IBC merge flag specifies that a video unit is coded by IBC merge, a first new syntax element (e.g., a flag) can be further signaled to specify the use of reordering of samples of the video unit coded by IBC merge. b. Additionally, for example, if the first new syntax element specifies the use of sample reordering for video units coded by a specific prediction method, a second new syntax element (e.g., a flag) can be further signaled to specify which reordering method (e.g., horizontal flip or vertical flip) is used for the video unit. c. For example, a single new syntax element (e.g., a parameter or a variable or an index) can be signaled to the video unit instead of multiple cascaded syntax elements to specify the type of reordering (e.g., no flip, horizontal flip, or vertical flip) applied to the video unit. a. For example, given that an intra-template matching usage flag specifies that a video unit is coded by intra-template matching, a new syntax element (e.g., an index) can be further signaled to specify the type of reordering of samples of the video unit coded by intra-template matching. b. For example, given that an IBC amvp flag specifies that a video unit is coded by IBC amvp, a new syntax element (e.g., an index) can be further signaled to specify the type of reordering of samples of the video unit coded by IBC amvp. c. For example, given that an IBC merge flag specifies that a video unit is coded by IBC merge, a new syntax element (e.g., an index) can be further signaled to specify the type of reordering of samples of the video unit coded by IBC merge. d. Additionally, for example, a new syntax element (e.g., an index) equal to 0 specifies that sample reordering is not used; equal to 1 specifies that sample reordering method A is used; equal to 2 specifies that sample reordering method B is used; and so on. d. For example, one or more syntax elements related to sample reordering can be context-coded. a. For example, the context can be based on neighboring block / sample coding information (e.g., availability, prediction mode, whether coded by merge, whether coded by IBC, whether sample reordering is applied, which sample reordering method is used, etc.). e. Alternatively, for example, instead of signaling, some (or all) of the steps of whether to perform sample reordering and / or which reordering method to use for a video unit can be determined based on predefined rules (without signaling). a. For example, the predefined rules can be based on information of neighboring block / sample coding. b. For example, given that the IBC merge flag specifies that a video unit is coded by IBC merge, a process can be performed to determine whether to perform reordering and how to reorder based on predefined rules / processes. i. Alternatively, for example, given that the first new syntax element specifies sample reordering for a video unit, however, how to reorder can be determined based on predefined rules / procedures (without signaling), rather than further signaling the reordering method. ii. Alternatively, for example, whether to perform reordering can be implicitly determined based on predefined rules / processes, but how to reorder can be signaled. c. For example, given that the IBC amvp flag specifies that a video unit is coded by IBC amvp, a program can be executed to determine whether to perform reordering and how to reorder based on predefined rules / processes. i. Alternatively, for example, given that the first new syntax element specifies sample reordering for a video unit, however, how to reorder can be determined based on predefined rules / procedures (without signaling) without further signaling the reordering method. ii. Alternatively, for example, whether to perform reordering can be implicitly determined based on predefined rules / processes, but how to reorder can be signaled. d. For example, given that the intra template matching flag specifies that a video unit is encoded by IBC merge, a process can be performed to determine whether to perform reordering and how to reorder based on predefined rules / processes. i. Alternatively, for example, given that the first new syntax element specifies sample reordering for a video unit, however, how to reorder can be determined based on predefined rules / procedures (without signaling), rather than further signaling the reordering method. ii. Alternatively, for example, whether to perform reordering can be implicitly determined based on predefined rules / processes, but how to reorder can be signaled. f. For example, whether to perform reordering and / or how to reorder can be inherited from the warp-decoded blocks. a. For example, it can be inherited from adjacent spatial neighboring blocks. b. For example, it can be inherited from non-adjacent spatial neighboring blocks. c. For example, it can be inherited from a history-based motion table (such as a certain HMVP table). d. For example, it can be inherited from temporal motion candidates. e. For example, it can be inherited based on the IBC merge candidate list. f. For example, it can be inherited based on the IBC amvp candidate list. g. For example, it can be inherited based on a generated motion candidate list / table. h. For example, in the case of encoding / decoding a video unit in the IBC merge mode, sample reordering inheritance can be allowed. i. For example, in the case of encoding / decoding a video unit in the IBC AMVP mode, sample reordering inheritance can be allowed. j. For example, in the case of encoding / decoding a video unit in the intra-template matching mode, sample reordering inheritance can be allowed. 2. After storing the sample reordering status (e.g., the second and related issues), the following methods are proposed. a. For example, information on whether and / or how to reorder for a video unit can be stored. a. For example, the stored information can be used for encoding / decoding future video units. b. For example, this information can be stored in a buffer. i. For example, the buffer can be a line buffer, a table, more than one line buffer, a picture buffer, a compressed picture buffer, a temporal buffer, etc. c. For example, this information can be stored in a history motion vector table (such as a certain HMVP table). b. For example, encoding / decoding information (e.g., whether sample reordering is applied, which sample reordering method is used, block availability, prediction mode, whether it is merged encoding / decoding, whether it is IBC encoding / decoding, etc.) can be stored for deriving the context of sample reordering syntax elements. General aspects 3. Whether and / or how to apply the methods disclosed above can be signaled at the sequence level / group of pictures level / picture level / strip level / tile group level, e.g., in the sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / strip header / tile group header. 4. Whether and / or how to apply the methods disclosed above can be signaled in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU rows / strips / tiles / sub-pictures / other types of regions containing more than one sample or pixel. 5. Whether and / or how to apply the methods disclosed above may depend on the transcoded information, such as block size, color format, single-tree partitioning / double-tree partitioning, color components, strip / picture type. 2.3.4 Regarding sample reordering - motion list generation, implicit derivation, and how to reorder The following detailed embodiments should be considered as examples for explaining general concepts. These embodiments should not be construed in a narrow manner. In addition, these embodiments can be combined in any way. The term "video unit" or "coding unit" may represent a picture, strip, tile, coding tree block (CTB), coding tree unit (CTU), coding block (CB), CU, PU, TU, PB, TB. The term "block" may represent a coding tree block (CTB), coding tree unit (CTU), coding block (CB), CU, PU, TU, PB, TB. Note that the terms mentioned below are not limited to the specific terms defined in existing standards. Any changes to the coding tools are also applicable. 1. Regarding motion candidate list generation for sample reordering (e.g., the first and related issues), the following methods are proposed: b. For example, the IBC merge motion candidate list can be used for both the regular IBC merge mode and the IBC merge mode based on sample reordering. c. For example, the IBC amvp motion prediction sub-candidate list can be used for both the regular IBC amvp mode and the IBC amvp mode based on sample reordering. d. For example, a new motion (prediction) candidate list can be generated for the target video unit coded with sample reordering. a. For example, the new candidate list can consider only motion candidates having the same reordering method as the reordering method of the target video unit. b. For example, the new candidate list can consider only motion candidates coded with sample reordering (regardless of the type of sample reordering method). c. Alternatively, the new candidate list can be generated without considering the sample reordering method of each motion candidate. d. For example, non-adjacent motion candidates can be inserted into the new candidate list. i. For example, non-adjacent candidates with sample reordering (regardless of the type of sample reordering method) can be inserted. ii. For example, non-adjacent candidates having the same reordering method as the reordering method of the target video unit may be inserted. iii. For example, non-adjacent candidates may be inserted regardless of whether the sample reordering method is applied to the candidates. e. For example, new motion candidates may be generated according to a certain rule and inserted into a new candidate list. i. For example, the rule may be based on an averaging process. ii. For example, the rule may be based on a cropping process. iii. For example, the rule may be based on a scaling process. e. For example, the generation of the motion (predictor) candidate list for the target video unit may depend on the reordering method. a. For example, the reordering method associated with each motion candidate (from spatial domain or temporal domain or history table) may be inserted into the list regardless of whether the target video unit will be coded / decoded with sample reordering. b. For example, if the target video unit is to be coded / decoded with sample reordering, only those motion candidates (from spatial domain or temporal domain or history table) coded / decoded with the same reordering method as the reordering method of the target video unit are inserted into the list. c. For example, if the target video unit is to be encoded with sample reordering, only those motion candidates (from spatial domain or temporal domain or history table) encoded with sample reordering are inserted into the list. d. For example, if the target video unit is to be encoded for sample reordering, those motion candidates (from spatial domain or temporal domain or history table) encoded with the same reordering method may not be inserted into the list. e. Alternatively, the generation of the motion list of the video unit may not depend on the reordering method associated with each motion candidate. f. For example, the adaptive reordering of the merge candidates (ARMC) of the video unit may depend on the reordering method. a. For example, if the target video unit is to be coded / decoded with sample reordering, the motion candidates coded / decoded with the same reordering method as the reordering method of the target video unit may be placed before those motion candidates coded / decoded with different reordering methods. b. For example, if the target video unit is to be coded / decoded with sample reordering, the motion candidates coded / decoded with sample reordering (regardless of the type of the sample reordering method) may be placed before those motion candidates coded / decoded with different reordering methods. c. For example, if the target video unit is to be coded / decoded without sample reordering, motion candidates without the reordering method can be placed before those motion candidates coded with the reordering method. d. Alternatively, the ARMC can be applied to the video unit regardless of the reordering method associated with each motion candidate. 2. Regarding the implicit determination of sample reordering (e.g., the second and related issues), the following methods are proposed: a. Whether to reorder the reconstructed / original / predicted samples of the video unit can be implicitly derived from the coded / decoded information at both the encoder and the decoder. a. The implicit derivation can be based on the cost / error / difference calculated from the coded / decoded information. i. For example, the cost / error / difference can be calculated based on template matching. ii. For example, the template matching can be performed by comparing the samples in the first template and the second template. 1. For example, the first template is constructed by a set of predefined samples adjacent to the current video unit, while the second template is constructed by a set of corresponding samples adjacent to the reference video unit. 2. For example, the cost / error can refer to the accumulated sum of the differences between the samples in the first template and the corresponding samples in the second template. a. For example, the difference can be based on the luminance sample values. 3. For example, the samples can refer to the reconstructed samples or variants based on the reconstructed samples. 4. For example, the samples can refer to the predicted samples or variants based on the predicted samples. b. For example, the first cost (denoted by Cost0) can be calculated without reordering, and the second cost (denoted by Cost1) can be calculated using reordering. Finally, identify the minimum cost value in {Cost0, Cost1}, and determine the corresponding coding / decoding method (without reordering or with reordering) as the final coding / decoding method for the video unit. c. Alternatively, it can be signaled in the bitstream to reorder the reconstructed / original / predicted samples of the video unit. i. For example, it can be signaled through a syntax element (e.g., a flag). b. Which reordering method to use to reorder the reconstructed / original / predicted samples can be implicitly derived from the coded / decoded information at both the encoder and the decoder. a. For example, whether it is a horizontal flip or a vertical flip. b. The implicit derivation can be based on the cost / error / difference calculated from the coded / decoded information. a. For example, whether it is a horizontal flip or a vertical flip. i. For example, the cost / error / difference can be calculated based on template matching. ii. For example, template matching can be performed by comparing samples in a first template and a second template. 1. For example, the first template is constructed by a set of predefined samples adjacent to the current video unit, while the second template is constructed by a corresponding set of samples adjacent to the reference video unit. 2. For example, the cost / error can refer to the accumulated sum of the differences between the samples in the first template and the corresponding samples in the second template. a. For example, the difference can be based on the luminance sample values. 3. For example, the samples can refer to reconstructed samples or variants based on the reconstructed samples. 4. For example, the samples can refer to predicted samples or variants based on the predicted samples. iii. For example, the first cost can be calculated without reordering method A (represented by Cost0), and the second cost can be calculated using reordering method B (represented by Cost1). Finally, the minimum cost value in {Cost0, Cost1} is identified, and the corresponding codec method (reordering method A, reordering method B) is determined as the final codec method for the video unit. c. Alternatively, the reordering method for reordering the reconstructed / original / predicted samples of the video unit can be signaled in the bitstream. i. For example, it can be signaled by a syntax element (e.g., a flag or an index or a parameter or a variable). c. Whether to use and which reordering method to use for reordering the reconstructed / original / predicted samples of the video unit can be implicitly derived from the decoded information at both the encoder and the decoder. a. For example, the first cost (represented by Cost0) can be calculated without reordering, the second cost can be calculated using reordering method A (represented by Cost1); the third cost can be calculated using reordering method B (represented by Cost2). Finally, the minimum cost value in {Cost0, Cost1, Cost2} is identified, and the corresponding codec method (no reordering, reordering method A, reordering method B) is determined as the final codec method for the video unit. a. For example, the first cost (represented by Cost0) can be calculated without reordering, the second cost can be calculated using reordering method A (represented by Cost1); the third cost can be calculated using reordering method B (represented by Cost2). Finally, the minimum cost value in {Cost0, Cost1, Cost2} is identified, and the corresponding codec method (no reordering, reordering method A, reordering method B) is determined as the final codec method for the video unit. 3. Regarding how to reorder samples (e.g., the third and related issues), the following methods are proposed: b. A possible sample reordering method can refer to one or more of the following processes: a. The reordering process can be applied based on the video unit. i. For example, the reordering process can be based on a block / CU / PU / TU. ii. For example, the reordering process may not be based on tiles / strips / pictures. b. Samples of a video unit may be transformed according to an M parameter model (e.g., M = 2 or 4 or 6 or 8). c. Samples of a video unit may be reordered. d. Samples of a video unit may be rotated. e. Samples of a video unit may be transformed according to an affine model. f. Samples of a video unit may be transformed according to a linear model. g. Samples of a video unit may be transformed according to a projection model. h. Samples of a video unit may be flipped along the horizontal direction. i. Samples of a video unit may be flipped along the vertical direction. General aspects 4. Whether and / or how to apply the methods disclosed above may be signaled at the sequence level / group level of the picture level / picture level / strip level / tile group level, e.g., in the sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / strip header / tile group header. 5. Whether and / or how to apply the methods disclosed above may be in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / strip / tile / sub - picture / other types of regions containing more than one sample or pixel. 6. Whether and / or how to apply the methods disclosed above may depend on the transcoded / decoded information, e.g., block size, color format, single - tree partitioning / double - tree partitioning, color components, strip / picture type. 3 Issues 1. So far, any motion vector can be applied to the coded / decoded unit coded by IBC AMVP. However, in cases where sample reordering may or may not be used for a video unit, specific motion constraints may be applied. 2. In cases where a certain motion constraint is applied to a video unit, the AMVR signaling may be changed based on the motion constraint. 3. In cases where sample reordering is enabled, methods based on template matching can be modified (such as intra - frame template matching, IBC with template matching). 4. Sample reordering can be extended to intra - frame template matching. When template matching based on sample reordering is used, new steps need to be designed. a. Moreover, sample reordering can be extended to IBC with template matching. When IBC template matching based on sample reordering is used, new steps need to be designed. 5. When the sample reordering method is applied, the motion search with template matching needs to be specified. 6. How to determine the sample reordering method for the blocks decoded with template matching (such as intra-template matching, IBC with template matching, etc.) needs to be specified. 4 Detailed solutions The following detailed embodiments should be considered as examples to explain the general concepts. These embodiments should not be interpreted in a narrow way. In addition, these embodiments can be combined in any way. The term "video unit" or "coding unit" may represent a picture, a slice, a tile, a coding tree block (CTB), a coding tree unit (CTU), a coding block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may represent a coding tree block (CTB), a coding tree unit (CTU), a coding block (CB), a CU, a PU, a TU, a PB, a TB. Note that the terms mentioned below are not limited to the specific terms defined in the existing standards. Any changes to the coding tools are also applicable. 4.1 Regarding the motion constraints for applying coding tools (e.g., the first problem and related problems), the following methods are proposed: a. The motion vectors of the video units coded with a specific prediction method can be constrained by a certain rule. a. The motion vector may refer to one or more of the following: i. Motion vector difference ii. Motion vector, iii. Motion vector predictor. b. The prediction method may refer to one or more of the following: i. IBC AMVP mode, ii. IBC merge mode, iii. IBC merge mode with template matching iv. Intra-template matching, v. IBC AMVP mode based on sample reordering, vi. IBC merge mode based on sample reordering vii. IBC merge mode with template matching based on sample reordering viii. Intra-template matching based on sample reordering. c. The rule may refer to one or more of the following: i. The horizontal component of the motion vector may be required to be equal to zero. ii. The vertical component of the motion vector may be required to be equal to zero. b. For example, given a video unit encoded / decoded using the IBC AMVP mode, the horizontal component of the motion vector may be required to be equal to zero. a. Alternatively, given a video unit encoded / decoded using the IBC AMVP mode, the vertical component of the motion vector may be required to be equal to zero. b. Additionally, the IBC AMVP mode in the disclosed item may be replaced by the IBC merge mode. c. Additionally, the IBC AMVP mode in the disclosed item may be replaced by the IBC mode with template matching. i. In one example, the template matching may be required to be searched in one direction (horizontal or vertical). d. Additionally, the IBC AMVP mode in the disclosed item may be replaced by the intra-template matching mode. i. In one example, the template matching may be required to be searched in one direction (horizontal or vertical). c. For example, given a video unit encoded / decoded using the IBC AMVP mode based on sample reordering (e.g., sample horizontal flip), the vertical component of the motion vector may be processed / constrained / required to be equal to zero. a. For example, given a video unit encoded / decoded using the IBC AMVP mode based on sample reordering (e.g., sample vertical flip), the horizontal component of the motion vector may be processed / constrained / required to be equal to zero. b. Additionally, the IBC AMVP mode in the disclosed item may be replaced by the IBC merge mode. c. Additionally, the IBC AMVP mode in the disclosed item may be replaced by the IBC mode with template matching. i. In one example, the template matching may be required to be searched in the horizontal direction for horizontal flip (the vertical component of the motion vector is equal to 0). ii. In one example, the template matching may be required to be searched in the vertical direction for vertical flip (the horizontal component of the motion vector is equal to 0). d. Additionally, the IBC AMVP mode in the disclosed item may be replaced by the intra-template matching mode. d. For example, if a certain component of the motion vector of a video unit (e.g., MVx or MVy) is processed / constrained / required to be equal to zero, then a. The corresponding component of the motion vector difference of the video unit (e.g., MVDx or MVDy) may be processed / constrained / required to be equal to zero. b. The corresponding component of the motion vector predictor of the video unit (e.g., MVPx or MVPy) may be processed / constrained / required to be equal to zero. e. For example, if a certain component of the motion vector difference (e.g., MVDx or MVDy) of a video unit is processed / constrained / required to be equal to zero, a. The corresponding component of the motion vector difference may not be signaled but is inferred to be equal to zero. f. For example, the signaling of the motion vector difference (MVD) for a certain video unit may depend on the motion constraints applied to that video unit. a. For example, if the MVDx of a given video unit is processed / constrained / required to be equal to zero, the sign of MVDx may not be signaled. b. For example, if the MVDy of a given video unit is processed / constrained / required to be equal to zero, the sign of MVDy may not be signaled. g. For example, if the first component of the motion vector is processed / constrained / required to be equal to zero, the first component of the corresponding MVD / MVP is processed / constrained / required to be equal to zero. h. The "zero" in the above items can be replaced by any other fixed or derived or signaled value. 4.2 Regarding AMVR signaling based on motion constraints (e.g., the second problem and related problems), the following methods are proposed: a. For example, the signaling of the resolution of the motion vector difference of a certain video unit (e.g., amvr_precision_idx of AMVR) may depend on the motion constraints applied to that video unit. a. For example, a video unit can be encoded / decoded using an AMVP mode. b. For example, a video unit can be encoded / decoded using IBC AMVP. c. For example, a video unit can be encoded / decoded using IBC AMVP based on sample reordering. d. For example, a video unit can be encoded / decoded using an AMVP mode based on sample reordering. e. For example, the signaling / presence of the resolution of the motion vector difference (e.g., amvr_precision_idx) can be decoupled from MVDx. For example, if the MVDx of a given video unit is processed / constrained / required to be equal to zero, the signaling may depend only on whether the value of MVDy is equal to zero (instead of checking both MVDx and MVDy). f. For example, the signaling / presence of the resolution of the motion vector difference (e.g., amvr_precision_idx) can be decoupled from MVDy. For example, if the MVDy of a given video unit is processed / constrained / required to be equal to zero, the signaling may depend only on whether the value of MVDx is equal to zero (instead of checking both MVDx and MVDy). g. For example, if the resolution of the motion vector difference (e.g., amvr_precision_idx) is not signaled for such a video unit, it can be inferred to be equal to some value (such as 0) indicating that the default resolution is used. i. For example, in the case where a video unit is coded based on the IBC AMVP mode, the default resolution can be 1-pixel precision. ii. For example, in the case where a video unit is coded based on the IBC AMVP mode with sample reordering, the default resolution can be 1-pixel precision. b. For example, the signaling of amvr_precision_idx for a block coded by IBC AMVP (taking the syntax structure in the VVC specification as an example) can be changed as follows, where cu_ibc_reorder_type indicates whether and how to reorder the samples in the block coded by IBC AMVP. 4.3 Template matching in the case of enabling sample reordering (e.g., the third issue and related issues) (e.g., intra TM, IBC with TM) Modifications are proposed as follows: Assume that the first template is used for a first video unit coded using TM with sample reordering, and the second template is used for a second video unit coded using TM without sample reordering: a. For example, the positions of the samples including in the template can depend on the sample reordering method used for the video unit. a. For example, the sample positions of the first template and the second template can be different. b. For example, the second template can be constructed using the samples above and to the left of the video unit. c. For example, the first template can be constructed using the samples above or to the left of the video unit. i. For example, if the first video unit is coded using horizontal flipping, the first template can be constructed using the samples above the video unit. ii. For example, if the first video unit is coded using vertical flipping, the first template can be constructed using the samples to the left of the video unit. d. Alternatively, the sample positions of the first template and the second template can be the same. b. For example, the number of samples including in the template can depend on the sample reordering method used for the video unit. a. For example, the number of rows and / or columns of the first template and the second template can be different. b. For example, the second template can be constructed using M1 row samples above the video unit and N1 column samples to the left of the video unit, while the first template can be constructed using M2 row samples above the video unit and / or the video unit It is constructed by taking the N2 columns of samples on the left. It can meet the following rules: i.M1!=m2, ii. N1!=N2. c. Alternatively, the number of rows and / or columns of the first template and the second template may be the same. 4.4 Regarding intra / IBC template matching based on sample reordering (e.g., the fourth problem and related problems), the following method is proposed: a. How to derive the block reference template after sample reordering coding may depend on the coding information. a. For example, it may depend on the sample reordering type and / or template shape to be used for the current block. b. The derivation of the motion vector (block vector) of a sample reordering coded block may depend on codec information. a. For example, it may depend on the sample reordering type and / or template shape to be used for the current block. b. For example, it may depend on the dimensions of the current block (such as width and / or height). c. For example, it may depend on the dimensions (such as width and / or height) of the template (or part of the template). d. For example, it may depend on the coordinates of the position of the current block or template (eg the center sample position or the top left sample position). i. For example, the template can be a current template and / or a reference template. c. Eight examples of template matching based on sample reordering are respectively Figures 10A - 10H , where the dotted line indicates that flipping is performed across the dotted line (i.e., a horizontal dotted line indicates a vertical flip, which means flipping up and down, and a vertical dotted line indicates a horizontal flip, which means flipping left and right), and the rectangles represent the current block, the current template, the reference block, and the reference template. For example, the rectangular block with (x1, y1) as the upper left sample is the current block. The rectangular block with (x1', y1') as the upper left sample and the rectangular block with (x1", y1") as the upper left sample are the current template. The rectangular block with (x2, y2) as the upper left sample is the reference block. The rectangular block with (x2', y2') as the upper left sample and the rectangular block with (x2", y2") as the upper left sample are the reference template. BV'x and BV'y represent the horizontal displacement and vertical displacement between the current template and the reference template, respectively. BVx and BVy represent the horizontal displacement and vertical displacement between the current block and the reference block, respectively, (W cur ,H cur) represents the width and height of the current block, (W tmpH , H tmpH ) represents the width and height of the horizontal template along the width direction of the block, (W tmpV , H tmpV ) represents the width and height of the vertical template along the height direction of the block, (x1, y1) and (x2, y2) respectively represent the coordinates of the upper-left samples of the current block and the reference block, (x1’, y1’) and (x2’, y2’) respectively represent the coordinates of the upper-left samples of the current horizontal template and the reference horizontal template, and (x1”, y1”) and (x2”, y2”) respectively represent the coordinates of the upper-left samples of the current vertical template and the reference vertical template. a. For example, in the case of the horizontal template and horizontal flipping (i.e., Figure 10A ), i. In one example, the current template includes neighboring samples above the current block, and the reference template includes neighboring samples above the reference block. ii. In one example, the relative positions of (the current block, the current template) and (the reference block, the reference template) can be the same. 1. In one example, x1 - x1’ = x2 - x2’, and y1 - y1’ = y2 - y2’, 2. In one example, x1 - x1’ = 0, and y1 - y1' = H tmpH . iii. In one example, the samples in the current template or the samples in the reference template can be flipped. iv. In one example, the samples in the current template can be flipped according to the type of flipping being examined (e.g., horizontal flipping). v. In one example, the samples in the reference template can be flipped according to the type of flipping being examined (e.g., horizontal flipping). vi. In one example, BVx = BV’x, vii. In one example, x1’ - x2’ = x1 - x2. b. For example, in the case of the vertical template and horizontal flipping (i.e., Figure 10B ), i. In one example, the current template can include neighboring samples to the left of the current block, and the reference template can include neighboring samples to the right of the reference block. ii. In one example, the relative positions of (the current block, the current template) and (the reference block, the reference template) can be different. 1. In one example, x1 - x1”!= x2 - x2”, and y1 - y1” = y2 - y2”, 2. In one example, x1 - x1” = WtmpV and y1 - y1” = 0, 3. In one example, x2 - x2” = -W cur and y2 - y2” = 0. iii. In one example, the samples in the current template or the reference template can be flipped. iv. In one example, the samples in the current template can be flipped according to the type of flip being examined (e.g., horizontal flip). v. In one example, the samples in the reference template can be flipped according to the type of flip being examined (e.g., horizontal flip). vi. In one example, BVx = BV’x - W cur -W tmpV . vii. In one example, x2” - x1” - W cur -W tmpV = x2 - xl. c. For example, in the case of a horizontal - vertical template (where W tmpH = W cur ) and a horizontal flip (i.e., Figure 10C ), i. In one example, the current template can include neighboring samples above and to the left of the current block, and the reference template can include neighboring samples above and to the right of the reference block. ii. In one example, the relative positions of (the current block, the current horizontal template) and (the reference block, the reference horizontal template) can be the same. 1. In one example, x1 - x1’ = x2 - x2’, and y1 - y1’ = y2 - y2’. 2. In one example, x1 - x1' = 0, and y1 - y1' = H tmpH . iii. In one example, the relative positions of (the current block, the current vertical template) and (the reference block, the reference vertical template) can be different. 1. In one example, x1 - x1”!= x2 - x2”, and y1 - y1” = y2 - y2”. 2. In one example, x1 - x1” = W tmpV , and y1 - y1” = 0. 3. In one example, x2 - x2” = -W cur , and y2 - y2” = 0. iv. In one example, the samples in the current horizontal template or the reference horizontal template can be flipped. 1. Additionally, the samples in the current vertical template or the reference vertical template can be flipped. v. In one example, the samples in the current horizontal template and the current vertical template can be flipped according to the type of flip being examined (e.g., horizontal flip). vi. In one example, the samples in the reference horizontal template and the reference vertical template can be flipped according to the type of flip being examined (e.g., horizontal flip). vii. In one example, BVx = BV’x. viii. In one example, x1’ - x2’ = x1 - x2. d. For example, in a horizontal - vertical template (where W tmpH = W cur + W tmpV ) and a horizontal flip (i.e., Figure 10D ), i. In one example, the current template can include neighboring samples above and to the left of the current block, and the reference template can include neighboring samples above and to the right of the reference block. ii. In one example, the relative positions of (the current block, the current horizontal template) and (the reference block, the reference horizontal template) can be different. 1. In one example, x1 - x1’!= x2 - x2’, and y1 - y1’ = y2 - y2’. 2. In one example, x1 - x1’ = W tmpV , and y1 - y1' = H tmpH . 3. In one example, x2 - x2’ = 0, and y2 - y2’ = H tmpH . iii. In one example, the relative positions of (the current block, the current vertical template) and (the reference block, the reference vertical template) can be different. 1. In one example, x1 - x1”!= x2 - x2”, and y1 - y1” = y2 - y2”. 2. In one example, x1 - x1” = W tmpV , and y1 - y1” = 0. 3. In one example, x2 - x2” = -W cur , and y2 - y2” = 0. iv. In one example, the samples in the current horizontal template or the reference horizontal template can be flipped. 1. Additionally, the samples in the current vertical template or the reference vertical template can be flipped. v. In one example, the samples in the current horizontal template and the current vertical template can be flipped according to the type of flip being examined (e.g., horizontal flip). vi. In one example, the samples in the reference horizontal template and the reference vertical template can be flipped according to the type of flip being examined (e.g., horizontal flip). vii. In one example, BVx = BV’x - W tmpV 。 viii. In one example, x2’ - x1’ - W tmpV = x2 - xl. e. For example, in the case of a horizontal template and a vertical flip (i.e., Figure 10E ), i. In one example, the current template can include neighboring samples above the current block, and the reference template can include neighboring samples below the reference block. ii. In one example, the relative positions of (the current block, the current template) and (the reference block, the reference template) can be different. 1. In one example, x1 - x1’ = x2 - x2’, and y1 - y1’!= y2 - y2’. 2. In one example, x1 - x1’ = 0, and y1 - y1’ = H tmpH 。 3. In one example, x2 - x2’ = 0, and y2 - y2’ = -H cur 。 iii. In one example, the samples in the current template or the samples in the reference template can be flipped. iv. In one example, the samples in the current template can be flipped according to the type of flip being examined (e.g., vertical flip). v. In one example, the samples in the reference template can be flipped according to the type of flip being examined (e.g., vertical flip). vi. In one example, BVy = BV'y - H tmpH -H cur 。 vii. In one example, y2’ - y1’ - H tmpH -H cur = y2 - y1. f. For example, in the case of a vertical template and a vertical flip (i.e., Figure 10F ), i. In one example, the current template can include neighboring samples to the left of the current block, and the reference template can include neighboring samples to the left of the reference block. ii. In one example, the relative positions of (the current block, the current template) and (the reference block, the reference template) can be the same. 1. In one example, x1 - x1” = x2 - x2”, and y1 - y1” = y2 - y2”. 2. In one example, x1 - x1” = W tmpV , and y1 - y1” = 0. iii. In one example, the samples in the current template or the samples in the reference template can be flipped. iv. In one example, the samples in the current template can be flipped according to the type of flip being examined (e.g., vertical flip). v. In one example, the samples in the reference template can be flipped according to the type of flip being examined (e.g., vertical flip). vi. In one example, BVy = BV’y. vii. In one example, y1” - y2” = y1 - y2. g. For example, in the case of a horizontal - vertical template (where W tmpH = W cur ) and a vertical flip (i.e., Figure 10G ), i. In one example, the current template can include neighboring samples above and to the left of the current block, and the reference template can include neighboring samples to the left and below the reference block. ii. In one example, the relative positions of (the current block, the current horizontal template) and (the reference block, the reference horizontal template) can be different. 1. In one example, x1 - x1’ = x2 - x2’, and y1 - y1’!= y2 - y2’. 2. In one example, x1 - x1’ = 0, and y1 - y1’ = H tmpH . 3. In one example, x2 - x2’ = 0, and y2 - y2’ = -H cur . iii. In one example, the relative positions of (the current block, the current vertical template) and (the reference block, the reference vertical template) can be the same. 1. In one example, x1 - x1” = x2 - x2”, and y1 - y1” = y2 - y2”. 2. In one example, x1 - x1” = W tmpV , and y1 - y1” = 0. iv. In one example, the samples in the current horizontal template or the samples in the reference horizontal template can be flipped. 1. Additionally, the samples in the current vertical template or the reference vertical template can be flipped. v. In one example, the samples in the current horizontal template and the current vertical template can be flipped according to the type of flip being examined (e.g., vertical flip). vi. In one example, the samples in the reference horizontal template and the reference vertical template can be flipped according to the type of flip being examined (e.g., vertical flip). vii. In one example, BVy = BV’y - H tmpH -H cur 。 viii. In one example, y2’ - y1’ - H tmpH -H cur = y2 - y1. h. For example, in the case of a horizontal - vertical template (where W tmpH = W cur + W tmpV ) and a vertical flip (i.e., Figure 10H ), i. In one example, the current template can include neighboring samples above and to the left of the current block, and the reference template can include neighboring samples to the left and below the reference block. ii. In one example, the relative positions of (the current block, the current horizontal template) and (the reference block, the reference horizontal template) can be different. 1. In one example, x1 - x1’ = x2 - x2’, and y1 - y1’!= y2 - y2’. 2. In one example, x1 - x1’ = W tmpV , and y1 - y1’ = H tmpH . 3. In one example, x2 - x2’ = W tmpV , y2 - y2’ = -H cur . iii. In one example, the relative positions of (the current block, the current vertical template) and (the reference block, the reference vertical template) can be the same. 1. In one example, x1 - x1” = x2 - x2”, and y1 - y1” = y2 - y2”. 2. In one example, x1 - x1” = W tmpV , and y1 - y1” = 0. iv. In one example, the samples in the current horizontal template or the reference horizontal template can be flipped. 1. Additionally, the samples in the current vertical template or the reference vertical template can be flipped. v. In one example, samples in the current horizontal template and the current vertical template can be flipped according to the type of flip being examined (e.g., vertical flip). vi. In one example, samples in the reference horizontal template and the reference vertical template can be flipped according to the type of flip being examined (e.g., vertical flip). vii. In one example, BVy = BV’y - H tmpH -H cur 。 viii. In one example, y2’ - y1’ - H tmpH -H cur = y2 - y1. 4.5 When the sample reordering method is applied (e.g., the fifth problem and related problems), regarding motion search with template matching, the following method is proposed: a. In one example, for a sample reordering method (such as vertical flip or horizontal flip), samples in the template around the current block can be reordered to obtain a cost before being compared with samples in the template of the reference block. b. In one example, for a sample reordering method (such as vertical flip or horizontal flip), samples in the template around the reference block can be reordered to obtain a cost before being compared with samples in the template of the current block. c. In one example, for a sample reordering method (such as vertical flip or horizontal flip), samples in both the template around the reference block and the template around the current block can be reordered to obtain a cost before being compared. 4.6 Regarding how to determine a sample reordering method (such as no flip, vertical flip or horizontal flip) for a block encoded / decoded with template matching (such as intra-template matching and / or IBC mode with template matching) (e.g., the sixth problem or related problems), the following method is proposed: a. In one example, the sample reordering method can depend on at least one syntax element signaled from the encoder to the decoder. i. In one example, the syntax element can indicate whether and / or how to reorder samples for a block encoded / decoded with template matching (such as intra-template matching and / or IBC mode with template matching). ii. The syntax element can be decoded in the same way as that used to indicate whether and / or how to reorder samples for a block encoded by a certain method (such as IBC). b. In one example, the sample reordering method can be derived based on at least one template cost. i. In one example, motion search with template matching can be applied to a block to derive the minimum cost of different sample reordering methods, where the template matching has different sample reordering methods. ii. In one example, a sample reordering method with the minimum template cost can be derived as the determined sample reordering method. General aspects 4.7 Whether and / or how to apply the methods disclosed above can be signaled at the sequence level / picture group level / picture level / slice level / tile group level, e.g., in the sequence header / picture header / SPS / VPS / DPS / DCI / PPS / APS / slice header / tile group header. 4.8 Whether and / or how to apply the methods disclosed above can be signaled in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / slice / tile / sub - picture / other types of regions containing more than one sample or pixel. 4.9 Whether and / or how to apply the methods disclosed above may depend on the decoded information, e.g., block size, color format, single - tree / dual - tree partitioning, color component, slice / picture type.

[0079] Embodiments of the present disclosure relate to motion information determination. As used herein, the term "block" may refer to a coding tree block (CTB), a coding tree unit (CTU), a coding block (CB), a coding unit (CU), a prediction unit (PU), a transform unit (TU), a prediction block (PB), a transform block (TB), or a video processing unit including multiple samples or pixels. A block can be rectangular or non - rectangular.

[0080] As used herein, the term "motion information" may refer to a motion vector (MV), a motion vector difference (MVD), or a motion vector predictor.

[0081] Figure 11 A flowchart of a method 1100 for video processing according to an embodiment of the present disclosure is shown. Method 1100 is implemented for the conversion between a current video block of a video and the bitstream of the video. In some embodiments, the conversion between the current video block and the bitstream may include encoding the current video block into the bitstream. Alternatively or additionally, the conversion may include decoding the current video block from the bitstream.

[0082] At block 1110, the motion information of the current video block is determined. The current video block is coded and decoded using at least one of the following: Intra Block Copy (IBC) merge mode, IBC mode with template matching, or intra template matching mode. At block 1120, the motion information is updated based on a constraint. The constraint indicates a target value of a component of the motion information. At block 1130, a transform is performed based on the updated motion information.

[0083] Method 1100 enables updating of motion information based on a constraint. In this way, coding and decoding efficiency and effectiveness can be improved.

[0084] In some embodiments, the current video block is coded and decoded using at least one of the following: IBC merge mode based on sample reordering, IBC mode with template matching based on sample reordering, or intra template matching mode based on sample reordering. The vertical component of the motion information may be updated to a target value.

[0085] In some embodiments, the samples of the current video block are horizontally flipped.

[0086] In some embodiments, the current video block is coded and decoded using IBC mode with template matching based on sample reordering. The template matching of the current video block is searched horizontally for the horizontal flip. In one example, the template matching may be required to be searched horizontally for the horizontal flip (the vertical component of the motion vector is equal to 0).

[0087] In some embodiments, the current video block is coded and decoded using at least one of the following: IBC merge mode based on sample reordering, IBC mode with template matching based on sample reordering, or intra template matching mode based on sample reordering. The horizontal component of the motion information may be updated to a target value.

[0088] In some embodiments, the samples of the current video block are vertically flipped.

[0089] In some embodiments, the current video block is coded and decoded using IBC mode with template matching based on sample reordering. The template matching of the current video block is searched vertically for the vertical flip. In one example, the template matching may be required to be searched vertically for the vertical flip (the horizontal component of the motion vector is equal to 0).

[0090] In some embodiments, the current video block is coded and decoded using at least one of the following: IBC merge mode, IBC mode with template matching, or intra template matching mode. The component of the motion information may be updated to a target value.

[0091] In some embodiments, the components of the motion information include at least one of the following: the horizontal component of the motion information, or the vertical component of the motion information.

[0092] In some embodiments, the current video block is encoded and decoded using at least one of the following: the IBC mode with template matching or the intra-template matching mode, and the template matching of the current video block is searched in a single direction.

[0093] In some embodiments, the single direction includes one of the following: the horizontal direction or the vertical direction.

[0094] In some embodiments, the motion information includes at least one of the following: a motion vector, a motion vector difference, or a motion vector predictor.

[0095] In some embodiments, the target value is zero.

[0096] In some embodiments, the target value is included in the bitstream. Alternatively or additionally, in some embodiments, the target value is derived during transformation.

[0097] According to further embodiments of the present disclosure, a non-transitory computer-readable recording medium is provided. The non-transitory computer-readable recording medium stores a bitstream generated by a method executed by a video processing device. In this method, the motion information of the current video block of the video is determined. The current video block is encoded and decoded using at least one of the following: the intra-block copy (IBC) merge mode, the IBC mode with template matching, or the intra-template matching mode. The motion information is updated based on a constraint. The constraint indicates a target value of a component of the motion information. The bitstream is generated based on the updated motion information.

[0098] According to still further embodiments of the present disclosure, a method for storing a bitstream of a video is provided. In this method, the motion information of the current video block of the video is determined. The current video block is encoded and decoded using at least one of the following: the intra-block copy (IBC) merge mode, the IBC mode with template matching, or the intra-template matching mode. The motion information is updated based on a constraint. The constraint indicates a target value of a component of the motion information. The bitstream is generated based on the updated motion information. The bitstream is stored in a non-transitory computer-readable recording medium.

[0099] Figure 12 A flowchart of a method 1200 for video processing according to an embodiment of the present disclosure is shown. The method 1200 is implemented for the conversion between the current video block of the video and the bitstream of the video. In some embodiments, the conversion between the current video block and the bitstream may include encoding the current video block into the bitstream. Alternatively or additionally, the conversion may include decoding the current video block from the bitstream.

[0100] Step 1210, the reference template of the current video block is determined based on the codec information of the current video block. The current video block is coded and decoded using a sample reordering mode. For example, how to derive the reference template of a block coded and decoded with sample reordering may depend on the codec information.

[0101] At block 1220, a base transform is performed on the reference template.

[0102] Method 1200 enables the determination of the reference template for the current video block coded and decoded using a sample reordering mode, and thus the coding efficiency and coding effectiveness can be improved.

[0103] In some embodiments, the codec information includes at least one of the following: the sample reordering type of the sample reordering mode or the template shape of the reference template.

[0104] In some embodiments, method 1200 further includes: determining the motion information of the current video block based on the codec information of the current video block. For example, the derivation of the motion vector (block vector) of a block coded and decoded with sample reordering may depend on the codec information.

[0105] In some embodiments, the motion information includes one of the following: the motion vector of the current video block, or the block vector of the current video block.

[0106] In some embodiments, the codec information includes at least one of the following: the sample reordering type of the sample reordering mode, the template shape of the reference template, the size of the current video block, the size of the template of the current video block, the size of a part of the template, the position of the current video block; or the position of the template.

[0107] In some embodiments, the template of the current video block includes at least one of the following: the current template of the current video block, or the reference template of the current video block.

[0108] In some embodiments, the size of the current video block includes at least one of the following: the width of the current video block; or the height of the current video block.

[0109] In some embodiments, the size of the template or the size of a part of the template includes at least one of the following: the width of the template or the width of a part of the template, or the height of the template or the height of a part of the template.

[0110] In some embodiments, the position of the current video block or the position of the template includes at least one of the following: the position of the central sample of the current video block, the position of the central sample of the template, the position of the upper left sample of the current block, or the position of the upper left sample of the template.

[0111] In some embodiments, as Figure 10AAs shown, the current template of the current video block and the reference template of the reference block of the current video block are horizontal templates. The width of the horizontal template is the same as the width of the current video block. The sample reordering mode includes a horizontal flip reordering mode.

[0112] In some embodiments, the current template includes neighboring samples above the current video block, and the reference template includes neighboring samples above the reference block.

[0113] In some embodiments, the positional difference between the current template and the current video block is the same as the positional difference between the reference template and the reference block.

[0114] In some embodiments, the first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block. The first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is the same as the second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block. For example, x1 - x1' = x2 - x2', and y1 - y1' = y2 - y2'.

[0115] In some embodiments, the first horizontal distance and the second horizontal distance are zero. The first vertical distance and the second vertical distance are the height of the current template or the reference template. For example, x1 - x1' = 0, and y1 - y1' = H tmpH 。

[0116] In some embodiments, the distance between the upper left sample of the current template and the upper left sample of the reference template is the same as the distance between the upper left sample of the current video block and the upper left sample of the reference block. For example, x1' - x2' = x1 - x2.

[0117] In some embodiments, at least one of the samples in the current template or the samples in the reference template is flipped.

[0118] In some embodiments, the flip type of the current video block is horizontal flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0119] In some embodiments, the horizontal distance between the current video block and the reference block is the same as the horizontal distance between the current template and the reference template. For example, BVx = BV'x.

[0120] In some embodiments, as Figure 10B shown, the current template of the current video block and the reference template of the reference block of the current video block are vertical templates. The height of the vertical template is the same as the height of the current video block. The sample reordering mode includes a horizontal flip reordering mode.

[0121] In some embodiments, the current template includes neighboring samples to the left of the current video block, and the reference template includes neighboring samples to the right of the reference block.

[0122] In some embodiments, the positional difference between the current template and the current video block is different from the positional difference between the reference template and the reference block.

[0123] In some embodiments, the first horizontal distance between the top-left sample of the current template and the top-left sample of the current video block is different from the second horizontal distance between the top-left sample of the reference template and the top-left sample of the reference block. The first vertical distance between the top-left sample of the current template and the top-left sample of the current video block is the same as the second vertical distance between the top-left sample of the reference template and the top-left sample of the reference block. For example, x1 - x1”!= x2 - x2”, and y1 - y1” = y2 - y2”.

[0124] In some embodiments, the first horizontal distance is the width of the current template, and the first vertical distance is zero. For example, x1 - x1” = W tmpV and y1 - y1” = 0.

[0125] In some embodiments, the second horizontal distance is the width of the current video block, the reference template is to the right of the reference block, and the second vertical distance is zero. For example, x2 - x2” = -W cur and y2 - y2” = 0.

[0126] In some embodiments, the sum of the first distance between the top-left sample of the current template and the top-left sample of the reference template, the width of the current video block, and the width of the current template is equal to the second distance between the top-left sample of the current video block and the top-left sample of the reference block. For example, x2” - x1” - W cur -W tmpV = x2 - xl.

[0127] In some embodiments, at least one of the samples in the current template or the samples in the reference template is flipped.

[0128] In some embodiments, the flip type of the current video block is horizontal flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0129] In some embodiments, the sum of the first horizontal distance between the current video block and the reference block, the width of the current video block, and the width of the current template is equal to the second horizontal distance between the current template and the reference template. For example, BVx = BV’x - W cur -W tmpV .

[0130] In some embodiments, the current template of the current video block includes a horizontal current template and a vertical current template. The reference template of the reference block of the current video block includes a horizontal reference template and a vertical reference template. The sample reordering mode includes a horizontal flip reordering mode.

[0131] In some embodiments, as Figure 10C shown, the width of the horizontal current template and the width of the horizontal reference template are the same as the width of the current video block.

[0132] In some embodiments, the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples above the reference block and neighboring samples to the right of the reference block.

[0133] In some embodiments, the positional difference between the horizontal reference template and the current video block is the same as the positional difference between the horizontal reference template and the reference block.

[0134] In some embodiments, the first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block. The first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as the second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block. For example, x1 - x1’ = x2 - x2’, and y1 - y1’ = y2 - y2’.

[0135] In some embodiments, the first horizontal distance is zero, and the first vertical distance is the height of the horizontal current template. For example, x1 - x1' = 0, and y1 - y1' = H tmpH .

[0136] In some embodiments, the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the distance between the upper left sample of the current video block and the upper left sample of the reference block. For example, x1’ - x2’ = x1 - x2.

[0137] In some embodiments, the positional difference between the vertical current template and the current video block is different from the positional difference between the vertical reference template and the reference block.

[0138] In some embodiments, the third horizontal distance between the upper-left sample of the vertical current template and the upper-left sample of the current video block is different from the fourth horizontal distance between the upper-left sample of the vertical reference template and the upper-left sample of the reference block. The third vertical distance between the upper-left sample of the vertical current template and the upper-left sample of the current video block is the same as the fourth vertical distance between the upper-left sample of the vertical reference template and the upper-left sample of the reference block. For example, x1 - x1” != x2 - x2”, and y1 - y1” = y2 - y2”.

[0139] In some embodiments, the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero. For example, x1 - x1” = W tmpV , and y1 - y1” = 0.

[0140] In some embodiments, the fourth horizontal distance is the width of the current video block, the vertical reference template is on the right side of the reference block, and the fourth vertical distance is zero. For example, x2 - x2” = -W cur , and y2 - y2” = 0.

[0141] In some embodiments, at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0142] In some embodiments, at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0143] In some embodiments, the flip type of the current video block is horizontal flip, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0144] In some embodiments, the flip type of the current video block is horizontal flip, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0145] In some embodiments, the horizontal distance between the current video block and the reference block is equal to the horizontal distance between the horizontal current template and the horizontal reference template.

[0146] In some embodiments, as Figure 10D shown, the width of the horizontal current template is the same as the width of the horizontal reference template. The width of the vertical current template is the same as the width of the vertical reference template. The width of the horizontal reference template is equal to the sum of the width of the current video block and the width of the vertical current template.

[0147] In some embodiments, the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples above the reference block and neighboring samples to the right of the reference block.

[0148] In some embodiments, the positional difference between the horizontal reference template and the current video block is different from the positional difference between the horizontal reference template and the reference block.

[0149] In some embodiments, a first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is different from a second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block. A first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as a second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block. For example, x1 - x1' != x2 - x2', and y1 - y1' = y2 - y2'.

[0150] In some embodiments, the first horizontal distance is the width of the vertical current template, and the first vertical distance is the height of the horizontal current template.

[0151] In some embodiments, the second horizontal distance is zero, and the second vertical distance is the height of the horizontal current template.

[0152] In some embodiments, the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the sum of the width of the vertical current template and the distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0153] In some embodiments, the positional difference between the vertical current template and the current video block is different from the positional difference between the vertical reference template and the reference block.

[0154] In some embodiments, a third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is different from a fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block. A third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as a fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block. For example, x1 - x1" != x2 - x2", and y1 - y1" = y2 - y2".

[0155] In some embodiments, the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

[0156] In some embodiments, the fourth horizontal distance is the width of the current video block, the vertical reference template is on the right side of the reference block, and the fourth vertical distance is zero.

[0157] In some embodiments, at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0158] In some embodiments, at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0159] In some embodiments, the flip type of the current video block is horizontal flip, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0160] In some embodiments, the flip type of the current video block is horizontal flip, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0161] In some embodiments, the horizontal distance between the horizontal current template and the horizontal reference template is equal to the sum of the width of the vertical current template and the horizontal distance between the current video block and the reference block. For example, BVx = BV’x - W tmpV 。

[0162] In some embodiments, as Figure 10E shown, the current template of the current video block and the reference template of the reference block of the current video block are horizontal templates. The width of the horizontal template is the same as the width of the current video block. The sample reordering mode includes a vertical flip reordering mode.

[0163] In some embodiments, the current template includes neighboring samples above the current video block, and the reference template includes neighboring samples below the reference block.

[0164] In some embodiments, the positional difference between the current template and the current video block is different from the positional difference between the reference template and the reference block.

[0165] In some embodiments, the first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block. The first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is different from the second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block. For example, x1 - x1’ = x2 - x2’, and y1 - y1’!= y2 - y2’.

[0166] In some embodiments, the first horizontal distance is zero, and the first vertical distance is the height of the current template. For example, x1 - x1’ = 0, and y1 - y1’ = H tmpH 。

[0167] In some embodiments, the second horizontal distance is zero, and the second vertical distance is the height of the current video block, with the reference template below the reference block. For example, x2 - x2’ = 0, and y2 - y2’ = -H cur 。

[0168] In some embodiments, the sum of the first distance between the upper left sample of the current template and the upper left sample of the reference template, the height of the current video block, and the height of the current template is equal to the second distance between the upper left sample of the current video block and the upper left sample of the reference block. For example, y2’ - y1’ - H tmpH -H cur = y2 - y1.

[0169] In some embodiments, at least one of the samples in the current template or the samples in the reference template is flipped.

[0170] In some embodiments, the flip type of the current video block is vertical flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0171] In some embodiments, the sum of the first vertical distance between the current video block and the reference block, the height of the current video block, and the height of the current template is equal to the second vertical distance between the current template and the reference template. For example, BVy = BV’y - H tmpH -H cur .

[0172] In some embodiments, as Figure 10F shown, the current template of the current video block and the reference template of the reference block of the current video block are vertical templates. The height of the vertical template is the same as the height of the current video block. The sample reordering mode includes a vertical flip reordering mode.

[0173] In some embodiments, the current template includes neighboring samples on the left side of the current video block, and the reference template includes neighboring samples on the left side of the reference block.

[0174] In some embodiments, the position difference between the current template and the current video block is the same as the position difference between the reference template and the reference block.

[0175] In some embodiments, the first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block. The first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is the same as the second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block. For example, x1 - x1” = x2 - x2”, and y1 - y1” = y2 - y2”.

[0176] In some embodiments, the first horizontal distance and the second horizontal distance are the width of the current template or the reference template, and the first vertical distance and the second vertical distance are zero. For example, x1 - x1” = W tmpV , and y1 - y1” = 0.

[0177] In some embodiments, the distance between the upper left sample of the current template and the upper left sample of the reference template is the same as the distance between the upper left sample of the current video block and the upper left sample of the reference block. For example, y1” - y2” = y1 - y2.

[0178] In some embodiments, at least one of the samples in the current template or the samples in the reference template is flipped.

[0179] In some embodiments, the flip type of the current video block is vertical flipping, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0180] In some embodiments, the vertical distance between the current video block and the reference block is the same as the vertical distance between the current template and the reference template. For example, BVy = BV’y.

[0181] In some embodiments, the current template of the current video block includes a horizontal current template and a vertical current template, the reference template of the reference block of the current video block includes a horizontal reference template and a vertical reference template, and the sample reordering pattern includes a vertical flip reordering pattern.

[0182] In some embodiments, as Figure 10G shown, the width of the horizontal current template and the width of the horizontal reference template are the same as the width of the current video block.

[0183] In some embodiments, the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples below the reference block and neighboring samples to the left of the reference block.

[0184] In some embodiments, the positional difference between the horizontal current template and the current video block is different from the positional difference between the horizontal reference template and the reference block.

[0185] In some embodiments, the first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block. The first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is different from the second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block. For example, x1 - x1’ = x2 - x2’, and y1 - y1’!= y2 - y2’.

[0186] In some embodiments, the first horizontal distance is zero, and the first vertical distance is the height of the horizontal current template. For example, x1 - x1’ = 0, and y1 - y1’ = H tmpH .

[0187] In some embodiments, the second horizontal distance is zero, and the second vertical distance is the height of the current video block, and the horizontal reference template is below the reference block. For example, x2 - x2' = 0, and y2 - y2' = -H cur .

[0188] In some embodiments, the distance between the top - left sample of the horizontal current template and the top - left sample of the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the distance between the top - left sample of the current video block and the top - left sample of the reference block.

[0189] In some embodiments, the positional difference between the vertical current template and the current video block is the same as the positional difference between the vertical reference template and the reference block.

[0190] In some embodiments, the third horizontal distance between the top - left sample of the vertical current template and the top - left sample of the current video block is the same as the fourth horizontal distance between the top - left sample of the vertical reference template and the top - left sample of the reference block. The third vertical distance between the top - left sample of the vertical current template and the top - left sample of the current video block is the same as the fourth vertical distance between the top - left sample of the vertical reference template and the top - left sample of the reference block. For example, x1 - x1" = x2 - x2", and y1 - y1" = y2 - y2".

[0191] In some embodiments, the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero. For example, x1 - x1" = W tmpV , and y1 - y1" = 0.

[0192] In some embodiments, at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0193] In some embodiments, at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0194] In some embodiments, the flip type of the current video block is vertical flip, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0195] In some embodiments, the flip type of the current video block is vertical flip, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0196] In some embodiments, the vertical distance between the horizontal current template and the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the vertical distance between the current video block and the reference block.

[0197] In some embodiments, as Figure 10HAs shown, the width of the horizontal current template is the same as the width of the horizontal reference template. The width of the vertical current template is the same as the width of the vertical reference template. The width of the horizontal current template is equal to the sum of the width of the current video block and the width of the vertical current template.

[0198] In some embodiments, the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples below the reference block and neighboring samples to the left of the reference block.

[0199] In some embodiments, the positional difference between the horizontal current template and the current video block is different from the positional difference between the horizontal reference template and the reference block.

[0200] In some embodiments, the first horizontal distance between the upper-left sample of the horizontal current template and the upper-left sample of the current video block is the same as the second horizontal distance between the upper-left sample of the horizontal reference template and the upper-left sample of the reference block. The first vertical distance between the upper-left sample of the horizontal current template and the upper-left sample of the current video block is different from the second vertical distance between the upper-left sample of the horizontal reference template and the upper-left sample of the reference block. For example, x1 - x1' = x2 - x2', and y1 - y1'!= y2 - y2'.

[0201] In some embodiments, the first horizontal distance is the width of the vertical current template, and the first vertical distance is the height of the horizontal current template.

[0202] In some embodiments, the second horizontal distance is the width of the vertical current template, and the second vertical distance is the height of the current video block, and the horizontal reference template is below the reference block.

[0203] In some embodiments, the distance between the upper-left sample of the horizontal current template and the upper-left sample of the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the distance between the upper-left sample of the current video block and the upper-left sample of the reference block.

[0204] In some embodiments, the positional difference between the vertical current template and the current video block is the same as the positional difference between the vertical reference template and the reference block.

[0205] In some embodiments, the third horizontal distance between the upper-left sample of the vertical current template and the upper-left sample of the current video block is the same as the fourth horizontal distance between the upper-left sample of the vertical reference template and the upper-left sample of the reference block. The third vertical distance between the upper-left sample of the vertical current template and the upper-left sample of the current video block is the same as the fourth vertical distance between the upper-left sample of the vertical reference template and the upper-left sample of the reference block. For example, x1 - x1" = x2 - x2", and y1 - y1" = y2 - y2".

[0206] In some embodiments, the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero. For example, x1 - x1” = W tmpV , and y1 - y1” = 0.

[0207] In some embodiments, at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0208] In some embodiments, at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0209] In some embodiments, the flip type of the current video block is vertical flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0210] In some embodiments, the flip type of the current video block is vertical flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0211] In some embodiments, the vertical distance between the horizontal current template and the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the vertical distance between the current video block and the reference block.

[0212] According to further embodiments of the present disclosure, a non - transitory computer - readable recording medium is provided. The non - transitory computer - readable recording medium stores a bitstream generated by a method executed by a video processing device. In this method, the reference template of the current video block of the video is determined based on the coding and decoding information of the current video block. The current video block is coded and decoded using a sample re - ordering mode. The bitstream is generated based on the reference template.

[0213] According to still further embodiments of the present disclosure, a method for storing a bitstream of a video is provided. In this method, the reference template of the current video block of the video is determined based on the coding and decoding information of the current video block. The current video block is coded and decoded using a sample re - ordering mode. The bitstream is generated based on the reference template. The bitstream is stored in a non - transitory computer - readable recording medium.

[0214] Figure 13 A flowchart of a method 1300 for video processing according to an embodiment of the present disclosure is shown. Method 1300 is implemented for the conversion between the current video block of a video and the bitstream of the video. In some embodiments, the conversion between the current video block and the bitstream may include encoding the current video block into the bitstream. Alternatively or additionally, the conversion may include decoding the current video block from the bitstream.

[0215] At block 1310, a first set of multiple samples in a first template associated with a current video block is determined. The current video block is encoded and decoded using a sample reordering mode. At block 1320, the first set of multiple samples is reordered. At block 1330, a cost is determined by comparing the first set of multiple samples with a second set of multiple samples in a second template associated with the current video block. At block 1340, a transform is performed based on the cost.

[0216] Method 1300 enables reordering of multiple samples before determining the cost, and thus can improve encoding and decoding efficiency and encoding and decoding effectiveness.

[0217] In some embodiments, the first template is a template around the current video block. The second template is a template around a reference block of the current video block.

[0218] In some embodiments, the first template is a template around a reference block of the current video block. The second template is a template around the current video block.

[0219] In some embodiments, the second set of multiple samples is not reordered.

[0220] In some embodiments, the second set of multiple samples is reordered before being compared with the first set of multiple samples.

[0221] In some embodiments, the sample reordering mode includes one of the following: horizontal flip or vertical flip.

[0222] According to further embodiments of the present disclosure, a non-transitory computer-readable recording medium is provided. The non-transitory computer-readable recording medium stores a bitstream generated by a method executed by a video processing device. In the method, a first set of multiple samples in a first template associated with a current video block of the video is determined. The current video block is encoded and decoded using a sample reordering mode. The first set of multiple samples is reordered. A cost is determined by comparing the first set of multiple samples with a second set of multiple samples in a second template associated with the current video block. The bitstream is generated based on the cost.

[0223] According to still further embodiments of the present disclosure, a method for storing a bitstream of a video is provided. In the method, a first set of multiple samples in a first template associated with a current video block of the video is determined. The current video block is encoded and decoded using a sample reordering mode. The first set of multiple samples is reordered. A cost is determined by comparing the first set of multiple samples with a second set of multiple samples in a second template associated with the current video block. The bitstream is generated based on the cost. The bitstream is stored in a non-transitory computer-readable recording medium.

[0224] Figure 14A flowchart of a method 1400 for video processing according to an embodiment of the present disclosure is illustrated. The method 1400 is implemented for the conversion between a current video block of a video and a bitstream of the video. In some embodiments, the conversion between the current video block and the bitstream may include encoding the current video block into the bitstream. Alternatively or additionally, the conversion may include decoding the current video block from the bitstream.

[0225] At block 1410, a sample reordering pattern for a current video block is determined based on at least one of the following: a syntax element in the bitstream, or a template cost of the current video block. At block 1420, the conversion is performed based on the sample reordering pattern.

[0226] The method 1400 enables the determination of a sample reordering pattern for a current video block based on a syntax element or a template cost, and thus can improve the encoding / decoding efficiency and encoding / decoding effectiveness.

[0227] In some embodiments, the syntax element indicates information regarding the reordering of samples of the current video block decoded using a template matching codec tool.

[0228] In some embodiments, the template matching codec tool includes at least one of the following: an intra-template matching codec tool, or an intra-block copy (IBC) mode with template matching.

[0229] In some embodiments, the decoding of the syntax element is the same as the decoding of another syntax element associated with the reordering of samples of a video block decoded using a prediction mode.

[0230] In some embodiments, the prediction mode includes an intra-block copy (IBC) mode.

[0231] In some embodiments, the method 1400 further includes: determining a plurality of template costs for a plurality of candidate sample reordering patterns for the current video block; and determining the candidate sample reordering pattern having the minimum template cost as the sample reordering pattern.

[0232] In some embodiments, the plurality of template costs are determined by applying a motion search with template matching to the current video block, the template matching having a plurality of candidate sample reordering patterns.

[0233] According to a further embodiment of the present disclosure, a non-transitory computer-readable recording medium is provided. The non-transitory computer-readable recording medium stores a bitstream of a video generated by a method executed by a video processing device. In the method, a sample reordering pattern for a current video block of the video is determined based on at least one of the following: a syntax element in the bitstream, or a template cost of the current video block. The bitstream is generated based on the sample reordering pattern.

[0234] According to still some other embodiments of the present disclosure, a method for storing a bitstream of a video is provided. In this method, a sample reordering pattern for the current video block of the video is determined based on at least one of the following: a syntax element in the bitstream, or a template cost of the current video block. The bitstream is generated based on the sample reordering pattern. The bitstream is stored in a non-transitory computer-readable recording medium.

[0235] In some embodiments, method 1100, 1200, 1300 or method 1400 further includes: indicating in the bitstream another piece of information on whether and / or how to apply the method.

[0236] In some embodiments, the another piece of information is indicated at one of the following: sequence level, group of pictures level, picture level, slice level or tile group level.

[0237] In some embodiments, the another piece of information is indicated in a sequence header, a picture header, a sequence parameter set (SPS), a video parameter set (VPS), a decoding parameter set (DPS), a decoding capability information (DCI), an image parameter set (PPS), an adaptation parameter set (APS), a slice header or a tile group header.

[0238] In some embodiments, the another piece of information is indicated in a region containing more than one sample or pixel.

[0239] In some embodiments, the region includes one of the following: a prediction block (PB), a transform block (TB), a coding block (CB), a prediction unit (PU), a transform unit (TU), a coding unit (CU), a virtual pipeline data unit (VPDU), a coding tree unit (CTU), a CTU row, a slice, a tile, a sub-picture.

[0240] In some embodiments, the another piece of information depends on the coded information.

[0241] In some embodiments, the coded information includes at least one of the following: a coding mode, a block size, a color format, a single-tree partition or a double-tree partition, a color component, a slice type or a picture type.

[0242] It should be understood that the above method 1100, method 1200, method 1300 and / or method 1400 can be used in combination or alone. Any suitable combination of these methods can be applied. The scope of the present disclosure is not limited in this regard.

[0243] By using these methods 1100, method 1200, method 1300 and method 1400 alone or in combination, motion information can be improved. In this way, coding efficiency and coding effectiveness can be increased.

[0244] Embodiments of the present disclosure can be described according to the following clauses, and the features can be combined in any reasonable manner.

[0245] Clause 1. A method for video processing, comprising: determining motion information for a current video block of a video for conversion between the current video block and a bitstream of the video, the current video block being encoded or decoded using at least one of: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint indicating a target value of a component of the motion information; and performing the conversion based on the updated motion information.

[0246] Clause 2. The method according to Clause 1, wherein the current video block is encoded or decoded using at least one of: an IBC merge mode based on sample reordering, an IBC mode with template matching based on sample reordering, or an intra template matching mode based on sample reordering, and wherein updating the motion information based on a constraint includes: updating a vertical component of the motion information to the target value.

[0247] Clause 3. The method according to Clause 2, wherein samples of the current video block are horizontally flipped.

[0248] Clause 4. The method according to Clause 2 or Clause 3, wherein the current video block is encoded or decoded using an IBC mode with template matching based on sample reordering, and template matching of the current video block is searched in a horizontal direction for horizontal flipping.

[0249] Clause 5. The method according to Clause 1, wherein the current video block is encoded or decoded using at least one of: an IBC merge mode based on sample reordering, an IBC mode with template matching based on sample reordering, or an intra template matching mode based on sample reordering, and wherein updating the motion information according to a constraint includes: updating a horizontal component of the motion information to the target value.

[0250] Clause 6. The method according to Clause 5, wherein samples of the current video block are vertically flipped.

[0251] Clause 7. The method according to Clause 5 or Clause 6, wherein the current video block is encoded or decoded using an IBC mode with template matching based on sample reordering, and template matching of the current video block is searched in a vertical direction for vertical flipping.

[0252] Clause 8. The method according to Clause 1, wherein the current video block is encoded or decoded by using at least one of the following: IBC merge mode, IBC mode with template matching, or intra-template matching mode; and wherein updating the motion information based on a constraint includes: updating the component of the motion information to the target value.

[0253] Clause 9. The method according to Clause 8, wherein the component of the motion information includes at least one of the following: the horizontal component of the motion information, or the vertical component of the motion information.

[0254] Clause 10. The method according to Clause 8 or Clause 9, wherein the current video block is encoded or decoded by using at least one of the following: IBC mode with template matching, or intra-template matching mode, and the template matching of the current video block is searched in a single direction.

[0255] Clause 11. The method according to Clause 10, wherein the single direction includes one of the following: horizontal direction or vertical direction.

[0256] Clause 12. The method according to any one of Clauses 1-11, wherein the motion information includes at least one of the following: motion vector, motion vector difference, or motion vector predictor.

[0257] Clause 13. The method according to any one of Clauses 1-12, wherein the target value is zero.

[0258] Clause 14. The method according to any one of Clauses 1-13, wherein the target value is included in the bitstream.

[0259] Clause 15. The method according to any one of Clauses 1-14, wherein the target value is derived during the transformation.

[0260] Clause 16. A method for video processing, including: for the conversion between the current video block of a video and the bitstream of the video, determining a reference template of the current video block based on the encoding and decoding information of the current video block, the current video block being encoded or decoded by using a sample reordering mode; and performing the conversion based on the reference template.

[0261] Clause 17. The method according to Clause 16, wherein the encoding and decoding information includes at least one of the following: the sample reordering type of the sample reordering mode, or the template shape of the reference template.

[0262] Clause 18. The method according to Clause 16 or Clause 17, further including: determining the motion information of the current video block based on the encoding and decoding information of the current video block.

[0263] Clause 19. The method according to Clause 18, wherein the motion information includes one of the following: the motion vector of the current video block, or the block vector of the current video block.

[0264] Clause 20. The method according to Clause 18 or Clause 19, wherein the codec information includes at least one of the following: the sample reordering type of the sample reordering pattern, the template shape of the reference template, the size of the current video block, the size of the template of the current video block, the size of a part of the template, the position of the current video block; or the position of the template.

[0265] Clause 21. The method according to Clause 20, wherein the template of the current video block includes at least one of the following: the current template of the current video block, or the reference template of the current video block.

[0266] Clause 22. The method according to Clause 20 or Clause 21, wherein the size of the current video block includes at least one of the following: the width of the current video block; or the height of the current video block.

[0267] Clause 23. The method according to any one of Clauses 20 - 22, wherein the size of the template or the size of the part of the template includes at least one of the following: the width of the template or the width of the part of the template, or the height of the template or the height of the part of the template.

[0268] Clause 24. The method according to any one of Clauses 20 - 23, wherein the position of the current video block or the position of the template includes at least one of the following: the position of the central sample of the current video block; the position of the central sample of the template, the position of the top - left sample of the current block, or the position of the top - left sample of the template.

[0269] Clause 25. The method according to any one of Clauses 16 - 24, wherein the current template of the current video block and the reference template of the reference block of the current video block are horizontal templates, the width of the horizontal template is the same as the width of the current video block, and the sample reordering pattern includes a horizontal flip reordering pattern.

[0270] Clause 26. The method according to Clause 25, wherein the current template includes neighboring samples above the current video block, and the reference template includes neighboring samples above the reference block.

[0271] Clause 27. The method according to Clause 25 or Clause 26, wherein the position difference between the current template and the current video block is the same as the position difference between the reference template and the reference block.

[0272] Clause 28. The method according to any one of Clauses 25-27, wherein a first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block, and a first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block.

[0273] Clause 29. The method according to Clause 28, wherein the first horizontal distance and the second horizontal distance are zero, and the first vertical distance and the second vertical distance are the height of the current template or the reference template.

[0274] Clause 30. The method according to Clause 28 or Clause 29, wherein a distance between the upper left sample of the current template and the upper left sample of the reference template is the same as a distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0275] Clause 31. The method according to any one of Clauses 25-30, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

[0276] Clause 32. The method according to any one of Clauses 25-31, wherein a flip type of the current video block is horizontal flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0277] Clause 33. The method according to any one of Clauses 25-32, wherein a horizontal distance between the current video block and the reference block is the same as a horizontal distance between the current template and the reference template.

[0278] Clause 34. The method according to any one of Clauses 16-24, wherein a current template of the current video block and a reference template of a reference block of the current video block are vertical templates, a height of the vertical template is the same as a height of the current video block, and the sample reordering mode includes a horizontal flip reordering mode.

[0279] Clause 35. The method according to Clause 34, wherein the current template includes neighboring samples on the left side of the current video block, and the reference template includes neighboring samples on the right side of the reference block.

[0280] Clause 36. The method according to Clause 34 or Clause 35, wherein a positional difference between the current template and the current video block is different from a positional difference between the reference template and the reference block.

[0281] Clause 37. The method according to any one of Clauses 34-36, wherein a first horizontal distance between a top-left sample of the current template and a top-left sample of the current video block is different from a second horizontal distance between a top-left sample of the reference template and a top-left sample of the reference block, and a first vertical distance between the top-left sample of the current template and the top-left sample of the current video block is the same as a second vertical distance between the top-left sample of the reference template and the top-left sample of the reference block.

[0282] Clause 38. The method according to Clause 37, wherein the first horizontal distance is a width of the current template, and the first vertical distance is zero.

[0283] Clause 39. The method according to Clause 37 or Clause 38, wherein the second horizontal distance is a width of the current video block, the reference template is on a right side of the reference block, and the second vertical distance is zero.

[0284] Clause 40. The method according to any one of Clauses 37-39, wherein a sum of a first distance between the top-left sample of the current template and the top-left sample of the reference template, a width of the current video block, and a width of the current template is equal to a second distance between the top-left sample of the current video block and the top-left sample of the reference block.

[0285] Clause 41. The method according to any one of Clauses 34-40, wherein at least one of samples in the current template or samples in the reference template is flipped.

[0286] Clause 42. The method according to any one of Clauses 34-41, wherein a flip type of the current video block is horizontal flipping, and at least one of samples in the current template or samples in the reference template is flipped.

[0287] Clause 43. The method according to any one of Clauses 34-42, wherein a sum of a first horizontal distance between the current video block and the reference block, a width of the current video block, and a width of the current template is equal to a second horizontal distance between the current template and the reference template.

[0288] Clause 44. The method according to any one of Clauses 16 - 24, wherein the current template of the current video block includes a horizontal current template and a vertical current template, the reference template of the reference block of the current video block includes a horizontal reference template and a vertical reference template, and the sample reordering mode includes a horizontal flip reordering mode.

[0289] Clause 45. The method according to Clause 44, wherein the width of the horizontal current template and the width of the horizontal reference template are the same as the width of the current video block.

[0290] Clause 46. The method according to Clause 44 or Clause 45, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples above the reference block and neighboring samples to the right of the reference block.

[0291] Clause 47. The method according to any one of Clauses 44 - 46, wherein the position difference between the horizontal reference template and the current video block and the position difference between the horizontal reference template and the reference block are the same.

[0292] Clause 48. The method according to any one of Clauses 44 - 47, wherein a first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block and a second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block are the same, and a first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block and a second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block are the same.

[0293] Clause 49. The method according to Clause 48, wherein the first horizontal distance is zero, and the first vertical distance is the height of the horizontal current template.

[0294] Clause 50. The method according to Clause 48 or Clause 49, wherein the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0295] Clause 51. The method according to any one of Clauses 44 - 50, wherein the position difference between the vertical current template and the current video block and the position difference between the vertical reference template and the reference block are different.

[0296] Clause 52. The method according to any one of Clauses 44 - 51, wherein a third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is different from a fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and a third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as a fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

[0297] Clause 53. The method according to Clause 52, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

[0298] Clause 54. The method according to Clause 52 or Clause 53, wherein the fourth horizontal distance is the width of the current video block, the vertical reference template is on the right side of the reference block, and the fourth vertical distance is zero.

[0299] Clause 55. The method according to any one of Clauses 44 - 54, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0300] Clause 56. The method according to any one of Clauses 44 - 55, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0301] Clause 57. The method according to any one of Clauses 44 - 56, wherein the flipping type of the current video block is horizontal flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0302] Clause 58. The method according to any one of Clauses 44 - 57, wherein the flipping type of the current video block is horizontal flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0303] Clause 59. The method according to any one of Clauses 44 - 58, wherein a horizontal distance between the current video block and the reference block is equal to a horizontal distance between the horizontal current template and the horizontal reference template.

[0304] Clause 60. The method according to Clause 44, wherein a width of the horizontal current template is the same as a width of the horizontal reference template, a width of the vertical current template is the same as a width of the vertical reference template, and a width of the horizontal reference template is equal to a sum of a width of the current video block and a width of the vertical current template.

[0305] Clause 61. The method according to Clause 60, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples above the reference block and neighboring samples to the right of the reference block.

[0306] Clause 62. The method according to Clause 60 or Clause 61, wherein a position difference between the horizontal current template and the current video block is different from a position difference between the horizontal reference template and the reference block.

[0307] Clause 63. The method according to any one of Clauses 60 - 62, wherein a first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is different from a second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block, and a first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as a second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block.

[0308] Clause 64. The method according to Clause 63, wherein the first horizontal distance is the width of the vertical current template, and the first vertical distance is the height of the horizontal current template.

[0309] Clause 65. The method according to Clause 63 or Clause 64, wherein the second horizontal distance is zero, and the second vertical distance is the height of the horizontal current template.

[0310] Clause 66. The method according to any one of Clauses 63 - 65, wherein a distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to a sum of the width of the vertical current template and a distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0311] Clause 67. The method according to any one of Clauses 60 - 66, wherein a position difference between the vertical current template and the current video block is different from a position difference between the vertical reference template and the reference block.

[0312] Clause 68. The method according to any one of Clauses 60-67, wherein a third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is different from a fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and a third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as a fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

[0313] Clause 69. The method according to Clause 68, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

[0314] Clause 70. The method according to Clause 68 or Clause 69, wherein the fourth horizontal distance is the width of the current video block, the vertical reference template is on the right side of the reference block, and the fourth vertical distance is zero.

[0315] Clause 71. The method according to any one of Clauses 60-70, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0316] Clause 72. The method according to any one of Clauses 60-71, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0317] Clause 73. The method according to any one of Clauses 60-72, wherein the flip type of the current video block is horizontal flip, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0318] Clause 74. The method according to any one of Clauses 60-73, wherein the flip type of the current video block is horizontal flip, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0319] Clause 75. The method according to any one of Clauses 60-74, wherein a horizontal distance between the horizontal current template and the horizontal reference template is equal to the sum of the width of the vertical current template and the horizontal distance between the current video block and the reference block.

[0320] Clause 76. The method according to any one of Clauses 16-24, wherein the current template of the current video block and the reference template of the reference block of the current video block are horizontal templates, the width of the horizontal template is the same as the width of the current video block, and the sample reordering mode includes a vertical flip reordering mode.

[0321] Clause 77. The method according to Clause 76, wherein the current template includes neighboring samples above the current video block, and the reference template includes neighboring samples below the reference block.

[0322] Clause 78. The method according to Clause 76 or Clause 77, wherein a positional difference between the current template and the current video block is different from a positional difference between the reference template and the reference block.

[0323] Clause 79. The method according to any one of Clauses 76 - 78, wherein a first horizontal distance between the top - left sample of the current template and the top - left sample of the current video block is the same as a second horizontal distance between the top - left sample of the reference template and the top - left sample of the reference block, and a first vertical distance between the top - left sample of the current template and the top - left sample of the current video block is different from a second vertical distance between the top - left sample of the reference template and the top - left sample of the reference block.

[0324] Clause 80. The method according to Clause 79, wherein the first horizontal distance is zero, and the first vertical distance is the height of the current template.

[0325] Clause 81. The method according to Clause 79 or Clause 80, wherein the second horizontal distance is zero, and the second vertical distance is the height of the current video block, and the reference template is below the reference block.

[0326] Clause 82. The method according to any one of Clauses 79 - 81, wherein a sum of a first distance between the top - left sample of the current template and the top - left sample of the reference template, the height of the current video block, and the height of the current template is equal to a second distance between the top - left sample of the current video block and the top - left sample of the reference block.

[0327] Clause 83. The method according to any one of Clauses 76 - 82, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

[0328] Clause 84. The method according to any one of Clauses 76 - 83, wherein a flip type of the current video block is vertical flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0329] Clause 85. The method according to any one of Clauses 76 - 84, wherein a sum of a first vertical distance between the current video block and the reference block, the height of the current video block, and the height of the current template is equal to a second vertical distance between the current template and the reference template.

[0330] Clause 86. The method according to any one of Clauses 16-24, wherein the current template of the current video block and the reference template of the reference block of the current video block are vertical templates, the height of the vertical template is the same as the height of the current video block, and the sample reordering mode includes a vertical flip reordering mode.

[0331] Clause 87. The method according to Clause 86, wherein the current template includes neighboring samples to the left of the current video block, and the reference template includes neighboring samples to the left of the reference block.

[0332] Clause 88. The method according to Clause 86 or Clause 87, wherein the positional difference between the current template and the current video block is the same as the positional difference between the reference template and the reference block.

[0333] Clause 89. The method according to any one of Clauses 86-88, wherein a first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block, and a first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block.

[0334] Clause 90. The method according to Clause 89, wherein the first horizontal distance and the second horizontal distance are the width of the current template or the reference template, and the first vertical distance and the second vertical distance are zero.

[0335] Clause 91. The method according to Clause 89 or Clause 90, wherein the distance between the upper left sample of the current template and the upper left sample of the reference template is the same as the distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0336] Clause 92. The method according to any one of Clauses 86-91, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

[0337] Clause 93. The method according to any one of Clauses 86-92, wherein the flip type of the current video block is vertical flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

[0338] Clause 94. The method according to any one of Clauses 86-93, wherein a vertical distance between the current video block and the reference block is the same as a vertical distance between the current template and the reference template.

[0339] Clause 95. The method according to any one of Clauses 16-24, wherein the current template of the current video block includes a horizontal current template and a vertical current template, the reference template of the reference block of the current video block includes a horizontal reference template and a vertical reference template, and the sample reordering mode includes a vertical flip reordering mode.

[0340] Clause 96. The method according to Clause 95, wherein a width of the horizontal current template and a width of the horizontal reference template are the same as a width of the current video block.

[0341] Clause 97. The method according to Clause 95 or Clause 96, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples below the reference block and neighboring samples to the left of the reference block.

[0342] Clause 98. The method according to any one of Clauses 95-97, wherein a position difference between the horizontal current template and the current video block is different from a position difference between the horizontal reference template and the reference block.

[0343] Clause 99. The method according to any one of Clauses 95-98, wherein a first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as a second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block, and a first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is different from a second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block.

[0344] Clause 100. The method according to Clause 99, wherein the first horizontal distance is zero, and the first vertical distance is a height of the horizontal current template.

[0345] Clause 101. The method according to Clause 99 or Clause 100, wherein the second horizontal distance is zero, and the second vertical distance is a height of the current video block, and the horizontal reference template is below the reference block.

[0346] Clause 102. The method according to any one of Clauses 99-101, wherein the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0347] Clause 103. The method according to any one of Clauses 95-102, wherein the positional difference between the vertical current template and the current video block is the same as the positional difference between the vertical reference template and the reference block.

[0348] Clause 104. The method according to any one of Clauses 95-103, wherein the third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as the fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and the third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as the fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

[0349] Clause 105. The method according to Clause 104, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

[0350] Clause 106. The method according to any one of Clauses 95-105, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0351] Clause 107. The method according to any one of Clauses 95-106, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0352] Clause 108. The method according to any one of Clauses 95-107, wherein the flip type of the current video block is vertical flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0353] Clause 109. The method according to any one of Clauses 95-108, wherein the flip type of the current video block is vertical flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0354] Clause 110. The method according to any one of Clauses 95 - 109, wherein the vertical distance between the horizontal current template and the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the vertical distance between the current video block and the reference block.

[0355] Clause 111. The method according to Clause 95, wherein the width of the horizontal current template is the same as the width of the horizontal reference template, the width of the vertical current template is the same as the width of the vertical reference template, and the width of the horizontal current template is equal to the sum of the width of the current video block and the width of the vertical current template.

[0356] Clause 112. The method according to Clause 111, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples below the reference block and neighboring samples to the left of the reference block.

[0357] Clause 113. The method according to Clause 111 or Clause 112, wherein the positional difference between the horizontal current template and the current video block is different from the positional difference between the horizontal reference template and the reference block.

[0358] Clause 114. The method according to any one of Clauses 111 - 113, wherein the first horizontal distance between the top - left sample of the horizontal current template and the top - left sample of the current video block is the same as the second horizontal distance between the top - left sample of the horizontal reference template and the top - left sample of the reference block, and the first vertical distance between the top - left sample of the horizontal current template and the top - left sample of the current video block is different from the second vertical distance between the top - left sample of the horizontal reference template and the top - left sample of the reference block.

[0359] Clause 115. The method according to Clause 114, wherein the first horizontal distance is the width of the vertical current template, and the first vertical distance is the height of the horizontal current template.

[0360] Clause 116. The method according to Clause 114 or Clause 115, wherein the second horizontal distance is the width of the vertical current template, and the second vertical distance is the height of the current video block, and the horizontal reference template is below the reference block.

[0361] Clause 117. The method according to any one of Clauses 114-116, wherein the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the distance between the upper left sample of the current video block and the upper left sample of the reference block.

[0362] Clause 118. The method according to any one of Clauses 111-117, wherein the positional difference between the vertical current template and the current video block is the same as the positional difference between the vertical reference template and the reference block.

[0363] Clause 119. The method according to any one of Clauses 111-118, wherein a third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as a fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and a third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as a fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

[0364] Clause 120. The method according to Clause 119, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

[0365] Clause 121. The method according to any one of Clauses 111-120, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

[0366] Clause 122. The method according to any one of Clauses 111-121, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

[0367] Clause 123. The method according to any one of Clauses 111-122, wherein the flip type of the current video block is vertical flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

[0368] Clause 124. The method according to any one of Clauses 111-123, wherein the flip type of the current video block is vertical flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

[0369] Clause 125. The method according to any one of Clauses 111 - 124, wherein a vertical distance between the horizontal current template and the horizontal reference template is equal to a sum of a height of the current video block, a height of the horizontal current template, and a vertical distance between the current video block and the reference block.

[0370] Clause 126. A method for video processing, comprising: determining a first set of a plurality of samples in a first template associated with a current video block of a video for conversion between the current video block of the video and a bitstream of the video, wherein the current video block is encoded and decoded using a sample reordering pattern; reordering the first set of the plurality of samples; determining a cost by comparing the first set of the plurality of samples and a second set of a plurality of samples in a second template associated with the current video block; and performing the conversion based on the cost.

[0371] Clause 127. The method according to Clause 126, wherein the first template is a template around the current video block, and the second template is a template around a reference block of the current video block.

[0372] Clause 128. The method according to Clause 126, wherein the first template is a template around a reference block of the current video block, and the second template is a template around the current video block.

[0373] Clause 129. The method according to Clause 127 or Clause 128, wherein the second set of the plurality of samples is not reordered.

[0374] Clause 130. The method according to Clause 127 or Clause 128, wherein the second set of the plurality of samples is reordered before being compared with the first set of the plurality of samples.

[0375] Clause 131. The method according to any one of Clauses 126 - 130, wherein the sample reordering pattern includes one of the following: horizontal flipping or vertical flipping.

[0376] Clause 132. A method for video processing, comprising: determining a sample reordering pattern for the current video block based on at least one of the following for conversion between the current video block of a video and a bitstream of the video: a syntax element in the bitstream, or a template cost of the current video block; and performing the conversion based on the sample reordering pattern.

[0377] Clause 133. The method according to Clause 132, wherein the syntax element indicates information about reordering of samples of the current video block encoded and decoded using a template matching codec tool.

[0378] Clause 134. The method according to Clause 133, wherein the template matching codec tool includes at least one of the following: an intra-frame template matching codec tool, or an intra-block copy (IBC) mode with template matching.

[0379] Clause 135. The method according to any one of Clauses 132-134, wherein the coding and decoding of the syntax element are the same as the coding and decoding of another syntax element, the other syntax element being associated with sample reordering for a video block coded using a prediction mode.

[0380] Clause 136. The method according to Clause 135, wherein the prediction mode includes an intra-block copy (IBC) mode.

[0381] Clause 137. The method according to any one of Clauses 132-134, further comprising: determining a plurality of template costs for a plurality of candidate sample reordering patterns for the current video block; and determining the candidate sample reordering pattern having the minimum template cost as the sample reordering pattern.

[0382] Clause 138. The method according to Clause 137, wherein the plurality of template costs are determined by applying motion search with template matching to the current video block, the template matching having the plurality of candidate sample reordering patterns.

[0383] Clause 139. The method according to any one of Clauses 1-138, further comprising: indicating in the bitstream another information on whether and / or how to apply the method.

[0384] Clause 140. The method according to Clause 139, wherein the another information is indicated at one of the following: sequence level, group of pictures level, picture level, slice level, or tile group level.

[0385] Clause 141. The method according to Clause 139 or Clause 140, wherein the another information is indicated in a sequence header, a picture header, a sequence parameter set (SPS), a video parameter set (VPS), a decoding parameter set (DPS), decoding capability information (DCI), a picture parameter set (PPS), an adaptation parameter set (APS), a slice header, or a tile group header.

[0386] Clause 142. The method according to any one of Clauses 139-141, wherein the another information is indicated in a region containing more than one sample or pixel.

[0387] Clause 143. The method according to Clause 142, wherein the region includes one of the following: a prediction block (PB), a transform block (TB), a coding / decoding block (CB), a prediction unit (PU), a transform unit (TU), a coding / decoding unit (CU), a virtual pipeline data unit (VPDU), a coding / decoding tree unit (CTU), a CTU row, a stripe, a tile, a sub-picture.

[0388] Clause 144. The method according to any one of Clauses 139 - 143, wherein the other information depends on the coded / decoded information.

[0389] Clause 145. The method according to Clause 144, wherein the coded / decoded information includes at least one of the following: a coding / decoding mode, a block size, a color format, a single-tree partition or a double-tree partition, a color component, a stripe type, or a picture type.

[0390] Clause 146. The method according to any one of Clauses 1 - 145, wherein the conversion includes encoding the current video block into the bitstream.

[0391] Clause 147. The method according to any one of Clauses 1 - 145, wherein the conversion includes decoding the current video block from the bitstream.

[0392] Clause 148. An apparatus for processing video data, comprising a processor and a non-transitory memory having instructions thereon, wherein the instructions, when executed by the processor, cause the processor to perform the method according to any one of Clauses 1 - 147.

[0393] Clause 149. A non-transitory computer-readable storage medium storing instructions that cause a processor to perform the method according to any one of Clauses 1 - 147.

[0394] Clause 150. A non-transitory computer-readable recording medium storing a bitstream generated by a method executed by a video processing apparatus, wherein the method includes: determining motion information of a current video block of the video, the current video block being coded / decoded using at least one of: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint indicating a target value of a component of the motion information; and generating the bitstream based on the updated motion information.

[0395] Clause 151. A method for storing a bitstream of a video, comprising: determining motion information of a current video block of the video, the current video block being encoded or decoded using at least one of: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint, the constraint indicating a target value of a component of the motion information; generating the bitstream based on the updated motion information; and storing the bitstream in a non-transitory computer-readable recording medium.

[0396] Clause 152. A non-transitory computer-readable recording medium storing a bitstream of a video generated by a method executed by a video processing device, wherein the method comprises: determining a reference template of a current video block of the video based on encoding or decoding information of the current video block, the current video block being encoded or decoded using a sample reordering mode; and generating the bitstream based on the reference template.

[0397] Clause 153. A method for storing a bitstream of a video, comprising: determining a reference template of a current video block of the video based on encoding or decoding information of the current video block, the current video block being encoded or decoded using a sample reordering mode; generating the bitstream based on the reference template; and storing the bitstream in a non-transitory computer-readable recording medium.

[0398] Clause 154. A non-transitory computer-readable recording medium storing a bitstream of a video generated by a method executed by a video processing device, wherein the method comprises: determining a first set of a plurality of samples in a first template associated with a current video block of the video, the current video block being encoded or decoded using a sample reordering mode; reordering the first set of a plurality of samples; determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; and generating the bitstream based on the cost.

[0399] Clause 155. A method for storing a bitstream of a video, comprising: determining a first set of a plurality of samples in a first template associated with a current video block of the video, the current video block being encoded or decoded using a sample reordering mode; reordering the first set of a plurality of samples; determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; generating the bitstream based on the cost; and storing the bitstream in a non-transitory computer-readable recording medium.

[0400] Clause 156. A non-transitory computer-readable recording medium stores a bitstream generated by a method executed by a video processing device, where the method includes: determining a sample reordering pattern for a current video block of the video based on at least one of: a syntax element in the bitstream, or a template cost of the current video block; and generating the bitstream based on the sample reordering pattern.

[0401] Clause 157. A method for storing a bitstream of a video includes: determining a sample reordering pattern for a current video block of the video based on at least one of: a syntax element in the bitstream, or a template cost of the current video block; generating the bitstream based on the sample reordering pattern; and storing the bitstream in a non-transitory computer-readable recording medium. Example device

[0402] Figure 15 A block diagram of a computing device 1500 is shown in which various embodiments of the present disclosure may be implemented. The computing device 1500 may be implemented as or included in a source device 110 (or video encoder 114 or 200) or a destination device 120 (or video decoder 124 or 300).

[0403] It should be understood that Figure 15 The illustrated computing device 1500 is for illustrative purposes only and does not imply any limitation to the functionality and scope of the embodiments of the present disclosure in any way.

[0404] As Figure 15 As shown, the computing device 1500 includes a general-purpose computing device 1500. The computing device 1500 may include at least one or more processors or processing units 1510, a memory 1520, a storage unit 1530, one or more communication units 1540, one or more input devices 1550, and one or more output devices 1560.

[0405] In some embodiments, the computing device 1500 may be implemented as any user terminal or server terminal having computing capabilities. The server terminal may be a server provided by a service provider, a large computing device, etc. The user terminal may be, for example, any type of mobile terminal, fixed terminal, or portable terminal, including mobile phones, stations, units, devices, multimedia computers, multimedia tablets, Internet nodes, communicators, desktop computers, laptop computers, notebook computers, netbook computers, tablets, personal communication system (PCS) devices, personal navigation devices, personal digital assistants (PDAs), audio / video players, digital cameras / video cameras, positioning devices, television receivers, radio broadcast receivers, e-book devices, gaming devices, or any combination thereof, including accessories and peripherals of these devices or any combination thereof. It is contemplated that the computing device 1500 may support any type of interface with the user (such as a "wearable" circuit, etc.).

[0406] The processing unit 1510 may be a physical or virtual processor and may implement various processes based on programs stored in the memory 1520. In a multi-processor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capabilities of the computing device 1500. The processing unit 1510 may also be referred to as a central processing unit (CPU), microprocessor, controller, or microcontroller.

[0407] The computing device 1500 generally includes various computer storage media. Such media may be any media accessible to the computing device 1500, including but not limited to volatile and non-volatile media, or removable and non-removable media. The memory 1520 may be volatile memory (e.g., registers, caches, random access memory (RAM)), non-volatile memory (e.g., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), or flash memory), or any combination thereof. The storage unit 1530 may be any removable or non-removable media and may include machine-readable media, such as a memory, flash drive, disk, or other media, which may be used to store information and / or data and may be accessed in the computing device 1500.

[0408] The computing device 1500 may also include additional removable / non-removable, volatile / non-volatile storage media. Although Figure 15 not shown, a disk drive for reading and / or writing to a removable and non-volatile disk and an optical disk drive for reading and / or writing to a removable non-volatile optical disk may be provided. In such a case, each drive may be connected to a bus (not shown) via one or more data media interfaces.

[0409] The communication unit 1540 communicates with another computing device via a communication medium. Additionally, the functionality of the components in the computing device 1500 may be implemented by a single computing cluster or multiple computing machines that can communicate via a communication link. Thus, the computing device 1500 may operate in a networked environment using logical connections to one or more other servers, networked personal computers (PCs), or other general network nodes.

[0410] The input device 1550 may be one or more of a variety of input devices, such as a mouse, keyboard, trackball, voice input device, etc. The output device 1560 may be one or more of a variety of output devices, such as a display, speaker, printer, etc. Through the communication unit 1540, the computing device 1500 can also communicate with one or more external devices (not shown), such as a storage device and a display device, where one or more of the devices enable a user to interact with the computing device 1500 or, if needed, any device that enables the computing device 1500 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface (not shown).

[0411] In some embodiments, some or all of the components of the computing device 1500 may also be arranged in a cloud computing architecture rather than integrated in a single device. In a cloud computing architecture, the components may be provided remotely and work together to implement the functions described in the present disclosure. In some embodiments, cloud computing provides computing, software, data access, and storage services, which do not require an end user to know the physical location or configuration of the system or hardware providing these services. In various embodiments, cloud computing uses appropriate protocols to provide services over a wide area network (e.g., the Internet). For example, a cloud computing provider provides applications over a wide area network, and these applications can be accessed via a web browser or any other computing component. The software or components of the cloud computing architecture and the corresponding data may be stored on a server at a remote location. The computing resources in a cloud computing environment may be consolidated or distributed across the locations of remote data centers. The cloud computing infrastructure may provide services through a shared data center, although they act as a single access point for users. Thus, the cloud computing architecture can be used to provide the components and functions described herein from a service provider at a remote location. Alternatively, they may be provided from a conventional server or directly installed or otherwise installed on a client device.

[0412] The computing device 1500 may be used to implement video encoding / decoding in embodiments of the present invention. The memory 1520 may include one or more video codec modules 1525 having one or more program instructions. These modules may be accessed and executed by the processing unit 1510 to perform the functions of the various embodiments described herein.

[0413] In an example embodiment of performing video encoding and decoding, an input device 1550 may receive video data as an input 1570 to be encoded. For example, the video data may be processed by a video codec module 1525 to generate an encoded bitstream. The encoded bitstream may be provided as an output 1580 via an output device 1560.

[0414] In an example embodiment of performing video decoding, an input device 1550 may receive an encoded bitstream as an input 1570. The encoded bitstream may be processed, for example, by a video codec module 1525 to generate decoded video data. The decoded video data may be provided as an output 1580 via an output device 1560.

[0415] Although the present disclosure has been specifically shown and described with reference to its preferred embodiments, those skilled in the art will understand that various changes in form and detail may be made therein without departing from the spirit and scope of the present application as defined by the appended claims. These changes are intended to be covered by the scope of the present application. Therefore, the foregoing description of the embodiments of the present application is not intended to be limiting.

Claims

1. A method for video processing, comprising: Determining motion information of a current video block for conversion between the current video block of a video and a bitstream of the video, the current video block being encoded and decoded using at least one of: an Intra Block Copy (IBC) merge mode, an IBC mode with template matching, or an intra-frame template matching mode; Updating the motion information based on a constraint, the constraint indicating a target value of a component of the motion information; And Performing the conversion based on the updated motion information.

2. The method according to claim 1, wherein the current video block is encoded and decoded using at least one of: an IBC merge mode based on sample reordering, an IBC mode with template matching based on sample reordering, or an intra-frame template matching mode based on sample reordering, and Wherein, updating the motion information based on the constraint includes: Updating a vertical component of the motion information to the target value.

3. The method according to claim 2, wherein samples of the current video block are horizontally flipped.

4. The method according to claim 2 or claim 3, wherein the current video block is encoded and decoded using an IBC mode with template matching based on sample reordering, and template matching of the current video block is searched in a horizontal direction for horizontal flipping.

5. The method according to claim 1, wherein the current video block is encoded and decoded using at least one of: an IBC merge mode based on sample reordering, an IBC mode with template matching based on sample reordering, or an intra-frame template matching mode based on sample reordering, and Wherein updating the motion information according to the constraint includes: Updating a horizontal component of the motion information to the target value.

6. The method according to claim 5, wherein samples of the current video block are vertically flipped.

7. The method according to claim 5 or claim 6, wherein the current video block is encoded and decoded using an IBC mode with template matching based on sample reordering, and template matching of the current video block is searched in a vertical direction for vertical flipping.

8. The method according to claim 1, wherein the current video block is encoded and decoded using at least one of: an IBC merge mode, an IBC mode with template matching, or an intra-frame template matching mode; and Among them, updating the motion information based on the constraint includes: Updating the component of the motion information to the target value.

9. The method according to claim 8, wherein the component of the motion information comprises at least one of: A horizontal component of the motion information, or A vertical component of the motion information.

10. The method according to claim 8 or claim 9, wherein the current video block is encoded and decoded using at least one of: an IBC mode with template matching or an intra-frame template matching mode, and template matching of the current video block is searched in a single direction.

11. The method according to claim 10, wherein the single direction comprises one of: a horizontal direction or a vertical direction.

12. The method according to any one of claims 1-11, wherein the motion information comprises at least one of: A motion vector, A motion vector difference, or A motion vector predictor.

13. The method according to any one of claims 1 - 12, wherein the target value is zero.

14. The method according to any one of claims 1 - 13, wherein the target value is included in the bitstream.

15. The method according to any one of claims 1 - 14, wherein the target value is derived during the conversion.

16. A method for video processing, comprising: determining, for a conversion between a current video block of a video and a bitstream of the video, a reference template of the current video block based on codec information of the current video block, the current video block being coded using a sample reordering mode; and performing the conversion based on the reference template.

17. The method according to claim 16, wherein the codec information includes at least one of the following: a sample reordering type of the sample reordering mode, or a template shape of the reference template.

18. The method according to claim 16 or claim 17, further comprising: determining motion information of the current video block based on the codec information of the current video block.

19. The method according to claim 18, wherein the motion information includes one of the following: a motion vector of the current video block, or a block vector of the current video block.

20. The method according to claim 18 or claim 19, wherein the codec information includes at least one of the following: a sample reordering type of the sample reordering mode, a template shape of the reference template, a size of the current video block, a size of a template of the current video block, a size of a portion of the template, a position of the current video block; or a position of the template.

21. The method according to claim 20, wherein the template of the current video block includes at least one of the following: a current template of the current video block, or the reference template of the current video block.

22. The method according to claim 20 or claim 21, wherein the size of the current video block includes at least one of the following: a width of the current video block; or a height of the current video block.

23. The method according to any one of claims 20 - 22, wherein the size of the template or the size of the portion of the template includes at least one of the following: a width of the template or a width of the portion of the template, or a height of the template or a height of the portion of the template.

24. The method according to any one of claims 20 - 23, wherein the position of the current video block or the position of the template includes at least one of the following: a position of a central sample of the current video block; a position of a central sample of the template, a position of an upper left sample of the current block, or a position of an upper left sample of the template.

25. The method according to any one of claims 16-24, wherein the current template of the current video block and the reference template of the reference block of the current video block are horizontal templates, the width of the horizontal template is the same as the width of the current video block, and the sample reordering mode includes a horizontal flip reordering mode.

26. The method according to claim 25, wherein the current template includes neighboring samples above the current video block, and the reference template includes neighboring samples above the reference block.

27. The method according to claim 25 or claim 26, wherein the positional difference between the current template and the current video block is the same as the positional difference between the reference template and the reference block.

28. The method according to any one of claims 25-27, wherein a first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block, and a first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block.

29. The method according to claim 28, wherein the first horizontal distance and the second horizontal distance are zero, and the first vertical distance and the second vertical distance are the height of the current template or the reference template.

30. The method according to claim 28 or claim 29, wherein the distance between the upper left sample of the current template and the upper left sample of the reference template is the same as the distance between the upper left sample of the current video block and the upper left sample of the reference block.

31. The method according to any one of claims 25-30, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

32. The method according to any one of claims 25-31, wherein the flip type of the current video block is horizontal flip, and at least one of the samples in the current template or the samples in the reference template is flipped.

33. The method according to any one of claims 25-32, wherein the horizontal distance between the current video block and the reference block is the same as the horizontal distance between the current template and the reference template.

34. The method according to any one of claims 16-24, wherein the current template of the current video block and the reference template of the reference block of the current video block are vertical templates, the height of the vertical template is the same as the height of the current video block, and the sample reordering mode includes a horizontal flip reordering mode.

35. The method according to claim 34, wherein the current template includes neighboring samples to the left of the current video block, and the reference template includes neighboring samples to the right of the reference block.

36. The method according to claim 34 or claim 35, wherein a positional difference between the current template and the current video block is different from a positional difference between the reference template and the reference block.

37. The method according to any one of claims 34-36, wherein a first horizontal distance between the top-left sample of the current template and the top-left sample of the current video block is different from a second horizontal distance between the top-left sample of the reference template and the top-left sample of the reference block, and a first vertical distance between the top-left sample of the current template and the top-left sample of the current video block is the same as a second vertical distance between the top-left sample of the reference template and the top-left sample of the reference block.

38. The method according to claim 37, wherein the first horizontal distance is the width of the current template, and the first vertical distance is zero.

39. The method according to claim 37 or claim 38, wherein the second horizontal distance is the width of the current video block, the reference template is on the right side of the reference block, and the second vertical distance is zero.

40. The method according to any one of claims 37-39, wherein a sum of a first distance between the top-left sample of the current template and the top-left sample of the reference template, the width of the current video block, and the width of the current template is equal to a second distance between the top-left sample of the current video block and the top-left sample of the reference block.

41. The method according to any one of claims 34-40, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

42. The method according to any one of claims 34-41, wherein a flip type of the current video block is horizontal flipping, and at least one of the samples in the current template or the samples in the reference template is flipped.

43. The method according to any one of claims 34-42, wherein a sum of a first horizontal distance between the current video block and the reference block, the width of the current video block, and the width of the current template is equal to a second horizontal distance between the current template and the reference template.

44. The method according to any one of claims 16-24, wherein the current template of the current video block includes a horizontal current template and a vertical current template, the reference template of the reference block of the current video block includes a horizontal reference template and a vertical reference template, and the sample reordering mode includes a horizontal flip reordering mode.

45. The method according to claim 44, wherein the width of the horizontal current template and the width of the horizontal reference template are the same as the width of the current video block.

46. The method according to claim 44 or claim 45, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples above the reference block and neighboring samples to the right of the reference block.

47. The method according to any one of claims 44 - 46, wherein a positional difference between the horizontal reference template and the current video block is the same as a positional difference between the horizontal reference template and the reference block.

48. The method according to any one of claims 44 - 47, wherein a first horizontal distance between the top - left sample of the horizontal current template and the top - left sample of the current video block is the same as a second horizontal distance between the top - left sample of the horizontal reference template and the top - left sample of the reference block, and a first vertical distance between the top - left sample of the horizontal current template and the top - left sample of the current video block is the same as a second vertical distance between the top - left sample of the horizontal reference template and the top - left sample of the reference block.

49. The method according to claim 48, wherein the first horizontal distance is zero, and the first vertical distance is the height of the horizontal current template.

50. The method according to claim 48 or claim 49, wherein a distance between the top - left sample of the horizontal current template and the top - left sample of the horizontal reference template is equal to a distance between the top - left sample of the current video block and the top - left sample of the reference block.

51. The method according to any one of claims 44 - 50, wherein a positional difference between the vertical current template and the current video block is different from a positional difference between the vertical reference template and the reference block.

52. The method according to any one of claims 44 - 51, wherein a third horizontal distance between the top - left sample of the vertical current template and the top - left sample of the current video block is different from a fourth horizontal distance between the top - left sample of the vertical reference template and the top - left sample of the reference block, and a third vertical distance between the top - left sample of the vertical current template and the top - left sample of the current video block is the same as a fourth vertical distance between the top - left sample of the vertical reference template and the top - left sample of the reference block.

53. The method according to claim 52, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

54. The method according to claim 52 or claim 53, wherein the fourth horizontal distance is the width of the current video block, the vertical reference template is on the right side of the reference block, and the fourth vertical distance is zero.

55. The method according to any one of claims 44 - 54, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

56. The method according to any one of claims 44 - 55, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

57. The method according to any one of claims 44 - 56, wherein a flip type of the current video block is horizontal flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

58. The method according to any one of claims 44 - 57, wherein the flipping type of the current video block is horizontal flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

59. The method according to any one of claims 44 - 58, wherein the horizontal distance between the current video block and the reference block is equal to the horizontal distance between the horizontal current template and the horizontal reference template.

60. The method according to claim 44, wherein the width of the horizontal current template is the same as the width of the horizontal reference template, the width of the vertical current template is the same as the width of the vertical reference template, and the width of the horizontal reference template is equal to the sum of the width of the current video block and the width of the vertical current template.

61. The method according to claim 60, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples above the reference block and neighboring samples to the right of the reference block.

62. The method according to claim 60 or claim 61, wherein the positional difference between the horizontal current template and the current video block is different from the positional difference between the horizontal reference template and the reference block.

63. The method according to any one of claims 60 - 62, wherein the first horizontal distance between the upper - left sample of the horizontal current template and the upper - left sample of the current video block is different from the second horizontal distance between the upper - left sample of the horizontal reference template and the upper - left sample of the reference block, and the first vertical distance between the upper - left sample of the horizontal current template and the upper - left sample of the current video block is the same as the second vertical distance between the upper - left sample of the horizontal reference template and the upper - left sample of the reference block.

64. The method according to claim 63, wherein the first horizontal distance is the width of the vertical current template, and the first vertical distance is the height of the horizontal current template.

65. The method according to claim 63 or claim 64, wherein the second horizontal distance is zero, and the second vertical distance is the height of the horizontal current template.

66. The method according to any one of claims 63 - 65, wherein the distance between the upper - left sample of the horizontal current template and the upper - left sample of the horizontal reference template is equal to the sum of the width of the vertical current template and the distance between the upper - left sample of the current video block and the upper - left sample of the reference block.

67. The method according to any one of claims 60 - 66, wherein the positional difference between the vertical current template and the current video block is different from the positional difference between the vertical reference template and the reference block.

68. The method according to any one of claims 60 - 67, wherein a third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is different from a fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and a third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as a fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

69. The method according to claim 68, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

70. The method according to claim 68 or claim 69, wherein the fourth horizontal distance is the width of the current video block, the vertical reference template is on the right side of the reference block, and the fourth vertical distance is zero.

71. The method according to any one of claims 60 - 70, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

72. The method according to any one of claims 60 - 71, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

73. The method according to any one of claims 60 - 72, wherein a flip type of the current video block is horizontal flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

74. The method according to any one of claims 60 - 73, wherein a flip type of the current video block is horizontal flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

75. The method according to any one of claims 60 - 74, wherein a horizontal distance between the horizontal current template and the horizontal reference template is equal to a sum of the width of the vertical current template and a horizontal distance between the current video block and the reference block.

76. The method according to any one of claims 16 - 24, wherein the current template of the current video block and the reference template of the reference block of the current video block are horizontal templates, a width of the horizontal template is the same as a width of the current video block, and the sample reordering mode includes a vertical flip reordering mode.

77. The method according to claim 76, wherein the current template includes neighboring samples above the current video block, and the reference template includes neighboring samples below the reference block.

78. The method according to claim 76 or claim 77, wherein a positional difference between the current template and the current video block is different from a positional difference between the reference template and the reference block.

79. The method according to any one of claims 76 - 78, wherein a first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block, and a first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is different from a second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block.

80. The method according to claim 79, wherein the first horizontal distance is zero, and the first vertical distance is the height of the current template.

81. The method according to claim 79 or claim 80, wherein the second horizontal distance is zero, and the second vertical distance is the height of the current video block, and the reference template is below the reference block.

82. The method according to any one of claims 79 - 81, wherein a sum of a first distance between the upper left sample of the current template and the upper left sample of the reference template, the height of the current video block, and the height of the current template is equal to a second distance between the upper left sample of the current video block and the upper left sample of the reference block.

83. The method according to any one of claims 76 - 82, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

84. The method according to any one of claims 76 - 83, wherein a flip type of the current video block is vertical flipping, and at least one of the samples in the current template or the samples in the reference template is flipped.

85. The method according to any one of claims 76 - 84, wherein a sum of a first vertical distance between the current video block and the reference block, the height of the current video block, and the height of the current template is equal to a second vertical distance between the current template and the reference template.

86. The method according to any one of claims 16 - 24, wherein the current template of the current video block and the reference template of the reference block of the current video block are vertical templates, a height of the vertical template is the same as a height of the current video block, and the sample reordering mode includes a vertical flipping reordering mode.

87. The method according to claim 86, wherein the current template includes neighboring samples on the left side of the current video block, and the reference template includes neighboring samples on the left side of the reference block.

88. The method according to claim 86 or claim 87, wherein a position difference between the current template and the current video block is the same as a position difference between the reference template and the reference block.

89. The method according to any one of claims 86 - 88, wherein a first horizontal distance between the upper left sample of the current template and the upper left sample of the current video block is the same as a second horizontal distance between the upper left sample of the reference template and the upper left sample of the reference block, and The first vertical distance between the upper left sample of the current template and the upper left sample of the current video block is the same as the second vertical distance between the upper left sample of the reference template and the upper left sample of the reference block.

90. The method according to claim 89, wherein the first horizontal distance and the second horizontal distance are the widths of the current template or the reference template, and the first vertical distance and the second vertical distance are zero.

91. The method according to claim 89 or claim 90, wherein the distance between the upper left sample of the current template and the upper left sample of the reference template is the same as the distance between the upper left sample of the current video block and the upper left sample of the reference block.

92. The method according to any one of claims 86-91, wherein at least one of the samples in the current template or the samples in the reference template is flipped.

93. The method according to any one of claims 86-92, wherein the flip type of the current video block is vertical flipping, and at least one of the samples in the current template or the samples in the reference template is flipped.

94. The method according to any one of claims 86-93, wherein the vertical distance between the current video block and the reference block is the same as the vertical distance between the current template and the reference template.

95. The method according to any one of claims 16-24, wherein the current template of the current video block includes a horizontal current template and a vertical current template, the reference template of the reference block of the current video block includes a horizontal reference template and a vertical reference template, and the sample reordering mode includes a vertical flip reordering mode.

96. The method according to claim 95, wherein the widths of the horizontal current template and the horizontal reference template are the same as the width of the current video block.

97. The method according to claim 95 or claim 96, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples below the reference block and neighboring samples to the left of the reference block.

98. The method according to any one of claims 95-97, wherein the position difference between the horizontal current template and the current video block is different from the position difference between the horizontal reference template and the reference block.

99. The method according to any one of claims 95-98, wherein the first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block, and the first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is different from the second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block.

100. The method according to claim 99, wherein the first horizontal distance is zero, and the first vertical distance is the height of the horizontal current template.

101. The method according to claim 99 or claim 100, wherein the second horizontal distance is zero, and the second vertical distance is the height of the current video block, and the horizontal reference template is below the reference block.

102. The method according to any one of claims 99 - 101, wherein the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the distance between the upper left sample of the current video block and the upper left sample of the reference block.

103. The method according to any one of claims 95 - 102, wherein the positional difference between the vertical current template and the current video block is the same as the positional difference between the vertical reference template and the reference block.

104. The method according to any one of claims 95 - 103, wherein the third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as the fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and the third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as the fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

105. The method according to claim 104, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

106. The method according to any one of claims 95 - 105, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

107. The method according to any one of claims 95 - 106, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

108. The method according to any one of claims 95 - 107, wherein the flip type of the current video block is vertical flip, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

109. The method according to any one of claims 95 - 108, wherein the flip type of the current video block is vertical flip, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

110. The method according to any one of claims 95 - 109, wherein the vertical distance between the horizontal current template and the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the vertical distance between the current video block and the reference block.

111. The method according to claim 95, wherein the width of the horizontal current template is the same as the width of the horizontal reference template, the width of the vertical current template is the same as the width of the vertical reference template, and the width of the horizontal current template is equal to the sum of the width of the current video block and the width of the vertical current template.

112. The method according to claim 111, wherein the current template includes neighboring samples above the current video block and neighboring samples to the left of the current video block, and the reference template includes neighboring samples below the reference block and neighboring samples to the left of the reference block.

113. The method according to claim 111 or claim 112, wherein the positional difference between the horizontal current template and the current video block is different from the positional difference between the horizontal reference template and the reference block.

114. The method according to any one of claims 111 - 113, wherein the first horizontal distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is the same as the second horizontal distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block, and the first vertical distance between the upper left sample of the horizontal current template and the upper left sample of the current video block is different from the second vertical distance between the upper left sample of the horizontal reference template and the upper left sample of the reference block.

115. The method according to claim 114, wherein the first horizontal distance is the width of the vertical current template, and the first vertical distance is the height of the horizontal current template.

116. The method according to claim 114 or claim 115, wherein the second horizontal distance is the width of the vertical current template, and the second vertical distance is the height of the current video block, and the horizontal reference template is below the reference block.

117. The method according to any one of claims 114 - 116, wherein the distance between the upper left sample of the horizontal current template and the upper left sample of the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the distance between the upper left sample of the current video block and the upper left sample of the reference block.

118. The method according to any one of claims 111 - 117, wherein the positional difference between the vertical current template and the current video block is the same as the positional difference between the vertical reference template and the reference block.

119. The method according to any one of claims 111 - 118, wherein the third horizontal distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as the fourth horizontal distance between the upper left sample of the vertical reference template and the upper left sample of the reference block, and The third vertical distance between the upper left sample of the vertical current template and the upper left sample of the current video block is the same as the fourth vertical distance between the upper left sample of the vertical reference template and the upper left sample of the reference block.

120. The method according to claim 119, wherein the third horizontal distance is the width of the vertical current template, and the third vertical distance is zero.

121. The method according to any one of claims 111-120, wherein at least one of the samples in the horizontal current template or the samples in the horizontal reference template is flipped.

122. The method according to any one of claims 111-121, wherein at least one of the samples in the vertical current template or the samples in the vertical reference template is flipped.

123. The method according to any one of claims 111-122, wherein the flip type of the current video block is vertical flipping, and the samples in the horizontal current template and the samples in the vertical current template are flipped.

124. The method according to any one of claims 111-123, wherein the flip type of the current video block is vertical flipping, and the samples in the horizontal reference template and the samples in the vertical reference template are flipped.

125. The method according to any one of claims 111-124, wherein the vertical distance between the horizontal current template and the horizontal reference template is equal to the sum of the height of the current video block, the height of the horizontal current template, and the vertical distance between the current video block and the reference block.

126. A method for video processing, comprising: Determining, for the conversion between a current video block of a video and a bitstream of the video, a first set of a plurality of samples in a first template associated with the current video block, wherein the current video block is encoded and decoded using a sample reordering pattern; Reordering the first set of a plurality of samples; Determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; and Performing the conversion based on the cost.

127. The method according to claim 126, wherein the first template is a template around the current video block, and the second template is a template around a reference block of the current video block.

128. The method according to claim 126, wherein the first template is a template around a reference block of the current video block, and the second template is a template around the current video block.

129. The method according to claim 127 or claim 128, wherein the second set of a plurality of samples is not reordered.

130. The method according to claim 127 or claim 128, wherein the second set of a plurality of samples is reordered before being compared with the first set of a plurality of samples.

131. The method according to any one of claims 126-130, wherein the sample reordering pattern includes one of the following: horizontal flipping or vertical flipping.

132. A method for video processing, comprising: Determining a sample reordering pattern for a current video block of a video based on at least one of the following for a conversion between the current video block of the video and a bitstream of the video: A syntax element in the bitstream, or A template cost of the current video block; and Performing the conversion based on the sample reordering pattern.

133. The method according to claim 132, wherein the syntax element indicates information about reordering of samples of the current video block decoded using a template matching codec tool.

134. The method according to claim 133, wherein the template matching codec tool comprises at least one of the following: An intra-frame template matching codec tool, or An intra-block copy (IBC) mode with template matching.

135. The method according to any one of claims 132-134, wherein the decoding and encoding of the syntax element are the same as those of another syntax element associated with reordering of samples of a video block decoded using a prediction mode.

136. The method according to claim 135, wherein the prediction mode comprises an intra-block copy (IBC) mode.

137. The method according to any one of claims 132-134, further comprising: Determining a plurality of template costs for a plurality of candidate sample reordering patterns for the current video block; And Determining the candidate sample reordering pattern having the minimum template cost as the sample reordering pattern.

138. The method according to claim 137, wherein the plurality of template costs are determined by applying a motion search with template matching to the current video block, the template matching having the plurality of candidate sample reordering patterns.

139. The method according to any one of claims 1-138, further comprising: Indicating in the bitstream another information about whether and / or how to apply the method.

140. The method according to claim 139, wherein the another information is indicated at one of the following: sequence level, picture group level, picture level, slice level, or tile group level.

141. The method according to claim 139 or claim 140, wherein the another information is indicated in a sequence header, an image header, a sequence parameter set (SPS), a video parameter set (VPS), a decoding parameter set (DPS), decoding capability information (DCI), an image parameter set (PPS), an adaptation parameter set (APS), a slice header, or a tile group header.

142. The method according to any one of claims 139-141, wherein the another information is indicated in a region containing more than one sample or pixel.

143. The method according to claim 142, wherein the region includes one of the following: a prediction block (PB), a transform block (TB), a coding / decoding block (CB), a prediction unit (PU), a transform unit (TU), a coding / decoding unit (CU), a virtual pipeline data unit (VPDU), a coding / decoding tree unit (CTU), a CTU row, a stripe, a tile, a sub-picture.

144. The method according to any one of claims 139 - 143, wherein the other information depends on the coded / decoded information.

145. The method according to claim 144, wherein the coded / decoded information includes at least one of the following: a coding / decoding mode, a block size, a color format, a single-tree partition or a dual-tree partition, a color component, a stripe type or a picture type.

146. The method according to any one of claims 1 - 145, wherein the conversion includes encoding the current video block into the bitstream.

147. The method according to any one of claims 1 - 145, wherein the conversion includes decoding the current video block from the bitstream.

148. An apparatus for processing video data, comprising a processor and a non-transitory memory having instructions thereon, wherein the instructions, when executed by the processor, cause the processor to perform the method according to any one of claims 1 - 147.

149. A non-transitory computer-readable storage medium storing instructions that cause a processor to perform the method according to any one of claims 1 - 147.

150. A non-transitory computer-readable recording medium storing a bitstream generated by a method executed by a video processing apparatus for a video, wherein the method includes: determining motion information of a current video block of the video, the current video block being coded / decoded using at least one of: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint indicating a target value of a component of the motion information; and generating the bitstream based on the updated motion information.

151. A method for storing a bitstream of a video, comprising: determining motion information of a current video block of the video, the current video block being coded / decoded using at least one of: an intra block copy (IBC) merge mode, an IBC mode with template matching, or an intra template matching mode; updating the motion information based on a constraint indicating a target value of a component of the motion information; generating the bitstream based on the updated motion information; and storing the bitstream in a non-transitory computer-readable recording medium.

152. A non-transitory computer-readable recording medium storing a bitstream generated by a method executed by a video processing apparatus for a video, wherein the method includes: determining a reference template of the current video block based on coding / decoding information of the current video block of the video, the current video block being coded / decoded using a sample reordering mode; and generating the bitstream based on the reference template.

153. A method for storing a bitstream of a video, comprising: determining a reference template for a current video block of the video based on codec information of the current video block, the current video block being coded and decoded using a sample reordering mode; generating the bitstream based on the reference template; and storing the bitstream in a non-transitory computer-readable recording medium.

154. A non-transitory computer-readable recording medium storing a bitstream generated by a method executed by a video processing device for a video, wherein the method comprises: determining a first set of a plurality of samples in a first template associated with a current video block of the video, the current video block being coded and decoded using a sample reordering mode; reordering the first set of a plurality of samples; determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; and generating the bitstream based on the cost.

155. A method for storing a bitstream of a video, comprising: determining a first set of a plurality of samples in a first template associated with a current video block of the video, the current video block being coded and decoded using a sample reordering mode; reordering the first set of a plurality of samples; determining a cost by comparing the first set of a plurality of samples with a second set of a plurality of samples in a second template associated with the current video block; generating the bitstream based on the cost; and storing the bitstream in a non-transitory computer-readable recording medium.

156. A non-transitory computer-readable recording medium storing a bitstream generated by a method executed by a video processing device for a video, wherein the method comprises: determining a sample reordering mode for a current video block of the video based on at least one of: syntax elements in the bitstream, or a template cost of the current video block; and generating the bitstream based on the sample reordering mode.

157. A method for storing a bitstream of a video, comprising: determining a sample reordering mode for a current video block of the video based on at least one of: syntax elements in the bitstream, or a template cost of the current video block; generating the bitstream based on the sample reordering mode; and storing the bitstream in a non-transitory computer-readable recording medium.