Encoding method and decoding method of a video signal and apparatuses therefor

By acquiring the intra-frame prediction mode of adjacent blocks and dividing the video signal blocks into sub-blocks for efficient encoding or decoding, the problem of increased data volume in high-definition video services is solved, and the compression rate and quality of video signals are improved.

CN116320406BActive Publication Date: 2026-05-15GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 6 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
Filing Date
2019-10-11
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing video coding technologies face the problem of a significant increase in data volume in high-definition video services. HEVC's compression performance is gradually showing its limitations, and there is a need to improve the efficiency of video signal encoding and decoding.

Method used

By determining the reference sample line of the current block, the intra-prediction mode with the adjacent blocks is obtained. The candidate intra-prediction mode is used to encode or decode the video signal. The encoded block or transform block is divided into multiple sub-blocks. Intra-prediction or transform is performed only on some sub-blocks, and an appropriate transform type is selected.

Benefits of technology

It improves intra-frame prediction and encoding or decoding efficiency, thereby enhancing the compression rate and quality of video signals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116320406B_ABST
    Figure CN116320406B_ABST
Patent Text Reader

Abstract

The video decoding method of the present application comprises: determining a reference sample line of a current block; determining whether there is a candidate intra prediction mode same as an intra prediction mode of the current block; obtaining the intra prediction mode of the current block based on the determination result; and performing intra prediction on the current block according to the reference sample line and the intra prediction mode. At least one of the candidate intra prediction modes can be: adding or subtracting an offset to the maximum value of the intra prediction mode of the upper neighboring block of the current block and the intra prediction mode of the left neighboring block of the current block.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Case Analysis

[0002] This application is a divisional application of Chinese patent application No. 201980056255.0, entitled "Encoding and Decoding Method and Apparatus for Video Signals", which entered the Chinese national phase of PCT international patent application PCT / KR2019 / 013384 filed on October 11, 2019.

[0003] Cross-reference to related applications

[0004] This application is based on and claims priority to Korean Patent Application No. 10-2018-0121713, filed on October 12, 2018, the entire contents of which are incorporated herein by reference.

[0005] This application is based on and claims priority to Korean Patent Application No. 10-2018-0121757, filed on October 12, 2018, the entire contents of which are incorporated herein by reference.

[0006] This application is based on and claims priority to Korean Patent Application No. 10-2019-0006611, filed on January 18, 2019, the entire contents of which are incorporated herein by reference. Technical Field

[0007] This application relates to methods for encoding and decoding video signals, and apparatus thereof. Background Technology

[0008] With the increasing size of display panels, there is a growing demand for higher-quality video services. The biggest challenge in high-quality video services is the significant increase in data volume. To address this, research aimed at improving video compression rates is actively underway. As a representative example, in 2009, MPEG (Motion Picture Experts Group) and ITU-T (International Telecommunication Union-Telecommunication)'s VCEG (Video Coding Experts Group) established JCT-VC (Joint Collaborative Team on Video Coding). JCT-VC proposed HEVC (High Efficiency Video Coding), a video compression standard with approximately twice the compression performance of H.264 / AVC, which was approved on January 25, 2013. However, with the rapid development of high-quality video services, HEVC's performance limitations are gradually becoming apparent. Summary of the Invention

[0009] The purpose of this application is to provide a method for obtaining candidate intra-prediction modes based on the intra-prediction modes of neighboring blocks adjacent to the current block, and an apparatus for performing the method, in the field of video signal encoding or decoding.

[0010] The purpose of this application is to provide a method for dividing a coded block or transform block into multiple sub-blocks and performing intra-frame prediction on each sub-block in the field of video signal encoding or decoding, as well as an apparatus for performing said method.

[0011] The purpose of this application is to provide a method for dividing an encoding block or transform block into multiple sub-blocks and performing transforms only on a portion of the sub-blocks in the field of video signal encoding or decoding, as well as an apparatus for performing the method.

[0012] The technical subject matter to be achieved by this application is not limited to the technical subject matter mentioned above. Other technical subject matter not mentioned is something that a person skilled in the art to which this application pertains can clearly understand from the following description.

[0013] The video signal decoding or encoding method of this application includes: determining a reference sample line for the current block; determining whether there exists a candidate intra-prediction mode that is the same as the intra-prediction mode of the current block; obtaining the intra-prediction mode of the current block based on the determined result; and performing intra-prediction on the current block according to the reference sample line and the intra-prediction mode. In this case, at least one of the candidate intra-prediction modes can be: the maximum value of the intra-prediction modes of the upper adjacent block and the intra-prediction modes of the left adjacent block of the current block plus or minus an offset.

[0014] In the video signal decoding or encoding method of this application, when the difference between the intra-prediction mode of the upper adjacent block and the intra-prediction mode of the left adjacent block is 64, at least one of the candidate intra-prediction modes can be: adding or subtracting 2 from the maximum value.

[0015] In the video signal decoding or encoding method of this application, the number of candidate intra-frame prediction modes may be different depending on the index of the reference sample line.

[0016] The video signal decoding or encoding method of this application may further include: determining whether to divide the current block into multiple sub-blocks; when the current block is divided into multiple sub-blocks, the multiple sub-blocks may share an intra-frame prediction mode.

[0017] In the video signal decoding or encoding method of this application, the inverse transform can be skipped for some of the multiple sub-blocks.

[0018] In the video signal decoding or encoding method of this application, the horizontal transformation type of the sub-block can be determined according to the width of the sub-block, and the vertical transformation type of the sub-block can be determined according to the height of the sub-block.

[0019] In the video signal decoding or encoding method of this application, the horizontal transformation type and vertical transformation type of the sub-block can be determined according to the shape of the sub-block.

[0020] The features described above in this application are merely examples of specific embodiments described below and are not intended to limit the scope of this application.

[0021] The invention of this application has the following technical effects.

[0022] According to this application, intra-prediction efficiency can be improved by obtaining candidate intra-prediction modes that are similar to the intra-prediction modes of adjacent blocks of the current block.

[0023] According to this application, intra-frame prediction efficiency can be improved by dividing the coded block or transform block into multiple sub-blocks and performing intra-frame prediction for each sub-block.

[0024] According to this application, encoding or decoding efficiency can be improved by dividing the coded block or transform block into multiple sub-blocks and performing transforms only on a portion of the sub-blocks.

[0025] The effects that can be obtained by this application are not limited to those mentioned above. Other effects not mentioned are clearly understood by those skilled in the art from the following description. Attached Figure Description

[0026] Figure 1 This is a block diagram of a video encoder according to an embodiment of this application.

[0027] Figure 2 This is a block diagram of a video decoder according to an embodiment of this application.

[0028] Figure 3 This is a diagram illustrating a basic coding tree unit of an embodiment of this application.

[0029] Figure 4 This is a schematic diagram of various partition shapes for the coded block.

[0030] Figure 5 This is a schematic diagram of the partition shape of the coding tree unit.

[0031] Figure 6 This is a flowchart of an inter-frame prediction method according to an embodiment of this application.

[0032] Figure 7 This is a schematic diagram of blocks in the same position.

[0033] Figure 8 This is a flowchart of an intra-frame prediction method according to an embodiment of this application.

[0034] Figure 9 This is a schematic diagram of the reference samples included in each reference sample line.

[0035] Figure 10 This is a schematic diagram of the intra-frame prediction mode.

[0036] Figure 11 and Figure 12 This is a schematic diagram illustrating an example of a one-dimensional arrangement of reference samples in a column.

[0037] Figure 13 This is a schematic diagram of the angle formed by the intra-frame prediction mode and a straight line parallel to the X-axis.

[0038] Figure 14 This is a schematic diagram illustrating the shape obtained by predicting a sample when the current block is not a square shape.

[0039] Figure 15 This is a diagram showing the wide-angle intra-frame prediction mode.

[0040] Figure 16 This is a schematic diagram illustrating an example of vertical and horizontal division.

[0041] Figure 17 This is a schematic diagram illustrating an example of determining the shape of a coded block.

[0042] Figure 18 This is a schematic diagram illustrating an example of determining the shape of a coded block.

[0043] Figure 19 This is a schematic diagram illustrating an example of determining the partition shape of a coding block based on its intra-prediction mode.

[0044] Figure 20 This is a schematic diagram used to illustrate the shape of the coded block division.

[0045] Figure 21 This is a schematic diagram illustrating an example of predictive coding patterns set according to different sub-blocks.

[0046] Figure 22 This is a schematic diagram illustrating an example of PDPC application.

[0047] Figure 23 and Figure 24 This is a schematic diagram of the sub-block that will undergo a second transformation.

[0048] Figure 25 This is a schematic diagram illustrating an example of determining the transformation type of the current block.

[0049] Figure 26 This is a schematic diagram illustrating an example of confirming the transformation type of a sub-block.

[0050] Figure 27 This is a schematic diagram illustrating an example where the residual coefficient of a sub-block is set to 0.

[0051] Figure 28 This is an example of using information transmitted through the bitstream to indicate the location of sub-blocks that are being transformed and / or quantized.

[0052] Figure 29 This is a flowchart of the process for determining the strength of a block.

[0053] Figure 30 This represents a predefined filter candidate. Detailed Implementation

[0054] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0055] Video encoding and decoding are performed on a block-by-block basis. As an example, encoding or decoding processes such as transform, quantization, prediction, loop filtering, or reconstruction can be performed on encoded blocks, transform blocks, or prediction blocks.

[0056] The block that is used for encoding or decoding will be referred to as the "current block". As an example, the current block can be represented as an encoded block, a transform block, or a prediction block, depending on the current encoding or decoding process.

[0057] Furthermore, the term "unit" as used in this specification refers to the basic unit used to perform a specific encoding or decoding process, and "block" can be understood as a sample array of a given size. Unless otherwise stated, "block" and "unit" can have the same meaning. As an example, in the embodiments described later, encoding block and encoding unit can be understood to have the same meaning.

[0058] Figure 1 This is a block diagram of a video encoder according to an embodiment of this application.

[0059] like Figure 1 As shown, the video encoding apparatus 100 may include an image segmentation unit 110, a prediction unit 120, 125, a transformation unit 130, a quantization unit 135, a reordering unit 160, an entropy encoding unit 165, an inverse quantization unit 140, an inverse transformation unit 145, a filtering unit 150, and a memory 155.

[0060] Figure 1 The various components shown are illustrated independently in the video encoding apparatus to illustrate their distinct characteristic functions, but this does not imply that each component is composed of a separate hardware or software unit. That is, the components are listed as separate components for ease of explanation. At least two components may be combined into one component, or one component may be divided into multiple components to perform functions. Such integrated and separate embodiments of the components are included within the scope of protection of this application, provided they do not depart from its essence.

[0061] Furthermore, some constituent elements are not essential for the essential functions of this application, but are selected to improve performance. This application may include only the constituent parts necessary to realize the essence of this application (i.e., this application may not include constituent elements used only to improve performance), and structures that include only essential constituent elements are also included within the scope of protection of this application.

[0062] The image partitioning unit 110 can divide the input image into at least one processing unit. This processing unit can be a prediction unit (PU), a transformation unit (TU), or a coding unit (CU). In the image partitioning unit 110, an image can be divided into combinations of multiple coding units, prediction units, and transformation units. Based on a predetermined criterion (e.g., a cost function), the combination of coding units, prediction units, and transformation units is selected to encode the image.

[0063] For example, an image can be divided into multiple coding units. To divide an image into coding units, a recursive tree structure such as a quadtree structure can be used, with a video or the largest coding unit as the root, to divide it into different coding units. The division can be performed using child nodes corresponding to the number of coding units. Coding units that cannot be further divided according to predetermined constraints become leaf nodes. That is, assuming that only square partitioning is possible for a coding unit, a coding unit can be divided into a maximum of 4 different coding units.

[0064] In the embodiments of this application, the encoding unit can represent either a unit that performs encoding or a unit that performs decoding.

[0065] Prediction units can be divided within a coding unit using at least one square or rectangle of the same size, or they can be divided into prediction units within a coding unit where one prediction unit has a different shape and / or size than another prediction unit.

[0066] When generating prediction units for intra-frame prediction based on coding units, intra-frame prediction can be performed without dividing the coding unit into multiple prediction units N×N if the coding unit is not the smallest coding unit.

[0067] Prediction units 120 and 125 may include an inter-frame prediction unit 120 that performs inter-frame prediction and an intra-frame prediction unit 125 that performs intra-frame prediction. It can be determined whether to use inter-frame prediction or perform intra-frame prediction for a prediction unit, and specific information based on each prediction method (e.g., intra-frame prediction mode, motion vector, reference image, etc.) can be determined. In this case, the processing unit performing the prediction, the prediction method, and the specific content will differ depending on the predetermined processing unit. For example, the prediction method and prediction mode are determined according to the prediction unit, and the prediction execution can also be performed according to the transform unit. The residual value (residual block) between the generated prediction block and the original block can be input to the transform unit 130. Furthermore, prediction mode information, motion vector information, etc., used for prediction can be encoded together with the residual value in the entropy coding unit 165 and transmitted to the decoder. When using a specific coding mode, the prediction blocks may not be generated by prediction units 120 and 125; instead, the original block can be directly encoded and transmitted to the decoding unit.

[0068] The inter-frame prediction unit 120 can predict prediction units based on information from at least one image preceding or following the current image, or, depending on the situation, based on information from a portion of the encoded region within the current image. The inter-frame prediction unit 120 may include a reference image interpolation unit, a motion prediction unit, and a motion compensation unit.

[0069] The reference image interpolation unit can obtain the provided reference image information from the memory 155 and generate pixel information in the reference image down to an integer pixel size. For luminance pixels, to generate pixel information down to an integer pixel size in 1 / 4 pixel units, an 8-tap DCT-based interpolation filter with different filtering coefficients can be used. For chrominance signals, to generate pixel information down to an integer pixel size in 1 / 8 pixel units, a 4-tap DCT-based interpolation filter with different filtering coefficients can be used.

[0070] The motion prediction unit can perform motion prediction based on a reference image interpolated by the reference image interpolation unit. Various methods can be used to calculate motion vectors, such as FBMA (Full search-based Block Matching Algorithm), TSS (Three Step Search), and NTS (New Three-Step Search Algorithm). The motion vectors are based on interpolated pixels and can have motion vector values ​​in 1 / 2 or 1 / 4 pixel units. The motion prediction unit can employ different motion prediction methods to predict the current prediction unit. Various motion prediction methods can be used, such as Skip mode, Merge mode, AMVP (Advanced Motion Vector Prediction) mode, and IntraBlock Copy mode.

[0071] The intra-prediction unit 125 can generate prediction units based on neighboring reference pixel information of the current block, which serves as pixel information within the current image. Since the neighboring blocks of the current prediction unit are blocks performing inter-frame prediction, when a reference pixel is a pixel performing inter-frame prediction, the reference pixel contained in the block performing inter-frame prediction can be replaced with the reference pixel information of the adjacent block performing intra-frame prediction. That is, when a reference pixel is unavailable, at least one of the available reference pixels can be used to replace the unavailable reference pixel information.

[0072] In intra-frame prediction, the prediction mode can have an angular prediction mode that uses reference pixel information based on the prediction direction and a non-angular mode that does not use angular information when performing prediction. The mode used to predict luminance information can be different from the mode used to predict chromatic difference information. To predict chromatic difference information, either the intra-frame prediction mode information used to predict luminance information or the predicted luminance signal information can be used.

[0073] When performing intra-frame prediction, if the size of the prediction unit is the same as the size of the transform unit, intra-frame prediction can be performed based on the pixels to the left, the pixels at the top left, and the pixels at the top of the prediction unit. However, when performing intra-frame prediction, if the size of the prediction unit is different from the size of the transform unit, intra-frame prediction can be performed using reference pixels based on the transform unit. Additionally, for the smallest coding unit, intra-frame prediction with an N×N partition can be used.

[0074] Intra-prediction methods can generate prediction blocks by applying AIS (Adaptive IntraSmoothing) filtering to reference pixels based on the prediction mode. The types of AIS filters applied to the reference pixels can be different. To perform intra-prediction, the intra-prediction mode of the current prediction unit can be predicted from the intra-prediction modes of adjacent prediction units. When using mode information predicted from adjacent prediction units to predict the prediction mode of the current prediction unit, if the intra-prediction modes of the current prediction unit and adjacent prediction units are the same, predetermined identification information can be used to transmit information indicating that the prediction modes of the current prediction unit and adjacent prediction units are the same. If the prediction modes of the current prediction unit and adjacent prediction units are different, entropy coding can be performed to encode the prediction mode information of the current block.

[0075] Additionally, based on the prediction units generated by prediction units 120 and 125, a residual block containing residual value information can be generated, where the residual value is the difference between the prediction unit performing the prediction and the original block of the prediction unit. The generated residual block can be input to the transformation unit 130.

[0076] In the transform unit 130, transform methods such as DCT (Discrete Cosine Transform), DST (Discrete Sine Transform), and KLT can be used to transform the residual block, which includes the residual information of the original block and the prediction units generated by the prediction units 120 and 125. Whether to apply DCT, DST, or KLT to transform the residual block can be determined based on the intra-frame prediction mode information of the prediction units used to generate the residual block.

[0077] The quantization unit 135 can quantize the values ​​that have been transformed into the frequency domain in the transformation unit 130. The quantization coefficients can vary depending on the block or the importance of the video. The values ​​calculated by the quantization unit 135 can be provided to the inverse quantization unit 140 and the reordering unit 160.

[0078] The reordering unit 160 can perform a reordering of coefficient values ​​for the quantized residual values.

[0079] The reordering unit 160 can transform two-dimensional block shape coefficients into one-dimensional vector shapes using a coefficient scanning method. For example, the reordering unit 160 can use a zig-zag scan method to scan from DC coefficients to high-frequency domain coefficients, transforming them into one-dimensional vector shapes. Depending on the size of the transform unit and the intra-frame prediction mode, vertical scanning along the column direction or horizontal scanning along the row direction can be used instead of zig scanning. That is, any scanning method among zig scanning, vertical scanning, and horizontal scanning can be used depending on the size of the transform unit and the intra-frame prediction mode.

[0080] The entropy coding unit 165 can perform entropy coding based on the value calculated by the reordering unit 160. Entropy coding can use various coding methods such as Exponential Golomb, CAVLC (Context-Adaptive Variable Length Coding), and CABAC (Context-Adaptive Binary Arithmetic Coding).

[0081] The entropy coding unit 165 can encode various information from the coding units of the reordering unit 160 and the prediction units 120 and 125, such as residual coefficient information, block type information, prediction mode information, partitioning unit information, prediction unit information, transmission unit information, motion vector information, reference frame information, block interpolation information, and filtering information.

[0082] The entropy coding unit 165 can entropy code the coefficient values ​​of the coding units input from the reordering unit 160.

[0083] The inverse quantization unit 140 and the inverse transform unit 145 perform inverse quantization on the value quantized by the quantization unit 135 and inverse transform on the value transformed by the transform unit 130. The residual value generated by the inverse quantization unit 140 and the inverse transform unit 145 can be merged with the prediction unit predicted by the motion prediction unit, motion compensation unit and intra-frame prediction unit included in the prediction units 120 and 125 to generate a reconstructed block.

[0084] The filtering unit 150 may include at least one of a deblocking filter, an offset compensation unit, and an ALF (Adaptive Loop Filter).

[0085] Deblocking filters can remove block distortion caused by block boundaries from a reconstructed image. To determine whether to perform deblocking, the number of columns or rows containing the pixels can be used to decide whether to apply deblocking filtering to the current block. When applying deblocking filtering to a block, a strong filter or a weak filter can be applied depending on the desired deblocking filtering intensity. Furthermore, when applying deblocking filters, vertical and horizontal filtering can be performed in parallel.

[0086] The offset compensation unit can compensate for the offset from the original video on a pixel-by-pixel basis for the video being deblocked. To perform offset compensation on a specific image, the pixels contained in the video can be divided into a predetermined number of regions, the regions where the offset will be applied can be determined, and the offset can be applied to the corresponding regions, or the offset can be applied based on the edge information of each pixel.

[0087] ALF (Adaptive Loop Filtering) can be performed by comparing the values ​​of the reconstructed image being filtered with those of the original image. After dividing the pixels of the image into predetermined groups, a filter can be determined to be applied to the corresponding group, and filtering is performed differently for each group. Information regarding whether ALF is applied, i.e., the luminance signal, can be transmitted according to coding units (CUs). The shape and filter coefficients of the ALF filter to be applied to each block can differ. Alternatively, ALF filters of the same shape (fixed shape) can be used regardless of the characteristics of the target block.

[0088] The memory 155 can store the reconstructed blocks or reconstructed images calculated by the filtering unit 150, and the stored reconstructed blocks or images can be provided to the prediction units 120 and 125 when performing inter-frame prediction.

[0089] Figure 2 This is a block diagram of a video decoder according to an embodiment of this application.

[0090] like Figure 2 As shown, the video decoder 200 may include an entropy decoding unit 210, a reordering unit 215, an inverse quantization unit 220, an inverse transform unit 225, a prediction unit 230, 235, a filtering unit 240, and a memory 245.

[0091] When a video stream is input into a video encoder, the input stream can be decoded in the reverse order of the video encoder steps.

[0092] The entropy decoding unit 210 can perform entropy decoding in the reverse order of entropy encoding performed by the entropy encoding unit of the video encoder. For example, corresponding to the method performed by the video encoder, various methods such as Exponential Golomb, CAVLC (Context-Adaptive Variable Length Coding), and CABAC (Context-Adaptive Binary Arithmetic Coding) can be used.

[0093] The entropy decoding unit 210 can decode information related to intra-frame prediction and inter-frame prediction performed by the encoder.

[0094] The reordering unit 215 can perform reordering in the encoding unit using a reordering method based on the bitstream entropy decoded by the entropy decoding unit 210. It can reorder coefficients represented as one-dimensional vectors, reconstructing them into two-dimensional block-shaped coefficients. The reordering unit 215 receives information from the encoding unit related to coefficient scanning and can perform reordering using a reverse scanning method based on the scanning order executed by the corresponding encoding unit.

[0095] The inverse quantization unit 220 can perform inverse quantization based on the quantization parameters provided by the encoder and the coefficient values ​​of the reordered blocks.

[0096] The inverse transform unit 225 performs the transforms on the quantization results of the video encoder as performed by the transform unit. Specifically, it performs the corresponding inverse transforms for DCT, DST, and KLT transforms, namely, inverse DCT, inverse DST, and inverse KLT transforms. The inverse transforms can be performed based on the transmission units determined by the video encoder. In the inverse transform unit 225 of the video decoder, transform methods (e.g., DCT, DST, and KLT transforms) can be selectively performed based on multiple pieces of information, such as the prediction method, the size of the current block, and the prediction direction.

[0097] Prediction units 230 and 235 can generate prediction blocks based on information related to the generation of prediction blocks provided by entropy decoding unit 210 and previously decoded block or image information provided by memory 245.

[0098] As mentioned earlier, when performing intra-frame prediction in the same manner as the video encoder, if the size of the prediction unit is the same as the size of the transform unit, intra-frame prediction is performed based on the pixels to the left, the pixels at the top left, and the pixels at the top of the prediction unit. However, if the size of the prediction unit is different from the size of the transform unit, intra-frame prediction can be performed using reference pixels based on the transform unit. Alternatively, intra-frame prediction can be performed only on the smallest coding unit using an N×N partition.

[0099] Prediction units 230 and 235 may include a prediction unit determination unit, an inter-frame prediction unit, and an intra-frame prediction unit. The prediction unit determination unit may receive various information input from the entropy decoding unit 210, such as prediction unit information, prediction mode information of the intra-frame prediction method, and motion prediction-related information of the inter-frame prediction method. It then distinguishes prediction units within the current coding unit and determines whether the prediction unit should perform inter-frame prediction or intra-frame prediction. The inter-frame prediction unit 230 may utilize the information required for inter-frame prediction of the current prediction unit provided by the video encoder, and perform inter-frame prediction for the current prediction unit based on information contained in at least one image preceding or following the current image contained in the current prediction unit. Alternatively, it may perform inter-frame prediction within the current image containing the current prediction unit, based on information from a reconstructed portion of the region.

[0100] To perform inter-frame prediction, the motion prediction method of the prediction unit contained in the corresponding coding unit can be determined based on the coding unit: Skip Mode, Merge Mode, AMVP Mode, or Intra-Block Copy Mode.

[0101] The intra-prediction unit 235 can generate prediction blocks based on pixel information within the current image. When the prediction unit is a prediction unit performing intra-prediction, intra-prediction can be performed based on the intra-prediction mode information of the prediction unit provided by the video encoder. The intra-prediction unit 235 may include an AIS (Adaptive Intra Smoothing) filter, a reference pixel interpolation unit, and a DC filter. The AIS filter, as the part that performs filtering on the reference pixels of the current block, can determine whether to apply the filter based on the prediction mode of the current prediction unit. AIS filtering can be performed on the reference pixels of the current block based on the prediction mode of the prediction unit and the AIS filter information provided by the video encoder. When the prediction mode of the current block is a mode in which AIS filtering is not performed, the AIS filter may not be applied.

[0102] The reference pixel interpolation unit can interpolate reference pixel values ​​to generate reference pixels for pixel units with integer values ​​when the prediction mode of the current prediction unit is a prediction mode that generates prediction blocks without interpolating reference pixel values. When the prediction mode of the current prediction unit is a prediction mode that generates prediction blocks without interpolating reference pixel values, the reference pixels do not need to be interpolated. The DC filter can generate prediction blocks by filtering when the prediction mode of the current block is DC mode.

[0103] The reconstructed blocks or image can be provided to the filtering unit 240. The filtering unit 240 may include a deblocking filter, an offset compensation unit, and an ALF.

[0104] Information about whether to apply a deblocking filter to a corresponding block or image can be obtained from the video encoder. When a deblocking filter is applied, information about whether a strong or weak filter is applied can be obtained. The video decoder's deblocking filter can receive relevant information about the deblocking filter provided by the video encoder, and the video decoder can perform deblocking filtering on the corresponding block.

[0105] The offset compensation unit can perform offset compensation on the reconstructed video based on the type of offset compensation applied to the video during encoding and offset value information.

[0106] The ALF can be applied to the coding unit based on information such as whether the ALF is applied and ALF coefficient information provided by the encoder. This ALF information can be provided within a specific parameter set.

[0107] The memory 245 can store the reconstructed image or block so that it can be used as a reference image or reference block. In addition, the reconstructed image can be provided to the output unit.

[0108] Figure 3 This is a diagram illustrating a basic coding tree unit of an embodiment of this application.

[0109] The largest coding block can be defined as the coding tree block. An image is divided into multiple coding tree units (CTUs). The coding tree unit, as the largest coding unit, can also be called the LCU (Largest Coding Unit). Figure 3 An example of dividing an image into multiple coding tree units is shown.

[0110] The size of a coding tree unit can be defined at the image level or the sequence level. Therefore, information representing the size of a coding tree unit can be signaled through an image parameter set or a sequence parameter set.

[0111] As an example, the size of the coding tree unit for all images in the sequence can be set to 128x128. Alternatively, at the image level, either 128x128 or 256x256 can be determined as the size of the coding tree unit. As an example, in the first image, the size of the coding tree unit can be set to 128x128, and in the second image, the size of the coding tree unit can be set to 256x256.

[0112] The coding tree can be divided into units to generate coding blocks. A coding block represents a basic unit used for encoding or decoding processing. As an example, prediction or transformation can be performed according to the coding block, or a prediction coding mode can be determined according to the coding block. The prediction coding mode represents the method for generating predicted video. As an example, prediction coding modes can include intra-frame prediction, inter-frame prediction, current picture referencing (CPR or intra-block copy, IBC), or combined prediction. For a given coding block, a prediction block can be generated using at least one of the prediction coding modes: intra-frame prediction, inter-frame prediction, current picture referencing, or combined prediction.

[0113] Information indicating the predictive coding mode of the current block can be signaled via the bitstream. As an example, this information could be a 1-bit identifier indicating whether the predictive coding mode is intra-frame or inter-frame. The current reference image or composite prediction can only be used if the predictive coding mode of the current block is determined to be inter-frame.

[0114] The current reference image is used to set the current image as the reference image, and to obtain the prediction block of the current block from the encoded or decoded regions within the current image. Here, the current image refers to the image that includes the current block. Information indicating whether the current block uses the current reference image can be transmitted via the bitstream. As an example, this information can be a 1-bit identifier. When the identifier is true, the prediction coding mode of the current block can be determined to be the current reference image; when the identifier is false, the prediction mode of the current block can be determined to be inter-frame prediction.

[0115] Alternatively, the predictive coding mode for the current block can be determined based on the reference image index. As an example, when the reference image index points to the current image, the predictive coding mode for the current block can be determined to be the current reference image. When the reference image index points to another image that is not the current image, the predictive coding mode for the current block can be determined to be inter-frame prediction. That is, the current reference image prediction method utilizes information from already encoded or decoded regions within the current image, while inter-frame prediction utilizes information from another already encoded or decoded image.

[0116] Composite prediction combines intra-frame prediction, inter-frame prediction, and two or more coding modes from the current reference image. As an example, when applying composite prediction, a first prediction block can be generated based on one of the intra-frame prediction, inter-frame prediction, or the current reference image, and a second prediction block can be generated based on another. After the first and second prediction blocks are generated, the final prediction block can be generated by averaging or weighted summing the first and second prediction blocks. Information indicating whether composite prediction is applied can be transmitted through the bitstream. This information can be a 1-bit identifier.

[0117] Figure 4 This is a schematic diagram of various partition shapes for the coded block.

[0118] A coded block can be divided into multiple coded blocks based on quadtree partitioning, binary tree partitioning, or ternary tree partitioning. A divided coded block can also be further divided into multiple coded blocks based on quadtree partitioning, binary tree partitioning, or ternary tree partitioning.

[0119] Quadtree partitioning represents a method of dividing the current block into four blocks. The result of quadtree partitioning is that the current block can be divided into four square partitions (see [reference]). Figure 4 (a) "SPLIT_QT").

[0120] Binary tree partitioning represents a method of dividing the current block into two blocks. Partitioning the current block along a vertical direction (i.e., using a vertical line crossing the current block) is called vertical binary tree partitioning, and partitioning it along a horizontal direction (i.e., using a horizontal line crossing the current block) is called horizontal binary tree partitioning. As a result of binary tree partitioning, the current block can be divided into two non-square partitions. Figure 4 (b) "SPLIT_BT_VER" shows the result of the vertical binary tree partitioning. Figure 4 (c) “SPLIT_BT_HOR” shows the result of the horizontal binary tree partitioning.

[0121] A ternary tree partition represents a method of dividing the current block into three blocks. Dividing the current block into three blocks along the vertical direction (i.e., using the two vertical lines crossing the current block) is called a vertical ternary tree partition, and dividing it into three blocks along the horizontal direction (i.e., using the two horizontal lines crossing the current block) is called a horizontal ternary tree partition. As a result of ternary tree partitioning, the current block can be divided into three non-square partitions. In this case, the width or height of the partition located in the center of the current block can be twice the width or height of the other partitions. Figure 4 (d) "SPLIT_TT_VER" shows the vertical ternary tree partitioning result. Figure 4(e) “SPLIT_TT_HOR” shows the result of the horizontal ternary tree partitioning.

[0122] The number of partitions in a coding tree unit can be defined as the partitioning depth. The maximum partitioning depth of a coding tree unit can be determined at the sequence or image level. Therefore, the maximum partitioning depth of a coding tree unit will vary depending on the sequence or image.

[0123] Alternatively, the maximum partition depth for each partitioning method can be determined individually. As an example, the maximum partition depth allowed for quadtree partitioning can be different from the maximum partition depth allowed for binary tree partitioning and / or ternary tree partitioning.

[0124] The encoder can transmit at least one piece of information, either the partition shape or the partition depth, of the current block via the bitstream. The decoder can determine the partition shape and partition depth of the coding tree unit based on the information parsed from the bitstream.

[0125] Figure 5 This is an exemplary illustration of the partition shape of a coding tree unit.

[0126] The use of quadtree partitioning, binary tree partitioning, and / or ternary tree partitioning to divide coding blocks is called multi-tree partitioning.

[0127] A coded block generated by applying a multi-way tree partitioning to a coded block can be called a lower-level coded block. When the partitioning depth of a coded block is k, the partitioning depth of the lower-level coded block is set to k+1.

[0128] Conversely, for a coded block with a partition depth of k+1, the coded block with a partition depth of k can be called the upper-level coded block.

[0129] The partition type of the current coding block can be determined based on at least one of the partition shape of the parent coding block or the partition type of adjacent coding blocks. Adjacent coding blocks can include at least one of the following: the upper adjacent block, the left adjacent block, or the adjacent block at the upper left corner of the current coding block. The partition type can include at least one of the following: whether it is a quadtree partition, whether it is a binary tree partition, the direction of the binary tree partition, whether it is a ternary tree partition, or the direction of the ternary tree partition.

[0130] To determine the shape of the coded block partition, information indicating whether the coded block has been partitioned can be transmitted via a signal in the bitstream. This information is a 1-bit identifier "split_cu_flag," which, if true, indicates that the coded block was partitioned using a quadtree partitioning method.

[0131] When split_cu_flag is true, information indicating whether the coded block is a quadtree partition can be transmitted through the bitstream. This information is a 1-bit identifier split_qt_flag. When this identifier is true, the coded block can be divided into 4 blocks.

[0132] As an example, in Figure 5 In the example shown, the coding tree unit is partitioned by a quadtree, thus illustrating the generation of four coding blocks with a partition depth of 1. Furthermore, the example illustrates applying quadtree partitioning again to the first and fourth coding blocks of the four coding blocks generated from the quadtree partitioning result. As a result, four coding blocks with a partition depth of 2 can be generated.

[0133] Furthermore, by applying quadtree partitioning to the coded block with a partition depth of 2 again, a coded block with a partition depth of 3 can be generated.

[0134] When a quadtree partitioning is not applied to the coded block, it can be determined whether to perform binary or ternary tree partitioning on the coded block based on at least one of the following: the size of the coded block, whether the coded block is located at the image boundary, the maximum partitioning depth, or the partitioning shape of adjacent blocks. When it is determined that binary or ternary tree partitioning will be performed on the coded block, information indicating the partitioning direction can be transmitted via the bitstream. This information can be a 1-bit identifier `mtt_split_cu_vertical_flag`. Based on this identifier, it can be determined whether the partitioning direction is vertical or horizontal. Optionally, information indicating whether binary or ternary tree partitioning is applied to the coded block can be transmitted via the bitstream. This information can be a 1-bit identifier `mtt_split_cu_binary_flag`. Based on this identifier, it can be determined whether binary or ternary tree partitioning has been applied to the coded block.

[0135] As an example, in Figure 5 The example shown illustrates the application of a vertical binary tree partitioning to a coded block with a partitioning depth of 1, the application of a vertical ternary tree partitioning to the left coded block in the resulting coded block, and the application of a vertical binary tree partitioning to the right coded block.

[0136] Inter-frame prediction utilizes information from previous images to predict the predictive coding mode of the current block. As an example, a block in a previous image that shares the same position as the current block (hereinafter referred to as a collocated block) can be set as the predicted block for the current block. The predicted block generated based on the block that shares the same position as the current block will be called a collocated prediction block.

[0137] Conversely, if an object present in a previous image has moved to a different position in the current image, the object's motion can be used to effectively predict the current block. For example, if the direction and size of an object's motion can be determined by comparing the previous and current images, a predicted block (or video prediction) can be generated based on the object's motion information. The predicted block generated from motion information is called a motion prediction block.

[0138] Residual blocks are generated by predicting blocks differentially from the current block. If there is movement of objects, the movement prediction block is used instead of the same-position prediction block, which reduces the energy of the residual block and thus improves the compression performance of the residual block.

[0139] As mentioned above, the use of motion information to generate prediction blocks is called motion-compensated prediction. In most inter-frame predictions, prediction blocks can be generated based on motion-compensated prediction.

[0140] Motion information may include at least one of a motion vector, a reference image index, a prediction direction, or a bidirectional weighted index. The motion vector represents the direction and distance of the object's movement. The reference image index indicates the reference image for the current block among the reference images contained in the reference image list. The prediction direction refers to one of unidirectional L0 prediction, unidirectional L1 prediction, or bidirectional prediction (L0 and L1 prediction). Depending on the prediction direction of the current block, at least one of motion information in the L0 direction or the L1 direction can be used. The bidirectional weighted index specifies the weights applied in the L0 prediction block and the weights applied in the L1 prediction block.

[0141] Figure 6 This is a flowchart of an inter-frame prediction method according to an embodiment of this application.

[0142] like Figure 6 As shown, the inter-frame prediction method includes: determining the inter-frame prediction mode of the current block (S601); obtaining motion information of the current block according to the determined inter-frame prediction mode (S602); and performing motion compensation prediction for the current block based on the obtained motion information (S603).

[0143] Inter-frame prediction modes represent various methods for determining motion information of the current block, which may include inter-frame prediction modes utilizing translational motion information and inter-frame prediction modes utilizing affine motion information. As an example, inter-frame prediction modes utilizing translational motion information may include merging mode and motion vector prediction mode, while inter-frame prediction modes utilizing affine motion information may include affine merging mode and affine motion vector prediction mode. The motion information of the current block is determined based on the inter-frame prediction mode, as well as information from neighboring blocks adjacent to the current block or information parsed from the bitstream.

[0144] As an example, the motion information of the current block can be obtained based on the motion information of spatially adjacent blocks contained in the same image as the current block, or co-located blocks contained in an image different from the current block. Spatially adjacent blocks include at least one of the following: adjacent blocks adjacent to the top edge of the current block, adjacent blocks adjacent to the left edge, adjacent blocks adjacent to the top left corner, adjacent blocks adjacent to the top right corner, or adjacent blocks adjacent to the bottom left corner. Co-located blocks can have the same position and size as the current block within a reference image. As an example, Figure 7 This is a diagram showing a block at the same location. The reference image can be determined based on the reference image indicated by the index information.

[0145] The precision of the motion vectors for the current block can be determined from a plurality of motion vector precision candidates. As an example, motion vector precision candidates may include at least one of the following: one-eighth of a pixel, one-quarter of a pixel, one-half of a pixel, an integer pixel, a multiple of 2 pixels, or a multiple of 4 pixels. The number or type of motion vector precision candidates can be determined based on a sequence, frame, or block unit. As an example, information used to determine the number or type of motion vector precision candidates can be signaled via the bitstream. Alternatively, the number or type of motion vector precision candidates can be determined based on whether the inter-frame prediction mode or affine motion model of the current block is used. Information for specifying one of the plurality of motion vector precision candidates can also be signaled via the bitstream.

[0146] Intra-frame prediction refers to predicting the current block using previously encoded or decoded reconstructed samples adjacent to the current block. In this case, the intra-frame prediction of the current block can use reconstructed samples before the application of loop filtering.

[0147] Intra-prediction methods include matrix-based intra-prediction and ordinary intra-prediction based on the angles of neighboring reconstructed samples. Information indicating the intra-prediction method for the current block can be transmitted via a signal in the bitstream. This information can be a 1-bit identifier. Alternatively, the intra-prediction method for the current block can be determined based on at least one of the current block's position, size, shape, or the intra-prediction methods of neighboring blocks. As an example, if the current block crosses an image boundary, it can be configured not to apply matrix-based intra-prediction in the current block.

[0148] Matrix-based intra-frame prediction obtains the predicted block for the current block by multiplying the matrices stored in the encoder and decoder with the reconstructed samples adjacent to the current block. Specific information can be extracted from one of the stored matrices, and this information can be transmitted via the bitstream. The decoder can determine the matrix required for intra-frame prediction of the current block based on this information and the size of the current block.

[0149] Ordinary intra-frame prediction is a method for obtaining the predicted block for the current block based on either non-angular intra-frame prediction mode or angular intra-frame prediction mode. The execution process of intra-frame prediction based on ordinary intra-frame prediction will be explained in more detail below with reference to the accompanying drawings.

[0150] Figure 8 This is a flowchart of an intra-frame prediction method according to an embodiment of this application.

[0151] The reference sample line for the current block can be determined (S801). The reference sample line means the set of reference samples contained in the k-th row starting from the top and / or left of the current block. The reference samples can be obtained from the reconstructed samples that have been encoded or decoded adjacent to the current block.

[0152] The index information of the reference sample lines in the current block among multiple reference sample lines can be identified by transmitting signals through the bitstream. As an example, specific index information `intra_luma_ref_idx` for the reference sample lines of the current block can be transmitted via the bitstream. This index information can be transmitted as a unit on the coding block.

[0153] Multiple reference sample lines may include at least one of the top and / or leftmost lines 1, 2, 3, or 4 of the current block. Alternatively, a reference sample line consisting of the row adjacent to the top of the current block and the column adjacent to the left of the current block may be called an adjacent reference sample line, and the other reference sample lines may be called non-adjacent reference sample lines.

[0154] Figure 9 This is a schematic diagram of the reference sample line.

[0155] exist Figure 9The diagram illustrates an adjacent reference sample line consisting of rows or columns adjacent to the current block and three non-adjacent reference sample lines consisting of rows or columns not adjacent to the current block.

[0156] You can select only a subset of multiple reference sample lines as the reference sample lines for the current block. As an example, you can... Figure 9 The reference sample lines shown, except for the second non-adjacent reference sample line, are designated as candidate reference sample lines. Table 1 shows the indices assigned to each candidate reference sample line.

[0157] Table 1

[0158] Index (intra_luma_ref_idx) Reference sample line 0 Adjacent reference sample lines 1 First non-adjacent reference sample line 2 Second non-adjacent reference sample line

[0159] You may also set more or fewer candidate reference sample lines than the number described. Furthermore, the number or position of non-adjacent reference sample lines set as candidate reference sample lines is not limited to the illustrated example. As an example, you may set the first and third non-adjacent reference sample lines as candidate reference sample lines, or you may set the second and third non-adjacent reference sample lines as candidate reference sample lines. Alternatively, you may set the first, second, and third non-adjacent reference sample lines as candidate reference sample lines.

[0160] The number or type of candidate reference sample lines can be determined based on at least one of the following: the size, shape, position, whether it is divided into sub-blocks, or intra-prediction mode of the current block.

[0161] The reference sample line for the current block can also be determined based on at least one of the following: the position, size, shape, or predicted coding patterns of adjacent blocks. As an example, if the current block is adjacent to the boundary of an image, tile, slice, or coding tree unit, the adjacent reference sample line can be used as the reference sample line for the current block.

[0162] Alternatively, if the current block is not square, adjacent reference sample lines can be used as reference sample lines for the current block. Or, if the width and height of the current block are greater than or less than a threshold, adjacent reference sample lines can be used as reference sample lines for the current block.

[0163] The reference sample line may include an upper reference sample located at the top of the current block and a left reference sample located to the left of the current block. The upper and left reference samples can be obtained from the reconstructed samples adjacent to the current block. The reconstructed samples can be the state before the application of loop filtering.

[0164] The number of reference samples contained in a reference sample line can be determined based on the distance between reference sample lines. As an example, a reference sample line at a distance *i* from the current block can contain more reference samples than a reference sample line at a distance of *i-1* from the current block. Therefore, non-adjacent reference sample lines contain more reference samples than adjacent reference sample lines.

[0165] The difference between the number of reference samples contained in a non-adjacent reference sample line at a distance i from the current block and the number of reference samples contained in an adjacent reference sample line can be defined as the reference sample number offset. In this case, the difference in the number of reference samples at the top of the current block can be defined as offsetX[i], and the difference in the number of reference samples at the left of the current block can be defined as offsetY[i]. offsetX and offsetY can be determined based on the distance between the current block and the non-adjacent reference sample lines. As an example, offsetX and offsetY can be set to integer multiples of i. As an example, offsetX[i] and offset[i] can be 2i.

[0166] Alternatively, the offset of the number of reference samples can be determined based on the width-to-height ratio of the current block. Equation 1 provides an example of numerically representing the width-to-height ratio of the current block.

[0167] [Formula 1]

[0168] whRatio = Log2(nTbW / nTbH)

[0169] Alternatively, a different approach can be used to numerically represent the width-to-height ratio of the current block, as shown in Formula 1.

[0170] The values ​​of offsetX and offsetY can be determined based on the width-to-height ratio of the current block. For example, if the whRatio value is greater than 1, the offsetX value can be set to be greater than the offsetY value. As an example, offsetX can be set to 1 and offsetY can be set to 0. Conversely, if the whRatio value is less than 1, offsetY can be set to be greater than the offsetX value. As an example, offsetX can be set to 0 and offsetY can be set to 1.

[0171] Besides the left-side upper reference sample with the same x-axis and y-axis coordinates, the non-adjacent reference sample line at a distance i from the current block can be composed of (refW+offsetX[i]) upper reference samples and (refH+offsetY[i]) left reference samples. Here, refW and refH represent the lengths of adjacent reference sample lines, which can be set as shown in Formulas 2 and 3 below, respectively.

[0172] [Formula 2]

[0173] refW=2*nTbW

[0174] [Formula 3]

[0175] refH=2*nTbH

[0176] In Equations 2 and 3, nTbW represents the width of the coded block or transform block performing intra-frame prediction, and nTbH represents the height of the coded block or transform block performing intra-frame prediction.

[0177] As a result, the reference sample line at a distance i from the current block can be composed of (refW+refH+offsetX[i]+offsetY[i]+1) reference samples.

[0178] The prediction sample is obtained based on the intra-frame prediction mode of the current block and by utilizing at least one of the reference samples belonging to the reference sample line.

[0179] Then, the intra-prediction mode of the current block can be determined (S802). The intra-prediction mode of the current block can be determined by at least one of the non-angular intra-prediction modes or the angular intra-prediction modes. The non-angular intra-prediction modes include planner and DC, and the angular intra-prediction modes include 33 or 65 modes from the lower left diagonal direction to the upper right diagonal direction.

[0180] Figure 10 This is a schematic diagram of the intra-frame prediction mode.

[0181] Figure 10 (a) shows 35 intra-frame prediction modes. Figure 10 (b) shows 67 intra-frame prediction modes.

[0182] You can also define a ratio Figure 10 The number of intra-prediction modes shown is either greater or less.

[0183] The Most Probable Mode (MPM) can be set based on the intra-prediction modes of neighboring blocks adjacent to the current block. Neighboring blocks can include the left-side neighboring block adjacent to the left of the current block and the upper-side neighboring block adjacent to the top of the current block. If the coordinates of the upper left sample of the current block are (0, 0), the left-side neighboring block can include samples at positions (-1, 0), (-1, H-1), or (-1, (H-1) / 2), where H represents the height of the current block. The upper-side neighboring block can include samples at positions (0, -1), (W-1, -1), or ((W-1) / 2, -1), where W represents the width of the current block.

[0184] When adjacent blocks are coded using normal intra-prediction, the MPM can be obtained based on the intra-prediction mode of the adjacent blocks. Specifically, the intra-prediction mode of the left adjacent block can be set to the parameter candIntraPredModeA, and the intra-prediction mode of the upper adjacent block can be set to the parameter candIntraPredModeB.

[0185] In situations where adjacent blocks cannot be utilized (e.g., when adjacent blocks have not yet been encoded or decoded, or when the position of adjacent blocks exceeds the image boundary), the parameter `candIntraPredModeX` (where X is A or B) obtained from the adjacent block's intra-prediction mode can be set to the default mode if the adjacent blocks are encoded using matrix-based intra-prediction, inter-prediction, or are contained in a different coding tree unit than the current block. The default mode can include at least one of planner, DC, vertical mode, or horizontal mode.

[0186] Alternatively, when adjacent blocks are encoded using matrix-based intra-prediction, the intra-prediction mode corresponding to a specific index value in the matrix can be set to candIntraPredModeX. For this purpose, a lookup table mapping the specific index values ​​in the matrix to the intra-prediction modes can be pre-stored in the encoder and decoder.

[0187] MPM can be obtained based on the parameters candIntraPredModeA and candIntraPredModeB. As an example, candIntraPredModeA and candIntraPredModeB can be set to MPM, or an intra-prediction mode close to the larger or smaller value of candIntraPredModeA or candIntraPredModeB can be set to MPM. Intra-prediction modes similar to candIntraPredModeX (where X is A or B) can be intra-prediction modes with an index difference of ±1 or ±2 from candIntraPredModeX.

[0188] The number of MPMs included in the MPM list can be preset in the encoder and decoder. As an example, the number of MPMs can be 3, 4, 5, or 6. Alternatively, information indicating the number of MPMs can be signaled through the bitstream. Alternatively, the number of MPMs can be determined based on at least one of the predictive coding modes of adjacent blocks, the size and shape of the current block, or the reference sample line index. As an example, if an adjacent reference sample line is determined to be the reference sample line of the current block, N MPMs can be used; conversely, if a non-adjacent reference sample line is determined to be the reference sample line of the current block, M MPMs can be used. M is a natural number less than N; as an example, N is 6, and M can be 5, 4, or 3. Therefore, if the index of the reference sample line of the current block is 0 and the MPM flag is true, the intra-prediction mode of the current block can be determined as one of 6 candidate intra-prediction modes; conversely, if the index of the reference sample line of the current block is greater than 0 and the MPM flag is true, the intra-prediction mode of the current block can be determined as one of 5 candidate intra-prediction modes.

[0189] Alternatively, a fixed number (e.g., 6 or 5) of MPM candidates can be used regardless of the reference sample line index of the current block.

[0190] In the embodiments described later, it is assumed that there are 6 MPMs, which are referred to as MPM[0], MPM[1], MPM[2], MPM[3], MPM[4], and MPM[5]. Embodiments with fewer than 6 MPMs may be implemented using only a portion of the 6 MPMs described in the embodiments described later. Alternatively, embodiments with more than 6 MPMs may include the 6 MPMs described in the subsequent embodiments.

[0191] The initial value of MPM can be set to different non-angular intra-prediction modes or angular intra-prediction modes of candIntraPredModeA. Specifically, the angular intra-prediction mode of MPM can include at least one of the following: vertical intra-prediction mode, horizontal intra-prediction mode, lower left diagonal intra-prediction mode, upper left diagonal intra-prediction mode, or upper right diagonal intra-prediction mode. As an example, the initial value of MPM can be set as follows.

[0192] MPM[0] = candIntraPredModeA

[0193] MPM[1]=(candIntraPredModeA==INTRA_PLANAR)? INTRA_DC:INTRA_PLANAR

[0194] MPM[2] = INTRA_ANGULAR50

[0195] MPM[3] = INTRA_ANGULAR18

[0196] MPM[4] = INTRA_ANGULAR2

[0197] MPM[5] = INTRA_ANGULAR34

[0198] In the example above, ((A)?B:C) represents a function that returns the value of B when the condition recorded in A is true, and returns the value of C when the condition recorded in A is false.

[0199] When candIntraPredModeA and candIntraPredModeB are the same, and candIntraPredModeA is an angular intra-prediction mode, MPM[0] can be set to candIntraPredModeA, and an intra-prediction mode similar to candIntraPredModeA can be set to MPM. An intra-prediction mode similar to candIntraPredModeA can be an intra-prediction mode with an index difference of ±1 or ±2 from candIntraPredModeA. To obtain an intra-prediction mode similar to candIntraPredModeA, modulo operation (%) and offset can be used. In addition, at least one of a non-angular intra-prediction mode or an intra-prediction mode with an angular difference of a predefined value from candIntraPredModeA can be set to MPM. Among them, an intra-prediction mode with an angular difference of a predefined value from candIntraPredModeA can be an intra-prediction mode perpendicular to candIntraPredModeA or an intra-prediction mode in the opposite direction to candIntraPredModeA. As an example, MPM can be obtained as follows.

[0200] MPM[0] = candIntraPredModeA

[0201] MPM[1] = INTRA_PLANAR

[0202] MPM[2] = INTRA_DC

[0203] MPM[3]=2+((candIntraPredModeA+62)%65)

[0204] MPM[4]=2+((candIntraPredModeA-1)%65)

[0205] MPM[5]=2+((candIntraPredModeA+94)%65)

[0206] MPM[3] corresponds to (candIntraPredModeA-1), and MPM[4] corresponds to (candIntraPredModeA+1). MPM[5] represents the intra-prediction mode perpendicular to candIntraPredModeA.

[0207] When candIntraPredModeA and candIntraPredModeB are different, candIntraPredModeA and candIntraPredModeB can be set to MPM[0] and MPM[1] respectively. Alternatively, candIntraPredA and candIntraPredModeB can be compared, and the maximum value can be set to MPM[0] and the minimum value can be set to MPM[1]. Conversely, the minimum value can be set to MPM[0] and the maximum value can be set to MPM[1].

[0208] At this time, when both candIntraPredModeA and candIntraPredModeB are angular intra-prediction modes, the non-angular intra-prediction mode can be set to MPM. As an example, planner and DC can be set to MPM[2] and MPM[3] respectively.

[0209] Alternatively, an intra-prediction mode similar to the case where the value in candIntraPredModeA and candIntraPredModeB is at its maximum or minimum can be set to MPM. An intra-prediction mode similar to candIntraPredModeX can be obtained by adding or subtracting an offset from candIntraPredModeX. In this case, the maximum size of the offset can be determined based on the difference between the maximum and minimum values ​​in candIntraPredModeA and candIntraPredModeB. As an example, the offset can be a natural number such as 1 or 2.

[0210] As an example, when the difference between MAX(candIntraPredModeA, candIntraPredModeB) and MIN(candIntraPredModeA, candIntraPredModeB) is not 64 or 1, MPM[4] and MPM[5] can be obtained by the following formula.

[0211] MPM[4]=2+((MAX(MPM[0],MPM[1])+62)%65

[0212] MPM[5]=2+((MAX(MPM[0],MPM[1])-1)%65

[0213] Among them, the MAX(A,B) function returns the larger of A and B, and the MIN(A,B) function returns the smaller of A and B. MPM[4] corresponds to (MAX(MPM[0], MPM[1])-1), and MPM[5] corresponds to (MAX(MPM[0], MPM[1])+1). Conversely, when the difference between MIN(candIntraPredModeA, candIntraPredModeB) and MAX(candIntraPredModeA, candIntraPredModeB) is 64 or 1, MPM[4] and MPM[5] can be obtained as follows.

[0214] MPM[4]=2+((MAX(MPM[0],MPM[1])+61)%65

[0215] MPM[5]=2+(MAX(MPM[0],MPM[1])%65

[0216] MPM[4] corresponds to (MAX(MPM[0],MPM[1])-2), and MPM[5] corresponds to (MAX(MPM[0],MPM[1])+2).

[0217] When one of candIntraPredModeA and candIntraPredModeB is an angular intra-prediction mode and the other is a non-angular intra-prediction mode, at least one of the following can be set to MPM: a non-angular intra-prediction mode that is different from MIN(candIntraPredModeA, candIntraPredModeB), an angular intra-prediction mode that is close to MAX(candIntraPredModeA, candIntraPredModeB), or an intra-prediction mode whose angular difference from MAX(candIntraPredModeA, candIntraPredModeB) is a predefined value. As an example, MPM[2] to MPM[5] can be obtained as follows.

[0218] MPM[2]=! MIN(MPM[0],MPM[1])

[0219] MPM[3]=2+((MAX(MPM[0],MPM[1])+62)%65

[0220] MPM[4]=2+((MAX(MPM[0],MPM[1])-1)%65

[0221] MPM[5]=2+((MAX(MPM[0],MPM[1])+94)%65

[0222] MPM[2] represents a non-angular intra-prediction mode that is different from MPM[0] or MPM[1]. For example, when MIN(MPM[0], MPM[1]) is DC, MPM[2] is set as the planner, and when MIN(MPM[0], MPM[1]) is the planner, MPM[2] is set as DC. MPM[3] corresponds to ((MAX(MPM[0], MPM[1])-1), and MPM[4] corresponds to (MAX(MPM[0], MPM[1])+1). MPM[5] represents an intra-prediction mode that is perpendicular to (MAX(MPM[0], MPM[1]). Unlike the examples listed above, MPM obtained by adding or subtracting 2 from (MAX(MPM[0], MPM[1]) can also be added to the MPM list.

[0223] When one of candIntraPredA and candIntraPredB is a non-angular intra-frame mode and the other is an angular intra-frame prediction mode, that is, when one of candIntraPredA and PredIntraPredB is less than 2 and the other is greater than or equal to 2, the maximum value of candIntraPredA and candIntraPredB can be set to MPM. In addition, an intra-frame prediction mode similar to the maximum value or an intra-frame prediction mode perpendicular to the maximum value can be set to MPM. As an example, MPM[0] to MPM[5] can be obtained as follows.

[0224] MPM[0]=MAX(candIntraPredA, candIntraPredB)

[0225] MPM[1] = INTRA_PLANAR

[0226] MPM[2] = INTRA_DC

[0227] MPM[3]=2+((MAX(candIntraPredA, candIntraPredB)+62)%65

[0228] MPM[4]=2+((MAX(candIntraPredA, candIntraPredB])-1)%65

[0229] MPM[5]=2+((MAX(candIntraPredA, candIntraPredB)+94)%65

[0230] MPM[3] corresponds to ((MAX(candIntraPredA, candIntraPredB)-1), and MPM[4] corresponds to (MAX(candIntraPredA, candIntraPredB)+1). MPM[5] represents the intra-prediction mode perpendicular to (MAX(candIntraPredA, candIntraPredB). Unlike the examples listed above, MPM obtained by adding or subtracting 2 from (MAX(candIntraPredA, candIntraPredB)) can also be added to the MPM list.

[0231] The MPM can be obtained based on the index of the reference sample line of the current block. Specifically, when a non-adjacent reference sample line is determined to be the reference sample line of the current block, non-angular prediction modes such as the planner or DC may not be set to MPM. As an example, the initial value of MPM can be set based on whether an adjacent reference sample line is determined to be the reference sample line of the current block, as follows.

[0232] MPM[0]=(IntraLumaRefLineIdx==0)? candIntraPredModeA:INTRA_ANGULAR2

[0233] MPM[1]=(IntraLumaRefLineIdx==0)? (candIntraPredModeA:==INTRA_PLANAR?INTRA_DC:INTRA_PLANAR):INTRA_ANGULAR18

[0234] MPM[2] = INTRA_ANGULAR50

[0235] MPM[3]=(IntraLumaRefLineIdx==0)? INTRA_ANGULAR18:INTRA_ANGULAR34

[0236] MPM[4]=(IntraLumaRefLineIdx==0)? INTRA_ANGULAR2:INTRA_ANGULAR66

[0237] MPM[5]=(IntraLumaRefLineIdx==0)? INTRA_ANGULAR34:INTRA_ANGULAR42

[0238] If the reference sample line of the current block is a non-adjacent reference sample line, and both candIntraPredModeA and candIntraPredModeB are angular intra-frame prediction modes, the MPM can be obtained as follows.

[0239] MPM[0] = candIntraPredModeA

[0240] MPM[1] = candIntraPredModeB

[0241] MPM[2] = INTRA_ANGULAR2

[0242] MPM[3] = INTRA_ANGULAR18

[0243] MPM[4] = INTRA_ANGULAR50

[0244] MPM[5] = INTRA_ANGULAR34

[0245] If the reference sample line of the current block is a non-adjacent reference sample line, and one of candIntraPredModeA and candIntraPredModeB is a non-angular intra-prediction mode and the other is an angular intra-prediction mode, the MPM can be obtained as follows.

[0246] MPM[0]=MAX(candIntraPredModeA, candIntraPredModeB)

[0247] MPM[1] = INTRA_ANGULAR2

[0248] MPM[2] = INTRA_ANGULAR18

[0249] MPM[3] = INTRA_ANGULAR50

[0250] MPM[4] = INTRA_ANGULAR34

[0251] MPM[5] = INTRA_ANGULAR66

[0252] After generating an MPM list containing multiple MPMs, information indicating whether an MPM with the same intra-prediction mode as the current block is included in the MPM list can be transmitted via the bitstream. This information is a 1-bit identifier, referred to as the MPM identifier. When the MPM identifier indicates that an MPM with the same intra-prediction mode as the current block is included in the MPM list, the index information of an MPM can be transmitted via the bitstream. As an example, specific index information `mpm_idx` for one of the multiple MPMs can be transmitted via the bitstream. The specific MPM identified by this index information can be set as the intra-prediction mode for the current block. When the MPM identifier indicates that an MPM with the same intra-prediction mode as the current block is not included in the MPM list, other mode information indicating one of the other intra-prediction modes besides the MPM can be transmitted via the bitstream. When re-indexing other intra-prediction modes besides the MPM, the other mode information indicates the index value corresponding to the intra-prediction mode of the current block. The decoder can sort the MPMs in ascending order, compare the other mode information with the MPMs, and determine the intra-prediction mode of the current block. As an example, when other mode information is equal to or less than MPM, the intra-prediction mode of the current block can be obtained by adding 1 to the other mode information.

[0253] When the intra-prediction mode of the current block is obtained, comparisons between some MPMs and other mode information can be skipped. As an example, MPMs that are non-angular intra-prediction modes can be excluded from the comparison. When a non-angular intra-prediction mode is set as an MPM, the other mode information explicitly indicates an angular intra-prediction mode; therefore, the intra-prediction mode of the current block can be obtained by comparing other MPMs (excluding angular intra-prediction modes) with other mode information. Alternatively, instead of excluding non-angular intra-prediction modes, the number of non-angular intra-prediction modes can be added to the other mode information, and the resulting value can be compared with other MPMs.

[0254] Instead of setting the default mode to MPM, information indicating whether the intra-prediction mode of the current block is the default mode can be transmitted via the bitstream. This information is a 1-bit identifier, which can be called the default mode identifier. The default mode identifier can only be transmitted when the MPM identifier indicates that the same MPM as the current block is included in the MPM list. As mentioned above, the default mode can include at least one of planner, DC, vertical mode, or horizontal mode. As an example, when planner is set as the default mode, the default mode identifier can indicate whether the intra-prediction mode of the current block is planner. When the default mode identifier indicates that the intra-prediction mode of the current block is not the default mode, one of the multiple MPMs indicated by the index information can be set as the intra-prediction mode of the current block.

[0255] When using the default mode identifier, the intra prediction mode that is the same as the default mode does not need to be set as MPM. As an example, when the default mode identifier indicates whether the intra prediction mode of the current block is planner, the MPM corresponding to planner among the above 6 MPMs can be replaced with another mode, or the intra prediction mode of the current block can be obtained by using the 5 MPMs other than the MPM corresponding to planner.

[0256] When multiple intra-prediction modes are set to the default mode, index information indicating one of the default modes can also be passed. The intra-prediction mode of the current block can be set to the default mode indicated by the index information.

[0257] If the index of the reference sample line in the current block is not 0, the default mode can be set not to be used. As an example, when a non-adjacent reference sample line is determined to be the reference sample line of the current block, it can be set not to use non-angular intra-prediction modes such as DC mode or planner mode. Therefore, if the index of the reference sample line is not 0, the default mode identifier can be set to a predefined value (i.e., pseudo) instead of being passed.

[0258] Once the intra-prediction mode of the current block is determined, prediction samples for the current block can be obtained based on the determined intra-prediction mode (S803).

[0259] When DC mode is selected, predicted samples for the current block can be generated based on the average value of reference samples. Specifically, the values ​​of all samples within the predicted block can be generated based on the average value of the reference samples. The average value can be obtained using at least one of the upper reference sample located above the current block and the left reference sample located to the left of the current block.

[0260] The number or range of reference samples used to calculate the average value will vary depending on the shape of the current block. For example, if the current block is a non-square block with a width greater than its height, the average value can be calculated using only the top reference sample. Conversely, if the current block is a non-square block with a width less than its height, the average value can be calculated using only the left reference sample. That is, if the width and height of the current block are different, the average value can be calculated using only the reference sample adjacent to the longer side. Alternatively, the ratio of the current block's width to its height can be used to determine whether to use only the top or only the left reference sample to calculate the average value.

[0261] When the planner mode is selected, prediction samples can be obtained using horizontal and vertical prediction samples. Horizontal prediction samples are obtained based on left and right reference samples located on the same horizontal line as the prediction sample. Vertical prediction samples are obtained based on upper and lower reference samples located on the same vertical line as the prediction sample. The right reference sample can be generated by copying the reference sample adjacent to the upper right corner of the current block, and the lower reference sample can be generated by copying the reference sample adjacent to the lower left corner of the current block. Horizontal prediction samples can be obtained based on the weighted sum of the left and right reference samples, and vertical prediction samples can be obtained based on the weighted sum of the upper and lower reference samples. The weighted values ​​of each reference sample are determined based on the position of the prediction sample. Prediction samples can also be obtained based on the average or weighted sum of the horizontal and vertical prediction samples. When performing a weighted sum operation, the weighted values ​​of the horizontal and vertical prediction samples are determined based on their positions.

[0262] When an angle prediction mode is selected, the parameters used to represent the prediction direction (or prediction angle) of the selected angle prediction mode can be determined. Table 2 below shows the intra-predAng parameter for each intra-prediction mode.

[0263] Table 2

[0264]

[0265] Table 2 shows the intra-direction parameters for each intra-prediction mode with an index from 2 to 34 when 35 intra-prediction modes are defined. When more than 33 intra-prediction modes with different angles are defined, Table 2 can be further refined to set the intra-direction parameters for each intra-prediction mode with different angles.

[0266] After arranging the top and left reference samples of the current block in a single column, prediction samples can be obtained based on the values ​​of the intra-frame orientation parameters. In this case, when the value of the intra-frame orientation parameter is negative, the left and top reference samples can be arranged in a single column.

[0267] Figure 11 and Figure 12 This is a schematic diagram illustrating an example of a one-dimensional arrangement of reference samples in a column.

[0268] Figure 11 This illustrates an example of a one-dimensional vertical arrangement of reference samples. Figure 12 An example of a one-dimensional horizontal arrangement of reference samples is shown. Assuming 35 intra-frame prediction modes are defined, for... Figure 11 and Figure 12 The embodiments are described below.

[0269] When the intra-prediction mode index is one of 11 to 18, a one-dimensional horizontal arrangement with the upper reference sample rotated counterclockwise can be applied. When the intra-prediction mode index is one of 19 to 25, a one-dimensional vertical arrangement with the left reference sample rotated clockwise can be applied. The reference samples can be arranged in a column according to the angle of the intra-prediction mode.

[0270] Reference sample determination parameters can be determined based on intra-frame orientation parameters. These parameters may include specific reference sample indexing for the reference samples and weighting parameters for determining the weights applied within the reference samples.

[0271] The reference sample index iIdx and the weighted parameter ifact can be obtained through formulas 4 and 5 below, respectively.

[0272] [Formula 4]

[0273] iIdx=(y+1)*P ang / 32

[0274] [Formula 5]

[0275] i fact =[(y+1)*P ang ]&31

[0276] In formulas 4 and 5, P ang This represents the intra-frame orientation parameter. A specific reference sample corresponds to an integer pixel (pel) based on the reference sample index iIdx.

[0277] To obtain the predicted sample, at least one reference sample can be specified. Specifically, the position of the reference sample used when obtaining the predicted sample can be specified, taking into account the slope of the prediction pattern. As an example, the reference sample index iIdx can be used to specify the reference sample used when obtaining the predicted sample.

[0278] In this case, when the slope of the intra-prediction mode is not represented by a single reference sample, multiple reference samples can be interpolated to generate a prediction sample. As an example, when the slope of the intra-prediction mode is a value between the slope between the prediction sample and the first reference sample, and between the slope between the prediction sample and the second reference sample, the first and second reference samples can be interpolated to obtain the prediction sample. That is, when the angular line based on the intra-prediction angle does not pass through a reference sample located at an integer pixel, reference samples located to the left, right, or top and bottom adjacent to the position through which the angular line passes can be interpolated to obtain the prediction sample.

[0279] Formula 6 below shows an example of obtaining a predicted sample based on a reference sample.

[0280] [Formula 6]

[0281] P(x,y)=((32-i fact ) / 32)*Ref_1D(x+iIdx+1)+(i fact / 32)*Ref_1D(x+iIdx+2)

[0282] In Equation 6, P represents the predicted sample, and Ref_1D represents one of the reference samples arranged in a one-dimensional array. The position of the reference sample can then be determined based on the position (x, y) of the predicted sample and the reference sample index iIdx.

[0283] When the slope of the intra-frame prediction mode can be represented by a reference sample, the weighting parameter i fact Set it to 0. Therefore, Equation 6 can be simplified as shown in Equation 7 below.

[0284] [Formula 7]

[0285] P(x,y)=Ref_1D(x+iIdx+1)

[0286] Intra-prediction of the current block can also be performed based on multiple intra-prediction modes. As an example, intra-prediction modes can be obtained according to the prediction samples, and prediction samples can be obtained based on the intra-prediction modes assigned to each prediction sample.

[0287] Alternatively, intra-prediction modes can be obtained according to regions, and intra-prediction for each region can be performed based on the intra-prediction modes assigned to each region. Each region may include at least one sample. At least one of the size or shape of the region can be adaptively determined based on at least one of the size, shape, or intra-prediction mode of the current block. Alternatively, at least one of the size or shape of the region can be predefined in the encoder and decoder, independent of the size or shape of the current block.

[0288] Alternatively, intra-prediction can be performed based on multiple intra-prediction methods, and the final prediction sample can be obtained by averaging or weighting the multiple prediction samples obtained through multiple intra-prediction methods. As an example, intra-prediction can be performed based on a first intra-prediction mode to obtain a first prediction sample, and intra-prediction can be performed based on a second intra-prediction mode to obtain a second prediction sample. Then, the final prediction sample can be obtained by averaging or weighting the first and second prediction samples. In this case, the weights assigned to the first and second prediction samples can be determined based on at least one of whether the first intra-prediction mode is a non-angular or angular prediction mode, whether the second intra-prediction mode is a non-angular or angular prediction mode, or the intra-prediction modes of adjacent blocks.

[0289] Multiple intra-frame prediction modes can be combinations of non-angle intra-frame prediction modes and angle prediction modes, combinations of angle prediction modes, or combinations of non-angle prediction modes.

[0290] Figure 13 This is an exemplary illustration of the angle formed by the intra-frame prediction mode of the angle and a straight line parallel to the X-axis.

[0291] like Figure 13 As shown, the angle prediction pattern can exist between the lower left diagonal direction and the upper right diagonal direction. If we use the angle formed by the x-axis and the angle prediction pattern, the angle prediction pattern can exist between 45 degrees (lower left diagonal direction) and -135 degrees (upper right diagonal direction).

[0292] If the current block is not square, depending on the intra-prediction mode of the current block, the reference sample that is closer to the prediction sample among the reference samples located on the corner of the intra-prediction angle will be used instead to obtain the prediction sample.

[0293] Figure 14 This is a schematic diagram illustrating the shape obtained by predicting a sample when the current block is not a square.

[0294] As an example, such as Figure 14 As shown in (a), assuming the current block is a non-square with a width greater than its height, and the intra-frame prediction mode of the current block is an angular intra-frame prediction mode with an angle between 0 and 45 degrees. In the above case, when a predicted sample A near the right column of the current block is obtained, a situation occurs in which the reference sample located in the angular mode of the angle does not utilize the upper reference sample T which is closer to the predicted sample, but instead utilizes the left reference sample L which is farther from the predicted sample.

[0295] As another example, such as Figure 14As shown in (b), assuming the current block is a non-square with a height greater than its width, and the intra-frame prediction mode of the current block is an angular intra-frame prediction mode between -90 degrees and -135 degrees. In the above case, when a prediction sample A near the lower row of the current block is obtained, a situation occurs in which, in the reference sample located on the angular mode according to the angle, the upper reference sample T, which is farther from the prediction sample, replaces the left reference sample L, which is closer to the prediction sample.

[0296] To eliminate the problem described above, if the current block is not square, the intra-prediction mode of the current block can be replaced with an intra-prediction mode in the opposite direction. Therefore, for non-square blocks, a mode with a higher frequency of prediction can be used. Figure 10 The angle prediction modes shown are for angles larger or smaller than the predicted angles. This type of intra-frame prediction mode can be defined as a wide-angle intra-frame prediction mode. A wide-angle intra-frame prediction mode refers to an intra-frame prediction mode for angles not falling within the range of 45 degrees to -135 degrees.

[0297] Figure 15 This is a schematic diagram of the wide-angle intra-frame prediction mode.

[0298] exist Figure 15 In the example shown, the intra-prediction modes with indices of -1 to -14 and the intra-prediction modes with indices of 67 to 80 represent the wide-angle intra-prediction modes.

[0299] exist Figure 15 The illustrations show 14 wide-angle intra-frame prediction modes (-1 to -14) with angles greater than 45 degrees and 14 wide-angle intra-frame prediction modes (67 to 80) with angles less than -135 degrees, but more or fewer wide-angle intra-frame prediction modes can also be defined.

[0300] When using the wide-angle intra-frame prediction mode, the length of the upper reference sample can be set to 2W+1, and the length of the left reference sample can be set to 2H+1.

[0301] With the use of wide-angle intra-frame prediction mode Figure 14 (a) The sample A shown can be predicted using the reference sample T. Figure 14 The sample A shown in (b) can be predicted using the reference sample L.

[0302] Including the existing intra-prediction mode and N wide-angle intra-prediction modes, a total of 67+N intra-prediction modes can be used. As an example, Table 3 shows the intra-prediction mode intra-direction parameters when 20 wide-angle intra-prediction modes are defined.

[0303] Table 3

[0304] PredModeIntra -10 -9 -8 -7 -6 -5 -4 -3 -2 intraPredAngle 114 93 79 68 60 54 49 45 39 PredModeIntra -1 2 3 4 5 6 7 8 9 intraPredAngle 35 32 29 26 23 21 19 17 15 PredModeIntra 10 11 12 13 14 15 16 17 18 intraPredAngle 13 11 9 7 5 3 2 1 0 PredModeIntra 19 20 21 22 23 24 25 26 27 intraPredAngle -1 -2 -3 -5 -7 -9 -11 -13 -15 PredModeIntra 28 29 30 31 32 33 34 35 36 intraPredAngle -17 -19 -21 -23 -26 -29 -32 -29 -26 PredModeIntra 37 38 39 40 41 42 43 44 45 intraPredAngle -23 -21 -19 -17 -15 -13 -11 -9 -7 PredModeIntra 46 47 48 49 50 51 52 53 54 intraPredAngle -5 -3 -2 -1 0 1 2 3 5 PredModeIntra 55 56 57 58 59 60 61 62 63 intraPredAngle 7 9 11 13 15 17 19 21 23 PredModeIntra 64 65 66 67 68 69 70 71 72 intraPredAngle 26 29 32 35 39 45 49 54 60 PredModeIntra 73 74 75 76 intraPredAngle 68 79 93 114

[0305] If the current block is not square and the intra-prediction mode of the current block obtained in step S802 falls within the transformation range, the intra-prediction mode of the current block can be transformed into a wide-angle intra-prediction mode. The transformation range can be determined based on at least one of the current block's size, shape, or ratio. The ratio can represent the ratio between the width and height of the current block.

[0306] If the current block is a non-square with a width greater than its height, the transformation range can be set from the index of the intra-prediction mode in the upper right diagonal direction (e.g., 66) to the index of the intra-prediction mode in the upper right diagonal direction (e.g., -N). Here, N can be determined based on the ratio of the current block. If the intra-prediction mode of the current block falls within the transformation range, the intra-prediction mode can be transformed into a wide-angle intra-prediction mode. This transformation can be achieved by subtracting a predefined value from the intra-prediction mode; the predefined value can be the total number of intra-prediction modes other than the wide-angle intra-prediction mode (e.g., 67).

[0307] According to the embodiment, the intra-frame prediction modes between 66 and 53 can be transformed into wide-angle intra-frame prediction modes between -1 and -14, respectively.

[0308] If the current block is a non-square with a height greater than its width, the transformation range can be set from the index of the intra-prediction mode in the lower left diagonal direction (e.g., 2) to the index of the intra-prediction mode in the lower left diagonal direction (e.g., +M). Here, M can be determined based on the ratio of the current block. If the intra-prediction mode of the current block falls within the transformation range, the intra-prediction mode can be transformed into a wide-angle intra-prediction mode. This transformation can be achieved by adding a predefined value to the intra-prediction mode; the predefined value can be the total number of angular intra-prediction modes other than the wide-angle intra-prediction mode (e.g., 65).

[0309] According to the embodiment, the intra-frame prediction modes between No. 2 and No. 15 can be transformed into wide-angle intra-frame prediction modes between No. 67 and No. 80, respectively.

[0310] The intra-prediction modes that fall within the transform range will be referred to as alternative wide-angle intra-prediction modes.

[0311] The transform range can be determined based on the ratio of the current block. As an example, Tables 4 and 5 show the transform range when 35 intra-prediction modes are defined in addition to the wide-angle intra-prediction mode and when 67 intra-prediction modes are defined, respectively.

[0312] Table 4

[0313] condition Alternative intra-frame prediction mode W / H = 2 Modes 2, 3, and 4 W / H > 2 Patterns 2, 3, 4, 5, 6 W / H = 1 none H / W = 1 / 2 Patterns 32, 33, and 34 H / W < 1 / 2 Patterns 30, 31, 32, 33, 34

[0314] Table 5

[0315] condition Alternative intra-frame prediction mode W / H = 2 Patterns 2, 3, 4, 5, 6, 7 W / H > 2 Patterns 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 W / H = 1 none H / W = 1 / 2 Patterns 61, 62, 63, 64, 65, 66 H / W < 1 / 2 Patterns 57, 58, 59, 60, 61, 62, 63, 64, 65, 66

[0316] As shown in Tables 4 and 5, the number of alternative wide-angle intra-prediction modes included in the transform range varies depending on the ratio of the current block.

[0317] The ratio of the current block can also be further refined, as shown in Table 6 below, to set the transformation range.

[0318] Table 6

[0319] condition Alternative intra-frame prediction mode W / H = 16 Patterns 12, 13, 14, and 15 W / H = 8 Modes 12 and 13 W / H = 4 Patterns 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 H / W = 2 Patterns 2, 3, 4, 5, 6, 7 H / W = 1 none W / H = 1 / 2 Patterns 61, 62, 63, 64, 65, 66 W / H = 1 / 4 Patterns 57, 58, 59, 60, 61, 62, 63, 64, 65, 66 W / H = 1 / 8 Patterns 55 and 56 H / W = 1 / 16 Patterns 53, 54, 55, 56

[0320] In cases where non-adjacent reference sample lines are determined as the reference sample lines for the current block, or in cases where multi-reference line intra-frame prediction is performed by selecting one of multiple reference sample lines, the wide-angle intra-frame prediction mode can be set not to be used. That is, even if the current block is not square and the intra-frame prediction mode of the current block is within the transform range, the intra-frame prediction mode of the current block may not be transformed into the wide-angle intra-frame prediction mode.

[0321] Alternatively, if the intra-prediction mode for the current block is determined to be wide-angle intra-prediction mode, it can be set to prevent non-adjacent reference sample lines from being used as reference sample lines for the current block, or it can be set to not use multi-reference line intra-prediction, which selects one of multiple reference sample lines. When multi-reference line intra-prediction is not used, adjacent reference sample lines can be determined as reference sample lines for the current block.

[0322] When wide-angle intra-frame prediction mode is not used, refW and refH can be set to the sum of nTbW and nTbH. Therefore, in addition to the upper left reference sample, the non-adjacent reference samples at a distance i from the current block can include (nTbW + nTbH + offsetX[i]) upper reference samples and (nTbW + nTbH + offsetY[i]) left reference samples. That is, the non-adjacent reference samples at a distance i from the current block can include (2nTbW + 2nTbH + offsetX[i] + offsetY[i] + 1) reference samples. For example, when the value of whRatio is greater than 1, the value of offsetX can be set to be greater than the value of offsetY. As an example, the value of offsetX can be set to 1 and the value of offsetY can be set to 0. Conversely, when the value of whRatio is less than 1, the value of offsetY can be set to be greater than the value of offsetX. As an example, the value of offsetX can be set to 0 and the value of offsetY can be set to 1.

[0323] As a wide-angle intra prediction mode is added to the existing intra prediction mode, the resources required for encoding the wide-angle intra prediction mode increase, and the coding efficiency decreases. Therefore, instead of directly encoding the wide-angle intra prediction mode, an alternative intra prediction mode can be encoded to improve coding efficiency.

[0324] As an example, if the current block is encoded using wide-angle intra prediction mode 67, then intra prediction mode 2, which replaces wide-angle intra prediction mode 67, can be used as the intra prediction mode for the current block. Conversely, if the current block is encoded using wide-angle intra prediction mode -1, then intra prediction mode 66, which replaces wide-angle intra prediction mode -1, can be used as the intra prediction mode for the current block.

[0325] The decoder can decode the intra-prediction mode of the current block and determine whether the decoded intra-prediction mode is included in the transform range. When the decoded intra-prediction mode is an intra-prediction mode replaced by a wide-angle intra-prediction mode, the intra-prediction mode can be transformed into a wide-angle intra-prediction mode.

[0326] Alternatively, if the current block is encoded in wide-angle intra-prediction mode, it can be encoded directly in wide-angle intra-prediction mode.

[0327] Encoding of the intra-prediction mode can be implemented based on the aforementioned MPM list. Specifically, when adjacent blocks are encoded in the wide-angle intra-prediction mode, the MPM can be set based on the intra-prediction mode that replaces the wide-angle intra-prediction mode. As an example, when adjacent blocks are encoded in the wide-angle intra-prediction mode, the parameter candIntraPredModeX (where X is A or B) can be set to the intra-prediction mode that replaces the wide-angle intra-prediction mode.

[0328] Alternatively, the MPM can be set based on the wide-angle intra-prediction mode of adjacent blocks. As an example, when adjacent blocks are encoded in wide-angle intra-prediction mode, the parameter candIntraPredModeX can be set to wide-angle intra-prediction mode.

[0329] The MPM can also be obtained based on whether the reference sample line of the current block is a non-adjacent reference sample line or whether multi-reference line intra-prediction, which selects one of multiple reference sample lines, is applied. As an example, if the reference sample line of the current block is a non-adjacent reference sample line, and the intra-prediction mode of the adjacent block is wide-angle intra-prediction mode, the default mode can be set to the MPM of the current block.

[0330] As an example, when candIntraPredModeA, obtained based on the intra-prediction mode of the left adjacent block, is the same as candIntraPredModeB, obtained based on the intra-prediction mode of the upper adjacent block, and candIntraPredModeA is planner or DC, the MPM can be obtained as follows, depending on whether the index of the reference sample line of the current block is 0.

[0331] MPM[0]=(IntraLumaRefLineIdx==0)? Intra_Planar:INTRA_ANGULAR 50

[0332] MPM[1]=(IntraLumaRefLineIdx==0)? Intra_DC:INTRA_ANGULAR 18

[0333] MPM[2] = INTRA_ANGULAR 2

[0334] That is, when the index of the reference sample line of the current block is 0, the planner mode and DC mode are set to MPM. Conversely, when the index of the reference sample line of the current block is not 0, the vertical intra-prediction mode (INTRA_ANGULAR 50) and the horizontal intra-prediction mode (INTRA_ANGULAR 18) can be set to MPM.

[0335] If the index of the reference sample line of the current block is not 0, and candIntraPredModeA is the same as candIntraPredModeB or candIntraPredModeA is a wide-angle intra-prediction mode, the MPM can be obtained as follows.

[0336] MPM[0] = INTRA_ANGULAR2

[0337] MPM[1] = INTRA_ANGULAR18

[0338] MPM[2] = INTRA_ANGULAR50

[0339] Alternatively, MPM can be obtained as follows.

[0340] MPM[0] = INTRA_ANGULAR50

[0341] MPM[1] = INTRA_ANGULAR18

[0342] MPM[2] = INTRA_ANGULAR2

[0343] That is, if the reference sample line index of the current block is not 0, the wide-angle intra-frame prediction mode does not need to be set to MPM.

[0344] When candIntraPredModeA and candIntraPredModeB are the same, and candIntraPredModeA is the angle intra-frame prediction mode, the MPM can be obtained as follows.

[0345] MPM[0] = candIntraPredModeA

[0346] MPM[1]=2+((candIntraPredModeA+61)%64)

[0347] MPM[2]=2+((candIntraPredModeA-1)%64)

[0348] If the index of the reference sample line of the current block is 0, and candIntraPredModeA and candIntraPredModeB are different, MPM[0] and MPM[1] can be set to candIntraPredModeA and candIntraPredModeB respectively. MPM[2] can be set to a different value from MPM[0] and MPM[1] in planner, DC and vertical direction modes.

[0349] If the index of the reference sample line of the current block is not 0, and one of candIntraPredModeA and candIntraPredModeB is a planner while the other is a DC, the MPM can be obtained as follows.

[0350] MPM[0] = INTRA_ANGULAR2

[0351] MPM[1] = INTRA_ANGULAR18

[0352] MPM[2] = INTRA_ANGULAR50

[0353] If the index of the reference sample line of the current block is not 0, and both candIntraPredModeA and candIntraPredModeB are wide-angle intra-prediction modes, the MPM can be obtained as follows.

[0354] MPM[0] = INTRA_ANGULAR2

[0355] MPM[1] = INTRA_ANGULAR18

[0356] MPM[2] = INTRA_ANGULAR50

[0357] If the index of the reference sample line of the current block is not 0, and one of candIntraPredModeA and candIntraPredModeB is a wide-angle intra-prediction mode, the non-wide-angle intra-prediction mode of candIntraPredModeA and candIntraPredModeB can be set to MPM[0], and intra-prediction modes similar to MPM[0] can be set to MPM[1] and MPM[2]. As an example, when candIntraPredModeA is a non-wide-angle intra-prediction mode and candIntraPredModeB is a wide-angle intra-prediction mode, MPM can be obtained as follows.

[0358] MPM[0] = candIntraPredModeA

[0359] MPM[1]=2+((candIntraPredModeA+61)%64)

[0360] MPM[2]=2+((candIntraPredModeA-1)%64)

[0361] Conversely, when candIntraPredModeA is the wide-angle intra-prediction mode and candIntraPredModeB is the non-wide-angle intra-prediction mode, the MPM can be obtained as follows.

[0362] MPM[0] = candIntraPredModeB

[0363] MPM[1]=2+((candIntraPredModeB+61)%64)

[0364] MPM[2]=2+((candIntraPredModeB-1)%64)

[0365] If the index of the reference sample line of the current block is not 0, and one of candIntraPredModeA and candIntraPredModeB is a planner or DC while the other is a non-wide-angle intra-prediction mode, the non-wide-angle intra-prediction mode of candIntraPredModeA and candIntraPredModeB can be set to MPM[0], and intra-prediction modes similar to MPM[0] can be set to MPM[1] and MPM[2]. As an example, when candIntraPredModeA is a non-wide-angle intra-prediction mode and candIntraPredModeB is a planner or DC, MPM can be obtained as follows.

[0366] MPM[0] = candIntraPredModeA

[0367] MPM[1]=2+((candIntraPredModeA+61)%64)

[0368] MPM[2]=2+((candIntraPredModeA-1)%64)

[0369] Conversely, when candIntraPredModeA is planner or DC and candIntraPredModeB is a non-wide-angle intra-prediction mode, the MPM can be obtained as follows.

[0370] MPM[0] = candIntraPredModeB

[0371] MPM[1]=2+((candIntraPredModeB+61)%64)

[0372] MPM[2]=2+((candIntraPredModeB-1)%64)

[0373] If the index of the reference sample line of the current block is not 0, and both candIntraPredModeA and candIntraPredModeB are non-wide-angle intra-prediction modes, candIntraPredModeA and candIntraPredModeB can be set to MPM[0] and MPM[1] respectively. One of the vertical intra-prediction modes (INTRA_ANGULAR50), horizontal intra-prediction modes (INTRA_ANGULAR18), or left lower diagonal intra-prediction modes (INTRA_ANGULAR2) that does not overlap with MPM[0] and MPM[1] can be set to MPM[2].

[0374] A coded block or transform block can be divided into multiple sub-blocks (or sub-partitions). When a coded block or transform block is divided into multiple sub-blocks, prediction, transform, and quantization can be performed on each sub-block. The case of dividing a coded block or transform block into multiple sub-blocks can be defined as the sub-partition intra-frame coding method.

[0375] Information indicating whether a subpartition intra-frame coding method is applied can be transmitted via the bitstream. This information can be a 1-bit identifier. As an example, the syntax element "intra_subpartitions_mode_flag," indicating whether a coded block or transform block is divided into multiple sub-blocks, can be transmitted via the bitstream.

[0376] Alternatively, the application of sub-partition intra-coding can be determined based on at least one of the size, shape, or intra-prediction mode of the coded block or transform block. As an example, sub-partition intra-coding may not be applied if the intra-prediction mode of the coded block is a non-angular intra-prediction mode (e.g., planner or DC) or a predefined angular intra-prediction mode (e.g., horizontal, vertical, or diagonal intra-prediction mode). Alternatively, sub-partition intra-coding may be disabled when the size of the coded block is less than a threshold.

[0377] Alternatively, when performing intra-block prediction on sub-blocks based on the intra-prediction mode of the coding block, the application of the sub-partition intra-coding method can be determined based on whether reconstructed samples contained in adjacent sub-blocks need to be used as reference samples during intra-block prediction. As an example, when the intra-prediction mode of the coding block is a diagonal intra-prediction mode or a wide-angle intra-prediction mode, and intra-block prediction is performed based on this mode, if adjacent sub-blocks cannot be used as reference samples, the sub-partition intra-coding method can be set not to be used.

[0378] Alternatively, when the height-to-width ratio of the coded block is above or below a threshold, sub-partition intra-coding can be disabled. Or, when at least one of the height or width of the coded block is below a threshold, sub-partition intra-coding can be disabled. As an example, when both the height and width of the coded block are below the threshold, sub-partition intra-coding can be disabled. The threshold can have predefined values ​​in the encoder and decoder. Alternatively, the information used to determine the threshold can be signaled through the bitstream.

[0379] Alternatively, it can be determined whether a flag indicating whether a sub-partition intra-coding method is applied can be transmitted based on at least one of the size, shape, or intra-prediction mode of the coded block or transform block. As an example, the flag indicating whether a sub-partition intra-coding method is applied can be encoded and transmitted only for cases where the height and width of the coded block are both below a threshold and / or the size of the coded block is above a threshold. When the flag indicating whether a sub-partition intra-coding method is applied is not encoded, the sub-partition intra-coding method may not be applied.

[0380] When applying the sub-partition intra-frame coding method, the partition shape of the coding block or transform block can be determined. The partition shape refers to the direction in which the coding block or transform block is partitioned. As an example, vertical partitioning means using at least one vertical line to partition the coding block or transform block, while horizontal partitioning means using at least one horizontal line to partition the coding block or transform block.

[0381] Figure 16 This is a schematic diagram illustrating an example of vertical and horizontal division.

[0382] Figure 16 (a) shows an example of a coded block being divided into two sub-blocks. Figure 16 (b) shows an example of a coded block being divided into 4 sub-blocks.

[0383] Information used to determine the partition shape of coded blocks and transform blocks can be transmitted via the bitstream. As an example, information indicating whether a coded block or transform block uses a vertical or horizontal partition can be transmitted via the bitstream. This information can be a 1-bit flag, `intra_subpart_type_flag`. A value of 1 indicates a horizontal partition, and a value of 0 indicates a vertical partition.

[0384] Alternatively, the partition shape of a coding block or transform block can be determined based on its size, shape, or intra-prediction mode. As an example, the partition shape of a coding block can be determined based on its width-to-height ratio. For instance, if the whRatio value (representing the width-to-height ratio of a coding block) is above a first threshold, a vertical partition can be applied to the coding block. Otherwise, a horizontal partition can be applied.

[0385] Figure 17 This is a schematic diagram illustrating an example of determining the shape of a coded block.

[0386] For ease of explanation, the first threshold is assumed to be 2. Figure 17In the example shown in (a), the whRatio of the coded block is 1, which is less than the first threshold. Therefore, the encoding of information representing the shape of the coded block can be skipped, and the coded block can be divided horizontally.

[0387] exist Figure 17 In the example shown in (b), the whRatio of the coded block is 2, which is the same as the first threshold. Therefore, the encoding of information representing the shape of the coded block can be skipped, and the coded block can be divided vertically.

[0388] The shape of the coded block partition can also be determined using a second threshold with the opposite sign to the first threshold. As an example, if the whRatio value is below the second threshold, a horizontal partition can be applied to the coded block; otherwise, a vertical partition can be applied. The absolute values ​​of the first and second thresholds can be the same, but their signs can be different. As an example, when the first threshold is N (where N is an integer such as 1, 2, 4, etc.), the second threshold can be -N.

[0389] Figure 18 This is a schematic diagram illustrating an example of determining the shape of a coded block.

[0390] For ease of explanation, the second threshold is assumed to be -2. Figure 18 In the example shown in (a), the whRatio of the coded block is -1, which is greater than the second threshold. Therefore, the encoding of information representing the shape of the coded block division can be skipped, and the coded block can be divided vertically.

[0391] exist Figure 18 In the example shown in (b), the whRatio of the coded block is -2, which is the same as the second threshold. Therefore, the encoding of information representing the shape of the coded block can be skipped, and the horizontal division can be applied to the coded block.

[0392] Alternatively, the shape of the coded block can be determined based on a first threshold and a second threshold. As an example, if the whRatio value is above the first threshold, the coded block can be divided horizontally; if the whRatio value is below the second threshold, the coded block can be divided vertically. When the whRatio value is between the first and second thresholds, the shape of the current block can be determined from the bitstream parsing information.

[0393] The first and second thresholds can be predefined in the encoder and decoder. Alternatively, the first and second thresholds can be defined according to a sequence, image, or slice.

[0394] Alternatively, the partition shape can be determined based on the size of the coded block or transform block. As an example, when the size of the coded block is N×n, a vertical partition can be applied, and when the size of the coded block is n×N, a horizontal partition can be applied. Here, n can be a natural number less than N. N and / or n can be values ​​predefined in the encoder and decoder. Alternatively, the information used to determine N and / or n can be transmitted as a signal through the bitstream. As an example, N can be 32, 64, 128, or 256, etc. Therefore, when the size of the coded block is 128×n (where n is a natural number such as 16, 32, or 64), a vertical partition can be applied, and when the size of the coded block is n×128, a horizontal partition can be applied.

[0395] Alternatively, the partition shape of the coding block or transform block can be determined based on its intra-prediction mode. As an example, when the intra-prediction mode of the coding block is horizontal or similar, a vertical partition can be applied to the coding block. Here, "intra-prediction mode similar to the horizontal" means that the intra-prediction mode in the horizontal direction (e.g., ...) is similar to the intra-prediction mode in the horizontal direction. Figure 10 (b) shows an intra-prediction mode where the index difference of INTRA_ANGULAR18 is below a threshold (e.g., INTRA_ANGULAR18 ± N). Conversely, when the intra-prediction mode of a coding block is vertical or similar to vertical, a horizontal division can be applied to the coding block. Here, intra-prediction mode in a direction similar to vertical means intra-prediction mode in the vertical direction (e.g., ...). Figure 10 The index difference of INTRA_ANGULAR50 shown in (b) is the intra-prediction mode below the threshold (e.g., INTRA_ANGULAR50 ± N). The threshold N can be a predefined value in the encoder and decoder. Alternatively, the information used to determine the threshold N can be passed signals from the sequence level, image level, or slice level.

[0396] Figure 19 This is a schematic diagram illustrating an example of determining the partition shape of a coding block based on its intra-prediction mode.

[0397] like Figure 19 As shown in (a), when the intra-frame prediction mode of the coding block is similar to the vertical direction, the coding block can be divided into horizontal directions.

[0398] On the contrary, such as Figure 19 As shown in (b), when the intra-prediction mode of the coding block is similar to the horizontal direction, the coding block can be divided into vertical directions.

[0399] Conversely to the example shown, horizontal partitioning can be applied when the intra-prediction mode of the coded block is horizontal or a similar direction, and vertical partitioning can be applied when the intra-prediction mode of the coded block is vertical or a similar direction.

[0400] When applying vertical or horizontal partitioning, the partitioning shape of the coded block or transform block can be determined based on whether at least one of the width or height of the sub-blocks generated by partitioning the coded block or transform block is less than a threshold. The threshold can be an integer such as 2, 4, or 8.

[0401] Figure 20 This is a schematic diagram used to illustrate the shape of the coded block division.

[0402] When on Figure 20 When a 4×8 coded block as shown in (a) is divided horizontally, it is divided into 2×8 sub-blocks. In this case, the width of the sub-blocks is less than a threshold, therefore horizontal division cannot be used for the coded block. Conversely, when a 4×8 coded block is divided vertically, it is divided into 4×4 sub-blocks. The width and height of the sub-blocks are both above the threshold, therefore vertical division can be used for the coded block. Since only vertical division can be used for the coded block, the encoding of information representing the division shape of the coded block can be skipped, and vertical division can be applied to the coded block.

[0403] When on Figure 20 When the 8×4 coded block shown in (b) is vertically divided, it is divided into 8×2 sub-blocks. In this case, the height of the sub-blocks is less than a threshold, therefore, vertical division cannot be used for the coded block. Conversely, when the 8×4 coded block is horizontally divided, it is divided into 4×4 sub-blocks. The width and height of the sub-blocks are both above the threshold, therefore, horizontal division can be used for the coded block. Since only horizontal division is possible for the coded block, the encoding of information representing the division shape of the coded block can be skipped, and vertical division can be applied to the coded block.

[0404] When both vertical and horizontal divisions are available, the information representing the division shape of the coding block can be parsed to determine the division shape of the coding block.

[0405] The number of sub-blocks can be determined based on at least one of the dimensions or shape of the coded block or transform block. As an example, when the width or height of the coded block is 8 and the other is 4, the coded block can be divided into 2 sub-blocks. Conversely, when both the width and height of the coded block are greater than 8, or when either the width or height of the coded block is greater than 8, the coded block can be divided into 4 sub-blocks. In short, when the coded block is 4×4 in size, it may not be divided into sub-blocks. When the coded block is 4×8 or 8×4 in size, it can be divided into 2 sub-blocks. In other cases, it can be divided into 4 sub-blocks.

[0406] Alternatively, information indicating the size, shape, or number of sub-blocks can be transmitted via a bitstream. The size or shape of a sub-block can be determined based on the information indicating its number. Alternatively, the number of sub-blocks can be determined based on the information indicating its size or shape.

[0407] When applying the sub-partition intra-coding method, sub-blocks generated by dividing coded blocks or transform blocks can use the same intra-prediction mode. As an example, the MPM (Multi-Modulation Mode) for a coded block can be obtained based on the intra-prediction modes of its neighboring blocks. The intra-prediction mode for the coded block is then determined based on the obtained MPM. Once the intra-prediction mode for the coded block is determined, each sub-block can perform intra-prediction using that determined mode.

[0408] When applying the sub-partition intra-frame coding method, one of the MPMs can be determined as the intra-prediction mode of the coding block. That is, when applying the sub-partition intra-frame coding method, the MPM can be regarded as true even if the MPM identifier is not transmitted.

[0409] Alternatively, when applying the sub-partition intra-frame coding method, one of the predefined candidate intra-frame prediction modes can be selected as the intra-frame prediction mode for the coding block. As an example, one of the following can be selected as the intra-frame prediction mode for the coding block: a horizontal intra-frame prediction mode, a vertical intra-frame prediction mode, a diagonal intra-frame prediction mode (e.g., at least one of the top-left, top-right, or bottom-left intra-frame prediction modes), or a non-angular intra-frame prediction mode (e.g., at least one of the planner or DC modes). Specific indexing information can be applied to one of the predefined candidate intra-frame prediction modes, and the signal can be transmitted through the bitstream.

[0410] According to one embodiment of this application, at least one intra-prediction mode in a sub-block can be set to be different from that of other sub-blocks. As an example, the intra-prediction mode of the Nth sub-block can be obtained by adding or subtracting an offset from the intra-prediction mode of the (N-1)th sub-block. The offset can be predefined in the encoder and decoder. Alternatively, the offset can be obtained based on at least one of the following: the size and shape of the coded block, the intra-prediction mode, the size and shape of the sub-block, the number of sub-blocks, or the partitioning direction of the coded block. Alternatively, the information used to obtain the offset can be transmitted as a signal through the bitstream.

[0411] Alternatively, if the intra-prediction mode of the (N-1)th sub-block is a non-angle mode, the intra-prediction mode of the Nth sub-block is also set in the same way as the intra-prediction mode of the (N-1)th sub-block. If the intra-prediction mode of the (N-1)th sub-block is an angle mode, the intra-prediction mode of the (N-1)th sub-block can be added to or subtracted from the offset to make the obtained intra-prediction mode the same as the intra-prediction mode of the Nth sub-block.

[0412] Alternatively, an angular intra-prediction mode can be applied to some of the sub-blocks, while a non-angular intra-prediction mode can be applied to the remaining sub-blocks. The sub-blocks to which the non-angular intra-prediction mode is applied can be determined based on at least one of the sub-blocks' size, shape, position, or number of sub-blocks. Alternatively, the non-angular intra-prediction mode can be applied to one of the sub-blocks only if the angular intra-prediction mode applied to one of the sub-blocks is a predefined value.

[0413] Alternatively, the intra-prediction mode of each sub-block can be obtained from the MPM. For this purpose, specific indexing information for a particular MPM can be passed to each sub-block.

[0414] Alternatively, the intra-prediction mode for each sub-block can be obtained from predefined candidate intra-prediction modes. To do this, specific indexing information for a particular predefined candidate intra-prediction mode can be passed to each sub-block.

[0415] Alternatively, information indicating whether the intra-prediction modes of sub-blocks are set identically can be transmitted via the bitstream.

[0416] The quantization parameters of each sub-block can be determined individually. Therefore, the values ​​of the quantization parameters for each sub-block can be set differently. To determine the quantization parameters of each sub-block, information representing the difference between the quantization parameters of the sub-blocks and those of the previous sub-blocks can be encoded. As an example, for the Nth sub-block, the difference between the quantization parameters of the Nth sub-block and those of the (N-1)th sub-block can be encoded.

[0417] Intra-frame prediction of a sub-block can be performed using reference samples. These reference samples can be obtained from the reconstructed samples of neighboring blocks adjacent to the sub-block. When the neighboring block is another sub-block contained within the same coded block as the sub-block, the reference sample of the sub-block can be obtained based on the reconstructed samples of that other sub-block. As an example, when the first sub-block is located to the left or above the second sub-block, the reference sample of the second sub-block can be obtained from the reconstructed samples of the first sub-block. Therefore, parallel intra-frame prediction can be avoided between sub-blocks. That is, encoding or decoding can be performed sequentially for the sub-blocks contained within the coded block. Thus, after the encoding or decoding of the first sub-block is completed, intra-frame prediction for the second sub-block can be performed.

[0418] When using the sub-partition intra-coding method, it is possible to configure it to not use multi-reference line intra-prediction, which selects one of multiple reference sample line candidates. Without using multi-reference line intra-prediction, the adjacent reference sample lines adjacent to each sub-block can be determined as the reference sample lines for that sub-block.

[0419] Alternatively, even when applying a sub-partition intra-coding method, multi-reference line intra-prediction can be used. For this purpose, specific indexing information for the reference sample lines can be passed for each sub-block. Alternatively, specific indexing information for the reference sample lines can be passed only for one of the multiple sub-blocks, while the indexing information can be directly applied to the remaining sub-blocks. Alternatively, it can be configured to pass specific indexing information for the reference sample lines for a coding block, wherein the multiple sub-blocks contained in the coding block share the indexing information.

[0420] Alternatively, multi-reference line intra-prediction can be configured to be used only in sub-blocks containing predefined positions or predefined partition indices. As an example, specific indexing information for a particular candidate reference sample line can be passed only to sub-blocks with partition index 0 or those adjoining the top or left boundary of the coded block. For other sub-blocks, multi-reference line intra-prediction can be omitted. Therefore, other sub-blocks can utilize adjacent reference sample lines to perform intra-prediction.

[0421] Predictive coding modes can be set differently for different sub-blocks. As an example, intra-frame prediction can be applied to some sub-blocks, while inter-frame prediction, current reference image, or composite prediction can be applied to other sub-blocks.

[0422] Figure 21 This is a schematic diagram illustrating an example of setting predictive coding modes differently for each sub-block.

[0423] Intra-frame prediction modes can be set differently for each sub-block, or different prediction coding modes can be set. As an example, in... Figure 21The example shown illustrates the application of in-frame prediction to sub-blocks 0 and 1, and the application of the current reference image to sub-blocks 1 and 2.

[0424] When using the current reference image, the predicted blocks of sub-blocks can be obtained from the decoded regions of the current image or tile group. When applying the current reference image, motion vectors can be obtained to specify the predicted blocks of sub-blocks. These motion vectors under the current reference image can also be called "block vectors".

[0425] Motion vectors can be obtained based on the motion vectors of neighboring blocks adjacent to the coded block or sub-block. Alternatively, information used to determine motion vectors can be transmitted via the bitstream.

[0426] At this point, the maximum value of the motion vector of the sub-block can be determined based on the size of the sub-block or the coding block or transform block to which the sub-block belongs. As an example, the motion vector of the sub-block can be set so that it does not exceed the boundary of the coding block or transform block to which the sub-block belongs. That is, the prediction block of the sub-block can be obtained from the region within the coding block to which the sub-block belongs that has been previously encoded or decoded.

[0427] It can replace motion vectors to encode and transmit signals representing index information of a specific decoded sub-block within a coded block. The prediction block of a sub-block can be determined as a specific decoded sub-block based on the index information.

[0428] As another example, it is also possible to allow the motion vector of a sub-block to extend beyond the boundary of the coded block or transform block to which the sub-block belongs.

[0429] If a prediction block is generated as a result of performing intra-frame prediction, the prediction samples can be updated based on the positions of the prediction samples contained in the prediction block. This update method can be called the position-dependent prediction combination (PDPC).

[0430] Whether to use PDPC can be determined based on the size, shape, intra-prediction mode, reference sample line of the current block, size, or chroma component of the current block. As an example, PDPC can be used if the intra-prediction mode of the current block is at least one of planner, DC, vertical, horizontal, a mode with an index value less than the vertical direction, or a mode with an index value greater than the horizontal direction. Alternatively, PDPC can only be used if at least one of the width or height of the current block is greater than 4. Alternatively, PDPC can only be used if the index of the reference image line of the current block is 0. Alternatively, PDPC can only be used if the index of the reference image line of the current block is above a preset value. Alternatively, PDPC can be used only for the luma component. Alternatively, whether to use PDPC can be determined based on whether two or more of the listed conditions are met.

[0431] Alternatively, the use of PDPC can be determined based on whether sub-partition intra-coding is utilized. As an example, when applying sub-partition intra-coding to a coded block or transform block, it can be configured not to utilize PDPC. Alternatively, when applying sub-partition intra-coding to a coded block or transform block, PDPC can be applied to at least one of multiple sub-blocks. In this case, the sub-block to which PDPC is applied can be determined based on at least one of the following: size, shape, position, intra-prediction mode, or reference sample line index of the coded block or sub-block. As an example, PDPC can be applied to sub-blocks adjacent to the top and / or left boundary of the coded block, or to sub-blocks adjacent to the bottom and / or right boundary of the coded block. Alternatively, it can be configured to apply PDPC to all sub-blocks included in the coded block based on their size or shape, or not apply PDPC to all sub-blocks included in the coded block. As yet another example, PDPC can also be applied to all sub-blocks within the coded block.

[0432] Alternatively, the application of PDPC can be determined based on whether at least one of the following conditions—size, shape, intra-prediction mode, or reference image index—of the sub-blocks generated by dividing the coding or transform blocks satisfies a pre-defined condition. As an example, PDPC can be applied to a sub-block if at least one of its width or height is greater than 4.

[0433] As another example, information indicating whether PDPC is applied can be transmitted via the bitstream.

[0434] Alternatively, the PDPC application area can be determined based on at least one of the following: the size, shape, intra-prediction mode, or the position of the predicted samples. As an example, if the intra-prediction mode of the current block has an index greater than the vertical direction, compensation may not be performed on predicted samples whose x-axis or y-axis coordinates are greater than a threshold; instead, compensation may be performed only on predicted samples whose x-axis or y-axis coordinates are below the threshold. Alternatively, if the intra-prediction mode of the current block has an index less than the horizontal direction, compensation may not be performed on predicted samples whose x-axis or y-axis coordinates are greater than a threshold; instead, compensation may be performed only on predicted samples whose x-axis or y-axis coordinates are below the threshold. In this case, the threshold can be determined based on at least one of the size, shape, or intra-prediction mode of the current block.

[0435] If a prediction sample is obtained through intra-frame prediction, a reference sample used to compensate the prediction sample can be determined based on the position of the obtained prediction sample. For ease of explanation, in the embodiments described later, the reference sample used to compensate the prediction sample can be referred to as the PDPC reference sample. Furthermore, the prediction sample obtained through intra-frame prediction is referred to as the first prediction sample, and the prediction sample obtained by compensating the first prediction sample is referred to as the second prediction sample.

[0436] Figure 22 This is a schematic diagram of the application shape of PDPC.

[0437] At least one PDPC reference sample can be used to compensate for the first prediction sample. The PDPC reference sample may include at least one of the following: a reference sample adjacent to the top left corner of the current block, an upper reference sample located at the top of the current block, or a left reference sample located at the left of the current block.

[0438] At least one of the reference samples belonging to the current block's reference sample line can be set as a PDPC reference sample. Alternatively, regardless of the current block's reference sample line, at least one of the reference samples belonging to the reference sample line at index 0 can be set as a PDPC reference sample. As an example, even if the first prediction sample is obtained using reference samples contained in the reference sample line at index 1 or index 2, the second prediction sample can also be obtained using reference samples contained in the reference sample line at index 0.

[0439] The number or location of the PDPC reference samples used to compensate the first prediction sample can be determined based on at least one of the intra-prediction mode of the current block, the size of the current block, the shape of the current block, or the location of the first prediction sample.

[0440] As an example, if the intra-prediction mode of the current block is planner or DC mode, a second prediction sample can be obtained using the upper reference sample and the left reference sample. In this case, the upper reference sample can be a reference sample perpendicular to the first prediction sample (e.g., a reference sample with the same x-coordinate), and the left reference sample can be a reference sample horizontal to the first prediction sample (e.g., a reference sample with the same y-coordinate).

[0441] If the intra-prediction mode of the current block is horizontal intra-prediction mode, the upper reference sample can be used to obtain the second prediction sample. In this case, the upper reference sample can be a reference sample perpendicular to the first prediction sample.

[0442] If the intra-prediction mode of the current block is the vertical intra-prediction mode, the second prediction sample can be obtained using the left reference sample. In this case, the left reference sample can be a reference sample at the same level as the first prediction sample.

[0443] If the intra-prediction mode of the current block is either the lower left diagonal or the upper right diagonal intra-prediction mode, a second prediction sample can be obtained based on the upper left reference sample, the upper reference sample, and the left reference sample. The upper left reference sample can be a reference sample adjacent to the upper left corner of the current block (e.g., the reference sample at position (-1, -1)). The upper reference sample can be a reference sample located in the upper right diagonal direction of the first prediction sample, and the left reference sample can be a reference sample located in the lower left diagonal direction of the first prediction sample.

[0444] In short, when the position of the first predicted sample is (x, y), R(-1, -1) can be set as the upper left reference sample, and R(x+y+1, -1) or R(x, -1) can be set as the upper reference sample. Alternatively, R(-1, x+y+1) or R(-1, y) can be set as the left reference sample.

[0445] As another example, the position of the left reference sample or the top reference sample can be determined based on at least one of the current block shape or whether a wide-angle intra-frame mode is applied.

[0446] Specifically, if the intra-prediction mode of the current block is wide-angle intra-prediction mode, a reference sample offset from a reference sample located diagonally opposite the first prediction sample can be set as a PDPC reference sample. As an example, the upper reference sample R(x+y+k+1, -1) and the left reference sample R(-1, x+y-k+1) can be set as PDPC reference samples.

[0447] In this case, the offset k can be determined based on the wide-angle intra-frame prediction mode. Equations 8 and 9 show examples of obtaining the offset based on the wide-angle intra-frame prediction mode.

[0448] [Formula 8]

[0449] k = CurrfntraMode-66

[0450] if (CurrIntraMode > 66)

[0451] [Formula 9]

[0452] k = -CurrIntraMode

[0453] if (CurrIntraMode < 0)

[0454] The second predicted sample can be determined based on a weighted sum of the first predicted sample and the PDPC reference sample. As an example, the second predicted sample can be obtained based on the following formula 10.

[0455] [Formula 10]

[0456] pred(x, y) = (xL*R) L +wT*R T -wTL*R TL +(64-wL-wT+wTL)*pred(x,y)+32)>>6

[0457] In Formula 10, R L R represents the left-hand reference sample. T R represents the upper reference sample. TL This represents the upper left reference sample. `pred(x,y)` represents the predicted sample at position (x,y). `wL` represents the weighted value of the left reference sample, `wT` represents the weighted value of the upper reference sample, and `wTL` represents the weighted value of the upper left reference sample. The weighted value of the first predicted sample can be obtained by subtracting the weighted value of the reference sample from the maximum value. For ease of explanation, the weighted value assigned to the PDPC reference sample is called the PDPC weighted value.

[0458] The weighting values ​​assigned to each reference sample can be determined based on at least one of the intra-prediction mode of the current block or the position of the first predicted sample.

[0459] As an example, at least one of wL, wT, or wTL can be directly or inversely proportional to at least one of the x-axis or y-axis coordinate values ​​of the predicted sample. Alternatively, at least one of wL, wT, or wTL can be directly or inversely proportional to at least one of the width or height of the current block.

[0460] If the intra-prediction mode of the current block is DC, the PDPC weighting value can be determined as shown in Formula 11 below.

[0461] [Formula 11]

[0462] wT=32>>((y<<1)>>shift)

[0463] wL=32>>((x<<1)>>shift)

[0464] wTL = (wL >> 4) + (wT >> 4)

[0465] In Formula 11, x and y represent the positions of the first predicted sample.

[0466] In Formula 11, the parameter shift used for the displacement operation can be obtained based on the width or height of the current block. As an example, the parameter shift can be obtained based on Formula 12 or Formula 13.

[0467] [Formula 12]

[0468] shift=(log2(width)-2+log2(height)-2+2)>>2

[0469] [Formula 13]

[0470] shift=((Log2(nTbW)+Log2(nTbH)-2)>>2)

[0471] Alternatively, the shift parameter can be obtained based on the intra-frame direction parameter of the current block.

[0472] The number or types of parameters used to obtain the parameter shift can vary depending on the intra-prediction mode of the current block. As an example, if the intra-prediction mode of the current block is planner, DC, vertical, or horizontal, as shown in Equation 12 or Equation 13, the parameter shift can be obtained using the width and height of the current block. If the intra-prediction mode of the current block has an index larger than the vertical intra-prediction mode, the parameter shift can be obtained using the height of the current block and the intra-direction parameter. If the intra-prediction mode of the current block has an index smaller than the horizontal intra-prediction mode, the parameter shift can be obtained using the width of the current block and the intra-direction parameter.

[0473] If the intra-prediction mode of the current block is planner, the value of wTL can be set to 0. wL and wT can be obtained based on the following formula 14.

[0474] [Formula 14]

[0475] wT[y]=32>>((y<<1)>>shift)

[0476] wL[x]=32>>((x<<1)>>shift)

[0477] If the intra-prediction mode of the current block is horizontal intra-prediction mode, wT can be set to 0, and wTL and wL can be set similarly. Conversely, if the intra-prediction mode of the current block is vertical intra-prediction mode, wL can be set to 0, and wTL and wT can be set similarly.

[0478] If the intra-prediction mode of the current block is an intra-prediction mode with an index value larger than that of the vertical intra-prediction mode and is oriented towards the upper right, the PDPC weighted value can be obtained as shown in Formula 15 below.

[0479] [Formula 15]

[0480] wT=16>>((y<<1)>>shift)

[0481] wL=16>>((x<<1)>>shift)

[0482] wTL=0

[0483] Conversely, if the intra-prediction mode of the current block is an intra-prediction mode with an index value smaller than that of the horizontal intra-prediction mode and oriented towards the lower left, the PDPC weighted value can be obtained as shown in Formula 16 below.

[0484] [Formula 16]

[0485] wT16>>((y<<1)>>shift)

[0486] wL=16>>((x<<1)>>shift)

[0487] wTL=0

[0488] As shown in the above embodiments, the PDPC weighting value can be determined based on the predicted sample's position x and y.

[0489] As another example, weights can also be assigned to PDPC reference samples separately for each sub-block. The predicted samples contained in a sub-block can share the same PDPC weights.

[0490] The size of the sub-block, which serves as the basic unit for determining the weighting value, can be predefined in the encoder and decoder. As an example, the weighting value can be determined for sub-blocks of 2×2 or 4×4 size, respectively.

[0491] Alternatively, the size, shape, or number of sub-blocks can be determined based on the size or shape of the current block. As an example, the coded block can be divided into 4 sub-blocks regardless of its size. Alternatively, the coded block can be divided into 4 or 16 sub-blocks based on its size.

[0492] Alternatively, the size, shape, or number of sub-blocks can be determined based on the intra-prediction mode of the current block. As an example, if the intra-prediction mode of the current block is horizontal, N columns (or N rows) can be set as a sub-block; conversely, if the intra-prediction mode of the current block is vertical, N rows (or N columns) can be set as a sub-block.

[0493] Equations 17 to 19 show examples of determining the PDPC weighting value for a 2×2 size sub-block. Equation 17 provides an example when the intra-prediction mode of the current block is DC mode.

[0494] [Formula 17]

[0495] wT=32>>(((y<<log2K)>>log2K)<<1)>>shift)

[0496] wL=32>>(((x<<log2K))>>log2K))<<1)>>shift)

[0497] wTL = (wL >> 4) + (wT >> 4)

[0498] In Formula 17, the value of K can be determined based on the size of the sub-block.

[0499] Equation 18 provides an example of a case where the intra-prediction mode of the current block has an index value larger than that of the vertical intra-prediction mode and is oriented towards the upper right.

[0500] [Formula 18]

[0501] wT=16>>(((y<<log2K))>>log2K))<<1)>>shift)

[0502] wL=16>>(((x<<log2K))>>log2K))<<1)>>shift)

[0503] wTL=0

[0504] Equation 19 provides an example of an intra-prediction mode for the current block that has an index value smaller than the horizontal intra-prediction mode and is oriented towards the lower left.

[0505] [Formula 19]

[0506] wT=16>>(((y<<log2K))>>log2K))<<1)>>shift)

[0507] wL=16>>(((x<<log2K))>>log2K))<<1)>>shift)

[0508] wTL0

[0509] In Equations 17 to 19, x and y represent the positions of the reference sample within the sub-block. The reference sample can be one of the following: the sample located at the upper left end of the sub-block, the sample located at the center of the sub-block, or the sample located at the lower right end of the sub-block.

[0510] Equations 20 to 22 illustrate examples of determining the PDPC weighting value for a 4×4 size sub-block. Equation 20 provides an example when the intra-prediction mode of the current block is DC mode.

[0511] [Formula 20]

[0512] wT=32>>(((y<<2)>>2)<<1)>>shift)

[0513] wL=32>>(((x<<2)>>2)<<1)>>shift)

[0514] wTL = (wL >> 4) + (wT >> 4)

[0515] Formula 21 illustrates the case where the intra-prediction mode of the current block has an index value larger than that of the vertical intra-prediction mode and is oriented towards the upper right.

[0516] [Formula 21]

[0517] wT=16>>(((y<<2)>>2)<<1)>>shift)

[0518] wL=16>>(((x<<2)>>2)<<1)>>shift)

[0519] wTL=0

[0520] Formula 22 illustrates the case where the intra-prediction mode of the current block has an index value smaller than that of the horizontal intra-prediction mode and is oriented towards the lower left.

[0521] [Formula 22]

[0522] wT=16>>(((y<<2)>>2)<<1)>>shift)

[0523] wL=16>>(((x<<2)>>2)<<1)>>shift)

[0524] wTL=0

[0525] In the above embodiments, the case where the PDPC weighting value is determined based on the position of the predicted sample contained in the first predicted sample or sub-block is illustrated. The PDPC weighting value can also be determined based on the shape of the current block.

[0526] As an example, in DC mode, the method for obtaining the PDPC weighting value will differ depending on whether the current block is a non-square with a width greater than its height or a non-square with a height greater than its width.

[0527] Formula 23 is an example of obtaining the PDPC weighted value when the current block is a non-square with a width greater than its height, and Formula 24 is an example of obtaining the PDPC weighted value when the current block is a non-square with a height greater than its width.

[0528] [Formula 23]

[0529] wT=32>>((y<<1)>>shift)

[0530] wL = 32 >> (x >> shift)

[0531] wTL=(wLL>>4)+(wT>>4)

[0532] [Formula 24]

[0533] wT >> (y >> shift)

[0534] wL=32>>((x<<1)>>shift)

[0535] wTL = (xL >> 4) + (wT >> 4)

[0536] If the current block is not square, the wide-angle intra-frame prediction mode can be used to predict the current block. When applying the wide-angle intra-frame prediction mode, PDPC can also be applied to update the first prediction sample.

[0537] When applying wide-angle intra-frame prediction to the current block, the PDPC weighting value can be determined based on the shape of the coded block.

[0538] As an example, if the current block is a non-square with a width greater than its height, depending on the position of the first predicted sample, the upper reference sample located at the upper right of the first predicted sample may be closer to the first predicted sample than the left reference sample located at the lower left of the first predicted sample. Therefore, in terms of compensation for the first predicted sample, the weighting value applied to the upper reference sample can be set to be larger than the weighting value applied to the left reference sample.

[0539] Conversely, if the current block is a non-square with a height greater than its width, depending on the position of the first predicted sample, the left reference sample located at the lower left of the first predicted sample may be closer to the first predicted sample than the upper reference sample located at the upper right of the first predicted sample. Therefore, in terms of first predicted sample compensation, the weighting value applied to the left reference sample can be set to be larger than the weighting value applied to the upper reference sample.

[0540] Formula 25 shows an example of obtaining the PDPC weighted value when the intra-prediction mode of the current block is a wide-angle intra-prediction mode with an index greater than 66.

[0541] [Formula 25]

[0542] wT = 16 >> (y >> shift)

[0543] wL=16>>((x<<1)>>shift)

[0544] wTL=0

[0545] Formula 26 shows an example of obtaining the PDPC weighted value when the intra-prediction mode of the current block is a wide-angle intra-prediction mode with an index less than 0.

[0546] [Formula 26]

[0547] wT=16>>((y<<1)>>shift)

[0548] wL = 16 >> (x >> shift)

[0549] wTL=0

[0550] The PDPC weighting value can also be determined based on the ratio of the current block. The ratio of the current block represents the ratio of the width to the height of the current block, and can be defined as shown in Formula 27 below.

[0551] [Formula 27]

[0552] whRatio = CUwidth / CUheight

[0553] The method for obtaining the PDPC weighting value can be variably determined based on the intra-prediction mode of the current block.

[0554] As an example, Equations 28 and 29 illustrate how to obtain the PDPC weighted value when the intra-prediction mode of the current block is DC. Specifically, Equation 28 is an example when the current block is a non-square with a width greater than its height, and Equation 29 is an example when the current block is a non-square with a height greater than its width.

[0555] [Formula 28]

[0556] wT=32>>((y<<1)>>shift)

[0557] wL=32>>(((x<<1)>>whRatio)>>shift)

[0558] wTL = (wL >> 4) + (wT >> 4)

[0559] [Formula 29]

[0560] wT=32>>(((y<<1)>>1 / whRatio)>>shift)

[0561] wL=32>>((x<<1)>>shift)

[0562] wTL = (wL >> 4) + (wT >> 4)

[0563] Formula 30 shows an example of obtaining the PDPC weighted value when the intra-prediction mode of the current block is a wide-angle intra-prediction mode with an index greater than 66.

[0564] [Formula 30]

[0565] wT=16>>(((y<<1)>>1 / whRatio)>>shift)

[0566] wL=16>>((x<<1)>>shift)

[0567] wTL=0

[0568] Equation 31 shows an example of obtaining the PDPC weighted value when the intra-prediction mode of the current block is a wide-angle intra-prediction mode with an index less than 0.

[0569] [Formula 31]

[0570] wT=16>>((y<<1)>>shift)

[0571] wL=16>>(((x<<1)>>whRatio)>>shift

[0572] wTL=0

[0573] The residual image can be obtained by differencing the predicted image from the original image. In this case, when transforming the residual video into the frequency domain, even if high-frequency components are removed, the subjective quality of the video does not significantly decrease. Therefore, reducing or setting the values ​​of high-frequency components to 0 can increase compression efficiency without significantly causing visual distortion. To decompose the residual image into two-dimensional frequency components and reflect the above characteristics, a transformation can be performed on the current block. This transformation can be performed using transformation methods such as Discrete Cosine Transform (DCT) or Discrete Sine Transform (DST).

[0574] DCT uses cosine transform to decompose (or transform) residual video into two-dimensional frequency components, while DST uses sine transform to decompose (or transform) residual video into two-dimensional frequency components. The frequency components of the transformed residual video can be represented as image features. As an example, when performing DCT on an N×N block, N... 2 The weights corresponding to each image feature can be obtained through transformation. The weights corresponding to each image feature within an N×N block can be called DCT coefficients or DST coefficients, depending on the transformation method used.

[0575] The Direct Transformation Method (DCT) is primarily used to transform videos with a large distribution of non-zero low-frequency components. The Direct Transformation Method (DST) is primarily used for videos with a large distribution of high-frequency components.

[0576] Transformation methods other than DCT or DST can also be used to transform residual video.

[0577] The transformation of residual video into two-dimensional frequency components is referred to as two-dimensional image transformation. Furthermore, the weights corresponding to the image features obtained in the transformation result are called transform coefficients. As an example, transform coefficients can represent DCT coefficients or DST coefficients. When both the main transform and the secondary transform are applied (described later), the transform coefficients can represent the weights corresponding to the image features generated as a result of the secondary transform.

[0578] The transform method can be determined on a block-by-block basis. The transform method can be determined based on at least one of the predictive coding mode of the current block, the size of the current block, or the size of the current block. As an example, if the current block is coded in intra-predictive mode and the size of the current block is less than N×N, the transform method DST can be used to perform the transform. Conversely, when these conditions are not met, the transform method DCT can be used to perform the transform.

[0579] For a portion of the residual video, a 2D video transform may not be performed. This situation, where no 2D video transform is performed, can be called transform skipping. When applying transform skipping, quantization can be applied to the residual values ​​from which the transform was not performed.

[0580] After transforming the current block using DCT or DST, the transformed current block can be transformed again. In this case, the transformation based on DCT or DST can be defined as the primary transformation, and the case of transforming the block again after applying the primary transformation can be defined as the secondary transformation.

[0581] The main transform can be performed using one of several transform kernel candidates. As an example, the main transform can be performed using one of DCT2, DCT8, or DCT7.

[0582] Different transform kernels can also be used for the horizontal and vertical directions. Information representing the combination of horizontal and vertical transform kernels can be transmitted as a signal through the bitstream.

[0583] The execution units for the primary and secondary transformations can be different. As an example, the primary transformation can be performed on an 8×8 block, and the secondary transformation can be performed on the 4×4 sub-blocks within the transformed 8×8 block. In this case, the transformation coefficients of other regions that do not undergo secondary transformations can also be set to 0.

[0584] Alternatively, a primary transformation can be performed on the 4×4 block, and a secondary transformation can be performed on the 8×8 dimensional region of the 4×4 block that includes the transformation.

[0585] Information indicating whether a secondary transformation should be performed can be transmitted via a code stream.

[0586] Alternatively, the decision to perform a secondary transformation can be based on whether the horizontal and vertical transformation kernels are the same. As an example, a secondary transformation can only be performed if the horizontal and vertical transformation kernels are the same. Alternatively, a secondary transformation can only be performed if the horizontal and vertical transformation kernels are different.

[0587] Alternatively, secondary transformations could be allowed only when horizontal and vertical transformations utilize a predefined transformation kernel. As an example, secondary transformations are allowed when both horizontal and vertical transformations use the DCT2 transformation kernel.

[0588] Alternatively, the decision to perform a secondary transform can be based on the number of non-zero transform coefficients in the current block. As an example, if the number of non-zero transform coefficients in the current block is less than or equal to a threshold, the secondary transform can be disabled; if the number of non-zero transform coefficients in the current block is greater than the threshold, the secondary transform can be used. Alternatively, the secondary transform can be used only when the current block is encoded using intra-frame prediction.

[0589] The size or shape of the sub-block to which the secondary transformation will be performed can be determined based on the shape of the current block.

[0590] Figure 23 and Figure 24 A schematic diagram of a sub-block performing a quadratic transformation is shown.

[0591] If the current block is square, after performing the primary transformation, a secondary transformation can be performed on the N×N sub-block at the top left of the current block. As an example, if the current block is an 8×8 coded block, after performing the primary transformation on the current block, a secondary transformation can be performed on the 4×4 sub-block at the top left of the current block (see [reference]). Figure 23 ).

[0592] If the current block is a non-square with a width greater than four times its height, a secondary transformation can be performed on the (kN) × (4kN) sub-block at the top left of the current block after the primary transformation. As an example, if the current block is a non-square with dimensions of 16 × 4, a secondary transformation can be performed on the 2 × 8 sub-block at the top left of the current block after the primary transformation (see [reference]). Figure 24 (a)

[0593] If the current block is a non-square with a height more than four times its width, a secondary transformation can be performed on the (4kN) × (kN) sub-block at the top left of the current block after the primary transformation. As an example, if the current block is a non-square with dimensions of 16 × 4, a secondary transformation can be performed on the (2 × 8) sub-block at the top left of the current block after the primary transformation (see [reference]). Figure 24 (b)

[0594] The inverse of the second inverse transform (second inverse transform) can be performed in the decoder, and based on its result, the inverse of the main transform (first inverse transform) is performed. Based on the results of the second and first inverse transforms, the residual signal for the current block is obtained.

[0595] Information indicating the transform type of the current block can be transmitted via the bitstream. This information can be the index information tu_mts_idx of a combination of horizontal and vertical transform types.

[0596] Based on the index information tu_mts_idx, specific transformation type candidates can be used to determine the vertical and horizontal transformation kernels. Tables 7 and 8 show the combinations of transformation types based on tu_mts_idx.

[0597] Table 7

[0598]

[0599] Table 8

[0600]

[0601] The transform type can be determined as one of DCT2, DST7, DCT8, or transform skip. Alternatively, except for transform skip, only the transform kernel can be used to construct a candidate combination of transform types.

[0602] When using Table 7, if tu_mts_idx is 0, transformations can be skipped in both the horizontal and vertical directions. If tu_mts_idx is 1, DCT2 can be applied in both the horizontal and vertical directions. If tu_mts_idx is 3, DCT8 can be applied in the horizontal direction and DCT7 in the vertical direction.

[0603] When using Table 8, if tu_mts_idx is 0, DCT2 can be applied to both the horizontal and vertical directions. If tu_mts_idx is 1, transform skip can be applied to both the horizontal and vertical directions. If tu_mts_idx is 3, DCT8 can be applied to the horizontal direction and DCT7 to the vertical direction.

[0604] Whether index information is encoded can be determined based on at least one of the following: the size, shape, or number of non-zero coefficients of the current block. As an example, when the number of non-zero coefficients is equal to or less than a threshold, index information can be omitted, and a default transform type can be applied to the current block. The default transform type can be DST7. Alternatively, the default mode can vary depending on the size, shape, or intra-prediction mode of the current block.

[0605] The threshold can be determined based on the size or shape of the current block. As an example, the threshold can be set to 2 if the size of the current block is less than or equal to 32×32, and to 4 if the current block is larger than 32×32 (e.g., when the current block is a coded block of size 32×64 or 64×32).

[0606] Multiple lookup tables can be pre-stored in the encoder or decoder. At least one of the following can be different: the index value assigned to the transform type combination candidate, the type of transform type combination candidate, or the number of transform type combination candidates.

[0607] The lookup table for the current block can be selected based on at least one of the following: the size and shape of the current block, the predictive coding mode, the intra-frame prediction mode, whether a quadratic transform is applied, or whether a transform skip is applied to adjacent blocks.

[0608] As an example, when the current block size is less than 4×4 or the current block is coded with inter-frame prediction, the lookup table in Table 7 can be used; when the current block size is greater than 4×4 or the current block is coded with intra-frame prediction, the lookup table in Table 8 can be used.

[0609] Alternatively, information indicating which of several lookup tables to use can be transmitted via a signal in the bitstream. The decoder can then select the appropriate lookup table for the current block based on this information.

[0610] As another example, the index assigned to a transform type combination candidate can be adaptively determined based on at least one of the following: the size and shape of the current block, the predictive coding mode, the intra-prediction mode, whether a quadratic transform is applied, or whether transform skipping is applied to adjacent blocks. As an example, the index assigned to transform skipping when the current block size is 4×4 can have a smaller value than the index assigned to transform skipping when the current block size is greater than 4×4. Specifically, if the current block size is 4×4, an index of 0 can be assigned to transform skipping; if the current block is greater than 4×4 but less than 16×16, an index greater than 0 (e.g., index 1) can be assigned to transform skipping; if the current block is greater than 16x16, a maximum value (e.g., 5) can be assigned to the transform skipping index.

[0611] Alternatively, if the current block is coded with inter-frame prediction, index 0 can be skipped for the transform. If the current block is coded with intra-frame prediction, an index greater than 0 (e.g., index 1) can be skipped for the transform.

[0612] Alternatively, if the current block is a 4×4 block coded with inter-frame prediction, index 0 can be skipped for the transform. Conversely, if the current block is not coded with inter-frame prediction or the current block is larger than 4×4, indices with values ​​greater than 0 (e.g., index 1) can be skipped for the transform.

[0613] Transform type combination candidates, different from those listed in Tables 7 and 8, can also be defined and used. As an example, transform skipping can be applied to either a horizontal or vertical transform, while for the other, a transform type combination candidate with a transform kernel such as DCT7, DCT8, or DST2 can be utilized. In this case, whether to use transform skipping as a transform type candidate for the horizontal or vertical direction can be determined based on at least one of the current block's size (e.g., width and / or height), shape, predictive coding mode, or intra-frame prediction mode.

[0614] Alternatively, information indicating whether a particular transform type candidate is available can be conveyed via the bitstream. As an example, an identifier indicating whether transforms can be skipped as transform type candidates for both horizontal and vertical directions can be conveyed. Based on this identifier, it can be determined whether a specific transform type combination candidate from multiple transform type combination candidates is included.

[0615] Alternatively, information about whether a specific transform type candidate is applied to the current block can be conveyed via the bitstream. As an example, a flag `cu_mts_flag` indicating whether DCT2 is applied to both the horizontal and vertical directions can be passed. When `cu_mts_flag` is 1, DCT2 can be set as the transform kernel for both the vertical and horizontal directions. When `cu_mts_flag` is 0, DCT8 or DST7 can be set as the transform kernel for both the vertical and horizontal directions. Alternatively, when `cu_mts_flag` is 0, specific information `tu_mts_idx` can be passed regarding applying a particular transform type combination candidate to one of several transform type combination candidates.

[0616] If the current block is a non-square with a width greater than its height or a non-square with a height greater than its width, the encoding of cu_mts_flag can be skipped, and the value of cu_mts_flag can be regarded as 0.

[0617] The number of available transform type combination candidates can be set differently depending on the size, shape, or intra-prediction mode of the current block. For example, if the current block is square, more than three transform type combination candidates can be used; if the current block is not square, two transform type combination candidates can be used. Alternatively, if the current block is square, only transform type combination candidates with different transform types for the horizontal direction and different transform types for the vertical direction can be used.

[0618] If the current block has more than three transform type combination candidates, the index information tu_mts_idx indicating one of the transform type combination candidates can be passed. Conversely, if the current block has two transform type combination candidates, the identifier mts_flag indicating one of the transform type combination candidates can be passed. Table 9 shows the encoded shape of the information required for transform type combination candidates specific to the shape of the current block.

[0619] Table 9

[0620]

[0621] Based on the shape of the current block, the indices of the transformation type combination candidates can be reordered. As an example, the indices assigned to transformation type combination candidates when the current block is a square can be different from those assigned when the current block is non-square. For example, when the current block is a square, transformation type combinations can be selected based on Table 10 below; when the current block is non-square, transformation type combinations can be selected based on Table 11 below.

[0622] Table 10

[0623]

[0624] Table 11

[0625]

[0626] The transformation type can be determined based on the number of non-zero coefficients in the horizontal or vertical direction of the current block. The number of non-zero coefficients in the horizontal direction represents the number of non-zero coefficients contained in 1 x N (where N is the width of the current block), and the number of non-zero coefficients in the vertical direction represents the number of non-zero coefficients contained in N x 1 (where N is the height of the current block). If the maximum value of the non-zero coefficients in the horizontal direction is less than or equal to a threshold, a primary transformation type can be applied to the horizontal direction; if the maximum value of the non-zero coefficients in the horizontal direction is greater than the threshold, a secondary transformation type can be applied to the horizontal direction. Similarly, if the maximum value of the non-zero coefficients in the vertical direction is less than or equal to a threshold, a primary transformation type can be applied to the vertical direction; if the maximum value of the non-zero coefficients in the vertical direction is greater than the threshold, a secondary transformation type can be applied to the vertical direction.

[0627] Figure 25 This is a diagram used to illustrate an example of determining the transformation type of the current block.

[0628] As an example, if the current block is coded using intra-frame prediction, and the maximum value of the non-zero coefficients in the horizontal direction of the current block is less than 2 (refer to...) Figure 25(a) can be used to determine the transformation type in the horizontal direction as DST7.

[0629] If the current block is coded using intra-frame prediction, and the maximum value of the non-zero coefficients in the vertical direction of the current block is greater than 2 (refer to...). Figure 25 (b) can be used to determine DCT2 or DCT8 as the transformation type in the vertical direction.

[0630] Information indicating whether the transform type of the current block is explicitly determined based on information transmitted from the bitstream can be transmitted via signals. As an example, at the sequence level, information such as `sps_explicit_intra_mts_flag` indicating whether explicit transform type determination is allowed for blocks coded with intra-frame prediction and / or `sps_explicit_inter_mts_flag` indicating whether explicit transform type determination is allowed for blocks coded with inter-frame prediction

[0631] When the transform type can be determined, it can be based on the index information tu_mts_idx passed from the bitstream. Conversely, when the transform type cannot be determined, it can be determined based on at least one of the following: the size and shape of the current block, whether sub-block units are allowed to transform, or the position of sub-blocks containing non-zero transform coefficients. As an example, the horizontal transform type of the current block can be determined based on its width, and the vertical transform type can be determined based on its height. For instance, if the width of the current block is less than 4 or greater than 16, the horizontal transform type can be determined as DCT2. Otherwise, the horizontal transform type can be determined as DST7. If the height of the current block is less than 4 or greater than 16, the vertical transform type can be determined as DCT2. Otherwise, the vertical transform type can be determined as DST7. The thresholds used for comparison with width and height to determine the horizontal and vertical transform types can be determined based on at least one of the current block's size, shape, or intra-frame prediction mode.

[0632] Alternatively, if the current block is a square with the same height and width, both the horizontal and vertical transformation types can be set equally. Conversely, if the current block is a non-square with different height and width, the horizontal and vertical transformation types can be set differently. As an example, if the width of the current block is greater than its height, the horizontal transformation type can be set to DST7, and the vertical transformation type to DCT2. If the height of the current block is greater than its width, the vertical transformation type can be set to DST7, and the horizontal transformation type to DCT2.

[0633] The number and / or types of transformation type candidates, or the number and / or types of transformation type combination candidates, will vary depending on whether explicit determination of the transformation type is allowed. As an example, when explicit determination of the transformation type is allowed, DCT2, DST7, and DCT8 can be used as transformation type candidates. Therefore, the horizontal transformation type and the vertical transformation type can be set to DCT2, DST8, or DCT8, respectively. When explicit determination of the transformation type is not allowed, only DCT2 and DST7 can be used as transformation type candidates. Therefore, the horizontal transformation type and the vertical transformation type can be determined as DCT2 or DST7, respectively.

[0634] The coded block or transform block can be divided into multiple sub-blocks, and the transform can be performed on each sub-block separately. As an example, when applying the above sub-partition intra-predictive coding method to a coded block, the coded block can be divided into multiple sub-blocks, and the transform can be performed on each sub-block separately.

[0635] The transformation types of each sub-block can be the same. As an example, if the transformation type for the first sub-block among multiple sub-blocks is determined, then the transformation type of the first sub-block can also be applied to the remaining sub-blocks. Alternatively, the transformation type for the coded block can be determined, and the transformation type of the coded block can be used as the transformation type of the sub-blocks.

[0636] As another example, the transformation type of multiple sub-blocks can be determined individually. The transformation type of each sub-block can be determined based on information about the signals transmitted for each sub-block. As an example, index information tu_mts_idx can be transmitted for each sub-block. The index information tu_mts_idx can be specific to one of multiple combinations of horizontal and vertical transformation types. Based on the value of tu_mts_idx, the horizontal and vertical transformation types can be determined as DCT2, DST7, or DCT8. Based on the index information tu_mts_idx, it can be determined whether the horizontal and vertical transformation types are the same.

[0637] Information indicating whether the transformation type of the current sub-block uses the same transformation type as the previous sub-block can be transmitted. When the information indicates that the same transformation type is used as the previous sub-block, the encoding of the index information tu_mts_idx of the current sub-block can be skipped, and the transformation type of the previous sub-block can be applied to the current sub-block. Conversely, when the information indicates that a different transformation type is used than the previous sub-block, the index information tu_mts_idx of the current sub-block can be encoded. In this case, the index information of the current sub-block can indicate one of the transformation type combinations other than the combination indicated by the index information of the previous sub-block.

[0638] Alternatively, when the coded block is divided into multiple sub-blocks, the transformation type can be set to not be explicitly determined. When explicit transformation types are allowed, the transformation type can be determined based on the index information tu_mts_idx. Conversely, when explicit transformation types are not allowed, the transformation type can be determined based on at least one of the sub-block's size, shape, or the position of its non-zero coefficients.

[0639] Figure 26 This is a schematic diagram illustrating an example of determining the transformation type of a sub-block.

[0640] exist Figure 26 Examples are shown where the height-to-width ratio of the sub-blocks is 1:2 or 2:1.

[0641] The horizontal and vertical transformation types can be determined based on the width and height of each sub-block. As an example, such as... Figure 26 As shown in (a) and (b), when the width of the sub-block is less than the threshold, the primary transform type (e.g., DCT2) can be used as the horizontal transform type. Conversely, when the width of the sub-block is greater than the threshold, the secondary transform type (e.g., DST7) can be used as the horizontal transform type.

[0642] Additionally, when the height of the sub-block is less than the threshold, the primary transform type (e.g., DCT2) can be used as the vertical transform type. Conversely, when the width of the sub-block is greater than the threshold, the secondary transform type (e.g., DST7) can be used as the vertical transform type.

[0643] The threshold can be a natural number such as 2, 4, or 8. The threshold can be variably determined based on at least one of the size and shape of the coded block, the intra-frame prediction mode, or the predictive coding mode. Alternatively, the information used to determine the threshold can be transmitted as a signal through the bitstream.

[0644] The example above illustrates comparing the width and height of a sub-block to a threshold, but the transformation type can also be determined by comparing the width and height of the sub-block to two thresholds. As an example, if the width of the sub-block is less than the first threshold or greater than the second threshold, the transformation type in the horizontal direction can be determined as DCT2. Otherwise, the transformation type in the horizontal direction can be determined as DST7. Similarly, if the height of the sub-block is less than the first threshold or greater than the second threshold, the transformation type in the vertical direction can be determined as DCT2. Otherwise, the transformation type in the vertical direction can be determined as DST7. The second threshold is a natural number greater than the first threshold, where the first threshold can be a natural number such as 2, 4, or 8, and the second threshold can be a natural number such as 8, 16, or 32.

[0645] As another example, when the sub-block is a square with the same height and width, the horizontal and vertical transformation types can be set identically. Conversely, when the sub-block is a non-square with different height and width, the horizontal and vertical transformation types can be set differently. For instance, if the width of the sub-block is greater than its height, the horizontal transformation type can be set to DST7, and the vertical transformation type to DCT2. If the height of the sub-block is greater than its width, the vertical transformation type can be set to DST7, and the horizontal transformation type to DCT2.

[0646] The residual coefficients contained in at least one of multiple sub-blocks can be set to 0. Here, a residual coefficient means a transform coefficient generated by a transform, a transform skip coefficient generated by a transform skip, or a quantized coefficient generated by quantizing said transform coefficient or transform skip coefficient. As an example, the residual coefficients contained in sub-blocks separated from the boundary of the coded block by a predetermined distance can be set to 0.

[0647] Figure 27 This is a diagram used to illustrate an example where the residual coefficients of a sub-block are set to 0.

[0648] exist Figure 27 In the example shown, CBF (Coded Block Flag) indicates whether there are non-zero residual coefficients within the sub-block. A CBF value of 0 indicates that there are no non-zero residual coefficients within the sub-block, and a CBF value of 1 indicates that there are non-zero residual coefficients within the sub-block.

[0649] When the distance from the boundary of the coded block to the sub-block is above a threshold, the residual coefficient contained in the sub-block can be set to 0. In this case, the distance from the boundary of the coded block to the sub-block can be obtained based on a first sample located at the boundary of the coded block and a second sample contained in the sub-block. As an example, the first sample can be a sample located at the top left corner, bottom left corner, middle left section, top right corner, bottom right corner, middle right section, middle upper section, or middle lower section of the coded block. The second sample can be a sample located at the top left corner, bottom left corner, middle left section, top right corner, bottom right corner, middle right section, middle upper section, or middle lower section of the sub-block.

[0650] The threshold can be determined based on at least one of the following: the size and shape of the coded block, the number of sub-blocks contained in the coded block, or the size of the sub-blocks. Alternatively, the information used to determine the threshold can be signaled via the bitstream.

[0651] As an example, when applying vertical partitioning to the current block, the residual coefficients of sub-blocks whose distance from the left boundary of the coded block is above a threshold can be set to 0. When the coded block size is 64 and the threshold is 32, such as... Figure 27 As shown in (a), the residual coefficients of sub-blocks (Sub-CU2 and Sub-CU3) that are more than 32 units away from the left boundary of the coded block can be set to 0.

[0652] Alternatively, when applying horizontal partitioning to the current block, the residual coefficients of sub-blocks whose distance from the upper boundary of the coding block is above a threshold can be set to 0. When the coding block size is 64 and the threshold is 32, such as... Figure 27 As shown in (b), the residual coefficients of sub-blocks (Sub-CU2 and Sub-CU3) that are more than 32 units away from the upper boundary of the coding block can be set to 0.

[0653] Conversely to the example shown, the residual coefficients contained in sub-blocks that are less than a threshold distance from the coded block boundary can also be set to 0.

[0654] Alternatively, the residual coefficients of all sub-blocks except those located at pre-defined positions can be set to 0. For example, when applying a vertical division to a coded block, the residual coefficients of all sub-blocks except those located at the leftmost or rightmost position can be set to 0. Similarly, when applying a horizontal division to a coded block, the residual coefficients of all sub-blocks except those located at the topmost or bottommost position can be set to 0.

[0655] For sub-blocks, information indicating the presence of non-zero coefficients, such as CBF encoding, can be skipped. When CBF encoding is skipped, it can be determined whether each sub-block contains non-zero residual coefficients based on the distance between the coded block boundary and the sub-block, or the position of the sub-block. As an example, in Figure 27 In the example shown, it can be concluded that the CBF value of sub-block 0 and sub-block 1 (sub-CU0, sub-CU1) is 1, and the CBF value of sub-block 2 and sub-block 3 (sub-CU2, sub-CU3) is 0.

[0656] For subblocks containing non-zero coefficients, transformation and / or quantization can be performed; on the other hand, for subblocks not containing non-zero coefficients, transformation and quantization can be skipped.

[0657] As another example, information indicating that only a portion of a coded block or transform block will be transformed can be encoded and transmitted. This information can be a 1-bit identifier, cu_sbt_flag. A flag of 1 indicates that the transformation will only be performed on a portion of the multiple sub-blocks generated by dividing the coded block or transform block, while a flag of 0 indicates that the transformation will not be performed without dividing the coded block or transform block into sub-blocks.

[0658] The method of performing a transformation on only a portion of a coded block is only permitted when applying sub-partition intra-frame coding to the coded block. Therefore, in the case of applying sub-partition intra-frame coding only to the coded block, `cu_sbt_flag` can be encoded and transmitted. When `cu_sbt_flag` is 1, the transformation can be performed on a portion of the multiple sub-blocks generated by dividing the coded block or transform block, and the residual coefficients of the remaining sub-blocks can be set to 0. When `cu_sbt_flag` is 1, the transformation can be performed on all sub-blocks.

[0659] Alternatively, when applying the sub-partition intra-frame coding method to a coded block, the encoding of cu_sbt_flag can be skipped, and the value of cu_sbt_flag can be set to 1.

[0660] As another example, a method can be used where the predictive coding mode of the coding block is inter-frame prediction or the current reference image, allowing transformation to be performed only on a portion of the coding block. When the coding block is coded using inter-frame prediction or the current reference image, information indicating whether transformation is performed only on a portion of the coding block can be encoded and transmitted. When transformation is performed only on a portion of the coding block, information indicating the shape of the coding block partitions can be encoded and transmitted. Information indicating the shape of the coding block partitions can include at least one of the following: information indicating whether the coding block is divided into four sub-blocks, information indicating the direction of the coding block partitions, or information indicating the number of sub-blocks. As an example, when cu_sbt_flag is 1, the identifier cu_sbt_quadtree_flag indicating whether the coding block is divided into four sub-blocks can be transmitted. cu_sbt_quadtree_flag being 1 indicates that the coding block is divided into four sub-blocks. As an example, a coded block can be divided into four sub-blocks using three vertical lines or three horizontal lines, or using one vertical line and one horizontal line. A `cu_sbt_quadtree_flag` of 0 indicates that the coded block is divided into two sub-blocks. As an example, a coded block can be divided into two sub-blocks using one vertical line or one horizontal line.

[0661] Additionally, the identifier indicating the direction of the coded block division can be transmitted via the bitstream. As an example, the identifier `cu_sbt_horizontal_flag`, indicating whether a horizontal division is applied to the coded block, can be encoded and transmitted. A value of 1 for `cu_sbt_horizontal_flag` indicates a horizontal division, while a value of 0 indicates a vertical division.

[0662] Information indicating the location of sub-blocks without non-zero coefficients or sub-blocks that do not undergo transformation can be transmitted via the bitstream. Based on this information, sub-blocks that have undergone transformation and / or quantization, and sub-blocks that skip transformation and / or quantization, can be identified.

[0663] Figure 28 This is an example of using information transmitted through the bitstream to indicate the location of sub-blocks that are being transformed and / or quantized.

[0664] The flag `sbt_upleft_flag`, indicating the presence of non-zero coefficients at a specific position or in the first sub-block, can convey a signal. A value of 1 for `sbt_upleft_flag` indicates that a transform and / or quantization was performed on the sub-block located at the top or left of the coded block, and that no transform and / or quantization was performed on the sub-block located at the right or bottom of the coded block. A value of 0 for `sbt_upleft_flag` indicates that a transform and / or quantization was performed on the sub-block located at the top or left of the coded block, and that no transform and / or quantization was performed on the sub-block located at the right or bottom of the coded block.

[0665] When the coded block is divided into 4 sub-blocks, `sbt_upleft_flag` can indicate that transforms and / or quantizations were performed on N sub-blocks. As an example, a value of 1 for `sbt_upleft_flag` indicates that transforms and / or quantizations were performed on the top or left sub-blocks, and a value of 0 indicates that transforms and / or quantizations were performed on the right or bottom sub-blocks.

[0666] Unlike the example shown in the diagram, the value of N can also be set to 1 or 3.

[0667] The residual coefficients of sub-blocks that have not undergone transformation and / or quantization can be set to 0.

[0668] The transformation type of a sub-block can be determined based on the division direction of the coded block and the position of the sub-blocks. As an example, when the coded block is divided vertically and a transformation is performed on the left-hand sub-block, the horizontal and vertical transformation types can be set differently. For example, the horizontal transformation type can be set to DCT8, and the vertical transformation type can be set to DST7. Conversely, when the coded block is divided vertically and a transformation is performed on the right-hand sub-block, the horizontal and vertical transformation types of the sub-block can be set the same. For example, the horizontal and vertical transformation types can be set to DST7.

[0669] Alternatively, when a coding block is divided horizontally and a transformation is performed on the uppermost sub-block, the horizontal and vertical transformation types can be set differently. As an example, the horizontal transformation type can be set to DST7, and the vertical transformation type can be set to DCT8. Conversely, when a coding block is divided horizontally and a transformation is performed on the lowermost sub-block, the horizontal and vertical transformation types of the sub-block can be set identically. As an example, both the horizontal and vertical transformation types can be set to DST7.

[0670] For sub-blocks, information indicating the presence of non-zero coefficients can be skipped; for example, CBF encoding can be skipped. When CBF encoding is skipped, the presence of non-zero residual coefficients in each sub-block can be determined based on the position of the block undergoing the transformation. As an example, when `sbt_upleft_flag` is 0, the CBF value of the sub-block located on the left or top edge is 0, and the CBF value of the sub-block located on the right or bottom edge is 1. Alternatively, when `sbt_upleft_flag` is 1, the CBF value of the sub-block located on the left or top edge is 1, and the CBF value of the sub-block located on the right or bottom edge is 0.

[0671] The reconstructed samples for the sub-blocks undergoing the transformation can be obtained by summing the predicted samples and the residual samples. Conversely, in sub-blocks where the transformation is skipped, the predicted samples can be set as the reconstructed samples. Quantization is performed to reduce the energy of the block, and the quantization process involves dividing the transformation coefficients by a specific constant value. This constant value can be obtained based on quantization parameters, which can be defined as values ​​between 1 and 63.

[0672] If the encoder performs transform and quantization, the decoder can obtain the residual block through inverse quantization and inverse transform. The decoder can then add the predicted block to the residual block to obtain the reconstructed block for the current block.

[0673] If a reconstructed block of the current block is obtained, information loss during quantization and encoding can be reduced through in-loop filtering. In-loop filtering can include at least one of a deblocking filter, a sample adaptive offset filter (SAO), or an adaptive loop filter (ALF). Hereinafter, the reconstructed block before applying in-loop filtering is referred to as the first reconstructed block, and the reconstructed block after applying in-loop filtering is referred to as the second reconstructed block.

[0674] A second reconstructed block can be obtained by applying at least one of a deblocking filter, SAO, or ALF to the first reconstructed block. In this case, SAO or ALF can be applied after the deblocking filter is applied.

[0675] Deblocking filters are used to mitigate the blocking artifacts at block boundaries that occur due to quantization performed on a block-by-block basis. To apply a deblocking filter, the block strength (BS) between the first reconstructed block and its adjacent reconstructed blocks can be determined.

[0676] Figure 29 This is a flowchart of the process for determining the strength of a block.

[0677] exist Figure 29 In the example shown, P represents the first reconstructed block, and Q represents the adjacent reconstructed block. The adjacent reconstructed block can be adjacent to the right or top of the current block.

[0678] exist Figure 29 The example shown illustrates how block strength is determined based on the predictive coding patterns of P and Q, whether non-zero transform coefficients are included, whether inter-frame prediction is performed using the same reference image, or whether the difference in motion vectors is above a threshold.

[0679] Whether to apply a deblocking filter can be determined based on the block strength. As an example, if the block strength is 0, filtering may not be performed.

[0680] SAO (Sound Offset Allocation) is used to mitigate the ringing artifact that occurs when quantization is performed in the frequency domain. SAO can be performed by adding or subtracting offsets determined based on a pattern from the first reconstructed video. Offset determination methods include Edge Offset (EO) or Band Offset (BO). EO represents a method of determining the compensation value for the current sample based on the pattern of adjacent pixels. BO represents a method of applying a common compensation value to a set of pixels with similar brightness values ​​within a region. Specifically, pixel brightness can be divided into 32 equal intervals, and pixels with similar brightness values ​​can be grouped together. As an example, four adjacent bands in the 32 bands can be grouped together, and samples belonging to these four bands can be given the same compensation value.

[0681] ALF is a method for generating a second reconstructed video by applying a filter of predefined size or shape to a first reconstructed video or a reconstructed video with a deblocking filter applied. Equation 32 below illustrates an application example of ALF.

[0682] [Formula 32]

[0683]

[0684] You can select one of the predefined filter candidates, using an image, coding tree unit, coding block, prediction block, or transform block as the unit. The size or shape of each filter candidate can be different.

[0685] Figure 30 Predefined filter candidates are shown.

[0686] like Figure 30 As shown, at least one diamond-shaped window of size 5×5, 7×7 or 9×9 can be selected.

[0687] For chromaticity components, only a 5x5 diamond-shaped window is available.

[0688] The embodiments described focusing on the decoding or encoding process are also included within the scope of this application when applied to the encoding or decoding process. Similarly, the embodiments described in a predetermined order are also included within the scope of this application when changed to a different order than the description.

[0689] The above embodiments are described based on a series of steps or sequence diagrams, but this does not limit the temporal order of the invention; they can be executed simultaneously or in different orders as needed. Furthermore, in the above embodiments, the constituent elements of the block diagram (e.g., units, modules, etc.) can be implemented individually in hardware or software, or multiple constituent elements can be combined to form a single hardware or software device. The above embodiments can be implemented in the form of program commands executable by various computer components and recorded on a computer-readable recording medium. The computer-readable recording medium can include program commands, data files, data structures, etc., individually or in combination. Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks, and magnetic tapes; optical recording media such as CD-ROMs and DVDs; magneto-optical media such as floppy disks; and hardware devices specifically configured to store and execute program commands, such as ROMs, RAMs, and flash memory. To execute the processing of this application, the hardware device can be configured to operate with one or more software modules, or vice versa.

[0690] Industrial applicability

[0691] This application can be applied to electronic devices that encode or decode images.

Claims

1. A video decoding method, characterized in that, include: Determine the reference sample line for the current block; Determine whether there exists a candidate intra-prediction mode that is the same as the intra-prediction mode of the current block; Based on the determined results, the intra-prediction mode of the current block is obtained; as well as Intra-frame prediction is performed on the current block based on the reference sample line and the intra-frame prediction mode; At least one of the candidate intra-prediction modes is: adding or subtracting the offset from the maximum value of the intra-prediction modes of the upper adjacent block and the intra-prediction modes of the left adjacent block of the current block. Determine whether to divide the current block into multiple sub-blocks. For some sub-blocks among the plurality of sub-blocks, skip the inverse transformation; The horizontal transformation type of the sub-block is determined based on the width of the sub-block of the current block, and the vertical transformation type of the sub-block is determined based on the height of the sub-block of the current block.

2. The video decoding method according to claim 1, characterized in that, When the difference between the intra-prediction mode of the upper adjacent block and the intra-prediction mode of the left adjacent block is 64, at least one of the candidate intra-prediction modes is: adding or subtracting 2 from the maximum value.

3. The video decoding method according to claim 1, characterized in that, The number of candidate intra-frame prediction modes varies depending on the index of the reference sample line.

4. The video decoding method according to claim 1, characterized in that, The horizontal and vertical transformation types of the sub-blocks are determined based on their shapes.

5. A video encoding method, characterized in that, include: Determine the reference sample line for the current block; Determine whether there exists a candidate intra-prediction mode that is the same as the intra-prediction mode of the current block; Based on the determined results, the intra-prediction mode of the current block is obtained; as well as Intra-prediction is performed on the current block based on the reference sample line and the intra-prediction mode. At least one of the candidate intra-prediction modes is: adding or subtracting the offset from the maximum value of the intra-prediction modes of the upper adjacent block and the intra-prediction modes of the left adjacent block of the current block. Determine whether to divide the current block into multiple sub-blocks. For some sub-blocks among the multiple sub-blocks, skip the transformation; The horizontal transformation type of the sub-block is determined based on the width of the sub-block of the current block, and the vertical transformation type of the sub-block is determined based on the height of the sub-block of the current block.

6. The video encoding method according to claim 5, characterized in that, When the difference between the intra-prediction mode of the upper adjacent block and the intra-prediction mode of the left adjacent block is 64, at least one of the candidate intra-prediction modes is: adding or subtracting 2 from the maximum value.

7. The video encoding method according to claim 5, characterized in that, The number of candidate intra-frame prediction modes varies depending on the index of the reference sample line.

8. The video encoding method according to claim 5, characterized in that, The horizontal and vertical transformation types of the sub-blocks are determined based on their shapes.

9. A video decoding device, characterized in that, include: A device for determining the reference sample line of the current block; A means for determining whether there exists a candidate intra-prediction mode that is the same as the intra-prediction mode of the current block; An apparatus for obtaining the intra-prediction mode of the current block based on the determined result; as well as A means for performing intra-frame prediction of the current block based on the reference sample line and the intra-frame prediction mode; Wherein, at least one of the candidate intra-prediction modes is: adding or subtracting the offset from the maximum value of the intra-prediction modes of the upper adjacent block and the intra-prediction modes of the left adjacent block of the current block. A means for determining whether to divide the current block into multiple sub-blocks. For some sub-blocks among the plurality of sub-blocks, skip the inverse transformation; The horizontal transformation type of the sub-block is determined based on its width, and the vertical transformation type of the sub-block is determined based on its height.

10. The video decoding apparatus according to claim 9, characterized in that, When the difference between the intra-prediction mode of the upper adjacent block and the intra-prediction mode of the left adjacent block is 64, at least one of the candidate intra-prediction modes is: adding or subtracting 2 from the maximum value.

11. The video decoding apparatus according to claim 9, characterized in that, The number of candidate intra-frame prediction modes varies depending on the index of the reference sample line.

12. The video decoding apparatus according to claim 9, characterized in that, The horizontal and vertical transformation types of the sub-blocks are determined based on their shapes.

13. A video encoding device, characterized in that, include: A device for determining the reference sample line of the current block; A means for determining whether there exists a candidate intra-prediction mode that is the same as the intra-prediction mode of the current block; An apparatus for obtaining the intra-prediction mode of the current block based on the determined result; as well as An apparatus for performing intra-frame prediction of the current block based on the reference sample line and the intra-frame prediction mode. At least one of the candidate intra-prediction modes is: adding or subtracting the offset from the maximum value of the intra-prediction modes of the upper adjacent block and the intra-prediction modes of the left adjacent block of the current block. A means for determining whether to divide the current block into multiple sub-blocks. For some sub-blocks among the multiple sub-blocks, skip the transformation; The horizontal transformation type of the sub-block is determined based on its width, and the vertical transformation type of the sub-block is determined based on its height.

14. The video encoding apparatus according to claim 13, characterized in that, When the difference between the intra-prediction mode of the upper adjacent block and the intra-prediction mode of the left adjacent block is 64, at least one of the candidate intra-prediction modes is: adding or subtracting 2 from the maximum value.

15. The video encoding apparatus according to claim 13, characterized in that, The number of candidate intra-frame prediction modes varies depending on the index of the reference sample line.

16. The video encoding apparatus according to claim 13, characterized in that, The horizontal and vertical transformation types of the sub-blocks are determined based on their shapes.

17. A computer-readable recording medium includes program instructions that, when executed by a computer component, perform the video decoding method according to any one of claims 1 to 4.

18. A computer-readable recording medium includes program instructions that, when executed by a computer component, perform the video encoding method according to any one of claims 5 to 8.

19. A method for transmitting a code stream, characterized in that, The video encoding method according to any one of claims 5 to 8 is used to generate a bitstream; and the bitstream is transmitted.