Method and device for video processing and medium
By determining the conversion between the video unit and its bitstream in the video processing and determining whether the template-based processing is applied, the problem of insufficient video encoding and decoding efficiency in the prior art is solved, and more efficient video encoding and decoding is achieved.
Patent Information
- Application Number
- CN202380046046.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-06-10
- Filing Date
- 2023-06-10
- Publication Date
- 2025-02-14
Smart Images

Figure CN119452652A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate generally to video processing techniques, and more particularly to the interaction of reconstruction reordered intra block copy (IBC) (RRIBC) and template-based methods in image / video codecs. Background Art
[0002] Nowadays, digital video capabilities are being applied to all aspects of people's lives. Various types of video compression technologies, such as MPEG-2, MPEG-4, ITU-TH.263, ITU-TH.264 / MPEG-4 Part 10 Advanced Video Codec (AVC), ITU-TH.265 High Efficiency Video Codec (HEVC) standard, and Versatile Video Codec (VVC) standard have been proposed for video encoding / decoding. However, it is generally expected to further improve the encoding and decoding efficiency of video encoding and decoding technologies. Summary of the invention
[0003] The embodiments of the present disclosure provide a solution for video processing.
[0004] In a first aspect, a method for video processing is provided. The method includes: for conversion between a video unit of a video and a bitstream of the video unit, determining whether template-based processing is applied to the video unit, wherein the template-based processing is based on at least one template of at least one of the following: a current picture or a reference picture of the video unit; and performing conversion based on the determination. Compared with conventional techniques, it can improve encoding and decoding efficiency.
[0005] In a second aspect, a device for video processing is provided. The device includes a processor and a non-volatile memory having instructions thereon. The instructions, when executed by the processor, cause the processor to perform the method according to the first aspect of the present disclosure.
[0006] In a third aspect, a non-transitory computer-readable storage medium is provided. The non-transitory computer-readable storage medium stores instructions, which enable a processor to execute the method according to the first aspect of the present disclosure.
[0007] In a fourth 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 performed by an apparatus for video processing. The method includes: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; and generating a bitstream based on the determination.
[0008] In a fifth aspect, a method for storing a bitstream of a video is provided. The method includes: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; generating a bitstream based on the determination; and storing the bitstream in a non-transitory computer-readable recording medium.
[0009] This disclosure is provided to introduce a selection of concepts in a simplified form, which are further described below in the 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
[0010] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become more apparent through 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.
[0011] Figure 1 A block diagram showing an example video encoding and decoding system according to some embodiments of the present disclosure is shown;
[0012] Figure 2 A block diagram of a first example video encoder according to some embodiments of the present disclosure is shown;
[0013] Figure 3 A block diagram of an example video decoder according to some embodiments of the present disclosure is shown;
[0014] Figure 4 The current CTU processing order and the available samples in the current CTU and the left CTU are shown;
[0015] Figure 5 The transform skip residual encoding and decoding process is shown;
[0016] Figure 6 An example of a block encoded and decoded in palette mode is shown;
[0017] Figure 7 An example sub-block based index map scan for a palette is shown, on the left for horizontal scanning and on the right for vertical scanning;
[0018] Figure 8 An example decoding flow chart with ACT is shown;
[0019] Fig. 9 shows an example intra-frame template matching search area used;
[0020] Fig.10 shows the IBC reference area depending on the current CU position;
[0021] Fig.11A BV adjustment for horizontal flipping is shown;
[0022] Fig. 11B BV adjustment for vertical flip is shown;
[0023] Fig.12 Shows spatial candidates for IBC merge / AMVP candidate list;
[0024] Fig.13 A template and a reference sample for the template are shown;
[0025] Fig.14A A schematic diagram showing a first example of template matching based on sample reordering;
[0026] Fig. 14B A schematic diagram showing a second example of template matching based on sample reordering;
[0027] Fig. 14C A schematic diagram showing a third example of template matching based on sample reordering;
[0028] Fig.14D A schematic diagram showing a fourth example of template matching based on sample reordering;
[0029] Fig.14E A schematic diagram showing a fifth example of template matching based on sample reordering;
[0030] Fig.14F A schematic diagram showing a sixth example of template matching based on sample reordering;
[0031] Figure 14G A schematic diagram showing a seventh example of template matching based on sample reordering;
[0032] Fig.14H A schematic diagram showing an eighth example of template matching based on sample reordering;
[0033] Fig.15A shows a reference template and a current template for template cost calculation when the motion candidate is RRIBC codec, where the motion candidate is RRIBC codec with horizontal flip;
[0034] Fig. 15B shows a reference template and a current template for template cost calculation when the motion candidate is RRIBC codec, where the motion candidate is decoded using vertical flip RRIBC codec;
[0035] Fig.16A flowchart showing a method for video processing according to an embodiment of the present disclosure is shown; and
[0036] Fig.17 A block diagram of a computing device is shown in which various embodiments of the present disclosure may be implemented.
[0037] Throughout the drawings, same or similar reference numbers generally refer to same or similar elements. DETAILED DESCRIPTION
[0038] The principle of the present disclosure will now be described with reference to some embodiments. It should be understood that these embodiments are described only for the purpose of illustrating and helping those skilled in the art to understand and implement the present disclosure, and do not imply any limitation on the scope of the present disclosure. In addition to the methods described below, the disclosure described herein can also be implemented in various ways.
[0039] In the following description and claims, unless defined otherwise, 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 belongs.
[0040] References in this disclosure to "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 must include the particular feature, structure, or characteristic. Furthermore, these phrases do not necessarily refer to the same embodiment. Furthermore, when a particular feature, structure, or characteristic is described in conjunction with an example embodiment, whether or not explicitly described, it is considered to be within the knowledge of those skilled in the art to affect such feature, structure, or characteristic in relation to other embodiments.
[0041] It should be understood that although the terms "first" and "second" etc. can be used to describe various elements, these elements should not be limited to these terms. These terms are only used to distinguish one element from another element. For example, a first element can be referred to as a second element, and similarly, a second element can be referred to as a first element without departing from the scope of the exemplary embodiments. As used herein, the term "and / or" includes any and all combinations of one or more of the listed terms.
[0042] The terms used herein are only used for the purpose of describing specific embodiments and are not intended to limit the exemplary 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", "includes", and / or "having" when used herein indicate the presence of the features, elements, and / or components, etc., but do not exclude the presence or addition of one or more other features, elements, components, and / or combinations thereof. Example Environment
[0043] Figure 1 1 is a block diagram illustrating an example video codec system 100 that may utilize the techniques of the present disclosure. As shown, the video codec 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.
[0044] Video source 112 may include a source such as a video capture device. Examples of a video capture device include, but are not limited to, an interface that receives video data from a video content provider, a computer graphics system for generating video data, and / or combinations thereof.
[0045] The video data may include one or more pictures. The video encoder 114 encodes the video data from the video source 112 to generate a bit stream. The bit stream may include a bit sequence that forms a coded representation of the video data. The bit stream may include coded pictures and associated data. The coded pictures are coded representations of pictures. The associated data may include sequence parameter sets, picture parameter sets, and other grammatical structures. The I / O interface 116 may include a modulator / demodulator and / or a transmitter. The coded video data may be directly transmitted to the destination device 120 via the network 130A via the I / O interface 116. The coded video data may also be stored on a storage medium / server 130B for access by the destination device 120.
[0046] The destination device 120 may include an I / O interface 126, a video decoder 124, and a display device 122. The I / O interface 126 may include a receiver and / or a modem. The I / O interface 126 may obtain encoded video data from the source device 110 or the storage medium / server 130B. The video decoder 124 may decode the encoded video data. The display device 122 may display the decoded video data to the user. The display device 122 may be integrated with the destination device 120, or may be outside the destination device 120, which is configured to be connected to an external display device interface.
[0047] The video encoder 114 and the video decoder 124 may operate according to a video compression standard, such as the High Efficiency Video Codec (HEVC) standard, the Versatile Video Codec (VVC) standard, and other existing and / or further standards.
[0048] Figure 2 is a block diagram showing an example of a video encoder 200 according to some embodiments of the present disclosure, which may be Figure 1 An example of a video encoder 114 in the system 100 is shown.
[0049] Video encoder 200 may be configured to implement any or all of the techniques of this disclosure. Figure 2 In the example of , video encoder 200 includes multiple functional components. The techniques described in this disclosure can be shared between the various components of video encoder 200. In some examples, a processor can be configured to perform any or all of the techniques described in this disclosure.
[0050] 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 coding unit 214, and the prediction unit 202 may include a mode selection unit 203, a motion estimation unit 204, a motion compensation unit 205 and an intra-frame prediction unit 206.
[0051] 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 intra-block copy (IBC) unit. The IBC unit may perform prediction in an IBC mode, where at least one reference picture is a picture where the current video block is located.
[0052] Furthermore, although some components (such as the motion estimation unit 204 and the motion compensation unit 205) may be integrated, for the purpose of explanation, these components are described in detail below. Figure 2 are shown separately in the example.
[0053] 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.
[0054] The mode selection unit 203 may select one of a plurality of codec modes (intra-frame coding or inter-frame coding), for example, based on the error result, and provide the generated intra-frame codec block or inter-frame codec block to the residual generation unit 207 to generate residual block data, and to the reconstruction unit 212 to reconstruct the codec block for use as a reference picture. In some examples, the mode selection unit 203 may select a combination of intra-frame and inter-frame prediction (CIIP) modes, where the prediction is based on an inter-frame prediction signal and an intra-frame prediction signal. In the case of inter-frame prediction, the mode selection unit 203 may also select a resolution for the motion vector (e.g., sub-pixel precision or integer pixel precision) for the block.
[0055] To perform inter-frame prediction on the current video block, the motion estimation unit 204 may generate motion information for the current video block by comparing the current video block with one or more reference frames from the buffer 213. 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 pictures from the buffer 213 other than the picture associated with the current video block.
[0056] The motion estimation unit 204 and the motion compensation unit 205 may perform different operations on the current video block, for example, 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 consisting of macroblocks, all of which are based on macroblocks within the same picture. Furthermore, as used herein, in some aspects, a "P slice" and a "B slice" may refer to a portion of a picture consisting of macroblocks that are independent of macroblocks in the same picture.
[0057] In some examples, the motion estimation unit 204 may perform unidirectional prediction on the current video block, and the motion estimation unit 204 may search the reference pictures of list 0 or list 1 to find the reference video block for the current video block. The motion estimation unit 204 may then generate a reference index and a motion vector, the reference index indicating the reference picture in list 0 or list 1 containing the reference video block, and the motion vector indicating 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.
[0058] Alternatively, in other examples, the motion estimation unit 204 may perform bidirectional prediction on the current video block. The motion estimation unit 204 may search the reference pictures in list 0 for a reference video block for the current video block, and may also search the reference pictures in list 1 for another reference video block for the current video block. The motion estimation unit 204 may then generate a plurality of reference indexes and a plurality of motion vectors, the plurality of reference indexes indicating a plurality of reference pictures in list 0 and list 1 containing a plurality of reference video blocks, and the plurality of motion vectors indicating a plurality of spatial displacements between the plurality of reference video blocks and the current video block. The motion estimation unit 204 may output the plurality of reference indexes and the plurality of motion vectors of the current video block as 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 plurality of reference video blocks indicated by the motion information of the current video block.
[0059] In some examples, motion estimation unit 204 may output a complete set of motion information for use in a decoding process by a decoder. Alternatively, in some embodiments, motion estimation unit 204 may signal motion information of a current video block with reference to motion information of another video block. For example, motion estimation unit 204 may determine that motion information of a current video block is sufficiently similar to motion information of a neighboring video block.
[0060] In one example, motion estimation unit 204 may indicate to video decoder 300 a value in a syntax structure associated with the current video block that indicates that the current video block has the same motion information as another video block.
[0061] 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.
[0062] As discussed above, the video encoder 200 may signal motion vectors in a predictive manner.Two examples of prediction signaling techniques that may be implemented by the video encoder 200 include Advanced Motion Vector Prediction (AMVP) and merge mode signaling.
[0063] 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 decoded samples of other video blocks in the same picture. The prediction data for the current video block may include a prediction video block and various syntax elements.
[0064] The residual generation unit 207 may generate residual data for the current video block by subtracting (e.g., indicated by a minus sign) the prediction video block(s) 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 samples in the current video block.
[0065] In other examples, such as in skip mode, there may be no residual data for the current video block, and the residual generation unit 207 may not perform a subtraction operation.
[0066] Transform processing unit 208 may generate one or more transform coefficient video blocks for a current video block by applying one or more transforms to the residual video block associated with the current video block.
[0067] After transform processing unit 208 generates a transform coefficient video block associated with the current video block, 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.
[0068] The inverse quantization unit 210 and the inverse transform unit 211 may apply inverse quantization and inverse transform to the transform coefficient video block, respectively, to reconstruct a residual video block from the transform coefficient video block. The reconstruction unit 212 may add the reconstructed residual video block to corresponding samples from one or more prediction 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.
[0069] After reconstruction unit 212 reconstructs the video block, a loop filtering operation may be performed to reduce video blocking artifacts in the video block.
[0070] The entropy coding unit 214 may receive data from other functional components of the video encoder 200. When the entropy coding unit 214 receives data, the entropy coding unit 214 may perform one or more entropy coding operations to generate entropy-coded data and output a bitstream including the entropy-coded data.
[0071] Figure 3 is a block diagram showing an example of a video decoder 300 according to some embodiments of the present disclosure, which may be Figure 1 An example of a video decoder 124 in the system 100 is shown.
[0072] Video decoder 300 may be configured to perform any or all of the techniques of this disclosure. Figure 3 In the example of , video decoder 300 includes multiple functional components. The techniques described in this disclosure can be shared between the various components of video decoder 300. In some examples, a processor can be configured to perform any or all of the techniques described in this disclosure.
[0073] exist Figure 3 In the example of , 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 that is generally opposite to the encoding process described with respect to the video encoder 200.
[0074] The entropy decoding unit 301 can retrieve the encoded bitstream. The encoded bitstream may include entropy encoded video data (e.g., encoded video data blocks). The entropy decoding unit 301 can decode the entropy encoded and decoded video data, and the motion compensation unit 302 can determine motion information from the entropy decoded video data, the motion information including motion vectors, motion vector precision, reference picture list indexes, and other motion information. The motion compensation unit 302 can determine the information, for example, by performing AMVP and merge mode. AMVP is used, including deriving several most likely candidates based on data and reference pictures of adjacent PBs. The motion information typically includes horizontal and vertical motion vector displacement values, one or two reference picture indexes, and in the case of prediction areas in B strips, also includes an identification 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 blocks adjacent in the spatial or temporal domain.
[0075] The motion compensation unit 302 may generate motion compensated blocks, possibly performing interpolation based on interpolation filters.Identifiers for the interpolation filters used with sub-pixel precision may be included in the syntax elements.
[0076] The motion compensation unit 302 may calculate interpolated values for sub-integer pixels of a reference block using interpolation filters used by the video encoder 200 during encoding of the video block. The motion compensation unit 302 may determine the interpolation filters used by the video encoder 200 based on received syntax information, and the motion compensation unit 302 may use the interpolation filters to generate a prediction block.
[0077] The motion compensation unit 302 may use at least part of the syntax information to determine the size of blocks used to encode (multiple) frames and / or (multiple) slices of the encoded video sequence, partition information describing how each macroblock of a picture of the encoded video sequence is partitioned, a mode indicating how each partition is encoded, one or more reference frames (and reference frame lists) for each inter-frame coding 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, signal prediction, and residual signal reconstruction. A slice may be an entire picture, or it may be a region of a picture.
[0078] The intra prediction unit 303 may use, for example, an intra prediction mode received in the bitstream to form a prediction block from spatially neighboring 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.
[0079] 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 in order to remove blocking artifacts. The decoded video block is then stored in a 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.
[0080] Some example embodiments of the present disclosure will be described in detail below. It should be noted that the section titles used in this document are for ease of understanding, and the embodiments disclosed in the section are not limited to that section. In addition, although some embodiments are described with reference to general video codecs or other specific video codecs, the disclosed technology is also applicable to other video codec technologies. In addition, although some embodiments describe the video coding and decoding steps in detail, it should be understood that the corresponding decoding steps of the uncoding will be 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 compression format or at different compression bit rates. 1 Overview The present disclosure relates to video coding technology. Specifically, it relates to the interaction between RRIBC and other coding tools in image / video coding. It can be applied to existing video coding standards such as HEVC, VVC, etc. It can also be applied to future video coding standards or video codecs. 2 Introduction Video codec standards have evolved primarily through the development of the 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 and H.264 / MPEG-4 Advanced Video Codec (AVC) and H.265 / HEVC[1]. Since H.262, video codec standards have been based on a hybrid video codec structure that uses temporal prediction plus transform codecs. In order to explore future video codec technologies 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 codec standard was officially named Versatile Video Codec (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[2] are updated after each meeting. The VVC project achieved technical completion (FDIS) at the July 2020 meeting[3]. In January 2021, JVET established Exploration Experiments (EE) with the goal of leveraging novel conventional algorithms to achieve enhanced compression efficiency beyond VVC capabilities. Soon after, ECM[4] was built as a common software foundation for long-term exploratory work toward next-generation video codec standards. 2.1 Existing screen content encoding and decoding tools 2.1.1 Intra-block copy (IBC) Intra-block copy (IBC) is a tool adopted in the HEVC extension on SCC. It is well known that it significantly improves the encoding 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, which 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 conjunction with AMVR, the IBC mode can switch between 1-pixel and 4-pixel motion vector precision. The IBC-encoded CU is regarded as a third prediction mode in addition to the intra or inter prediction mode. The IBC mode is applicable to CUs with a width and height that are both less than or equal to 64 luminance samples. On the encoder side, hash-based motion estimation is performed for IBC. The encoder performs RD checks on blocks with width or height no greater than 16 luma samples. For non-merge mode, a block vector search is first performed using a hash-based search. If the hash search does not return a valid candidate, a local search based on block matching is performed. In hash-based search, the hash key matching (32-bit CRC) between the current block and the reference blocks 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 current blocks of larger size, the hash key is determined to match the hash key of the reference block when all hash keys in 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 through a flag, which can be signaled as IBC AMVP mode or IBC Skip / Merge mode as shown below: -IBC skip / merge mode: The merge candidate index is used to indicate which block vector from the list of neighboring candidate IBC codec blocks is used to predict the current block. The merge list includes spatial candidates, HMVP candidates and pairwise candidates. - IBC AMVP mode: Block vector differences are encoded and decoded in the same way as motion vector differences. The block vector prediction method uses two candidates as predictors, one from the left neighbor and one from the top neighbor (if IBC coded). When either neighbor is not available, the default block vector is used as predictor. A flag is signaled to indicate the block vector predictor index. 2.1.1.1 IBC Reference Area To reduce memory consumption and decoder complexity, IBC in VVC only allows reconstructed portions of predefined areas, which include areas of the current CTU and some areas of the left CTU. Figure 4 The reference area of the IBC mode is shown, where each block represents a 64×64 luma sample unit. Depending on the location of the current codec CU position within the current CTU, the following applies: -If the current block falls into the 64×64 block to the upper left of the current CTU, in addition to the reconstructed samples in the current CTU, the CPR mode can be used to refer to the reference samples in the lower right 64x64 block of the left CTU. The current block can also use the CPR mode to refer to the reference samples in the lower left 64×64 block of the left CTU and the reference samples in the upper right 64×64 block of the left CTU. -If the current block falls into the 64×64 block to the upper right of the current CTU, in addition to the samples that have been reconstructed in the current CTU, if the brightness position (0, 64) relative to the current CTU has not been reconstructed, the current block can also use the CPR mode and refer to the reference samples in the lower left 64×64 block and the lower right 64×64 block of the left CTU; otherwise, the current block can also refer to the reference sample in the lower right 64×64 block of the left CTU. - If the current block falls into the 64×64 block at the lower left of the current CTU, in addition to the samples that have been 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 refer to the reference samples in the upper right 64×64 block and the lower right 64×64 block of the left CTU. Otherwise, the current block can also use the CPR mode to refer to the reference samples in the lower right 64×64 block of the left CTU. - If the current block falls into the 64×64 block to the lower right of the current CTU, only the CPR mode can be used, referring to the reconstructed samples in the current CTU. This restriction allows the IBC mode to be implemented using local on-chip memory for hardware implementation. 2.1.1.2 Interaction between IBC and other codecs The interaction between IBC mode and other inter-frame codec tools in VVC, such as pairwise merge candidates, history-based motion vector predictor (HMVP), combined intra / frame prediction modes (CIIP), merge mode with motion vector difference (MMVD), and geometric partition model (GPM), is as follows: -IBC can be used with pairwise merge candidates and HMVP. A new pairwise IBC merge candidate can be generated by averaging two IBC merge candidates. For HMVP, IBC motions are inserted into the history buffer for future reference. - IBC cannot be used in conjunction with the following interframe tools: Affine Motion, CIIP, MMVD, and GPM. - When DUAL_TREE partitioning is used, IBC is not allowed for chroma codec blocks. Unlike in the HEVC screen content codec 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 in IBC mode excludes all neighboring blocks in inter mode and vice versa. The following IBC design aspects are applied: - IBC shares the same process as regular MV merging, including pairwise merging candidates and history-based motion predictors, but TMVP and zero vectors are not allowed as they are invalid for IBC mode. - Separate HMVP buffers (5 candidates each) for regular MV and IBC. - Block vector constraints are implemented as bitstream consistency constraints, where the encoder needs to ensure that there are no invalid vectors in the bitstream and that merges 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 handled as an inter mode. - If the current block is coded using IBC prediction mode, AMVR does not use quarter pixels; instead, AMVR is signaled to only indicate whether the MV is inter pixels or 4 integer pixels. - The number of IBC merge candidates may be signaled in the slice header separately from the number of normal, sub-block and geometric merge candidates. The concept of virtual buffer is used to describe the allowable reference area of IBC prediction mode and valid block vector. The CTU size is expressed as ctbSize, and 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 size of 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 VPDU is min(ctbSize, 64), W v =min(ctbSize, 64). The virtual IBC buffer ibcBuf is maintained as follows. - At the start of decoding each CTU line, flush the entire ibcBuf with an invalid value of -1. -When starting to decode the VPDU (xVPDU, yVPDU) relative to the upper 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 the (x, y) relative to the upper left corner of the picture, set ibcBuf[x%wIbcBuf][y%ctbSize]=recSample[x][y]. For a block covering coordinates (x, y), if the following holds for the block vector bv = (bv[0], bv[1]), then it is valid; 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 Coded Modulation (BDPCM) VVC supports Block Differential Pulse Coded Modulation (BDPCM) for picture content coding. At the sequence level, the BDPCM enable flag is signaled in the SPS; this flag is signaled only when 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 luma samples and if the CU is intra-coded, a flag is sent at the CU level, where MaxTsSize is the maximum block size allowed for transform skip mode. This flag indicates whether conventional intra-coding or BDPCM is used. If BDPCM is used, the BDPCM prediction direction flag is sent to indicate whether the prediction is horizontal or vertical. The block is then predicted using a conventional horizontal or vertical intra prediction process with unfiltered reference samples. The residuals are quantized, and the difference between each quantized residual and its predicted value, i.e., the previously coded residual of a neighboring position horizontally or vertically (depending on the BDPCM prediction direction), is coded. For a block of size M (height) × N (width), let r i,j , 0≤i≤M-1, 0≤j≤N-1 is the prediction residual. Let Q(r i,j ), 0≤i≤M-1, 0≤j≤N-1 represents the residual r i,j BDPCM is applied to the quantized residual values, resulting in a quantized version of The modified M×N array in is predicted from its neighboring quantized residual values. For vertical BDPCM prediction mode, for 0≤j≤(N-1), the following is used to derive For the horizontal BDPCM prediction mode, for 0≤i≤(M-1), the following is used to derive On the decoder side, the above process is reversed to calculate Q(r i,j ), 0≤i≤M-1, 0≤j≤N-1, as follows: Dequantized residual Q -1 (Q(r i,j )) is added to the intra block prediction value to produce the reconstructed sample value. The predicted quantized residual value is converted to Sent to the decoder. For lossless codec, if slice_ts_residual_coding_disabled_flag is set to 1, the quantized residual values are sent to the decoder using conventional transform residual codec as described in 2.2.2. For MPM modes for future intra-mode codecs, if the BDPCM prediction direction is horizontal or vertical, respectively, the horizontal or vertical prediction mode is stored for the BDPCM-coded CU, respectively. For deblocking, if the two blocks on both sides of the block boundary are coded and decoded using BDPCM, then the specific block boundary is not deblocked. 2.1.3 Residual Codec for Transform Skip Mode VVC allows 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 encoded and decoded in transform skip mode, its prediction residual is quantized and encoded using the transform skip residual encoding and decoding process. This process is modified from the transform coefficient encoding and decoding process described in 2.2.2. In transform skip mode, the residual of the TU is also encoded and decoded in units of non-overlapping sub-blocks of size 4×4. For better coding efficiency, some modifications are made to customize the residual coding and decoding process to the residual signal characteristics. The following summarizes the differences between transform skip residual coding and conventional transform residual coding: - a forward scanning order is applied to scan sub-blocks within a transformed block and also to scan positions within the sub-blocks; - no signaling of the last (x,y) position; - when all previous flags are equal to 0, coded_sub_block_flag is coded and decoded for each sub-block except the last sub-block; -sig_coefl_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 the abs_level_gt1 flag also depends on the left sig_coeff_flag value and the upper sig_co-eff_flag value; - par_level_flag to use only one context model; - additional more than 3, 5, 7, 9 flags are signaled to indicate coefficient levels, one context for each flag; - Rice parameter derivation with fixed order = 1 for binarization of the remainder values; - Determine the context model for the sign flag based on the left and above neighbor values, and parse the sign flag after sig_coeff_flag to keep all context-decoded bins together. For each subblock, if coded_subblock_flag is equal to 1 (i.e., there is at least one non-zero quantized residual in the subblock), encoding and decoding of the quantized residual level is performed in three scanning passes (see Figure 5 ): - First scan pass: Encode and decode the validity flag (sig_coeff_flag), the sign flag (coeff_sign_flag), the absolute level greater than 1 flag (abs_level_gtx_flag[0]), and the parity check (par_level_flag). For a given scan position, if sig_coeff_flag is equal to 1, then coeff_sign_flag is encoded and decoded, followed by abs_level_gtx_flag[0] (which specifies whether the absolute level is greater than 1). If abs_level_gtx_flag[0] is equal to 1, then par_level_flag is additionally encoded and decoded to specify the parity of the absolute level. - Scan pass greater than x: For each scan position where the absolute level is greater than 1, up to four abs_level_gtx_flag[i] are encoded for i=1...4 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 encoded and decoded in bypass mode. The absolute level remainder is binarized using a fixed Rice parameter value of 1. The bins in scan passes #1 and #2 (the first scan pass and greater than x scan passes) are context-decoded until the maximum number of context-decoded bins in the TU has been exhausted. The maximum number of context-decoded bins in the residual block is limited to 1.75×block_width×block_height, or equivalently, an average of 1.75 context-decoded bins per sample position. The bins 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 bins of the block and is decremented by 1 each time a context-decoded bin is decoded. When RemCcbs is greater than or equal to 4, the context-decoded bins are used to encode and decode the syntax elements including sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag in the first codec pass. If RemCcbs becomes less than 4 when encoding the first pass, the remaining coefficients that have not been encoded in the first pass are encoded in the remainder scan pass (pass #3). After the first pass of encoding and decoding is completed, if RemCcbs is greater than or equal to 4, the syntax elements in the second encoding and decoding pass including abs_level_gt3_flag, abs_level_gt5_flag, abs_level_gt7_flag, and abs_level_gt9_flag are encoded and decoded using the context-encoded bins. If RemCcbs becomes less than 4 when encoding and decoding the second pass, the remaining coefficients that have not been encoded and decoded in the second pass are encoded and decoded in the remainder scan pass (pass #3). Figure 5 The transform skip residual coding process is shown. The stars mark the positions where the context coded bits are exhausted, at which point all remaining bits are coded using bypass coding. In addition, for blocks that are not encoded in BDPCM mode, a level mapping mechanism is applied to transform skip residual encoding until the maximum number of context encoded bins has been reached. Level mapping uses the top and left neighboring coefficient levels to predict the current coefficient level in order to reduce signaling cost. For a given residual position, denote absCoeff as the absolute coefficient level before mapping, and absCoeffMod as the coefficient level after mapping. Let X0 denote the absolute coefficient level of the left neighboring position, and let X1 denote the absolute coefficient level of the upper neighboring position. Level mapping is performed as follows: The absCoeffMod value is then encoded as described above.After all context-decoded bins have been exhausted, level mapping is disabled for all remaining scan positions in the current block. 2.1.4 Palette Mode In VVC, palette mode is used for picture content encoding and decoding in all chroma formats supported in 4:4:4 profiles (i.e., 4:4:4, 4:2:0, 4:2:2, and monochrome). When palette mode is enabled, if the CU size is less than or equal to 64×64, a flag is sent at the CU level, and the amount of samples in the CU is greater than 16 to indicate whether palette mode is used. Considering that applying palette mode on small CUs introduces insignificant codec gain and brings additional complexity on small blocks, palette mode is disabled for CUs less than or equal to 16 samples. A palette-encoded codec unit (CU) is treated as a prediction mode different from intra prediction, inter prediction, and intra block copy (IBC) mode. If palette mode is used, the sample values in a 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 escape symbols. For samples within a CU coded with escape symbols, their component values are directly signaled using (possibly) quantized component values. This is done in Figure 6 , which shows an example of a block encoded and decoded in palette mode. The quantized escaped symbols are binarized using a fifth order exponential Golomb binarization process (EG5). For palette encoding and decoding, the palette predictor is maintained. For the non-wavefront case, the palette predictor is initialized to 0 at the beginning of each stripe. For the WPP case, the palette predictor at the beginning of each CTU row is initialized to the predictor derived from the first CTU in the previous CTU row, so that the initialization scheme between the palette predictor and the CABAC synchronization is unified. For each entry in the palette predictor, a reuse flag is signaled to indicate whether it is part of the current palette in the CU. The reuse flag is sent using a run length codec of zero. Thereafter, the number of new palette entries and the component values of the new palette entries are signaled. After encoding and decoding a palette-encoded CU, the palette predictor will be updated with the current palette, and entries from the previous palette predictor that are not reused in the current palette will be added to the end of the new palette predictor until the maximum allowed size is reached. An 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 expanded by one and the last index is assigned as the escape symbol. In a manner similar to the coefficient groups (CGs) used in transform coefficient coding, a CU coded with palette mode is divided into multiple line-based coefficient groups, each consisting of m samples (i.e., m=16), where the index run of the escape mode, the palette index value, and the quantized color are encoded / parsed sequentially for each CG. As in HEVC, horizontal or vertical traversal scanning can be applied to scan samples, such as Figure 7 , which shows a sub-block based index map scan for a palette, the left side (a) for horizontal scanning, and the right side (b) for vertical scanning. The encoding and decoding order for palette run-length encoding and decoding in each segment is as follows: For each sample position, a context-coded binary bit run_copy_flag=0 is signaled to indicate whether the pixel has the same mode as the previous sample position, that is, whether the previously scanned sample and the current sample are both run-type COPY_ABOVE, or whether the previously scanned sample and the current sample are both run-type INDEX and the same index value. Otherwise, run_copy_flag=1 is signaled. If the current sample has a different mode than the previous sample, then a context-coded binary bit copy_above_palet_teindices_flag is signaled to indicate the run-type of the current sample, that is, 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 palette run-decoding of samples in one codec pass, index values (for INDEX mode) and quantized escape colors are grouped and decoded using CABAC bypass codec in another codec pass. This separation of context-decoded bins and bypass-decoded bins can improve throughput within each line CG. For slices with dual luma / chroma trees, the palette is applied separately for 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 slices with a single tree, the palette is applied on the Y, Cb, Cr components jointly, i.e., each entry in the palette contains Y, Cb, Cr values, unless when a CU is encoded using local dual-tree encoding, in which case the encoding and decoding of luma and chroma are handled separately. In this case, if the corresponding luma blocks or chroma blocks are encoded and decoded using palette mode, their palettes are applied in a manner similar to the dual-tree case (this is related to non-4:4:4 encoding and will be further explained in 2.1.4.1). For slices decoded with dual-tree codec, the maximum palette predictor size is 63, and the maximum palette table size for the codec of the current CU is 31. For slices decoded with dual-tree codec, 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 deblocking, palette-coded blocks on the side of a block boundary are not deblocked. 2.1.4.1 Palette Mode for Non-4:4:4 Content The palette modes in VVC are supported for all chroma formats in a similar way as the palette modes in HEVC SCC. For non-4:4:4 content, the following customizations apply: 1. When signaling an escape value for a given sample position, if that sample position has only luma components but no chroma components 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 signaled value of the luma (or chroma) component and fills in the "missing" chroma (or luma) component by setting it to a default value (1<<(component bit depth-1)). b. The maximum palette predictor size remains at 63 (since a single tree is used to encode and decode the slices), but the maximum palette table size for luma / chroma blocks remains at 15 (since separate palettes are used to encode and decode the blocks). 3. For the palette mode of monochrome format, the number of color components in the palette codec 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 of the current CU. 1. First, in order to derive the initial entries in the palette table of the current CU, a simplified K-means clustering is applied. The palette table of the current CU is initialized to an empty table. For each sample position in the CU, the SAD between this sample and each palette table entry is calculated, and the minimum SAD among all palette table entries is obtained. If the minimum SAD is less than the predefined error limit errorLimit, the current sample is clustered with the palette table entry with the minimum SAD. Otherwise, a new palette table entry is created. The threshold errorLimit is QP-related and is retrieved from a lookup table containing 57 elements covering the entire QP range. After all samples of 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, the corresponding sample is converted to an escape symbol in the next step. 3. The palette table thus generated contains some new entries from the centroids of the clusters in step 1, and some entries from the palette predictor. Therefore, the table is reordered again so that all new entries (i.e., centroids) are placed at the beginning of the table, followed by 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 of all index values corresponding to the palette table entry, 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 coded bits (2-5) After determining the index map for 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 entry will be removed. After deciding the index map for the current CU, a grid RD optimization is applied to find the best values of run_copy_flag and run type for each sample position by comparing the RD costs of three options: same as the previously scanned position, run type COPY ABOVE, or run type INDEX. When calculating the SAD value, the sample values are scaled down to 8 bits, unless the CU is encoded or decoded in lossless mode, in which case the actual input bit depth is used to calculate the SAD. In addition, in the case of lossless codecs, only the rate is used in the above rate-distortion optimization step (because lossless codecs do not cause distortion). 2.1.5 Adaptive Color Transformation In the HEVC SCC extension, Adaptive Color Transform (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 codec efficiency of the 444 chroma format codec. As in HEVC SCC, ACT performs in-loop color space conversion in the prediction residual domain by adaptively converting the residual from the input color space to the YCgCo space. Figure 8 A decoding flow chart for applying ACT is shown. Two color spaces are adaptively selected by signaling an ACT flag at the CU level. When the flag is equal to 1, the residual of the CU is encoded and decoded in the YCgCo space; otherwise, the residual of the CU is encoded and decoded in the original color space. In addition, similar to the HEVCACT design, for inter-frame and IBcCU, ACT is enabled only when there is at least one non-zero coefficient in the CU. ACT is only enabled when the chroma component selects the same intra-frame prediction mode of the luminance component (i.e., DM mode). 2.1.5.1ACT Mode In the HEVC SCC extension, ACT supports both lossless and lossy codecs based on the lossless flag (i.e., cu_transquant_bypass_flag). However, there is no flag in the bitstream to indicate whether lossy or lossless codec is applied. Therefore, the YCgCo-R transform is applied as ACT to support both lossy and lossless cases. The YCgCo-R reversible color transform is shown below. Since the YCgCo-R transform is not normalized. In order to compensate for the dynamic range change of the residual signal before and after the color transform, the QP adjustment of (-5, 1, 3) is 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 residual in the CU. For other encoding and decoding processes (such as deblocking), the original QP is still applied. Additionally, because the forward and inverse color transforms require access to the residuals of all three components, ACT mode is always disabled for split tree partitioning and ISP mode, where the prediction block sizes for different color components are different. When ACT is applied, transform skip (TS) and block differential pulse coded modulation (BDPCM) extended to code chroma residuals are also enabled. 2.1.5.2 ACT Fast Encoding Algorithm To avoid brute force RD searches in both the original and converted color spaces, the following fast encoding algorithm is applied in the VTM reference software to reduce encoder complexity when ACT is enabled. - The order of enabling / disabling RD checking for ACT depends on the original color space of the input video. For RGB video, RD cost for ACT mode is checked first; for YCbCr video, RD cost for non-ACT mode is checked first. RD cost for 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, the same ACT enable / disable decision is reused. Specifically, when the CU is encoded and decoded for the first time, the selected color space used to encode and decode the residual of a CU will be stored. Then, when the same CU is obtained by another partitioning path, the stored color space decision will be 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 the RD cost of the first color space is less than the RD cost of the second color space for the parent CU, the second color space is not checked for the current CU. To reduce the number of tested codec modes, the selected codec modes are shared between the two color spaces. Specifically, for intra mode, the pre-selected intra mode candidates according to SATD-based intra mode selection are shared between the two color spaces. For inter and IBC modes, only one block vector search or motion estimation is performed. Block vectors and motion vectors are shared by the two color spaces. 2.1.6 Intra-frame 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, whose L-shaped template matches the current template. For a predefined search range, the encoder searches for the template that is most similar to the current template in the reconstructed part of the current frame and uses the corresponding block as the prediction block. The encoder then signals the use of this mode and performs the same prediction operation on the decoder side. By combining the L-shaped causal neighborhood of the current block with Fig. 9The prediction signal is generated by matching another block in a predefined search area in the image to generate a prediction signal, the predefined search area including: R1: current CTU, R2: Upper left CTU, R3: Above CTU, R4: Left CTU. SAD is used as the cost function. In 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 size of all regions (Search Range_w, SearchRange_h) is proportional to the block size (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 tradeoff. In practice, 'a' is equal to 5. The intra template matching tool is enabled on width and height for CUs of 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, the intra template matching prediction mode is signaled at the CU level through a dedicated flag. 2.1.7 Template Matching Using IBC (IBC-TM) In ECM-5.0, template matching with IBC is used for both IBC merge mode and IBC AMVP mode. Compared to the merge list used by the regular IBC merge mode, the IBC-TM merge list has been modified so that candidates are selected according to a pruning method with motion distances between candidates in the regular TM merge mode. Ending zero motion implementations (which are meaningless with respect to intra coding) have been replaced by motion vectors of the left (-W, 0), top (0, -H), and top-left (-W, -H), where W is the width of the current CU and H is the height of the current CU. In IBC-TM merge mode, the selected candidates are refined using template matching methods before the RDO or decoding process. The IBC-TM merge mode has been competed with the regular IBC merge mode and the TM merge flag is signaled. In IBC-TM AMVP mode, up to 3 candidates are selected from the IBC-TM merge list. Each of these 3 selected candidates is refined using a template matching method and ranked according to the template matching cost they incur. Only the first two are then typically considered in the motion estimation process. Template matching refinement for both IBC-TM merge mode and AMVP mode is very simple, because IBC motion vectors are constrained (i) to be integers and (ii) to be Fig.10 . Therefore, in IBC-TM merge mode, all refinements are performed with integer precision, and in IBC-TM AMVP mode, they are performed with integer or 4-pixel precision depending on the AMVR value. Such refinement is only performed on samples that are not interpolated. In both cases, the refined motion vectors and the template used in each refinement step must respect the constraints of the reference region. 2.1.8 Expanded HMVP Table for IBC In ECM-5.0, the HMVP table size for IBC is increased to 25. After deriving up to 20 IBC merge candidates with full pruning, they are re-ranked together. After re-ranking, the top 6 candidates with the lowest template matching cost are selected as the final candidates in the IBC merge list. 2.1.9 Block Vector Difference Binarization In ECM-4.0, the block vector difference (BVD) shares the same binarization method as the motion vector difference (MVD). For each component, a flag greater than 0, a flag greater than 1 are signaled, and then the residual amplitude of the bypass codec is binarized using EG1 code. In ECM-5.0, the flag greater than 1 is removed and the first 5 bins of the EG1 prefix are context coded, all other bins remain bypass coded. 2.1.10 Reconstruction-Reordering IBC (RRIBC) At the JVET-Z conference, the reconstruction-reordering IBC (RR-IBC) mode for screen content video coding and decoding was proposed. When applied, the samples in the reconstructed block are flipped according to the flip type of the current block. On the encoder side, the original block is flipped before motion search and residual calculation, while the prediction block is derived without flipping. On the decoder side, the reconstructed block is flipped to restore the original block. For RR-IBC codec blocks, two flipping methods are supported, horizontal flipping and vertical flipping. For IBC AMVP codec blocks, the syntax flag is first transmitted by signal, indicating whether the reconstruction is flipped, and if flipped, another flag specifying the flip type is further transmitted by signal. For IBC merging, the flip type is inherited from the adjacent block in the absence of syntax signaling. Taking into account horizontal or vertical symmetry, the current block and the reference block are generally aligned horizontally or vertically. Therefore, when horizontal flipping is applied, the vertical component of BV is not transmitted by signal and is inferred to be equal to 0. Similarly, when vertical flipping is applied, the horizontal component of BV is not transmitted by signal and is inferred to be equal to 0. In order to better exploit the symmetry property, a flip-aware BV adjustment method is applied to refine the block vector candidates. Fig.11A shows the BV adjustment for horizontal flipping, and Fig. 11B The BV adjustment for vertical flipping is shown respectively. Fig.11A and Fig. 11B As shown, (x nbr ,y nbr ), (x cur ,y cur ) represent the coordinates of the center samples of the neighboring blocks and the current block, BV nbr , B.V. cur Denote the BV of the neighboring block and the current block respectively. Instead of inheriting the BV directly from the neighboring block, when the neighboring block is encoded and decoded with horizontal flipping, the BV cur The horizontal component of nbr (expressed as BV nbr h ), that is, BV cur h =2(x nbr -X cur )+BV nbr b Similarly, in the case where the neighboring blocks are coded with vertical flipping, BV cur The vertical component of the motion shift is added to BV nbr (expressed as BV nbr v ), that is, BV cur v =2(y nbr -y cur )+BV nbr v . 2.1.11 Modifications to IBC merging / AMVP list construction using Adaptive Reordering-based Motion Compensation (ARMC) In ECM, IBC merging / AMVP list building was modified with the following changes: 1) An IBC merge / AMVP candidate can be inserted into the IBC merge / AMVP candidate list only if it is valid. 2) Top-right, bottom-left, and top-left spatial candidates (e.g. Fig.12 As shown, it shows that a spatial candidate for IBC merge / AMVP candidate list) and a pairwise average candidate can be added to the IBC merge / AMVP candidate list. 3) ARMC-TM is extended to the IBC merge list, which is called adaptive reordering of merge candidates with template matching for IBC (ARMC-TM-IBC). The template and the reference sample of the template are in Fig.13 is shown in . 2.2 Previous related solutions 2.2.1 Reordering of Reconstructed Samples The detailed solutions below should be considered as examples to explain the general concept. 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), a coding unit (CU), a prediction block (PB), a prediction unit (PU), a transform block (TB), a transform unit (TU), a sub-block, a sub-CU, a codec tree unit (CTU), a codec tree block (CTB), or a codec group (CG). In the following disclosure, a region may refer to any video unit, such as a picture, a slice, or a block. A region may also refer to a non-rectangular area, such as a triangle. In the following disclosure, W and H represent the width and height of the rectangular area mentioned. 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 denoted as S(x, y), and the sample at position (x, y) in the region after reordering is denoted 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 the position in the region, and f and g are two functions. i. For example, it is required that there is 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 area to be reordered can be i. Original sample before encoding. ii. Prediction sample. iii. Reconstruct the sample. iv. Transformed samples (transform 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.Sample before ALF processing. xi. Samples after ALF processing. xii. Samples before post-processing. xiii. Samples after post-processing. c. In one example, reordering may be applied in more than one stage. i. For example, at least two of the samples listed in item 1.b above may be reordered. 1. For example, different re-ranking methods can be applied to the two samples. 2. For example, the same re-ranking method can be applied to both samples. d. In one example, the reordering may be a horizontal flip. For example, f(x, y) = Px, g(x, y) = y. For example, P = W-1. e. In one example, the reordering may be a vertical flip. For example, f(x, y) = x, g(x, y) = Qy. For example, Q = H-1. f. In one example, the reordering may be horizontal or vertical flipping. For example, f(x, y) = Px, g(x, y) = Qy. For example, P = W-1 and Q = H-1. g. In one example, the reordering may be a move. 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 may be a rotation. i. In one example, there exists 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 samples may be signaled from the encoder to the decoder, e.g., in SPS / sequence header / PPS / picture header / APS / slice header / sub-picture / 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 may be encoded and decoded using context encoding and decoding. ii. For example, a second syntax element (eg, a flag) is signaled to indicate which reordering method (eg, horizontal flip or vertical flip) is used. 1. For example, the second syntax element is signaled only if it is indicated that reordering is applied. 2. For example, context coding may be used to code the second syntax element. 2. Propose whether and / or how to reorder samples may depend on encoding solution information. a. In one example, whether and / or how the reordering of samples may be derived depends on the codec information at picture level / slice level / CTU level / CU level / PU level / TU level. b. In one example, the codec information may include: i. The size of the area. ii. The codec mode of the region (e.g. inter, intra or IBC). iii. Motion information (such as motion vectors and reference indices). iv. Intra prediction mode (eg angular intra prediction mode, planar or DC). v. Inter prediction modes (such as affine prediction, bi-directional 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. Codec tree partition information such as codec tree depth. viii. Color format and / or color components. 3. It is proposed that at least one parsing or decoding process other than the reordering process may depend on whether and / or how the samples are reordered. a. For example, a syntax element may be conditionally signaled based on whether reordering applies. b. For example, different scan orders may be used based on whether and / or how the samples are reordered. c. For example, deblocking filtering / SAO / ALF may be used based on whether and / or how samples are reordered. 4. In one example, the sample may be processed by at least one auxiliary program before or after the resampling process. Some possible auxiliary programs may include: (combinations may be allowed) a. For example, at least one sample may be added by an offset. b. For example, at least one sample may be multiplied by a factor. c. For example, at least one sample may be cropped. d. For example, at least one sample may 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 a block encoded and decoded in IBC mode. a. For example, a first flag is signaled to indicate whether the reconstructed samples should be reordered. i. For example, the first flag may be encoded and decoded using context encoding and decoding. b. For example, a second flag may be signaled to indicate whether the reconstructed samples should be flipped horizontally or vertically. i. For example, the second flag is signaled only when the first flag is true. ii. For example, the second flag may be encoded using context encoding and decoding. 2.2.2 About sample reordering - application conditions and interaction with other processes The detailed solutions below should be considered as examples to explain the general concept. These solutions should not be interpreted in a narrow sense. In addition, these solutions can be combined in any way. The term “video unit” or “codec unit” may refer to a picture, a slice, a tile, a codec tree block (CTB), a codec tree unit (CTU), a codec block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may refer to a codec tree block (CTB), a codec tree unit (CTU), a codec 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 existing standards. Any changes in codec tools are also applicable. 1. Regarding the application conditions of sample reordering (e.g., first and related problems), the following method is proposed: a. Whether the reordering process is applied to the reconstructed / original / prediction 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 encoded 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 called IBC). ii. Current Picture Reference (also called CPR). iii. Intra-template matching (also called Intra-TM). iv. IBC template matching (or IBC mode based on template matching). v. Merge-based encoding and decoding. vi. Codec based on AMVP. c. For example, it may depend on the block dimensions (such as block width and / or height). d. For example, if the size W×H of the video unit meets one or more rules listed below, then the reordering process can 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 types of samples are reordered and the interaction with other processes (e.g., second and related issues), the following methods are proposed: a. A possible method for sample reordering can refer to one or more of the following processes: a. The shaping domain samples of a video unit (e.g., obtained based on the LMCS method) can be reordered. i. For example, the shaping domain luminance samples of a video unit (e.g., obtained based on the luminance mapping of the LMCS method) can be reordered. b. The samples of the original domain (instead of the LMCS shaping domain) of a video unit can be reordered. i. For example, the original domain chrominance samples of a video unit can be reordered. ii. For example, the original domain luminance samples of a video unit can be reordered. c. The reconstructed samples of a video unit can be reordered. i. For example, the reconstructed samples of a video unit can be reordered immediately after adding the decoded residuals to the prediction. ii. For example, the shaping domain luminance reconstructed samples of a video unit can be reordered. iii. For example, the original domain luminance reconstructed samples of a video unit can be reordered. iv. For example, the original domain chrominance reconstructed samples of a video unit can be reordered. d. The inverse luminance mapping of the LMCS process can be applied based on the reordered reconstructed samples. e. The loop filter process (e.g., luminance / chrominance bilateral filter, luminance / chrominance SAO, CCSAO, luminance / chrominance 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 shaping 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 reconstructed samples reordered from the original domain. g. The original samples of a video unit can be reordered. i. For example, the integer-domain raw luma samples of a video unit may be reordered. ii. For example, the original domain raw luma samples of a video unit may be reordered. iii. For example, the original domain raw chroma samples of a video unit may be reordered. iv. For example, the residual can be generated by subtracting the prediction from the reordered original samples. h. The prediction samples of the video unit can be reordered. i. For example, the reordering process for prediction samples may be performed immediately after the motion compensation process. ii. For example, sign prediction may be applied based on the reordered prediction samples of the video unit. General Aspects 3. Whether and / or how to apply the method disclosed above can be transmitted by signal at sequence level / picture group level / picture level / slice level / tile group level, for example in sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / slice header / tile group header. 4. Whether and / or how to apply the above disclosed methods can be signaled in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / slice / tile / sub-picture / other kinds of regions containing more than one sample or pixel. 5. Whether and / or how to apply the above disclosed method may depend on the encoded information, such as block size, color format, single-tree partitioning / dual-tree partitioning, color component, slice / picture type. 2.2.3 About sample reordering - sample reordering, signaling and storage The following detailed embodiments should be considered as examples to explain the general concept. These embodiments should not be interpreted in a narrow manner. In addition, these embodiments can be combined in any way. The term “video unit” or “codec unit” may refer to a picture, a slice, a tile, a codec tree block (CTB), a codec tree unit (CTU), a codec block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may refer to a codec tree block (CTB), a codec tree unit (CTU), a codec 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 existing standards. Any changes in codec tools are also applicable. 1. Regarding the signaling of sample reordering (eg, the first problem and related problems), the following method is proposed. a. For example, at least one new syntax element (eg, flag, index, variable, parameter, etc.) may be signaled to specify the use of sample reordering of a video unit. a. For example, given that a particular prediction method is used for a video unit, at least one new syntax element (eg, a flag) may be further signaled to specify the use of sample reordering. b. For example, given an intra template matching usage flag specifies that a video unit is coded by intra template matching, a first new syntax element (eg, a flag) may be further signaled to specify the use of sample reordering for the video unit coded by intra template matching. c. For example, given an IBC amvp flag specifies that a video unit is coded by IBC amvp, a first new syntax element (eg, a flag) may be further signaled to specify the use of sample reordering for the video unit coded by IBC amvp. d. For example, given an IBC merge flag that specifies that a video unit is coded by IBC merge, a first new syntax element (eg, a flag) may be further signaled that specifies the use of sample reordering for the IBC merge-coded video unit. b. In addition, for example, if the first new syntax element specifies that sample reordering is used for video units encoded and decoded by a specific prediction method, a second new syntax element (e.g., a flag) may be further signaled to specify which reordering method (e.g., horizontal flipping or vertical flipping) is used for the video unit. c. For example, a single new syntax element (e.g., parameter or variable or index) may be signaled to a video unit, rather than multiple concatenated syntax elements, specifying the type of reordering applied to the video unit (e.g., no flip, horizontal flip, or vertical flip). a. For example, given an intra template matching usage flag specifies that a video unit is encoded and decoded by intra template matching, a new syntax element (eg, index) may be further signaled to specify the type of reordering of samples of the video unit encoded and decoded by intra template matching. b. For example, given an IBC amvp flag that specifies that a video unit is coded by IBC amvp, a new syntax element (eg, index) may be further signaled to specify the type of sample reordering for the video unit coded by IBC amvp. c. For example, given an IBC merge flag that specifies that a video unit is coded by IBC merge, a new syntax element (eg, index) may be further signaled to specify the type of sample reordering for the video unit coded by IBC merge. d. Additionally, for example, a new syntax element (eg, 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 may be context encoded and decoded. a. For example, the context may be based on neighboring block / sample coding information (eg, availability, prediction mode, whether merge coded, whether IBC coded, whether sample reordering is applied, which sample reordering method is used, etc.). e. Alternatively, for example, whether to perform sample reordering and / or which reordering method to use for a video unit may be determined based on predefined rules (without signaling) rather than being signaled. a. For example, the predefined rules may be based on information about neighboring block / sample codecs. b. For example, given an IBC merge flag that specifies that a video unit is encoded and decoded via IBC merging, a process may be performed to determine whether and how to perform reordering based on predefined rules / processes. i. Alternatively, for example, given a first new syntax element specifying sample reordering for a video unit, however, how to reorder can be determined based on a predefined rule / procedure (without signaling) instead of further signaling the reordering method. ii. Alternatively, for example, whether to perform reordering may be determined implicitly based on a predefined rule / process, but how to reorder may be signaled. c. For example, given an IBC amvp flag specifying that the video unit is coded by IBC amvp, a program may be executed to determine whether and how to perform reordering based on predefined rules / procedures. i. Alternatively, for example, given a first new syntax element specifying sample reordering for a video unit, however, how to reorder may be determined based on a predefined rule / procedure (without signaling) rather than further signaling the reordering method. ii. Alternatively, for example, whether to perform reordering may be determined implicitly based on a predefined rule / process, but how to reorder may be signaled. d. For example, given an intra template matching flag that specifies that a video unit is encoded via IBC merging, a process may be performed to determine whether and how to perform reordering based on predefined rules / processes. i. Alternatively, for example, given a first new syntax element specifying sample reordering for a video unit, however, rather than further signaling the reordering method, how to reorder may be determined based on a predefined rule / procedure (without signaling). ii. Alternatively, for example, whether to perform reordering may be determined implicitly based on a predefined rule / process, but how to reorder may be signaled. f. For example, whether to perform reordering and / or how to reorder can be inherited from the encoded and decoded blocks. a. For example, it can be inherited from an adjacent spatial neighbor block. b. For example, it may be inherited from a non-adjacent spatially neighboring block. c. For example, it may be inherited from a history-based motion table such as some HMVP table. d. For example, it may be inherited from the temporal motion candidate. 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 case the video unit is encoded and decoded by IBC merge mode, sample reordering inheritance may be allowed. i. For example, in case a video unit is encoded and decoded by IBC AMVP mode, sample reordering inheritance may be allowed. j. For example, in case of encoding and decoding video units via intra template matching mode, sample reordering inheritance may be allowed. 2. With regard to the storage of sample reordering states (eg, second and related issues), the following method is proposed. a. For example, information on whether and / or how to reorder video units may be stored. a. For example, the stored information can be used for encoding and decoding of future video units. b. For example, this information may be stored in a buffer. i. For example, a 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 may be stored in a historical motion vector table (such as a HMVP table). b. For example, coding information (e.g., whether sample reordering is applied, which sample reordering method is used, block availability, prediction mode, whether merge coded or IBC coded, etc.) may be stored for deriving the context of the sample reordering syntax element. General Aspects 3. Whether and / or how to apply the method disclosed above can be transmitted by signal at sequence level / picture group level / picture level / slice level / tile group level, for example in sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / slice header / Tile group header. 4. Whether and / or how to apply the above disclosed methods can be signaled in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / slice / tile / sub-picture / other kinds of regions containing more than one sample or pixel. 5. Whether and / or how to apply the above disclosed method may depend on the encoded information, such as block size, color format, single-tree partitioning / dual-tree partitioning, color component, slice / picture type. 2.2.4 About sample reordering - motion list generation, implicit derivation and how to reorder The following detailed embodiments should be considered as examples to explain the general concept. These embodiments should not be interpreted in a narrow manner. In addition, these embodiments can be combined in any way. The term “video unit” or “codec unit” may refer to a picture, a slice, a tile, a codec tree block (CTB), a codec tree unit (CTU), a codec block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may refer to a codec tree block (CTB), a codec tree unit (CTU), a codec 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 existing standards. Any changes in codec tools are also applicable. 1. Regarding the motion candidate list generation for sample reordering (e.g., first and related problems), the following method is proposed: b. For example, the IBC merge motion candidate list can be used for both the regular IBC merge mode and the sample reordering based IBC merge mode. c. For example, the IBC amvp motion predictor candidate list can be used for both the regular IBC amvp mode and the sample reordering based IBC amvp mode. d. For example, a new motion (predictor) candidate list may be generated for a target video unit coded with sample reordering. a. For example, the new candidate list may only consider motion candidates that have the same reordering method as that of the target video unit. b. For example, the new candidate list may only consider motion candidates that are encoded with sample reordering (but regardless of the type of sample reordering method). c. Alternatively, a new candidate list may be generated without considering the sample reordering method for each motion candidate. d. For example, non-adjacent motion candidates may be inserted into a new candidate list. i. For example, non-adjacent candidates with sample reordering (but regardless of the type of sample reordering method) may be inserted. ii. For example, non-adjacent candidates having the same reordering method as that of the target video unit may be inserted. iii. For example, whether or not a sample re-ordering method is applied to the candidates, non-adjacent candidates may be inserted. 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 rules can be based on an averaging process. ii. For example, rules can be based on a tailoring process. iii. For example, the rules can be based on a scaling process. e. For example, the motion (predictor) candidate list generation for the target video unit may depend on the reordering method. a. For example, the reordering method associated with each motion candidate (from the spatial or temporal domain or the history table) may be inserted into the list, regardless of whether the target video unit will be coded with sample reordering. b. For example, if the target video unit is to be encoded with sample reordering, only those motion candidates (from the spatial domain or temporal domain or the history table) that are encoded with the same reordering method as that 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 the spatial domain or temporal domain or the history table) that are to be 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 the spatial domain or temporal domain or the history table) encoded with the same reordering method may not be inserted into the list. e. Alternatively, motion list generation for a video unit may not depend on the reordering method associated with each motion candidate. f. For example, adaptive reordering of merge candidates (ARMC) of video units may depend on the reordering method. a. For example, if the target video unit is to be coded with sample reordering, motion candidates coded with the same reordering method as that of the target video unit may be placed before those motion candidates coded with a different reordering method. b. For example, if the target video unit is to be coded with sample reordering, motion candidates coded with sample reordering may be placed before those coded with a different reordering method (but regardless of the type of sample reordering method). c. For example, if the target video unit is to be coded without sample reordering, the motion candidates without the reordering method may be placed before those motion candidates coded with the reordering method. d. Alternatively, ARMC may be applied to video units regardless of the reordering method associated with each motion candidate. 2. Regarding the implicit determination of sample reordering (e.g., second and related problems), the following method is proposed: a. Whether to reorder the reconstructed / original / predicted samples of a video unit may be derived implicitly from the coded information at both the encoder and the decoder. a. Implicit derivation can be based on costs / errors / differences computed from the encoded and decoded information. 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 the first template and the second template. 1. For example, a first template is constructed from a set of predefined samples adjacent to the current video unit, and a second template is constructed from a set of corresponding samples adjacent to the reference video unit. 2. For example, the cost / error may refer to the cumulative sum of the differences between the samples in the first template and the corresponding samples in the second template. a. For example, the difference may be based on luma sample values. 3. For example, a sample may refer to a reconstructed sample or a variant based on the reconstructed sample. 4. For example, a sample may refer to a predicted sample or a variant based on a predicted sample. 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, {Cost0, Cost1} is identified and determines the corresponding coding method (without reordering or with reordering) as the final coding method of the video unit. c. Alternatively, the reconstructed / original / predicted samples of the reordered video units may be signaled in the bitstream. i. For example, it may be signaled via a syntax element (eg, a flag). b. Which reordering method to use to reorder the reconstructed / original / prediction samples can be implicitly derived from the coded and decoded information at both the encoder and the decoder. a. For example, whether to flip horizontally or vertically. b. Implicit derivation can be based on costs / errors / differences computed from the encoded and decoded information. 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 the first template and the second template. 1. For example, a first template is constructed from a set of predefined samples adjacent to the current video unit, and a second template is constructed from a set of corresponding samples adjacent to the reference video unit. 2. For example, the cost / error may refer to the cumulative sum of the differences between the samples in the first template and the corresponding samples in the second template. a. For example, the difference may be based on luma sample values. 3. For example, a sample may refer to a reconstructed sample or a variant based on the reconstructed sample. 4. For example, a sample may refer to a predicted sample or a variant based on a predicted sample. 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 of the video unit. c. Alternatively, the reordering method for reordering the reconstructed / original / predicted samples of a video unit may be signaled in the bitstream. i. For example, it may be signaled by a syntax element (eg, a flag or an index or a parameter or a variable). c. Whether and which reordering method to use to reorder the reconstructed / original / prediction samples of a video unit may be implicitly derived from the encoded and 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), and the third cost can be calculated using reordering method B (represented by Cost2). Finally, the minimum cost value among {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 of the video unit. 3. Regarding how to reorder samples (e.g., 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 video units. i. For example, the reordering process may be based on block / CU / PU / TU. ii. For example, the reordering process may not be tile / slice / picture based. b. Samples of a video unit may be transformed according to an M parameter model (eg, M=2 or 4 or 6 or 8). c. Samples of a video unit can be reordered. d. The sample of the video unit can be rotated. e. The samples of the video unit can be transformed according to the affine model. f. The samples of the video unit can be transformed according to the linear model. g. The samples of the video unit can be transformed according to the projection model. h. The samples of the video unit can be flipped in the horizontal direction. i. The samples of the video unit can 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 of picture level / picture level / slice level / tile group level, e.g. in sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / slice header / tile group header. 5. Whether and / or how to apply the above disclosed methods to include more than one sample or pixel in a PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / slice / tile / sub-picture / other type of area. 6. Whether and / or how to apply the methods disclosed above may depend on the encoded information, such as block size, color format, single-tree partitioning / dual-tree partitioning, color component, slice / picture type. 2.2.5 About motion constraints, AMVR signaling, template matching, and sample reordering The following detailed embodiments should be considered as examples to explain the general concept. These embodiments should not be interpreted in a narrow manner. In addition, these embodiments can be combined in any way. The term “video unit” or “codec unit” may refer to a picture, a slice, a tile, a codec tree block (CTB), a codec tree unit (CTU), a codec block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may refer to a codec tree block (CTB), a codec tree unit (CTU), a codec 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 existing standards. Any changes in codec tools are also applicable. 1. Regarding motion constraints for applying codec tools (e.g., the first problem and related problems), the following methods are proposed: a. The motion vectors of a video unit encoded and decoded using a specific prediction method may be constrained by a certain rule. a. A motion vector can refer to one or more of the following: i. Motion vector difference ii. Motion vector, iii. Motion vector predictor. b. Forecasting methods can refer to one or more of the following: i.IBC AMVP mode, ii. IBC merger mode, iii. IBC merge mode with template matching iv. Intra-frame template matching, v. IBC AMVP mode based on sample reordering, vi. IBC merging mode based on sample reordering vii. Sample reordering based IBC merging mode with template matching viii. Intra-frame template matching based on sample reordering. c. Rules can 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 is encoded using IBCAMVP mode, the horizontal component of the motion vector may be required to be equal to zero. a. Alternatively, given a video unit is encoded using IBC AMVP mode, the vertical component of the motion vector may be required to be equal to zero. b. In addition, the IBC AMVP mode in public projects can be replaced by the IBC merge mode. c. In addition, the IBCAMVP mode in the public project can be replaced by the IBC mode with template matching. i. In one example, template matching may be required to be searched along one direction (horizontally or vertically). d. In addition, the IBC AMVP mode in the public project can be replaced by the intra-frame template matching mode. i. In one example, template matching may be required to be searched along one direction (horizontally or vertically). c. For example, given a video unit is encoded and decoded using IBC AMVP mode based on sample reordering (eg, sample horizontal flipping), the vertical component of the motion vector may be processed / constrained / required to be equal to zero. a. For example, given a video unit is encoded and decoded using IBC AMVP mode based on sample reordering (eg, sample vertical flipping), the horizontal component of the motion vector may be processed / constrained / required to be equal to zero. b. In addition, the IBC AMVP mode in public projects can be replaced by the IBC merge mode. c. In addition, the IBCAMVP mode in the public project can be replaced by the IBC mode with template matching. i. In one example, template matching may be required to be searched in the horizontal direction for horizontal flipping (vertical component of the motion vector equals 0). ii. In one example, template matching may be required to be searched in the vertical direction for vertical flipping (horizontal component of the motion vector equals 0). d. In addition, the IBC AMVP mode in the public project can be replaced by the intra-frame template matching mode. d. For example, if a component of the motion vector (e.g., MVx or MVy) of a video unit is processed / constrained / required to be equal to zero, then a. The corresponding component of the motion vector difference (eg, MVDx or MVDy) of the video unit may be processed / constrained / required to be equal to zero. b. The corresponding component of the motion vector predictor (eg, MVPx or MVPy) of the video unit 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 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 the video unit. a. For example, given that the MVDx of a video unit is processed / constrained / required to be equal to zero, the sign of MVDx may not be signaled. b. For example, given that the MVDy of a 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 a motion vector is processed / constrained / required to be equal to zero, the corresponding first component of the MVD / MVP is processed / constrained / required to be equal to zero. h. "Zero" in the above items may be replaced by any other fixed or derived or signaled value. 2. Regarding motion constraint-based AMVR signaling (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 for a certain video unit (eg, amvr_precision_idx for AMVR) may depend on the motion constraints applied to the video unit. a. For example, a video unit may be encoded and decoded using an AMVP mode. b. For example, the video unit may be encoded and decoded using IBC AMVP. c. For example, a video unit may be encoded and decoded using IBC AMVP based on sample reordering. d. For example, a video unit may be encoded and 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, given that the MVDx of a video unit is processed / constrained / required to be equal to zero, the signaling can depend only on whether the value of MVDy is equal to zero (rather than 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 can only depend on whether the value of MVDx is equal to zero (rather than checking both MVDx and MVDy). g. For example, if the resolution of the motion vector difference (eg, amvr_precision_idx) is not signaled for such a video unit, it may be inferred to be equal to some value (such as 0) indicating that a default resolution is used. i. For example, in the case where a video unit is encoded and decoded based on the IBC AMVP mode, the default resolution may be 1-pixel precision. ii. For example, in the case where the video unit is encoded and decoded based on the IBC AMVP mode based on sample reordering, the default resolution may be 1-pixel precision. b. For example, the signaling of amvr_precision_idx of an IBC AMVP coded block (taking the syntax structure in the VVC specification as an example) may be changed as follows, where cu_ibc_reorder_type indicates whether and how to reorder samples in an IBC AMVP coded block. 3. With respect to template matching (e.g., intra TM, IBC with TM) modification with sample reordering enabled (e.g., the third problem and related problems), the following method is proposed: Assuming that a first template is used for a first video unit encoded using a TM with sample reordering, and a second template is used for a second video unit encoded using a TM without sample reordering: a. For example, the location of samples comprising a template may 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 may be different. b. For example, the second template may be constructed from samples above and to the left of the video unit. c. For example, the first template may be constructed from samples above or to the left of the video unit. i. For example, if the first video unit is encoded with horizontal flipping, the first template may be constructed from samples above the video unit. ii. For example, if the first video unit is encoded with vertical flipping, the first template may be constructed from samples on the left side of the video unit. d. Alternatively, the sample positions of the first template and the second template may be the same. b. For example, the number of samples comprising a template may 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 may be different. b. For example, the second template may be constructed from M1 row samples above the video unit and N1 column samples to the left of the video unit, while the first template may be constructed from M2 row samples above the video unit and / or N2 column samples to the left of the video unit. The following rules may be met: 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. 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 Figures 14A-14H , where a 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), a blue rectangle indicates a current block and a current template, an orange rectangle indicates a reference block and a reference template, BV'x and BV'y indicate the horizontal displacement and vertical displacement between the current template and the reference template, respectively. BVx and BVy indicate 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 block width direction, (W tmpV , H tmpV ) represents the width and height of the vertical template along the block height direction, (x1, y1) and (x2, y2) represent the coordinates of the upper left samples of the current block and the reference block, respectively, (x1', y1') and (x2', y2') represent the coordinates of the upper left samples of the current horizontal template and the reference horizontal template, respectively, (x1", y1") and (x2", y2") represent the coordinates of the upper left samples of the current vertical template and the reference vertical template, respectively. a. For example, in the case of a horizontal template and horizontal flip (i.e., Fig.14A), i. In one example, both the current template and the reference template may include neighboring samples above the current block. ii. In one example, the relative position of (current block, current template) and (reference block, The relative positions of the reference templates) 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, samples in the current template or samples in the reference template may be flipped. iv. In one example, the samples in the current template may be flipped according to the flip type being checked (eg, horizontal flip). v. In one example, samples in the reference template may be flipped depending on the type of flip being checked (eg, horizontal flip). vi. In one example, BVx = BV'x, vii. In one example, x1′-x2′=x1-x2. b. For example, in the case of a vertical template and horizontal flip (i.e., Fig. 14B ), i. In one example, the current template may include neighboring samples on the left side of the current block, and the reference template may include neighboring samples on the right side of the current block. ii. In one example, the relative position of (current block, current template) and the relative position of (reference block, reference template) may 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. iii. In one example, samples in the current template or samples in the reference template may be flipped. iv. In one example, the samples in the current template may be flipped according to the flip type being checked (eg, horizontal flip). v. In one example, samples in the reference template may be flipped according to the type of flip being checked (eg, horizontal flip). vi. In one example, BVx = BV'x - W cur -WtmpV . vii. In one example, x2"-x1"-W cur -W tmpV =x2-xl. c. For example, in the horizontal-vertical template (where W tmpH =W cur ) and horizontal flip (i.e., Fig. 14C ), i. In one example, the current template may include neighboring samples above and to the left of the current block, and the reference template may include neighboring samples above and to the right of the current block. ii. In one example, the relative position of (current block, current horizontal template) and the relative position of (reference block, reference horizontal template) may 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 position of (current block, current vertical template) and the relative position of (reference block, reference vertical template) may 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, samples in the current horizontal template or samples in the reference horizontal template may be flipped. 1. In addition, samples in the current vertical template or samples in the reference vertical template may be flipped. v. In one example, samples in the current horizontal template and the current vertical template may be flipped according to the flip type being checked (eg, horizontal flip). vi. In one example, samples in the reference horizontal template and the reference vertical template may be flipped according to the flip type being checked (eg, horizontal flip). vii. In one example, BVx=BV'x. viii. In one example, x1′-x2′=x1-x2. d. For example, in the horizontal-vertical template (where W tmpH =W cur +W tmpV) and horizontal flip (i.e., Fig.14D ), i. In one example, the current template may include neighboring samples above and to the left of the current block, and the reference template may include neighboring samples above and to the right of the current block. ii. In one example, the relative position of (current block, current horizontal template) and the relative position of (reference block, reference horizontal template) may not 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′=H tmpH . 3. In one example, x2-x2'=0, and y2-y2'=H tmpH . iii. In one example, the relative position of (current block, current vertical template) and the relative position of (reference block, reference vertical template) may 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, samples in the current horizontal template or samples in the reference horizontal template may be flipped. 1. In addition, samples in the current vertical template or samples in the reference vertical template may be flipped. v. In one example, samples in the current horizontal template and the current vertical template may be flipped according to the flip type being checked (eg, horizontal flip). vi. In one example, samples in the reference horizontal template and the reference vertical template may be flipped according to the flip type being checked (eg, 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 vertical flip (i.e. Fig.14E ), i. In one example, the current template may include neighboring samples above the current block, and the reference template may include neighboring samples below the current block. ii. In one example, the relative position of (current block, current template) and the relative position of (reference block, reference template) may 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, samples in the current template or samples in the reference template may be flipped. iv. In one example, the samples in the current template may be flipped according to the flip type being checked (eg, vertical flip). v. In one example, samples in the reference template may be flipped according to the flip type being checked (eg, 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 vertical template and vertical flip (i.e., Fig.14F ), i. In one example, both the current template and the reference template may include neighboring samples to the left of the current block. ii. In one example, the relative position of (current block, current template) and the relative position of (reference block, reference template) may 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, samples in the current template or samples in the reference template may be flipped. iv. In one example, the samples in the current template may be flipped according to the flip type being checked (eg, vertical flip). v. In one example, samples in the reference template may be flipped according to the flip type being checked (eg, vertical flip). vi. In one example, BVy=BV'y. vii. In one example, y1"-y2"=y1-y2. g. For example, in the horizontal-vertical template (where W tmpH =W cur ) and vertical flip (i.e., Figure 14G ), i. In one example, the current template may include neighboring samples above and to the left of the current block, and the reference template may include neighboring samples to the left and below the current block. ii. In one example, the relative position of (current block, current horizontal template) and the relative position of (reference block, reference horizontal template) may 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 position of (current block, current vertical template) and the relative position of (reference block, reference vertical template) may 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, samples in the current horizontal template or samples in the reference horizontal template may be flipped. 1. Further, the samples in the current vertical template or the samples in the reference vertical template may be flipped. v. In one example, depending on the flip type being checked (eg, vertical flip), the samples in the current horizontal template and the current vertical template may be flipped. vi. In one example, depending on the flip type being checked (eg, vertical flip), samples in the reference horizontal template and the reference vertical template may be flipped. 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, horizontal-vertical template (where W tmpH =W cur +W tmpV ) and in the case of vertical flipping (i.e., Fig.14H ) i. In one example, the current template may include neighboring samples above and to the left of the current block, and the reference sample may include neighboring samples to the left and below the current block. ii. In one example, the relative position of (current block, current horizontal template) and the relative position of (reference block, reference horizontal template) may not 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'=H tmpH . 3. In one example, x2-x2'=W tmpV , and y2-y2'=-H cur . iii. In one example, the relative position of (current block, current vertical template) and the relative position of (reference block, reference vertical template) may 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, samples in the current horizontal template or samples in the reference horizontal template may be flipped. 1. In addition, samples in the current vertical template or samples in the reference vertical template may be flipped. v. In one example, samples in the current horizontal template and the current vertical template may be flipped according to the flip type being checked (eg, vertical flip). vi. In one example, samples in the reference horizontal template and the reference vertical template may be flipped according to the flip type being checked (eg, 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. 5. When the sample reordering method is applied (e.g., the fifth problem and related problems), the following method is proposed for motion search with template matching: a. In one example, for a sample reordering method (such as vertical flip or horizontal flip), samples in the template surrounding the current block may 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 templates surrounding the reference block may 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 surrounding the reference block and the template surrounding the current block can be reordered before being compared to get the cost. 6. Regarding how to determine a sample reordering method (such as no flipping, vertical flipping, or horizontal flipping) for a block (e.g., the sixth problem or a related problem) encoded and decoded by template matching (such as intra template matching and / or IBC mode with template matching), the following method is proposed: a. In one example, the sample reordering method may depend on at least one syntax element signaled from the encoder to the decoder. i. In one example, a syntax element may indicate whether and / or how to reorder samples for a template matching coded block (such as intra template matching and / or IBC mode with template matching). ii. The syntax element may be encoded in the same way as 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, a sample reordering method may be derived based on at least one template cost. i. In one example, motion search with template matching can be applied to the block to derive the minimum cost of different sample reordering methods. ii. In one example, a sample reordering method having a minimum template cost may be derived as the determined sample reordering method. General Aspects 7. Whether and / or how to apply the method disclosed above can be transmitted by signaling at sequence level / picture group level / picture level / slice level / tile group level, for example in sequence header / picture header / SPS / VPS / DPS / DCI / PPS / APS / slice header / tile group header. 8. Whether and / or how the above disclosed methods may be applied to signal in PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / slice / tile / sub-picture / other kinds of regions containing more than one sample or pixel. 9. Whether and / or how to apply the above disclosed method may depend on the coded information, such as block size, color format, single tree / dual tree partitioning, color component, slice / picture type. 2.2.6 Interaction between RRIBC and IBC-TM_v0 The detailed solutions below should be considered as examples to explain the general concept. These solutions should not be interpreted in a narrow sense. In addition, these solutions can be combined in any way. The term “video unit” or “codec unit” may refer to a picture, a slice, a tile, a codec tree block (CTB), a codec tree unit (CTU), a codec block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may refer to a codec tree block (CTB), a codec tree unit (CTU), a codec 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 existing standards. Any changes in codec tools are also applicable. 1. When the neighbor candidate is encoded or decoded as RRIBC, regarding the interaction between RRIBC and IBC-TM such as how to construct the IBC-TM-MERGE list (eg, Problem 1 and related issues), the following method is proposed. i. For example, an IBC-TM-MERGE candidate may inherit motion from a neighboring block that was decoded by RRIBC. a. In one example, motion can be inherited directly. b. In one example, motion may first be adjusted (eg, have a motion offset added to it) and then inherited. c. Alternatively, an IBC-TM-MERGE candidate may not inherit motion from neighboring blocks decoded by RRIBC. j. For example, an IBC-TM-MERGE candidate may not inherit the flip type from a neighboring block that is decoded by RRIBC. a. In one example, the flip type of an IBC-TM-MERGE candidate may always be set equal to NO_FLIP, regardless of whether the motion of this IBC-TM merge candidate is inherited from a neighboring block that is decoded by RRIBC. k. Alternatively, the IBC-TM-MERGE candidate may inherit the flip type from a neighboring block that is decoded by RRIBC. a. In one example, the rollover type of this IBC-TM-MERGE candidate is set equal to the rollover type of the neighboring block decoded by RRIBC. 1. For example, an IBC-TM-MERGE candidate may inherit motion from a neighboring block decoded with RRIBC, but never inherit flip type from a neighboring block decoded with RRIBC. a. In one example, motion can be inherited directly. b. In one example, motion may first be adjusted (eg, have a motion offset added to it) and then inherited. c. In one example, the flip type of an IBC-TM-MERGE candidate may always be set equal to NO_FLIP. m. For example, IBC-TM-MERGE candidates may be prohibited from being derived based on neighboring blocks that are decoded by RRIBC. a. In this case, the motion and flip types of neighboring blocks decoded by RRIBC may be prohibited from being added to the IBC-TM-MERGE candidate. b. In this case, if the neighboring block is coded with RRIBC, the codec information of the neighboring block is never inserted into the IBC-TM-MERGE list. 2. When IBC-TM is allowed (eg, Question 2 and related issues), the following method is proposed regarding the interaction between RRIBC and IBC-TM such as how to construct an IBC AMVP list based on RRIBC. a. For example, in the case where the current video unit is in IBC-AMVP mode with RRIBC (eg, the flip type of the current video unit is not equal to NO_FLIP), the AMVP candidate may not be allowed to be refined by template matching (eg, IBC-TM-AMVP). b. For example, in the case where the current video unit is in IBC-AMVP mode without RRIBC (eg, the flip type of the current video unit is equal to NO_FLIP), the AMVP candidates may be allowed to be refined by template matching (eg, IBC-TM-AMVP). c. For example, during the IBC-AMVP list generation process, the MVD threshold used for similarity checking (e.g., pruning process by comparing the similarity between a potential candidate and another candidate already in the list) may be different in different video units depending on whether the current video unit is encoded and decoded by RRIBC or non-RRIBC. a. In one example, assuming that the MVD threshold of the video unit of the IBC-AMVP non-RRIBC codec is equal to K1, and the MVD threshold of the IBC-AMVP RRIBC video unit is equal to K2, then K1 may not be equal to K2. b. Additionally, furthermore, K1 may be greater than K2. c. Additionally, furthermore, K1 and / or K2 may be predefined. i. For example, K1 and / or K2 may be equal to a specific number (eg, 0 or 1). ii. For example, K1 and / or K2 may depend on the dimensions of the current video unit (eg, width / height, number of samples / pixels). iii. For example, K1 and / or K2 may be derived based on the same rules used in similarity checking of existing codec tools in the codec (eg, IBC-TM-MERGE mode, Inter-TM mode, etc.). d. Alternatively, K1 may be equal to K2. d. For example, when the current video unit is in IBC-AMVP mode with RRIBC (for example, the flip type of the current video unit is not equal to NO_FLIP) and the MVP candidate of the current video unit is also coded and decoded by RRIBC, a. In one example, first the motion vector of the MVP candidate may be adjusted and then used for the current video unit. b. In one example, motion adjustment may be performed only if the flip type of the current video unit and the flip type of the neighboring block used to derive the MVP candidate are the same. i. Alternatively, motion adjustment can be performed as long as the current video unit and neighboring blocks are coded by RRIBC. c. In one example, motion adjustment may refer to adding motion offset to the MVP candidate. d. In one example, the motion offset may depend on the block dimensions and / or position of the current video unit. e. In one example, the motion offset may depend on the block dimensions and / or positions of neighboring blocks used to derive the MVP candidate. e. For example, when the current video unit is in IBC-AMVP mode with non-RRIBC (eg, the flip type of the current video unit is equal to NO_FLIP) and the MVP candidate of the current video unit is RRIBC coded, a. In one example, the motion vector of the MVP candidate may not be adjusted. b. Alternatively, the motion vector of the MVP candidate may be adjusted. i. In one example, motion adjustment can be used as long as the neighboring blocks are coded by RRIBC. c. In one example, motion adjustment may refer to adding motion offset to the MVP candidate. d. In one example, the motion offset may depend on the block dimensions and / or position of the current video unit. e. In one example, the motion offset may depend on the block dimensions and / or positions of neighboring blocks used to derive the MVP candidate. 3 Questions How to handle the interaction between RRIBC and adaptive reordering motion compensation (eg, ARMC) needs to be considered. 1. How to apply ARMC when the prediction list contains RRIBC candidates. 2. Which samples should be used to construct the reference template for RRIBC-based ARMC. 3. Whether and how to reorder samples in the template used for RRIBC-based ARMC. In the case of RRIBC it can be extended to template-based methods, such as IBC-TM merging and / or template-based AMVP candidate refinement, and / or Intra-TM. 4. The position of the current template relative to the current video unit and the position of the reference template relative to the reference video unit may be different. a. In addition, samples in the reference template can be filled with sample values in the reference video unit. 5. Samples in the current template or reference template can be reordered. 4. Embodiment The following detailed embodiments should be considered as examples to explain the general concept. These embodiments should not be interpreted in a narrow manner. In addition, these embodiments can be combined in any way. The term “video unit” or “codec unit” may refer to a picture, a slice, a tile, a codec tree block (CTB), a codec tree unit (CTU), a codec block (CB), a CU, a PU, a TU, a PB, a TB. The term "block" may refer to a codec tree block (CTB), a codec tree unit (CTU), a codec 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 existing standards. Any variation of the codec tool is also applicable. Fig.15A A reference template 1510 and a current template 1520 are shown for template cost calculation when the motion candidate is RRIBC codec, where the motion candidate is RRIBC with horizontal flip codec. Fig. 15B A reference template 1511 and a current template 1521 are shown for template cost calculation when the motion candidate is RRIBC codec, where the motion candidate is RRIBC with vertical flip codec. 4.1. In the case where the prediction list contains RRIBC candidates, regarding the interaction between RRIBC and ARMC, such as how to apply ARMC (e.g., (the first question and related questions), the following method is proposed: a. For example, if a prediction list contains at least one motion candidate of RRIBC codec, ARMC can be used for the prediction list, but using templates of different shapes for different motion candidates based on the RRIBC flip type of the specific motion candidate. b. For example, if a prediction list contains at least one motion candidate for RRIBC codec, ARMC may not be used for the prediction list. c. For example, if the prediction list contains at least one motion candidate of RRIBC codec, ARMC may be used only for motion candidates of non-RRIBC codec. a. In one example, assume that motion candidates in a prediction list are divided into different subgroups according to whether RRIBC is used (such as an RRIBC subgroup and a non-RRIBC subgroup). i. For example, for motion candidates in the RRIBC subgroup, ARMC may not be applied. ii. For example, for motion candidates in the non-RRIBC subgroup, ARMC may be applied. b. In one example, the order of which candidate subgroup (RRIBC, non-RRIBC) is placed first in the final prediction list may depend on codec information. i. In one example, ARMC-ordered non-RRIBC candidates may be placed before non-ARMC-processed RRIBC candidates. ii. In one example, ARMC-ordered non-RRIBC candidates may be placed after non-ARMC-processed RRIBC candidates. iii. In one example, the codec information may refer to the flip type of the first available candidate in the original prediction list (before ARMC processing). iv. In one example, if the first available candidate in the original prediction list is RRIBC coded, the non-ARMC processed RRIBC candidate may be placed first. v. In one example, if the first available candidate in the original prediction list is of non-RRIBC codec, then the ARMC-ordered non-RRIBC candidate may be placed first. 4.2 Regarding the interaction between RRIBC and ARMC, such as which samples should be used to construct reference templates for RRIBC-based ARMC (e.g., the second question and related questions), the following approach is proposed: a. For example, when performing ARMC on a prediction list including at least one RRIBC codec candidate, a second reference template different from the first reference template may be used, where a "reference template" refers to a template of a reference block. a. In one example, the first reference template is constructed by left samples and / or upper samples adjacent to the reference block (eg Fig.15A and Fig. 15B shown). i. Furthermore, additionally, the first reference template is used to calculate the template cost of the candidate for the non-RRIBC codec. b. In one example, a second reference template can be constructed from a bottom sample adjacent to the reference block. c. In one example, the second reference template can be constructed from right samples adjacent to the reference block. d. In one example, the second reference template may be used to calculate the template cost of the candidate for the RRIBC codec. e. In one example, whether to use the bottom samples or the right samples adjacent to the reference block to construct the reference template may depend on the flip type of the RRIBC codec candidate. f. In one example, whether to use the second reference template or the first reference template may depend on the candidate flip type. g. In one example, Fig.15A As shown, the second template is constructed from upper samples and right samples adjacent to the reference block, and the first template is constructed from upper samples and left samples adjacent to the current block. h. In one example, Fig. 15B As shown, the second template is constructed from the bottom samples and the left samples adjacent to the reference block, and the first template is constructed from the top samples and the left samples adjacent to the current block. b. For example, a validation check may be applied to a reference template of the RRIBC codec candidate. a. In one example, Fig.15A As shown, a validation check may be applied to check whether the right portion of the reference template is within the valid region. b. In one example, Fig. 15B As shown, a validation check may be applied to check whether the bottom portion of the reference template is within the valid area. c. In one example, the valid area may be predefined by a set of rules related to codec information (eg, VPDU size, LCU size, tile / picture / slice boundary, tile row, etc.). d. In one example, if a sample of the reference template is outside the valid area, another sample within the valid area may be used instead to construct the reference template. i. For example, the valid sample closest to the invalid sample may be used. ii. For example, valid samples (eg, close to invalid samples) within the reference block may be used. e. In one example, if at least one sample of the reference template is outside the valid area, the candidate reference template may be considered unavailable. i. For example, in this case, ARMC may not be applied to the prediction list. f. In one example, Fig.15A As shown, if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns within the reference block may be used instead to construct the reference template, where M is equal to the width of the right portion of the reference template (e.g., M is predefined). g. In one example, Fig. 15B As shown, if at least one sample of the bottom portion of the reference template is outside the valid area, at least one sample of the top N rows within the reference block may be used instead to construct the reference template, where N is equal to the height of the bottom portion of the reference template (e.g., N is predefined). c. For example, the term "sample" in the above aspects may refer to a reconstructed sample. d. For example, the term "sample" in the above aspects may refer to a prediction sample. 4.3 Regarding the interaction between RRIBC and ARMC, such as whether and how to reorder samples in the template for RRIBC-based ARMC (e.g., the third question and related questions), the following method is proposed: a. For example, when ARMC is performed on a prediction list including at least one RRIBC codec candidate, samples in the reference template may be reordered (ie, flipped horizontally, flipped vertically, etc.). a. In one example, samples in the upper portion of the reference template may be reordered, and / or samples in the right portion of the reference template may be reordered. b. In one example, samples in the left portion of the reference template may be reordered, and / or samples in the bottom portion of the reference template may be reordered. c. In one example, whether to reorder samples in the reference template may depend on the candidate flip type. d. In one example, Fig.15A As shown, samples in the upper portion of the reference template constructed from upper samples adjacent to the reference block may be horizontally flipped. e. In one example, if Fig. 15B As shown in , samples in the right portion of a reference template constructed from right samples adjacent to a reference block may be horizontally flipped. i. Furthermore, additionally, if the width of the right portion of the reference template is equal to a certain number (such as 1), there may be no need to perform horizontal flipping. f. In one example, Fig. 15B As shown in , samples in the left portion of the reference template constructed from left samples adjacent to the reference block may be vertical. g. In one example, Fig. 15B As shown in , samples in the bottom portion of a reference template constructed from bottom samples adjacent to a reference block may be flipped vertically. i. Furthermore, additionally, if the height of the bottom portion of the reference template is equal to a certain number (such as 1), there may be no need to perform vertical flipping. h. In an example, assuming that "temp" represents the sample buffer of the upper / right / left / bottom part of the reference template, (temp W, tempH) represents the width and height of the upper / right / left / bottom part of the reference template, (x, y) represents the position of the upper / right / left / bottom part of the reference template relative to the part of the reference template, "cur" represents the sample buffer of the current video unit, (curW, curH) represents the width and height of the current video unit, and "curStride" represents the stride of the sample buffer of the current video unit. i. For example, in the case of horizontal flipping, the samples in the upper part of the reference template can be exported as: 1.temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride] ii. For example, in the case of horizontal flipping, the samples in the right part of the reference template can be exported as: 1.temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride] iii. For example, in the case of vertical flipping, the samples in the bottom part of the reference template can be exported as: 1.temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride] iv. For example, in the case of vertical flipping, the samples in the left part of the reference template can be exported as: 1.temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride] b. For example, when performing ARMC on a prediction list including at least one RRIBC codec candidate, samples in a current template may be reordered (ie, horizontally flipped, vertically flipped, etc.), where "current template" refers to a template of a current block. a. In one example, samples in the upper portion of the current template may be reordered, and / or samples in the left portion of the current template may be reordered. b. In one example, whether to reorder samples in the current template may depend on the candidate flip type. c. In one example, Fig.15A As shown, samples in the upper portion of the current template constructed from upper samples adjacent to the current block may be horizontally flipped. d. In one example, Fig.15A As shown, samples in the left portion of the reference template constructed from left samples adjacent to the current block may be horizontally flipped. i. Furthermore, additionally, if the width of the left portion of the current template is equal to a certain number (such as 1), there may be no need to perform horizontal flipping. e. In one example, Fig. 15B As shown, samples in the upper portion of the current template constructed from upper samples adjacent to the current block may be vertically flipped. i. Furthermore, additionally, if the height of the upper portion of the current template is equal to a certain number (such as 1), there may be no need to perform vertical flipping. f. In one example, Fig. 15B As shown, samples in the left portion of the current template constructed from left samples adjacent to the current block may be vertically flipped. g. In one example, assuming that "temp" represents the sample buffer of the upper / right / left / bottom part of the current template, (temp W, tempH) represents the width and height of the upper / right / left / bottom part of the current template, (x, y) represents the position of the upper / right / left / bottom part of the current template relative to the part of the current template, "cur" represents the sample buffer of the current video unit, (curW, curH) represents the width and height of the current video unit, and "curStride" represents the stride of the sample buffer of the current video unit. i. For example, in the case of horizontal flipping, the samples in the upper part of the current template can be exported as: 1.temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride] ii. For example, in the case of horizontal flipping, the samples in the right part of the current template can be exported as: 1.temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride] iii. For example, in the case of vertical flipping, the samples in the bottom part of the current template can be exported as: 1.temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride] iv. For example, in the case of vertical flipping, the samples in the left part of the current template can be exported as: 1.temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride] c. For example, at most one template (eg, the current template or the reference template) can be reordered. a. In one example, if the samples in the current template are reordered, the samples in the reference template may not be reordered. b. In one example, if the samples in the reference template are reordered, the samples in the current template may not be reordered. d. For example, the term "sample" in the above aspects may refer to a reconstructed sample. e. For example, the term "sample" in the above aspects may refer to a prediction sample. 4.4 Regarding the location of the current / reference template and the filling of template samples for template-based methods (e.g., the fourth problem and related problems), the following method is proposed: a. For example, a template-based approach may refer to a coding tool based on at least one template in a current picture and / or a reference picture. a. In one example, the template cost may be calculated by comparing the difference / error / distortion between the current template and the reference template. b. In one example, template matching / refinement can be performed based on template cost. c. In one example, the template-based method can be the IBC-TM merge mode. d. In one example, the template-based approach can be TM-based IBC AMVP candidate refinement. e. In one example, the template-based approach may be an ARMC-based IBC mode. f. In addition, for example, RRIBC can be used for video units encoded and decoded by template-based methods. g. In addition, for example, RRIBC may not be used for video units encoded or decoded by the template-based approach. b. For example, the position of (at least a portion of) the current template relative to the current video unit and the position of (at least a portion of) the reference template relative to the reference video unit may be different. a. In one example, as shown in FIG11( a ). b. In one example, as shown in FIG11( b ). c. For example, aspects of item 4.2 and / or its sub-items may be applicable to the second template-based method (in addition to ARMC). a. In addition, accordingly, the wording "when ARMC is performed on a prediction list including at least one candidate for RRIBC encoding and decoding" in item 4.2 and / or its sub-items can be replaced by "when RRIBC is applied to a current video unit encoded and decoded by a template-based method". b. In addition, accordingly, the wording "candidate for RRIBC codec" in item 4.2 and / or its sub-items may be replaced by "video unit of RRIBC codec". c. In addition, for example, the reference template of the video unit encoded by the template-based method may include neighboring samples adjacent to the right side and / or the bottom side and / or the top side and / or the left side of the reference video unit. d. In addition, for example, a reference template of a video unit encoded and decoded by a template-based method may include samples within the reference video unit. d. In addition, for example, aspects of item 4.2b and / or its sub-items may be applicable to video units encoded in non-RRIBC codecs. a. In one example, a validation check may be applied to a reference template of a non-RRIBC codec video unit. b. In one example, if the reference template of a non-RRIBC codec video unit exceeds the valid area, at least one sample within the valid area (eg, within the reference video unit) may be used instead to fill the reference template. e. In addition, in one example, the second template-based method in the above aspect may refer to any template-based method shown in 4.4.a. 4.5 Regarding template sample reordering for template-based methods (e.g., the fifth problem and related problems), the following method is proposed: a. For example, a template-based approach may refer to a coding tool based on at least one template in a current picture and / or a reference picture. a. In one example, the template cost can be calculated by comparing the difference / error / distortion between the current template and the reference template. b. In one example, template matching / refinement can be performed based on template cost. c. In one example, the template-based method can be the IBC-TM merge mode. d. In one example, the template-based approach can be TM-based IBC AMVP candidate refinement. e. In one example, the template-based approach may be an ARMC-based IBC mode. f. In addition, for example, RRIBC can be used for video units encoded and decoded by template-based methods. g. In addition, for example, RRIBC may not be used for video units encoded or decoded by the template-based approach. b. For example, aspects of item 4.3 and / or its sub-items may be applicable to the second template-based method (in addition to ARMC). a. In addition, accordingly, the wording "when ARMC is performed on a prediction list including at least one candidate for RRIBC encoding and decoding" in item 4.3 and / or its sub-items can be replaced by "when RRIBC is applied to a current video unit encoded and decoded by a template-based method". b. In addition, accordingly, the wording "candidate for RRIBC codec" in item 4.3 and / or its sub-items may be replaced by "video unit of RRIBC codec". c. In addition, for example, samples (at least a portion of) in a reference template of a video unit encoded by a template-based method may be reordered (ie, flipped horizontally, flipped vertically, etc.). d. Furthermore, alternatively, (at least a portion of) the samples in the current template of the video unit encoded by the template-based method may be reordered (ie, flipped horizontally, flipped vertically, etc.). e. Furthermore, for example, (at least a portion of) the samples in the reference template or (at least a portion of) the samples in the current template may be reordered (but never both). c. In addition, in one example, the second template-based method in the above aspect may refer to any template-based method shown in 4.5.a. General 4.6 Whether and / or how to apply the method disclosed above may be transmitted by a signal at a sequence level / picture group level / picture level / slice level / tile group level, such as in a sequence header / picture header / SPS / VPS / DPS / DCI / PPS / PPS / APS / slice header / tile group header. 4.7 Whether and / or how to apply the above disclosed methods may be signaled at a PB / TB / CB / PU / TU / CU / VPDU / CTU / CTU row / slice / tile / sub-picture / other kind of region containing more than one sample or pixel. 4.8 Whether and / or how to apply the above disclosed method may depend on codec information, such as block size, color format, single / dual tree partitioning, color component, slice / picture type.
[0081] As used herein, the term "video unit" or "video block" may be a sequence, picture, slice, tile, block, sub-picture, codec tree unit (CTU) / codec tree block (CTB), CTU row / CTB row, one or more codec units (CU) / codec blocks (CB), one or more CTU / CTB, one or more virtual pipeline data units (VPDU), sub-region within a picture / slice / tile / block. The term "image compression" may refer to any variation of a signal processing method that compresses or processes the current input. Input images / videos include, but are not limited to, screen content and natural content.
[0082] Fig.16 A flow chart of a method 1600 for video processing according to an embodiment of the present disclosure is shown. The method 1600 is implemented during conversion between a video unit of a video and a bitstream of the video.
[0083] At block 1610, for conversion between a video unit of a video and a bitstream of the video unit, it is determined whether template-based processing is applied to the video unit. The template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit. For example, a template-based method may refer to a codec tool based on at least one template in a current picture and / or a reference picture.
[0084] At block 1620, conversion is performed based on the determination. In this way, encoding and decoding efficiency can be improved. In some embodiments, conversion may include encoding the video unit into a bitstream. Alternatively or additionally, conversion may include decoding the video unit from the bitstream.
[0085] In some embodiments, the template cost is determined by comparing at least one of: a difference, an error, or a distortion between the current template and a reference template. In some embodiments, template matching or template refinement is performed based on the template cost.
[0086] In some embodiments, template-based processing includes one of: intra block copy (IBC) template matching (TM) merge mode, TM-based IBC advanced motion vector prediction (AMVP) candidate refinement, or adaptive reordering-based motion compensation (ARMC) IBC mode.
[0087] In some embodiments, if the video unit is encoded using template-based processing, reconstruction reordered IBC (RRIBC) is applied to the video unit.Alternatively, if it is determined that the video unit is encoded using template-based processing, RRIBC is not applied to the video unit.
[0088] In some embodiments, the position of at least a portion of the current template relative to the current video unit and the position of at least a portion of the reference template relative to the reference video unit are different.
[0089] In some embodiments, Fig.15A As shown in , the current template is located above and to the left of the current video unit, and the reference template is located above and to the right of the reference video unit. Fig. 15B As shown in , the current template is located above and to the left relative to the current video unit, and the reference template is located below and to the left relative to the reference video unit.
[0090] In some embodiments, if a template-based process other than ARMC is applied to the prediction list, a second reference template different from the first reference template is used. In some other embodiments, if RRIBC is applied to a video unit encoded and decoded using a template-based process, a second reference template different from the first reference template is used.
[0091] In some embodiments, the validation check is applied to a reference template of the motion candidate of at least one RRIBC codec.
[0092] In some embodiments, a validation check is applied to check whether the right portion of the reference template is within the valid area.
[0093] In some embodiments, a validation check is applied to check whether the bottom portion of the reference template is within the valid area.
[0094] In some embodiments, the valid area is predefined by a set of rules associated with the codec information.
[0095] In some embodiments, the codec information includes at least one of: a virtual pipeline data unit (VPDU) size, a maximum codec unit (LCU) size, a tile boundary, a picture boundary, a slice boundary, or a tile row.
[0096] In the above case, in some embodiments, if a sample of the reference template is outside the valid area, another sample in the valid area is used instead to construct the reference template. In some embodiments, the valid sample closest to the invalid sample is used. In some embodiments, the valid sample in the reference block is used. In some embodiments, if at least one sample of the reference template is outside the valid area, the reference template of the motion candidate of at least one RRIBC codec is deemed unavailable.
[0097] In some embodiments, template based processing is not applied to the prediction list. Alternatively, RRIBC is not applied to video units coded using template based processing. Alternatively, ARMC is not applied to video units coded for non-RRIBC video units.
[0098] In some embodiments, if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns in the reference block is used instead to construct the reference template. In this case, M is equal to the width of the right portion of the reference template.
[0099] In some embodiments, if at least one sample of the bottom portion of the reference template is outside the valid area, at least one sample of the top N rows within the reference block is used instead to construct the reference template. In this case, M is equal to the width of the right portion of the reference template.
[0100] In some embodiments, the second reference template is used to determine the template cost of the at least one RRIBC coded video unit. In some embodiments, using the bottom sample or the right sample adjacent to the reference block to construct the reference template of the reference block depends on the flip type of the at least one RRIBC coded video unit.
[0101] In some embodiments, the validation check is applied to a reference template of at least one RRIBC-encoded video unit. In some embodiments, the reference template of the video unit includes neighboring samples adjacent to at least one of the following, right, bottom, top, or left sides of the reference video unit. In some embodiments, the reference template of the video unit includes samples within the reference video unit.
[0102] In some embodiments, if ARMC is applied to a video unit that is a non-RRIBC codec video unit, a second reference template different from the first reference template is used. In this case, in some embodiments, a validation check is applied to the reference template of the non-RRIBC codec video unit.
[0103] In some other embodiments, a validation check is applied to check whether the right portion of the reference template is within the valid area. In some other embodiments, a validation check is applied to check whether the bottom portion of the reference template is within the valid area.
[0104] In some embodiments, the valid area is predefined by a set of rules related to codec information. In some embodiments, the codec information includes at least one of the following: a virtual pipeline data unit (VPDU) size, a maximum codec unit (LCU) size, a tile boundary, a picture boundary, a slice boundary, or a tile row.
[0105] In some embodiments, if a sample of the reference template is outside the valid area, another sample in the valid area is used instead to construct the reference template. In some embodiments, the valid sample closest to the invalid sample is used. In some embodiments, the valid sample within the reference block is used.
[0106] In some embodiments, a reference template of a non-RRIBC codec video unit is considered unusable if at least one sample of the reference template is outside the valid area. In some embodiments, ARMC is not applied to non-RRIBC codec video units.
[0107] In some embodiments, if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns within the reference block is used instead to construct the reference template, where M is equal to the width of the right portion of the reference template. In some embodiments, if at least one sample of the bottom portion of the reference template is outside the valid area, at least one sample of the top N rows within the reference block is used instead to construct the reference template, where N is equal to the height of the bottom portion of the reference template.
[0108] In some embodiments, if the reference template of the non-RRIBC codec video unit exceeds the valid area, at least one sample in the valid area is used instead to fill the reference template. In some embodiments, the first reference template is constructed from at least one of the following: a left sample or an upper sample adjacent to the reference block. In some embodiments, the first reference template is used to determine the template cost of the motion candidate that does not utilize RRIBC codec.
[0109] In some embodiments, the second reference template is constructed from at least one of bottom samples or right samples adjacent to the reference block.In some embodiments, the second reference template is used to determine a template cost for at least one motion candidate of an RRIBC codec.
[0110] In some embodiments, using the bottom sample or the right sample adjacent to the reference block to construct the reference template of the reference block depends on the flip type of the motion candidate of at least one RRIBC codec. In some embodiments, using the second reference template or the first reference template depends on the flip type of the motion candidate.
[0111] In some embodiments, the second template is constructed from upper and right samples adjacent to the reference block, and the first template is constructed from upper and left samples adjacent to the current block. In some embodiments, the second template is constructed from bottom and left samples adjacent to the reference block, and the first template is constructed from upper and left samples adjacent to the current block. In some embodiments, if template-based processing other than ARMC is applied to the prediction list, samples in the reference template of the reference block of the video unit are reordered.
[0112] In some embodiments, if RRIBC is applied to a video unit that is coded using template-based processing, samples in a reference template of a reference block of the video unit are reordered. In some embodiments, if ARMC is applied to a video unit that is coded for RRIBC, samples in a reference template of a reference block of the video unit are reordered.
[0113] In some embodiments, samples in the upper portion of the reference template are reordered. Alternatively, or additionally, samples in the right portion of the reference template are reordered. In some embodiments, samples in the left portion of the reference template are reordered. Alternatively, or additionally, samples in the bottom portion of the reference template are reordered. In some embodiments, whether to reorder samples in the reference template depends on the flip type of the motion candidate.
[0114] In some embodiments, the horizontal flipping process is applied to samples in an upper portion of a reference template constructed from upper samples adjacent to the reference block. In some embodiments, the horizontal flipping process is applied to samples in a right portion of a reference template constructed from right samples adjacent to the reference block. In some embodiments, if the width of the right portion of the reference template is equal to a predefined number, the horizontal flipping process is not applied.
[0115] In some embodiments, the vertical flipping process is applied to samples in the left portion of the reference template constructed from left samples adjacent to the reference block. In some embodiments, the vertical flipping process is applied to samples in the bottom portion of the reference template constructed from bottom samples adjacent to the reference block. In some embodiments, if the height of the bottom portion of the reference template is equal to a predefined number, the vertical flipping process is not applied.
[0116] In an example, it can be assumed that "temp" represents the sample buffer of the top / right / left / bottom part of the reference template, (temp W, tempH) represents the width and height of the top / right / left / bottom part of the reference template, (x, v) represents the position of the top left sample of the top / right / left / bottom part of the reference template relative to the part of the reference template, "cur" represents the sample buffer of the current video unit, (curW, curH) represents the width and height of the current video unit, and "curStride" represents the stride of the sample buffer of the current video unit.
[0117] In some embodiments, if a horizontal flip process is applied, the samples in the upper part of the reference template are derived as: temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride], and wherein temp represents the sample buffer of the upper part of the reference template, (temp W, tempH) represents the width and height of the upper part of the reference template, (x, y) represents the position of the upper left sample of the upper part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0118] In some embodiments, if a horizontal flip process is applied, the samples in the right part of the reference template are derived as: temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride], and wherein temp represents the sample buffer of the right part of the reference template, (temp W, tempH) represents the width and height of the right part of the reference template, (x, y) represents the position of the upper left sample of the right part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0119] In some embodiments, if vertical flip processing is applied, the samples in the bottom portion of the reference template are derived as: temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride]], and wherein temp represents the sample buffer of the bottom portion of the reference template, (temp W, tempH) represents the width and height of the bottom portion of the reference template, (x, y) represents the position of the upper left sample of the bottom portion of the reference template relative to the portion of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0120] In some embodiments, if vertical flip processing is applied, the samples in the left part of the reference template are derived as: temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride], and wherein temp represents the sample buffer of the left part of the reference template, (temp W, tempH) represents the width and height of the left part of the reference template, (x, y) represents the position of the upper left sample of the left part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0121] In some embodiments, if ARMC is applied to the prediction list, the samples in the current template of the current block of the video unit are sorted. In some embodiments, if ARMC is applied to the video unit for RRIBC encoding and decoding of the video unit, the samples in the current template of the current block of the video unit are sorted.
[0122] In some embodiments, samples in the upper portion of the current template are reordered. Alternatively, or additionally, samples in the left portion of the current template are reordered. In some embodiments, whether to reorder samples in the current template depends on the flip type of the motion candidate.
[0123] In some embodiments, the horizontal flipping process is applied to samples in the upper portion of the current template constructed from upper samples adjacent to the current block. In some embodiments, the horizontal flipping process is applied to samples in the left portion of the reference template constructed from left samples adjacent to the current block. In some embodiments, if the width of the left portion of the current template is equal to a predefined number, the horizontal flipping process is not applied.
[0124] In some embodiments, the vertical flipping process is applied to samples in the upper portion of the reference template constructed from upper samples adjacent to the current block. In some embodiments, if the height of the upper portion of the current template is equal to a predefined number, the vertical flipping process is not applied. In some embodiments, the vertical flipping process is applied to samples in the left portion of the current template constructed from left samples adjacent to the current block.
[0125] In an example, it can be assumed that "temp" represents the sample buffer of the top / right / left / bottom part of the current template, (temp W, tempH) represents the width and height of the top / right / left / bottom part of the current template, (x, y) represents the position of the top left sample of the top / right / left / bottom part of the current template relative to that part of the reference template, "cur" represents the sample buffer of the current video unit, (curW, curH) represents the width and height of the current video unit, and "curStride" represents the stride of the sample buffer of the current video unit.
[0126] In some embodiments, if horizontal flipping processing is applied, the samples in the upper part of the current template are derived as: temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride], and wherein temp represents the sample buffer of the upper part of the current template, (temp W, tempH) represents the width and height of the upper part of the current template, (x, y) represents the position of the upper left sample of the upper part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0127] In some embodiments, if horizontal flipping processing is applied, the samples in the right part of the current template are derived as: temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride], and wherein temp represents the sample buffer of the right part of the current template, (temp W, tempH) represents the width and height of the right part of the current template, (x, y) represents the position of the upper left sample of the right part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0128] In some embodiments, if vertical flip processing is applied, the samples in the bottom portion of the current template are derived as: temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride]], and wherein temp represents the sample buffer of the bottom portion of the current template, (temp W, tempH) represents the width and height of the bottom portion of the current template, (x, y) represents the position of the upper left sample of the bottom portion of the current template relative to the portion of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0129] In some embodiments, if vertical flip processing is applied, the samples in the left part of the current template are derived as: temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride], and wherein temp represents the sample buffer of the left part of the current template, (temp W, tempH) represents the width and height of the left part of the current template, (x, y) represents the position of the upper left sample of the left part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0130] In some embodiments, at most one template is reordered. In some embodiments, samples in a current template for a current block of a video unit are reordered, and samples in a reference template for a reference block of a video unit are not reordered. In some embodiments, samples in a reference template for a reference block of a video unit are reordered, and samples in the current template for the current block of the video unit are not reordered.
[0131] In some embodiments, at least a portion of the samples in a reference template of a video unit encoded using template-based processing are ordered. In some embodiments, at least a portion of the samples in a current template of a video unit encoded using template-based processing are ordered. In some embodiments, at least a portion of the samples in a reference template of a video unit encoded using template-based processing or at least a portion of the samples in the current template are ordered. In some embodiments, the samples include at least one of: reconstructed samples or predicted samples.
[0132] In some embodiments, whether to determine whether template-based processing is applied to a video unit and / or how to determine whether template-based processing is applied to a video unit is indicated at one of the following: sequence level, picture group level, picture level, slice level, or tile group level. In some embodiments, whether to determine whether template-based processing is applied to a video unit and / or how to determine whether template-based processing is applied to a video unit is indicated in one of the following: sequence header, picture header, sequence parameter set (SPS), video parameter set (VPS), dependency parameter set (DPS), decoding capability information (DCI), picture parameter set (PPS), adaptation parameter sets (APs), slice header, or tile group header. In some embodiments, an indication of whether to determine whether template-based processing is applied to a video unit and / or how to determine whether template-based processing is applied to a video unit is included in one of the following: a prediction block (PB), a transform block (TB), a codec block (CB), a prediction unit (PU), a transform unit (TU), a codec unit (CU), a virtual pipeline data unit (VPDU), a codec tree unit (CTU), a CTU row, a slice, a tile, a sub-picture, or a region containing more than one sample or pixel.
[0133] In some embodiments, method 1600 further includes: determining whether to apply template-based processing to the video unit and / or how to determine whether template-based processing is applied to the video unit based on codec information of the video unit. The codec information may include at least one of the following: block size, color format, single tree partitioning and / or dual tree partitioning, color component, slice type, or picture type.
[0134] According to another 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 performed by an apparatus for video processing. The method includes: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of the following: a current picture or a reference picture of the video unit; and generating a bitstream based on the determination.
[0135] According to some further embodiments of the present disclosure, a method for storing a bitstream of a video is provided. The method includes: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of the following: a current picture or a reference picture of the video unit; generating a bitstream based on the determination; and storing the bitstream in a non-transitory computer-readable recording medium.
[0136] Embodiments of the present disclosure may be described according to the following clauses, features of which may be combined in any reasonable way.
[0137] Clause 1. A method of video processing, comprising: determining whether template-based processing is applied to a conversion between a video unit of a video and a bitstream of the video unit, wherein the template-based processing is based on at least one template of at least one of the following: a current picture or a reference picture of the video unit; and performing the conversion based on the determination.
[0138] Clause 2. The method of clause 1, wherein the template cost is determined by comparing at least one of: a difference, an error, or a distortion between the current template and a reference template.
[0139] Clause 3. The method of clause 1, wherein template matching or template refinement is performed based on template cost.
[0140] Clause 4. A method according to clause 1, wherein the template-based processing includes one of the following: intra block copy (IBC) template matching (TM) merge mode, TM-based IBC advanced motion vector prediction (AMVP) candidate refinement, or adaptive reordering-based motion compensation (ARMC) IBC mode.
[0141] Clause 5. A method according to Clause 1, wherein based on a determination that the video unit was encoded and decoded using the template-based processing, a reconstructed reordered IBC (RRIBC) is applied to the video unit, or wherein based on a determination that the video unit was encoded and decoded using the template-based processing, the RRIBC is not applied to the video unit.
[0142] Clause 6. The method of clause 1, wherein a position of at least a portion of the current template relative to a current video unit and a position of at least a portion of the reference template relative to a reference video unit are different.
[0143] Clause 7. The method of clause 1, wherein the current template is located above and to the left relative to the current video unit, and the reference template is located above and to the right relative to the reference video unit.
[0144] Clause 8. The method of clause 1, wherein the current template is located above and to the left relative to the current video unit, and the reference template is located below and to the left relative to the reference video unit.
[0145] Clause 9. The method of any one of clauses 1 to 8, wherein if the template-based processing in addition to the ARMC is applied to the prediction list, a second reference template different from the first reference template is used.
[0146] Clause 10. A method according to any one of clauses 1 to 8, wherein if the RRIBC is applied to the video unit encoded using the template-based processing, a second reference template different from the first reference template is used.
[0147] Clause 11. A method according to clause 9 or 10, wherein a validation check is applied to a reference template of the motion candidate of the at least one RRIBC codec.
[0148] Clause 12. The method of clause 11, wherein the validation check is applied to check whether the right portion of the reference template is within a valid area.
[0149] Clause 13. The method of clause 11, wherein the validation check is applied to check whether a bottom portion of the reference template is within a valid area.
[0150] Clause 14. The method according to clause 12 or 13, wherein the validity area is predefined by a set of rules related to codec information.
[0151] Clause 1 5. The method of clause 14, wherein the codec information comprises at least one of: a virtual pipeline data unit (VPDU) size, a maximum codec unit (LCU) size, a tile boundary, a picture boundary, a slice boundary, or a tile row.
[0152] Clause 16. The method of clause 11, wherein if a sample of the reference template is outside a valid region, another sample within the valid region is used instead to construct the reference template.
[0153] Clause 17. The method of clause 16, wherein the valid sample that is closest to the invalid sample is used.
[0154] Clause 18. The method of clause 16, wherein valid samples within a reference block are used.
[0155] Clause 19. The method of clause 11, wherein the reference template of the at least one RRIBC codec motion candidate is deemed unusable if at least one sample of the reference template is outside a valid region.
[0156] Clause 20. A method according to clause 19, wherein the template-based processing is not applied to the prediction list, or wherein the RRIBC is not applied to the video unit encoded and decoded using the template-based processing, or wherein the ARMC is not applied to the video unit that is a non-RRIBC encoded video unit.
[0157] Clause 21. A method according to Clause 11, wherein if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns within the reference block is used instead to construct the reference template, where M is equal to the width of the right portion of the reference template.
[0158] Clause 22. A method according to clause 11, wherein if at least one sample of the bottom portion of the reference template is outside the valid area, at least one sample of the top N rows within the reference block is used instead to construct the reference template, where N is equal to the height of the bottom portion of the reference template.
[0159] Clause 23. The method of clause 9 or 10, wherein the second reference template is used to determine a template cost for at least one RRIBC coded video unit.
[0160] Clause 24. The method of clause 23, wherein whether bottom samples or right samples adjacent to the reference block are used to construct the reference template of the reference block depends on a flip type of the at least one RRIBC-coded video unit.
[0161] Clause 25. A method according to clause 9 or 10, wherein the validation check is applied to a reference template of the at least one RRIBC coded video unit.
[0162] Clause 26. The method of clause 9 or 10, wherein the reference template of the video unit comprises neighboring samples adjacent to the reference video unit to at least one of a lower side, a right side, a lower side, an upper side, or a left side.
[0163] Clause 27. The method of clause 9 or 10, wherein the reference template for the video unit comprises samples within the reference video unit.
[0164] Clause 28. A method according to any of clauses 1 to 8, wherein if the ARMC is applied to the video unit for a non-RRIBC codec video unit, a second reference template different from the first reference template is used.
[0165] Clause 29. The method of clause 28, wherein a validation check is applied to a reference template of the non-RRIBC codec video unit.
[0166] Clause 30. The method of clause 29, wherein the validation check is applied to check whether the right portion of the reference template is within a valid area.
[0167] Clause 31. The method of clause 29, wherein the validation check is applied to check whether a bottom portion of the reference template is within a valid area.
[0168] Clause 32. The method according to clause 30 or 31, wherein the validity area is predefined by a set of rules related to codec information.
[0169] Clause 33. The method of clause 32, wherein the codec information comprises at least one of: a virtual pipeline data unit (VPDU) size, a maximum codec unit (LCU) size, a tile boundary, a picture boundary, a slice boundary, or a tile row.
[0170] Clause 34. The method of clause 29, wherein if a sample of the reference template is outside a valid region, another sample within the valid region is used instead to construct the reference template.
[0171] Clause 35. The method of clause 34, wherein the valid sample that is closest to the invalid sample is used.
[0172] Clause 36. The method of clause 34, wherein valid samples within a reference block are used.
[0173] Clause 37. The method of clause 29, wherein the reference template of the non-RRIBC coded video unit is deemed unusable if at least one sample of the reference template is outside a valid region.
[0174] Clause 38. The method of clause 37, wherein the ARMC is not applied to the non-RRIBC codec video units.
[0175] Clause 39. A method according to Clause 29, wherein if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns within the reference block is used instead to construct the reference template, where M is equal to the width of the right portion of the reference template.
[0176] Clause 40. A method according to Clause 29, wherein if at least one sample of the bottom portion of the reference template is outside the valid area, at least one sample of the top N rows within the reference block is used instead to construct the reference template, where N is equal to the height of the bottom portion of the reference template.
[0177] Clause 41. The method of clause 29, wherein if the reference template of the non-RRIBC codec video unit exceeds a valid area, at least one sample within the valid area is used instead to fill the reference template.
[0178] Clause 42. The method of any one of clauses 9, 10 or 28, wherein the first reference template is constructed from at least one of: a left sample or an upper sample adjacent to a reference block.
[0179] Clause 43. The method of clause 42, wherein the first reference template is used to determine a template cost for a motion candidate that does not utilize the RRIBC codec.
[0180] Clause 44. The method of any one of clauses 9, 10 or 28, wherein the second reference template is constructed from at least one of a bottom sample or a right sample adjacent to the reference block.
[0181] Clause 45. A method according to any of clauses 9, 10 or 28, wherein the second reference template is used to determine a template cost for a motion candidate of the at least one RRIBC codec.
[0182] Clause 46. A method according to any one of clauses 9, 10 or 28, wherein whether a bottom sample or a right sample adjacent to the reference block is used to construct a reference template for the reference block depends on the flip type of the motion candidate of the at least one RRIBC codec.
[0183] Clause 47. A method according to any one of clauses 9, 10 or 28, wherein whether the second reference template or the first reference template is used depends on the flip type of the motion candidate.
[0184] Clause 48. A method according to any one of clauses 9, 10 or 28, wherein the second template is constructed from upper and right samples adjacent to the reference block, and the first template is constructed from upper and left samples adjacent to the current block.
[0185] Clause 49. A method according to any one of clauses 9, 10 or 28, wherein the second template is constructed from bottom and left samples adjacent to the reference block, and the first template is constructed from top and left samples adjacent to the current block.
[0186] Clause 50. A method according to any one of clauses 1 to 8, wherein if the template-based processing in addition to the ARMC is applied to the prediction list, samples in the reference template of the reference block of the video unit are reordered.
[0187] Clause 51. A method according to any one of clauses 1 to 8, wherein if the RRIBC is applied to the video unit encoded and decoded using the template-based processing, samples in a reference template of a reference block of the video unit are reordered.
[0188] Clause 52. A method according to any one of clauses 1 to 8, wherein if the ARMC is applied to the video unit that is encoded for RRIBC, samples in a reference template of a reference block of the video unit are reordered.
[0189] Clause 53. A method according to any one of clauses 50 to 52, wherein samples in an upper portion of the reference template are reordered, and / or wherein samples in a right portion of the reference template are reordered.
[0190] Clause 54. A method according to any one of clauses 50 to 52, wherein samples in a left portion of the reference template are reordered, and / or wherein samples in a bottom portion of the reference template are reordered.
[0191] Clause 55. The method of any one of clauses 50 to 52, wherein whether to reorder samples in the reference template depends on a flip type of a motion candidate.
[0192] Clause 56. The method of any one of clauses 50 to 52, wherein a horizontal flipping process is applied to samples in an upper portion of the reference template constructed from upper samples adjacent to the reference block.
[0193] Clause 57. A method according to any one of clauses 50 to 52, wherein a horizontal flipping process is applied to samples in a right portion of the reference template constructed from right samples adjacent to the reference block.
[0194] Clause 58. The method according to Clause 57, wherein if the width of the right portion of the reference template is equal to a predefined number, the horizontal flipping process is not applied.
[0195] Clause 59. A method according to any one of clauses 50 to 52, wherein a vertical flipping process is applied to samples in a left portion of the reference template constructed from left samples adjacent to the reference block.
[0196] Clause 60. The method of any one of clauses 50 to 52, wherein a vertical flipping process is applied to samples in a bottom portion of the reference template constructed from bottom samples adjacent to the reference block.
[0197] Clause 61. The method of clause 60, wherein if the height of the bottom portion of the reference template is equal to a predefined number, the vertical flipping process is not applied.
[0198] Clause 62. A method according to any one of clauses 50 to 52, wherein if horizontal flipping processing is applied, the samples in the upper part of the reference template are derived as: temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride], and wherein temp represents the sample buffer of the upper part of the reference template, (temp W, tempH) represents the width and height of the upper part of the reference template, (x, y) represents the position of the upper left sample of the upper part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0199] Clause 63. A method according to any one of clauses 50 to 52, wherein if a horizontal flipping process is applied, the samples in the right part of the reference template are derived as: temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride], and wherein temp represents the sample buffer of the right part of the reference template, (temp W, tempH) represents the width and height of the right part of the reference template, (x, y) represents the position of the upper left sample of the right part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0200] Clause 64. A method according to any one of clauses 50 to 52, wherein if vertical flip processing is applied, the samples in the bottom part of the reference template are derived as: temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride]], and wherein temp represents the sample buffer of the bottom part of the reference template, (temp W, tempH) represents the width and height of the bottom part of the reference template, (x, y) represents the position of the upper left sample of the bottom part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0201] Clause 65. A method according to any one of clauses 50 to 52, wherein if vertical flip processing is applied, the samples in the left part of the reference template are derived as: temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride], and wherein temp represents the sample buffer of the left part of the reference template, (temp W, tempH) represents the width and height of the left part of the reference template, (x, y) represents the position of the upper left sample of the left part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0202] Clause 66. The method of any one of clauses 1 to 8, wherein if the ARMC is applied to the prediction list, samples in a current template for a current block of the video unit are ordered.
[0203] Clause 67. A method according to any one of clauses 1 to 8, wherein if the ARMC is applied to the video unit that is a RRIBC coded video unit, samples in a current template for a current block of the video unit are ordered.
[0204] Clause 68. A method according to clause 66 or 67, wherein samples in an upper portion of the current template are reordered, and / or wherein samples in a left portion of the current template are reordered.
[0205] Clause 69. The method of clause 66 or 67, wherein whether to reorder samples in the current template depends on a flip type of a motion candidate.
[0206] Clause 70. The method of clause 66 or 67, wherein a horizontal flipping process is applied to samples in an upper portion of the current template constructed from upper samples adjacent to the current block.
[0207] Clause 71. A method according to clause 66 or 67, wherein a horizontal flipping process is applied to samples in a left portion of the reference template constructed from left samples adjacent to the current block.
[0208] Clause 72. The method according to clause 71, wherein if the width of the left portion of the current template is equal to a predefined number, the horizontal flipping process is not applied.
[0209] Clause 73. The method of clause 66 or 67, wherein a vertical flipping process is applied to samples in an upper portion of the reference template constructed from upper samples adjacent to the current block.
[0210] Clause 74. The method according to clause 73, wherein if the height of the upper portion of the current template is equal to a predefined number, the vertical flipping process is not applied.
[0211] Clause 75. The method of clause 66 or 67, wherein a vertical flipping process is applied to samples in a left portion of the current template constructed from left samples adjacent to the current block.
[0212] Clause 76. A method according to clause 66 or 67, wherein if horizontal flipping processing is applied, the samples in the upper part of the current template are derived as: temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride], and wherein temp represents the sample buffer of the upper part of the current template, (temp W, tempH) represents the width and height of the upper part of the current template, (x, y) represents the position of the upper left sample of the upper part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0213] Clause 77. A method according to clause 66 or 67, wherein if horizontal flipping processing is applied, the samples in the right part of the current template are derived as: temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride], and wherein temp represents the sample buffer of the right part of the current template, (temp W, tempH) represents the width and height of the right part of the current template, (x, y) represents the position of the upper left sample of the right part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0214] Clause 78. A method according to clause 66 or 67, wherein if vertical flip processing is applied, the samples in the bottom part of the current template are derived as: temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride]], and wherein temp represents the sample buffer of the bottom part of the current template, (temp W, tempH) represents the width and height of the bottom part of the current template, (x, y) represents the position of the upper left sample of the bottom part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0215] Clause 79. A method according to clause 66 or 67, wherein if vertical flip processing is applied, the samples in the left part of the current template are derived as: temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride], and wherein temp represents the sample buffer of the left part of the current template, (temp W, tempH) represents the width and height of the left part of the current template, (x, y) represents the position of the upper left sample of the left part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
[0216] Clause 80. A method according to clause 66 or 67, wherein at most one template is reordered.
[0217] Clause 81. The method of clause 80, wherein samples in a current template for a current block of the video unit are reordered, and samples in a reference template for a reference block of the video unit are not reordered.
[0218] Clause 82. The method of clause 80, wherein samples in a reference template of a reference block of the video unit are reordered and samples in a current template of a current block of the video unit are not reordered.
[0219] Clause 83. The method of Clause 50, wherein at least a portion of the samples in the reference template of the video unit encoded using the template-based process are ordered.
[0220] Clause 84. The method of Clause 50, wherein at least a portion of the samples in the current template of the video unit encoded using the template-based process are ordered.
[0221] Clause 85. The method of Clause 50, wherein at least a portion of the samples in the reference template or at least a portion of the samples in the current template for the video unit encoded using the template-based process are ordered.
[0222] Clause 86. A method according to any one of clauses 9 to 85, wherein the sample comprises at least one of: a reconstructed sample or a predicted sample.
[0223] Clause 87. A method according to any one of clauses 1 to 86, wherein an indication of whether to determine whether the template-based processing is applied to the video unit and / or how to determine whether the template-based processing is applied to the video unit is indicated at one of: a sequence level, a picture group level, a picture level, a slice level, or a tile group level.
[0224] Clause 88. A method according to any one of clauses 1 to 86, wherein an indication of whether to determine whether the template-based processing is applied to the video unit and / or how to determine whether the template-based processing is applied to the video unit is indicated in one of the following: a sequence header, a picture header, a sequence parameter set (SPS), a video parameter set (VPS), a dependency 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.
[0225] Clause 89. A method according to any one of clauses 1 to 86, wherein an indication of whether to determine whether the template-based processing is applied to the video unit and / or how to determine whether the template-based processing is applied to the video unit is included in one of the following: a prediction block (PB), a transform block (TB), a codec block (CB), a prediction unit (PU), a transform unit (TU), a codec unit (CU), a virtual pipeline data unit (VPDU), a codec tree unit (CTU), a CTU row, a slice, a tile, a sub-picture, or a region containing more than one sample or pixel.
[0226] Clause 90. The method according to any one of clauses 1 to 86 further includes: determining whether to apply the template-based processing to the video unit and / or how to determine whether the template-based processing is applied to the video unit based on the codec information of the video unit, the codec information including at least one of the following: block size, color format, single tree partitioning and / or double tree partitioning, color component, slice type, or picture type.
[0227] Clause 91. A method according to any one of clauses 1 to 90, wherein the converting comprises encoding the video unit into the bitstream.
[0228] Clause 92. The method of any one of clauses 1 to 90, wherein the converting comprises decoding the video unit from the bitstream.
[0229] Clause 93. An apparatus for video processing, 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 of any one of clauses 1 to 92.
[0230] Clause 94. A non-transitory computer-readable storage medium storing instructions for causing a processor to perform the method of any one of clauses 1 to 92.
[0231] Clause 95. A non-transitory computer-readable recording medium storing a bitstream of a video generated by a method performed by an apparatus for video processing, wherein the method comprises: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; and generating a bitstream based on the determination.
[0232] Clause 96. A method for storing a bitstream of a video, comprising: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; generating a bitstream based on the determination; and storing the bitstream in a non-transitory computer-readable recording medium. Example Device
[0233] Fig.17 A block diagram of a computing device 1 700 in which various embodiments of the present disclosure may be implemented is shown. The computing device 1700 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).
[0234] It should be understood that Fig.17 The computing device 1700 shown is for illustration purposes only and is not intended to in any way imply any limitation on the functionality and scope of the embodiments of the present disclosure.
[0235] like Figure 17 , the computing device 1700 includes a general computing device 1700. The computing device 1700 may include at least one or more processors or processing units 1710, a memory 1720, a storage unit 1730, one or more communication units 1740, one or more input devices 1750, and one or more output devices 1760.
[0236] In some embodiments, computing device 1700 can be implemented as any user terminal or server terminal with computing capability. The server terminal can be a server provided by a service provider, a large computing device, etc. The user terminal can be, for example, any type of mobile terminal, fixed terminal or portable terminal, including a mobile phone, a station, a unit, a device, a multimedia computer, a multimedia tablet computer, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system (PCS) device, a personal navigation device, a personal digital assistant (PDA), an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an e-book device, a gaming device, or any combination thereof, including accessories and peripherals of these devices, or any combination thereof. It can be expected that computing device 1700 can support any type of interface with a user (such as a "wearable" circuit, etc.).
[0237] Processing unit 1710 may be a physical or virtual processor and may implement various processes based on a program stored in memory 1720. In a multi-processor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capabilities of computing device 1700. Processing unit 1710 may also be referred to as a central processing unit (CPU), a microprocessor, a controller, or a microcontroller.
[0238] The computing device 1700 typically includes various computer storage media. Such media can be any media accessible to the computing device 1700, including but not limited to volatile and non-volatile media, or removable and non-removable media. The memory 1720 can be a volatile memory (e.g., a register, a cache, a random access memory (RAM)), a non-volatile memory (e.g., a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), or flash memory), or any combination thereof. The storage unit 1730 can be any removable or non-removable medium, and can include a machine-readable medium, such as a memory, a flash drive, a disk, or other media, which can be used to store information and / or data and can be accessed in the computing device 1700.
[0239] The computing device 1700 may also include additional removable / non-removable, volatile / non-volatile storage media. Fig.17Not shown in the figure, but a magnetic disk drive for reading and / or writing a removable and nonvolatile magnetic disk and an optical disk drive for reading and / or writing a removable nonvolatile optical disk may be provided. In this case, each drive may be connected to a bus (not shown) via one or more data medium interfaces.
[0240] The communication unit 1740 communicates with another computing device via a communication medium. In addition, the functions of the components in the computing device 1700 can be implemented by a single computing cluster or multiple computing machines that can communicate via a communication connection. Therefore, the computing device 1700 can operate in a networked environment using logical connections to one or more other servers, networked personal computers (PCs), or other general-purpose network nodes.
[0241] Input device 1750 may be one or more of various input devices, such as a mouse, keyboard, trackball, voice input device, etc. Output device 1760 may be one or more of various output devices, such as a display, speaker, printer, etc. Computing device 1700 may also communicate with one or more external devices (not shown) such as storage devices and display devices through communication unit 1740, one or more of which enable a user to interact with computing device 1700, or any device (e.g., a network card, a modem, etc.) that enables computing device 1700 to communicate with one or more other computing devices if necessary. Such communication may be performed via an input / output (I / O) interface (not shown).
[0242] In some embodiments, some or all components of computing device 1700 may also be arranged in a cloud computing architecture, rather than being integrated in a single device. In a cloud computing architecture, 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 end users to understand the physical location or configuration of the system or hardware that provides these services. In various embodiments, cloud computing uses a suitable protocol 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, which can be accessed through 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 merged or distributed at the location of a remote data center. Cloud computing infrastructure may provide services through a shared data center, although they act as a single access point for users. Therefore, cloud computing architecture may be used to provide 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.
[0243] The computing device 1700 may be used to implement video encoding / decoding in embodiments of the present invention. The memory 1720 may include one or more video encoding / decoding modules 1725 having one or more program instructions. These modules may be accessed and executed by the processing unit 1710 to perform the functions of various embodiments described herein.
[0244] In an example embodiment performing video encoding and decoding, input device 1750 may receive video data as input to be encoded 1770. For example, the video data may be processed by video encoding and decoding module 1725 to generate an encoded bitstream. The encoded bitstream may be provided as output 1780 via output device 1760.
[0245] In an example embodiment performing video decoding, input device 1750 may receive an encoded bitstream as input 1770. The encoded bitstream may be processed, for example, by video codec module 1725 to generate decoded video data. The decoded video data may be provided as output 1780 via output device 1760.
[0246] Although the present disclosure has been specifically shown and described with reference to its preferred embodiments, it will be appreciated by those skilled in the art 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 video processing method, comprising: For conversion between a video unit of a video and a bitstream of the video unit, determining whether template-based processing is applied to the video unit, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; as well as The converting is performed based on the determination.
2. The method of claim 1 , wherein the template cost is determined by comparing at least one of the following between the current template and the reference template: Difference, Error, or distortion. The method of claim 1 , wherein template matching or template refinement is performed based on template cost.
4. The method of claim 1, wherein the template-based processing comprises one of: Intra Block Copy (IBC) Template Matching (TM) Merge Mode, TM-based IBC Advanced Motion Vector Prediction (AMVP) candidate refinement, or Adaptive reordering-based motion compensation (ARMC) IBC mode.
5. The method of claim 1 , wherein based on a determination that the video unit was coded using the template-based processing, a reconstruction reordered IBC (RRIBC) is applied to the video unit, or Wherein based on a determination that the video unit was encoded and decoded using the template based processing, the RRIBC is not applied to the video unit.
6. The method of claim 1, wherein a position of at least a portion of the current template relative to a current video unit and a position of at least a portion of the reference template relative to a reference video unit are different.
7. The method of claim 1, wherein the current template is located above and to the left of the current video unit, and the reference template is located above and to the right of the reference video unit.
8. The method of claim 1, wherein the current template is located above and to the left of the current video unit, and the reference template is located below and to the left of the reference video unit.
9. The method according to any one of claims 1 to 8, wherein if the template-based processing in addition to the ARMC is applied to the prediction list, a second reference template different from the first reference template is used.
10. The method according to any one of claims 1 to 8, wherein if the RRIBC is applied to the video unit encoded using the template-based process, a second reference template different from the first reference template is used.
11. The method according to claim 9 or 10, wherein a validation check is applied to a reference template of the motion candidate of the at least one RRIBC codec.
12. The method of claim 11, wherein the validation check is applied to check whether a right portion of the reference template is within a valid area.
13. The method of claim 11, wherein the validation check is applied to check whether a bottom portion of the reference template is within a valid area.
14. The method according to claim 12 or 13, wherein the valid area is predefined by a set of rules related to codec information.
15. The method according to claim 14, wherein the codec information comprises at least one of the following: Virtual Pipeline Data Unit (VPDU) size, Maximum codec unit (LCU) size, Tile boundaries, Picture borders, Strip borders, or Tile rows. 16 . The method of claim 11 , wherein if a sample of the reference template is outside a valid area, another sample within the valid area is used instead to construct the reference template. The method of claim 16 , wherein the valid sample closest to the invalid sample is used. The method according to claim 16 , wherein valid samples within a reference block are used.
19. The method of claim 11, wherein the reference template of the at least one RRIBC codec motion candidate is considered unavailable if at least one sample of the reference template is outside a valid area.
20. The method of claim 19, wherein the template-based processing is not applied to the prediction list, or wherein the RRIBC is not applied to the video units encoded or decoded using the template based processing, or Wherein the ARMC is not applied to the video unit for a non-RRIBC codec video unit.
21. The method of claim 11, wherein if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns within a reference block is used instead to construct the reference template, where M is equal to the width of the right portion of the reference template.
22. The method of claim 11, wherein if at least one sample of a bottom portion of the reference template is outside a valid area, at least one sample of a top N rows within a reference block is used instead to construct the reference template, where N is equal to the height of the bottom portion of the reference template.
23. The method of claim 9 or 10, wherein the second reference template is used to determine a template cost for at least one RRIBC coded video unit.
24. The method of claim 23, wherein whether to use bottom samples or right samples adjacent to the reference block to construct the reference template of the reference block depends on a flip type of the at least one RRIBC-coded video unit.
25. The method of claim 9 or 10, wherein a validation check is applied to a reference template of the at least one RRIBC-coded video unit.
26. The method of claim 9 or 10, wherein the reference template of the video unit comprises neighboring samples adjacent to at least one of the lower sides of the reference video unit, Right side, Lower side, upper side, or Left side.
27. The method of claim 9 or 10, wherein the reference template for the video unit comprises samples within the reference video unit.
28. The method according to any one of claims 1 to 8, wherein if the ARMC is applied to the video unit for a non-RRIBC codec video unit, a second reference template different from the first reference template is used.
29. The method of claim 28, wherein a validation check is applied to a reference template of the non-RRIBC codec video unit.
30. The method of claim 29, wherein the validation check is applied to check whether a right portion of the reference template is within a valid area.
31. The method of claim 29, wherein the validation check is applied to check whether a bottom portion of the reference template is within a valid area.
32. The method according to claim 30 or 31, wherein the valid area is predefined by a set of rules related to codec information.
33. The method according to claim 32, wherein the codec information comprises at least one of the following: Virtual Pipeline Data Unit (VPDU) size, Maximum codec unit (LCU) size, Tile boundaries, Picture borders, Strip borders, or Tile rows.
34. The method of claim 29, wherein if a sample of the reference template is outside a valid area, another sample within the valid area is used instead to construct the reference template.
35. The method of claim 34, wherein the valid sample closest to the invalid sample is used.
36. The method of claim 34, wherein valid samples within a reference block are used.
37. The method of claim 29, wherein the reference template of the non-RRIBC-coded video unit is deemed unavailable if at least one sample of the reference template is outside a valid region.
38. The method of claim 37, wherein the ARMC is not applied to the non-RRIBC codec video units.
39. The method of claim 29, wherein if at least one sample of the right portion of the reference template is outside the valid area, at least one sample of the rightmost M columns within a reference block is used instead to construct the reference template, where M is equal to the width of the right portion of the reference template.
40. The method of claim 29, wherein if at least one sample of a bottom portion of the reference template is outside a valid area, at least one sample of a top N rows within a reference block is used instead to construct the reference template, where N is equal to the height of the bottom portion of the reference template.
41. The method of claim 29, wherein if the reference template of the non-RRIBC codec video unit exceeds a valid area, at least one sample within the valid area is used instead to fill the reference template.
42. The method of any one of claims 9, 10 or 28, wherein the first reference template is constructed from at least one of: a left sample or an upper sample adjacent to a reference block.
43. The method of claim 42, wherein the first reference template is used to determine a template cost for a motion candidate that does not utilize the RRIBC codec.
44. The method of any one of claims 9, 10 or 28, wherein the second reference template is constructed from at least one of a bottom sample or a right sample adjacent to a reference block.
45. The method of any one of claims 9, 10 or 28, wherein the second reference template is used to determine a template cost for a motion candidate of the at least one RRIBC codec.
46. The method of any one of claims 9, 10 or 28, wherein whether to use bottom samples or right samples adjacent to the reference block to construct a reference template for the reference block depends on a flip type of the motion candidate of the at least one RRIBC codec.
47. The method of any one of claims 9, 10 or 28, wherein whether to use the second reference template or the first reference template depends on a flip type of the motion candidate.
48. The method according to any one of claims 9, 10 or 28, wherein the second template is constructed from upper samples and right samples adjacent to the reference block, and the first template is constructed from upper samples and left samples adjacent to the current block.
49. The method of any one of claims 9, 10 or 28, wherein the second template is constructed from bottom and left samples adjacent to the reference block, and the first template is constructed from top and left samples adjacent to the current block.
50. The method of any one of claims 1 to 8, wherein if the template-based processing in addition to the ARMC is applied to the prediction list, samples in a reference template of a reference block of the video unit are reordered.
51. The method according to any one of claims 1 to 8, wherein if the RRIBC is applied to the video unit encoded and decoded using the template-based processing, samples in a reference template of a reference block of the video unit are reordered.
52. The method according to any one of claims 1 to 8, wherein if the ARMC is applied to the video unit that is a RRIBC coded video unit, samples in a reference template of a reference block of the video unit are reordered.
53. A method according to any one of claims 50 to 52, wherein the samples in the upper part of the reference template are reordered, and / or The samples in the right part of the reference template are reordered.
54. A method according to any one of claims 50 to 52, wherein the samples in the left part of the reference template are reordered, and / or The samples in the bottom portion of the reference template are reordered.
55. The method of any one of claims 50 to 52, wherein whether to reorder samples in the reference template depends on a flip type of a motion candidate.
56. The method according to any one of claims 50 to 52, wherein a horizontal flipping process is applied to samples in an upper portion of the reference template constructed from upper samples adjacent to the reference block.
57. The method according to any one of claims 50 to 52, wherein a horizontal flipping process is applied to samples in a right portion of the reference template constructed from right samples adjacent to the reference block.
58. The method of claim 57, wherein if a width of the right portion of the reference template is equal to a predefined number, the horizontal flipping process is not applied.
59. The method according to any one of claims 50 to 52, wherein a vertical flipping process is applied to samples in a left portion of the reference template constructed from left samples adjacent to the reference block.
60. The method according to any one of claims 50 to 52, wherein a vertical flipping process is applied to samples in a bottom portion of the reference template constructed from bottom samples adjacent to the reference block.
61. The method of claim 60, wherein if the height of the bottom portion of the reference template is equal to a predefined number, the vertical flipping process is not applied.
62. The method according to any one of claims 50 to 52, wherein if a horizontal flip process is applied, the samples in the upper part of the reference template are derived as: temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride], and Wherein temp represents the sample buffer of the upper part of the reference template, (temp W, tempH) represents the width and height of the upper part of the reference template, (x, y) represents the position of the upper left sample of the upper part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
63. The method according to any one of claims 50 to 52, wherein if a horizontal flip process is applied, the samples in the right part of the reference template are derived as: temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride], and Wherein temp represents the sample buffer of the right part of the reference template, (temp W, tempH) represents the width and height of the right part of the reference template, (x, y) represents the position of the upper left sample of the right part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
64. The method of any one of claims 50 to 52, wherein if a vertical flip process is applied, the samples in the bottom portion of the reference template are derived as: temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride]], and Wherein temp represents the sample buffer of the bottom part of the reference template, (temp W, tempH) represents the width and height of the bottom part of the reference template, (x, y) represents the position of the upper left sample of the bottom part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
65. The method according to any one of claims 50 to 52, wherein if a vertical flip process is applied, the samples in the left part of the reference template are derived as: temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride], and Wherein temp represents the sample buffer of the left part of the reference template, (temp W, tempH) represents the width and height of the left part of the reference template, (x, y) represents the position of the upper left sample of the left part of the reference template relative to the part of the reference template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
66. The method of any one of claims 1 to 8, wherein if the ARMC is applied to the prediction list, samples in a current template for a current block of the video unit are ordered.
67. The method of any one of claims 1 to 8, wherein if the ARMC is applied to the video unit that is a RRIBC coded video unit, samples in a current template for a current block of the video unit are ordered.
68. A method according to claim 66 or 67, wherein the samples in the upper part of the current template are reordered, and / or The samples in the left part of the current template are reordered.
69. The method of claim 66 or 67, wherein whether to reorder samples in the current template depends on a flip type of a motion candidate.
70. The method of claim 66 or 67, wherein a horizontal flipping process is applied to samples in an upper portion of the current template constructed from upper samples adjacent to the current block.
71. The method of claim 66 or 67, wherein a horizontal flipping process is applied to samples in a left portion of the reference template constructed from left samples adjacent to the current block.
72. The method of claim 71, wherein if a width of the left portion of the current template is equal to a predefined number, the horizontal flipping process is not applied.
73. The method of claim 66 or 67, wherein a vertical flipping process is applied to samples in an upper portion of the reference template constructed from upper samples adjacent to the current block.
74. The method of claim 73, wherein if a height of the upper portion of the current template is equal to a predefined number, the vertical flipping process is not applied.
75. The method of claim 66 or 67, wherein a vertical flipping process is applied to samples in a left portion of the current template constructed from left samples adjacent to the current block.
76. The method of claim 66 or 67, wherein if a horizontal flip process is applied, samples in the upper portion of the current template are derived as: temp[x+y*tempW]=cur[curW-1-x+(y-tempH)*curStride], and Wherein temp represents the sample buffer of the upper part of the current template, (temp W, tempH) represents the width and height of the upper part of the current template, (x, y) represents the position of the upper left sample of the upper part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
77. The method according to claim 66 or 67, wherein if a horizontal flip process is applied, the samples in the right part of the current template are derived as: temp[x+y*tempW]=cur[curW+tempW-1-x+y*curStride], and Wherein temp represents the sample buffer of the right part of the current template, (temp W, tempH) represents the width and height of the right part of the current template, (x, y) represents the position of the upper left sample of the right part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
78. The method of claim 66 or 67, wherein if vertical flipping is applied, samples in the bottom portion of the current template are derived as: temp[x+y*tempW]=cur[x+(curH+tempH-1-y)*curStride]], and Wherein temp represents the sample buffer of the bottom part of the current template, (temp W, tempH) represents the width and height of the bottom part of the current template, (x, y) represents the position of the upper left sample of the bottom part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
79. The method of claim 66 or 67, wherein if a vertical flip process is applied, samples in the left portion of the current template are derived as: temp[x+y*tempW]=cur[x-tempW+(curH-1-y]*curStride], and Wherein temp represents the sample buffer of the left part of the current template, (temp W, tempH) represents the width and height of the left part of the current template, (x, y) represents the position of the upper left sample of the left part of the current template relative to the part of the current template, cur represents the sample buffer of the video unit, (curW, curH) represents the width and height of the video unit, and curStride represents the stride of the sample buffer of the video unit.
80. The method of claim 66 or 67, wherein at most one template is reordered.
81. The method of claim 80, wherein samples in a current template for a current block of the video unit are reordered and samples in a reference template for a reference block of the video unit are not reordered.
82. The method of claim 80, wherein samples in a reference template of a reference block of the video unit are reordered and samples in a current template of a current block of the video unit are not reordered.
83. The method of claim 50, wherein at least a portion of samples in the reference template of the video unit encoded using the template-based process are ordered.
84. The method of claim 50, wherein at least a portion of samples in the current template of the video unit encoded using the template-based process are ordered.
85. The method of claim 50, wherein at least a portion of samples in the reference template or at least a portion of samples in the current template for the video unit encoded using the template-based process are ordered.
86. The method of any one of claims 9 to 85, wherein the samples comprise at least one of: reconstructed samples or predicted samples.
87. The method of any one of claims 1 to 86, wherein an indication of whether to determine whether the template-based processing is applied to the video unit and / or how to determine whether the template-based processing is applied to the video unit is indicated at one of: Sequence level, Picture group level, Picture level, Stripe level, or Tile group level.
88. The method of any one of claims 1 to 86, wherein an indication of whether to determine whether the template-based processing is applied to the video unit and / or how to determine whether the template-based processing is applied to the video unit is indicated in one of the following: Sequence header, Picture header, Sequence Parameter Set (SPS), Video Parameter Set (VPS), Dependency Parameter Set (DPS), Decoding Capability Information (DCI), Picture Parameter Set (PPS), Adaptive Parameter Set (APS), Strip header, or Tile group header.
89. The method of any one of claims 1 to 86, wherein an indication of whether to determine whether the template-based processing is applied to the video unit and / or how to determine whether the template-based processing is applied to the video unit is included in one of: Prediction Block (PB), Transform Block (TB), Codec Block (CB), Prediction Unit (PU), Transformation Unit (TU), Codec Unit (CU), Virtual Pipeline Data Unit (VPDU), Codec Tree Unit (CTU), CTU line, Strips, Tile, sub-image, or An area that contains more than one sample or pixel.
90. The method of any one of claims 1 to 86, further comprising: Determine whether to apply the template-based processing to the video unit and / or how to determine whether the template-based processing is applied to the video unit based on codec information of the video unit, wherein the codec information includes at least one of the following: Block size, Color format, Single-tree partitioning and / or dual-tree partitioning, Color components, Strip type, or Image type.
91. The method of any one of claims 1 to 90, wherein the converting comprises encoding the video unit into the bitstream.
92. The method of any one of claims 1 to 90, wherein the converting comprises decoding the video unit from the bitstream.
93. An apparatus for video processing, comprising a processor and a non-volatile memory having instructions thereon, wherein the instructions, when executed by the processor, cause the processor to perform a method according to any one of claims 1 to 92.
94. A non-transitory computer-readable storage medium storing instructions for causing a processor to execute the method according to any one of claims 1 to 92.
95. A non-transitory computer-readable recording medium storing a bit stream of a video generated by a method performed by an apparatus for video processing, wherein the method comprises: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; as well as A bitstream is generated based on the determination.
96. A method for storing a bitstream of a video, comprising: determining whether template-based processing is applied to a video unit of the video, wherein the template-based processing is based on at least one template of at least one of: a current picture or a reference picture of the video unit; generating a bitstream based on the determination; as well as The bit stream is stored in a non-transitory computer-readable recording medium.