Method for decoding and encoding image and apparatus for transmitting compressed video data
By using wide angle intra prediction mode, right and lower reference samples in video signal encoding/decoding, and taking into account the forward and reverse direction of intra prediction mode, the increase in data volume in high-resolution video signal processing is solved Problem, more efficient encoding and decoding is achieved.
Patent Information
- Application Number
- CN202411540419.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2018-06-27
- Filing Date
- 2019-06-27
- Publication Date
- 2025-02-11
AI Technical Summary
The prior art faces the problem of increased transmission and storage costs caused by increased data volume when processing high-resolution and high-quality video signals.
Intra prediction is performed using wide angle intra prediction mode, right-side reference sample and lower-side reference sample when encoding/decoding of video signals, combined with forward and reverse considerations of intra prediction mode.
Through these technical means, intra prediction can be effectively performed, encoding/decoding efficiency can be improved, and transmission and storage costs can be reduced.
Smart Images

Figure CN119420906A_ABST
Abstract
Description
[0001] This application is a divisional application of invention patent application No. 201980036451.1, with the application date of June 27, 2019, international application number PCT / KR2019 / 007819, and entered the Chinese national phase on November 30, 2020, with the invention name being “Method and device for processing video signals”. Technical Field
[0002] The invention relates to a method and an apparatus for processing a video signal. Background Art
[0003] Recently, the demand for high-resolution and high-quality images, such as high-definition (HD) images and ultra-high-definition (UHD) images, has increased in various application fields. However, compared with conventional image data, higher resolution and quality image data has an increased data volume. Therefore, when the image data is transmitted by using a medium such as a conventional wired and wireless broadband network, or when the image data is stored by using a conventional storage medium, the cost of transmission and storage increases. In order to solve these problems arising as the resolution and quality of image data increase, efficient image encoding / decoding technology can be used.
[0004] The image compression technology includes various technologies, including: an inter-frame prediction technology that predicts a pixel value included in a current picture based on a previous picture or a subsequent picture of the current picture; an intra-frame prediction technology that predicts a pixel value included in the current picture by using pixel information in the current picture; an entropy coding technology that assigns a short code to a value with a high frequency of occurrence and a long code to a value with a low frequency of occurrence, etc. Image data can be effectively compressed by using such an image compression technology and can be transmitted or stored.
[0005] Meanwhile, along with the demand for high-resolution images, the demand for stereoscopic image content as a new image service is also increasing. Video compression technology for efficiently providing stereoscopic image content with high resolution and ultra-high resolution is being studied. Summary of the invention
[0006] Technical issues
[0007] The present invention provides a method and apparatus for efficiently performing intra prediction on an encoding / decoding target block when encoding / decoding a video signal.
[0008] The present invention provides a method and apparatus for performing intra prediction using a wide-angle intra prediction mode when encoding / decoding a video signal.
[0009] The present invention provides a method and apparatus for performing intra prediction using right reference samples and lower reference samples when encoding / decoding a video signal.
[0010] The present invention provides a method and apparatus for performing intra prediction in consideration of both forward and reverse directions of an intra prediction mode when encoding / decoding a video signal.
[0011] Technical problems that can be obtained from the present invention are not limited to the above-mentioned technical tasks, and a person of ordinary skill in the technical field to which the present invention belongs can clearly understand other unmentioned technical tasks according to the following description.
[0012] Technical Solution
[0013] The video signal decoding method and device according to the present invention can derive the intra prediction mode of the current block; and when the intra prediction mode is less than or equal to a threshold value and the current block is a non-square type with a width greater than a height, the intra prediction mode is modified to a wide-angle intra prediction mode. In this case, the wide-angle intra prediction mode has an angle greater than 135 degrees.
[0014] The video signal encoding method and apparatus according to the present invention can derive an intra prediction mode of a current block; and when the intra prediction mode is less than or equal to a threshold and the current block is a non-square type with a width greater than a height, the intra prediction mode is modified to a wide-angle intra prediction mode. In this case, the wide-angle intra prediction mode has an angle greater than 135 degrees.
[0015] For the video signal encoding / decoding method and apparatus according to the present invention, the threshold value may be determined based on the ratio of the width to the height of the current block.
[0016] For the video signal encoding / decoding method and apparatus according to the present invention, the wide-angle intra prediction mode may be derived by adding a predefined value to the intra prediction mode, and the predefined value may be the number of directional intra prediction modes.
[0017] For the video signal encoding / decoding method and apparatus according to the present invention, the number of wide-angle intra prediction modes available for the current block may be determined based on the ratio of the width to the height of the current block.
[0018] For the video signal encoding / decoding method and apparatus according to the present invention, when a multi-intra prediction method is applied to a current block, a non-wide-angle intra prediction mode may be applied to a first subblock of the current block, and a wide-angle intra prediction mode may be applied to a second subblock.
[0019] With the video signal encoding / decoding method and apparatus according to the present invention, samples located at the boundary of the first sub-block may be modified to values calculated by the smoothing filter.
[0020] For the video signal encoding / decoding method and apparatus according to the present invention, filtering based on a smoothing filter may be performed based on first adjacent samples of samples located at the boundary of a first subblock and samples included in the first subblock and second adjacent samples of samples included in a second subblock.
[0021] The present invention also provides a method for decoding an image, the method comprising: determining a reference sample line index of a current block, the current block having a non-square shape whose width is greater than its height; deriving an intra-frame prediction mode of the current block; comparing the intra-frame prediction mode of the current block with a threshold; when the intra-frame prediction mode is less than or equal to the threshold, modifying the intra-frame prediction mode of the current block to a wide-angle intra-frame prediction mode; and obtaining a prediction block of the current block based on the wide-angle intra-frame prediction mode, wherein the wide-angle intra-frame prediction mode has an angle greater than an angle of an upper right diagonal intra-frame prediction mode, wherein the threshold is adaptively determined based on a ratio of the width to the height of the current block, wherein the most likely mode MPM mark of the current block is used. The MPM flag is used to derive the intra-frame prediction mode of the current block, wherein, when the MPM flag has a first value, the intra-frame prediction mode of the current block is derived from the MPM candidates and the default mode, wherein, when the MPM flag has a second value, the intra-frame prediction mode of the current block is not derived from the MPM candidates and the default mode, wherein, when the MPM flag has the first value, a default mode flag indicating whether the intra-frame prediction mode of the current block is the default mode is decoded from the bitstream, wherein the default mode represents a planar mode, and wherein, when the reference sample line index of the current block is greater than a predefined value, decoding of the MPM flag from the bitstream is omitted, and the value of the MPM flag is inferred to be the first value.
[0022] The present invention also provides a method for encoding an image, the method comprising: determining a reference sample line index of a current block, the current block having a non-square shape whose width is greater than its height; determining an intra-frame prediction mode of the current block; comparing the intra-frame prediction mode of the current block with a threshold; when the intra-frame prediction mode is less than or equal to the threshold, modifying the intra-frame prediction mode of the current block to a wide-angle intra-frame prediction mode; and obtaining a prediction block of the current block based on the wide-angle intra-frame prediction mode, wherein the wide-angle intra-frame prediction mode has an angle greater than an angle of an upper right diagonal intra-frame prediction mode, wherein the threshold is adaptively determined based on a ratio of the width to the height of the current block, wherein the intra-frame prediction mode of the current block is one of an MPM candidate and a default mode. Determine a value of a most probable mode (MPM) flag, wherein, when the intra-frame prediction mode of the current block is one of the MPM candidate and the default mode, the MPM flag has a first value, wherein, when the intra-frame prediction mode of the current block is not one of the MPM candidate and the default mode, the MPM flag has a second value, wherein, when the MPM flag has the first value, a default mode flag indicating whether the intra-frame prediction mode of the current block is the default mode is encoded into a bitstream, wherein the default mode represents a planar mode, and wherein, when the reference sample line index of the current block is greater than a predefined value, encoding the MPM flag into the bitstream is omitted, and the intra-frame prediction mode of the current block is the same as one of the MPM candidate and the default mode.
[0023] The present invention also provides a device for sending compressed video data, the device comprising: a processor configured to obtain the compressed video data; and a sending unit configured to send the compressed video data, wherein obtaining the compressed video data comprises: determining a reference sample line index of a current block, the current block having a non-square shape whose width is greater than its height; determining an intra-frame prediction mode of the current block; comparing the intra-frame prediction mode of the current block with a threshold; when the intra-frame prediction mode is less than or equal to the threshold, modifying the intra-frame prediction mode of the current block to a wide-angle intra-frame prediction mode; and obtaining a prediction block of the current block based on the wide-angle intra-frame prediction mode, wherein the wide-angle intra-frame prediction mode has an angle greater than the angle of the upper right diagonal intra-frame prediction mode, wherein the threshold is adaptively determined based on a ratio of the width to the height of the current block, wherein the threshold is adaptively determined based on the ratio of the width to the height of the current block, The value of the most probable mode MPM flag is determined according to whether the intra-frame prediction mode of the current block is one of the MPM candidate and the default mode, wherein, when the intra-frame prediction mode of the current block is one of the MPM candidate and the default mode, the MPM flag has a first value, wherein, when the intra-frame prediction mode of the current block is not one of the MPM candidate and the default mode, the MPM flag has a second value, wherein when the MPM flag has the first value, a default mode flag indicating whether the intra-frame prediction mode of the current block is the default mode is encoded into a bitstream, wherein the default mode represents a planar mode, and wherein, when the reference sample line index of the current block is greater than a predefined value, encoding the MPM flag into the bitstream is omitted, and the intra-frame prediction mode of the current block is the same as one of the MPM candidate and the default mode.
[0024] It should be understood that the above-summarized features are exemplary aspects of the following detailed description of the invention and do not limit the scope of the invention.
[0025] Beneficial Effects
[0026] According to the present invention, efficient intra prediction can be performed on an encoding / decoding target block.
[0027] According to the present invention, there is an advantage that the efficiency of intra prediction can be improved by using a wide-angle intra prediction mode.
[0028] According to the present invention, there is an advantage that the efficiency of intra prediction can be improved by using right reference samples and lower reference samples.
[0029] According to the present invention, by considering both the forward and reverse directions of the intra prediction mode, there is an advantage that the efficiency of the intra prediction can be improved.
[0030] Effects that can be obtained from the present invention may not be limited to the above-mentioned effects, and other unmentioned effects may be clearly understood by a person of ordinary skill in the technical field to which the present invention pertains from the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 is a block diagram showing an apparatus for encoding a video according to an embodiment of the present invention.
[0032] Figure 2 is a block diagram showing an apparatus for decoding a video according to an embodiment of the present invention.
[0033] Figure 3 is a diagram showing partition mode candidates that can be applied to a coding block when the coding block is encoded by inter prediction.
[0034] Figure 4 An example of hierarchical division of coding blocks based on a tree structure is shown as an embodiment to which the present invention is applied.
[0035] Figure 5 1 is a diagram showing a partition shape that allows binary tree-based partitioning as an embodiment to which the present invention is applied.
[0036] Figure 6 A ternary tree partition shape is shown.
[0037] Figure 7 is a diagram showing an example of binary tree-based partitioning that allows only specific shapes.
[0038] Figure 8 is a diagram for describing an example in which information related to the number of times binary tree division is allowed is encoded / decoded according to an embodiment to which the present invention is applied.
[0039] Fig. 9 is a diagram illustrating types of predefined intra prediction modes of an apparatus for encoding / decoding an image according to an embodiment of the present invention.
[0040] Fig.10 is a diagram showing intra prediction modes available in extended intra mode.
[0041] Fig.11 is a diagram showing intra prediction modes including a wide-angle intra prediction mode.
[0042] Fig.12 is a diagram showing aspects of application of a wide-angle intra prediction mode according to the shape of a current block.
[0043] Fig.13 is a flowchart briefly illustrating an intra prediction method according to an embodiment of the present invention.
[0044] Fig.14 is a diagram showing reference sample line candidates.
[0045] Fig.15 is a diagram illustrating a method of modifying a prediction sample of a current block based on differential information of adjacent samples according to an embodiment of the present invention.
[0046] Fig.16 and Fig.17 is a diagram showing a one-dimensional reference sample group in which the reference samples are rearranged in a row.
[0047] Fig.18 is a diagram showing an example of deriving a right reference sample or a lower reference sample using a plurality of reference samples.
[0048] Fig.19 and Fig. 20 2 is a diagram for explaining how to determine right reference samples and lower reference samples for a non-square block according to an embodiment of the present invention.
[0049] Fig.21 is a diagram for explaining an example of deriving a second reference sample using a first reference sample.
[0050] Fig. 22 is a diagram showing an example of deriving right reference samples and lower reference samples by using temporary prediction samples obtained based on a planar mode.
[0051] Fig.23 is a diagram showing reference samples constituting a one-dimensional reference sample group.
[0052] Fig.24 and Fig.25 is a diagram showing the positions of a first reference target sample and a second reference target sample.
[0053] Fig.26 is a diagram showing an example of obtaining a prediction sample based on a weighted sum operation of a first reference target sample and a second reference target sample.
[0054] Fig. 27 is a diagram showing a region to which bidirectional intra prediction is applied.
[0055] Fig.28 is a diagram that identifies and indicates the directional prediction mode that allows bidirectional intra prediction.
[0056] Fig.29 is a flowchart illustrating a process of determining whether to apply a bidirectional intra prediction mode according to the present invention.
[0057] Fig.30 An embodiment to which a multi-intra prediction method is applied is shown.
[0058] Fig.31 is a diagram showing an example of applying a smoothing filter. DETAILED DESCRIPTION
[0059] Various modifications can be made to the present invention, and there are various embodiments of the present invention, examples of which will now be provided with reference to the accompanying drawings, and examples of which will be described in detail. However, the present invention is not limited thereto, and the exemplary embodiments may be interpreted as including all modifications, equivalents or alternatives within the technical concept and technical scope of the present invention. In the accompanying drawings described, similar reference numerals refer to similar elements.
[0060] The terms 'first', 'second', etc. used in the specification may be used to describe various components, but these components should not be interpreted as being limited to these terms. These terms are only used to distinguish one component from other components. For example, without departing from the scope of the present invention, a 'first' component may be referred to as a 'second' component, and a 'second' component may also be similarly referred to as a 'first' component. The term 'and / or' includes a combination of a plurality of items or any one of a plurality of items.
[0061] In the present disclosure, when an element is referred to as being "connected" or "coupled" to another element, it should be understood that it includes not only that the element is directly connected or coupled to the other element, but also that another element may exist between them. When an element is referred to as being "directly connected" or "directly coupled" to another element, it should be understood that there are no other elements between them.
[0062] The terms used in this specification are only used to describe specific embodiments and are not intended to limit the present invention. Expressions used in the singular include expressions in the plural form unless the expression has a significantly different meaning in the context. In this specification, it should be understood that terms such as "including", "having" etc. are intended to indicate the existence of features, numbers, steps, actions, elements, parts or combinations thereof disclosed in this specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, actions, elements, parts or combinations thereof may exist or may be added.
[0063] Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings. Hereinafter, the same constituent elements in the drawings are denoted by the same reference numerals, and repeated description of the same elements will be omitted.
[0064] Figure 1 is a block diagram showing an apparatus for encoding a video according to an embodiment of the present invention.
[0065] Reference Figure 1, the device 100 for encoding a video may include: a picture division module 110, prediction modules 120 and 125, a transformation module 130, a quantization module 135, a rearrangement module 160, an entropy coding module 165, an inverse quantization module 140, an inverse transformation module 145, a filter module 150 and a memory 155.
[0066] Figure 1 The components shown in are shown independently to represent the different characteristic functions in the device for encoding the video. Therefore, this does not mean that each component is composed of a separate hardware or software component unit. In other words, for convenience, each component includes each of the listed components. Therefore, at least two components in each component can be combined to form a component, or a component can be divided into multiple components to perform each function. Without departing from the essence of the present invention, the embodiment of combining each component and the embodiment of dividing a component are also included in the scope of the present invention.
[0067] In addition, some of the components may not be indispensable components for performing the basic functions of the present invention, but selective components that only improve the performance of the present invention. The present invention can be implemented by excluding components for improving performance and only including indispensable components for implementing the essence of the present invention. Structures that exclude selective components that only improve performance and only include indispensable components are also included in the scope of the present invention.
[0068] The picture partitioning module 110 may partition an input picture into one or more processing units. Here, a processing unit may be a prediction unit (PU), a transform unit (TU), or a coding unit (CU). The picture partitioning module 110 may partition a picture into a combination of a plurality of coding units, prediction units, and transform units, and may encode a picture by selecting a combination of coding units, prediction units, and transform units using a predetermined criterion (e.g., a cost function).
[0069] For example, a picture may be divided into a plurality of coding units. A recursive tree structure such as a quadtree structure may be used to divide a picture into coding units. A coding unit divided into other coding units with a picture or a maximum coding unit as a root may be divided into child nodes corresponding to the number of divided coding units. Coding units that cannot be further divided according to predetermined restrictions are used as leaf nodes. That is, when it is assumed that only square division is feasible for a coding unit, a coding unit may be divided into up to four other coding units.
[0070] Hereinafter, in an embodiment of the present invention, a coding unit may mean a unit that performs encoding or a unit that performs decoding.
[0071] The prediction unit may be one of partitions split into a square shape or a rectangular shape having the same size in a single coding unit, or the prediction unit may be one of partitions split so as to have different shapes / sizes in a single coding unit.
[0072] When a prediction unit subject to intra prediction is generated based on a coding unit and the coding unit is not a minimum coding unit, intra prediction may be performed without splitting the coding unit into a plurality of prediction units NxN.
[0073] The prediction modules 120 and 125 may include an inter prediction module 120 that performs inter prediction and an intra prediction module 125 that performs intra prediction. It may be determined whether inter prediction or intra prediction is performed for a prediction unit, and detailed information (e.g., intra prediction mode, motion vector, reference picture, etc.) according to each prediction method may be determined. Here, the processing unit subjected to prediction may be different from the processing unit for which the prediction method and detailed content are determined. For example, the prediction method, prediction mode, etc. may be determined by the prediction unit, and the prediction may be performed by the transform unit. The residual value (residual block) between the generated prediction block and the original block may be input to the transform module 130. In addition, the prediction mode information, motion vector information, etc. used for prediction may be encoded together with the residual value by the entropy encoding module 165, and may be transmitted to a device for decoding a video. When a specific encoding mode is used, it may be transmitted to a device for decoding a video by encoding the original block as it is without generating a prediction block through the prediction modules 120 and 125.
[0074] The inter-frame prediction module 120 may predict a prediction unit based on information of at least one of a previous picture or a subsequent picture of the current picture, or in some cases, may predict a prediction unit based on information of some coding regions in the current picture. The inter-frame prediction module 120 may include a reference picture interpolation module, a motion prediction module, and a motion compensation module.
[0075] The reference picture interpolation module may receive reference picture information from the memory 155, and may generate pixel information of integer pixels or less than integer pixels according to the reference picture. In the case of luma pixels, an 8-tap interpolation filter based on DCT with different filter coefficients may be used to generate pixel information of integer pixels or less than integer pixels in units of 1 / 4 pixels. In the case of chrominance signals, a 4-tap interpolation filter based on DCT with different filter coefficients may be used to generate pixel information of integer pixels or less than integer pixels in units of 1 / 8 pixels.
[0076] The motion prediction module can perform motion prediction based on the reference picture interpolated by the reference picture interpolation module. Various methods such as full search based block matching algorithm (FBMA), three-step search (TSS), new three-step search algorithm (NTS), etc. can be used as methods for calculating motion vectors. Based on the interpolated pixels, the motion vector can have a motion vector value in units of 1 / 2 pixel or 1 / 4 pixel. The motion prediction module can predict the current prediction unit by changing the motion prediction method. Various methods such as skip method, merge method, AMVP (Advanced Motion Vector Prediction) method, intra-frame block copy method, etc. can be used as motion prediction methods.
[0077] The intra prediction module 125 may generate a prediction unit based on reference pixel information adjacent to the current block, which is pixel information in the current picture. When the adjacent block of the current prediction unit is a block subject to inter-frame prediction and thus the reference pixel is a pixel subject to inter-frame prediction, the reference pixel information of the adjacent block subject to intra-frame prediction may be used to replace the reference pixel included in the block subject to inter-frame prediction. That is, when the reference pixel is unavailable, at least one reference pixel among the available reference pixels may be used to replace the unavailable reference pixel information.
[0078] The prediction mode of the intra prediction may include a directional prediction mode using reference pixel information according to a prediction direction and a non-directional prediction mode that does not use directional information when performing prediction. The mode for predicting luminance information may be different from the mode for predicting chrominance information, and in order to predict chrominance information, the intra prediction mode information for predicting luminance information or the predicted luminance signal information may be used.
[0079] When performing intra prediction, when the size of the prediction unit is the same as the size of the transform unit, intra prediction can be performed on the prediction unit based on pixels located on the left, upper left, and upper sides of the prediction unit. However, when performing intra prediction, when the size of the prediction unit is different from the size of the transform unit, intra prediction can be performed using reference pixels based on the transform unit. In addition, intra prediction using NxN partitioning can be used only for the minimum coding unit.
[0080] In the intra prediction method, according to the prediction mode, a prediction block can be generated after applying an AIS (Adaptive Intra Smoothing) filter to a reference pixel. The type of the AIS filter applied to the reference pixel may be different. In order to perform the intra prediction method, the intra prediction mode of the current prediction unit may be predicted according to the intra prediction mode of a prediction unit adjacent to the current prediction unit. When the prediction mode of the current prediction unit is predicted by using the mode information predicted according to the adjacent prediction unit, when the intra prediction mode of the current prediction unit is the same as the intra prediction mode of the adjacent prediction unit, predetermined flag information may be used to transmit information indicating that the prediction mode of the current prediction unit and the prediction mode of the adjacent prediction unit are the same as each other. When the prediction mode of the current prediction unit is different from the prediction mode of the adjacent prediction unit, entropy coding may be performed to encode the prediction mode information of the current block.
[0081] In addition, a residual block including information on a residual value, which is a difference between the prediction unit subjected to prediction and the original block of the prediction unit, may be generated based on the prediction unit generated by the prediction modules 120 and 125. The generated residual block may be input to the transform module 130.
[0082] The transform module 130 may transform the residual block including information on the residual value between the original block and the prediction unit generated by the prediction modules 120 and 125 by using a transform method such as discrete cosine transform (DCT), discrete sine transform (DST), and KLT. Whether to apply DCT, DST, or KLT in order to transform the residual block may be determined based on intra prediction mode information of the prediction unit used to generate the residual block.
[0083] The quantization module 135 may quantize the value transformed to the frequency domain by the transform module 130. The quantization coefficient may be different according to the block or importance of the picture. The value calculated by the quantization module 135 may be provided to the inverse quantization module 140 and the rearrangement module 160.
[0084] The rearrangement module 160 may rearrange coefficients of the quantized residual value.
[0085] The rearrangement module 160 can change the coefficient of the two-dimensional block form into the coefficient of the one-dimensional vector form by the coefficient scanning method. For example, the rearrangement module 160 can use a zigzag scanning method to scan from the DC coefficient to the coefficient of the high frequency domain so that the coefficient is changed into a one-dimensional vector form. According to the size of the transform unit and the intra-frame prediction mode, the zigzag scanning can be replaced by the vertical scanning of the coefficient of the two-dimensional block form in the column direction or the horizontal scanning of the coefficient of the two-dimensional block form in the row direction. That is to say, it can be determined according to the size of the transform unit and the intra-frame prediction mode which scanning method to use among the zigzag scanning, the vertical scanning and the horizontal scanning.
[0086] The entropy encoding module 165 may perform entropy encoding based on the value calculated by the rearrangement module 160. The entropy encoding may use various encoding methods such as exponential Golomb coding, context adaptive variable length coding (CAVLC), and context adaptive binary arithmetic coding (CABAC).
[0087] The entropy coding module 165 can encode various information from the rearrangement module 160 and the prediction modules 120 and 125, such as residual value coefficient information and block type information of the coding unit, prediction mode information, partition unit information, prediction unit information, transformation unit information, motion vector information, reference frame information, block interpolation information, filtering information, etc.
[0088] The entropy encoding module 165 may entropy encode coefficients of the coding unit input from the rearrangement module 160 .
[0089] The inverse quantization module 140 may inversely quantize the value quantized by the quantization module 135, and the inverse transform module 145 may inversely transform the value transformed by the transform module 130. The residual values generated by the inverse quantization module 140 and the inverse transform module 145 may be combined with the prediction units predicted by the motion estimation module, the motion compensation module, and the intra prediction module of the prediction modules 120 and 125, so that a reconstructed block may be generated.
[0090] The filter module 150 may include at least one of a deblocking filter, an offset correction unit, and an adaptive loop filter (ALF).
[0091] The deblocking filter can remove block distortion that occurs due to the boundaries between blocks in the reconstructed picture. In order to determine whether to perform deblocking, the pixels in several rows or columns included in the block can be the basis for determining whether to apply the deblocking filter to the current block. When the deblocking filter is applied to the block, a strong filter or a weak filter can be applied according to the required deblocking filter strength. In addition, when applying the deblocking filter, horizontal filtering and vertical filtering can be processed in parallel.
[0092] The offset correction module can correct the offset from the original picture in units of pixels in the picture subjected to deblocking. In order to perform offset correction on a specific picture, a method of applying an offset in consideration of edge information of each pixel or a method of dividing the pixels of the picture into a predetermined number of regions, determining the region to be subjected to performing the offset, and applying the offset to the determined region can be used.
[0093] Adaptive loop filtering (ALF) can be performed based on a value obtained by comparing a filtered reconstructed picture with an original picture. The pixels included in the picture can be divided into predetermined groups, a filter to be applied to each group in the group can be determined, and filtering can be performed separately for each group. Information on whether ALF is applied and a luminance signal can be transmitted by a coding unit (CU). The shape and filter coefficients of the filter used for ALF can be different for each block. In addition, regardless of the characteristics of the application target block, a filter for ALF of the same shape (fixed shape) can be applied.
[0094] The memory 155 may store the reconstructed block or the reconstructed picture calculated by the filter module 150. The stored reconstructed block or the reconstructed picture may be provided to the prediction modules 120 and 125 when performing inter prediction.
[0095] Figure 2 is a block diagram showing an apparatus for decoding a video according to an embodiment of the present invention.
[0096] Reference Figure 2 The apparatus 200 for decoding a video may include an entropy decoding module 210 , a rearrangement module 215 , an inverse quantization module 220 , an inverse transform module 225 , prediction modules 230 and 235 , a filter module 240 , and a memory 245 .
[0097] When a video bitstream is input from the apparatus for encoding a video, the input bitstream may be decoded according to an inverse process of the apparatus for encoding a video.
[0098] The entropy decoding module 210 may perform entropy decoding according to an inverse process of entropy encoding performed by an entropy encoding module of a device for encoding a video. For example, corresponding to a method performed by a device for encoding a video, various methods such as exponential Golomb coding, context adaptive variable length coding (CAVLC), and context adaptive binary arithmetic coding (CABAC) may be applied.
[0099] The entropy decoding module 210 may decode information about intra prediction and inter prediction performed by the apparatus for encoding a video.
[0100] The rearrangement module 215 may perform rearrangement on the bitstream entropy-decoded by the entropy decoding module 210 based on the rearrangement method used in the apparatus for encoding a video. The rearrangement module may reconstruct and rearrange coefficients in the form of a one-dimensional vector into coefficients in the form of a two-dimensional block. The rearrangement module 215 may receive information related to coefficient scanning performed in the apparatus for encoding a video, and may perform rearrangement via a method of inversely scanning the coefficients based on the scanning order performed in the apparatus for encoding a video.
[0101] The inverse quantization module 220 may perform inverse quantization based on a quantization parameter received from the apparatus for encoding a video and coefficients of the rearranged block.
[0102] The inverse transform module 225 may perform an inverse transform, i.e., inverse DCT, inverse DST, and inverse KLT, on the quantization result of the apparatus for encoding the video, which is an inverse process of the transform, i.e., DCT, DST, and KLT, performed by the transform module. The inverse transform may be performed based on a transmission unit determined by the apparatus for encoding the video. The inverse transform module 225 of the apparatus for decoding the video may selectively perform a transform scheme (e.g., DCT, DST, and KLT) according to multiple pieces of information such as a prediction method, a size of a current block, a prediction direction, and the like.
[0103] The prediction modules 230 and 235 may generate a prediction block based on the information on prediction block generation received from the entropy decoding module 210 and previously decoded block or picture information received from the memory 245 .
[0104] As described above, similar to the operation of the apparatus for encoding a video, when performing intra prediction, when the size of the prediction unit is the same as the size of the transform unit, intra prediction can be performed on the prediction unit based on pixels located on the left, upper left, and upper sides of the prediction unit. When performing intra prediction, when the size of the prediction unit is different from the size of the transform unit, intra prediction can be performed using reference pixels based on the transform unit. In addition, intra prediction using NxN partitioning can be used only for the minimum coding unit.
[0105] The prediction modules 230 and 235 may include a prediction unit determination module, an inter-frame prediction module, and an intra-frame prediction module. The prediction unit determination module may receive various information such as prediction unit information, prediction mode information of an intra-frame prediction method, information about motion prediction of an inter-frame prediction method, etc. from the entropy decoding module 210, may divide the current coding unit into prediction units, and may determine whether to perform inter-frame prediction or intra-frame prediction on the prediction unit. By using the information required in the inter-frame prediction of the current prediction unit received from the device for encoding a video, the inter-frame prediction module 230 may perform inter-frame prediction on the current prediction unit based on information of at least one of a previous picture or a subsequent picture of the current picture including the current prediction unit. Alternatively, inter-frame prediction may be performed based on information of some pre-reconstructed areas in the current picture including the current prediction unit.
[0106] In order to perform inter prediction, which mode of the skip mode, the merge mode, the AMVP mode, and the inter block copy mode to use as a motion prediction method of a prediction unit included in the coding unit may be determined for the coding unit.
[0107] The intra prediction module 235 can generate a prediction block based on pixel information in the current picture. When the prediction unit is a prediction unit subjected to intra prediction, intra prediction can be performed based on intra prediction mode information of the prediction unit received from the device for encoding the video. The intra prediction module 235 may include an adaptive intra smoothing (AIS) filter, a reference pixel interpolation module, and a DC filter. The AIS filter performs filtering on the reference pixels of the current block, and it can be determined whether to apply the filter according to the prediction mode of the current prediction unit. AIS filtering can be performed on the reference pixels of the current block by using the AIS filter information received from the device for encoding the video and the prediction mode of the prediction unit. 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.
[0108] When the prediction mode of the prediction unit is a prediction mode in which intra prediction is performed based on pixel values obtained by interpolating reference pixels, the reference pixel interpolation module may interpolate the reference pixels to generate reference pixels that are integer pixels or smaller than integer pixels. When the prediction mode of the current prediction unit is a prediction mode in which a prediction block is generated without interpolating reference pixels, the reference pixels may not be interpolated. When the prediction mode of the current block is a DC mode, a DC filter may generate a prediction block by filtering.
[0109] The reconstructed block or picture may be provided to the filter module 240. The filter module 240 may include a deblocking filter, an offset correction module, and an ALF.
[0110] Information about whether to apply a deblocking filter to a corresponding block or picture and information about which filter of a strong filter and a weak filter to apply when applying the deblocking filter can be received from a device for encoding a video. The deblocking filter of a device for decoding a video can receive information about the deblocking filter from a device for encoding a video, and can perform deblocking filtering on the corresponding block.
[0111] The offset correction module may perform offset correction on the reconstructed picture based on the type of offset correction applied to the picture when encoding is performed and offset value information.
[0112] The ALF may be applied to the coding unit based on information on whether the ALF is applied, ALF coefficient information, etc. received from the apparatus for encoding a video. The ALF information may be provided to be included in a specific parameter set.
[0113] The memory 245 may store the reconstructed picture or block to be used as a reference picture or block, and may provide the reconstructed picture to the output module.
[0114] As described above, in the embodiments of the present invention, for convenience of explanation, a coding unit is used as a term indicating a unit for encoding, but the coding unit may be used as a unit that performs decoding as well as encoding.
[0115] In addition, the current block may represent a target block to be encoded / decoded. And, according to the encoding / decoding step, the current block may represent a coding tree block (or coding tree unit), a coding block (or coding unit), a transform block (or transform unit), a prediction block (or prediction unit), etc. In the present specification, a 'unit' may represent a basic unit for performing a specific encoding / decoding process, and a 'block' may represent a sample array of a predetermined size. Unless otherwise specified, "block" and "unit" may be used to represent the same thing. For example, in the examples mentioned later, it can be understood that coding blocks and coding units have the same meaning as each other.
[0116] A picture can be encoded / decoded by being divided into basic blocks having a square shape or a non-square shape. In this case, the basic block can be referred to as a coding tree unit. The coding tree unit can be defined as a coding unit of the maximum size allowed within a sequence or slice. Information indicating whether the coding tree unit has a square shape or a non-square shape or information related to the size of the coding tree unit can be signaled through a sequence parameter set, a picture parameter set, or a slice header. The coding tree unit can be divided into partitions of smaller sizes. In this case, if it is assumed that the depth of the partition generated by splitting the coding tree unit is 1, the depth of the partition generated by splitting the partition with a depth of 1 can be defined as 2. That is, the partition generated by splitting the partition with a depth of k in the coding tree unit can be defined as a depth of k+1.
[0117] A partition of any size generated by splitting a coding tree unit may be defined as a coding unit. A coding unit may be recursively split or divided into a basic unit for performing prediction, quantization, transformation, or loop filtering, etc. For example, a partition of any size generated by splitting a coding unit may be defined as a coding unit, or may be defined as a transformation unit or a prediction unit, which is a basic unit for performing prediction, quantization, transformation, or loop filtering, etc.
[0118] Alternatively, a prediction block having the same size as or smaller than the coding block can be determined by predictive partitioning of the coding block. For the predictive partitioning of the coding block, any one of the partitioning modes (Part_mode) showing the partitioning shape of the coding block can be specified. Information for determining the partitioning index of any one of the partitioning mode candidates can be sent with a bitstream signal. Alternatively, the partitioning index of the coding block can be determined based on the size or shape of the coding block or at least one of the coding modes. The size or shape of the prediction block can be determined based on the partitioning mode specified by the partitioning index. The partitioning mode candidates may include asymmetric partitioning shapes (e.g., nLx2N, nRx2N, 2NxnU, 2NxnD). The number or type of asymmetric partitioning mode candidates that can be used by the coding block can be determined based on the size or shape of the coding block or at least one of the coding modes.
[0119] Figure 3 is a diagram showing partition mode candidates that can be applied to a coding block when the coding block is encoded by inter prediction.
[0120] When encoding a coding block by inter-frame prediction, Figure 3 Any one of the 8 partition mode candidates shown in is applied to the coding block.
[0121] On the other hand, when the coding block is encoded by intra prediction, only the square partitioning mode may be applied to the coding block. In other words, when the coding block is encoded by intra prediction, the partitioning mode, PART_2Nx2N or PART_NxN, may be applied to the coding block.
[0122] PART_NxN can be applied when the coding block has a minimum size. In this case, the minimum size of the coding block can be predefined in the encoder and decoder. Alternatively, information related to the minimum size of the coding block can be signaled in the bitstream. In an example, the minimum size of the coding block can be signaled in the slice header. Therefore, the minimum size of the coding block can be determined differently for each slice.
[0123] In another example, the partition mode candidates that the coding block can use may be determined differently according to at least one of the size or shape of the coding block. In one example, the number or type of partition mode candidates that the coding block can use may be determined differently according to at least one of the size or shape of the coding block.
[0124] Alternatively, based on the size or shape of the coding block, the type or number of asymmetric partitioning pattern candidates that the coding block can use may be determined. The number or type of asymmetric partitioning pattern candidates that the coding block can use may be determined differently according to at least one of the size or shape of the coding block. In the example, when the coding block has a non-square shape with a width greater than the height, at least one of PART_2NxN, PART_2NxnU, or PART_2NxnD may not be used as a partitioning pattern candidate for the coding block. When the coding block has a non-square shape with a height greater than the width, at least one of PART_Nx2N, PART_nLx2N, PART_nRx2N may not be used as a partitioning pattern candidate for the coding block.
[0125] Generally, the prediction block may have a size of 4×4 to 64×64. However, when the coding block is encoded by inter-frame prediction, the prediction block may be set to not have a size of 4×4 to reduce the memory bandwidth when performing motion compensation.
[0126] Based on the partition mode, the coding block may be recursively partitioned. In other words, based on the partition mode determined by the partition index, the coding block may be partitioned and each partition generated by partitioning the coding block may be defined as a coding block.
[0127] Hereinafter, the method of dividing the coding unit will be described in more detail. In the example mentioned later, the coding unit may refer to a coding tree unit or a coding unit included in a coding tree unit. In addition, the "division" generated as the coding block is divided may refer to a "coding block". The division method mentioned later can be applied when the coding block is divided into multiple prediction blocks or transform blocks.
[0128] The coding unit may be divided by at least one line. In this case, the angle of the line dividing the coding unit may be a value in the range of 0 to 360 degrees. For example, the angle of the horizontal line may be 0 degrees, the angle of the vertical line may be 90 degrees, the angle of the diagonal line in the upper right direction may be 45 degrees, and the angle of the upper left diagonal line may be 135 degrees.
[0129] When a coding unit is divided by multiple lines, the multiple lines may all have the same angle. Alternatively, at least one of the multiple lines may have an angle different from the other lines. Alternatively, the multiple lines that divide the coding tree unit or the coding unit may have a predefined angle difference (e.g., 90 degrees).
[0130] Information about the lines dividing the coding unit may be determined by a division pattern. Alternatively, information about at least one of the number, direction, angle, or position of the lines in the block may be encoded.
[0131] For convenience of description, in an example mentioned later, it is assumed that a coding unit is divided into a plurality of coding units by using at least one of a vertical line or a horizontal line.
[0132] The number of vertical lines or horizontal lines that divide the coding unit may be at least one or more. In the example, the coding unit may be divided into 2 partitions by using one vertical line or one horizontal line. Alternatively, the coding unit may be divided into 3 partitions by using two vertical lines or two horizontal lines. Alternatively, the coding unit may be divided into 4 partitions with a width and height of 1 / 2 of the coding unit by using one vertical line or one horizontal line.
[0133] When a coding unit is divided into multiple partitions by using at least one vertical line or at least one horizontal line, the partitions may have a uniform size. Alternatively, one partition may have a different size from the other partitions, or each partition may have a different size. In the example, when the coding unit is divided by two horizontal lines or two vertical lines, the coding unit may be divided into 3 partitions. In this case, the width ratio or height ratio of the 3 partitions may be n:2n:n, 2n:n:n, or n:n:2n.
[0134] In the example mentioned later, when the coding unit is divided into 4 partitions, it is called a quadtree-based partition. And, when the coding unit is divided into 2 partitions, it is called a binary tree-based partition. In addition, when the coding unit is divided into 3 partitions, it is called a ternary tree-based partition.
[0135] In the figures mentioned later, it will be shown that the coding unit is divided using one vertical line and / or one horizontal line, but it will be described that the following case is also included in the scope of the present invention: the coding unit is divided into more divisions than shown or fewer divisions than shown by using more vertical lines than shown and / or more horizontal lines than shown.
[0136] Figure 4 An example of hierarchical division of coding blocks based on a tree structure is shown as an embodiment to which the present invention is applied.
[0137] The input video signal is decoded in predetermined block units, and the basic unit for decoding the input video signal is called a coding block. A coding block may be a unit that performs intra / inter prediction, transformation, and quantization. In addition, a prediction mode (e.g., an intra prediction mode or an inter prediction mode) may be determined in units of coding blocks, and the prediction blocks included in the coding block may share the determined prediction mode. A coding block may be a square block or a non-square block of any size in the range of 8x8 to 64x64, or may be a square block or a non-square block having a size of 128x128, 256x256, or larger.
[0138] Specifically, the coding block may be hierarchically divided based on at least one of a quadtree partitioning method, a binary tree partitioning method, or a ternary tree partitioning method. Quadtree-based partitioning may mean a method of dividing a 2Nx2N coding block into four NxN coding blocks. Binary tree-based partitioning may mean a method of dividing one coding block into two coding blocks. Ternary tree-based partitioning may mean a method of dividing one coding block into three coding blocks. Even when ternary tree-based or binary tree-based partitioning is performed, square coding blocks may exist at a lower depth.
[0139] The partitions generated by the binary tree-based partitioning may be symmetric or asymmetric. In addition, the coding blocks based on the binary tree partitioning may be square blocks or non-square blocks (eg, rectangular).
[0140] Figure 52 is a diagram showing the division shape of a coding block based on binary tree division. The division shape of the coding block based on binary tree division may include a symmetric type such as 2NxN (non-square coding unit in the horizontal direction) or Nx2N (non-square coding unit in the vertical direction), or an asymmetric type such as nLx2N, nRx2N, 2NxnU, or 2NxnD. Only one of the symmetric type or the asymmetric type may be allowed as the division shape of the coding block.
[0141] The ternary tree partition shape may include at least one of a shape of dividing the coding block into 2 vertical lines or a shape of dividing the coding block into 2 horizontal lines. Three non-square partitions may be generated by the ternary tree partition.
[0142] Figure 6 A ternary tree partition shape is shown.
[0143] The ternary tree partition shape may include a shape of dividing the coding block into 2 horizontal lines or a shape of dividing the coding block into 2 vertical lines. The width ratio or height ratio of the partition generated by dividing the coding block may be n:2n:n, 2n:n:n, or n:n:2n.
[0144] The position of the partition with the largest width or height among the 3 partitions may be predefined in the encoder and the decoder. Alternatively, information showing the partition with the largest width or height among the 3 partitions may be signaled in the bitstream.
[0145] For coding units, only square partitions or symmetrically shaped non-square partitions are allowed. In this case, when the coding unit is divided into square partitions, it can correspond to a quadtree CU partition, and when the coding unit is divided into a symmetrically shaped non-square partition, it can correspond to a binary tree partition. When the coding tree unit is divided into square partitions and symmetrically shaped non-square partitions, it can correspond to a quadtree and binary tree CU partition (QTBT).
[0146] Binary tree or ternary tree based partitioning may be performed on a coding block for which quadtree based partitioning is no longer performed. A coding block generated by binary tree or ternary tree based partitioning may be divided into smaller coding blocks. In this case, at least one of quadtree partitioning, ternary tree partitioning, or binary tree partitioning may be set not to be applied to the coding block. Alternatively, for a coding block, binary tree partitioning in a predetermined direction or ternary tree partitioning in a predetermined direction may not be allowed. In an example, for a coding block generated by binary tree or ternary tree based partitioning, quadtree partitioning and ternary tree partitioning may be set to be not allowed. For the coding block, only binary tree partitioning may be allowed.
[0147] Alternatively, only the largest coding block among the three coding blocks generated by the ternary tree-based partitioning may be partitioned into smaller coding blocks. Alternatively, only the largest coding block among the three coding blocks generated by the ternary tree-based partitioning may be allowed to be partitioned based on a binary tree or partitioned based on a ternary tree.
[0148] The division shape of the lower depth division can be determined accordingly based on the division shape of the top depth division. In the example, when the top division and the lower division are divided based on the binary tree, for the lower depth division, only the binary tree-based division of the same shape as the binary tree division shape of the top depth division can be allowed. For example, when the binary tree division shape of the top depth division is 2NxN, the binary tree division shape of the lower depth division can also be set to 2NxN. Alternatively, when the binary tree division shape of the top depth division is Nx2N, the division shape of the lower depth division can also be set to Nx2N.
[0149] Alternatively, for the maximum partition among the partitions generated by ternary-tree based partitioning, binary tree partitioning in the same partitioning direction as the partitioning of the top depth or ternary tree partitioning in the same partitioning direction as the partitioning of the top depth may be set to be disallowed.
[0150] Alternatively, the partition shape of the partition of the lower depth can be determined by considering the partition shape of the partition of the top depth and the partition shape of the adjacent lower depth partition. Specifically, if the partition of the top depth is partitioned based on a binary tree, the partition shape of the partition of the top depth can be determined to avoid the same result as the partition of the top depth is partitioned based on a quadtree. In the example, when the partition shape of the partition of the top depth is 2NxN and the partition shape of the adjacent lower depth partition is Nx2N, the partition shape of the current top depth partition may not be set to Nx2N. This is because when the partition shape of the current lower depth partition is Nx2N, it leads to the same result as the partition of the top depth partition based on a quadtree of an NxN shape. When the partition shape of the partition of the top depth is Nx2N and the partition shape of the adjacent lower depth partition is 2NxN, the partition shape of the current lower depth partition may not be set to 2NxN. In other words, when the binary tree partition shape of the partition at the top depth is different from the binary tree partition shape of the adjacent lower depth partition, the binary tree partition shape of the current lower depth partition can be set to be the same as the binary tree partition shape of the partition at the top depth.
[0151] Alternatively, the binary tree division shape of the division at the lower depth may be set to be different from the binary tree division shape of the division at the top depth.
[0152] The allowed binary tree partition shape can be determined in units of sequence, slice or coding unit. In an example, the binary tree partition shape allowed by the coding tree unit can be limited to 2NxN or Nx2N shape. The allowed partition shape can be predefined in the encoder or decoder. Alternatively, information about the allowed partition shape or the disallowed partition shape can be encoded in the bit stream and sent with a signal.
[0153] Figure 7 is a diagram showing an example of binary tree-based partitioning that allows only specific shapes.
[0154] Figure 7 (a) in FIG. 1 represents an example in which only partitioning based on a binary tree of Nx2N shape is allowed, and Figure 7 (b) in FIG. 1 shows an example in which only partitioning based on a binary tree in a 2NxN shape is allowed.
[0155] In order to represent various partition shapes, information about quadtree partition, information about binary tree partition, or information about ternary tree partition may be used. The information about quadtree partition may include at least one of information indicating whether quadtree-based partition is performed or information about the size / depth of the coding block that allows quadtree-based partition. The information about binary tree partition may include at least one of the following: information indicating whether binary tree-based partition is performed, information about whether binary tree-based partition is vertical or horizontal, information about the size / depth of the coding block that allows binary tree-based partition, or information about the size / depth of the coding block that does not allow binary tree-based partition. The information about ternary tree partition may include at least one of the following: information indicating whether ternary tree-based partition is performed, information about whether ternary tree-based partition is vertical or horizontal, information about the size / depth of the coding block that allows ternary tree-based partition, or information about the size / depth of the coding block that does not allow ternary tree-based partition. The information about the size of the coding block may represent at least one minimum or maximum value of the width, height, product of width and height, or ratio of width to height of the coding block.
[0156] In an example, when the width or height of a coding block is smaller than the minimum size of allowed binary tree partitioning, or when the partition depth of the coding block is greater than the maximum depth of allowed binary tree partitioning, binary tree-based partitioning may not be allowed for the coding block.
[0157] In an example, when the width or height of a coding block is smaller than the minimum size allowed for ternary tree partitioning, or when the partition depth of the coding block is greater than the maximum depth allowed for ternary tree partitioning, ternary tree-based partitioning may not be allowed for the coding block.
[0158] Information about conditions for allowing binary tree-based or ternary tree-based partitioning may be signaled in a bitstream. Information may be encoded in units of a sequence, a picture, or a partial image (clip). A partial image may mean at least one of a slice, a tile group, a tile, a brick, a coding block, a prediction block, or a transform block.
[0159] In an example, in a bitstream, the syntax "max_mtt_depth_idx_minus1" may be encoded / decoded in the bitstream, indicating the maximum depth allowed for binary / ternary tree partitioning. In this case, max_mtt_depth_idx_minus1+1 may indicate the maximum depth allowed for binary / ternary tree partitioning.
[0160] In an example, at least one of the number of allowed binary / ternary tree partitions, the maximum depth of allowed binary / ternary tree partitions, or the number of depths of allowed binary / ternary tree partitions may be signaled at a sequence or slice level. Thus, at least one of the number of allowed binary / ternary tree partitions, the maximum depth of allowed binary / ternary tree partitions, or the number of depths of allowed binary / ternary tree partitions may be different for a first slice and a second slice. In an example, while for a first slice, binary / ternary tree partitions may be allowed at only one depth, for a second slice, binary / ternary tree partitions may be allowed at two depths.
[0161] exist Figure 8 In the example shown in Figure 8 It is shown that binary tree partitioning is performed on a coding unit having a depth of 2 and a coding unit having a depth of 3. Therefore, at least one of the following can be encoded / decoded in a bitstream: information indicating the number of times binary tree partitioning is performed in a coding tree unit (2 times), information indicating the maximum depth (depth 3) of partitions generated by binary tree partitioning in a coding tree unit, or information indicating the number of partition depths (2 depths, depth 2 and depth 3) to which binary tree partitioning is applied in a coding tree unit.
[0162] Alternatively, the number of times binary / ternary tree divisions are allowed, the depth of binary / ternary tree divisions allowed, or the number of depths of binary / ternary tree divisions allowed may be predefined in the encoder and decoder. Alternatively, the number of times binary / ternary tree divisions are allowed, the depth of binary / ternary tree divisions allowed, or the number of depths of binary / ternary tree divisions allowed may be determined based on at least one of the index of the sequence or slice or the size / shape of the coding unit. In the example, for the first slice, binary / ternary tree division may be allowed at one depth, while for the second slice, binary / ternary tree division may be allowed at two depths.
[0163] In another example, at least one of the number of times binary tree partitioning is allowed, the depth of binary tree partitioning is allowed, or the number of depths of binary tree partitioning is allowed may be set differently according to a temporal level identifier (TemporalID) of a slice or picture. In this case, the temporal level identifier (TemporalID) is used to identify each of a plurality of image layers having at least one or more perspective, space, time, or quality.
[0164] like Figure 4 As shown in , the first coding block 300 with a division depth (split depth) of k can be divided into multiple second coding blocks based on a quadtree. For example, the second coding blocks 310 to 340 can be square blocks with a width and height halved relative to the first coding block, and the division depth of the second coding block can be increased to k+1.
[0165] The second coding block 310 with a division depth of k+1 may be divided into a plurality of third coding blocks with a division depth of k+2. The division of the second coding block 310 may be performed by selectively using one of a quadtree or a binary tree according to a division method. In this case, the division method may be determined based on at least one of information indicating a quadtree-based division or information indicating a binary tree-based division.
[0166] When the second coding block 310 is divided based on a quadtree, the second coding block 310 may be divided into four third coding blocks 310a having half the width and height of the second coding block, and the division depth of the third coding block 310a may be increased to k+2. In other words, when the second coding block 310 is divided based on a binary tree, the second coding block 310 may be divided into two third coding blocks. In this case, each of the two third coding blocks may be a non-square block with one of the width and height halved relative to the second coding block, and the division depth may be increased to k+2. The second coding block may be determined as a non-square block in the horizontal direction or in the vertical direction according to the division direction, and the division direction may be determined based on information about whether the binary tree-based division is performed in the vertical direction or in the horizontal direction.
[0167] Meanwhile, the second coding block 310 may be determined as a leaf coding block that is no longer divided based on the quadtree or the binary tree, and in this case, the corresponding coding block may be used as a prediction block or a transform block.
[0168] Similar to the division of the second coding block 310, the third coding block 310a may be determined as a leaf coding block, or may be further divided based on a quadtree or a binary tree.
[0169] On the other hand, the third coding block 310b divided based on the binary tree can be further divided into a coding block 310b-2 in the vertical direction or a coding block 310b-3 in the horizontal direction based on the binary tree, and the division depth of the corresponding coding block can be increased to k+3. Alternatively, the third coding block 310b can be determined as a leaf coding block 310b-1 that is no longer divided based on the binary tree, and in this case, the corresponding coding block 310b-1 can be used as a prediction block or a transform block. However, the above-mentioned division process can be restrictively performed based on at least one of the following: information about the size / depth of the coding block that allows quadtree-based division, information about the size / depth of the coding block that allows binary tree-based division, or information about the size / depth of the coding block that does not allow binary tree-based division.
[0170] The number of candidates representing the size of the coding block may be limited to a predetermined number, or the size of the coding block in a predetermined unit may have a fixed value. In an example, the size of the coding block in a sequence or in a picture may be limited to any one of 256x256, 128x128, or 32x32. Information representing the size of the coding block in the sequence or in the picture may be signaled in a sequence header or a picture header.
[0171] As a result of quadtree and binary tree based partitioning, the coding unit can be represented as a square or rectangular shape of any size.
[0172] like Figure 4 As shown in , the first coding block 300 with a division depth (split depth) of k can be divided into multiple second coding blocks based on a quadtree. For example, the second coding blocks 310 to 340 can be square blocks with half the width and height of the first coding block, and the division depth of the second coding block can be increased to k+1.
[0173] The second coding block 310 with a division depth of k+1 may be divided into a plurality of third coding blocks with a division depth of k+2. The division of the second coding block 310 may be performed by selectively using one of a quadtree or a binary tree according to a division method. In this case, the division method may be determined based on at least one of information indicating a quadtree-based division or information indicating a binary tree-based division.
[0174] When the second coding block 310 is divided based on a quadtree, the second coding block 310 may be divided into four third coding blocks 310a whose width and height are halved relative to the second coding block, and the division depth of the third coding block 310a may be increased to k+2. In other words, when the second coding block 310 is divided based on a binary tree, the second coding block 310 may be divided into two third coding blocks. In this case, each of the two third coding blocks may be a non-square block whose width and height are halved relative to the second coding block, and the division depth may be increased to k+2. The second coding block may be determined as a non-square block in the horizontal direction or in the vertical direction according to the division direction, and the division direction may be determined based on information about whether the binary tree-based division is performed in the vertical direction or in the horizontal direction.
[0175] Meanwhile, the second coding block 310 may be determined as a leaf coding block that is no longer divided based on the quadtree or the binary tree, and in this case, the corresponding coding block may be used as a prediction block or a transform block.
[0176] Similar to the division of the second coding block 310, the third coding block 310a may be determined as a leaf coding block, or may be further divided based on a quadtree or a binary tree.
[0177] On the other hand, the third coding block 310b divided based on the binary tree can be further divided into a coding block 310b-2 in the vertical direction or a coding block 310b-3 in the horizontal direction based on the binary tree, and the division depth of the corresponding coding block can be increased to k+3. Alternatively, the third coding block 310b can be determined as a leaf coding block 310b-1 that is no longer divided based on the binary tree, and in this case, the corresponding coding block 310b-1 can be used as a prediction block or a transform block. However, the above-mentioned division process can be restrictively performed based on at least one of the following: information about the size / depth of the coding block that allows quadtree-based division, information about the size / depth of the coding block that allows binary tree-based division, or information about the size / depth of the coding block that does not allow binary tree-based division.
[0178] The number of candidates representing the size of the coding block may be limited to a predetermined number, or the size of the coding block in a predetermined unit may have a fixed value. In an example, the size of the coding block in a sequence or in a picture may be limited to any one of 256x256, 128x128, or 32x32. Information representing the size of the coding block in the sequence or in the picture may be signaled in a sequence header or a picture header.
[0179] As a result of quadtree and binary tree based partitioning, the coding unit can be represented as a square or rectangular shape of any size.
[0180] The transform skip may be set not to be used for a coding unit generated by binary tree-based partitioning or ternary tree-based partitioning. Alternatively, the transform skip may be set to be applied to at least one of a vertical direction or a horizontal direction in a non-square coding unit. In the example, when the transform skip is applied to the horizontal direction, it means that only scaling is performed without transform / inverse transform in the horizontal direction, and transform / inverse transform using DCT or DST is performed in the vertical direction. When the transform skip is applied to the vertical direction, it means that only scaling is performed without transform / inverse transform in the vertical direction, and transform / inverse transform using DCT or DST is performed in the horizontal direction.
[0181] Information about whether inverse transform for the horizontal direction is skipped or information about whether inverse transform for the vertical direction is skipped may be signaled in a bitstream. In an example, information about whether inverse transform for the horizontal direction is skipped may be a 1-bit flag 'hor_transform_skip_flag', and information about whether inverse transform for the vertical direction is skipped may be a 1-bit flag 'ver_transform_skip_flag'.
[0182] The encoder may determine whether to encode 'hor_transform_skip_flag' or 'ver_transform_skip_flag' according to the size and / or shape of the current block. In an example, when the current block has an Nx2N shape, hor_transform_skip_flag may be encoded and the encoding of ver_transform_skip_flag may be omitted. When the current block has a 2NxN shape, ver_transform_skip_flag may be encoded and hor_transform_skip_flag may be omitted.
[0183] Alternatively, based on the size and / or shape of the current block, it may be determined whether to perform transform skipping in the horizontal direction or whether to perform transform skipping in the vertical direction. In an example, when the current block has an Nx2N shape, transform skipping may be applied to the horizontal direction, and transform / inverse transform may be performed in the vertical direction. When the current block has a 2NxN shape, transform skipping may be applied to the vertical direction, and transform / inverse transform may be performed in the horizontal direction. Transform / inverse transform may be performed based on at least one of DCT or DST.
[0184] As a result of partitioning based on a quadtree, a binary tree, or a ternary tree, a coding block that is no longer divided can be used as a prediction block or a transform block. In other words, a coding block generated by quadtree partitioning or binary tree partitioning can be used as a prediction block or a transform block. In the example, a predicted image can be generated in units of coding blocks, and the difference between the residual signal, the original image, and the predicted image can be transformed in units of coding blocks. In order to generate a predicted image in units of coding blocks, motion information can be determined based on the coding blocks, or an intra-frame prediction mode can be determined based on the coding blocks. Therefore, the coding block can be encoded by using at least one of a skip mode, an intra-frame prediction, or an inter-frame prediction.
[0185] Alternatively, multiple coding blocks generated by dividing the coding block may be set to share at least one of motion information, merge candidates, reference samples, reference sample rows, or intra-frame prediction modes. In an example, when the coding block is divided by a ternary tree, the divisions generated by dividing the coding block may share at least one of motion information, merge candidates, reference samples, reference sample rows, or intra-frame prediction modes according to the size or shape of the coding block. Alternatively, only a portion of the multiple coding blocks may be set to share information, and the remaining coding blocks may be set to not share information.
[0186] In another example, a prediction block or a transform block smaller than the coding block may be used by partitioning the coding block.
[0187] Hereinafter, a method of performing intra prediction on a coding block or a prediction block or a transform block generated by splitting the coding block will be described in detail.
[0188] Fig. 9 is a diagram illustrating types of predefined intra prediction modes of an apparatus for encoding / decoding a video according to an embodiment of the present invention.
[0189] The apparatus for encoding / decoding a video may perform intra prediction using one of the predefined intra prediction modes. The predefined intra prediction modes for intra prediction may include a non-directional prediction mode (eg, planar mode, DC mode) and 33 directional prediction modes.
[0190] Alternatively, in order to improve the accuracy of intra-frame prediction, more than 33 directional prediction modes can be defined. That is, M extended directional prediction modes (M>33) can be defined by further subdividing the angle of the directional prediction mode. A directional prediction mode different from the existing 33 directional prediction modes can be derived based on at least one of the existing 33 directional prediction modes.
[0191] Therefore, we can define the ratio Fig. 935 intra prediction modes are shown. If the number of available intra prediction modes is greater than Fig. 9 35 as shown in , the available intra prediction mode can be called extended intra mode.
[0192] Fig.10 2 is a diagram showing intra prediction modes available in extended intra mode. In extended intra mode, available intra prediction modes may be configured with 2 non-directional prediction modes and 65 extended directional prediction modes.
[0193] The number of available intra prediction modes may be set equally for the luminance component and the chrominance component. Alternatively, the number of available intra prediction modes for each color component may be different. For example, any one of 67 intra prediction modes may be selected and used for the luminance component, and any one of 35 intra prediction modes may be selected and used for the chrominance component.
[0194] Alternatively, the number of available intra prediction modes may be different depending on the color format. For example, in a 4:2:0 format, 67 intra prediction modes may be set to be available for luma components, and 35 intra prediction modes may be set to be available for chroma components. In a 4:4:4 format, 67 intra prediction modes may be set to be available for both luma components and chroma components.
[0195] Alternatively, the number of available intra prediction modes may be different depending on the size and / or shape of the block. Specifically, the number of available intra prediction modes may be determined to be 35 or 67 depending on the size and / or shape of the PU, TU, or CU. For example, when the size of the CU, TU, or PU is less than 64×64, or when the CU, TU, or PU is asymmetrically divided, the number of available intra prediction modes may be 35. On the other hand, when the size of the CU, TU, or PU is 64x64 or larger, or when the CU, TU, or PU is symmetrically divided, the number of available intra prediction modes may be set to 67.
[0196] Alternatively, for Intra_2Nx2N partitioning, the number of available directional intra prediction modes may be set to 65. On the other hand, for Intra_NxN partitioning, the number of available directional intra prediction modes may be set to 33.
[0197] Whether to apply the extended intra mode may be determined based on at least one of the size, shape, or color component of the block. In this case, information indicating the size or shape of the block to which the extended intra mode is applied may be signaled via the bitstream. The information may be signaled at a sequence, picture, or slice level. Thus, the size of the block to which the extended intra mode is applied may be different for each sequence, picture, or slice. For example, in a first slice, the extended intra mode may be set to apply to blocks larger than 64x64 (e.g., CU, TU, or PU), while in a second slice, the extended intra mode may be set to apply to blocks larger than 32x32.
[0198] Information indicating the size of a block to which the extended intra mode is applied may be obtained by taking a logarithmic value from the size of a reference block and then subtracting a predetermined value. For example, "log2_extended_intra_mode_size_minus4" obtained by subtracting an integer 4 from a value obtained by taking a logarithmic value from the size of a reference block may be encoded. For example, when the value of log2_extended_intra_mode_size_minus4 is 0, it indicates that the extended intra mode is applied to a block having a size of 16x16 or more or a block having a size greater than 16x16, and when the value of log2_extended_intra_mode_size_minus4 is 1, it may indicate that the extended intra mode is applied to a block having a size of 32x32 or more or a block having a size greater than 32x32.
[0199] As described above, the number of available intra prediction modes may be determined based on at least one of the chrominance component, color format, size, or shape of the block. Intra prediction for the current block may be performed based on at least one of the available intra prediction modes.
[0200] In addition, the number of intra prediction mode candidates (e.g., the number of MPMs) for determining the intra prediction mode of the current block to be encoded / decoded may also be determined according to at least one of the color component, color format, or size or shape of the block. Figure 8 The intra prediction modes shown are more numerous than the intra prediction modes. For example, by further subdividing Figure 8 The directional prediction mode shown in FIG. 1 may also use 129 directional prediction modes and 2 non-directional prediction modes. At least one of the color component, color format component, size, or shape of the block in the example described above may be considered to determine whether to use the directional prediction mode. Figure 8 A greater number of intra prediction modes than the intra prediction modes shown in .
[0201] Assuming the horizontal prediction mode angle is 0 degrees and the vertical prediction mode angle is 90 degrees, then Fig. 9 and Fig.10 The directional prediction mode shown has an angle between -45 degrees and 135 degrees. That is, in general, intra-frame prediction based on a directional intra-frame prediction mode within an angle range can be performed. However, when the angle formed by an object existing between the current block and an adjacent block is not within the angle range, the accuracy of the intra-frame prediction may be reduced. Therefore, when the current block is a square, intra-frame prediction is performed using a directional prediction mode between -45 degrees and 135 degrees, and when the current block is non-square, intra-frame prediction can be performed using an intra-frame prediction mode not included in the angle range. Directional prediction modes outside the range of -45 degrees to 135 degrees may be referred to as wide-angle intra-frame prediction modes. In addition, intra-frame prediction based on a wide-angle intra-frame prediction mode may be referred to as wide-angle intra-frame prediction.
[0202] Fig.11 is a diagram showing intra prediction modes including a wide angle intra prediction mode. Fig.11 In the example shown, a wide-angle intra prediction mode within the range of -45 to -90 degrees (intra prediction mode indices -1 to -14) or a wide-angle intra prediction mode within the range of 135 to 180 degrees (intra prediction mode indices 67 to 80) may be defined.
[0203] Fewer wide-angle intra prediction modes than shown may be defined, or more wide-angle intra prediction modes than shown may be defined. As an example, only wide-angle intra prediction modes between -45 degrees and -67 degrees and wide-angle intra prediction modes between 135 degrees and 157 degrees may be defined.
[0204] Alternatively, the range of available wide-angle intra prediction modes may be determined based on the size or shape of the current block. For example, when the current block is in the form of N×2N or 2N×N, a wide-angle intra prediction mode between -45 degrees and -55 degrees or a wide-angle intra prediction mode between 135 degrees and 145 degrees may be used. On the other hand, when the current block is in the form of NxkN or kNxN (where k is an integer greater than or equal to 4), a wide-angle intra prediction mode between -45 degrees and -67 degrees or a wide-angle intra prediction mode between 135 degrees and 157 degrees may be used.
[0205] When the current block is a non-square with a height smaller than the width, a wide-angle intra-frame prediction mode with an angle less than -45 degrees may be available, and when the current block is a non-square with a width larger than the height, a wide-angle intra-frame prediction mode with an angle greater than 135 degrees may be available.
[0206] Fig.12 is a diagram showing aspects of application of a wide-angle intra prediction mode according to the shape of a current block.
[0207] like Fig.12 In the example shown in (a), when the current block has a non-square shape with a height greater than a width, intra prediction using a wide-angle intra prediction mode having an angle greater than 135 degrees may be performed.
[0208] On the other hand, Fig.12 In the example shown in (b), when the current block has a non-square shape in which the width is greater than the height, intra prediction using a wide-angle intra prediction mode having an angle less than -45 degrees may be performed.
[0209] Whether wide angle intra prediction is allowed can be determined based on predetermined coding information. The coding information may include at least one of the size, shape, or segmentation type of the current block. As an example, wide angle intra prediction may be allowed when the size of the current block is greater than a threshold or when the size of the current block is less than a threshold. The threshold may represent a maximum size or a minimum size for which wide angle intra prediction is allowed. The threshold may be predefined by an encoder and a decoder. Alternatively, information for determining the threshold may be signaled via a bitstream.
[0210] As another example, when the partition type of the upper node is a first type, wide angle intra prediction may be allowed, and when the partition type is a second type, wide angle intra prediction may not be allowed. The first type includes at least one of quadtree partitioning, binary tree partitioning, or ternary tree partitioning, and the second type includes a partition type other than the first type.
[0211] As another example, wide angle intra prediction may be allowed only when the ratio of the height to the width of the current block is greater than or equal to a first threshold or less than or equal to a second threshold. The first threshold and the second threshold may represent a maximum size or a minimum size that allows wide angle intra prediction. The first threshold and the second threshold may be predefined by an encoder and a decoder. Alternatively, information for determining the first threshold and the second threshold may be signaled via a bitstream.
[0212] As another example, information indicating whether wide-angle intra prediction is allowed may be signaled through a bitstream.
[0213] With reference to the drawings to be described later, a method of determining an intra prediction mode of a current block to be encoded / decoded and a method of performing intra prediction using the determined intra prediction mode will be described through the drawings.
[0214] With reference to the drawings to be described later, a method of determining an intra prediction mode of a current block to be encoded / decoded and a method of performing intra prediction using the determined intra prediction mode will be described through the drawings.
[0215] Fig.13is a flowchart briefly illustrating an intra prediction method according to an embodiment of the present invention.
[0216] First, a reference sample line index of a current block may be determined (S1110). The reference sample line index may be used to determine a reference sample line for performing intra prediction of the current block. Intra prediction of the current block may be performed using at least one reference sample line indicated by the reference sample line index among a plurality of reference sample lines.
[0217] Fig.14 is a diagram showing reference sample line candidates.
[0218] The Nth reference sample line may include an upper reference sample and a left reference sample, wherein the y coordinate of the upper reference sample is N less than the uppermost row of the current block, and the x coordinate of the left reference sample is N less than the leftmost column of the current block. Fig.14 In the example shown, the reference sample index is N-1. The Nth reference sample line may include upper reference samples from P(-N, -N) to P(2W+N-1, -N) and left reference samples from P(-N, -N) to P(-N, 2H+N-1). For example, reference sample line 1 may include upper reference samples from P(-2, -2) to P(2W+1, -2) and left reference samples from P(-2, -2) to P(-2, 2H+1).
[0219] The number of reference sample lines that can be used as reference sample line candidates may be 1, 2, 3, 4, or more. Fig.14 In the example shown, reference sample line 0, reference sample line 1, and reference sample line 3 may be used as reference sample line candidates.
[0220] The number of reference sample lines or the positions of reference sample lines that can be used as reference sample line candidates can be determined based on at least one of the size, shape, intra-frame prediction mode or position of the current block. For example, when the current block is located near the boundary of the CTU or the boundary of the tile, the number of reference sample line candidates can be 1 (for example, reference sample line 0). When the current block is not located near the boundary of the CTU or the boundary of the tile, the number of reference sample line candidates can be 3 (for example, reference sample line 0, reference sample line 1, reference sample line 3). For example, when the intra-frame prediction mode of the current block is within a first range, reference sample line 0, reference sample line 1 and reference sample line 3 can be used as reference sample line candidates. When the intra-frame prediction mode of the current block is within a second range, reference sample line 0, reference sample line 2 and reference sample line 2 can be used as reference sample line candidates.
[0221] Information specifying at least one of the reference sample line candidates may be signaled through a bitstream. When the number of available reference sample line candidates is 1, encoding of index information may be omitted. When index information is not encoded, reference sample line 0 adjacent to the current block may be considered selected.
[0222] Alternatively, at least one of the reference sample line candidates may be selected based on at least one of the size, shape, position, or intra prediction mode of the current block. For example, when at least one of the width, height, and size of the current block is less than a predefined value, reference sample line 0 may be selected. For example, when the current block is located on the upper boundary of a CTU or tile, reference sample line 0 may be selected.
[0223] Alternatively, the reference sample line may be selected based on whether the current block is divided into sub-blocks. For example, when the current block is divided into sub-blocks, the reference sample line 0 may be selected.
[0224] Alternatively, when the current block is divided into a plurality of sub-blocks, a reference sample line may be determined for each sub-block. Alternatively, all sub-blocks may be defined to have the same reference sample line index.
[0225] When the current block is divided into a plurality of subblocks, intra prediction may be performed in units of subblocks.
[0226] Multiple reference sample lines may be selected for the current block. Whether to use multiple reference sample lines to perform intra prediction may be adaptively determined according to the size, shape, or intra prediction mode of the current block. For example, when the intra prediction mode of the current block is a non-directional prediction mode or a predefined directional intra prediction mode, multiple reference sample lines may not be used. The predefined directional intra prediction mode may include at least one of a vertical intra prediction mode, a horizontal intra prediction mode, and a diagonal intra prediction mode.
[0227] The plurality of reference sample lines may include a reference sample line selected by the index information and a reference sample line obtained by adding or subtracting a predefined value from the reference sample line index. Here, the predefined value may be 1 or 2.
[0228] Alternatively, a plurality of index information may be signaled through a bitstream, each of the plurality of index information indicating a different reference sample line.
[0229] The prediction sample may be obtained based on at least one of a weighted sum operation, an average operation, a minimum operation, or a maximum operation of the plurality of reference samples. Here, the reference sample line index including at least one of the plurality of reference samples may be different from the reference sample line index including the remaining reference samples.
[0230] Next, the intra prediction mode of the current block may be determined (S1220).
[0231] In order to determine the intra prediction mode of the current block, the most probable mode (MPM) candidate may be derived based on the intra prediction mode of the neighboring block adjacent to the current block. Here, the neighboring block may include at least one of the blocks adjacent to the upper side, lower side, left side, right side or corner of the current block. For example, the MPM candidate may be derived based on the intra prediction mode of the upper neighboring block and the intra prediction mode of the left neighboring block. The upper neighboring block may include an upper neighboring sample at a predefined position having a smaller y coordinate value than the uppermost row of the current block. The predefined position may be (0, -1), (W / 2, -1), (W-1, -1) or (W, -1). (0, 0) indicates the position of the upper left sample included in the current block, and W indicates the width of the current block. The left neighboring block may include a left neighboring sample at a predefined position having a smaller x coordinate value than the leftmost column of the current block. The predefined position may be (-1, 0), (-1, H / 2), (-1, H-1) or (-1, H). H represents the height of the current block. If the neighboring block is encoded in inter prediction, the intra prediction mode of the neighboring block or the intra prediction mode of the collocated block of the current block may be used to include the MPM candidate.
[0232] The number of MPM (most probable mode) candidates included in the candidate list may be 3, 4, 5, 6 or more. The maximum number of MPM candidates may be a fixed value predetermined in the image encoder / decoder. Alternatively, the maximum number of MPM candidates may be determined based on the properties of the current block. The property may include at least one of the following items: the position / size / shape of the current block, the number / type of intra-prediction modes that the current block can use, the color type (luminance / chrominance) of the current block, the color format of the current block, or whether the current block is divided into multiple sub-blocks. Alternatively, information indicating the maximum number of MPM candidates may be signaled via a bitstream. The information indicating the maximum number may be signaled at at least one of a sequence level, a picture level, a slice level, or a block level.
[0233] The intra prediction mode of the adjacent block, the directional intra prediction mode similar to the adjacent block, or the default mode may be set as the MPM candidate. A directional intra prediction mode similar to the adjacent block may be derived by adding or subtracting a predefined value from the intra prediction mode of the adjacent block. The predefined value may be an integer of 1, 2 or more. The predefined value may be adaptively determined according to the number of available intra prediction modes. For example, when the number of available intra prediction modes is 35, the predefined value may be set to 1, and when the number of available intra prediction modes is 67, the predefined value may be set to 2. In addition, when the available intra prediction mode is 131, the predefined value may be set to 4. When both the intra prediction mode of the first adjacent block and the intra prediction mode of the second adjacent block are directional prediction modes, a similar directional intra prediction mode may be derived based on the maximum value of the intra prediction mode of the first adjacent block and the intra prediction mode of the second adjacent block. The default mode may include at least one of a DC mode, a plane mode, a horizontal prediction mode, a vertical prediction mode, an upper right diagonal mode, a lower left diagonal mode, or an upper left diagonal mode. When the number of MPM candidates included in the MPM candidate list is less than the maximum number, a default mode different from the MPM candidate previously inserted in the MPM candidate list may be inserted into the MPM candidate list. The number, type, or priority of the default mode may be different according to at least one of a reference sample line index of the current block, whether an intra prediction technique in units of subblocks is applied to the current block, or a partition type of the current block.
[0234] The MPM candidate index may be determined according to a predefined order. For example, when the intra prediction mode of the left neighboring block is different from the intra prediction mode of the upper neighboring block, the index value of the intra prediction mode of the left neighboring block may be smaller than the index value of the intra prediction mode of the upper neighboring block.
[0235] Alternatively, the MPM candidate index may be determined according to the size / type of the current block. For example, when the current block has a non-square shape with a height greater than the width, the intra-prediction mode of the upper neighboring block may have an index value smaller than the index value of the intra-prediction mode of the left neighboring block. When the current block has a non-square shape with a width greater than the height, the intra-prediction mode of the left neighboring block may have an index value smaller than the index value of the intra-prediction mode of the upper neighboring block.
[0236] Alternatively, only N predefined intra prediction modes can be used as MPM candidates. When the intra prediction mode of the adjacent block is different from the predefined N intra prediction modes, the intra prediction mode of the adjacent block is transformed into one of the predefined N intra prediction modes, and the transformed intra prediction mode can be set as the MPM candidate. A predefined table can be used for the transformation of the intra prediction mode, or a scaling operation based on a predetermined value can be used. Here, the predefined table can define the mapping relationship between the intra prediction modes.
[0237] For example, when the neighboring block is encoded in non-extended intra mode (i.e., the available intra prediction mode is 35), and when the current block is encoded in extended intra mode (i.e., the available intra prediction mode is 67), the intra prediction mode index of the neighboring block can be transformed into the intra prediction mode index in the extended intra mode. For example, when the intra prediction mode of the left neighboring block is 10 (horizontal mode), it can be converted to index 18 corresponding to the horizontal mode in the extended intra mode.
[0238] Alternatively, when the adjacent block is encoded in the extended intra mode and the current block is encoded in the non-extended intra mode, the intra prediction mode index of the adjacent block can be transformed into the intra prediction mode index in the non-extended intra mode. For example, when the intra prediction mode index of the upper adjacent block is 50 (vertical mode), it can be transformed into the index 26 corresponding to the vertical mode in the non-extended intra mode.
[0239] When the reference sample line index selected by step S1110 is greater than or equal to a predefined value, the candidate list may be set to not include the DC mode and / or the planar mode. The predefined value may be an integer of 1 or greater.
[0240] When the current block is divided into a plurality of sub-blocks, the current candidate list may be set to not include the DC mode and / or the plane mode. In addition, the default mode may be included in the candidate list. In this case, the number or type of the default mode may be different depending on the partition type of the current block.
[0241] The following information may be signaled through the bitstream: the information indicating whether the candidate list includes the same MPM candidate as the intra prediction mode of the current block. For example, the MPM flag may be signaled through the bitstream. When the value of the MPM flag is 0, it indicates that the candidate list does not include the same MPM candidate as the intra prediction mode of the current block. When the value of the MPM flag is 1, it indicates that the candidate list includes the same MPM candidate as the intra prediction mode of the current block.
[0242] When the MPM flag indicates that there is an MPM candidate identical to the intra prediction mode of the current block, index information of one of the MPM candidates included in the candidate list may be sent by a bitstream signal. The MPM candidate specified by the index information may be set as the intra prediction mode of the current block. When encoding / signaling of the MPM flag is omitted, it may be determined that the MPM candidate identical to the intra prediction mode of the current block is included in the candidate list.
[0243] On the other hand, when the MPM flag indicates that there is no MPM candidate that is the same as the intra-frame prediction mode of the current block, the remaining mode information may be signaled through the bitstream. The remaining mode information is used to specify any one of the remaining intra-frame prediction modes other than the MPM candidates included in the candidate list. Using the remaining mode information, the intra-frame prediction mode of the current block may be determined. When the MPM flag indicates that there is no MPM candidate that is the same as the intra-frame prediction mode of the current block, the MPM candidates may be rearranged in ascending order. Thereafter, the mode value indicated by the remaining mode information may be sequentially compared with the rearranged MPM candidates to derive the intra-frame prediction mode of the current block. For example, when the mode value indicated by the remaining mode information is less than or equal to the rearranged MPM candidate, 1 may be added to the mode value. If there is no MPM candidate that is smaller than the updated mode value, the updated mode value may be determined as the intra-frame prediction mode of the current block.
[0244] When the reference sample line index selected by step S1110 is greater than or equal to a predefined value, the encoding of the MPM flag can be omitted. Therefore, when the reference sample line index is greater than or equal to a predefined value, the intra prediction mode of the current block can be set to the MPM candidate indicated by the index information.
[0245] As described above, when the reference sample line index is greater than or equal to a predefined value, the candidate list can be set to not include the DC mode and / or the plane mode. Therefore, when the reference sample line index is greater than or equal to the predefined value, the DC mode and / or the plane mode cannot be applied to the current block.
[0246] Information indicating whether the intra-frame prediction mode of the current block is a default mode may be sent by a bitstream signal. The default mode may include at least one of DC, plane, horizontal mode, vertical mode, or diagonal mode. For example, a default mode flag indicating whether the intra-frame prediction mode of the current block is the same as the default mode may be sent by a bitstream signal. The default mode flag may include at least one of the following: a flag indicating whether the intra-frame prediction mode of the current block is a plane mode, a flag indicating whether the intra-frame prediction mode of the current block is a DC mode, a flag indicating whether the intra-frame prediction mode of the current block is a vertical mode, a flag indicating whether the intra-frame prediction mode of the current block is a horizontal mode, or a flag indicating whether the intra-frame prediction mode of the current block is a diagonal mode.
[0247] For example, is_planar_not_flag may be signaled through a bitstream. When the value of the flag is 0, it indicates that the intra prediction mode of the current block is the planar mode. When the value of the flag is 1, it indicates that the intra prediction mode of the current block is not the planar mode.
[0248] When the MPM flag indicates that there is an MPM candidate that is the same as the intra prediction mode of the current block, the default mode flag may be signaled. When the default mode flag indicates that the intra prediction mode of the current block is not the default mode, the MPM candidate specified by the index information may be set as the intra prediction mode of the current block.
[0249] When the intra prediction mode index of the current block is less than or equal to the first threshold and the current block is a non-square shape with a width greater than a height, the intra prediction mode can be modified to a wide-angle intra prediction mode. Here, the first threshold can be determined based on the shape of the current block. For example, the first threshold can be derived by adding the ratio of the width to the height to the predefined index. Therefore, as the ratio of the width to the height of the current block increases, the number of available wide-angle intra prediction modes can also increase. The predefined index can be 8. When the above conditions are met, the intra prediction mode can be modified to a wide-angle intra prediction mode by adding a predefined value to the intra prediction mode index. The modified wide-angle intra prediction mode can have an angle greater than 135 degrees. The predefined value can be the number of directional prediction modes other than the wide-angle intra prediction mode. For example, when following Fig. 9 , the predefined value can be set to 33, and when following Fig.10 In the example shown, the predefined value can be set to 65.
[0250] When the intra prediction mode index of the current block is greater than or equal to the second threshold and the current block has a non-square shape with a height greater than the width, the intra prediction mode can be modified to a wide-angle intra prediction mode. Here, the second threshold can be determined based on the shape of the current block. For example, the second threshold can be derived by subtracting the ratio of the height to the width from a predefined index. Therefore, as the ratio of the height to the width of the current block increases, the number of available wide-angle intra prediction modes can also increase. The predefined index can be 60. When the above conditions are met, the intra prediction mode can be modified to a wide-angle intra prediction mode by subtracting a predefined value from the intra prediction mode index. The modified wide-angle intra prediction mode can have an angle less than -45 degrees. The predefined value can be the number of intra prediction modes other than the wide-angle intra prediction mode. For example, when following Fig. 9 , the predefined value can be set to 35, and when following Fig.10In the example shown, the predefined value can be set to 67.
[0251] When the current block is divided into a plurality of sub-blocks, the plurality of sub-blocks may share the intra-prediction mode of the current block. Alternatively, the intra-prediction mode may be determined for each sub-block. For example, information and / or residual mode may be encoded / decoded for each sub-block. Alternatively, information indicating whether the intra-prediction mode of the sub-block is the same as the sub-block on which the previous encoding / decoding has been completed may be signaled via a bitstream. Alternatively, the intra-prediction mode of the current sub-block may be derived by adding / subtracting an offset to the intra-prediction mode of the sub-block on which the previous encoding / decoding has been completed.
[0252] When the current block is divided into a plurality of sub-blocks, encoding of the MPM flag may be omitted. Therefore, when the current block is divided into a plurality of sub-blocks, the intra prediction mode of the current block may be set to the MPM candidate indicated by the index information.
[0253] Multiple sub-blocks can share the intra prediction mode of the current block.
[0254] The intra prediction mode of each of the luma component and the chroma component may be determined independently. Alternatively, the intra prediction mode of the chroma component may be determined according to the intra prediction mode of the luma component.
[0255] Specifically, as shown in Table 1 below, the intra prediction mode of the chrominance component may be determined based on the intra prediction mode of the luminance component.
[0256] [Table 1]
[0257]
[0258]
[0259] In Table 1, intra_chroma_pred_mode represents information signaled to specify an intra prediction mode of a chroma component, and IntraPredModeY indicates an intra prediction mode of a luma component.
[0260] Next, the reference samples of the current block may be derived (S1130). For example, when the Nth reference sample line is selected by step S1110, the upper reference samples from P(-N, -N) to P(2W+N-1, -N) and the left reference samples from P(-N, -N) to P(-N, 2H+N-1) may be derived.
[0261] The reference sample may be derived from a reconstructed sample that has been encoded / decoded before the current block. The reconstructed sample may represent a state before applying the loop filter or a state after applying the loop filter.
[0262] A predetermined intra-frame filter may be applied to a reference sample. Filtering a reference sample using an intra-frame filter may be referred to as reference sample smoothing. The intra-frame filter may include at least one of a first intra-frame filter applied in a horizontal direction or a second intra-frame filter applied in a vertical direction. One of the first intra-frame filter or the second intra-frame filter may be selectively applied according to the position of the reference sample. Alternatively, two intra-frame filters may be repeatedly applied to one reference sample. At least one of the filter coefficients in the first intra-frame filter or the second intra-frame filter may be (1, 2, 1), but is not limited thereto.
[0263] Filtering may be adaptively performed based on at least one of the intra prediction mode of the current block or the size of the transform block for the current block. For example, when the intra prediction mode of the current block is a DC mode, a vertical mode, or a horizontal mode, filtering may not be performed. When the size of the transform block is N×M, filtering may not be performed. Here, N and M may be the same value or different values, or may be 4, 8, 16 or greater. For example, if the size of the transform block is 4×4, filtering may not be performed. Alternatively, it may be determined whether filtering is performed based on the result of a comparison of a predefined threshold with the difference between the intra prediction mode and the vertical mode (or horizontal mode) of the current block. For example, filtering may be performed when the difference between the intra prediction mode and the vertical mode of the current block is greater than a threshold. As shown in Table 2, a threshold may be defined for each size of the transform block.
[0264] [Table 2]
[0265] 8x8 Transform 16x16 Transform 32x32 Transform Threshold 7 1 0
[0266] The intra filter may be determined as one of a plurality of intra filter candidates predefined in the apparatus for encoding / decoding a video. To this end, a separate index of the intra filter for the current block may be specified in the plurality of intra filter candidates by signaling. Alternatively, the intra filter may be determined based on at least one of the size / shape of the current block, the size / shape of the transform block, information on filter strength, or a change in surrounding samples.
[0267] Next, intra prediction may be performed using the intra prediction mode and reference samples of the current block ( S1140 ).
[0268] The prediction sample may be obtained by using the intra prediction mode and the reference sample of the current block. When multiple reference sample lines are selected, the prediction sample may be obtained based on a weighted operation or an average operation of reference samples belonging to different reference sample lines. As an example, the prediction sample may be derived based on a weighted sum operation of a first reference sample belonging to a first reference sample line and a second reference sample belonging to a second reference sample line. In this case, the weight applied to the first reference sample and the second reference sample may have the same value. Alternatively, the weight applied to each reference sample may be determined based on the distance between the prediction target sample and the reference sample. For example, in the first reference sample and the second reference sample, the weight applied to the reference sample having a close distance to the prediction target sample may have a larger value than the weight applied to other reference samples.
[0269] However, in the case of intra prediction, boundary samples of adjacent blocks may be used, and therefore, the quality of the predicted picture may be reduced. Therefore, a correction process may be performed on the predicted samples generated by the above prediction process, and the reference Fig.15 However, the correction process is not limited to being applied only to intra-prediction samples, but can be applied to inter-prediction samples or reconstructed samples.
[0270] Fig.15 is a diagram illustrating a method of correcting a prediction sample of a current block based on differential information of adjacent samples according to an embodiment of the present invention.
[0271] The prediction samples of the current block may be corrected based on differential information of a plurality of adjacent samples of the current block. The correction may be performed on all prediction samples in the current block, or may be performed on prediction samples in a predetermined partial area. The partial area may be a row / column or a plurality of rows / columns, and these may be preset areas for correction in a device for encoding / decoding a video. For example, correction may be performed on a row / column located at the boundary of the current block, or correction may be performed on a plurality of rows / columns away from the boundary of the current block. Alternatively, the partial area may be variably determined based on at least one of the size / shape of the current block or the intra prediction mode.
[0272] The neighboring samples may belong to neighboring blocks located at the upper side, the left side, and the upper left corner of the current block. The number of neighboring samples used for correction may be two, three, four, or more. The positions of the neighboring samples may be variably determined according to the positions of the prediction samples as the correction target in the current block. Alternatively, some of the neighboring samples may have fixed positions regardless of the positions of the prediction samples as the correction target, and the remaining neighboring samples may have variable positions according to the positions of the prediction samples as the correction target.
[0273] The differential information of adjacent samples may represent differential samples between adjacent samples, or may represent a value obtained by scaling the differential samples by a predetermined constant value (e.g., one, two, three, etc.). Here, the predetermined constant value may be determined in consideration of the following positions: the position of the prediction sample as the correction target, including the position of the column or row of the prediction sample as the correction target, the position of the prediction sample within the column, row, etc.
[0274] For example, as shown in Formula 1, when the intra prediction mode of the current block is a vertical mode, the final prediction sample can be obtained using the differential sample between the upper left adjacent sample p(-1, -1) and the adjacent sample p(-1, y) adjacent to the left boundary of the current block.
[0275] [Formula 1]
[0276] P′(0,y)=P(0,y)+((p(-1,y)-p(-1,-1))>>1 for y=0...N-1
[0277] For example, as shown in Formula 1, when the intra prediction mode of the current block is a horizontal mode, the final prediction sample can be obtained using the differential sample between the upper left adjacent sample p(-1, -1) and the adjacent sample p(x, -1) adjacent to the upper boundary of the current block.
[0278] [Formula 2]
[0279] P′(x,0)=p(x,0)+((p(x,-1)-p(-1,-1))>>1 for x=0...N-1
[0280] For example, as shown in Formula 2, when the intra prediction mode of the current block is a vertical mode, the final prediction sample can be obtained using the difference sample between the upper left adjacent sample p (-1, -1) and the adjacent sample p (-1, y) adjacent to the left boundary of the current block. Here, the difference sample can be added to the prediction sample, or the difference sample can be scaled by a predetermined constant value and then added to the prediction sample. The predetermined constant value for scaling can be determined differently according to the column and / or row. For example, the prediction sample can be corrected as shown in Formulas 3 and 4.
[0281] [Formula 3]
[0282] P′(0,y)=P(0,y)+((p(-1,y)-p(-1,-1))>>1 for y=0...N-1
[0283] [Formula 4]
[0284] P′(1,y)=P(1,y)+((p(-1,y)-p(-1,-1))>>2 for y=0...N-1
[0285] For example, when the intra prediction mode of the current block is the horizontal mode, the final prediction sample can be obtained using the difference sample between the upper left adjacent sample p (-1, -1) and the adjacent sample p (x, -1) adjacent to the left boundary of the current block. This is the same as described above in the horizontal mode. For example, the prediction sample can be corrected as shown in the following formulas 5 and 6.
[0286] [Formula 5]
[0287] P′(x,0)=p(x,0)+((p(x,-1)-p(-1,-1))>>1 for x=0...N-1
[0288] [Formula 6]
[0289] P′(x, 1)=P(x, 1)+((p(x, -1)-p(-1, -1))>>2 for x=0...N-1
[0290] When the intra prediction mode of the current block is a directional prediction mode, the intra prediction of the current block can be performed based on the directionality of the directional prediction mode. For example, Table 3 shows the intra directional parameters intraPredAng from mode 2 to mode 34, which are Fig. 9 Directional intra prediction modes are shown.
[0291] [Table 3]
[0292]
[0293]
[0294] In Table 3, 33 directional intra prediction modes are described by way of example, but more or fewer directional intra prediction modes may be defined. The intra direction parameters of the current block may be determined based on a lookup table defining a mapping relationship between the directional intra prediction modes and the intra direction parameters. Alternatively, the intra direction parameters of the current block may be determined based on information signaled by a bitstream.
[0295] Depending on the directionality of the directional intra prediction mode, at least one of the left reference sample or the upper reference sample may be used to perform intra prediction of the current block. Here, the upper reference sample may be a reference sample having a y-axis coordinate smaller than the prediction target sample (x, 0) included in the upper row in the current block (e.g., (-1, -1) to (2W-1, -1)), and the left reference sample may be a reference sample having an x-axis coordinate smaller than the prediction target sample (0, y) included in the leftmost column in the current block (e.g., (-1, -1) to (-1, 2H-1)).
[0296] According to the directionality of the intra prediction mode, the reference samples of the current block may be rearranged in one dimension. Specifically, in the case where both the upper reference sample and the left reference sample should be used for intra prediction of the current block, it is assumed that both the upper reference sample and the left reference sample are arranged in a line in the vertical direction or the horizontal direction, and the reference sample of each prediction target sample may be selected.
[0297] For example, when the intra direction parameter is negative (eg, intra prediction modes corresponding to modes 11 to 25 in Table 3), the upper reference samples and the left reference samples may be rearranged horizontally or vertically to form a one-dimensional reference sample group P_ref_1D.
[0298] Fig.16 and Fig.17 is a diagram showing a one-dimensional reference sample group in which the reference samples are rearranged in a row.
[0299] Whether to rearrange the reference samples in the vertical direction or in the horizontal direction may be determined according to the directionality of the intra prediction mode. Fig.16 In the example shown, when the intra prediction mode is toward the left (e.g., in Fig. 9 In the example shown, the intra prediction mode index is between 11 and 18), the upper reference sample of the current block can be rotated counterclockwise to generate the following one-dimensional reference sample group, in which the left reference sample and the upper reference sample are arranged in the vertical direction.
[0300] On the other hand, Fig.17 In the example shown, when the intra prediction mode is toward the upper side (for example, in Fig. 9 In the example shown, the intra prediction mode index is between 19 and 25), the left reference sample of the current block can be rotated clockwise to generate the following one-dimensional reference sample group, in which the left reference sample and the upper reference sample are arranged in the horizontal direction.
[0301] If the intra-frame direction parameter of the current block is not negative, only the left reference sample or the upper reference sample can be used to perform intra-frame prediction of the current block. Therefore, for the intra-frame prediction mode whose intra-frame direction parameter is not negative, only the left reference sample or the upper reference sample can be used to reconstruct the one-dimensional reference sample group.
[0302] Based on the intra-frame direction parameter, a reference sample determination index iIdx may be derived, where the reference sample determination index iIdx is used to specify at least one reference sample for predicting a prediction target sample. In addition, a weight-related parameter i fact , weight-related parameter i factFor determining the weight applied to each reference sample based on the intra-frame direction parameter. For example, Formula 7 shows an example of deriving reference sample determination index and weight-related parameters.
[0303] [Formula 7]
[0304] iIdx=(y+1)*(P ang / 32)
[0305] ifact=[(y+1)*P ang ]31
[0306] As shown in Formula 7, iIdx and iIdx are variably determined according to the slope of the directional intra prediction mode. fact In this case, the reference sample specified by iIdx may correspond to an integer pixel.
[0307] Based on the reference sample determination index, at least one reference sample may be specified for each prediction sample. For example, the position of the reference sample in a one-dimensional reference sample group used to predict the prediction target sample in the current block may be specified based on the reference sample determination index. Based on the reference sample at the specified position, a prediction image (i.e., prediction sample) of the prediction target sample may be generated.
[0308] A prediction image of a prediction target sample may be generated based on one or more reference samples according to an intra prediction mode of a current block.
[0309] For example, when a virtual angle line extending from a prediction target sample passes through an integer pixel position in a one-dimensional reference sample group (i.e., a reference sample at an integer position), a prediction image of the prediction target sample can be generated by copying the reference sample at the integer pixel position or scaling the reference sample while considering the position between the reference sample at the integer pixel position and the prediction target sample. The virtual angle line may refer to a line extending in one direction or in two directions along the angle of the intra-prediction mode of the current block or the slope of the intra-prediction mode. As an example, the following formula 8 shows an example of generating a prediction image P(x, y) of a prediction target sample at a position (x, y) by copying a reference sample P_ref_1D(x+iIdx+1) specified by the intra-prediction mode of the current block.
[0310] [Formula 8]
[0311] P(x, y) = P_ref_1D(x+iIdx+1)
[0312] On the other hand, when the virtual angle line extending from the prediction target sample does not pass through the integer pixel position, a plurality of reference samples can be used to obtain a predicted image of the prediction target sample. The predicted image of the prediction target sample can be generated by linearly interpolating a reference sample adjacent to the position where the virtual angle line passes and at least one adjacent reference sample adjacent to the reference sample. Alternatively, the predicted image of the prediction target sample can be obtained by performing a tap filter-based interpolation on the reference sample and at least one adjacent reference sample. The number of taps of the interpolation filter can be a natural number of 2 or greater. Specifically, depending on the number of reference samples to be interpolated, the number of taps of the tap filter can be an integer of 2, 3, 4, 5, 6 or more.
[0313] As an example, when a virtual angle line extending from a prediction target sample passes between two integer pixel positions, a prediction image of the prediction target sample can be generated by using at least one of the reference samples at the two positions where the virtual angle line passes or the reference samples at the two integer pixel positions and at least one adjacent reference sample. Here, the adjacent reference sample may include at least one of the reference samples adjacent to the left / right side or the upper / lower side of the reference sample. As an example, the following formula 9 shows an example of generating a prediction sample P(x, y) of a prediction target sample by interpolating two or more reference samples.
[0314] [Formula 9]
[0315] P(x,y)=(32-i fact )32*P_ref_1D(x+iIdx+1)+i fact / 32*P_ref_1D(x+iIdx+2)
[0316] The coefficients of the interpolation filter may be determined based on the weight-related parameters ifact. As an example, the coefficients of the interpolation filter may be determined based on the distance between the integer pixels (ie, the integer position of each reference sample) located on the corner line and the fractional pixels.
[0317] The following formula 10 shows a case where the number of taps of the tap filter is 4.
[0318] [Formula 10]
[0319] P(x,y)-f(0)*P_ref_1D(x+iIdx-1)+f(1)*P_ref_1D(x+iIdx)+f(2)*P_ref_1D(x+iIdx+1)+f(3)*P_ref_1D(x+iIdx-2)
[0320] As in the example shown in Formula 10, a predicted image of a predicted target sample can be obtained by interpolating a plurality of continuous reference samples. In this case, when at least one of the N continuous reference samples is not included in the one-dimensional reference sample group, the value of the reference sample can be replaced with a predefined value or a value of an adjacent reference sample. As an example, when a sample at a position (x+iIdx-1) is not included in the one-dimensional reference sample group, the reference sample value at the position can be replaced with a predefined value or a value of an adjacent reference sample (e.g., P_ref_1D(x+iIdx)). Alternatively, when a sample at a position (x+iIdx+2) is not included in the one-dimensional reference sample group, the reference sample value at the position can be replaced with a predefined value, a precalculated value, or a value of an adjacent reference sample (e.g., P_ref(x+iIdx+1)). Here, the predefined value may be an integer including 0. The precalculated value may be a value determined by the bit depth. Alternatively, the predefined value may be calculated based on an average value, a minimum value, or a maximum value of at least one reference sample.
[0321] The multi-tap filter may have a straight shape. As an example, a straight multi-tap filter using a plurality of continuous reference samples in the horizontal direction or the vertical direction may be applied. Alternatively, the multi-tap filter may have a polygonal shape such as a square or a cross. As an example, a cross-shaped multi-tap filter may be used, which uses a reference sample and reference samples adjacent to all four sides of the reference sample. The shape of the multi-tap filter may be variably determined based on the size, shape, or intra-prediction mode of the current block.
[0322] As shown in Formulas 8 to 10, generating a prediction sample by interpolating a reference sample using the directionality of intra prediction may be referred to as an intra prediction sample interpolation technique.
[0323] When using intra-frame prediction sample interpolation technology, a large number of tap numbers of tap filters do not necessarily guarantee an improvement in prediction accuracy. For example, in the case where the size of the current block is an asymmetric coding unit such as 2x16 or a small-size block such as 4x4 in which one of the height or width is significantly larger than the other, the use of a tap filter with 4 or more taps may result in excessive smoothing of the predicted image. Therefore, the type of the tap filter can be adaptively determined according to the size, shape or intra-frame prediction mode of the current block. Here, the type of the tap filter can be defined by at least one of the number of taps, filter coefficients, filter strength (strong / weak), filtering direction or filter type. The number of filter taps or filter coefficients can be variably determined according to the filter strength. In addition, according to the type of the tap filter, the application direction of the tap filter can be determined, such as horizontal interpolation, vertical interpolation or horizontal and vertical interpolation. The application direction of the tap filter can be variably set in units of lines (rows or columns) or samples in the current block.
[0324] Specifically, the type of tap filter to be used can be determined based on the width or height of the current block. For example, when at least one of the width or height of the current block is less than a predetermined value, the intra-frame prediction sample interpolation technique can be performed by using a 2-tap filter instead of a 4-tap filter. On the other hand, when both the width and height of the current block are greater than or equal to a predetermined value, a 4-tap filter can be used to perform the intra-frame prediction sample interpolation technique. Here, the predefined value can represent a value such as 4, 8, or 16.
[0325] Alternatively, the type of tap filter to be used may be determined according to whether the width and height of the current block are the same. For example, in the case where the width and height of the current block are different values, a 2-tap filter may be used instead of a 4-tap filter to perform the intra-frame prediction sample interpolation technique. On the other hand, in the case where the width and height of the current block have the same value, a 4-tap filter may be used to perform the intra-frame prediction sample interpolation technique.
[0326] Alternatively, the type of tap filter to be used may be determined based on the ratio of the width and height of the current block. For example, when the ratio of the width (w) to the height (h) of the current block (i.e., w / h or h / w) is less than a predefined threshold, a 2-tap filter may be used instead of a 4-tap filter to perform the intra-frame prediction sample interpolation technique; on the other hand, when the ratio of the width and height of the current block is greater than or equal to the predefined threshold, a 4-tap filter may be used to perform the intra-frame prediction sample interpolation technique.
[0327] Alternatively, the type of the tap filter can be determined according to the intra-frame prediction mode, shape or size of the current block. For example, when the current block is a 2x16 type coding unit and the intra-frame prediction mode of the current block is an intra-frame prediction mode belonging to the horizontal range, a tap filter with a tap number of n can be used to perform the intra-frame prediction sample interpolation technology. On the other hand, when the current block is a 2x16 type coding unit and the intra-frame prediction mode of the current block is an intra-frame prediction mode belonging to the vertical direction range, a tap filter with a tap number of m can be used to perform the intra-frame prediction sample interpolation technology.
[0328] On the other hand, when the current block is a 16x2 type coding unit and the intra-frame prediction mode of the current block is an intra-frame prediction mode belonging to the horizontal direction range, a tap filter with a tap number of n can be used to perform the intra-frame prediction sample interpolation technology. On the other hand, when the current block is a 16x2 type coding unit and the intra-frame prediction mode of the current block is an intra-frame prediction mode belonging to the vertical direction range, a tap filter with a tap number of m can be used to perform the intra-frame prediction sample interpolation technology.
[0329] Here, the horizontal range may indicate a predetermined range including intra prediction modes in the horizontal direction, and the vertical range may indicate a predetermined range including intra prediction modes in the vertical direction. For example, based on 35 intra prediction modes, the horizontal direction range may indicate an intra prediction mode between mode 11 and mode 18, and the vertical direction range may indicate an intra prediction mode between mode 19 and mode 27.
[0330] In addition, n and m are constants greater than 0, and n and m may have different values. Alternatively, n and m may be set to have the same value, but at least one of the filter coefficients or filter strengths of the n-tap filter and the m-tap filter may be set differently.
[0331] When intra prediction is performed based on the directional prediction mode or DC mode, there is a problem that the image quality may deteriorate at the block boundary. On the other hand, when intra prediction is performed based on the planar mode, there is an advantage that the quality degradation of the image at the block boundary is relatively small compared to the prediction mode.
[0332] In the intra prediction based on the planar mode, a predicted image may be obtained through weighted prediction of a first predicted image in a horizontal direction and a second predicted image in a vertical direction.
[0333] Herein, a first predicted image may be generated based on a reference sample placed in the horizontal direction of the prediction target sample. As an example, a first predicted image may be generated based on a weighted sum of reference samples placed in the horizontal direction of the prediction target sample. In this case, the weight applied to each reference sample may be determined based at least on the distance from the prediction target sample or the size of the current block. The reference sample placed in the horizontal direction of the prediction target sample may include a left reference sample having the same y coordinate as the prediction target sample and a right reference sample having the same y coordinate as the prediction target sample. The right reference sample may be derived from the upper reference sample of the current block. For example, the right reference sample may be derived by copying the value of the upper reference sample placed on the same vertical line as the right reference sample. Alternatively, the right reference sample may be derived as a weighted sum or average of multiple upper reference samples. Herein, the upper reference sample placed on the same vertical line as the right reference sample may include a reference sample adjacent to the upper right corner of the current block. The reference sample adjacent to the upper right corner may have the same x coordinate as the right reference sample. Alternatively, the position of the upper reference sample used to derive the right reference sample may be variably determined according to the shape, size, or position of the prediction target sample of the current block.
[0334] The second predicted image may be generated based on the reference samples placed in the vertical direction of the prediction target sample. As an example, the second predicted image may be generated based on the weighted sum of the reference samples placed in the vertical direction of the prediction target sample. In this case, the weight applied to each reference sample may be determined in consideration of the distance from the prediction target sample or the size of the current block. The reference samples placed in the vertical direction of the prediction target sample may include an upper reference sample and a lower reference sample; the upper reference sample is located on the same vertical line as the prediction target sample and has the same x coordinate as the prediction target sample, and the lower reference sample is located on the same vertical line as the prediction target sample and has the same x coordinate as the prediction target sample. The lower reference sample may be derived from the left reference sample of the current block. For example, the lower reference sample may be derived by copying the value of the left reference sample placed on the same horizontal line as the lower reference sample. Alternatively, the lower reference sample may be derived as a weighted sum or average of multiple left reference samples. Herein, the left reference sample placed on the same horizontal line as the lower reference sample may include a reference sample adjacent to the lower left corner of the current block. The reference sample adjacent to the lower left corner may have the same y coordinate as the lower reference sample. Alternatively, the position of the upper reference sample used to derive the lower reference sample may be variably determined according to the shape, size, or position of the prediction target sample of the current block.
[0335] Alternatively, at least one of the right reference sample and the lower reference sample may be derived using both the left reference sample and the upper reference sample.
[0336] As an example, a weighted sum or an average value of the upper reference sample and the left reference sample of the current block may be determined as the value of at least one of the right reference sample or the lower reference sample.
[0337] Alternatively, the lower left reference sample and the upper right reference sample may be used to derive a lower right reference sample adjacent to the lower right corner of the current block, and the derived lower right reference sample may then be used to derive the right reference sample and the lower reference sample. The lower right reference sample may be derived based on a weighted sum or average of the upper right reference sample and the left reference sample of the current block. In this case, the weights applied to the upper right reference sample and the left reference sample may have the same value, or may be determined based on the width / height of the current block.
[0338] Once the lower right reference sample is determined, the right reference sample can be derived by interpolating the lower right reference sample and the upper right reference sample, and the lower reference sample can be derived by interpolating the lower right reference sample and the lower left reference sample. In this case, the coefficient of the interpolation filter can be determined based on the size of the current block, the shape of the current block, the distance to the lower right reference sample, the distance to the upper right reference sample, or the distance to the lower left reference sample.
[0339] In order to derive the right reference sample or the left reference sample, a reference sample of a fixed position may be used, or a reference sample adaptively selected according to the position of the prediction target sample may be used. For example, the right reference sample may be derived by using an upper right reference sample that is independent of the position of the prediction target sample, or the right reference sample may be derived by using a left reference sample selected according to the position of the prediction target sample (e.g., a reference sample having the same y-axis coordinate as the prediction target sample) or an upper reference sample selected according to the position of the prediction target sample (e.g., a reference sample having the same x-axis coordinate as the prediction target sample). Alternatively, the lower reference sample may be derived using a lower left reference sample (regardless of the position of the prediction target sample), or the lower reference sample may be derived using a left reference sample selected according to the position of the prediction target sample (e.g., a reference sample having the same y-axis coordinate as the prediction target sample) or an upper reference sample selected according to the position of the prediction target sample (e.g., a reference sample having the same x-axis coordinate as the prediction target sample).
[0340] Fig.18 is a diagram showing an example of deriving a right reference sample or a lower reference sample using a plurality of reference samples. It is assumed that a current block is a block having a size of W×H.
[0341] Reference Fig.18 (a), first, based on the weighted sum or average of the upper right reference sample P (W, -1) and the lower left sample P (-1, H) of the current block, the lower right reference sample P (W, H) can be generated. In this case, the weights applied to the upper right reference sample and the left reference sample can be set equally or the weights applied to the upper right reference sample and the left reference sample can be determined based on the width W and height H of the current block. For example, when the current block is non-square, the weight applied to the upper right reference sample can be determined as W / (W+H), and the weight applied to the lower left reference sample can be determined as H / (W+H).
[0342] In addition, a right reference sample P(W, y) for predicting the target sample (x, y) may be generated based on the lower right reference sample P(W, H) and the upper right reference sample P(W, -1). For example, the right prediction sample P(W, y) may be calculated as a weighted sum or average value of the lower right reference sample P(W, H) and the upper right reference sample P(W, -1). In addition, a lower reference sample P(x, H) for predicting the target sample (x, y) may be generated based on the lower right reference sample P(W, H) and the lower left reference sample P(-1, H). For example, the lower reference sample P(x, H) may be calculated as a weighted sum or average value of the lower right reference sample P(W, H) and the left reference sample P(-1, H).
[0343] like Fig.18 As shown in (b), when the right reference sample and the lower reference sample are generated, the first prediction sample Ph(x, y) and the second prediction sample Pv(x, y) can be generated by using the generated prediction samples. In this case, the first prediction sample Ph(x, y) can be generated based on the weighted sum of the left reference sample P(-1, y) and the right reference sample P(W, y), and the second prediction sample Pv(x, y) can be generated based on the weighted sum of the upper reference sample P(x, -1) and the lower reference sample P(x, H).
[0344] Fig.19 and Fig. 20 is a diagram for explaining determination of right reference samples and lower reference samples for a non-square block according to an embodiment of the present invention.
[0345] As in Fig.19 In the example shown, when the current block is a (N / 2)×N non-square block, the right reference sample can be derived based on the upper right reference sample P(N / 2,-1), and the lower reference sample can be derived based on the lower left reference sample P(-1,N).
[0346] Alternatively, the right reference sample or the lower reference sample may be derived based on at least one of a weighted sum, an average value, a minimum value, or a maximum value of the upper right reference sample P(N / 2, -1) and the lower left reference sample P(-1, N). For example, the right reference sample may be derived based on a weighted sum or an average value of P(N / 2, -1) and P(-1, N), or the right reference sample may be derived by interpolating the lower right reference sample and the upper right reference sample. After the lower right reference sample P(N / 2, N) is derived based on P(N / 2, -1) and P(-1, N). Alternatively, the lower reference sample may be derived based on a weighted sum or an average value of P(N / 2, -1) and P(-1, N), or the lower reference sample may be derived by interpolating the lower right reference sample and the lower left reference sample after the lower right reference sample P(N / 2, N) is derived based on P(N / 2, -1) and P(-1, N).
[0347] On the other hand, Fig. 20 In the example shown, when the current block is an Nx(N / 2) non-square block, the right reference sample can be derived based on the upper right reference sample P(N, -1), and the lower reference sample can be derived based on the lower left reference sample P(-1, N / 2).
[0348] Alternatively, the right reference sample or the lower reference sample may be derived based on at least one of a weighted sum, an average value, a minimum value, or a maximum value of the upper left reference sample P(N, -1) and the lower left reference sample P(-1, N / 2). For example, the right reference sample may be derived based on a weighted sum or an average value of P(N, -1) and P(-1, N / 2), or the right reference sample may be derived by interpolating the lower right reference sample and the upper right reference sample after deriving the lower right reference sample P(N, N / 2) based on P(N, -1) and P(-1, N / 2). Alternatively, the lower reference sample may be derived based on a weighted sum or an average value of P(N, -1) and P(-1, N / 2), or the lower reference sample may be derived by interpolating the lower right reference sample and the lower left reference sample after deriving the lower right reference sample P(N, N / 2) based on P(N, -1) and P(-1, N / 2).
[0349] In reference Figures 18 to 20In the described example, the lower reference sample may be derived based on at least one of the lower left reference sample of the current block placed on the same horizontal line as the lower reference sample or the upper right reference sample of the current block placed on the same vertical line as the right reference sample, and the right reference sample may be derived based on at least one of the upper right reference sample of the current block placed on the same vertical line as the right reference sample or the lower left reference sample of the current block placed on the same horizontal line as the lower reference sample. Unlike the described example, the right reference sample or the left reference sample may be derived based on at least one of the upper center reference sample or the left center reference sample. For example, after the lower center sample is derived using the upper center sample and the lower left reference sample, the lower sample may be generated by interpolation or extrapolation of the lower center sample and the lower left sample. In addition, after the right center sample is derived by using the left center sample and the upper right sample, the lower sample may be generated by interpolation or extrapolation of the right center sample and the upper right sample.
[0350] The positions of the reference samples used to generate the first predicted image and the second predicted image may be determined differently according to the size or shape of the current block. For example, the positions of the upper reference samples or the left reference samples used to derive the right reference samples or the lower reference samples may be determined differently according to the size or shape of the current block.
[0351] As an example, when the current block is a square block of N×N size, the right reference sample may be derived based on the upper right reference sample P(N,-1), and the lower reference sample may be derived based on the lower left reference sample P(-1,N). Alternatively, when the current block is a square block of N×N size, the right reference sample and the lower reference sample may be derived based on at least one of the weighted sum, average value, minimum value, or maximum value of the upper right reference sample P(N,-1) and the lower left reference sample P(-1,N).
[0352] On the other hand, when the current block is a non-square block of Nx2 / N size, the lower center reference sample P(N / 2, N / 2) may be derived based on the upper center reference sample P(N / 2, -1) and the lower left reference sample P(-1, N / 2), and then the lower reference sample may be derived based on the derived lower center reference sample. For example, the lower reference sample may be derived by interpolation or extrapolation of the lower center reference sample and the lower left reference sample. Alternatively, when the current block is a non-square block of N / 2×N size, the right center reference sample P(N / 2, N / 2) may be derived based on the upper right reference sample P(N / 2, -1) and the left center reference sample P(-1, N / 2), and then the right reference sample may be derived based on the derived right center reference sample. For example, the right reference sample may be derived by interpolation or extrapolation of the right center reference sample and the upper right reference sample.
[0353] The first predicted image may be calculated based on weighted prediction of reference samples disposed on the same horizontal line as the prediction target sample. Likewise, the second predicted image may be calculated based on weighted prediction of reference samples disposed on the same vertical line as the prediction target sample.
[0354] In addition to the above examples, the first predicted image or the second predicted image may be generated using an average value, a minimum value, or a maximum value of the reference samples.
[0355] The method of deriving the reference sample may be set differently, or the method of deriving the first prediction image or the second prediction may be set differently, depending on whether the prediction target sample is included in a predetermined area of the current block, the size or shape of the current block, etc. Specifically, the number of reference samples or the position of the reference samples used to derive the right reference sample or the lower reference sample may be determined differently, or the weight or number of reference samples used to derive the first prediction image or the second prediction image may be set differently, depending on the position of the prediction target sample.
[0356] For example, the right side reference sample for generating the first prediction image of the prediction target sample included in the predetermined area can be derived using only the upper side reference sample, and the right side reference sample for generating the first prediction image of the prediction target sample included outside the predetermined area can be derived based on the weighted sum or average value of the upper side reference sample and the left side reference sample.
[0357] For example, Fig.19 In the example shown, when the current block is a non-square block with a height greater than a width, a right reference sample of a prediction target sample at a position (x, y) in a predetermined area included in the current block can be derived from P(N / 2, -1). For example, the right reference sample of the prediction target sample included in the predetermined area can be generated by copying the value of the reference sample P(N / 2, -1). On the other hand, the right reference sample of the prediction target sample at a position (x', y') outside the predetermined area included in the current block can be derived based on a weighted sum or average of P(N / 2, -1) and P(-1, N). For example, the right reference sample of the prediction target sample outside the predetermined area can be generated by interpolating the lower right reference sample P(N / 2, N) and the upper right reference sample P(N / 2, -1) derived based on P(N / 2, -1) and P(-1, N).
[0358] Alternatively, for example, Fig. 20In the example shown, when the current block is a non-square block with a width greater than a height, a lower reference sample of a prediction target sample at a position (x, y) in a predetermined area included in the current block can be derived from P(-1, N / 2). For example, the lower reference sample of the prediction target sample included in the predetermined area can be generated by copying the value of the reference sample P(-1, N / 2). On the other hand, the lower reference sample of the prediction target sample at a position (x', y') outside the predetermined area included in the current block can be derived based on a weighted sum or average of P(N, -1) and P(-1, N / 2). For example, the lower reference sample of the prediction target sample outside the predetermined area can be generated by interpolating the lower right reference sample P(N, N / 2) and the lower left reference sample P(-1, N / 2) derived based on P(N, -1) and P(-1, N / 2).
[0359] As another example, a first prediction image or a second prediction image of a prediction target sample included in a predetermined area may be generated based on a weighted sum of reference samples, and a first prediction image or a second prediction image of a prediction target sample outside the predetermined area may be generated using an average value, a minimum value, or a maximum value of the reference samples or using only one reference sample having a predefined position among the reference samples. Fig.19 In the example shown, when the current block is a non-square block with a height greater than a width, only one of the right reference sample P(N / 2, y) derived from P(N / 2, -1) and the left reference sample at the position P(-1, y) may be used to generate a first predicted image of a predicted target sample at a position (x, y) included in a predetermined region of the current block. On the other hand, a first predicted image of a predicted target sample at a position (x', y') not included in the predetermined region may be generated based on a weighted sum or average of the right reference sample P(N / 2, -1) derived from P(N / 2, -1) and the reference sample at the position of P(1, y').
[0360] Alternatively, if Fig. 20 In the example shown, when the current block is a non-square block having a width greater than a height, only one of the lower reference sample P(x, N / 2) derived from P(-1, N / 2) or the upper reference sample at the position P(x, -1) may be used to generate a second predicted image of a predicted target sample at the position (x, y) included in a predetermined region of the current block. On the other hand, a second predicted image of a predicted target sample at the position (x', y') not included in the predetermined region may be generated based on a weighted sum or average of the lower reference sample P(x', N / 2) derived from P(-1, N / 2) and the reference sample at the position P(1, y').
[0361] In the above-mentioned embodiment, the predetermined area may be at least one sample line adjacent to the boundary of the current block or one of the remaining areas other than the sample line. Herein, the boundary of the current block may include at least one of a left boundary, a right boundary, an upper boundary or a lower boundary. In addition, the number or position of the boundaries for defining the predetermined area may be set differently according to the shape of the current block. Alternatively, the predetermined area may be the shape of a block adjacent to one corner of the current block. In this case, the size and shape of the predetermined area may be determined based on at least one of the size or shape of the current block.
[0362] In the planar mode, the final predicted image may be derived based on a weighted sum, an average value, a minimum value, or a maximum value of the first predicted image and the second predicted image.
[0363] For example, the following formula 11 shows an example of generating a final predicted image P based on a weighted sum of a first predicted image Ph and a second predicted image Pv.
[0364] [Formula 11]
[0365] P(x,y)=(w*P h (x,y)+(1-w)*P v (x,y)+N)>>(log2(N)+1)
[0366] In Formula 11, the prediction weight w may be different according to the shape, size, or position of the prediction target sample of the current block.
[0367] As an example, the prediction weight w may be derived in consideration of the width of the current block, the height of the current block, the ratio of the width to the height, etc. When the current block is a non-square block having a width greater than the height, w may be set to apply a higher weight to the first prediction image. On the other hand, when the current block is a non-square block having a height greater than the width, w may be set to apply a higher weight to the second prediction image.
[0368] As an example, when the current block is a square, the prediction weight w may have a value of 1 / 2. On the other hand, when the current block is a non-square block with a height greater than a width (e.g., (N / 2)×N), the prediction weight w may be set to 1 / 4. In addition, when the current block is a non-square block with a width greater than a height (e.g., Nx(N / 2)), the prediction weight w may be set to 3 / 4.
[0369] In addition to the planar mode, intra-frame prediction based on the DC mode or the directional intra-frame prediction mode can also be performed by using reference samples other than the left reference samples and the upper reference samples. In the following embodiments, the left reference samples and the upper reference samples will be referred to as first reference samples, and the reference samples other than the left reference samples and the upper reference samples will be referred to as second reference samples. As an example, the second reference sample may include a right reference sample and / or a lower reference sample of the current block. Herein, the lower reference sample may refer to a reference sample having a y-axis coordinate larger than the predicted target sample of the lower row in the current block, and the right reference sample may refer to a reference sample having an x-axis coordinate larger than the predicted target sample of the rightmost column in the current block.
[0370] Whether to perform intra prediction using the second reference sample may be determined based on at least one of the size, shape, or intra prediction mode of the current block or the position of the prediction target sample. For example, whether to perform intra prediction using the second reference sample may be determined based on whether the intra prediction mode of the current block is a vertical mode, a horizontal mode, or a diagonal mode. Alternatively, intra prediction of the prediction target sample included in the predetermined area of the current block is performed by using the second reference sample, and intra prediction of the prediction target sample not included in the predetermined area of the current block is performed by using the first reference sample.
[0371] Alternatively, information indicating whether to use the second reference sample may be signaled through a bitstream. The information may be a 1-bit flag, an index for determining the intra prediction mode of the current block, and the like.
[0372] Alternatively, whether to use the second reference sample may be determined based on whether the second reference sample is used in a neighboring block of the current block.
[0373] The second reference sample may be generated based on the first reference sample. As an example, the second reference sample may be configured by changing the order of the first reference sample, or the second reference sample may be derived using the first reference sample at a specific position.
[0374] Fig.21 is a diagram for explaining an example of deriving a second reference sample using a first reference sample.
[0375] First, a lower right reference sample P(W, H) derived based on the upper right reference sample r(W, -1) and the lower left reference sample r(-1, H) of the current block may be derived. In detail, the lower right reference sample may be derived by a weighted sum or average of the upper right reference sample and the lower left reference sample. Formula 12 shows an example of deriving the lower right reference sample.
[0376] [Formula 12]
[0377]
[0378] As shown in Formula 12, the lower right reference sample can be calculated based on the weighted sum between the upper right reference sample and the lower left reference sample. In this case, the weights applied to the upper right reference sample and the lower left reference sample can be determined according to the width and height of the current block. For example, when the current block is a square, the same weight is applied to the upper right reference sample and the lower left reference sample. On the contrary, when the current block is a non-square, different weights can be applied to the upper right reference sample and the lower left reference sample. However, the weight setting method shown in Formula 12 is only an example of the present invention, and the present invention is not limited to this. In addition to the example shown in Formula 12, the weight can be determined based on at least one of the following: the size, shape or intra-frame prediction mode of the current block, the availability of reference samples, the availability of adjacent blocks, whether the adjacent blocks are encoded in intra-frame prediction mode or the intra-frame prediction mode of the adjacent blocks.
[0379] The right reference sample can be derived based on the upper right reference sample and the lower right reference sample. For example, the right reference sample can be obtained by interpolating the upper right reference sample and the lower right reference sample. The following formula 13 shows an example of deriving the right reference sample.
[0380] [Formula 13]
[0381]
[0382] As shown in Formula 13, the right reference sample Pr(W, y) (where y is an integer between 0 and CU height (cu_height)) can be obtained by weighted prediction of the upper right reference sample r(W, -1) and the lower right reference sample P(W, H). In this case, the weights applied to the upper right reference sample and the lower right reference sample can be determined based on at least one of the width, height, or position of the right reference sample of the current block. For example, in the example shown in Formula 13, a weight of (H-1-y) / H is applied to the upper right reference sample, and a weight of (y+1) / H is applied to the lower right reference sample. However, the weight setting method shown in Formula 13 is only an example of the present invention, and the present invention is not limited thereto. In addition to the example shown in Formula 13, the weight can be determined based on at least one of the following: the size, shape, or intra-prediction mode of the current block, the availability of reference samples, the availability of adjacent blocks, whether the adjacent blocks are encoded in intra-prediction mode, or the intra-prediction mode of the adjacent blocks.
[0383] The lower reference sample may be derived based on the lower left reference sample and the lower right reference sample. As an example, the lower reference sample may be obtained by interpolating the lower left reference sample and the lower right reference sample. Formula 14 shows an example of deriving the lower reference sample.
[0384] [Formula 14]
[0385]
[0386] As shown in Formula 14, the lower reference sample Pb(x, H) (where x is an integer between 0 and the CU width (cu_width)) can be obtained by weighted prediction of the lower left reference sample r(-1, H) and the lower right reference sample P(W, H). In this case, the weights applied to the lower left reference sample and the lower right reference sample can be determined based on at least one of the width, height, or position of the lower reference sample of the current block. For example, as shown in the example of Formula 14, a weight of (W-1-x) / W is applied to the lower left reference sample, and a weight of (x+1) / H is applied to the lower right reference sample. However, the weight setting method shown in Formula 14 is only an example of the present invention, and the present invention is not limited thereto. In addition to the example shown in Formula 14, the weight can be determined based on at least one of the following: the size, shape, or intra-prediction mode of the current block, the availability of reference samples, the availability of adjacent blocks, whether the adjacent blocks are encoded in intra-prediction mode, or the intra-prediction mode of the adjacent blocks.
[0387] When the current block is non-square, you can refer to the above Fig.19 and Fig. 20 An example is described to derive the right reference sample and the lower reference sample.
[0388] As in the above example, the first reference sample at a fixed position, such as the upper right reference sample and the lower left reference sample, can be used to derive the second reference sample, such as the right reference sample and the lower reference sample. Unlike the above example, the second reference sample can be derived using the first reference sample at a different position from the upper right reference sample and / or the upper left reference sample. For example, the right reference sample and the lower reference sample can be derived by using the first reference sample, such as the upper center reference sample of the current block or the left center sample of the current block.
[0389] Alternatively, the first reference sample used to derive the second reference sample may be determined according to the intra prediction mode of the current block. As an example, the right reference sample and / or the lower reference sample may be derived based on the left reference sample and / or the upper reference sample specified by the directionality of the intra prediction mode of the current block.
[0390] Alternatively, the second reference sample may be determined using a plurality of left reference samples and / or a plurality of upper reference samples. For example, at least one of the right reference sample, the lower reference sample, or the lower right reference sample may be generated based on a weighted sum, an average value, a maximum value, or a minimum value of a plurality of left reference samples or a weighted sum, an average value, a maximum value, or a minimum value of a plurality of upper reference samples.
[0391] Alternatively, the second reference sample can be generated by copying the first reference sample. In this case, the first reference sample used to generate the second reference sample can have a fixed position, or can be adaptively determined according to the size, shape or intra prediction mode of the current block or the position of the second reference sample.
[0392] In the above example, although it is shown as having W lower reference samples and H right reference samples, a greater number of lower reference samples and / or right reference samples may be derived. For example, the lower reference samples may be derived to the same vertical line as the rightmost upper reference sample r(2W-1, -1), or the right reference samples may be derived to the same horizontal line as the lowest left reference sample r(-1, 2H-1).
[0393] In this case, the lower reference sample having an x coordinate greater than w may be generated by extrapolating the lower left reference sample and the lower right reference sample, or may be generated by interpolating the lower right reference sample P(W, H) and the rightmost lower reference sample P(2W-1, H). The rightmost lower reference sample may be generated by copying the rightmost upper reference sample r(2W-1, -1), or may be generated by a weighted sum operation between the rightmost upper reference sample and the lower left reference sample. The right reference sample having a y coordinate greater than H may be generated by extrapolating the upper right reference sample and the lower right reference sample, or may be generated by interpolating the lower right reference sample P(W, H) and the lowest right reference sample P(W, 2H-1). In this case, the lowest right reference sample may be generated by copying the lowest left reference sample r(-1, 2H-1), or may be generated by a weighted sum operation between the lowest left reference sample and the upper left reference sample.
[0394] Based on the first reference sample and the predetermined intra prediction mode, intra prediction can be performed on the current block, and a second reference sample can be derived based on the prediction sample generated by the intra prediction. Here, the second reference sample can be derived based on the prediction sample according to the result of performing the intra prediction or based on the reconstructed sample of the prediction sample. The reconstructed value can be a value before applying the loop filter, or can be a value after applying the loop filter.
[0395] The prediction sample is only used to derive the second reference sample and may not be used as the actual prediction sample of the current block. That is, even if intra prediction is performed based on a predetermined intra prediction mode to derive the second reference sample, the actual prediction of the current block can be obtained by reapplying an intra prediction mode that is the same as or different from the predetermined intra prediction mode.
[0396] Alternatively, based on the prediction sample obtained according to the predetermined intra prediction mode and the other prediction sample obtained according to the prediction mode different from the predetermined intra prediction mode, the final prediction sample of the current block can be obtained. The final prediction sample can be obtained based on a weighted sum operation or an average operation between the prediction sample and the other prediction sample.
[0397] In embodiments described later, prediction samples used to derive the second reference sample will be referred to as temporary prediction samples.
[0398] The predetermined intra prediction mode for obtaining the temporary prediction sample may include at least one of a planar mode, a DC mode, a horizontal mode, a vertical mode, and a diagonal mode.
[0399] Fig. 22 is a diagram showing an example of deriving right reference samples and lower reference samples by using temporary prediction samples obtained based on a planar mode.
[0400] Based on the planar mode, a temporary prediction sample of the current block can be obtained. Specifically, a temporary prediction sample of the prediction target sample can be generated by using a first prediction sample and a second prediction sample for the prediction target sample. The first prediction sample can be obtained using a reference sample placed in the horizontal direction of the prediction target sample. As an example, the first prediction sample can be generated based on a weighted sum operation of a left reference sample having the same y coordinate as the prediction target sample and a reference sample adjacent to the upper right corner. The second prediction sample can be obtained using a reference sample placed in the vertical direction of the prediction target sample. As an example, the second prediction sample can be generated based on a weighted sum operation of an upper reference sample having the same x coordinate as the prediction target sample and a reference sample adjacent to the lower left corner.
[0401] The second reference sample may be generated by copying a temporary prediction sample adjacent to the second reference sample. As an example, the right reference sample may be generated by copying a temporary prediction sample located at the right boundary of the current block, and the lower reference sample may be generated by copying a temporary prediction sample located at the lower boundary of the current block.
[0402] Alternatively, the second reference sample may be derived by adding an offset to a temporary prediction sample adjacent to the second reference sample. As an example, the right reference sample may be derived by adding an offset to a temporary prediction sample located at the right boundary of the current block, and the lower reference sample may be derived by adding an offset to a temporary prediction sample located at the lower boundary of the current block. The offset may be a difference between the temporary prediction sample and an adjacent temporary prediction sample adjacent to the temporary prediction sample.
[0403] Alternatively, the second reference sample may be generated based on interpolation of a plurality of temporary prediction samples or a weighted sum operation or an average operation of a plurality of temporary prediction samples. As an example, the right reference sample may be generated based on a weighted sum operation or an average operation of a temporary prediction sample located at the right boundary of the current block and adjacent temporary prediction samples adjacent to the temporary prediction sample. The lower reference sample may be generated by interpolating a temporary prediction sample located at the lower boundary of the current block and adjacent temporary prediction samples adjacent to the temporary prediction sample, or may be generated based on a weighted sum operation or an average operation of the temporary prediction samples.
[0404] Alternatively, the second reference sample may be derived based on a weighted sum operation or an average operation of adjacent reference samples. As an example, a right reference sample adjacent to the right boundary of the current block may be derived by copying a temporary reference sample located at the right boundary of the current block, and a lower boundary sample adjacent to the lower boundary of the current block may be derived by copying a temporary reference sample located at the lower boundary of the current block. In this case, a reference sample adjacent to the lower right corner of the current block (e.g., P(W, H-1)) may be derived based on a weighted sum operation or an average operation of adjacent right reference samples (e.g., P(W-1, H)) and adjacent lower reference samples (e.g., P(W-1, H)).
[0405] The predetermined intra prediction mode for obtaining the temporary prediction sample may be predefined in the encoder and the decoder. Alternatively, information for determining the predetermined intra prediction mode may be signaled via the bitstream. Alternatively, the predetermined intra prediction mode may be determined based on the intra prediction mode for obtaining the actual prediction sample.
[0406] The first reference samples may be arranged in one dimension to generate a first one-dimensional reference sample group, and the second reference samples may be arranged in one dimension to generate a second one-dimensional reference sample group. The first one-dimensional reference sample group may be configured with only the first reference samples, and the second one-dimensional reference sample group may be configured with only the second reference samples. Alternatively, the first one-dimensional reference sample group may be configured to include not only the first reference samples but also at least one or more second reference samples, and the second one-dimensional reference sample group may be configured to include not only the second reference samples but also at least one or more first reference samples.
[0407] Fig.23 is a diagram showing reference samples constituting a one-dimensional reference sample group.
[0408] like Fig.23 In the example shown in (a), the first one-dimensional reference sample group may consist of left reference samples and top reference samples of the current block.
[0409] On the other hand, Fig.23In the example shown in (b), the second one-dimensional reference sample group may be configured to include not only right reference samples and lower reference samples of the current block, but also some left reference samples and some upper reference samples.
[0410] That is, the lower left reference sample r(-1, H) and the left reference sample having a larger y-axis coordinate than the lower left reference sample among the left reference samples may be included in both the first one-dimensional reference sample group and the second one-dimensional reference sample group. In addition, the upper reference sample r(W, -1) and the upper reference sample having a larger x-axis coordinate than the upper right reference sample among the upper reference samples may be included in the first one-dimensional reference sample group and the second one-dimensional reference sample group.
[0411] Alternatively, based on at least one of the size, shape, or intra prediction mode of the current block, a portion of the first reference sample may be included only in the first one-dimensional reference sample group, or a portion of the first reference sample may be included only in the second one-dimensional reference sample group. In addition to the configuration of the one-dimensional reference sample group, the arrangement order of the reference samples constituting the one-dimensional reference sample group may be variably determined based on at least one of the size, shape, or intra prediction mode of the current block.
[0412] For ease of description, in the embodiments described below, a reference sample group including a left reference sample and an upper reference sample of a current block will be referred to as a first reference sample group (e.g., a first one-dimensional reference sample group), and a reference sample group including a right reference sample and a lower reference sample of a current block will be referred to as a second reference sample group (e.g., a second one-dimensional reference sample group). For example, the first reference sample group and the second reference sample group may be classified according to whether the right reference sample and the lower reference sample are included. In addition, in order to perform intra-frame prediction of a prediction target sample, a reference sample selected from the first reference sample group will be referred to as a first reference target sample, and a reference sample selected from the second reference sample group will be referred to as a second reference target sample.
[0413] Intra-frame prediction of the current block may be performed using at least one of the first reference sample group or the second reference sample group. For example, a prediction value of a prediction target sample in the current block may be obtained based on at least one of a first reference target sample selected from the first reference sample group or a second reference target sample selected from the second reference sample group. In this case, the first reference target sample and / or the second reference target sample may be determined based on at least one of a shape, a size, or an intra-frame prediction mode of the current block. For example, when the intra-frame prediction mode of the current block is determined, a first reference target sample of the prediction target sample may be specified according to the direction of the determined intra-frame prediction mode, and a second reference target sample of the prediction target sample may be specified according to the opposite direction of the determined intra-frame prediction mode. Alternatively, the first reference target sample and the second reference target sample may be specified according to the direction of the determined intra-frame prediction mode.
[0414] Fig.24 and Fig.25 is a diagram showing the positions of a first reference target sample and a second reference target sample.
[0415] Fig.24 An example is shown in which a reference sample placed in a direction indicated by an intra prediction mode of a current block is determined as a first reference target sample, and a reference sample placed in a direction opposite to the direction is determined as a second reference target sample.
[0416] When the intra prediction mode of the current block is in the upper right diagonal direction, a reference sample placed in the upper right diagonal direction from the prediction target sample among the reference samples included in the first reference sample group may be determined as the first reference target sample. In addition, a reference sample placed in the opposite direction to the upper right diagonal direction (i.e., the lower left diagonal direction) among the reference samples included in the second reference sample group may be determined as the second reference target sample.
[0417] Fig.25 An example is shown in which reference samples placed in a direction indicated by an intra-prediction sample of a current block are determined as first and second reference target samples, respectively.
[0418] When the intra prediction mode of the current block indicates an upper right direction, a reference sample placed in an upper right direction of a prediction target sample among the reference samples included in the first reference sample group may be determined as a first reference target sample, and a reference sample placed in an upper right direction of a prediction target sample among the reference samples included in the second reference sample group may be determined as a second reference target sample. Fig.25 In (a), it is shown that the upper reference sample is selected as the first reference target sample and the right reference sample is selected as the second reference target sample.
[0419] When the intra prediction mode of the current block indicates a lower left direction, a reference sample placed in a lower left direction of a prediction target sample among the reference samples included in the first reference sample group may be determined as a first reference target sample, and a reference sample placed in a lower left direction of a prediction target sample among the reference samples included in the second reference sample group may be determined as a second reference target sample. Fig.25 In (b), it is shown that the left reference sample is selected as the first reference target sample and the lower reference sample is selected as the second reference target sample.
[0420] Alternatively, the position of the second reference target sample may be determined based on the position of the first reference target sample, or the position of the first reference target sample may be determined based on the position of the second reference target sample. For example, a second reference target sample having the same x-coordinate or the same y-coordinate as the first reference target sample may be selected, or a second reference target sample having a position derived by adding an offset to the x-coordinate or y-coordinate of the first reference target sample may be selected. Herein, the offset may have a fixed value or may be adaptively determined according to the size, shape, or intra-prediction mode of the current block.
[0421] Alternatively, the position of the first reference target sample and / or the second reference target sample may be determined based on the position of the prediction target sample. For example, a first reference target sample and / or a second reference target sample having the same x-coordinate or the same y-coordinate as the prediction target sample may be selected, or a first reference target sample and / or a second reference target sample having a position obtained by adding an offset to the x-coordinate or y-coordinate of the prediction target sample may be selected. Herein, the offset may have a fixed value or may be adaptively determined according to the size, shape, or intra-prediction mode of the current block.
[0422] The predicted value of the predicted target sample may be generated based on at least one of a first predicted image according to the first reference target sample or a second predicted image according to the second reference target sample. In this case, the first predicted image may be generated based on the above description through the above formulas 8 to 10.
[0423] The second predicted image may be generated by interpolating or copying the second reference target sample specified according to the slope of the intra prediction mode of the current block. For example, Formula 15 is a diagram showing an example of deriving the second predicted image by copying the second reference target sample.
[0424] [Formula 15]
[0425] P2(x,y)=P_2nd_1D(x+iIdx+1+f)
[0426] In Formula 15, P2(x, y) represents the second predicted image, and P_2nd_1D(x+iIdx+1+f) represents the second reference target sample.
[0427] When only one second reference target sample cannot represent the slope of the intra-frame prediction mode of the current block, a second predicted image can be generated by interpolating multiple second reference target samples. Specifically, when an imaginary angle line following the slope and / or angle of the intra-frame prediction mode does not pass through integer pixels (i.e., reference samples at integer positions), the second predicted image can be obtained by interpolating the second reference samples adjacent to the left and right sides or the upper and lower sides of the angle line. For example, Formula 16 shows an example of obtaining a second predicted image by interpolating the second reference samples.
[0428] [Formula 16]
[0429]
[0430] The coefficients of the interpolation filter may be determined based on the weight-related parameters ifact.As an example, the coefficients of the interpolation filter may be determined based on the distance between the fractional pixels and the integer pixels (ie, the integer position of each reference sample) located on the corner line.
[0431] In Formula 16, the use of an interpolation filter having a tap number of 2 is shown, but an interpolation filter having a tap number greater than 2 may be used instead.
[0432] The final predicted image of the prediction target sample may be obtained based on at least one of the first predicted image or the second predicted image. For example, the first predicted image may be determined as the final predicted image of the prediction target sample, or the second predicted image may be determined as the final predicted image of the prediction target sample. Alternatively, the final predicted image of the prediction target sample may be determined based on a weighted sum or average of the first predicted image and the second predicted image.
[0433] Fig.26 is a diagram showing an example of obtaining a prediction sample based on a weighted sum operation of a first reference target sample and a second reference target sample.
[0434] The predicted value of the predicted target sample may be obtained based on a weighted sum operation of the first predicted image and the second predicted image. In other words, the predicted value may be obtained based on a weighted sum operation of the first reference target sample and the second reference target sample.
[0435] Formula 17 shows an example of obtaining a final prediction sample based on a weighted operation of the first prediction image and the second prediction image.
[0436] [Formula 17]
[0437] P(x,y)=w(x,y)×P1(x,y(+(1-w(x,y)))×P2(x,y)
[0438] In Formula 17, Pl(x, y) represents the first predicted image or the first reference target sample, and P2(x, y) represents the second predicted image or the second reference target sample. In addition, w(x, y) represents the weight applied to the first predicted image.
[0439] The weight applied to each predicted target sample may be determined based on the position of the predicted target sample. For example, the following formula 18 shows an example of determining the weight w.
[0440] [Formula 18]
[0441] w=(x+y) / N
[0442] In Formula 18, x represents the x-axis coordinate of the predicted target sample, and y represents the y-axis coordinate of the predicted target sample. N represents the L1 norm between the first reference target sample and the second reference target sample. For example, if the coordinates of the first reference target sample are (x0, y0) and the coordinates of the second reference target sample are (x1, y1), N can be defined as |x0-x1|+|y0-y1|.
[0443] Alternatively, the weights assigned to the first predicted image and the second predicted image may be determined based on the position of the predicted target sample or at least one of the size, shape, or intra-prediction mode of the current block. For example, Formula 19 shows an example of determining the weights based on the size of the current block and the position of the predicted target sample.
[0444] [Formula 19]
[0445]
[0446] In Formula 19, W and H represent the width and height of the current block, respectively, and (x, y) represents the coordinates of the predicted target sample.
[0447] As shown in Formula 19, as the prediction target sample is closer to the upper left corner of the current block, the weight to be applied to the first prediction image can be increased. In addition, as the prediction target sample is closer to the lower right corner of the current block, the weight applied to the second prediction image can be increased.
[0448] Alternatively, the weights may be derived based on neighboring blocks of the current block. Herein, the neighboring blocks of the current block may include at least one of an upper neighboring block, a left neighboring block, or a neighboring block adjacent to a corner of the current block (e.g., an upper left neighboring block, an upper right neighboring block, or a lower left neighboring block).
[0449] Alternatively, information for determining the weight may be signaled via a bitstream. The information may indicate a weight value applied to the first predicted image or the second predicted image, or may indicate a weight difference between the current block and a neighboring block.
[0450] Alternatively, the first predicted image may be set as the final predicted image in the first area of the current block, and the second predicted image may be set as the final predicted image in the second area of the current block. The first area and the second area may be generated by dividing the current block into two based on a vertical line, a horizontal line, or a diagonal line. For example, the first area and the second area may be rectangular or triangular partitions generated by partitioning the current block. The predicted value of a position adjacent to the boundary between the first area and the second area may be obtained by weighted prediction of the first predicted image and the second predicted image. In this case, the weights applied to the first predicted image and the second predicted image may be determined based on at least one of the position of the prediction target sample, the size, shape, or intra-prediction mode of the current block.
[0451] As in the above example, obtaining a final prediction image based on a plurality of prediction images may be referred to as bidirectional intra prediction (or dual intra prediction).
[0452] Dual intra prediction may be applied only to a partial area in the current block. In this case, the area to which dual intra prediction is applied may be predefined in the encoder and decoder. For example, dual intra prediction may be applied to a block of a predetermined size (e.g., 4×4) adjacent to the lower right corner of the current block. Alternatively, the area to which dual intra prediction is applied may be adaptively determined according to the size, shape, or intra prediction mode of the current block. Alternatively, information for determining the area to which dual intra prediction is applied (e.g., information indicating the size or position of the area) may be signaled via a bitstream.
[0453] Fig.28 is a diagram showing an area to which bidirectional intra prediction is applied.
[0454] In the area where bidirectional intra prediction is applied, the final prediction sample can be obtained by weighted prediction of the first prediction image and the second prediction image. On the other hand, in the area where bidirectional intra prediction is not applied, the first prediction image or the second prediction image can be determined as the final prediction sample.
[0455] The area to which the bidirectional intra prediction is applied may have a rectangular shape or a triangular shape.
[0456] In the above examples, it has been described that bidirectional intra prediction is performed using a first reference target sample selected from a first sample group and a second reference target sample selected from a second sample group. Different from the described examples, multiple reference samples may be selected from the first sample group to perform bidirectional intra prediction, or multiple reference samples may be selected from the second sample group to perform bidirectional intra prediction. For example, when the intra prediction mode of the current block has an upper right diagonal direction or a lower left diagonal direction, bidirectional intra prediction may be performed by selecting an upper reference sample and a left reference sample from the first sample group. That is, the final prediction sample of the current block may be obtained by weighted prediction of a first reference image obtained based on the upper reference sample and a second reference image obtained based on the lower reference sample.
[0457] Alternatively, according to the intra prediction mode, bidirectional intra prediction may be performed by selecting right reference samples and lower reference samples from the second sample group.
[0458] Bidirectional intra prediction can be defined as an independent intra prediction mode. For example, a total of 2N+2 intra prediction modes can be defined by defining N directional prediction modes and N bidirectional intra prediction modes corresponding to the N directional prediction modes. For example, by adding the bidirectional intra prediction mode to Fig. 9 The intra prediction modes shown in , a total of 68 intra prediction modes can be defined (that is, two non-directional intra prediction modes, 33 directional intra prediction modes and 33 bidirectional intra prediction modes). Of course, more or less than 33 directional intra prediction modes or more or less than 33 bidirectional intra prediction modes can also be used.
[0459] Alternatively, after determining the intra prediction mode of the current block, it can be determined whether to use the determined intra prediction mode to switch to the bidirectional prediction mode. For example, when determining the intra prediction mode of the current block, information about whether the determined intra prediction mode is used as the bidirectional intra prediction mode can be encoded. The information can be a 1-bit flag (e.g., bi_intra_flag), but is not limited to this. A value of bi_intra_flag of 0 indicates that directional intra prediction is performed, while a value of bi_intra_flag of 1 indicates that bidirectional intra prediction is performed. That is, when the value of bi_intra_flag is 0, the first predicted image is determined as the final predicted sample of the current block, and when the value of bi_intra_flag is 1, the weighted prediction of the first predicted image and the second predicted image can be determined as the final predicted sample of the current block.
[0460] Alternatively, whether the current block uses the bidirectional intra prediction mode may be determined based on whether the neighboring blocks adjacent to the current block use the bidirectional intra prediction mode. For example, when the intra prediction mode of the current block is the same as the candidate derived based on the intra prediction mode of the neighboring blocks (i.e., the MPM candidate), whether the bidirectional intra prediction mode is used for the current block may be determined in the same manner as whether the bidirectional intra prediction mode is used in the neighboring blocks.
[0461] Alternatively, whether to perform bidirectional intra prediction may be determined based on the size and / or shape of the current block. For example, bidirectional intra prediction is allowed only for blocks of 32×32 or larger. Therefore, when the size of the current block is less than 32×32, bidirectional intra prediction may not be applied, while when the size of the current block is 32×32, bidirectional intra prediction may be applied.
[0462] As another example, bidirectional intra prediction may be allowed only for square blocks, or bidirectional intra prediction may be allowed only for non-square blocks.
[0463] Alternatively, bidirectional intra prediction may be applied to only a portion of the directional intra prediction modes. Fig.26 is an example of identifying and indicating a directional prediction mode that allows bidirectional intra prediction. Fig.26 In the example shown, only a part of the intra prediction modes between the horizontal direction and the vertical direction allows bidirectional intra prediction. In this case, when the intra prediction mode is selected within the range, the bidirectional intra prediction may be performed by default, or whether the bidirectional intra prediction mode is performed may be determined based on information parsed through the bitstream or at least one of the size or shape of the current block when the intra prediction mode within the range is selected.
[0464] The intra prediction modes that allow bidirectional intra prediction are not limited to Fig.26 The example shown. The intra-frame prediction mode that allows bidirectional intra-frame prediction can be predefined in the encoder and the decoder, or the intra-frame prediction mode that allows bidirectional intra-frame prediction can be adaptively determined according to the size and / or shape of the current block. Alternatively, information for determining the intra-frame prediction mode that allows bidirectional intra-frame prediction can be sent by signaling through the bitstream.
[0465] Fig.29 is a flowchart illustrating a process of determining whether to apply a bidirectional intra prediction mode according to the present invention.
[0466] First, it may be determined whether the intra prediction mode of the current block is a non-directional mode (S2710). The non-directional mode may include at least one of planar and DC.
[0467] Information indicating whether the intra-frame prediction mode of the current block is a non-directional mode may be signaled through the bitstream. For example, at least one of a flag indicating whether the intra-frame prediction mode of the current block is a non-directional mode, a flag indicating whether the intra-frame prediction mode of the current block is a planar mode, or a flag indicating whether the intra-frame prediction mode of the current block is a DC mode may be signaled through the bitstream.
[0468] Alternatively, the intra prediction mode of the current block may be determined based on MPM candidates or residual mode information.
[0469] When the intra prediction mode of the current block is a non-directional mode, bidirectional intra prediction is not applied to the current block (S2720).
[0470] When the intra prediction mode of the current block is not a non-directional mode, it may be determined whether to apply bidirectional intra prediction to the current block (S2730). Whether to apply bidirectional intra prediction to the current block may be determined based on information parsed from the bitstream, the shape of the current block, the size of the current block, or the intra prediction mode of the current block.
[0471] For example, whether to apply bidirectional intra prediction to the current block may be determined based on a flag (e.g., bi_pred_flag) parsed from the bitstream. A value of bi_pred_flag of 0 indicates that bidirectional intra prediction is not applied to the current block, while a value of bi_pred_flag of 1 indicates that bidirectional intra prediction is applied to the current block. Alternatively, whether to apply bidirectional intra prediction to the current block may be determined based on whether the intra prediction mode of the current block is a directional prediction mode to which bidirectional intra prediction is applied.
[0472] In order to perform unidirectional or bidirectional intra prediction, a reference sample of the current block may be derived. The reference sample may include a first reference sample adjacent to the left and upper sides of the current block and a second reference sample adjacent to the right and lower sides of the current block. The second reference sample may be derived only when bidirectional intra prediction is applied to the current block.
[0473] If bidirectional intra prediction is not applied to the current block, unidirectional intra prediction may be performed according to the intra prediction mode of the current block (S2740). In the unidirectional intra prediction, a prediction sample may be obtained based on at least one of the first reference samples.
[0474] When bidirectional intra prediction is applied to the current block, bidirectional intra prediction (S2750) may be performed according to the intra prediction mode of the current block. In the bidirectional intra prediction, a prediction sample may be obtained based on a first prediction image obtained based on at least one of the first reference target samples and a second prediction image obtained based on at least one of the second reference target samples. The first reference target sample and the second reference target sample may be determined based on the directionality of the intra prediction mode, or may be determined based on the size, shape, or position of other basic reference samples of the current block. When acquiring the first prediction image and the second prediction image, the prediction sample may be obtained by weighted prediction of the first prediction image and the second prediction image.
[0475] As another example, after the current block is divided into a plurality of regions, intra prediction may be performed on each of the divided regions. For example, for a first region included in the current block, intra prediction may be performed using reference samples included in a first reference sample group. On the other hand, for a second region included in the current block, intra prediction may be performed using reference samples derived based on a predicted value or a reconstructed value of the first region, reference samples included in the first reference sample group, or reference samples included in a second reference sample group.
[0476] In this case, the first intra-frame prediction mode applied to the first area and the second intra-frame prediction mode applied to the second area may be the same or different from each other. As an example, any one of the first intra-frame prediction mode and the second intra-frame prediction mode may be predefined by the encoder and the decoder. For example, any one of the first intra-frame prediction mode and the second intra-frame prediction mode may be a plane mode, a DC mode, a horizontal mode, a vertical mode, or a diagonal mode. Alternatively, any one of the first intra-frame prediction mode and the second intra-frame prediction mode may be variably determined based on at least one of the size, shape, or partition type of the current block. For example, when the width of the current block is greater than the height, any one of the first intra-frame prediction mode and the second intra-frame prediction mode may be determined as a vertical mode. On the other hand, when the height of the current block is greater than the width, any one of the first intra-frame prediction mode and the second intra-frame prediction mode may be determined as a horizontal mode. When the width and height of the current block are the same, any one of the first intra-frame prediction mode and the second intra-frame prediction mode may be determined as a plane mode or a DC mode.
[0477] The other of the first intra prediction mode and the second intra prediction mode may be determined using an MPM candidate-based derivation method.
[0478] Each of the first region and the second region may include at least one sample included in the current block. For example, the first region may include at least one of n columns on the left (or right) side of the current block or m rows on the upper (or lower) side of the current block. n and m may be integers of 1, 2 or more. Alternatively, n and m may be determined based on at least one of the size, shape, or intra prediction mode of the current block. The second region may be a remaining region or a partial region of the remaining region except the first region.
[0479] One coding block may be divided into a plurality of subblocks, and intra prediction may be performed on each subblock. The intra prediction method as described above may be referred to as a multi-intra prediction method.
[0480] The subblocks generated by dividing one coding block may have an N×M form. Here, N and M are integers of 1 or more, and N and M may be the same as or different from each other. The size of the subblock or the number of subblocks included in the coding block may be determined based on at least one of the size, shape, or intra prediction mode of the current block.
[0481] One intra prediction mode may be applied to a plurality of subblocks. In this case, intra prediction for the first subblock may be performed based on reference samples adjacent to the first subblock, and intra prediction for the second subblock may be performed based on reference samples adjacent to the second subblock. When the first subblock is located to the left or above the second subblock, at least one of the reference samples of the second subblock may be derived from the reconstructed samples of the first subblock.
[0482] Alternatively, different intra prediction modes or different directional intra prediction modes may be applied to each sub-block. In this case, when the intra prediction mode of the first sub-block is a non-directional mode, the intra prediction mode of the second sub-block may also be set to have a non-directional mode. For example, when the DC mode is applied to the first sub-block, the plane mode may be applied to the second sub-block. Alternatively, the intra prediction mode applied to the second sub-block may be derived based on the intra prediction mode applied to the first sub-block. For example, the intra prediction mode applied to the second sub-block may be derived by adding an offset to the intra prediction mode applied to the first sub-block or by subtracting an offset from the intra prediction mode applied to the first sub-block. The offset may be determined based on at least one of the size of the current block, the shape of the current block, or the intra prediction mode of the first sub-block. Alternatively, information for determining the offset may be sent by a bitstream signal. Alternatively, the intra prediction mode of the second sub-block may be set to an angle opposite to the intra prediction mode applied to the first sub-block, or may be set to an intra prediction mode having a predetermined angle difference with the intra prediction mode applied to the first sub-block.
[0483] Alternatively, a predefined mapping table may be used to derive the intra prediction mode of the second sub-block according to the intra prediction mode of the first sub-block. The mapping table may define the correspondence between the intra prediction modes. The mapping table may be predefined in the encoder and the decoder.
[0484] Alternatively, information for determining the intra prediction mode of the first subblock and information for determining the intra prediction mode of the second subblock may be independently signaled.
[0485] Alternatively, a non-wide-angle intra prediction mode may be applied to the first sub-block, and a wide-angle intra prediction mode may be applied to the second sub-block. Whether to apply the wide-angle intra prediction mode to the sub-block may be determined based on the size or shape of the current block. The non-wide-angle intra prediction mode may be an intra prediction mode with a predefined angle, or an intra prediction mode whose angle (or index) difference with the wide-angle intra prediction mode is a predefined value.
[0486] Fig.30 An embodiment to which a multi-intra prediction method is applied is shown.
[0487] After a non-square coding block is divided into a plurality of sub-blocks, a non-wide-angle intra prediction mode may be applied to a first sub-block, and a wide-angle intra prediction mode may be applied to a second sub-block.
[0488] Here, the first sub-block and the second sub-block may be determined according to a scanning order between blocks.
[0489] Contrary to the illustrated example, the wide-angle intra prediction mode may be applied to the first subblock, and the non-wide-angle intra prediction mode may be applied to the second subblock.
[0490] Whether to apply a multiple intra prediction method can be determined based on the size or shape of the current block. For example, when the current block is a non-square type, it can be set to apply a multiple intra prediction method. Alternatively, information indicating whether a multiple intra prediction method is applied can be signaled through a bitstream. As an example, the syntax isMultipleIntra_flag indicating whether a multiple intra prediction method is applied can be signaled through a sequence header, a picture header, a slice header, or a block header. For example, when the value of isMultipleIntra_flag is 1, it may mean that the multiple intra prediction method is applied to all non-square coding units. On the other hand, when the value of isMultipleIntra_flag is 0, it may mean that the multiple intra prediction method is not applied to all non-square coding units.
[0491] Alternatively, it can be determined based on the coding information whether to apply the multi-intra prediction method. The coding information may include at least one of the size, shape or segmentation type of the current block. For example, when the size of the current block is greater than a threshold or when the size of the current block is less than a threshold, the multi-intra prediction method can be applied. The threshold value may represent the maximum size or minimum size of a block in which the multi-intra prediction method is allowed. The threshold value may be predefined by an encoder and a decoder. Alternatively, information for determining the threshold value may be signaled via a bitstream. As another example, when the segmentation type of the higher node is a first type, the multi-intra prediction method may be allowed, and when the segmentation type of the higher node is a second type, the multi-intra prediction method may not be allowed. The first type includes at least one of a quadtree partition, a binary tree partition or a ternary tree partition, and the second type includes a partition type other than the first type.
[0492] When the intra prediction mode applied to each subblock is different, a smoothing filter may be applied at the boundary of the subblocks.
[0493] Fig.31 is a diagram showing an example of applying a smoothing filter.
[0494] A smoothing filter may be applied to a sample located at a boundary between a first sub-block and a second sub-block. In this case, the sample to which the smoothing filter is applied may be a predicted sample or a reconstructed sample repaired based on the predicted sample. A sample located at a boundary of the first sub-block may be modified using a filter value based on n samples included in the first sub-block and m samples included in the second sub-block. In addition, a sample located at a boundary of the second sub-block may be modified to a filter value based on n samples included in the second sub-block and m samples included in the first sub-block. Here, n and m may be integers of 1, 2 or more.
[0495] exist Fig.31 In the example shown in (a), sample q located at the boundary of the first sub-block may be modified to a value calculated by applying a smoothing filter to sample q, sample p located at the left side of sample q, and sample r located at the right side of sample q. Here, sample q and sample p are included in the first sub-block, and sample r is included in the second sub-block.
[0496] exist Fig.31 In the example shown in (b), a sample r located at the boundary of the second sub-block may be modified to a value calculated by applying a smoothing filter to the sample r, a sample q located at the left side of the sample r, and a sample s located at the right side of the sample r. Here, the sample q is included in the first sub-block, and the samples r and s are included in the second sub-block.
[0497] The coefficients of the smoothing filter can be {1, 2, 1}.
[0498] exist Fig.31 In FIG. 1 , it is shown that the smoothing filter is applied only to samples located at the boundary between the first sub-block and the second sub-block, but the present invention is not limited thereto. The smoothing filter may be applied to samples included from the boundary between the first sub-block and the second sub-block to the k-th row (column or row). Here, k may be an integer of 1, 2 or more. The number of rows to which the smoothing filter is applied may be determined based on at least one of the size, shape, or intra prediction mode of the current block.
[0499] The samples used in the smoothing filter can be arranged in a row either horizontally or vertically. Fig.31 In the example shown, when the sub-blocks are arranged in a row in the horizontal direction, filtering can be performed using samples arranged in a row in the horizontal direction. On the other hand, when the sub-blocks are arranged in a row in the vertical direction, filtering can be performed using samples arranged in a row in the vertical direction.
[0500] Alternatively, the position of the samples used in the smoothing filter may be determined based on the intra prediction mode. For example, when the intra prediction mode of the first subblock is diagonal, filtering may be performed using samples located at the boundary of the first subblock and samples located in the diagonal direction of the samples.
[0501] The smoothing filter may be applied to the sub-blocks sequentially. For example, after applying the smoothing filter to the boundary of the first sub-block, the smoothing filter may be applied to the boundary of the second sub-block. Alternatively, the smoothing filter may be applied to multiple sub-blocks in parallel or independently.
[0502] It is within the scope of the present invention to apply the embodiments described with emphasis on the decoding process or the encoding process to the encoding process or the decoding process. It is also within the scope of the present invention to change the embodiments described in a predetermined order to a different order.
[0503] Although the above embodiments have been described based on a series of steps or flow charts, the above embodiments are not intended to limit the time series order of the present invention, and can be executed simultaneously or in different orders. In addition, each of the components (e.g., units, modules, etc.) constituting the block diagram in the above embodiments can be implemented as a hardware device or software, and multiple components can be combined into one hardware device or software. The above embodiments can be implemented in the form of program instructions, which can be executed by various computer components and recorded in a computer-readable recording medium. Computer-readable storage media can include program instructions, data files, data structures, etc., alone or in combination. Examples of computer-readable storage media include: magnetic recording media such as hard disks, floppy disks, and tapes; optical data storage media such as CD-ROMs or DVD-ROMs; magneto-optical media such as optical disks; and hardware devices such as read-only memories (ROMs), random access memories (RAMs), and flash memories, which are particularly structured to store and implement program instructions. Hardware devices can be configured to be operated by one or more software modules or software modules can be configured to be operated by one or more hardware devices to perform processing according to the present invention.
[0504] Industrial Applicability
[0505] The present invention can be applied to electronic devices capable of encoding / decoding images.
[0506] In addition, the embodiment of the present invention further includes:
[0507] 1. A method for decoding an image, the method comprising:
[0508] deriving an intra prediction mode for a current block; and
[0509] When the intra prediction mode is less than or equal to a threshold and the current block is a non-square type with a width greater than a height, modifying the intra prediction mode to a wide-angle intra prediction mode,
[0510] Wherein, the wide-angle intra prediction mode has an angle greater than 135 degrees.
[0511] 2. The method according to (1), wherein the threshold is determined based on a ratio of a width to a height of the current block.
[0512] 3. The method according to (2), wherein the wide angle intra prediction mode is derived by adding a predefined value to the intra prediction mode,
[0513] The predefined value is the number of directional intra prediction modes.
[0514] 4. The method according to (1), wherein the number of the wide-angle intra prediction modes that can be used for the current block is determined based on a ratio of a width to a height of the current block.
[0515] 5. The method according to (1), wherein, when a multi-intra prediction method is applied to the current block, a non-wide-angle intra prediction mode is applied to a first subblock of the current block, and the wide-angle intra prediction mode is applied to a second subblock.
[0516] 6. The method according to (5), wherein samples located at a boundary of the first sub-block are modified to values calculated by a smoothing filter.
[0517] 7. The method according to (6), wherein filtering based on the smoothing filter is performed based on first neighboring samples of samples located at a boundary of the first subblock and second neighboring samples of samples included in the first subblock and samples included in the second subblock.
[0518] 8. A method for encoding an image, the method comprising:
[0519] deriving an intra prediction mode for a current block; and
[0520] When the intra prediction mode is less than or equal to a threshold and the current block is a non-square type with a width greater than a height, modifying the intra prediction mode to a wide-angle intra prediction mode,
[0521] Wherein, the wide-angle intra prediction mode has an angle greater than 135 degrees.
[0522] 9. The method of (8), wherein the threshold is determined based on a ratio of a width to a height of the current block.
[0523] 10. The method of (9), wherein the wide angle intra prediction mode is derived by adding a predefined value to the intra prediction mode,
[0524] The predefined value is the number of directional intra prediction modes.
[0525] 11. The method of (8), wherein the number of wide-angle intra prediction modes that can be used for the current block is determined based on a ratio of a width to a height of the current block.
[0526] 12. The method according to (8), wherein, when a multi-intra prediction method is applied to the current block, a non-wide-angle intra prediction mode is applied to a first subblock of the current block, and the wide-angle intra prediction mode is applied to a second subblock.
[0527] 13. The method according to (12), wherein samples located at a boundary of the first sub-block are modified to values calculated by a smoothing filter.
[0528] 14. The method according to (13), wherein filtering based on the smoothing filter is performed based on first neighboring samples of samples located at a boundary of the first subblock and second neighboring samples of samples included in the first subblock and samples included in the second subblock.
[0529] 15. A device for decoding an image, the device comprising:
[0530] an intra prediction unit, configured to derive an intra prediction mode of a current block; and when the intra prediction mode is less than or equal to a threshold and the current block is a non-square type with a width greater than a height, modify the intra prediction mode to a wide angle intra prediction mode,
[0531] Wherein, the wide-angle intra prediction mode has an angle greater than 135 degrees.
Claims
1. A method for decoding an image, the method comprising: determining a reference sample line index of a current block, the current block having a non-square shape having a width greater than a height; deriving an intra prediction mode of the current block; comparing the intra prediction mode of the current block with a threshold; When the intra prediction mode is less than or equal to the threshold, modifying the intra prediction mode of the current block to a wide-angle intra prediction mode; as well as Obtaining a prediction block of the current block based on the wide-angle intra prediction mode, wherein the wide angle intra prediction mode has an angle greater than an angle of the top right diagonal intra prediction mode, wherein the threshold is adaptively determined based on the ratio of the width to the height of the current block, The intra prediction mode of the current block is derived based on the most probable mode MPM flag of the current block, wherein, when the MPM flag has a first value, the intra prediction mode of the current block is derived from MPM candidates and a default mode, wherein, when the MPM flag has a second value, the intra prediction mode of the current block is not derived from the MPM candidates and the default mode, wherein, when the MPM flag has the first value, a default mode flag indicating whether the intra prediction mode of the current block is the default mode is decoded from a bitstream, Wherein, the default mode represents the planar mode, and When the reference sample line index of the current block is greater than a predefined value, decoding of the MPM flag from the bitstream is omitted, and the value of the MPM flag is inferred to be the first value.
2. The method according to claim 1, wherein: modifying the intra prediction mode of the current block is performed by adding a predefined value to the intra prediction mode, and The predefined value is 65.
3. The method according to claim 1, wherein: The total number of wide-angle intra prediction modes applicable to the current block is adaptively determined according to a ratio of a width to a height of the current block.
4. A method for encoding an image, the method comprising: determining a reference sample line index of a current block, the current block having a non-square shape having a width greater than a height; Determining an intra prediction mode of the current block; comparing the intra prediction mode of the current block with a threshold; When the intra prediction mode is less than or equal to the threshold, modifying the intra prediction mode of the current block to a wide-angle intra prediction mode; as well as Obtaining a prediction block of the current block based on the wide-angle intra prediction mode, wherein the wide angle intra prediction mode has an angle greater than an angle of the top right diagonal intra prediction mode, wherein the threshold is adaptively determined based on the ratio of the width to the height of the current block, The value of the most probable mode MPM flag is determined according to whether the intra prediction mode of the current block is one of the MPM candidate and the default mode, wherein, when the intra prediction mode of the current block is one of the MPM candidate and the default mode, the MPM flag has a first value, wherein, when the intra prediction mode of the current block is not one of the MPM candidate and the default mode, the MPM flag has a second value, wherein, when the MPM flag has a first value, a default mode flag indicating whether the intra prediction mode of the current block is the default mode is encoded into a bitstream, Wherein, the default mode represents the planar mode, and When the reference sample line index of the current block is greater than a predefined value, encoding the MPM flag into the bitstream is omitted, and the intra prediction mode of the current block is the same as one of the MPM candidate and the default mode.
5. A device for sending compressed video data, the device comprising: a processor configured to obtain the compressed video data; as well as a sending unit, configured to send the compressed video data, Wherein, obtaining the compressed video data comprises: determining a reference sample line index of a current block, the current block having a non-square shape having a width greater than a height; Determining an intra prediction mode of the current block; comparing the intra prediction mode of the current block with a threshold; When the intra prediction mode is less than or equal to the threshold, modifying the intra prediction mode of the current block to a wide-angle intra prediction mode; and Obtaining a prediction block of the current block based on the wide-angle intra prediction mode, wherein the wide angle intra prediction mode has an angle greater than an angle of the top right diagonal intra prediction mode, wherein the threshold is adaptively determined based on the ratio of the width to the height of the current block, The value of the most probable mode MPM flag is determined according to whether the intra prediction mode of the current block is one of the MPM candidate and the default mode, wherein, when the intra prediction mode of the current block is one of the MPM candidate and the default mode, the MPM flag has a first value, wherein, when the intra prediction mode of the current block is not one of the MPM candidate and the default mode, the MPM flag has a second value, wherein, when the MPM flag has a first value, a default mode flag indicating whether the intra prediction mode of the current block is the default mode is encoded into the bitstream, Wherein, the default mode represents the planar mode, and When the reference sample line index of the current block is greater than a predefined value, encoding the MPM flag into the bitstream is omitted, and the intra prediction mode of the current block is the same as one of the MPM candidate and the default mode.