Method and apparatus for encoding and decoding image signals

By efficiently encoding and decoding the local block coefficients in the image signal, the problem of low image compression efficiency in the prior art is solved, and more efficient image signal processing is achieved.

CN113810712BActive Publication Date: 2025-04-25IND ACAD COOP GRP OF SEJONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111060380.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2017-04-18
Filing Date
2017-04-26
Publication Date
2025-04-25
Estimated Expiration
2037-04-26

AI Technical Summary

Technical Problem

The prior art is difficult to improve the compression efficiency of image signals, especially when encoding and decoding coefficients in local blocks.

Method used

By efficiently encoding and decoding the coefficients in the local block, the specific method includes efficiently encoding and decoding the local block coefficient flag, absolute value flag, and intra prediction mode information.

Benefits of technology

The image compression efficiency is improved, and the processing process of image signals is optimized through efficient encoding and decoding methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113810712B_ABST
    Figure CN113810712B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for encoding and decoding an image signal. The method for encoding an image signal according to the present invention can perform the following operations: encoding a local block coefficient flag indicating whether a coefficient of a current local block is a non-zero coefficient; encoding a first flag indicating whether the absolute value of the coefficient is greater than 1; encoding a second flag indicating whether the absolute value of the coefficient is greater than 2; encoding the remaining coefficients in the current local block that are not encoded based on the first flag or the second flag; and encoding the code of the coefficient of the current local block.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application with the application date of April 26, 2017, application number 201780041200.3, and invention name “Method and device for encoding and decoding image signals”. Technical Field

[0002] The present invention relates to a method and apparatus for encoding and decoding an image signal. Background Art

[0003] Recently, the demand for multimedia data such as videos on the Internet has grown rapidly. However, the development speed of channel bandwidth has been unable to keep up with the rapidly growing amount of multimedia data. Summary of the invention

[0004] Technical issues

[0005] The object of the present invention is to improve the compression efficiency of an image by efficiently encoding / decoding coefficients in a local block.

[0006] An object of the present invention is to improve the compression efficiency of an image by efficiently encoding / decoding a partitioning method of a target encoding / decoding block when encoding / decoding the image.

[0007] An object of the present invention is to improve the compression efficiency of an image by efficiently encoding / decoding intra-frame prediction mode information of a target encoding / decoding block when encoding / decoding the image.

[0008] Technical Solution

[0009] According to the method and device for encoding an image signal of the present invention, the following operations may be performed: encoding a local block coefficient flag indicating whether a coefficient of a current local block is a non-zero coefficient; encoding a first flag indicating whether an absolute value of the coefficient is greater than 1; encoding a second flag indicating whether an absolute value of the coefficient is greater than 2; encoding the remaining coefficients in the current local block that are not encoded based on the first flag or the second flag; and encoding the signs of the coefficients of the current local block.

[0010] The method and apparatus for encoding an image signal according to the present invention may encode a maximum value among absolute values ​​of coefficients of a current local block.

[0011] The method and apparatus for encoding an image signal according to the present invention can determine whether absolute values ​​of all coefficients in a current local block are less than a current threshold value; and encode a first threshold flag for the current local block based on a result of the determination.

[0012] In a method and apparatus for encoding an image signal according to the present invention, when the absolute values ​​of all coefficients in a current local block are greater than or equal to a current threshold, a first threshold flag may be encoded as false, and, when the absolute values ​​of all coefficients in the current local block are less than the current threshold, the first threshold flag may be encoded as true.

[0013] In the method and apparatus for encoding an image signal according to the present invention, when the first threshold flag is encoded as false, the current threshold may be updated to a next threshold.

[0014] In the method and apparatus for encoding an image signal according to the present invention, at least one of the first flag or the second flag may be selectively encoded according to a value of the first threshold flag.

[0015] In the method and apparatus for encoding an image signal according to the present invention, the current threshold may be a threshold belonging to a predetermined threshold range.

[0016] In the method and apparatus for encoding an image signal according to the present invention, the predetermined threshold may be determined based on at least one of a quantization parameter, a size of a block, or a pixel value range.

[0017] According to the method and device for decoding an image signal of the present invention, the following operations may be performed: decoding a local block coefficient flag indicating whether a coefficient of a current local block is a non-zero coefficient; decoding a first flag indicating whether an absolute value of the coefficient is greater than 1; decoding a second flag indicating whether an absolute value of the coefficient is greater than 2; decoding the remaining coefficients in the current local block that are not encoded based on the first flag or the second flag; and decoding the signs of the coefficients of the current local block.

[0018] The method and apparatus for decoding an image signal according to the present invention can decode the maximum value among the absolute values ​​of coefficients of the current local block.

[0019] The method and apparatus for decoding an image signal according to the present invention can decode the first threshold flag of the current local block.

[0020] In a method and apparatus for decoding an image signal according to the present invention, when the first threshold flag is false, the absolute values ​​of all coefficients in the current local block may be greater than or equal to the current threshold, and, when the first threshold flag is true, the absolute values ​​of all coefficients in the current local block may be less than the current threshold.

[0021] In the method and apparatus for decoding an image signal according to the present invention, when the first threshold flag is false, the current threshold may be updated to a next threshold.

[0022] In the method and apparatus for decoding an image signal according to the present invention, at least one of the first flag or the second flag may be selectively decoded according to a value of the first threshold flag.

[0023] In the method and apparatus for decoding an image signal according to the present invention, the current threshold may be a threshold belonging to a predetermined threshold range.

[0024] In the method and apparatus for decoding an image signal according to the present invention, the predetermined threshold may be determined based on at least one of a quantization parameter, a size of a block, or a pixel value range.

[0025] The method and apparatus for encoding an image signal according to the present invention may perform the following operations: encoding a local block flag indicating whether there is at least one non-zero coefficient in a current local block; encoding a local block coefficient flag indicating whether a current coefficient of the current local block is a non-zero coefficient; encoding the absolute value of the current coefficient of the current local block; and encoding the sign of the current coefficient of the current local block.

[0026] In the method and apparatus for encoding an image signal according to the present invention, the local block coefficient flag may be encoded based on the number of non-zero coefficients in a previous local block.

[0027] In the method and apparatus for encoding an image signal according to the present invention, the step of encoding the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients in a previous local block.

[0028] In the method and apparatus for encoding an image signal according to the present invention, the local block coefficient flag may be encoded based on the number of non-zero coefficients up to a previous coefficient in a current local block.

[0029] In the method and apparatus for encoding an image signal according to the present invention, the step of encoding the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients up to a previous coefficient.

[0030] According to the method and device for decoding an image signal of the present invention, the following operations may be performed: decoding a local block flag indicating whether there is at least one non-zero coefficient in a current local block; decoding a local block coefficient flag indicating whether a current coefficient of the current local block is a non-zero coefficient; decoding the absolute value of the current coefficient of the current local block; and decoding the sign of the current coefficient of the current local block.

[0031] In the method and apparatus for decoding an image signal according to the present invention, the local block coefficient flag may be decoded based on the number of non-zero coefficients in a previous local block.

[0032] In the method and apparatus for decoding an image signal according to the present invention, the step of decoding the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients in a previous local block.

[0033] In the method and apparatus for decoding an image signal according to the present invention, the local block coefficient flag may be decoded based on the number of non-zero coefficients up to a previous coefficient in a current local block.

[0034] In the method and apparatus for decoding an image signal according to the present invention, the decoding of the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients up to a previous coefficient.

[0035] According to the present invention, the method and device for decoding an image signal can perform the following operations: decoding partition information indicating whether a current decoding block is partitioned into two local blocks; and, when the partition information indicates that the current decoding block is partitioned into two local blocks, decoding information about a partition mode of the current decoding block, and partitioning the current decoding block into two local blocks based on the information about the partition mode.

[0036] In the method and apparatus for decoding an image signal according to the present invention, the information about the partition mode may include at least one of direction information indicating a partition direction of a current decoding block or information specifying the accuracy of a size of a partial block generated by partitioning the current decoding block.

[0037] In the method and apparatus for decoding an image signal according to the present invention, the horizontal length or vertical length of the partial block may have a value obtained by dividing the horizontal length or vertical length of the decoded block by 2 to a value obtained by dividing the horizontal length or vertical length of the decoded block by 2 to the Nth power (2 N ), where the value (N) is specified by the precision information.

[0038] In the method and apparatus for decoding an image signal according to the present invention, the information about the partition mode may include index information specifying a partition shape of a current decoding block.

[0039] According to the method and device for decoding an image signal of the present invention, the following operations may be performed: based on the intra-frame prediction modes of neighboring blocks adjacent to the current decoding block, an MPM (most probable mode) candidate of the current decoding block is determined; information indicating whether there is an MPM candidate that is the same as the intra-frame prediction mode of the current decoding block is decoded; and, based on the information, the intra-frame prediction mode of the current decoding block is derived.

[0040] In the method and apparatus for decoding an image signal according to the present invention, the number of intra prediction modes available for a current decoding block may be variably determined according to the size of the current decoding block, the shape of the current decoding block, or the intra prediction modes of neighboring blocks.

[0041] In a method and apparatus for decoding an image signal according to the present invention, when the number of intra-frame prediction modes available for a current decoding block is different from the number of intra-frame prediction modes available for a neighboring block, an MPM candidate corresponding to a directional prediction mode may be set to a prediction angle of the directional prediction mode.

[0042] According to the present invention, the method and device for encoding an image signal can perform the following operations: determine whether a current coding block is partitioned into two local blocks; according to a result of the determination, encode partition information indicating whether the current coding block is partitioned into two local blocks; when the current coding block is determined to be partitioned into two local blocks, determine a partition mode of the current coding block; and, based on the determination, encode information on the partition mode of the current coding block.

[0043] In the method and apparatus for encoding an image signal according to the present invention, the information about the partition mode may include at least one of direction information indicating a partition direction of a current coding block or information specifying the accuracy of a size of a local block generated by partitioning the current coding block.

[0044] In the method and apparatus for encoding an image signal according to the present invention, the horizontal length or vertical length of the partial block may have a value obtained by dividing the horizontal length or vertical length of the encoding block by 2 to a value obtained by dividing the horizontal length or vertical length of the decoding block by 2 to the Nth power (2 N ), where the value (N) is specified by the precision information.

[0045] In the method and apparatus for encoding an image signal according to the present invention, the information about the partition mode may include index information specifying a partition shape of a current coding block.

[0046] According to the method and device for encoding an image signal of the present invention, the following operations may be performed: determining an MPM (most probable mode) candidate of a current coding block based on an intra-frame prediction mode of a neighboring block adjacent to the current coding block; determining an intra-frame prediction mode of the current coding block; and encoding information indicating whether there is an MPM candidate that is the same as the intra-frame prediction mode of the current coding block.

[0047] In the method and apparatus for encoding an image signal according to the present invention, the number of intra prediction modes available for a current coding block may be variably determined according to the size of the current coding block, the shape of the current coding block, or the intra prediction modes of neighboring blocks.

[0048] In a method and apparatus for encoding an image signal according to the present invention, when the number of intra-frame prediction modes available for a current coding block is different from the number of intra-frame prediction modes available for a neighboring block, an MPM candidate corresponding to a directional prediction mode may be set to a prediction angle of the directional prediction mode.

[0049] Beneficial Effects

[0050] According to the present invention, the compression efficiency of an image can be improved by efficiently encoding / decoding coefficients in a local block.

[0051] According to the present invention, the compression efficiency of an image can be improved by efficiently encoding / decoding a partitioning method of a target encoding / decoding block when encoding / decoding the image.

[0052] According to the present invention, the compression efficiency of an image can be improved by efficiently encoding / decoding intra-prediction mode information of a target encoding / decoding block when encoding / decoding the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 is a block diagram illustrating an apparatus for encoding an image according to an embodiment of the present invention.

[0054] Figure 2 is a block diagram illustrating an apparatus for decoding an image according to an embodiment of the present invention.

[0055] Figure 3 is a diagram illustrating a method for encoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0056] Figure 4 : is a diagram showing a method of encoding a maximum value of coefficients of a partial block as an embodiment to which the present invention is applied.

[0057] Figure 5 is a diagram illustrating a method of encoding a first threshold flag for a local block as an embodiment to which the present invention is applied.

[0058] Figure 6 is a diagram illustrating a method of encoding a second threshold flag for a local block as an embodiment to which the present invention is applied.

[0059] Figure 7 : is a diagram showing a method of decoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0060] Figure 8 : is a diagram showing a method of decoding a maximum value of coefficients of a partial block as an embodiment to which the present invention is applied.

[0061] Fig. 9 is a diagram illustrating a method of decoding a first threshold flag for a partial block as an embodiment to which the present invention is applied.

[0062] Fig.10 is a diagram illustrating a method of decoding a second threshold flag for a partial block as an embodiment to which the present invention is applied.

[0063] Fig.11 is a diagram illustrating a method of deriving a first threshold flag / a second threshold flag for a current local block as an embodiment to which the present invention is applied.

[0064] Fig.12 : is a diagram showing a method of encoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0065] Fig.13 : is a diagram illustrating a method of encoding a first threshold flag of a local block as an embodiment to which the present invention is applied.

[0066] Fig.14 : is a diagram showing a method of decoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0067] Fig.15 is a diagram illustrating a method of decoding a first threshold flag for a partial block as an embodiment to which the present invention is applied.

[0068] Fig.16 is a diagram illustrating a method of deriving a first threshold flag for a current local block as an embodiment to which the present invention is applied.

[0069] Fig.17 is a diagram illustrating a method of determining a size / shape of a partial block based on partition index information as an embodiment to which the present invention is applied.

[0070] Fig.18 : is a diagram showing a method of encoding a local block coefficient flag based on the number of non-zero coefficients in a local block as an embodiment to which the present invention is applied.

[0071] Fig.19 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients in a local block as an embodiment to which the present invention is applied.

[0072] Fig. 20 : is a diagram showing a method of encoding a local block coefficient flag based on the number of non-zero coefficients up to a current coefficient as an embodiment to which the present invention is applied.

[0073] Fig.21: is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients up to a current coefficient as an embodiment to which the present invention is applied.

[0074] Fig. 22 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients in a local block as an embodiment to which the present invention is applied.

[0075] Fig.23 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients up to a current coefficient as an embodiment to which the present invention is applied.

[0076] Fig.24 is a block diagram illustrating an image encoding apparatus according to an embodiment of the present invention.

[0077] Fig.25 is a block diagram showing an image decoding apparatus according to an embodiment of the present invention.

[0078] Fig.26 is a diagram for explaining an intra prediction method using a DC mode.

[0079] Fig. 27 is a diagram for explaining an intra prediction method using a planar mode.

[0080] Fig.28 is a diagram for explaining an intra prediction method using a directional prediction mode.

[0081] Fig.29 is a diagram illustrating a method of encoding QT partition information for a coding block.

[0082] Fig.30 is a diagram illustrating a method of encoding BT partition information for encoding a block.

[0083] Fig.31 is a diagram illustrating a method of decoding QT partition information for decoding a block.

[0084] Fig.32 is a diagram illustrating a method of decoding BT partition information for decoding a block.

[0085] Fig.33 is a diagram showing the state of partitions in a coding block.

[0086] Fig.34 It is shown using a tree structure Fig.33 Schematic diagram of the optimal partition state of the input coding block shown in .

[0087] Fig.35is a flowchart illustrating a process of controlling the number or type of prediction modes in an encoding device.

[0088] Fig.36 and Fig.37 is a diagram showing an example in which 13 directional prediction modes are available for a current coding block.

[0089] Fig.38 and Fig.39 is a diagram showing an example in which 21 directional prediction modes are available for a current block.

[0090] Fig.40 is a flow chart illustrating a process of encoding the best intra prediction mode for a current coding block.

[0091] Fig.41 is a diagram illustrating an example of setting MPM candidates.

[0092] Fig.42 and Fig.43 is a diagram showing an example of quantizing a prediction angle.

[0093] Fig.44 is a diagram illustrating another example of setting MPM candidates.

[0094] Fig.45 is a diagram illustrating an example of neighboring blocks used to derive MPM candidates for a current coding block.

[0095] Fig.46 is a diagram illustrating an example of deriving MPM candidates from neighboring blocks that are not adjacent to a current coding block.

[0096] Fig.47 is a flow chart showing a process of decoding an intra prediction mode of a current decoding block. DETAILED DESCRIPTION

[0097] Best Practices

[0098] According to the method and device for encoding an image signal of the present invention, the following operations may be performed: encoding a local block coefficient flag indicating whether a coefficient of a current local block is a non-zero coefficient; encoding a first flag indicating whether an absolute value of the coefficient is greater than 1; encoding a second flag indicating whether an absolute value of the coefficient is greater than 2; encoding the remaining coefficients in the current local block that are not encoded based on the first flag or the second flag; and encoding the signs of the coefficients of the current local block.

[0099] The method and apparatus for encoding an image signal according to the present invention may encode a maximum value among absolute values ​​of coefficients of a current local block.

[0100] The method and apparatus for encoding an image signal according to the present invention can determine whether absolute values ​​of all coefficients in a current local block are less than a current threshold value; and encode a first threshold flag for the current local block based on a result of the determination.

[0101] In a method and apparatus for encoding an image signal according to the present invention, a first threshold flag may be encoded as false when the absolute values ​​of all coefficients in a current local block are greater than or equal to a current threshold, and may be encoded as true when the absolute values ​​of all coefficients in the current local block are less than the current threshold.

[0102] In the method and apparatus for encoding an image signal according to the present invention, when the first threshold flag is encoded as false, the current threshold may be updated to a next threshold.

[0103] In the method and apparatus for encoding an image signal according to the present invention, at least one of the first flag or the second flag may be selectively encoded according to a value of the first threshold flag.

[0104] In the method and apparatus for encoding an image signal according to the present invention, the current threshold may be a threshold belonging to a predetermined threshold range.

[0105] In the method and apparatus for encoding an image signal according to the present invention, the predetermined threshold may be determined based on at least one of a quantization parameter, a size of a block, or a pixel value range.

[0106] According to the method and device for decoding an image signal of the present invention, the following operations may be performed: decoding a local block coefficient flag indicating whether a coefficient of a current local block is a non-zero coefficient; decoding a first flag indicating whether an absolute value of the coefficient is greater than 1; decoding a second flag indicating whether an absolute value of the coefficient is greater than 2; decoding the remaining coefficients in the current local block that are not encoded based on the first flag or the second flag; and decoding the signs of the coefficients of the current local block.

[0107] The method and apparatus for decoding an image signal according to the present invention can decode the maximum value among the absolute values ​​of coefficients of the current local block.

[0108] The method and apparatus for decoding an image signal according to the present invention may decode a first threshold flag for a current local block.

[0109] In the method and apparatus for decoding an image signal according to the present invention, when the first threshold flag is false, the absolute values ​​of all coefficients in the current local block may be greater than or equal to the current threshold, and when the first threshold flag is true, the absolute values ​​of all coefficients in the current local block may be less than the current threshold.

[0110] In the method and apparatus for decoding an image signal according to the present invention, when the first threshold flag is false, the current threshold may be updated to the next threshold.

[0111] In the method and apparatus for decoding an image signal according to the present invention, at least one of the first flag or the second flag may be selectively encoded according to a value of the first threshold flag.

[0112] In the method and apparatus for decoding an image signal according to the present invention, the current threshold may be a threshold belonging to a predetermined threshold range.

[0113] In the method and apparatus for decoding an image signal according to the present invention, the predetermined threshold may be determined based on at least one of a quantization parameter, a size of a block, or a pixel value range.

[0114] The method and apparatus for encoding an image signal according to the present invention may perform the following operations: encoding a local block flag indicating whether there is at least one non-zero coefficient in a current local block; encoding a local block coefficient flag indicating whether a current coefficient of a current local block is a non-zero coefficient; encoding the absolute value of the current coefficient of the current local block; and encoding the sign of the current coefficient of the current local block.

[0115] In the method and apparatus for encoding an image signal according to the present invention, the local block coefficient flag may be encoded based on the number of non-zero coefficients in a previous local block.

[0116] In the method and apparatus for encoding an image signal according to the present invention, the step of encoding the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients in a previous local block.

[0117] In the method and apparatus for encoding an image signal according to the present invention, a local block coefficient flag may be encoded based on the number of non-zero coefficients up to a previous coefficient in a current local block.

[0118] In the method and apparatus for encoding an image signal according to the present invention, the step of encoding the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients up to a previous coefficient.

[0119] According to the method and device for decoding an image signal of the present invention, the following operations may be performed: decoding a local block flag indicating whether there is at least one non-zero coefficient in a current local block; decoding a local block coefficient flag indicating whether a current coefficient of the current local block is a non-zero coefficient; decoding the absolute value of the current coefficient of the current local block; and decoding the sign of the current coefficient of the current local block.

[0120] In the method and apparatus for decoding an image signal according to the present invention, the local block coefficient flag may be decoded based on the number of non-zero coefficients in a previous local block.

[0121] In the method and apparatus for decoding an image signal according to the present invention, the step of decoding the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients in a previous local block.

[0122] In the method and apparatus for decoding an image signal according to the present invention, the local block coefficient flag may be decoded based on the number of non-zero coefficients up to a previous coefficient in a current local block.

[0123] In the method and apparatus for decoding an image signal according to the present invention, the decoding of the local block coefficient flag may include changing probability information of the local block coefficient flag based on the number of non-zero coefficients up to a previous coefficient.

[0124] According to the present invention, the method and device for decoding an image signal can perform the following operations: decoding partition information indicating whether the current decoding block is partitioned into two local blocks; and when the partition information indicates that the current decoding block is partitioned into two local blocks, decoding information about the partition mode of the current decoding block, and partitioning the current decoding block into two local blocks based on the partition mode.

[0125] In the method and apparatus for decoding an image signal according to the present invention, the information about the partition mode may include at least one of the following information: direction information indicating a partition direction of a current decoding block or information specifying the accuracy of a size of a local block generated by partitioning the current decoding block.

[0126] In the method and apparatus for decoding an image signal according to the present invention, the horizontal length or vertical length of the partial block may have a value obtained by dividing the horizontal length or vertical length of the decoded block by 2 to a value obtained by dividing the horizontal length or vertical length of the decoded block by 2 to the Nth power (2 N ), where the value (N) is specified by the precision information.

[0127] In the method and apparatus for decoding an image signal according to the present invention, the information about the partition mode may include index information specifying a partition shape of a current decoding block.

[0128] According to the method and device for decoding an image signal of the present invention, the following operations may be performed: based on the intra-frame prediction modes of neighboring blocks adjacent to the current decoding block, an MPM (Most Probable Mode) candidate of the current decoding block is determined; information indicating whether there is an MPM candidate that is the same as the intra-frame prediction mode of the current decoding block is decoded; and the intra-frame prediction mode of the current decoding block is derived based on the information.

[0129] In the method and apparatus for decoding an image signal according to the present invention, the number of intra prediction modes available for a current decoding block may be variably determined according to the size of the current decoding block, the shape of the current decoding block, or the intra prediction modes of neighboring blocks.

[0130] In a method and apparatus for decoding an image signal according to the present invention, when the number of intra-frame prediction modes available for a current decoding block is different from the number of intra-frame prediction modes available for a neighboring block, an MPM candidate corresponding to a directional prediction mode may be set to a prediction angle of the directional prediction mode.

[0131] According to the present invention, the method and device for encoding an image signal can perform the following operations: determine whether a current coding block is partitioned into two local blocks; according to a result of the determination, encode partition information indicating whether the current coding block is partitioned into two local blocks; when the current coding block is determined to be partitioned into two local blocks, determine a partition mode of the current coding block; and based on the determination, encode information about the partition mode of the current coding block.

[0132] In the method and apparatus for encoding an image signal according to the present invention, the information about the partition mode may include at least one of the following information: direction information indicating a partition direction of a current coding block or information specifying the accuracy of a size of a local block generated by partitioning the current coding block.

[0133] In the method and apparatus for encoding an image signal according to the present invention, the horizontal length or vertical length of the partial block may have a value obtained by dividing the horizontal length or vertical length of the coding block by 2 to a value obtained by dividing the horizontal length or vertical length of the coding block by 2 to the Nth power (2 N ), where the value (N) is specified by the precision information.

[0134] In the method and apparatus for encoding an image signal according to the present invention, the information about the partition mode may include index information specifying a partition shape of a current coding block.

[0135] According to the method and device for encoding an image signal of the present invention, the following operations may be performed: determining an MPM (most probable mode) candidate of a current coding block based on an intra-frame prediction mode of a neighboring block adjacent to the current coding block; determining an intra-frame prediction mode of the current coding block; and encoding information indicating whether there is an MPM candidate that is the same as the intra-frame prediction mode of the current coding block.

[0136] In the method and apparatus for encoding an image signal according to the present invention, the number of intra prediction modes available for a current coding block may be variably determined according to the size of the current coding block, the shape of the current coding block, or the intra prediction modes of neighboring blocks.

[0137] In a method and apparatus for encoding an image signal according to the present invention, when the number of intra-frame prediction modes available for a current coding block is different from the number of intra-frame prediction modes available for a neighboring block, an MPM candidate corresponding to a directional prediction mode may be set to a prediction angle of the directional prediction mode.

[0138] Mode for Carrying Out the Invention

[0139] Various modifications may be made to the present invention, and there are various embodiments of the present invention, and examples of the present invention will now be provided with reference to the accompanying drawings and described in detail. However, the present invention is not limited thereto, and the exemplary embodiments may be interpreted as including all modifications, equivalents or substitutes within the technical concept and technical scope of the present invention. The same reference numerals represent the same elements described in the accompanying drawings.

[0140] 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 the terms. The terms are only used to distinguish one component from other components. For example, without departing from the scope of the present invention, the "first" component may be named as the "second" component, and the "second" component may also be similarly named as the "first" component. The term "and / or" includes a combination of multiple items or any one of the multiple items.

[0141] It will be understood that when an element is merely referred to as being “connected to” or “coupled to” another element in this specification rather than being “directly connected to” or “directly coupled to” another element, the element may be “directly connected to” or “directly coupled to” another element, or connected to or coupled to another element with other elements interposed therebetween. Conversely, it will be understood that when an element is referred to as being “directly connected to” or “directly coupled to” another element, there are no intervening elements.

[0142] The terms used in this specification are only used to describe specific embodiments and are not intended to limit the present invention. Unless there is a clear different meaning in the context, the expression used in the singular form covers the expression of the plural number. In this specification, it should be understood that terms such as "including", "having" and the like are intended to indicate the presence of the features, quantities, steps, actions, elements, parts or combinations thereof disclosed in the specification, and are not intended to exclude the possibility that one or more other features, quantities, steps, actions, elements, parts or combinations thereof may exist or may be added.

[0143] 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.

[0144] Figure 1 is a block diagram illustrating an apparatus for encoding an image according to an embodiment of the present invention.

[0145] Reference Figure 1 The image encoding device 100 may include a picture partition module 110, prediction modules 120 and 125, a transform module 130, a quantization module 135, a rearrangement module 160, an entropy encoding module 165, an inverse quantization module 140, an inverse transform module 145, a filter module 150 and a memory 155.

[0146] Figure 1 The constituent components shown in are shown independently in order to represent the characteristic functions that are different from each other in the image encoding device, but it does not mean that each constituent component is composed of separate hardware or software constituent units. In other words, for convenience, each constituent component includes each constituent component listed, and at least two constituent components of each constituent component can be combined to form a constituent component, or a constituent component can be divided into multiple constituent components to perform each function. If it does not depart from the essence of the present invention, the embodiment of combining each constituent component and the embodiment of dividing a constituent component are also included in the scope of the present invention.

[0147] In addition, some structures may not be indispensable structures for performing the necessary functions of the present invention, but are optional structures only for improving their performance. The present invention can be realized by only including indispensable components for realizing the essence of the present invention except for the structures for improving performance. Structures including only indispensable structures except for the optional structures only for improving performance are also included in the scope of the present invention.

[0148] The picture partition module 110 may partition the input picture into at least one block. Here, the block may represent a coding unit (CU), a prediction unit (PU), or a transform unit (TU). The partitioning may be performed based on at least one of a quadtree or a binary tree. A quadtree is a method of partitioning an upper block into four lower blocks whose width and height are half of the width and height of the upper block. A binary tree is a method of partitioning an upper block into two lower blocks whose width or height is half of the width or height of the upper block. By using a partition based on a binary tree, a block may have a square shape as well as a non-square shape.

[0149] Hereinafter, in an embodiment of the present invention, a coding unit may be used as a unit for performing encoding or may be used as a unit for performing decoding.

[0150] The prediction modules 120 and 125 may include an inter prediction module 120 for performing inter prediction and an intra prediction module 125 for performing intra prediction. It may be determined whether inter prediction or intra prediction is performed for a prediction unit, and specific information according to each prediction method (e.g., intra prediction mode, motion vector, reference picture, etc.) may be determined. Here, the processing unit for which prediction is performed may be different from the processing unit for which the prediction method and specific content are determined. For example, the prediction method, prediction mode, etc. may be determined in units of prediction units, and prediction may be performed in units of transform units.

[0151] 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 it may be transmitted to the decoding device. When a specific encoding mode is used, the original block may be encoded as it is without generating a prediction block through the prediction modules 120 and 125 to transmit to the decoding device.

[0152] In some cases, the inter-frame prediction module 120 may predict the prediction unit based on information of at least one of the previous picture or the subsequent picture of the current image, or may predict the 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.

[0153] The reference picture interpolation module may receive reference picture information from the memory 155, and may generate pixel information of integer pixels or pixel information less than integer pixels from the reference picture. In the case of luma pixels, an 8-tap DCT-based interpolation filter with different filter coefficients may be used to generate pixel information of integer pixels or pixel information less than integer pixels in units of 1 / 4 pixels. In the case of chrominance signals, an 4-tap DCT-based interpolation filter with different filter coefficients may be used to generate pixel information of integer pixels or pixel information less than integer pixels in units of 1 / 8 pixels.

[0154] The motion prediction module may perform motion prediction based on a reference picture interpolated by a reference picture interpolation module. Various methods such as a full search based block matching algorithm (FBMA), a three-step search (TSS), a new three-step search algorithm (NTS), etc. may be used as a method for calculating a motion vector. A motion vector may have a motion vector value in units of 1 / 2 pixel or 1 / 4 pixel based on an interpolated pixel. The motion prediction module may predict a current prediction unit by changing a motion prediction method. Various methods such as a skip method, a merge method, an advanced motion vector prediction (AMVP) method, etc. may be used as a motion prediction method.

[0155] The intra prediction module 125 may generate a prediction unit based on reference pixel information adjacent to the current block, wherein the reference pixel information adjacent to the current block is pixel information in the current picture. When the neighboring block of the current prediction unit is a block on which inter prediction is performed and thus the reference pixel is a pixel on which inter prediction is performed, the reference pixel information of the neighboring block on which intra prediction is performed may be used to replace the reference pixel included in the block on which inter prediction is performed. 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.

[0156] The prediction mode in the intra prediction may include a directional prediction mode using reference pixel information depending on the prediction direction and a non-directional prediction mode that does not use the directional information when performing the prediction. The mode for predicting the luminance information may be different from the mode for predicting the chrominance information, and in order to predict the chrominance information, the intra prediction mode information for predicting the luminance information or the predicted luminance signal information may be used.

[0157] In the intra prediction method, a prediction block may be generated after an adaptive intra smoothing (AIS) filter is applied to reference pixels according to a prediction mode. The type of the AIS filter applied to the reference pixels may vary. In order to perform the intra prediction method, an intra prediction mode of a current prediction unit may be predicted based on an intra prediction mode of a prediction unit adjacent to the current prediction unit. In the process of predicting the prediction mode of the current prediction unit by using mode information predicted from adjacent prediction units, 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 send 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, and 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.

[0158] In addition, a residual block including information on a residual value, which is a difference between the prediction unit on which prediction is performed 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.

[0159] The transform module 130 may transform the residual block including the residual data using a transform method such as discrete cosine transform (DCT), discrete sine transform (DST), and Karhunen Loeve Transform (KLT). Here, the transform method may be determined based on an intra prediction mode of a prediction unit used to generate the residual block. For example, DCT may be used in the horizontal direction, and DST may be used in the vertical direction, depending on the intra prediction mode.

[0160] The quantization module 135 may quantize the value transformed to the frequency domain by the transform module 130. The quantization coefficient may vary 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.

[0161] The transform module unit 130 and / or the quantization module 135 may be selectively included in the image encoding device 100. That is, the image encoding device 100 may perform at least one of transform or quantization on the residual data of the residual block, or may skip both transform and quantization, thereby encoding the residual block. Even if transform or quantization or both transform and quantization are not performed in the image encoding device 100, the block provided as an input of the entropy encoding module 165 is generally referred to as a transform block.

[0162] The rearrangement module 160 may rearrange coefficients of the quantized residual value.

[0163] The rearrangement module 160 may convert the coefficients in the two-dimensional block form into the coefficients in the one-dimensional vector form by a coefficient scanning method. For example, the rearrangement module 160 may scan from the DC coefficient to the coefficients in the high frequency domain using a predetermined scanning method to change the coefficients into the one-dimensional vector form.

[0164] 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).

[0165] The entropy encoding module 165 may 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 and transmission unit information, motion vector information, reference frame information, interpolation information of the block, filtering information, etc. In the entropy encoding module 165, the coefficients of the transform block may be encoded as non-zero coefficients, coefficients having an absolute value greater than 1 or 2, and various types of flags indicating the sign of the coefficient, etc., in units of local blocks in the transform block. Coefficients that are not encoded using only the flag may be encoded by the absolute value of the difference between the coefficient encoded by the flag and the coefficient of the actual transform block. Figure 3 and Fig.12 A method of encoding coefficients of a transform block is described in detail.

[0166] The entropy encoding module 165 may entropy encode coefficients of the coding unit input from the rearrangement module 160 .

[0167] 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 included in the prediction modules 120 and 125 to generate a reconstructed block.

[0168] The filter module 150 may include at least one of a deblocking filter, an offset correction unit, and an adaptive loop filter (ALF).

[0169] The deblocking filter can remove block distortion caused by the boundary between blocks in the reconstructed picture. In order to determine whether to perform deblocking, the pixels included in the multiple 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 the deblocking filter is applied, horizontal direction filtering and vertical direction filtering can be processed in parallel.

[0170] The offset correction module can correct the offset relative to the original picture in units of pixels in the picture to be deblocked. 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 partitioning the pixels of the picture into a predetermined number of regions, determining the region to be offset, and applying the offset to the determined region can be used.

[0171] Adaptive loop filtering (ALF) may be performed based on a value obtained by comparing a filtered reconstructed picture with an original picture. The pixels included in the picture may be divided into predetermined groups, a filter to be applied to each group may be determined, and filtering may be performed separately for each group. Information on whether to apply ALF and a luminance signal may be transmitted per coding unit (CU), and the shape and filter coefficient of the filter used for ALF may vary according to each block. In addition, a filter for ALF of the same shape (fixed shape) may be applied regardless of the characteristics of the application target block.

[0172] The memory 155 may store a reconstructed block or picture calculated by the filter module 150 , and may provide the stored reconstructed block or picture to the prediction modules 120 and 125 when performing inter prediction.

[0173] Figure 2 is a block diagram illustrating an apparatus for decoding an image according to an embodiment of the present invention.

[0174] Reference Figure 2 , the image decoding device 200 may include an entropy decoding module 210, a rearrangement module 215, a dequantization module 220, an inverse transform module 225, prediction modules 230 and 235, a filter module 240, and a memory 245.

[0175] When an image bitstream is input from the image encoding apparatus, the input bitstream may be decoded according to an inverse process of the image encoding apparatus.

[0176] The entropy decoding module 210 may perform entropy decoding according to an inverse process of entropy encoding by the entropy encoding module of the image encoding device. For example, various methods such as exponential Golomb coding, context adaptive variable length coding (CAVLC), and context adaptive binary arithmetic coding (CABAC) may be applied corresponding to the method performed by the image encoding device. In the entropy decoding module 210, the coefficients of the transform block may be decoded in units of local blocks in the transform block based on non-zero coefficients, coefficients having an absolute value greater than 1 or 2, and various types of flags indicating the signs of the coefficients. Coefficients that are not represented only by a flag may be decoded by combining the coefficients represented by the flag with the coefficients transmitted by the signal. Reference will be made to Figure 7 and Fig.14 A method of decoding coefficients of a transform block is described in detail.

[0177] The entropy decoding module 210 may decode information about intra prediction and inter prediction performed by the image encoding device.

[0178] 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 image encoding device. The rearrangement may include reconstructing and rearranging coefficients in a one-dimensional vector form into coefficients in a two-dimensional block form. The rearrangement module 215 may receive information related to coefficient scanning performed in the image encoding device, and may perform rearrangement via a method of inversely scanning the coefficients based on a scanning order performed in the image encoding device.

[0179] The inverse quantization module 220 may perform inverse quantization based on the quantization parameter received from the image encoding device and the rearranged coefficients of the block.

[0180] The inverse transform module 225 may perform inverse transform of the inverse quantized transform coefficient according to a predetermined transform method. Here, the transform method may be determined based on a prediction method (inter prediction / intra prediction), a size / shape of a block, information about an intra prediction mode, and the like.

[0181] 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 .

[0182] The prediction modules 230 and 235 may include a prediction unit determination module, an inter prediction module, and an intra prediction module. The prediction unit determination module may receive various information (such as prediction unit information, prediction mode information of an intra prediction method, information on motion prediction of an inter 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 prediction or intra prediction on the prediction unit. By using the information required in the inter prediction of the current prediction unit received from the image encoding device, the inter prediction module 230 may perform inter 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 prediction may be performed based on information of some pre-reconstructed areas in the current picture including the current prediction unit.

[0183] In order to perform inter prediction, which of the skip mode, the merge mode, the AMVP mode, and the inter-block copy mode is used as a motion prediction method of a prediction unit included in the coding unit may be determined for the coding unit.

[0184] The intra prediction module 235 may generate a prediction block based on pixel information in the current picture. When the prediction unit is a prediction unit to which intra prediction is performed, intra prediction may be performed based on intra prediction mode information of the prediction unit received from the image encoding device. 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 may filter the reference pixels of the current block, and may determine whether to apply the filter based on the prediction mode of the current prediction unit. AIS filtering may be performed on the reference pixels of the current block by using the prediction mode of the prediction unit and the AIS filter information received from the image encoding device. 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.

[0185] When the prediction mode of the prediction unit is a prediction mode for performing intra-frame prediction based on pixel values ​​obtained by interpolating reference pixels, the reference pixel interpolation module may interpolate the reference pixels to generate reference pixels of integer pixels or reference pixels less than integer pixels. When the prediction mode of the current prediction unit is a prediction mode for generating a prediction block without interpolating the reference pixels, the reference pixels may not be interpolated. When the prediction mode of the current block is a DC mode, the DC filter may generate a prediction block by filtering.

[0186] 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.

[0187] Information about whether to apply a deblocking filter to a corresponding block or picture and information about which of a strong filter and a weak filter to apply when applying the deblocking filter may be received from the image encoding device. The deblocking filter of the image decoding device may receive information about the deblocking filter from the image encoding device and may perform deblocking filtering on the corresponding block.

[0188] 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.

[0189] 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 image encoding device. The ALF information may be provided to be included in a specific parameter set.

[0190] 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.

[0191] Figure 3 is a diagram illustrating a method for encoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0192] The coefficients of the transform block may be encoded in units of predetermined blocks (hereinafter referred to as local blocks) in the image encoding device. The transform block may include one or more local blocks. The local block may be a block of N×M size. Here, N and M are natural numbers, and N and M may be equal to or different from each other. That is, the local block may be a square block or a non-square block. The size / shape of the local block predefined in the image encoding device may be fixed (for example, 4×4), or the size / shape of the local block may be variably determined according to the size / shape of the transform block. Optionally, the image encoding device may determine the optimal size / shape of the local block in consideration of encoding efficiency, and encode the local block. Information about the size / shape of the encoded local block may be signaled at the level of at least one of a sequence, a picture, a slice, or a block.

[0193] In the image encoding device, the order in which the local blocks included in the transform block are encoded may be determined according to a predetermined scan type (hereinafter referred to as the first scan type). In addition, the order in which the coefficients included in the local block are encoded may be determined according to a predetermined scan type (hereinafter referred to as the second scan type). The first scan type and the second scan type may be the same or different. For the first / second scan type, diagonal scanning, vertical scanning, horizontal scanning, etc. may be used. However, the present invention is not limited thereto, and one or more scan types with a predetermined angle may be added. The first / second scan type may be determined based on at least one of the coding block related information (e.g., maximum / minimum size, partitioning technique, etc.), the size / shape of the transform block, the size / shape of the local block, the prediction mode, the intra-frame prediction related information (e.g., the value of the intra-frame prediction mode, the directionality, the angle, etc.), or the inter-frame prediction related information.

[0194] The image encoding device may encode the position information of the coefficient having a non-zero value (hereinafter, referred to as a non-zero coefficient) that appears first in the above encoding order in the transform block. The encoding may be performed sequentially starting from the local block including the non-zero coefficient. Figure 3 Describes the process of encoding the coefficients of a local block.

[0195] The local block flag of the current local block may be encoded (S300). The local block flag may be encoded in units of local blocks. The local block flag may indicate whether there is at least one non-zero coefficient in the current local block. For example, when the local block flag is a first value, it may indicate that the current local block includes at least one non-zero coefficient, and when the local block flag is a second value, it may indicate that all coefficients of the current local block are 0.

[0196] The local block coefficient flag of the current local block may be encoded (S310). The local block coefficient flag may be encoded in units of coefficients. The local block coefficient flag may indicate whether the coefficient is a non-zero coefficient. For example, when the coefficient is a non-zero coefficient, the local block coefficient flag may be encoded as a first value, and when the coefficient is zero, the local block coefficient flag may be encoded as a second value. The local block coefficient flag may be selectively encoded according to the local block flag. For example, the current local block may be encoded for each coefficient in the local block only when there is at least one non-zero coefficient in the current local block (i.e., the local block flag is the first value).

[0197] A flag indicating whether the absolute value of the coefficient is greater than 1 (hereinafter, referred to as a first flag) may be encoded (S320). The first flag may be selectively encoded according to the value of the local block coefficient flag. For example, when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value), the first flag may be encoded by checking whether the absolute value of the coefficient is greater than 1. When the absolute value of the coefficient is greater than 1, the first flag is encoded as a first value, and when the absolute value of the coefficient is not greater than 1, the first flag may be encoded as a second value.

[0198] A flag indicating whether the absolute value of the coefficient is greater than 2 (hereinafter, referred to as a second flag) may be encoded (S330). The second flag may be selectively encoded according to the value of the first flag. For example, when the coefficient is greater than 1 (i.e., the first flag is a first value), the second flag may be encoded by checking whether the absolute value of the coefficient is greater than 2. When the absolute value of the coefficient is greater than 2, the second flag is encoded as the first value, and when the absolute value of the coefficient is not greater than 2, the second flag may be encoded as the second value.

[0199] The number of at least one of the first flag or the second flag may be at least one to at most N×M. Optionally, at least one of the first flag or the second flag may be a fixed number (e.g., one, two, or more) predefined in the image encoding device. The number of the first / second flags may vary according to the bit depth of the input image, the dynamic range of the original pixel values ​​in a specific area of ​​the image, the size / depth of the block, the partitioning technology (e.g., quadtree, binary tree), the transform technology (e.g., DST, DCT), whether to skip the transform, the quantization parameter, the prediction mode (e.g., intra / inter mode), etc. In addition to encoding the first / second flag, the nth flag indicating whether the absolute value of the coefficient is greater than n may also be encoded. Here, n may represent a natural number greater than 2. The number of the nth flag may be one, two, or more, and may be determined in the same / similar manner as the first / second flag described above.

[0200] The remaining coefficients that are not encoded based on the first / second flag may be encoded in the current partial block (S340). Here, encoding may be a process of encoding the coefficient value itself. The remaining coefficients may be equal to or greater than 2.

[0201] The sign of the coefficient of the local block may be encoded (S350). The sign may be encoded in a flag format in units of coefficients. The sign may be selectively encoded according to the value of the local block coefficient flag. For example, the sign may be encoded only when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value).

[0202] In addition, the above-mentioned step of encoding the coefficients of the local block may also include a process of specifying a range of coefficient values ​​belonging to the local block. Through the above-mentioned process, it can be confirmed whether there is at least one non-zero coefficient in the local block. The above-mentioned process can be implemented by at least one of (A) encoding the maximum value, (B) encoding the first threshold flag or (C) encoding the second threshold flag (to be described below). The above-mentioned process can be implemented by being included in any one of the above-mentioned steps S300 to S350, or can be implemented in the form of replacing at least one of the steps S300 to S350. In the following, reference will be made to Figures 4 to 6 A process of specifying a range of coefficient values ​​belonging to a partial block is described in detail.

[0203] Figure 4 : is a diagram showing a method of encoding a maximum value of coefficients of a partial block as an embodiment to which the present invention is applied.

[0204] Reference Figure 4 , the maximum value among the absolute values ​​of the coefficients of the current local block can be encoded (S400). Through the maximum value, the range of coefficient values ​​belonging to the current local block can be inferred. For example, when the maximum value is m, the coefficients of the current local block can fall within the range of 0 to m. The maximum value can be selectively encoded according to the value of the above-mentioned local block flag. For example, the maximum value can be encoded only when the current local block includes at least one non-zero coefficient (that is, the local block flag is the first value). When the coefficients of the current local block are all 0 (that is, the local block flag is the second value), the maximum value can be derived as 0.

[0205] In addition, through the maximum value, it can be determined whether at least one non-zero coefficient is included in the current local block. For example, when the maximum value is greater than 0, the current local block includes at least one non-zero coefficient, and when the maximum value is 0, all coefficients of the current local block may be 0. Therefore, the step of encoding the maximum value may be performed instead of the step of encoding the local block flag of S300.

[0206] Figure 5 : is a diagram illustrating a method of encoding a first threshold flag of a local block as an embodiment to which the present invention is applied.

[0207] The first threshold flag of the present invention may indicate whether all coefficients of the local block are less than a predetermined threshold. The number of thresholds may be N (N>=1), wherein the threshold range may be {T0, T1, T2, ..., T N-1 Here, the 0th threshold T0 represents the minimum value, and the N-1th threshold T N-1 represents the maximum value, {T0,T1,T2,...,T N-1} may be a threshold range in which the thresholds are arranged in ascending order. The number of thresholds may be predetermined in the image encoding device. The image encoding device may determine the optimal number of thresholds in consideration of encoding efficiency and encode the number.

[0208] The threshold value may be obtained by setting the minimum value to 1 and increasing the minimum value by n (n>=1). The threshold value may be predetermined in the image encoding device. The image encoding device may determine an optimal threshold value in consideration of encoding efficiency and encode the threshold value.

[0209] The threshold range may be determined differently according to a quantization parameter (QP).The QP is set at a level of at least one of a sequence, a picture, a slice, or a transform block.

[0210] For example, when the QP is greater than a predetermined QP threshold, it can be expected that the distribution of zero coefficients in the transform block will be higher. In this case, the threshold range can be determined as {3}, or the encoding process of the first / second threshold flag can be omitted, and the coefficients of the local block can be encoded through the above steps S300 to S350.

[0211] When the QP is less than a predetermined QP threshold, it can be expected that the distribution of non-zero coefficients in the transform block will be higher. In this case, the threshold range can be determined as {3, 5} or {5, 3}.

[0212] That is, the threshold range when the QP is small may have a different number and / or size (e.g., maximum value) of thresholds from the threshold range when the QP is large. The number of QP thresholds may be one, two, or more. The QP threshold may be predetermined in the image encoding device. For example, the QP threshold may correspond to a median value of a QP range available in the image encoding device. Alternatively, the image encoding device may determine an optimal QP threshold in consideration of encoding efficiency, and encode the QP threshold.

[0213] Alternatively, the threshold range may be determined differently depending on the size / shape of the block. Here, the block may represent a coding block, a prediction block, a transform block, or a local block. The size may be represented by at least one of width, height, the sum of width and height, or the number of coefficients.

[0214] For example, when the size of the block is smaller than the predetermined threshold size, the threshold range may be determined as {3}, or the encoding process of the first / second threshold flag may be omitted, and the coefficients of the local block may be encoded through the above steps S300 to S350. When the size of the block is larger than the predetermined threshold size, the threshold range may be determined as {3,5} or {5,3}.

[0215] That is, the threshold range when the size of the block is small may have a number and / or size (e.g., maximum value) of thresholds different from the threshold range when the size of the block is large. The number of threshold sizes may be one, two, or more. The threshold size may be predetermined in the image encoding device. For example, the threshold size may be represented by a×b, where a and b are 2, 4, 8, 16, 32, 64, or more, and a and b may be equal to or different from each other. Alternatively, the image encoding device may determine an optimal threshold size in consideration of encoding efficiency, and encode the threshold size.

[0216] Alternatively, the threshold range may be determined differently according to the range of pixel values. The range of pixel values ​​may be represented by the maximum value and / or minimum value of pixels belonging to a predetermined area. Here, the predetermined area may represent at least one of a sequence, a picture, a strip, or a block.

[0217] For example, when the difference between the maximum value and the minimum value of the range of pixel values ​​is less than the predetermined threshold difference, the threshold range is determined to be {3}, or the encoding process of the first / second threshold flag can be omitted, and the coefficients of the local block can be encoded through the above steps S300 to S350. When the difference is greater than the predetermined threshold difference, the threshold range can be determined to be {3,5} or {5,3}.

[0218] That is, the threshold range when the difference is small may have a different number and / or size (e.g., maximum value) of threshold values ​​from the threshold range when the difference is large. The number of threshold difference values ​​may be one, two, or more. The threshold difference value may be predetermined in the image encoding device. Alternatively, the image encoding device may determine an optimal threshold difference value in consideration of encoding efficiency, and encode the threshold difference value.

[0219] Reference Figure 5 , it can be determined whether the absolute values ​​of all coefficients in the current local block are less than the current threshold value (S500).

[0220] When the absolute values ​​of not all coefficients are less than the current threshold, the first threshold flag may be encoded as "false" (S510). In this case, the current threshold (i-th threshold) may be updated to the next threshold ((i+1)th threshold) (S520), and the above step S500 may be performed based on the updated current threshold. Alternatively, when the absolute values ​​of not all coefficients are less than the current threshold, the first threshold flag encoding process of step S510 may be omitted, and the current threshold may be updated to the next threshold.

[0221] When the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the current threshold may be updated by adding the current threshold to a predetermined constant. The predetermined constant may be an integer greater than or equal to 1. Here, the update may be repeatedly performed until the first threshold flag is encoded as "true". Based on the updated current threshold, step S500 may be performed. Optionally, when the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the update process may be terminated.

[0222] When the absolute values ​​of all coefficients are less than the current threshold, the first threshold flag may be encoded as “true” ( S530 ).

[0223] As described above, when the first threshold flag of the i-th threshold is "true", this may indicate that the absolute values ​​of all coefficients in the local block are less than the i-th threshold. When the first threshold flag of the i-th threshold is "false", this may indicate that the absolute values ​​of all coefficients in the local block are greater than or equal to the i-th threshold. Based on the first threshold flag being "true", the range of coefficient values ​​belonging to the local block may be specified. That is, when the first threshold flag of the i-th threshold is "true", the coefficients belonging to the local block may fall within the range of 0 to (i-threshold-1).

[0224] According to the encoded first threshold flag, at least one of the above steps S300 to S350 may be omitted.

[0225] For example, when the threshold range is {3, 5}, at least one of the first threshold flag of the threshold value "3" or the first threshold flag of the threshold value "5" may be encoded. When the first threshold flag of the threshold value "3" is "true", the absolute values ​​of all coefficients in the local block may fall within the range of 0 to 2. In this case, the coefficients of the local block may be encoded by performing the remaining steps except at least one of the above-mentioned steps S330 or S340, or the coefficients of the local block may be encoded by performing the remaining steps except at least one of S300, S330, or S340.

[0226] When the first threshold flag of the threshold value "3" is "false", the first threshold flag of the threshold value "5" may be encoded. When the first threshold flag of the threshold value "5" is "false", at least one of the absolute values ​​of the coefficients in the partial block may be greater than or equal to 5. In this case, the coefficients of the partial block may be encoded by performing the above-mentioned steps S300 to S350 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S300.

[0227] When the first threshold flag of the threshold value "5" is "true", the absolute values ​​of all coefficients in the partial block may fall within the range of 0 to 4. In this case, the coefficients of the partial block may be encoded by performing the above-mentioned steps S300 to S350 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S300.

[0228] In addition, the first threshold flag of the current local block can be derived based on the first threshold flag of another local block. In this case, the encoding process of the first threshold flag can be omitted, and the reference Fig.11 Describe this.

[0229] Figure 6 : is a diagram illustrating a method of encoding a second threshold flag of a local block as an embodiment to which the present invention is applied.

[0230] The second threshold flag of the present invention may indicate whether all coefficients of the local block are less than a predetermined threshold. The number of thresholds may be N (N>=1), wherein the threshold range may be {T0, T1, T2, ..., T N-1 Here, T0 (the 0th threshold) is the maximum value, T N-1 (the N-1th threshold) is the minimum value, {T0,T1,T2,...,T N-1} may be a threshold range in which the thresholds are arranged in descending order. The number of thresholds may be predetermined in the image encoding device. The image encoding device may determine the optimal number of thresholds in consideration of encoding efficiency and encode the number.

[0231] The threshold value may be obtained by setting the maximum value to m and reducing the minimum value by n (n>=1). m may be predetermined in the image encoding device. Alternatively, the image encoding device may determine the optimal maximum value m in consideration of encoding efficiency and encode the maximum value. The threshold value may be predetermined in the image encoding device. The image encoding device may determine the optimal threshold value in consideration of encoding efficiency and encode the threshold value.

[0232] As in Figure 5 As described in the embodiments of the present invention, the threshold range may be determined differently according to at least one of a quantization parameter, a size / shape of a block, or a range of a pixel value.

[0233] Reference Figure 6 , it can be determined whether the absolute values ​​of all coefficients in the current local block are less than the current threshold value (S600).

[0234] When the absolute values ​​of all coefficients are less than the current threshold, the second threshold flag may be encoded as "true" (S610). In this case, the current threshold (i-th threshold) may be updated to the next threshold ((i+1)th threshold) (S620), and the above step S600 may be performed based on the updated current threshold. Alternatively, when the absolute values ​​of all coefficients are less than the current threshold, the second threshold flag encoding process in step S610 may be omitted, and the current threshold may be updated to the next threshold.

[0235] When the current threshold reaches the minimum value of the thresholds or when the number of thresholds is 1, the current threshold may be updated by subtracting a predetermined constant from the current threshold. The predetermined constant may be an integer greater than or equal to 1. Here, the update may be repeatedly performed until the second threshold flag is encoded as "false". Similarly, based on the updated current threshold, the above step S600 may be performed. Optionally, when the current threshold reaches the minimum value of the threshold or when the number of thresholds is 1, the update process may be terminated.

[0236] When the absolute values ​​of not all coefficients are smaller than the current threshold, the second threshold flag may be encoded as "false" (S630).

[0237] As described above, when the second threshold flag of the i-th threshold is "true", this may indicate that the absolute values ​​of all coefficients in the local block are less than the i-th threshold. When the second threshold flag of the i-th threshold is "false", this may indicate that at least one of the absolute values ​​of all coefficients in the local block is greater than or equal to the i-th threshold.

[0238] According to the encoded second threshold flag, at least one of the above steps S300 to S350 may be omitted.

[0239] For example, when the threshold range is {5, 3}, at least one of the second threshold flag of the threshold value "5" or the second threshold flag of the threshold value "3" may be encoded. When the second threshold flag of the threshold value "5" is "false", at least one of the absolute values ​​of all coefficients in the partial block may be greater than or equal to 5. In this case, the coefficients of the partial block may be encoded by performing the above-mentioned steps S310 to S350 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S300.

[0240] When the second threshold flag of the threshold value "5" is "true", the second threshold flag of the threshold value "3" may be encoded. When the second threshold flag of the threshold value "3" is "true", the absolute value of the coefficient in the local block may fall within the range of 0 to 2. In this case, the coefficient of the local block may be encoded by performing the remaining steps except at least one of the above-mentioned steps S330 and S340, or the coefficient of the local block may be encoded by performing the remaining steps except at least one of S300, S330, or S340.

[0241] When the second threshold flag of the threshold value "3" is "false", at least one of the absolute values ​​of all coefficients in the partial block may be equal to or greater than 3. In this case, the coefficients of the partial block may be encoded by performing the above-mentioned steps S300 to S350 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S300.

[0242] In addition, the second threshold flag of the current local block can be derived based on the second threshold flag of another local block. In this case, the encoding process of the second threshold flag can be omitted, and the reference Fig.11 Describe this.

[0243] Figure 7 : is a diagram showing a method of decoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0244] The coefficients of the transform block may be decoded in units of predetermined blocks (hereinafter referred to as local blocks) in the image decoding device. The transform block may include one or more local blocks. The local block may be a block of N×M size. Here, N and M are natural numbers, and N and M may be equal to or different from each other. That is, the local block may be a square block or a non-square block. The size / shape of the local block predefined in the image decoding device may be fixed (for example, 4×4), the size / shape of the local block may be variably determined according to the size / shape of the transform block, or the size / shape of the local block may be variably determined based on information about the size / shape of the local block sent by a signal. Information about the size / shape of the local block may be sent by a signal at the level of at least one of a sequence, a picture, a slice, or a block.

[0245] In the image decoding device, the order in which the local blocks belonging to the transform block are decoded may be determined according to a predetermined scan type (hereinafter referred to as the first scan type). In addition, the order in which the coefficients belonging to the local block are decoded may be determined according to a predetermined scan type (hereinafter referred to as the second scan type). The first scan type and the second scan type may be the same or different. For the first / second scan type, diagonal scanning, vertical scanning, horizontal scanning, etc. may be used. However, the present invention is not limited thereto, and one or more scan types with a predetermined angle may be added. The first / second scan type may be determined based on at least one of the coding block related information (e.g., maximum / minimum size, partitioning technique, etc.), the size / shape of the transform block, the size / shape of the local block, the prediction mode, the intra-frame prediction related information (e.g., the value, directionality, angle, etc. of the intra-frame prediction mode), or the inter-frame prediction related information.

[0246] The image decoding apparatus may decode the position information of the coefficient having a non-zero value (hereinafter, referred to as a non-zero coefficient) that appears first in the above decoding order in the transform block. The decoding may be performed sequentially from the local block according to the position information. Figure 3 Describes the process of decoding the coefficients of a local block.

[0247] The local block flag of the current local block may be decoded (S700). The local block flag may be decoded in units of local blocks. The local block flag may indicate whether there is at least one non-zero coefficient in the current local block. For example, when the local block flag is a first value, it may indicate that the current local block includes at least one non-zero coefficient, and when the local block flag is a second value, it may indicate that all coefficients of the current local block are 0.

[0248] The local block coefficient flag of the current local block may be decoded (S710). The local block coefficient flag may be decoded in units of coefficients. The local block coefficient flag may indicate whether the coefficient is a non-zero coefficient. For example, when the local block coefficient flag is a first value, it may indicate that the coefficient is a non-zero coefficient, and when the local block coefficient flag is a second value, it may indicate that the coefficient is zero. The local block coefficient flag may be selectively decoded according to the local block flag. For example, the current local block may be decoded for each coefficient of the local block only when there is at least one non-zero coefficient in the current local block (i.e., the local block flag is a first value).

[0249] A flag indicating whether the absolute value of the coefficient is greater than 1 (hereinafter, referred to as a first flag) may be decoded (S720). The first flag may be selectively decoded according to the value of the local block coefficient flag. For example, when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value), the first flag may be decoded to check whether the absolute value of the coefficient is greater than 1. When the first flag is a first value, the absolute value of the coefficient is greater than 1, and when the first flag is a second value, the absolute value of the coefficient may be 1.

[0250] A flag indicating whether the absolute value of the coefficient is greater than 2 (hereinafter, referred to as a second flag) may be decoded (S730). The second flag may be selectively decoded according to the value of the first flag. For example, when the coefficient is greater than 1 (i.e., the first flag is a first value), the second flag may be decoded to check whether the absolute value of the coefficient is greater than 2. When the second flag is the first value, the absolute value of the coefficient is greater than 2, and when the second flag is the second value, the absolute value of the coefficient may be 2.

[0251] The number of at least one of the first flag or the second flag may be at least one to at most N×M. Optionally, at least one of the first flag or the second flag may be a fixed number (e.g., one, two, or more) predefined in the image decoding device. The number of the first / second flags may vary according to the bit depth of the input image, the dynamic range of the original pixel values ​​in a specific area of ​​the image, the size / depth of the block, the partitioning technology (e.g., quadtree, binary tree), the transform technology (e.g., DST, DCT), whether to skip the transform, the quantization parameter, the prediction mode (e.g., intra / inter mode), etc. In addition to decoding the first / second flag, the nth flag indicating whether the absolute value of the coefficient is greater than n may also be decoded. Here, n may represent a natural number greater than 2. The number of the nth flag may be one, two, or more, and may be determined in the same / similar manner as the first / second flag described above.

[0252] The remaining coefficients that are not decoded based on the first / second flag may be decoded in the current partial block (S740). Here, decoding may be a process of decoding the coefficient value itself. The remaining coefficients may be equal to or greater than 2.

[0253] The sign of the coefficient of the local block may be decoded (S750). The sign may be decoded in a flag format in units of coefficients. The sign may be selectively decoded according to the value of the local block coefficient flag. For example, the sign may be decoded only when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value).

[0254] In addition, the above-mentioned step of decoding the coefficients of the local block may also include a process of specifying a range of coefficient values ​​belonging to the local block. Through the above-mentioned process, it can be confirmed whether there is at least one non-zero coefficient in the local block. The above-mentioned process can be implemented by at least one of (A) decoding the maximum value, (B) decoding the first threshold flag or (C) decoding the second threshold flag (to be described below). The above-mentioned process can be implemented by being included in any one of the above-mentioned steps S700 to S750, or can be implemented in the form of replacing at least one of the steps S700 to S750. In the following, reference will be made to Figures 8 to 10 A process of specifying a range of coefficient values ​​belonging to a partial block is described in detail.

[0255] Figure 8 : is a diagram showing a method of decoding a maximum value of coefficients of a partial block as an embodiment to which the present invention is applied.

[0256] Reference Figure 8 , information indicating the maximum value among the absolute values ​​of the coefficients of the current local block may be decoded (S800). By using the maximum value of the information, the range of coefficient values ​​belonging to the current local block may be inferred. For example, when the maximum value is m, the coefficients of the current local block may fall within the range of 0 to m. The information indicating the maximum value may be selectively decoded according to the value of the local block flag. For example, the current local block may be decoded only when the current local block includes at least one non-zero coefficient (i.e., the local block flag is the first value). When the coefficients of the current local block are all 0 (i.e., the local block flag is the second value), the information indicating the maximum value may be derived as 0.

[0257] In addition, by using the maximum value of the information, it can be determined whether at least one non-zero coefficient is included in the current partial block. For example, when the maximum value is greater than 0, the current partial block includes at least one non-zero coefficient, and when the maximum value is 0, all coefficients of the current partial block may be 0. Therefore, the step of decoding the maximum value may be performed instead of the step of decoding the partial block flag of S700.

[0258] Fig. 9 is a diagram illustrating a method of decoding a first threshold flag of a local block as an embodiment to which the present invention is applied.

[0259] The first threshold flag of the present invention may indicate whether all coefficients of the local block are less than a predetermined threshold. The number of thresholds may be N (N>=1), wherein the threshold range may be {T0, T1, T2, ..., T N-1 Here, the 0th threshold T0 can represent the minimum value, and the N-1th threshold T N-1 It can represent the maximum value, {T0,T1,T2,...,T N-1} may be a threshold range in which the thresholds are arranged in ascending order. The number of thresholds may be predetermined in the image decoding device, or may be determined based on information about the number of thresholds transmitted by a signal.

[0260] The threshold value may be obtained by setting the minimum value to 1 and increasing the minimum value by n (n>=1). The threshold value may be set in the image decoding device, or may be determined based on signaled information about the threshold value.

[0261] The threshold range may be determined differently according to a quantization parameter (QP).The QP may be set at a level of at least one of a sequence, a picture, a slice, or a transform block.

[0262] For example, when the QP is greater than a predetermined QP threshold, the threshold range may be determined as {3}, or the decoding process of the first / second threshold flag may be omitted, and the coefficients of the partial block may be decoded through the above steps S700 to S750.

[0263] In addition, when the QP is less than a predetermined QP threshold, the threshold range may be determined as {3, 5} or {5, 3}.

[0264] That is, the threshold range when the QP is small may have a different number and / or size (e.g., maximum value) of thresholds from the threshold range when the QP is large. The number of QP thresholds may be one, two, or more. The QP threshold may be set in the image decoding device. For example, the QP threshold may correspond to the median of the QP range available in the image decoding device. Alternatively, the QP threshold may be determined based on information about the QP threshold signaled by the image encoding device.

[0265] Alternatively, the threshold range may be determined differently depending on the size / shape of the block. Here, the block may represent a coding block, a prediction block, a transform block, or a local block. The size may be represented by at least one of width, height, the sum of width and height, or the number of coefficients.

[0266] For example, when the size of the block is smaller than the predetermined size threshold, the threshold range may be determined as {3}, or the decoding process of the first / second threshold flag may be omitted, and the coefficients of the local block may be decoded through the above steps S700 to S750. In addition, when the size of the block is larger than the predetermined size threshold, the threshold range may be determined as {3,5} or {5,3}.

[0267] That is, the threshold range when the size of the block is small may have a number and / or size (e.g., maximum value) of thresholds different from the threshold range when the size of the block is large. The number of size thresholds may be one, two, or more. The size threshold may be set in the image decoding device. For example, the size threshold may be represented by a×b, where a and b are 2, 4, 8, 16, 32, 64, or more, and a and b may be the same or different. Alternatively, the size threshold may be determined based on information about the size threshold signaled by the image encoding device.

[0268] Alternatively, the threshold range may be determined differently according to the range of pixel values. The range of pixel values ​​may be represented by the maximum value and / or minimum value of pixels belonging to a predetermined area. Here, the predetermined area may represent at least one of a sequence, a picture, a strip, or a block.

[0269] For example, when the difference between the maximum value and the minimum value of the range of pixel values ​​is less than the predetermined threshold difference, the threshold range may be determined as {3}, or the decoding process of the first / second threshold flag may be omitted, and the coefficients of the local block may be decoded through the above steps S700 to S750. In addition, when the difference is greater than the predetermined threshold difference, the threshold range may be determined as {3,5} or {5,3}.

[0270] That is, the threshold range when the difference is small may have a different number and / or size (e.g., maximum value) of thresholds from the threshold range when the difference is large. The number of threshold difference values ​​may be one, two, or more. The threshold difference value may be set in the image decoding device, or may be determined based on information about the threshold difference value signaled by the image encoding device.

[0271] Reference Fig. 9 , the first threshold flag of the current threshold can be decoded (S900).

[0272] The first threshold flag may indicate whether the absolute values ​​of all coefficients of the local block are less than the current threshold. For example, when the first threshold flag is "false", it may indicate that the absolute values ​​of all coefficients of the local block are greater than or equal to the current threshold. In addition, when the first threshold flag is "true", it may indicate that the absolute values ​​of all coefficients of the local block are less than the current threshold.

[0273] When the first threshold flag is "false", the current threshold (i-th threshold) may be updated to the next threshold (i+1-th threshold) (S910), and the above step S900 may be performed based on the updated current threshold.

[0274] When the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the current threshold may be updated by adding the current threshold to a predetermined constant. The predetermined constant may be an integer greater than or equal to 1. Here, the update may be repeatedly performed until the first threshold that is "true" is decoded. Optionally, when the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the update process may be terminated.

[0275] like Fig. 9 As shown, when the first threshold flag is "true", decoding of the first threshold flag may no longer be performed.

[0276] As described above, when the first threshold flag of the i-th threshold is "true", it may indicate that the absolute values ​​of all coefficients in the local block are less than the i-th threshold. In addition, when the first threshold flag of the i-th threshold is "false", it may indicate that the absolute values ​​of all coefficients in the local block are greater than or equal to the i-th threshold. Based on the first threshold flag being "true", the range of coefficient values ​​belonging to the local block may be specified. That is, when the first threshold flag of the i-th threshold is "true", the coefficients belonging to the local block may fall within the range of 0 to (i-threshold-1).

[0277] According to the decoded first threshold flag, at least one of the above steps S700 to S750 may be omitted.

[0278] For example, when the threshold range is {3, 5}, at least one of the first threshold flag of the threshold value "3" or the first threshold flag of the threshold value "5" may be decoded. When the first threshold flag of the threshold value "3" is "true", the absolute values ​​of all coefficients in the local block may fall within the range of 0 to 2. In this case, the coefficients of the local block may be decoded by performing the remaining steps except at least one of the above steps S730 or S740, or the coefficients of the local block may be decoded by performing the remaining steps except at least one of the above steps S700, S730, or S740.

[0279] When the first threshold flag of the threshold value "3" is "false", the first threshold flag of the threshold value "5" may be decoded. When the first threshold flag of the threshold value "5" is "false", at least one of the absolute values ​​of the coefficients in the partial block may be greater than or equal to 5. In this case, the coefficients of the partial block may be decoded by performing the above-mentioned steps S700 to S750 in the same manner, or the coefficients of the partial block may be decoded by performing the remaining steps except step S700.

[0280] In addition, when the first threshold flag of the threshold value "5" is "true", the absolute values ​​of all coefficients in the partial block may fall within the range of 0 to 4. In this case, the coefficients of the partial block may be decoded by performing the above-mentioned steps S700 to S750 in the same manner, or the coefficients of the partial block may be decoded by performing the remaining steps except step S700.

[0281] In addition, the first threshold flag of the current local block can be derived based on the first threshold flag of another local block. In this case, the decoding process of the first threshold flag can be omitted, and the reference Fig.11 Describe this.

[0282] Fig.10 : is a diagram illustrating a method of decoding a second threshold flag of a local block as an embodiment to which the present invention is applied.

[0283] The second threshold flag of the present invention may indicate whether all coefficients of the local block are less than a predetermined threshold. The number of thresholds may be N (N>=1), wherein the threshold range may be {T0, T1, T2, ..., T N-1 Here, the 0th threshold T0 can represent the maximum value, and the N-1th threshold T N-1 The minimum value that can be represented is {T0,T1,T2,...,T N-1} may be a threshold range in which the thresholds are arranged in descending order. The number of thresholds may be predetermined in the image decoding device, or may be determined based on information on the number of thresholds signaled by the image encoding device.

[0284] The threshold value may be obtained by setting the maximum value to m and reducing the minimum value by n (n>=1). m may be predetermined in the image decoding device, or may be determined based on information about the maximum value (m) signaled by the image encoding device. The threshold value may be predetermined in the image decoding device, or may be determined based on information about the threshold value signaled by the image encoding device.

[0285] As in Fig. 9 As described in the embodiments of the present invention, the threshold range may be determined differently based on at least one of a quantization parameter, a size / shape of a block, or a range of a pixel value.

[0286] Reference Fig.10 , a second threshold flag related to the current threshold can be decoded (S1000).

[0287] The second threshold flag may indicate whether the absolute values ​​of all coefficients of the local block are less than the current threshold. For example, when the second threshold flag is "false", it may indicate that the absolute values ​​of all coefficients of the local block are greater than or equal to the current threshold. In addition, when the second threshold flag is "true", it may indicate that the absolute values ​​of all coefficients of the local block are less than the current threshold.

[0288] When the second threshold flag is "true", the current threshold (i-th threshold) is updated to the next threshold ((i+1)-th threshold) (S1010), and the above step S1000 can be performed based on the updated current threshold.

[0289] In addition, when the second threshold flag is "false", decoding of the second threshold flag may no longer be performed.

[0290] When the current threshold reaches the minimum value of the threshold or when the number of thresholds is 1, the current threshold may be updated by subtracting a predetermined constant from the current threshold. The predetermined constant may be an integer greater than or equal to 1. Here, the update may be repeatedly performed until a second threshold flag of "false" is decoded. Optionally, when the current threshold reaches the minimum value of the threshold or when the number of thresholds is 1, the update process may be terminated.

[0291] As described above, when the second threshold flag of the i-th threshold is "true", this may indicate that the absolute values ​​of all coefficients in the local block are less than the i-th threshold. In addition, when the second threshold flag of the i-th threshold is "false", this may indicate that at least one of the absolute values ​​of all coefficients in the local block is greater than or equal to the i-th threshold.

[0292] According to the decoded second threshold flag, at least one of the above steps S700 to S750 may be omitted.

[0293] For example, when the threshold range is {5, 3}, at least one of the second threshold flag of the threshold value "5" or the second threshold flag of the threshold value "3" may be decoded. When the second threshold flag of the threshold value "5" is "false", at least one of the absolute values ​​of all coefficients in the partial block may be greater than or equal to 5. In this case, the coefficients of the partial block may be decoded by performing the above-mentioned steps S710 to S750, or the coefficients of the partial block may be decoded by performing the remaining steps except step S700.

[0294] When the second threshold flag of the threshold value "5" is "true", the second threshold flag of the threshold value "3" may be decoded. When the second threshold flag of the threshold value "3" is "true", the absolute value of the coefficient in the partial block may fall within the range of 0 to 2. In this case, the coefficient of the partial block may be decoded by performing the remaining steps except at least one of the above-mentioned steps S730 or S740, or the coefficient of the partial block may be decoded by performing the remaining steps except at least one of steps S700, S730, or S740.

[0295] In addition, when the second threshold flag of the threshold value "3" is "false", at least one of the absolute values ​​of all coefficients in the partial block may be equal to or greater than 3. In this case, the coefficients of the partial block may be decoded by performing the above-mentioned steps S700 to S750 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S700.

[0296] In addition, the second threshold flag of the current local block can be derived based on the second threshold flag of another local block. In this case, the decoding process of the second threshold flag can be omitted, and the reference Fig.11 Describe this.

[0297] Fig.11 : is a diagram illustrating a method of deriving a first threshold flag / a second threshold flag of a current local block as an embodiment to which the present invention is applied.

[0298] In this embodiment, it is assumed that the transform block 1100 is 8×8, the local block is 4×4, the block including the first non-zero coefficient is 1120, and the local blocks of the transform block are encoded / decoded in the order of 1140, 1120, 1130, and 1110 according to the scan type.

[0299] In the current local block, the first threshold flag of a specific threshold may be derived based on the first threshold flag of the previous local block. For example, based on the first threshold flag of "false" in the previous local block, the first threshold flag of the current local block may be derived as "false". Here, it is assumed that {3, 5, 7} is used as the threshold range.

[0300] Specifically, since the local block 1140 at the first position in the encoding / decoding order has an earlier encoding / decoding order than the position of the local block 1120 to which the first non-zero coefficient belongs, the first threshold flag may not be encoded / decoded. In the local block 1120 at the second position in the encoding / decoding order, since the first threshold flag of the threshold value "3" is "true", only the first threshold flag of the threshold value "3" may be encoded / decoded. In the local block 1130 at the third position in the encoding / decoding order, since the first threshold flag of the threshold value "3" is "false" and the first threshold flag of the threshold value "5" is "true", the first threshold flag of the threshold value "3" and the first threshold flag of the threshold value "5" may be encoded / decoded respectively. In the local block 1110 at the last position in the encoding / decoding order, the first threshold flag of the threshold value "3" is "false" and the first threshold flag of the threshold value "5" is "false". Here, since the first threshold flag of the threshold "3" in the previous local block 1130 is "false", it can be expected that the current local block 1110 has at least one coefficient whose absolute value is equal to or greater than 3, and it can be deduced that the first threshold flag of the threshold "3" is "false".

[0301] In the current local block, the first threshold flag of a specific threshold can be derived based on the first threshold flag of the previous local block. For example, based on the first threshold flag of "false" in the previous local block, the first threshold flag of the current local block can be derived as "false".

[0302] In this embodiment, for ease of explanation, the transform block 1100 is 8×8, the local block is 4×4, the threshold range is {3, 5, 7}, the block including the first non-zero coefficient is 1120, and the local blocks of the transform block are encoded / decoded in the order of 1140, 1120, 1130, and 1110 according to the scan type.

[0303] Likewise, in the current local block, the second threshold flag of a specific threshold may be derived based on the second threshold flag of the previous local block. For example, based on the first threshold flag of "false" in the previous local block, the first threshold flag of the current local block may be derived as "false". Here, it is assumed that {7, 5, 3} is used as the threshold range.

[0304] Specifically, since the local block 1140 at the first position in the encoding / decoding order has an earlier encoding / decoding order than the position of the local block 1120 to which the first non-zero coefficient belongs, the second threshold flag may not be encoded / decoded. In the local block 1120 at the second position in the encoding / decoding order, since the second threshold flag of the threshold value "7" is "true", the second threshold flag of the threshold value "5" is "true" and the second threshold flag of the threshold value "3" is "true", the second threshold flag of the threshold value "7", the second threshold flag of the threshold value "5" and the second threshold flag of the threshold value "3" may be encoded / decoded respectively. In the local block 1130 at the third position in the encoding / decoding order, since the second threshold flag of the threshold value "7" and the second threshold flag of the threshold value "5" are respectively "true", and the second threshold flag of the threshold value "3" is "false". In the local block 1110 at the last position in the encoding / decoding order, the second threshold flag of the threshold value "3" is "false". Here, by utilizing that the second threshold flag of threshold "3" in the previous local block 1130 is "false", in the current local block 1110, the second threshold flag of threshold "3" may not be encoded / decoded, and it can be deduced that the second threshold flag of threshold "3" is "false".

[0305] Fig.12 : is a diagram showing a method of encoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0306] In an image encoding device, coefficients of a transform block may be encoded in units of predetermined block units (hereinafter referred to as local blocks). A transform block may include one or more local blocks. A local block may be a block of N×M size. Here, N and M are natural numbers, and N and M may be the same as or different from each other. That is, a local block may be a square block or a non-square block. The size / shape of a local block predefined in the image encoding device may be fixed (e.g., 4×4), or the size / shape of the local block may be variably determined according to the size / shape of the transform block. Alternatively, the image encoding device may determine the optimal size / shape of the local block in consideration of encoding efficiency, and encode the local block. Information about the size / shape of the encoded local block may be signaled at the level of at least one of a sequence, a picture, a slice, or a block.

[0307] In the image encoding device, the order in which the local blocks included in the transform block are encoded may be determined according to a predetermined scan type (hereinafter referred to as the first scan type). In addition, the order in which the coefficients included in the local block are encoded may be determined according to a predetermined scan type (hereinafter referred to as the second scan type). The first scan type and the second scan type may be the same or different. For the first / second scan type, diagonal scanning, vertical scanning, horizontal scanning, etc. may be used. However, the present invention is not limited thereto, and one or more scan types with a predetermined angle may be added. The first / second scan type may be determined based on at least one of the coding block related information (e.g., maximum / minimum size, partitioning technique, etc.), the size / shape of the transform block, the size / shape of the local block, the prediction mode, the intra-frame prediction related information (e.g., the value of the intra-frame prediction mode, the directionality, the angle, etc.), or the inter-frame prediction related information.

[0308] The image encoding device may encode the position information of the coefficient having a non-zero value (hereinafter, referred to as a non-zero coefficient) that appears first in the above encoding order in the transform block. The encoding may be performed sequentially from the local block including the non-zero coefficient. Fig.12 Describes the process of encoding the coefficients of a local block.

[0309] The local block flag of the current local block may be encoded (S1200). The local block flag may be encoded in units of local blocks. The local block flag may indicate whether there is at least one non-zero coefficient in the current local block. For example, when the local block flag is a first value, it may indicate that the current local block includes at least one non-zero coefficient, and when the local block flag is a second value, it may indicate that all coefficients of the current local block are 0.

[0310] The local block coefficient flag of the current local block may be encoded (S1210). The local block coefficient flag may be encoded in units of coefficients. The local block coefficient flag may indicate whether the coefficient is a non-zero coefficient. For example, when the coefficient is a non-zero coefficient, the local block coefficient flag may be encoded as a first value, and when the coefficient is zero, the local block coefficient flag may be encoded as a second value. The local block coefficient flag may be selectively encoded according to the local block flag. For example, the current local block may be encoded for each coefficient of the local block only when there is at least one non-zero coefficient in the current local block (i.e., the local block flag is the first value).

[0311] A flag indicating whether the absolute value of the coefficient is greater than 1 (hereinafter, referred to as a first flag) may be encoded (S1220). The first flag may be selectively encoded according to the value of the local block coefficient flag. For example, when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value), the first flag may be encoded by checking whether the absolute value of the coefficient is greater than 1. When the absolute value of the coefficient is greater than 1, the first flag is encoded as a first value, and when the absolute value of the coefficient is not greater than 1, the first flag may be encoded as a second value.

[0312] A flag indicating whether the absolute value of the coefficient is greater than 2 (hereinafter, referred to as a second flag) may be encoded (S1230). The second flag may be selectively encoded according to the value of the first flag. For example, when the coefficient is greater than 1 (i.e., the first flag is a first value), the second flag may be encoded by checking whether the absolute value of the coefficient is greater than 2. When the absolute value of the coefficient is greater than 2, the second flag is encoded as the first value, and when the absolute value of the coefficient is not greater than 2, the second flag may be encoded as the second value.

[0313] The number of at least one of the first flag or the second flag may be at least one to at most N×M. Optionally, at least one of the first flag or the second flag may be a fixed number (e.g., one, two, or more) predefined in the image encoding device. The number of the first / second flags may vary according to the size / depth of the block, the partitioning technique (e.g., quadtree, binary tree), the transform technique (e.g., DST, DCT), whether to skip the transform, the quantization parameter, the prediction mode (e.g., intra / inter mode), etc. In addition to encoding the first / second flag, the nth flag indicating whether the absolute value of the coefficient is greater than n may be encoded. Here, n may represent a natural number greater than 2. The number of the nth flag may be one, two, or more, and may be determined in the same / similar manner as the first / second flag described above.

[0314] The remaining coefficients that are not encoded based on the first / second flag may be encoded in the current local block (S1240). Here, encoding may be a process of encoding the coefficient value itself. The remaining coefficients may be equal to or greater than 2. The remaining coefficients may be encoded based on at least one of the local block coefficient flag, the first flag of the remaining coefficients, or the second flag. For example, the remaining coefficients may be encoded as a value obtained by subtracting (local block coefficient flag+first flag+second flag) from the absolute value of the remaining coefficients.

[0315] The sign of the coefficient of the local block may be encoded (S1250). The sign may be encoded in a flag format per coefficient. The sign may be selectively encoded according to the value of the local block coefficient flag. For example, the sign may be encoded only when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value).

[0316] As described above, each of the absolute values ​​of the coefficients of the partial block may be encoded by at least one of encoding the partial block coefficient flag, encoding the first flag, encoding the second flag, or encoding the remaining coefficients.

[0317] In addition, the above-mentioned step of encoding the coefficients of the local block may also include a process of specifying a range of coefficient values ​​belonging to the local block. Through the above-mentioned process, it can be confirmed whether there is at least one non-zero coefficient in the local block. The above-mentioned process can be implemented by encoding a first threshold flag (to be described below). The above-mentioned process can be implemented by being included in any one of the above-mentioned steps S1200 to S1250, or can be implemented in the form of replacing at least one of the steps S1200 to S1250. In the following, reference will be made to Fig.13 A process of specifying a range of coefficient values ​​belonging to a partial block is described in detail.

[0318] Fig.13 : is a diagram illustrating a method of encoding a first threshold flag of a local block as an embodiment to which the present invention is applied.

[0319] The first threshold flag of the present invention may indicate whether all coefficients of the local block are less than a predetermined threshold. The number of thresholds may be N (N>=1), wherein the threshold range may be {T0, T1, T2, ..., T N-1 Here, the 0th threshold T0 represents the minimum value, and the N-1th threshold T N-1 represents the maximum value, {T0,T1,T2,...,T N-1} may be a threshold range in which the thresholds are arranged in ascending order. The number of thresholds may be predetermined in the image encoding device. The image encoding device may determine the optimal number of thresholds in consideration of encoding efficiency.

[0320] The threshold value may be obtained by setting the minimum value to 1 and increasing the minimum value by n (n>=1). The threshold value may be predetermined in the image encoding device. The image encoding device may determine an optimal threshold value in consideration of encoding efficiency and encode the threshold value.

[0321] The threshold range may be determined differently according to a quantization parameter (QP).The QP may be set at a level of at least one of a sequence, a picture, a slice, or a transform block.

[0322] For example, when the QP is greater than a predetermined QP threshold, it can be expected that the distribution of zero coefficients in the transform block will be higher. In this case, the threshold range can be determined as {3}, or the encoding process of the first threshold flag can be omitted, and the coefficients of the local block can be encoded through the above steps S1200 to S1250.

[0323] When the QP is less than a predetermined QP threshold, it can be expected that the distribution of non-zero coefficients in the transform block will be higher. In this case, the threshold range can be determined as {3, 5} or {5, 3}.

[0324] That is, the threshold range when the QP is small may have a different number and / or size (e.g., maximum value) of thresholds from the threshold range when the QP is large. The number of QP thresholds may be one, two, or more. The QP threshold may be predetermined in the image encoding device. For example, the QP threshold may correspond to a median value of a QP range available in the image encoding device. Alternatively, the image encoding device may determine an optimal QP threshold in consideration of encoding efficiency, and encode the QP threshold.

[0325] Alternatively, the threshold range may be determined differently depending on the size / shape of the block. Here, the block may represent a coding block, a prediction block, a transform block, or a local block. The size may be represented by at least one of width, height, the sum of width and height, or the number of coefficients.

[0326] For example, when the size of the block is smaller than the predetermined threshold size, the threshold range may be determined as {3}, or the encoding process of the first threshold flag may be omitted, and the coefficients of the local block may be encoded through the above steps S1200 to S1250. When the size of the block is larger than the predetermined threshold size, the threshold range may be determined as {3,5} or {5,3}.

[0327] That is, the threshold range when the size of the block is small may have a number and / or size (e.g., maximum value) of thresholds different from the threshold range when the size of the block is large. The number of threshold sizes may be one, two, or more. The threshold size may be predetermined in the image encoding device. For example, the threshold size may be represented by a×b, where a and b are 2, 4, 8, 16, 32, 64, or more, and a and b may be equal to or different from each other. Alternatively, the image encoding device may determine an optimal threshold size in consideration of encoding efficiency, and encode the threshold size.

[0328] Alternatively, the threshold range may be determined differently according to the range of pixel values. The range of pixel values ​​may be represented by the maximum value and / or minimum value of pixels belonging to a predetermined area. Here, the predetermined area may represent at least one of a sequence, a picture, a strip, or a block.

[0329] For example, when the difference between the maximum value and the minimum value of the range of pixel values ​​is less than the predetermined threshold difference, the threshold range is determined to be {3}, or the encoding process of the first threshold flag can be omitted, and the coefficients of the local block can be encoded through the above steps S1200 to S1250. When the difference is greater than the predetermined threshold difference, the threshold range can be determined to be {3,5} or {5,3}.

[0330] That is, the threshold range when the difference is small may have a different number and / or size (e.g., maximum value) of threshold values ​​from the threshold range when the difference is large. The number of threshold difference values ​​may be one, two, or more. The threshold difference value may be predetermined in the image encoding device. Alternatively, the image encoding device may determine an optimal threshold difference value in consideration of encoding efficiency, and encode the threshold difference value.

[0331] Reference Fig.13 , it can be determined whether the absolute values ​​of all coefficients in the current local block are less than the current threshold (S1300).

[0332] When the absolute values ​​of not all coefficients are less than the current threshold, the first threshold flag may be encoded as "false" (S1310). In this case, the current threshold (i-th threshold) may be updated to the next threshold ((i+1)th threshold) (S1320), and the above step S1300 may be performed based on the updated current threshold. Alternatively, when the absolute values ​​of not all coefficients are less than the current threshold, the first threshold flag encoding process of step S1310 may be omitted, and the current threshold may be updated to the next threshold.

[0333] When the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the current threshold may be updated by adding the current threshold to a predetermined constant. The predetermined constant may be an integer greater than or equal to 1. Here, the update may be repeatedly performed until the first threshold flag is encoded as "true". Based on the updated current threshold, step S1300 may be performed. Optionally, when the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the update process may be terminated.

[0334] When the absolute values ​​of all coefficients are less than the current threshold, the first threshold flag may be encoded as “true” ( S1330 ).

[0335] As described above, when the first threshold flag of the i-th threshold is "true", this may indicate that the absolute values ​​of all coefficients in the local block are less than the i-th threshold. When the first threshold flag of the i-th threshold is "false", this may indicate that the absolute values ​​of all coefficients in the local block are greater than or equal to the i-th threshold. Based on the first threshold flag being "true", the range of coefficient values ​​belonging to the local block may be specified. That is, when the first threshold flag of the i-th threshold is "true", the coefficients belonging to the local block may fall within the range of 0 to (i-threshold-1).

[0336] According to the encoded first threshold flag, at least one of the above steps S1200 to S1250 may be omitted.

[0337] For example, when the threshold range is {3, 5}, at least one of the first threshold flag of the threshold value "3" or the first threshold flag of the threshold value "5" may be encoded. When the first threshold flag of the threshold value "3" is "true", the absolute values ​​of all coefficients in the local block may fall within the range of 0 to 2. In this case, the coefficients of the local block may be encoded by performing the remaining steps except at least one of the above-mentioned steps S1230 or S1240, or the coefficients of the local block may be encoded by performing the remaining steps except at least one of S1200, S1230, or S1240.

[0338] When the first threshold flag of the threshold value "3" is "false", the first threshold flag of the threshold value "5" may be encoded. When the first threshold flag of the threshold value "5" is "false", at least one of the absolute values ​​of the coefficients in the partial block may be greater than or equal to 5. In this case, the coefficients of the partial block may be encoded by performing the above-mentioned steps S1200 to S1250 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S1200.

[0339] When the first threshold flag of the threshold value "5" is "true", the absolute values ​​of all coefficients in the partial block may fall within the range of 0 to 4. In this case, the coefficients of the partial block may be encoded by performing the above-mentioned steps S1200 to S1250 in the same manner, or the coefficients of the partial block may be encoded by performing the remaining steps except step S1200.

[0340] In addition, the first threshold flag of the current local block can be derived based on the first threshold flag of another local block. In this case, the encoding process of the first threshold flag can be omitted, and the reference Fig.16 Describe this.

[0341] Fig.14 : is a diagram showing a method of decoding coefficients of a transform block as an embodiment to which the present invention is applied.

[0342] The coefficients of the transform block may be decoded in units of predetermined blocks (hereinafter referred to as local blocks) in the image decoding device. The transform block may include one or more local blocks. The local block may be a block of N×M size. Here, N and M are natural numbers, and N and M may be equal to or different from each other. That is, the local block may be a square block or a non-square block. The size / shape of the local block predefined in the image decoding device may be fixed (for example, 4×4), the size / shape of the local block may be variably determined according to the size / shape of the transform block, or the size / shape of the local block may be variably determined based on information about the size / shape of the local block sent by a signal. Information about the size / shape of the local block may be sent by a signal at the level of at least one of a sequence, a picture, a slice, or a block.

[0343] In the image decoding device, the order in which the local blocks belonging to the transform block are decoded may be determined according to a predetermined scan type (hereinafter referred to as the first scan type). In addition, the order in which the coefficients belonging to the local block are decoded may be determined according to a predetermined scan type (hereinafter referred to as the second scan type). The first scan type and the second scan type may be the same or different. For the first / second scan type, diagonal scanning, vertical scanning, horizontal scanning, etc. may be used. However, the present invention is not limited thereto, and one or more scan types with a predetermined angle may be added. The first / second scan type may be determined based on at least one of the coding block related information (e.g., maximum / minimum size, partitioning technique, etc.), the size / shape of the transform block, the size / shape of the local block, the prediction mode, the intra-frame prediction related information (e.g., the value, directionality, angle, etc. of the intra-frame prediction mode), or the inter-frame prediction related information.

[0344] The image decoding apparatus may decode the position information of the coefficient having a non-zero value (hereinafter, referred to as a non-zero coefficient) that appears first in the above decoding order in the transform block. The decoding may be performed sequentially from the local block according to the position information. Fig.14 Describes the process of decoding the coefficients of a local block.

[0345] The local block flag of the current local block may be decoded (S1400). The local block flag may be decoded in units of local blocks. The local block flag may indicate whether there is at least one non-zero coefficient in the current local block. For example, when the local block flag is a first value, it may indicate that the current local block includes at least one non-zero coefficient, and when the local block flag is a second value, it may indicate that all coefficients of the current local block are 0.

[0346] The local block coefficient flag of the current local block may be decoded (S1410). The local block coefficient flag may be decoded in units of coefficients. The local block coefficient flag may indicate whether the coefficient is a non-zero coefficient. For example, when the local block coefficient flag is a first value, it may indicate that the coefficient is a non-zero coefficient, and when the local block coefficient flag is a second value, it may indicate that the coefficient is zero. The local block coefficient flag may be selectively decoded according to the local block flag. For example, the current local block may be decoded for each coefficient of the local block only when there is at least one non-zero coefficient in the current local block (i.e., the local block flag is a first value).

[0347] A flag indicating whether the absolute value of the coefficient is greater than 1 (hereinafter, referred to as a first flag) may be decoded (S1420). The first flag may be selectively decoded according to the value of the local block coefficient flag. For example, when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value), the first flag may be decoded to check whether the absolute value of the coefficient is greater than 1. When the first flag is a first value, the absolute value of the coefficient is greater than 1, and when the first flag is a second value, the absolute value of the coefficient may be 1.

[0348] A flag indicating whether the absolute value of the coefficient is greater than 2 (hereinafter, referred to as a second flag) may be decoded (S1430). The second flag may be selectively decoded according to the value of the first flag. For example, when the coefficient is greater than 1 (i.e., the first flag is a first value), the second flag may be decoded to check whether the absolute value of the coefficient is greater than 2. When the second flag is the first value, the absolute value of the coefficient is greater than 2, and when the second flag is the second value, the absolute value of the coefficient may be 2.

[0349] The number of at least one of the first flag or the second flag may be at least one to at most N×M. Optionally, at least one of the first flag or the second flag may be a fixed number (e.g., one, two, or more) predefined in the image decoding device. The number of the first / second flags may vary according to the size / depth of the block, the partitioning technology (e.g., quadtree, binary tree), the transform technology (e.g., DST, DCT), whether to skip the transform, the quantization parameter, the prediction mode (e.g., intra / inter mode), etc. In addition to being able to decode the first / second flag, the nth flag indicating whether the absolute value of the coefficient is greater than n may be decoded. Here, n may represent a natural number greater than 2. The number of the nth flag may be one, two, or more, and may be determined in the same / similar manner as the first / second flag described above.

[0350] The remaining coefficients that are not decoded based on the first / second flag may be decoded in the current local block (S1440). Here, decoding may be a process of decoding the coefficient value itself. The remaining coefficients may be equal to or greater than 2. The remaining coefficients may be encoded based on at least one of the local block coefficient flag, the first flag of the remaining coefficients, or the second flag. For example, the remaining coefficients may be encoded as a value obtained by subtracting the absolute value of the remaining coefficients from (local block coefficient flag+first flag+second flag).

[0351] The sign of the coefficient of the local block may be decoded (S1450). The sign may be decoded in a flag format in units of coefficients. The sign may be selectively decoded according to the value of the local block coefficient flag. For example, the sign may be decoded only when the coefficient is a non-zero coefficient (i.e., the local block coefficient flag is a first value).

[0352] In addition, the above-mentioned step of decoding the coefficients of the local block may also include a process of specifying a range of coefficient values ​​belonging to the local block. Through the above-mentioned process, it can be confirmed whether there is at least one non-zero coefficient in the local block. The above-mentioned process can be implemented by decoding the first threshold flag (to be described below). The above-mentioned process can be implemented by being included in any one of the above-mentioned steps S1400 to S1450, or can be implemented in the form of replacing at least one of the steps S1400 to S1450. In the following, reference will be made to Fig.15 A process of specifying a range of coefficient values ​​belonging to a partial block is described in detail.

[0353] Fig.15 is a diagram illustrating a method of decoding a first threshold flag of a local block as an embodiment to which the present invention is applied.

[0354] The first threshold flag of the present invention may indicate whether all coefficients of the local block are less than a predetermined threshold. The number of thresholds may be N (N>=1), wherein the threshold range may be {T0, T1, T2, ..., T N-1 Here, the 0th threshold T0 can represent the minimum value, and the N-1th threshold T N-1 It can represent the maximum value, {T0,T1,T2,...,T N-1} may be a threshold range in which the thresholds are arranged in ascending order. The number of thresholds may be predetermined in the image decoding device, or may be determined based on information about the number of thresholds transmitted by a signal.

[0355] The threshold value may be obtained by setting the minimum value to 1 and increasing the minimum value by n (n>=1). The threshold value may be set in the image decoding device, or may be determined based on signaled information about the threshold value.

[0356] The threshold range may be determined differently according to a quantization parameter (QP).The QP may be set at a level of at least one of a sequence, a picture, a slice, or a transform block.

[0357] For example, when the QP is greater than a predetermined QP threshold, the threshold range may be determined as {3}, or the decoding process of the first threshold flag may be omitted, and the coefficients of the partial block may be decoded through the above steps S1400 to S1450.

[0358] In addition, when the QP is less than a predetermined QP threshold, the threshold range may be determined as {3, 5} or {5, 3}.

[0359] That is, the threshold range when the QP is small may have a different number and / or size (e.g., maximum value) of thresholds from the threshold range when the QP is large. The number of QP thresholds may be one, two, or more. The QP threshold may be set in the image decoding device. For example, the QP threshold may correspond to the median of the range of QPs available in the image decoding device. Alternatively, the QP threshold may be determined based on information about the QP threshold signaled by the image encoding device.

[0360] Alternatively, the threshold range may be determined differently depending on the size / shape of the block. Here, the block may represent a coding block, a prediction block, a transform block, or a local block. The size may be represented by at least one of width, height, the sum of width and height, or the number of coefficients.

[0361] For example, when the size of the block is smaller than the predetermined threshold size, the threshold range may be determined as {3}, or the decoding process of the first threshold flag may be omitted, and the coefficients of the local block may be decoded through the above steps S1400 to S1450. In addition, when the size of the block is larger than the predetermined threshold size, the threshold range may be determined as {3,5} or {5,3}.

[0362] That is, the threshold range when the size of the block is small may have a number and / or size (e.g., maximum value) of thresholds different from the threshold range when the size of the block is large. The number of size thresholds may be one, two, or more. The threshold size may be set in the image decoding device. For example, the threshold size may be represented by a×b, where a and b are 2, 4, 8, 16, 32, 64, or more, and a and b may be the same or different. Alternatively, the threshold size may be determined based on information about the threshold size signaled by the image encoding device.

[0363] Alternatively, the threshold range may be determined differently according to the range of pixel values. The range of pixel values ​​may be represented by the maximum value and / or minimum value of pixels belonging to a predetermined area. Here, the predetermined area may represent at least one of a sequence, a picture, a strip, or a block.

[0364] For example, when the difference between the maximum value and the minimum value of the range of pixel values ​​is less than the predetermined threshold difference, the threshold range may be determined as {3}, or the decoding process of the first threshold flag may be omitted, and the coefficients of the local block may be decoded through the above steps S1400 to S1450. In addition, when the difference is greater than the predetermined threshold difference, the threshold range may be determined as {3,5} or {5,3}.

[0365] That is, the threshold range when the difference is small may have a different number and / or size (e.g., maximum value) of thresholds from the threshold range when the difference is large. The number of threshold difference values ​​may be one, two, or more. The threshold difference value may be set in the image decoding device, or may be determined based on information about the threshold difference value signaled by the image encoding device.

[0366] Reference Fig.15 , the first threshold flag of the current threshold can be decoded (S1500).

[0367] The first threshold flag may indicate whether the absolute values ​​of all coefficients of the local block are less than the current threshold. For example, when the first threshold flag is "false", it may indicate that the absolute values ​​of all coefficients of the local block are greater than or equal to the current threshold. In addition, when the first threshold flag is "true", it may indicate that the absolute values ​​of all coefficients of the local block are less than the current threshold.

[0368] When the first threshold flag is "false", the current threshold (i-th threshold) may be updated to the next threshold (i+1-th threshold) (S1510), and the above step S1500 may be performed based on the updated current threshold.

[0369] When the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1, the current threshold may be updated by adding the current threshold to a predetermined constant. The predetermined constant may be an integer greater than or equal to 1. Here, the update may be repeatedly performed until the first threshold flag that is "true" is decoded. Optionally, the update process may be terminated when the current threshold reaches the maximum value of the threshold or when the number of thresholds is 1.

[0370] like Fig.15 As shown, when the first threshold flag is "true", decoding of the first threshold flag may no longer be performed.

[0371] As described above, when the first threshold flag of the i-th threshold is "true", it may indicate that the absolute values ​​of all coefficients in the local block are less than the i-th threshold. In addition, when the first threshold flag of the i-th threshold is "false", it may indicate that the absolute values ​​of all coefficients in the local block are greater than or equal to the i-th threshold. Based on the first threshold flag being "true", the range of coefficient values ​​belonging to the local block may be specified. That is, when the first threshold flag of the i-th threshold is "true", the coefficients belonging to the local block may fall within the range of 0 to (i-threshold-1).

[0372] According to the decoded first threshold flag, at least one of the above steps S1400 to S1450 may be omitted.

[0373] For example, when the threshold range is {3, 5}, at least one of the first threshold flag of the threshold value "3" or the first threshold flag of the threshold value "5" may be decoded. When the first threshold flag of the threshold value "3" is "true", the absolute values ​​of all coefficients in the local block may fall within the range of 0 to 2. In this case, the coefficients of the local block may be decoded by performing the remaining steps except at least one of the above steps S1430 or S1440, or the coefficients of the local block may be decoded by performing the remaining steps except at least one of the above steps S1400, S1430, or S1440.

[0374] When the first threshold flag of the threshold value "3" is "false", the first threshold flag of the threshold value "5" may be decoded. When the first threshold flag of the threshold value "5" is "false", at least one of the absolute values ​​of the coefficients in the partial block may be greater than or equal to 5. In this case, the coefficients of the partial block may be decoded by performing the above-mentioned steps S1400 to S1450 in the same manner, or the coefficients of the partial block may be decoded by performing the remaining steps except step S1400.

[0375] In addition, when the first threshold flag of the threshold value "5" is "true", the absolute values ​​of all coefficients in the partial block may fall within the range of 0 to 4. In this case, the coefficients of the partial block may be decoded by performing the above-mentioned steps S1400 to S1450 in the same manner, or the coefficients of the partial block may be decoded by performing the remaining steps except step S1400.

[0376] In addition, the first threshold flag of the current local block can be derived based on the first threshold flag of another local block. In this case, the decoding process of the first threshold flag can be omitted, and the reference Fig.16 Describe this.

[0377] Fig.16 is a diagram illustrating a method of deriving a first threshold flag of a current local block as an embodiment to which the present invention is applied.

[0378] In this embodiment, it is assumed that the transform block 1600 is 8×8, the local block is 4×4, the block including the first non-zero coefficient is 1620, and the local blocks of the transform block are encoded / decoded in the order of 1640, 1620, 1630, and 1610 according to the scan type.

[0379] In the current local block, the first threshold flag of a specific threshold may be derived based on the first threshold flag of the previous local block. For example, based on the first threshold flag of "false" in the previous local block, the first threshold flag of the current local block may be derived as "false". Here, it is assumed that {3, 5, 7} is used as the threshold range.

[0380] Specifically, since the local block 1640 at the first position in the encoding / decoding order has an earlier encoding / decoding order than the position of the local block 1620 to which the first non-zero coefficient belongs, the first threshold flag may not be encoded / decoded. In the local block 1620 at the second position in the encoding / decoding order, since the first threshold flag of the threshold value "3" is "true", only the first threshold flag of the threshold value "3" may be encoded / decoded. In the local block 1630 at the third position in the encoding / decoding order, since the first threshold flag of the threshold value "3" is "false" and the first threshold flag of the threshold value "5" is "true", the first threshold flag of the threshold value "3" and the first threshold flag of the threshold value "5" may be encoded / decoded respectively. In the local block 1610 at the last position in the encoding / decoding order, the first threshold flag of the threshold value "3" is "false" and the first threshold flag of the threshold value "5" is "false". Here, since the first threshold flag of the threshold "3" in the previous local block 1630 is "false", it can be expected that the current local block 1610 has at least one coefficient whose absolute value is equal to or greater than 3, and it can be deduced that the first threshold flag of the threshold "3" is "false".

[0381] In the current local block, the first threshold flag of a specific threshold can be derived based on the first threshold flag of the previous local block. For example, based on the first threshold flag of "false" in the previous local block, the first threshold flag of the current local block can be derived as "false".

[0382] Hereinafter, a method of determining a partial block of a transform block will be described in detail.

[0383] The image encoding device may determine a local block having a predetermined size / shape constituting a transform block, and may encode information about the size / shape of the local block. The image decoding device may determine the size / shape of the local block based on the encoded information (first method). Alternatively, the size / shape of the local block may be determined by a predetermined rule in the image encoding / decoding device (second method). Information indicating whether the size / shape of the local block is determined by which method of the first method and the second method may be signaled in at least one layer of a video, sequence, picture, slice, or block. The block may refer to a coding block, a prediction block, or a transform block.

[0384] The size of the local block in the transform block may be equal to or smaller than the size of the transform block. The shape of the transform block / local block may be square or non-square. The shape of the transform block may be the same as or different from the shape of the local block.

[0385] Information about the shape of the transform block may be encoded. Here, the information may include at least one of information about whether only square, only non-square, or both square and non-square are used for the shape of the transform block. The information may be signaled in at least one layer of a video, sequence, picture, slice, or block. The block may refer to a coding block, a prediction block, or a transform block. Information about the size of the transform block may be encoded. Here, the information may include at least one of a minimum size, a maximum size, a partition depth, or a maximum / minimum value of the partition depth. The information may be signaled in at least one layer of a video, sequence, picture, slice, or block.

[0386] Information about the shape of the local block may be encoded. Here, the information may include at least one of the information about whether only square, only non-square, or both square and non-square are used for the shape of the local block. The information may be sent by signal in at least one layer of a video, sequence, picture, strip, or block. The block may refer to a coding block, a prediction block, or a transform block. Information about the size of the local block may be encoded. Here, the information may include at least one of a minimum size, a maximum size, a partition depth, and a maximum / minimum value of the partition depth. The information may be sent by signal in at least one layer of a video, sequence, picture, strip, or block.

[0387] Fig.17 : is a diagram illustrating a method of determining a size / shape of a partial block based on partition index information as an embodiment to which the present invention is applied.

[0388] The image encoding apparatus may determine which partition format of the local blocks is optimal through RDO from when all the local blocks of the transform block have a maximum value until when the all the local blocks have a minimum value.

[0389] Reference Fig.17 , transform block 1701 is composed of one local block 1, and the RD (rate distortion) cost value in this case can be calculated. Local block 1 can be a local block with a maximum size predefined in the image encoding device. Transform block 1702 is a case where transform block 1701 is partitioned into four local blocks 1 to 4, and the RD cost value in this case can be calculated. Transform block 1703 is a case where each local block in transform block 1702 is partitioned into four local blocks again, and the RD cost value in this case can be calculated.

[0390] As described above, within the range of the local block of the maximum size to the minimum size, the RD cost value may be calculated while partitioning the transform block into local blocks of the same size. An optimal partition is determined based on the RD cost value, and partition index information indicating the optimal partition may be encoded. The image decoding device may determine the size / shape of the local block in the transform block based on the encoded partition index information.

[0391] For example, when transform block 1701 is the best partition, the image encoding device may encode "0" as the partition index information; when transform block 1702 is the best partition, the image encoding device may encode "1" as the partition index information; when transform block 1703 is the best partition, the image encoding device may encode "2" as the partition index information. The image decoding device may determine the size / shape of the local block in the transform block based on the encoded partition index information.

[0392] Depending on the quantization parameter (QP) of the transform block, some or all of the local blocks in the transform block may be selectively encoded / decoded. For example, when the QP of the transform block is greater than a predetermined QP threshold, only the local area in the transform block may be encoded / decoded. In addition, when the QP of the transform block is less than a predetermined QP threshold, all local blocks in the transform block may be encoded / decoded.

[0393] Here, the local area may be specified by at least one of a predetermined vertical line or horizontal line. The vertical line may be located at a position spaced apart from the left boundary of the transform block in the left-right direction by a distance a, and the horizontal line may be located at a position spaced apart from the top boundary of the transform block in the bottom direction by a distance b. a and b are natural numbers and may be the same or different from each other. a may fall within the range of 0 to the width of the transform block, and b may fall within the range of 0 to the height of the transform block. The local area may be an area located on the left side relative to the vertical line and / or an area located on the upper side relative to the horizontal line. The position of the vertical / horizontal line may be predetermined in the image encoding / decoding device, or may be variably determined in consideration of the size / shape of the transform block. Alternatively, the image encoding device may encode information specifying the local area (e.g., information for specifying the position of the vertical / horizontal line) and transmit the information with a signal, and the image decoding device may specify the local area based on the information transmitted with the signal. The boundary of the specified local area may contact the boundary of the local block in the transform block or may not contact the boundary of the local block in the transform block.

[0394] For example, the local area may be a local block of the area in which the DC component is concentrated or further include N local blocks (N≥1) of adjacent local blocks. Optionally, the local area may be specified by a vertical line passing through a 1 / n point of the top boundary of the transform block and / or a horizontal line passing through a 1 / m point of the left boundary of the transform block. n and m are natural numbers and may be the same or different from each other.

[0395] The number of QP thresholds may be one, two, or more. The QP threshold may be predetermined in the image encoding device. For example, the QP threshold may correspond to the median of the range of QPs available in the image encoding / decoding device. Alternatively, the image encoding device may determine an optimal QP threshold in consideration of encoding efficiency, and may encode the QP threshold.

[0396] Optionally, depending on the size of the transform block, some or all of the local blocks in the transform block may be selectively encoded / decoded. For example, when the size of the transform block is equal to or greater than a predetermined threshold size, only the local area in the transform block may be encoded / decoded. In addition, when the size of the transform block is less than a predetermined threshold size, all local blocks in the transform block may be encoded / decoded.

[0397] Here, the local area may be specified by at least one of a predetermined vertical line or horizontal line. The vertical line may be located at a position spaced apart from the left boundary of the transform block by a distance a in the left direction, and the horizontal line may be located at a position spaced apart from the top boundary of the transform block by a distance b in the bottom direction. a and b are natural numbers and may be the same or different from each other. a may fall within the range of 0 to the width of the transform block, and b may fall within the range of 0 to the height of the transform block. The local area may be an area located on the left side relative to the vertical line and / or an area located on the upper side relative to the horizontal line. The position of the vertical / horizontal line may be predetermined in the image encoding / decoding device, or may be variably determined in consideration of the size / shape of the transform block. Alternatively, the image encoding device may encode information specifying the local area (e.g., information for specifying the position of the vertical / horizontal line) and transmit the information with a signal, and the image decoding device may specify the local area based on the information transmitted with the signal. The boundary of the specified local area may contact the boundary of the local block in the transform block or may not contact the boundary of the local block in the transform block.

[0398] For example, the local area may be a local block of the area in which the DC component is concentrated or further include N local blocks (N≥1) of adjacent local blocks. Optionally, the local area may be specified by a vertical line passing through a 1 / n point of the top boundary of the transform block and / or a horizontal line passing through a 1 / m point of the left boundary of the transform block. n and m are natural numbers and may be the same or different from each other.

[0399] The number of size thresholds may be one, two, or more. The threshold size may be predetermined in the image encoding device. For example, the threshold size may be represented by c×d, where c and d are 2, 4, 8, 16, 32, 64, or more, and c and d may be the same or different. Alternatively, the image encoding device may determine an optimal threshold size in consideration of encoding efficiency, and may encode the threshold size.

[0400] In the following, reference will be made to Figures 18 to 23 Methods for efficiently encoding / decoding the above-mentioned local block coefficient flags are described.

[0401] In the frequency domain, the DC component region in the transform block has a high probability that the local block coefficient flag is determined to be "1", and the AC component region has a high probability that the local block coefficient flag is determined to be "0". The local block coefficient flag may be encoded in consideration of such statistical characteristics.

[0402] Fig.18 : is a diagram showing a method of encoding a local block coefficient flag based on the number of non-zero coefficients in a local block as an embodiment to which the present invention is applied.

[0403] First, a local block coefficient flag may be encoded for a coefficient of a current local block. That is, when a coefficient is a non-zero coefficient, the local block coefficient flag may be encoded as a first value (e.g., "1"), and when a coefficient is 0, the local block coefficient flag may be encoded as a second value (e.g., "0"). The local block coefficient flag may be encoded for each coefficient belonging to the current local block, and the number of non-zero coefficients belonging to the current local block may be determined through the above process. The local block coefficient flag of the next local block may be encoded based on the number of non-zero coefficients in the current local block.

[0404] Reference Fig.18 , the number of non-zero coefficients in the current local block may be compared with a predetermined threshold value (hereinafter, referred to as the number of NZ) (S1800). Here, the number of NZ may be a fixed number predetermined in the image encoding device, or may be variably determined based on the size of the transform block and / or the local block. For example, when the local block is N×N, the local block includes (N×N) coefficients, wherein the number of NZ may be determined as a value of (N×N) / 2.

[0405] Based on the comparison result of step S1800, the local block coefficient flag of the coefficient of the next local block may be encoded (S1810). Here, the next local block may represent a local block to be encoded next after the current local block according to the encoding order (or according to the order of the scan type).

[0406] For example, when the number of non-zero coefficients in the current local block is greater than the number of NZ, the local block coefficient flag of the next local block may be encoded with a different meaning from that of the local block coefficient flag of the current local block. That is, in the next local block, when the coefficient is a non-zero coefficient, the local block coefficient flag of the coefficient may be encoded as a second value (e.g., "0"), and when the coefficient is 0, the local block coefficient flag of the coefficient may be encoded as a first value (e.g., "1").

[0407] In addition, when the number of non-zero coefficients in the current local block is less than the number of NZ, the local block coefficient flag of the next local block may be encoded with the same meaning as the local block coefficient flag of the current local block. That is, in the next local block, when the coefficient is a non-zero coefficient, the local block coefficient flag of the coefficient may be encoded as a first value (e.g., "1"), and when the coefficient is 0, the local block coefficient flag of the coefficient may be encoded as a second value (e.g., "0").

[0408] The above encoding scheme may be performed in units of transform blocks. For example, the encoding scheme may be limited to being performed only until the next partial block reaches the partial block with the last encoding order in the transform block. However, the present invention is not limited thereto, and when the current partial block and the next partial block belong to different transform blocks, the same / similar scheme may be performed.

[0409] When the local block coefficient flag is encoded according to the above method, the image decoding device can determine whether the coefficient of the current local block is a non-zero coefficient based on at least one of the encoded local block coefficient flag of the current local block or the number of non-zero coefficients in the previous local block.

[0410] For example, when the local block coefficient flag of the coefficient of the current local block is a first value, the coefficient may be determined to be a non-zero coefficient, and when the local block coefficient flag is a second value, the coefficient may be determined to be '0'.

[0411] Here, further considering the number of non-zero coefficients in the previous local block, it may be finally determined whether the coefficient is a non-zero coefficient. When the number of non-zero coefficients in the previous local block is greater than the number of NZ, the coefficient having the local block coefficient flag of the first value may be determined to be 0, and the coefficient having the local block coefficient flag of the second value may be determined to be a non-zero coefficient. In addition, when the number of non-zero coefficients in the previous local block is less than the number of NZ, the first determination as to whether it is a non-zero coefficient may be maintained.

[0412] The previous local block referenced by the current local block may be limited to belong to the same transform block as the current local block. However, the present invention is not limited thereto, and the local block coefficient flag of the current local block may be decoded by referring to a local block belonging to another transform block.

[0413] Fig.19 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients in a local block as an embodiment to which the present invention is applied.

[0414] The image encoding device may encode the local block coefficient flag as a predetermined value according to whether the coefficient of the current local block is a non-zero coefficient. That is, when the coefficient is a non-zero coefficient, the local block coefficient flag may be encoded as a first value (e.g., "1"), and when the coefficient is 0, the local block coefficient flag may be encoded as a second value (e.g., "0"). In addition, based on the number of non-zero coefficients in the current local block, the probability information of the local block coefficient flag of the next local block may be changed. In the following, for ease of explanation, it is assumed that the local block coefficient flag is encoded / decoded based on the CABAC conventional encoding method.

[0415] Reference Fig.19 , the number of non-zero coefficients in the current local block may be compared with a predetermined threshold (hereinafter, referred to as the number of NZ) (S1900). Here, the number of NZ is as follows: Fig.18 The present invention is shown in the embodiment of the present invention, and its detailed description will be omitted.

[0416] Based on the comparison result of step S1900, probability information of the local block coefficient flag of the coefficient of the next local block may be changed (S1910). Here, the next local block may mean a local block to be encoded next after the current local block according to the encoding order (or according to the order of the scan type). The probability information may refer to a probability table predetermined in the image encoding / decoding device, a probability value derived from the image encoding / decoding device, a variable for calculating probability, etc.

[0417] For example, when encoding the local block coefficient flag of the next local block, when the number of non-zero coefficients in the current local block is greater than the number of NZ, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may be exchanged for the local block coefficient flag of the next local block. In addition, when the number of non-zero coefficients in the current local block is less than the number of NZ, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may not be exchanged for the local block coefficient flag of the next local block.

[0418] The above encoding scheme may be performed in units of transform blocks. For example, the encoding scheme may be limited to being performed only until the next partial block reaches the partial block with the last encoding order in the transform block. However, the present invention is not limited thereto, and when the current partial block and the next partial block belong to different transform blocks, the same / similar scheme may be performed.

[0419] When the local block coefficient flag is encoded according to the above-described manner, the image decoding apparatus may decode the local block coefficient flag of the current local block based on the number of non-zero coefficients in the previous local block.

[0420] Specifically, probability information about a local block coefficient flag of a current local block may be changed based on a comparison result of the number of non-zero coefficients in a previous block and the number of NZs, and the local block coefficient flag may be decoded based on the changed probability information.

[0421] For example, when the number of non-zero coefficients in the previous partial block is greater than the number of NZ, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may be exchanged with each other for the local block coefficient flag. In addition, when the number of non-zero coefficients in the previous partial block is less than the number of NZ, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may not be exchanged with each other for the local block coefficient flag.

[0422] In addition, the previous local block referenced by the current local block may be limited to belong to the same transform block as the current local block. However, the present invention is not limited thereto, and the local block coefficient flag of the current local block may be decoded by referring to a local block belonging to another transform block.

[0423] Fig. 20: is a diagram showing a method of encoding a local block coefficient flag based on the number of non-zero coefficients up to a current coefficient as an embodiment to which the present invention is applied.

[0424] Reference Fig. 20 , the number of non-zero coefficients up to the current coefficient in the current partial block may be compared with the number of NZs (S2000). The number of non-zero coefficients up to the current coefficient may be calculated according to the coding order of the coefficients (or according to the order of the scan type). The number of NZs is as follows: Fig.18 The present invention is shown in the embodiment of the present invention, and its detailed description will be omitted.

[0425] Based on the comparison result of step S2000, the local block coefficient flag of the next coefficient may be encoded (S2010). Here, the next coefficient may indicate a coefficient to be encoded next after the current coefficient according to the encoding order (or according to the order of the scan type).

[0426] For example, when the number of non-zero coefficients up to the current coefficient is greater than or equal to the number of NZ, the local block coefficient flag of the next coefficient may be encoded with a different meaning from the local block coefficient flag of the current coefficient. That is, when the next coefficient is a non-zero coefficient, the local block coefficient flag of the next coefficient may be encoded as a second value (e.g., "0"), and when the next coefficient is 0, the local block coefficient flag of the next coefficient may be encoded as a first value (e.g., "1").

[0427] In addition, when the number of non-zero coefficients up to the current coefficient is less than the number of NZ, the local block coefficient flag of the next coefficient may be encoded with the same meaning as the local block coefficient flag of the current coefficient. That is, when the next coefficient is a non-zero coefficient, the local block coefficient flag of the next coefficient may be encoded as a first value (e.g., "1"), and when the next coefficient is 0, the local block coefficient flag of the next coefficient may be encoded as a second value (e.g., "0").

[0428] The above encoding scheme may be performed in units of transform blocks or local blocks. For example, the encoding scheme may be limited to being performed only until the next coefficient reaches the coefficient with the last encoding order in the transform block or local block. However, the present invention is not limited thereto, and when the current coefficient and the next coefficient belong to different transform blocks or different local blocks, the same / similar scheme may be performed.

[0429] When the local block coefficient flag is encoded according to the above manner, the image decoding device can determine whether the current coefficient is a non-zero coefficient based on at least one of the encoded local block coefficient flag of the current coefficient or the number of non-zero coefficients until the previous coefficient.

[0430] For example, when the local block coefficient flag of the current coefficient is a first value, the current coefficient may be determined to be a non-zero coefficient, and when the local block coefficient flag is a second value, the current coefficient may be determined to be '0'.

[0431] Here, further considering the number of non-zero coefficients up to the previous coefficient in the current local block, it can be finally determined whether the current coefficient is a non-zero coefficient. When the number of non-zero coefficients up to the previous coefficient is greater than the number of NZ, the current coefficient having the local block coefficient flag of the first value can be determined to be 0, and the current coefficient having the local block coefficient flag of the second value can be determined to be a non-zero coefficient. In addition, when the number of non-zero coefficients up to the previous coefficient is less than the number of NZ, the first determination as to whether it is a non-zero coefficient can be maintained.

[0432] In addition, the previous coefficient referenced by the current coefficient may be limited to belong to the same partial block as the current coefficient. However, the present invention is not limited thereto, and the current coefficient may refer to a coefficient belonging to another partial block or another transform block.

[0433] Fig.21 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients up to a current coefficient as an embodiment to which the present invention is applied.

[0434] The image encoding device may encode the local block coefficient flag as a predetermined value according to whether the coefficient of the current local block is a non-zero coefficient. That is, when the coefficient is a non-zero coefficient, the local block coefficient flag may be encoded as a first value (e.g., "1"), and when the coefficient is 0, the local block coefficient flag may be encoded as a second value (e.g., "0"). Here, in the current local block, based on the number of non-zero coefficients up to the current coefficient, the probability information of the local block coefficient flag of the next coefficient may be changed. In the following, for ease of explanation, it is assumed that the local block coefficient flag is encoded / decoded based on the CABAC conventional encoding method.

[0435] Reference Fig.21 , the number of non-zero coefficients in the current local block up to the current coefficient may be compared with the number of NZs (S2100). Here, the number of NZs is as follows: Fig.18 The present invention is shown in the embodiment of the present invention, and its detailed description will be omitted.

[0436] Based on the comparison result of step S2100, probability information of the local block coefficient flag of the next coefficient may be changed (S2110). Here, the next coefficient may represent a coefficient to be encoded next after the current coefficient according to the encoding order (or according to the order of the scan type). The probability information may refer to a probability table predetermined in the image encoding / decoding device, a probability value derived from the image encoding / decoding device, a variable for calculating probability, etc.

[0437] For example, when encoding the local block coefficient flag of the next coefficient, when the number of non-zero coefficients up to the current coefficient in the current local block is greater than or equal to the number of NZ, for the local block coefficient flag of the next coefficient, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may be exchanged with each other. In addition, when the number of non-zero coefficients up to the current coefficient is less than the number of NZ, for the local block coefficient flag of the next coefficient, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may not be exchanged with each other for the local block coefficient flag of the next local block.

[0438] The above encoding scheme may be performed in units of a local block or a transform block. For example, the encoding scheme may be limited to being performed only until the next coefficient reaches the coefficient with the last encoding order in the transform block or the local block. However, the present invention is not limited thereto, and when the current coefficient and the next coefficient belong to different transform blocks or different local blocks, the same / similar scheme may be performed.

[0439] When the local block coefficient flag is encoded according to the above-described manner, the image decoding apparatus may decode the local block coefficient flag of the current local block based on the number of non-zero coefficients up to the previous coefficient in the current local block.

[0440] Specifically, probability information about a local block coefficient flag of a current coefficient may be changed based on a comparison result of the number of non-zero coefficients until a previous coefficient and the number of NZs, and the local block coefficient flag may be decoded based on the changed probability information.

[0441] For example, when the number of non-zero coefficients up to the previous coefficient is greater than or equal to the number of NZ, for the local block coefficient flag of the current coefficient, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may be exchanged with each other. In addition, when the number of non-zero coefficients up to the previous local block is less than the number of NZ, for the local block coefficient flag of the current coefficient, the probability information about the occurrence of "0" and the probability information about the occurrence of "1" may not be exchanged with each other.

[0442] In addition, the previous coefficient referenced by the current coefficient may be limited to belong to the same partial block as the current coefficient. However, the present invention is not limited thereto, and the current coefficient may refer to a coefficient belonging to another partial block or another transform block.

[0443] The above-mentioned local block coefficient flag encoding / decoding method may be selectively used according to a quantization parameter (QP) associated with a transform block.

[0444] For example, when the QP of the transform block is greater than a predetermined QP threshold, the above encoding / decoding method may be restricted to not be used. In addition, when the QP of the transform block is less than a predetermined QP threshold, at least one of the above encoding / decoding methods may be used to encode / decode the local block coefficient flag.

[0445] The number of QP thresholds may be one, two or more. The QP threshold may be predetermined in the image encoding device. For example, the QP threshold may correspond to the median of the range of QPs available in the image encoding / decoding device. Alternatively, the image encoding device may determine an optimal QP threshold in consideration of encoding efficiency and encode the QP threshold.

[0446] Alternatively, a local block coefficient flag encoding / decoding method may be selectively used according to the size of a transform block (or a local block).

[0447] For example, when the size of the transform block is greater than or equal to a predetermined threshold size, at least one of the above encoding / decoding methods may be used to encode / decode the local block coefficient flag. In addition, when the size of the transform block is less than a predetermined threshold size, the above encoding / decoding method may be restricted to not be used.

[0448] The number of threshold sizes may be one, two or more. The threshold size may be predetermined in the image encoding device. For example, the threshold size may be represented by a×b, where a and b are 2, 4, 8, 16, 32, 64 or more, and a and b may be equal to or different from each other. Alternatively, the image encoding device may determine an optimal threshold size in consideration of encoding efficiency, and encode the threshold size.

[0449] Fig. 22 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients in a local block as an embodiment to which the present invention is applied.

[0450] Reference Fig. 22 , the number of non-zero coefficients in the current local block may be compared with the number of NZs (S2200). Here, the number of NZs is as follows: Fig.18 The present invention is shown in the embodiment of the present invention, and its detailed description will be omitted.

[0451] Based on the comparison result of step S2200, probability information of the local block coefficient flag of the next local block may be changed (S2210). Here, the next local block may mean a local block to be encoded next after the current local block according to the encoding order (or according to the order of the scan type). The probability information may refer to a probability table predetermined in the image encoding / decoding device, a probability value derived from the image encoding / decoding device, a variable for calculating probability, etc.

[0452] For example, when the number of non-zero coefficients in the current local block is greater than the number of NZ, the probability information of the local block coefficient flag of the next local block may be changed. The change may mean applying other probability information with a high probability that the local block coefficient flag is "true".

[0453] In addition, when the number of non-zero coefficients in the current local block is less than the number of NZ, the probability information of the local block coefficient flag of the next local block may not be changed. That is, the local block coefficient flag of the next local block may use the probability information of the local block coefficient flag of the current local block as is.

[0454] The above encoding scheme may be performed in units of transform blocks. For example, the encoding scheme may be limited to being performed only until the next partial block reaches the partial block with the last encoding order in the transform block. However, the present invention is not limited thereto, and when the current partial block and the next partial block belong to different transform blocks, the same / similar scheme may be performed.

[0455] The image decoding apparatus may decode the local block coefficient flag of the local block according to a scheme that is the same as / similar to the above-mentioned encoding scheme.

[0456] Fig.23 : is a diagram showing a method of changing probability information of a local block coefficient flag based on the number of non-zero coefficients up to a current coefficient as an embodiment to which the present invention is applied.

[0457] Reference Fig.23 , the number of non-zero coefficients up to the current coefficient in the current partial block may be compared with the number of NZs (S2300). The number of non-zero coefficients up to the current coefficient may be calculated according to the coding order of the coefficients (or according to the order of the scan type). The number of NZs is as follows: Fig.18 The present invention is shown in the embodiment of the present invention, and its detailed description will be omitted.

[0458] Based on the comparison result of step S2300, probability information of the local block coefficient flag of the next coefficient may be changed (S2310). Here, the next coefficient may represent a coefficient to be encoded next after the current coefficient according to the encoding order (or according to the order of the scan type). The probability information may refer to a probability table predetermined in the image encoding / decoding device, a probability value derived from the image encoding / decoding device, a variable for calculating probability, etc.

[0459] For example, when the number of non-zero coefficients up to the current coefficient is greater than or equal to the number of NZ, the probability information of the local block coefficient flag of the next coefficient may be changed. The change may mean applying other probability information with a high probability that the local block coefficient flag is "true".

[0460] In addition, when the number of non-zero coefficients up to the current coefficient is less than the number of NZ, the probability information of the local block coefficient flag of the next coefficient may not be changed. That is, the local block coefficient flag of the next coefficient may use the probability information of the local block coefficient flag of the current coefficient as it is.

[0461] The above encoding scheme may be performed in units of transform blocks or local blocks. For example, the encoding scheme may be limited to being performed only until the next coefficient reaches the coefficient with the last encoding order in the transform block or local block. However, the present invention is not limited thereto, and when the current coefficient and the next coefficient belong to different transform blocks or different local blocks, the same / similar scheme may be performed.

[0462] The image decoding apparatus may change the probability information of the local block coefficient flag according to a scheme that is the same as / similar to the above-mentioned encoding scheme.

[0463] In addition, the above-mentioned step of changing the probability information may be performed in consideration of the frequency components of the transform block. Fig.16 , the AC component region (e.g., local blocks 1620, 1630, 1640) may use probability information having a higher probability that the local block coefficient flag is "false", and the DC component region (e.g., local block 1610) may use probability information having a higher probability that the local block coefficient flag is "true".

[0464] Fig.24 is a block diagram illustrating an image encoding apparatus according to an embodiment of the present invention.

[0465] Reference Fig.24 , the image encoding device 2400 may include a picture partition module 2410, prediction modules 2420 and 2425, a transform module 2430, a quantization module 2435, a rearrangement module 2460, an entropy encoding module 2465, an inverse quantization module 2440, an inverse transform module 2445, a filter module 2450 and a memory 2455.

[0466] Fig.24 The components shown in the figure are shown independently in order to represent the characteristic functions that are different from each other in the image encoding device, but it does not mean that each component is composed of separate hardware or software components. In other words, for convenience, each component includes each listed component, and at least two components of each component can be combined to form one component, or one component can be divided into multiple components to perform each function. If it does not depart from the essence of the present invention, the embodiments of combining each component and the embodiments of dividing one component are also included in the scope of the present invention.

[0467] In addition, some structures may not be indispensable structures for performing the basic functions of the present invention, but are only optional structures for improving their performance. The present invention can be realized by only including indispensable structures for realizing the essence of the present invention except the structures for improving performance. Structures including only indispensable structures except the optional structures for improving performance are also included in the scope of the present invention.

[0468] The picture partition module 2410 may partition the input picture into at least one block. Here, the block may represent a coding unit (CU), a prediction unit (PU), or a transform unit (TU). The partition may be performed based on at least one of a quadtree or a binary tree. A quadtree is a method of partitioning an upper block into four lower blocks with a width and height of half that of the upper block. A binary tree is a method of partitioning an upper block into two lower blocks with a width or height of half that of the upper block. Using a binary tree-based partition, the block may have a square shape as well as a non-square shape.

[0469] Hereinafter, in an embodiment of the present invention, a coding unit may be used as a unit for performing encoding or may be used as a unit for performing decoding.

[0470] The prediction modules 2420 and 2425 may include an inter prediction module 2420 for performing inter prediction and an intra prediction module 2425 for performing intra prediction. Whether to perform inter prediction or intra prediction may be determined for a prediction unit, and specific information according to each prediction method (e.g., intra prediction mode, motion vector, reference picture, etc.) may be determined. Here, the processing unit on which prediction is performed may be different from the processing unit for which the prediction method and specific content are determined. For example, the prediction method, prediction mode, etc. may be determined in units of prediction units, and prediction may be performed in units of transform units.

[0471] The encoding apparatus may determine an optimal prediction mode for a coding block by using various schemes such as rate-distortion optimization (RDO) for a residual block obtained by subtracting a prediction block from a source block. In one example, RDO may be determined by Equation 1 below.

[0472] [Equation 1]

[0473] J(Φ,λ)=D(Φ)+λR(Φ)

[0474] In the above equation (1), D represents degradation due to quantization, R represents the rate of the compressed stream, and J represents the RD cost. In addition, Φ represents the coding mode, and λ represents the Lagrange multiplier. λ can be used as a proportional correction coefficient for matching the units of the error amount and the bit amount. During the encoding process, the encoding device can determine the mode with the minimum RD cost value as the optimal mode for the encoding block. Here, the RD cost value is calculated based on both the bit rate and the error.

[0475] Among the intra modes, the DC mode, which is a non-directional prediction mode (or non-angular prediction mode), may use an average value of neighboring pixels of the current block. Fig.26 is a diagram for explaining an intra prediction method using a DC mode.

[0476] After filling the average value of the neighboring pixels in the prediction block, filtering may be performed on the pixels located at the boundary of the prediction block. In one example, weighted sum filtering using neighboring reference pixels may be applied to pixels located at the left boundary or the top boundary of the prediction block. For example, Equation 2 shows an example of generating predicted pixels by a DC mode for each region. In Equation 2, regions R1, R2, R3 are regions located at the outermost side (i.e., the boundary) of the prediction block, and weighted sum filtering may be applied to the pixels included in the regions.

[0477] [Equation 2]

[0478]

[0479] R1 area) Pred[0][0] = (R[-1][0] + 2*DC value + R[0][-1] + 2) > > 2

[0480] R2 area) Pred[x][0] = (R[x][-1] + 3*DC value + 2)>>2, x>0

[0481] R3 area) Pred[0][y] = (R[0][y] + 3*DC value + 2)>>2, y>0

[0482] R4 area) Pred[x][y] = DC value, x>0, y>0

[0483] In Equation 2, Wid represents the horizontal length of the prediction block, and Hei represents the vertical length of the prediction block. x, y represent the coordinate position of each prediction pixel when the upper leftmost position of the prediction block is defined as (0, 0). R represents the neighboring pixel. For example, when Fig.26 When the pixel s shown is defined as R[-1][-1], the pixels a to i can be represented as R[0][-1] to R[8][-1], and the pixels j to r can be represented as R[-1][0] to R[-1][8]. Fig.26 In the illustrated example, the predicted pixel value Pred may be calculated for each of the regions R1 to R4 according to the weighted sum filtering method shown in Equation 2.

[0484] The planar mode among the non-directional modes is a method of generating predicted pixels of the current block by applying linear interpolation according to distance to neighboring pixels of the current block. Fig. 27 is a diagram for explaining an intra prediction method using a planar mode.

[0485] For example, assuming prediction in an 8×8 coding block Fig. 27 Pred shown in . In this case, the pixel e located on the upper side of Pred and the pixel r located on the lower left side of Pred can be copied to the lowermost side of Pred, and the vertical prediction value can be obtained by linear interpolation by distance in the vertical direction. In addition, the pixel n located on the left side of Pred and the pixel i located on the upper right side of Pred can be copied to the rightmost side of Pred, and the horizontal prediction value can be obtained by linear interpolation by distance in the horizontal direction. Then, the average value of the horizontal prediction value and the vertical prediction value can be determined as the value of Pred. Equation 3 is a formula representing the process of obtaining the prediction value Pred according to the planar mode.

[0486] [Equation 3]

[0487]

[0488] In Equation 3, Wid represents the horizontal length of the prediction block, and Hei represents the vertical length of the prediction block. x, y represent the coordinate position of each prediction pixel when the upper leftmost position of the prediction block is defined as (0, 0). R represents the neighboring pixel. For example, when Fig. 27 When the pixel s shown is defined as R[-1][-1], pixels a to i can be represented as R[0][-1] to R[8][-1], and pixels j to r can be represented as R[-1][0] to R[-1][8].

[0489] Fig.28 is a diagram for explaining an intra prediction method using a directional prediction mode.

[0490] The directional prediction mode (or angular prediction mode) is a method of generating at least one or more pixels located in any one direction of N predetermined directions among neighboring pixels of the current block as prediction samples.

[0491] The directional prediction mode may include a horizontal direction mode and a vertical direction mode. Here, the horizontal direction mode refers to a mode having a greater horizontal directivity than an angular prediction mode pointing to the upper left side along 45 degrees, and the vertical direction mode refers to a mode having a greater vertical directivity than an angular prediction mode pointing to the upper left side along 45 degrees. A directional prediction mode having a prediction direction pointing to the upper left side along 45 degrees may be regarded as a horizontal direction mode, or may be regarded as a vertical direction mode. Fig.28 , the horizontal direction mode and the vertical direction mode are shown.

[0492] Reference Fig.28 , there may be a direction that does not match the integer pixel part in each direction. In this case, after applying distance-based interpolation (such as a linear interpolation method, a DCT-IF method, a cubic convolution interpolation method, etc.) to the distance between the pixel and the adjacent pixels, the pixel value can be filled in the pixel position that matches the direction of the prediction block.

[0493] The residual value (residual block or transform block) between the generated prediction block and the original block can be input to the transform module 2430. The residual block is the smallest unit for the transform and quantization process. The partition method of the coding block can be applied to the transform block. In one example, the transform block can be partitioned into four or two local blocks.

[0494] The prediction mode information, motion vector information, etc. used for prediction may be encoded together with the residual value by the entropy encoding module 2465 and may be transmitted to the decoding device. When a specific encoding mode is used, the original block may be encoded as is without generating a prediction block through the prediction modules 2420 and 2425 to transmit to the decoding device.

[0495] In some cases, the inter-frame prediction module 2420 may predict the prediction unit based on information of at least one of the previous picture or the subsequent picture of the current picture, or may predict the prediction unit based on information of some coding regions in the current picture. The inter-frame prediction module 2420 may include a reference picture interpolation module, a motion prediction module, and a motion compensation module.

[0496] The reference picture interpolation module may receive reference picture information from the memory 2455, and may generate pixel information of integer pixels or pixel information less than integer pixels from the reference picture. In the case of luma pixels, an 8-tap DCT-based interpolation filter with different filter coefficients may be used to generate pixel information of integer pixels or pixel information less than integer pixels in units of 1 / 4 pixels. In the case of chrominance signals, an 4-tap DCT-based interpolation filter with different filter coefficients may be used to generate pixel information of integer pixels or pixel information less than integer pixels in units of 1 / 8 pixels.

[0497] The motion prediction module may 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. may be used as a method for calculating a motion vector. The motion vector may have a motion vector value in units of 1 / 2 pixel or 1 / 4 pixel based on the interpolated pixel. The motion prediction module may predict the current prediction unit by changing the motion prediction method. Various methods such as skip method, merge method, advanced motion vector prediction (AMVP) method, etc. may be used as a motion prediction method.

[0498] The encoding device may generate motion information of the current block based on motion estimation or motion information of neighboring blocks. Here, the motion information may include at least one of a motion vector, a reference image index, and a prediction direction.

[0499] The intra prediction module 2425 may generate a prediction unit based on reference pixel information adjacent to the current block, wherein the reference pixel information adjacent to the current block is pixel information in the current picture. When the neighboring block of the current prediction unit is a block on which inter-frame prediction is performed and thus the reference pixel is a pixel on which inter-frame prediction is performed, the reference pixel information of the neighboring block on which intra-frame prediction is performed may be used to replace the reference pixel included in the block on which inter-frame prediction is performed. 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.

[0500] The prediction mode in the intra prediction may include a directional prediction mode using reference pixel information depending on the prediction direction and a non-directional prediction mode that does not use the directional information when performing the prediction. The mode for predicting the luminance information may be different from the mode for predicting the chrominance information, and in order to predict the chrominance information, the intra prediction mode information for predicting the luminance information or the predicted luminance signal information may be used.

[0501] In the intra prediction method, a prediction block may be generated after an adaptive intra smoothing (AIS) filter is applied to reference pixels according to a prediction mode. The type of the AIS filter applied to the reference pixels may vary. In order to perform the intra prediction method, an intra prediction mode of a current prediction unit may be predicted from an intra prediction mode of a prediction unit adjacent to the current prediction unit. In the prediction of the prediction mode of the current prediction unit by using the mode information predicted from 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 send 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, and 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.

[0502] In addition, a residual block including information on a residual value, which is a difference between the prediction unit on which prediction is performed and the original block of the prediction unit, may be generated based on the prediction unit generated by the prediction modules 2420 and 2425. The generated residual block may be input to the transform module 2430.

[0503] The transform module 2430 may transform the residual block including the residual data using a transform method such as discrete cosine transform (DCT), discrete sine transform (DST), and Karhunen Loeve Transform (KLT). In order to easily use the transform method, a matrix operation is performed using a basic vector. Here, depending on the prediction mode for encoding the prediction block, various transform methods may be mixed differently and used for matrix operations. For example, when performing intra prediction, a discrete cosine transform may be used for the horizontal direction and a discrete sine transform may be used for the vertical direction depending on the intra prediction mode.

[0504] The quantization module 2435 may quantize the value transformed to the frequency domain by the transform module 2430. That is, the quantization module 2435 may quantize the transform coefficients of the transform block generated from the transform module 2430, and generate a quantized transform block having the quantized transform coefficients. Here, the quantization method may include dead zone uniform threshold quantization (DZUTQ) or a quantization weighting matrix, etc. An improved quantization method that improves these quantization methods may also be used. The quantization coefficient may vary according to the block or importance of the image. The value calculated by the quantization module 2435 may be provided to the inverse quantization module 2440 and the rearrangement module 2460.

[0505] The transform module unit 2430 and / or the quantization module 2435 may be selectively included in the image encoding device 2400. That is, the image encoding device 2400 may perform at least one of transform or quantization on the residual data of the residual block, or may skip both transform and quantization, thereby encoding the residual block. Even if transform or quantization or both transform and quantization are not performed in the image encoding device 2400, the block provided as an input to the entropy encoding module 2465 is generally referred to as a transform block (or a quantized transform block).

[0506] The rearrangement module 2460 may rearrange coefficients of the quantized residual value.

[0507] The rearrangement module 2460 may change the coefficients in the two-dimensional block form into coefficients in the one-dimensional vector form by a coefficient scanning method. For example, the rearrangement module 2460 may scan from the DC coefficient to the coefficients in the high frequency domain using a predetermined scanning method so as to change the coefficients into the one-dimensional vector form.

[0508] The entropy encoding module 2465 may perform entropy encoding based on the value calculated by the rearrangement module 2460. 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).

[0509] The entropy encoding module 2465 may encode various information (such as residual value coefficient information and block type information of the coding unit, prediction mode information, partition unit information, prediction unit information and transmission unit information, motion vector information, reference frame information, interpolation information of the block, filtering information, etc.) from the rearrangement module 2460 and the prediction modules 2420 and 2425. In the entropy encoding module 2465, the coefficient of the transform block may be encoded as a non-zero coefficient, a coefficient having an absolute value greater than 1 or 2, and various types of flags indicating the sign of the coefficient, etc., in units of local blocks in the transform block. The coefficient that is not encoded using only the flag may be encoded by the absolute value of the difference between the coefficient encoded by the flag and the coefficient of the actual transform block.

[0510] The entropy encoding module 2465 may entropy encode coefficients of the coding unit input from the rearrangement module 2460 .

[0511] The inverse quantization module 2440 may inversely quantize the value quantized by the quantization module 2435 , and the inverse transform module 2445 may inversely transform the value transformed by the transform module 2430 .

[0512] In addition, the inverse quantization module 2440 and the inverse transform module 2445 may perform inverse quantization and inverse transform by inversely using the quantization method and transform method used in the quantization module 2435 and the transform module 2430. In addition, when the transform module 2430 and the quantization module 2435 perform only quantization but not transform, only inverse quantization is performed and inverse transform may not be performed. When neither transform nor quantization is performed, the inverse quantization module 2440 and the inverse transform module 2445 may neither perform inverse transform nor inverse quantization, may not be included in the image encoding device 2400, and may be omitted.

[0513] The residual value generated by the inverse quantization module 2440 and the inverse transform module 2445 may be combined with a prediction unit predicted by a motion estimation module, a motion compensation module, and an intra prediction module included in the prediction modules 2420 and 2425 to generate a reconstructed block.

[0514] The filter module 2450 may include at least one of a deblocking filter, an offset correction unit, and an adaptive loop filter (ALF).

[0515] The deblocking filter can remove block distortion caused by the boundary between blocks in the reconstructed picture. In order to determine whether to perform deblocking, the pixels included in the multiple 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 the deblocking filter is applied, horizontal direction filtering and vertical direction filtering can be processed in parallel.

[0516] The offset correction module can correct the offset from the original picture in units of pixels in the picture to be deblocked. 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 partitioning the pixels of the picture into a predetermined number of regions, determining the region to be offset, and applying the offset to the determined region can be used.

[0517] Adaptive loop filtering (ALF) may be performed based on a value obtained by comparing a filtered reconstructed picture with an original picture. The pixels included in the picture may be divided into predetermined groups, a filter to be applied to each group may be determined, and filtering may be performed separately for each group. Information on whether to apply ALF and a luminance signal may be transmitted by a coding unit (CU), and the shape and filter coefficient of the filter used for ALF may vary according to each block. In addition, regardless of the characteristics of the application target block, a filter for ALF of the same shape (fixed shape) may be applied.

[0518] The memory 2455 may store the reconstructed block or picture calculated by the filter module 2450 , and may provide the stored reconstructed block or picture to the prediction modules 2420 and 2425 when performing inter prediction.

[0519] Fig.25 is a block diagram showing an image decoding apparatus according to an embodiment of the present invention.

[0520] Reference Fig.25 , the image decoding device 2500 may include an entropy decoding module 2510, a rearrangement module 2515, an inverse quantization module 2520, an inverse transform module 2525, prediction modules 2530 and 2535, a filter module 2540 and a memory 2545.

[0521] When an image bitstream is input from the image encoding apparatus, the input bitstream may be decoded according to an inverse process of the image encoding apparatus.

[0522] The entropy decoding module 2510 may perform entropy decoding according to the inverse process of the entropy encoding of the entropy encoding module of the image encoding device. For example, various methods such as exponential Golomb coding, context adaptive variable length coding (CAVLC), and context adaptive binary arithmetic coding (CABAC) may be applied corresponding to the method performed by the image encoding device. In the entropy decoding module 2510, the coefficients of the transform block may be decoded in units of local blocks in the transform block based on non-zero coefficients, coefficients having an absolute value greater than 1 or 2, and various types of flags indicating the sign of the coefficient. The coefficients not represented only by the flag may be decoded by combining the coefficients represented by the flag with the coefficients transmitted by the signal.

[0523] The entropy decoding module 2510 may decode information about intra prediction and inter prediction performed by the image encoding device.

[0524] The rearrangement module 2515 may perform rearrangement on the bitstream entropy-decoded by the entropy decoding module 2510 based on the rearrangement method used in the image encoding device. The rearrangement may include reconstructing and rearranging coefficients in a one-dimensional vector form into coefficients in a two-dimensional block form. The rearrangement module 2515 may receive information related to coefficient scanning performed in the image encoding device, and may perform rearrangement by a method of inversely scanning the coefficients based on the scanning order performed in the image encoding device.

[0525] The inverse quantization module 2520 may perform inverse quantization based on the quantization parameter received from the image encoding device and the rearranged coefficients of the block.

[0526] The inverse transform module 2525 may perform inverse transform of the inverse quantized transform coefficient according to a predetermined transform method. Here, the transform method may be determined based on a prediction method (inter prediction / intra prediction), a size / shape of a block, information about an intra prediction mode, and the like.

[0527] The prediction modules 2530 and 2535 may generate a prediction block based on the information on prediction block generation received from the entropy decoding module 2510 and previously decoded block or picture information received from the memory 2545 .

[0528] The prediction modules 2530 and 2535 may include a prediction unit determination module, an inter prediction module, and an intra prediction module. The prediction unit determination module may receive various information (such as prediction unit information, prediction mode information of an intra prediction method, information on motion prediction of an inter prediction method, etc.) from the entropy decoding module 2510, may divide the current coding unit into prediction units, and may determine whether to perform inter prediction or intra prediction on the prediction unit. By using the information required in the inter prediction of the current prediction unit received from the image encoding device, the inter prediction module 2530 may perform inter 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 prediction may be performed based on information of some pre-reconstructed areas in the current picture including the current prediction unit.

[0529] In order to perform inter prediction, which of the skip mode, the merge mode, the AMVP mode, and the inter block copy mode is used as a motion prediction method of a prediction unit included in the coding unit may be determined for the coding unit.

[0530] The intra prediction module 2535 may generate a prediction block based on pixel information in the current picture. When the prediction unit is a prediction unit on which intra prediction is performed, intra prediction may be performed based on intra prediction mode information of the prediction unit received from the image encoding device. The intra prediction module 2535 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 may determine whether to apply the filter based on the prediction mode of the current prediction unit. AIS filtering may be performed on the reference pixels of the current block by using the prediction mode of the prediction unit and the AIS filter information received from the image encoding device. 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.

[0531] When the prediction mode of the prediction unit is a prediction mode for performing intra-frame prediction based on pixel values ​​obtained by interpolating reference pixels, the reference pixel interpolation module may interpolate the reference pixels to generate reference pixels of integer pixels or reference pixels less than integer pixels. When the prediction mode of the current prediction unit is a prediction mode for generating a prediction block without interpolating the reference pixels, the reference pixels may not be interpolated. When the prediction mode of the current block is a DC mode, the DC filter may generate a prediction block by filtering.

[0532] The reconstructed block or picture may be provided to the filter module 2540. The filter module 2540 may include a deblocking filter, an offset correction module, and an ALF.

[0533] Information about whether to apply a deblocking filter to a corresponding block or picture and information about which of a strong filter and a weak filter to apply when applying the deblocking filter may be received from the image encoding device. The deblocking filter of the image decoding device may receive information about the deblocking filter from the image encoding device and may perform deblocking filtering on the corresponding block.

[0534] 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.

[0535] 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 image encoding device. The ALF information may be provided to be included in a specific parameter set.

[0536] The memory 2545 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.

[0537] The coding block may be partitioned into at least one block. Specifically, here, the coding block may be partitioned into a maximum size coding block to a minimum size coding block based on quadtree partitioning or binary tree partitioning (or binarized tree partitioning). Information about the maximum size coding block and the minimum size coding block or information about the difference between the maximum size coding block and the minimum size coding block may be signaled to a decoding device through a bitstream.

[0538] Quadtree (QT) partitioning is a method of partitioning a coding block into four blocks. Through QT partitioning, the coding block can be partitioned into four blocks with the vertical length and horizontal length reduced to 1 / 2. The maximum size or minimum size of the coding block that can be QT partitioned, the number of QT partitions (or the maximum partition depth), the partition depth of the minimum size block, the depth that can be partitioned from the maximum size coding block that can be QT partitioned, etc. can be sent by signaling via the upper layer header. Here, the upper layer header may include a slice layer, a picture layer, a sequence layer, a video layer, etc.

[0539] Binary tree (BT) partitioning is a method of partitioning a coding block into two blocks. Through BT partitioning, the coding block can be divided into two blocks in the horizontal or vertical direction. For example, through BT partitioning, the coding block can be partitioned into two blocks with the vertical length and horizontal length reduced to 1 / 2 or two blocks with the vertical length or horizontal length reduced to 3 / 4 or 1 / 4. Therefore, BT partitioning can represent a method of partitioning coding blocks with an accuracy of 1 / N (N>>2). The maximum size or minimum size of the coding block that can be partitioned by BT, the number of BT partitions (or the maximum partition depth), the partition depth of the minimum size block, the depth of partitioning from the maximum size coding block that can be partitioned by BT, etc. can be sent by signaling via the upper layer header.

[0540] Hereinafter, the QT partition and the BT partition will be described in detail with reference to the accompanying drawings.

[0541] Fig.29 is a diagram illustrating a method for encoding QT partition information of a coding block. In this embodiment, a "current" coding block refers to a block on which encoding is performed at a specific point in time. For example, the current coding block may refer to a block having a partition depth at which encoding is currently performed. For example, when a coding block is input for encoding, the first input coding block may be regarded as a "current coding block". Thereafter, as the coding block is partitioned, when encoding is performed on a partitioned block, the partitioned block may be regarded as a "current coding block".

[0542] When a coding block is input, the input coding block may be regarded as a 'current coding block' (S2901). The coding block input first may refer to a coding block having a partition depth of the highest level to be encoded (ie, a coding block having a depth of 0).

[0543] The encoding device may encode the QT partition information of the current coding block (S2902). Here, the QT partition information indicates whether QT partitioning is performed for the current coding block. When QT partitioning is performed on the current coding block, the QT partition information may be set to "true", and when QT partitioning is not performed on the current coding block, the QT partition information may be set to "false".

[0544] When it is determined that the current coding block is not to be QT partitioned (S2903), the QT partitioning process of the current coding block may be terminated. In addition, when it is determined that the current coding block is to be QT partitioned (S2903), four local blocks (or sub-blocks) included in the current coding block may be generated by QT partitioning (S2904).

[0545] When the current coding block is partitioned into four local blocks, one of the local blocks included in the current coding block is set as the current local block according to the encoding order, and the QT partition information of the current local block may be encoded (S2905). Here, the encoding order between the local blocks may follow raster scanning, Z scanning, etc., or may follow a predetermined order. That is, according to the encoding order of the local blocks, the QT partition information of the local blocks may be sequentially encoded.

[0546] When it is determined that the current local block is not to be QT partitioned (S2906), the QT partitioning process may be terminated based on whether the current local block is the last block in the current coding block and the last block in the input coding block (S2907, S2908). For example, when the current local block is not QT partitioned and the current local block is the last block in the current coding block and the last block in the input coding block, the QT partitioning process may be terminated. In addition, when the current local block is not the last local block of the current coding block or when the current coding block is the last local block of the current coding block but is not the last local block in the input coding block, the QT partition information encoding process may be performed for the next local block as the current local block (S2909).

[0547] In addition, when it is determined to perform QT ​​partitioning on the current local block (S2906), the current local block may be set as the current coding block (S2910), and the newly set current coding block may be partitioned into four local blocks (S2904). When the newly set current coding block is partitioned into four local blocks, the QT partition information encoding process for the four newly generated local blocks (S2905 to S2910) may be repeatedly performed.

[0548] The encoding device can encode the maximum size of the coding block that can be QT partitioned, the depth of the coding block that can be QT partitioned, etc. through the upper layer header based on the partition result of the current coding block.

[0549] The partition result of the current coding block may be used to determine the maximum size of the coding block capable of QT partitioning, the depth of the coding block capable of QT partitioning, etc. for the next coding block.

[0550] Fig.30 is a diagram illustrating a method of encoding BT partition information of a coding block.

[0551] When a coding block is input, the input coding block may be regarded as a current coding block (S3001). The coding block input first may refer to a coding block having a partition depth of the highest level to be encoded (ie, a coding block having a depth of 0).

[0552] The encoding device may encode BT partition information of the current coding block (S3002). Here, the BT partition information indicates whether BT partitioning is performed for the current coding block. When BT partitioning is performed on the current coding block, the BT partition information may be set to "true", and when BT partitioning is not performed on the current coding block, the BT partition information may be set to "false".

[0553] When the current coding block is partitioned into two local blocks, the encoding device may further encode information about the partition mode. In one example, the information about the partition mode may further include information about at least one of the partition direction or precision. Here, the partition direction indicates whether the current coding block is partitioned in the horizontal direction or in the vertical direction. In addition, the precision of the current block may be used as an element for determining the size of the local block. For example, according to the precision of the current block, it may be partitioned into two local blocks whose horizontal length or vertical length is 1 / 4 and 3 / 4 respectively compared to the upper block, or it may be partitioned into two local blocks whose horizontal length or vertical length is 1 / 2 respectively compared to the upper block.

[0554] For another example, the information about the partition mode may include a partition index. Here, the partition index indicates the partition shape of the current coding block. For example, according to the precision, the current coding block can be partitioned into a local block with a horizontal length of 1 / 4 compared to the upper block, a local block with a horizontal length of 1 / 2 compared to the upper block, a local block with a horizontal length of 3 / 4 compared to the upper block, a local block with a vertical length of 1 / 4 compared to the upper block, a local block with a vertical length of 1 / 2 compared to the upper block, a local block with a vertical length of 3 / 4 compared to the upper block, etc. Therefore, the encoding device can determine which of the seven cases the partition mode of the current decoding block corresponds to, and then can encode the index corresponding to the partition mode of the current decoding block according to the determination result.

[0555] When it is determined that the current coding block is not to be partitioned by BT (S3003), the BT partitioning process of the current coding block may be terminated. In addition, when it is determined that the current coding block is to be partitioned by BT (S3003), two local blocks (or sub-blocks) included in the current coding block may be generated by BT partitioning (S3004).

[0556] When the current coding block is partitioned into two local blocks, one of the local blocks included in the current coding block is set as the current local block according to the encoding order, and the BT partition information of the current local block may be encoded (S3005). Here, the encoding order between the local blocks may follow raster scanning, Z scanning, etc., or may follow a predetermined order. That is, according to the encoding order of the local blocks, the BT partition information of the local blocks may be sequentially encoded.

[0557] When it is determined that the current local block is not to be partitioned by BT (S3006), the BT partitioning process may be terminated based on whether the current local block is the last block in the current coding block and the last block in the input coding block (S3007, S3008). For example, when the current local block is not to be partitioned by BT and the current local block is the last block in the current coding block and the last block in the input coding block, the BT partitioning process may be terminated. In addition, when the current local block is not the last local block of the current coding block or when the current local block is the last local block of the current coding block but is not the last local block in the input coding block, the BT partition information encoding process may be performed for the next local block as the current local block (S3009).

[0558] In addition, when it is determined to perform BT partitioning on the current partial block (S3006), the current partial block may be set as the current coding block (S3010), and the newly set current coding block may be partitioned into two partial blocks (S3004). When the newly set current coding block is partitioned into two partial blocks, the BT partition information encoding process for the two newly generated partial blocks (S3005 to S3010) may be repeatedly performed.

[0559] The encoding device may encode the maximum size of the coding block that can be BT-partitioned, the depth of the coding block that can be BT-partitioned, etc. through an upper-layer header based on the partition result of the current coding block.

[0560] The partition result of the current coding block may be used to determine the maximum size of the coding block that can be BT partitioned, the depth of the coding block that can be BT partitioned, etc. for the next coding block.

[0561] Fig.31 is a diagram illustrating a method of decoding QT partition information of a decoding block. In this embodiment, a "current" decoding block refers to a block on which decoding is performed at a specific point in time. For example, a current decoding block may refer to a block having a partition depth at which decoding is currently performed. For example, when a decoding block is input for decoding, the first input decoding block may be regarded as a "current decoding block". Thereafter, as the decoding block is partitioned, when decoding is performed for a partitioned block, the partitioned block may be regarded as a "current decoding block".

[0562] When a decoding block is input, the input decoding block may be regarded as a 'current decoding block' (S3101). The decoding block input first may refer to a decoding block having a partition depth of the highest level to be decoded (ie, a decoding block having a depth of 0).

[0563] The decoding device may decode the QT partition information of the current decoding block (S3102). Here, the QT partition information indicates whether QT partitioning has been performed for the current decoding block. When the QT partition information is "true", the current decoding block may be QT partitioned, and when the QT partition information is "false", the current decoding block may not be QT partitioned.

[0564] When the QT partition information is false (i.e., when it is determined that the current decoding block is not partitioned by QT) (S3103), the QT partition process of the current decoding block may be terminated. In addition, when the QT partition information is "true" (i.e., when it is determined that the current decoding block is partitioned by QT) (S3103), four local blocks (or sub-blocks) included in the current decoding block may be generated by QT partitioning (S3104).

[0565] When the current decoding block is partitioned into four local blocks, one of the local blocks included in the current decoding block is set as the current local block according to the decoding order, and the QT partition information of the current local block may be decoded (S3105). Here, the decoding order between the local blocks may follow raster scanning, Z scanning, etc., or may follow a predetermined order. That is, according to the decoding order of the local blocks, the QT partition information of the local blocks may be sequentially decoded.

[0566] When the QT partition information of the current local block is false (i.e., when it is determined that the current local block is not partitioned by QT) (S3106), the QT partition process may be terminated based on whether the current local block is the last block in the current decoding block and the last block in the input decoding block (S3107, S3108). For example, when the current local block is not partitioned by QT and the current local block is the last block in the current decoding block and the last block in the input decoding block, the QT partition process may be terminated. In addition, when the current local block is not the last local block of the current decoding block or when the current decoding block is the last local block of the current decoding block but is not the last local block in the input decoding block, the QT partition information decoding process may be performed for the next local block as the current local block (S3109).

[0567] In addition, when the QT partition information of the current local block is true (i.e., when it is determined that the current local block is QT partitioned) (S3106), the current local block may be set as the current decoding block (S3110), and the newly set current decoding block may be partitioned into four local blocks (S3104). When the newly set current decoding block is partitioned into four local blocks, the QT partition information decoding process for the four newly generated local blocks (S3105 to S3110) may be repeatedly performed.

[0568] In the above embodiment, when the size of the current decoded block is equal to or smaller than the maximum block size capable of QT partitioning sent by a signal from the upper layer header or the depth of the current decoded block is equal to or greater than the maximum block size capable of QT partitioning sent by a signal from the upper layer header, the decoding of the partition information of the current decoded block may be omitted and QT partitioning may no longer be performed on the current decoded block.

[0569] Fig.32 is a diagram illustrating a method of decoding BT partition information of a decoding block.

[0570] When a decoding block is input, the input decoding block may be regarded as a current decoding block (S3201). The decoding block input first may refer to a decoding block having a partition depth of the highest level to be decoded (ie, a decoding block having a depth of 0).

[0571] The decoding device may decode the BT partition information of the current decoding block (S3202). Here, the BT partition information indicates whether BT partitioning has been performed for the current decoding block. When the BT partition information is "true", the current decoding block may be BT partitioned, the BT partition information may be set to "true", and when the BT partition information is "false", the current decoding block may not be BT partitioned.

[0572] When the BT partition information is "true" (i.e., when the current decoding block is partitioned by BT), the decoding device may also decode information about the partition mode. In one example, the information about the partition mode may also include information about at least one of the partition direction or precision. Here, the partition direction indicates whether the current decoding block is partitioned in the horizontal direction or in the vertical direction. In addition, the precision of the current block may be used as an element for determining the size of the local block. For example, according to the precision of the current block, it may be partitioned into two local blocks whose horizontal length or vertical length is 1 / 4 and 3 / 4, respectively, compared to the upper block, or it may be partitioned into two local blocks whose horizontal length or vertical length is 1 / 2, respectively, compared to the upper block.

[0573] For another example, the information about the partition mode may include a partition index. Here, the partition index indicates the partition shape of the current decoding block. For example, according to the accuracy, the current decoding block can be partitioned into a local block with a horizontal length of 1 / 4 compared to the upper block, a local block with a horizontal length of 1 / 2 compared to the upper block, a local block with a horizontal length of 3 / 4 compared to the upper block, a local block with a vertical length of 1 / 4 compared to the upper block, a local block with a vertical length of 1 / 2 compared to the upper block, and a local block with a vertical length of 3 / 4 compared to the upper block. Therefore, the decoding device can decode the index indicating one of the seven situations, and can determine the partition mode of the current decoding block.

[0574] When the BT partition information is false (i.e., when it is determined that the current decoding block is not partitioned by BT) (S3203), the BT partition process of the current decoding block may be terminated. In addition, when the BT partition information is true (i.e., when it is determined that the current decoding block is partitioned by BT) (S3203), two partial blocks (or sub-blocks) included in the current decoding block may be generated by BT partitioning (S3204).

[0575] When the current decoding block is partitioned into two local blocks, one of the local blocks included in the current decoding block is set as the current local block according to the decoding order, and the BT partition information of the current local block may be decoded (S3205). Here, the decoding order between the local blocks may follow a raster scan, a Z scan, etc., or may follow a predetermined order. That is, according to the decoding order of the local blocks, the BT partition information of the local blocks may be sequentially decoded.

[0576] When it is determined that the current partial block is not partitioned by BT (S3206), the BT partition process may be terminated based on whether the current partial block is the last block in the current decoding block and the last block in the input decoding block (S3207, S3208). For example, when the current partial block is not partitioned by BT and the current partial block is the last block in the current decoding block and the last block in the input decoding block, the BT partition process may be terminated. In addition, when the current partial block is not the last partial block of the current decoding block or when the current decoding block is the last partial block of the current decoding block but is not the last partial block in the input decoding block, the BT partition information decoding process may be performed for the next partial block as the current partial block (S3209).

[0577] In addition, when it is determined that the current partial block is BT partitioned (S3206), the current partial block may be set as the current decoding block (S3210), and the newly set current decoding block may be partitioned into two partial blocks (S3204). When the newly set current decoding block is partitioned into two partial blocks, the BT partition information decoding process for the two newly generated partial blocks (S3205 to S3210) may be repeatedly performed.

[0578] In the above embodiment, when the size of the current decoded block is equal to or smaller than the maximum block size capable of BT partitioning sent by a signal from the upper layer header or the depth of the current decoded block is equal to or greater than the maximum block size capable of QT partitioning sent by a signal from the upper layer header, decoding of the partition information of the current decoded block may be omitted and BT partitioning may no longer be performed on the current decoded block.

[0579] exist Figure 29 to Figure 32In the example shown in , a method of recursively partitioning a coding / decoding block of a maximum size using QT partitioning or BT partitioning has been described. Here, when partitioning a coding / decoding block into multiple local blocks, the QT partitioning method and the BT partitioning method may be used in combination, and the order of the QT partitioning and the BT partitioning may be set differently. For example, the encoding device may continue to partition the maximum coding block using QT partitioning, and when a local block determined to be optimal for applying BT partitioning is found, the QT partitioning may be terminated and the local blocks may continue to be partitioned by BT partitioning. Alternatively, the local blocks may be partitioned using QT partitioning when it is determined that the local blocks generated by BT partitioning are optimal for applying QT partitioning. Therefore, the encoding device may identify the optimal partitioning method for each block, and therefore may encode information indicating the optimal partitioning method for each block.

[0580] For another example, the decoding device may decode the QT partition information or the BT partition information to determine the optimal partition state of the decoding block. Here, the QT partition method or the BT partition method may be applied only when the other method is not applicable. For example, the BT partition information of the predetermined block may be decoded only when the QT partition information of the predetermined block is false or the upper block including the predetermined block is BT partitioned.

[0581] When encoding block partition information, the encoding device may encode information indicating whether each partitioning method is used through an upper-layer header. For example, the encoding device may encode information indicating whether QT partitioning is used, whether BT partitioning is used, etc. through an upper-layer header. For example, when it is determined to use QT partitioning but not BT partitioning, the coding block may be partitioned using only QT partitioning. In this case, the encoding of BT partition information indicating whether the coding block has been partitioned by BT may be omitted. For another example, when it is determined that both QT partitioning and BT partitioning will be used, the coding block may be partitioned using QT partition mode and BT partition mode.

[0582] Fig.33 is a diagram showing the state of partitions in a coding block.

[0583] For ease of explanation, it is assumed that when a block is partitioned by BT, the local block generated by BT partitioning may no longer be partitioned into BT blocks. Fig.33 In the example shown in FIG. 1 , the solid line indicates that the partition is performed using the QT partition method, and the dotted line indicates that the partition is performed using the BT partition method. Fig.33, showing that: QT partitioning generates a sub-block whose width and length are reduced by 1 / 2 compared to the upper block, and BT partitioning generates a sub-block whose horizontal length or vertical length is reduced to 1 / 2 of the upper block or a sub-block whose horizontal length or vertical length is reduced to 1 / 4 of the upper block. Therefore, in the example shown, the maximum partition accuracy of the coding block can be 1 / 4. The numbers indicated on each partition line represent the partition order.

[0584] Reference Fig.33 , partition line ① indicates that the QT partition is the best for the first input coding block. Partition line ② indicates that the 1 / 2 horizontal BT partition is the best partition for the upper left local block partitioned by partition line ①. Partition line ③ indicates that the 1 / 2 vertical BT partition is the best partition for the upper local block partitioned by partition line ②. Partition line ④ indicates that the 1 / 2 horizontal BT partition is the best partition for the lower local block partitioned by partition line ②. Partition line ⑤ indicates that the 1 / 2 vertical BT partition is the best partition for the upper right local block partitioned by partition line ①. Partition line ⑥ indicates that the 1 / 2 vertical BT partition is the best partition for the left local block partitioned by partition line ⑤. Partition line ⑦ indicates that the 1 / 2 vertical BT partition is the best partition for the right local block partitioned by partition line ⑤. Partition line ⑧ indicates that the QT partition is the best partition for the lower left local block partitioned by partition line ①. Partition line ⑨ indicates that the 1 / 2 horizontal BT partition is the best partition for the upper left local block partitioned by partition line ⑧. Partition line ⑩ indicates that the 3 / 4 horizontal BT partition is the best partition for the lower local block partitioned by partition line ⑨. Indicates that the 1 / 4 horizontal BT partition is the best partition for the lower left local block partitioned by partition line⑧. It shows that the 1 / 2 horizontal BT partition is the best partition for the lower right local block partitioned by partition line ①. Show 3 / 4 vertical BT partition for passing partition line The partition line is the best partition for the local block in the zone. Show 1 / 2 vertical BT partition for passing partition line The partition line is the best partition for the lower local block of the zone. Show 3 / 4 vertical BT partition for passing partition line It is the best partition for the right local block of the zone.

[0585] Fig.34 is shown using a tree structure Fig.33 Schematic diagram of the optimal partition state of the input coding block shown in .

[0586] In the case of QT partitioning, since there are two cases (i.e., a case where QT partitioning is not performed and a case where a block is partitioned into four partial blocks (i.e., horizontal and vertical partitioning 1 / 2) according to QT partitioning), the QT partition information can be represented as 0 or 1. The case of BT partitioning may include a case where BT partitioning is not performed, and may include a case where a block is partitioned into two partial blocks according to BT partitioning. Here, when a block is partitioned into two partial blocks, there are multiple cases depending on the accuracy: a case where a block is partitioned into a partial block having a horizontal length of 1 / 4 of an upper block, a case where a block is partitioned into a partial block having a horizontal length of 1 / 2 of an upper block, a case where a block is partitioned into a partial block having a horizontal length of 3 / 4 of an upper block, a case where a block is partitioned into a partial block having a vertical length of 1 / 4 of an upper block, a case where a block is partitioned into a partial block having a vertical length of 1 / 2 of an upper block, a case where a block is partitioned into a partial block having a vertical length of 3 / 4 of an upper block, etc. Therefore, the BT partition information can be represented as 0 to 6.

[0587] exist Fig.34 In the tree structure, QT partition information and BT partition information are indicated.

[0588] Based on the above description, a method for controlling the number or type of intra prediction modes in an encoding / decoding block and a method for encoding / decoding the same will be described in detail.

[0589] Fig.35 is a flowchart showing a process of controlling the number or type of prediction modes in an encoding device. Fig.35 In the embodiment, each step is connected as a series of processes, but it is not limited to that each step is performed in the order illustrated. For example, when the determination result of the number or type of intra-frame prediction modes for the prediction block is not affected, the order illustrated may be changed. For example, when the number or type of intra-frame prediction modes does not change when the order of steps S3501 and S3502 is changed, the order may be changed. In addition, the steps S3501 and S3502 may be omitted. Fig.35 For example, if the number or type of intra prediction modes can be controlled regardless of the shape of the prediction block, step S3502 can be omitted.

[0590] In this embodiment, the current coding block may represent a prediction block or a coding block including a prediction block. Fig.35 The present invention is described in detail.

[0591] In S3501, it has been shown that the number or type of intra-frame prediction modes can be controlled according to the size of the current coding block. Specifically, the number of intra-frame prediction modes that can be used for the current coding block can be variably determined according to the size of the current coding block. For example, the number of intra-frame prediction modes that can be used for the current coding block can increase as the size of the current coding block increases. For example, assuming that the minimum size of the prediction block is 4×4 and the maximum size is 256×256, when the size of the current coding block is equal to or greater than 4×4 and less than or equal to 32×32, the number of intra-frame prediction modes that can be used for the current coding block can be set to 35, or when the size of the current coding block is equal to or greater than 64×64 and less than or equal to 256×256, the number of intra-frame prediction modes that can be used for the current coding block can be set to 67.

[0592] Optionally, the number of intra-frame prediction modes available for the current coding block may increase as the size of the current coding block decreases. For example, assuming that the minimum size of the prediction block is 4×4 and the maximum size is 256×256, when the size of the current coding block is equal to or greater than 4×4 and less than or equal to 32×32, the number of intra-frame prediction modes available for the current coding block may be set to 67, or when the size of the current coding block is equal to or greater than 64×64 and less than or equal to 256×256, the number of intra-frame prediction modes available for the current coding block may be set to 35.

[0593] The number of intra-frame prediction modes available for the current coding block can be determined based on the comparison result of the size of the current coding block and the reference size. Here, the reference size can be sent by signaling through the upper layer header, or the reference size can be derived as the same condition in the encoding device and the decoding device. For example, assuming that the reference size is 32×32, information about the reference size can be defined by applying the logarithmic function "log232" and can be sent through the bitstream. When the size of the current coding block is smaller than or larger than the reference size, the number of intra-frame prediction modes available for the current coding block can increase. For example, when the size of the current coding block is 32×32, the number of intra-frame prediction modes available for the current coding block can be 19, when the size of the current coding block is equal to or greater than 64×64 and less than or equal to 128×128, the number of intra-frame prediction modes available for the current coding block can be 35, and when the size of the current coding block is 256×256, the number of intra-frame prediction modes available for the current coding block can be 67. When the size of the current coding block is equal to or less than 16×16 and greater than or equal to 8×8, the number of intra-frame prediction blocks available for the current coding block is 35, and when the size of the current coding block is 4×4, the number of intra-frame prediction blocks available for the current coding block is 67.

[0594] Optionally, when the size of the current coding block is less than or greater than the reference size, the number of intra-frame prediction modes available for the current coding block may be reduced. For example, when the size of the current coding block is 32×32, the number of intra-frame prediction modes available for the current coding block may be 67, when the size of the current coding block is equal to or greater than 64×64 and less than or equal to 128×128, the number of intra-frame prediction modes available for the current coding block may be 35, and when the size of the current coding block is 256×256, the number of intra-frame prediction modes available for the current coding block may be 19. When the size of the current coding block is equal to or less than 16×16 and greater than or equal to 8×8, the number of intra-frame prediction blocks available for the current coding block is 35, and when the size of the current coding block is 4×4, the number of intra-frame prediction blocks available for the current coding block is 19.

[0595] Regardless of the size of the current coding block, the intra-frame prediction mode that can be used for the current coding block may include a non-directional intra-frame prediction mode (or a non-angular prediction mode). That is, regardless of the size of the current coding block, the current coding block can be encoded using a non-directional intra-frame prediction mode. In addition, the number of directional prediction modes (i.e., angular prediction modes) that can be used for the current coding block may vary according to the size of the current coding block. As the number of intra-frame prediction modes that can be used for the current coding block decreases or increases, the number of directional prediction modes that can be used for the current coding block may also decrease or increase.

[0596] When the number of directional prediction modes available for the current coding block is reduced, the current coding block may use an integer unit directional prediction mode or a mode similar thereto. Here, the integer unit directional prediction mode refers to a mode in which intra prediction can be performed using integer unit reference samples. Here, the integer unit reference samples may refer to the reference samples themselves rather than additional reference samples generated by interpolation of the reference samples. For example, an intra prediction mode in the horizontal direction, vertical direction, or diagonal direction may be an integer unit directional prediction mode.

[0597] In addition, the directional prediction modes that can be used for the current coding block can be determined by partitioning the entire directional prediction mode section by the number N of directional prediction modes to be used (N-1 equally divided partitions).

[0598] Fig.36 and Fig.37 is a diagram showing an example in which 13 directional prediction modes are available for a current coding block.

[0599] Reference Fig.36 , the intra prediction modes available for the current coding block may be integer unit directional prediction modes and directional prediction modes adjacent to the integer unit directional prediction modes. Fig.36, intra prediction modes in the vertical direction, the horizontal direction, and three diagonal directions and intra prediction modes adjacent thereto (intra prediction modes with offsets of ±1) are shown as available directional prediction modes.

[0600] Reference Fig.37 , the directional prediction modes available for the current coding block may be 13 directional prediction modes allocated at uniform intervals by partitioning the entire directional prediction mode segment into 12 equal parts.

[0601] When the number of intra prediction modes available for a current prediction block increases, more intra prediction modes adjacent to an integer-unit directional prediction mode may be used, or a section of the entire directional prediction mode may be partitioned into more parts.

[0602] For example, Fig.38 and Fig.39 is a diagram showing an example in which 21 directional prediction modes are available for a current block.

[0603] exist Fig.38 , for the intra modes available for the current coding block, the intra prediction modes in the vertical direction, the horizontal direction, and the three diagonal directions and the intra prediction modes adjacent thereto (intra prediction modes with an offset of ±2) are shown as directional prediction modes available for the current coding block.

[0604] exist Fig.39 , it is shown that the intra prediction modes available for the current coding block are 21 directional prediction modes allocated at uniform intervals by partitioning the entire directional prediction mode section into 20 equal parts.

[0605] The encoding device may encode the number of intra-frame prediction modes for each size of the prediction block, and may send the encoded number to the decoding device. Here, information indicating the number of intra-frame prediction modes for each size of the prediction block may be encoded in the upper layer header. For example, assuming that the minimum size of the prediction block is 4×4 and the maximum size is 256×256, and when it is determined that the number of intra-frame prediction modes available for prediction blocks less than or equal to 32×32 blocks is 64, a value (log264) obtained by applying a logarithm to the number of available intra-frame prediction modes may be encoded and sent to the decoding device. When it is determined that the number of intra-frame prediction modes available for a 64×64 prediction block is 32, a value (log232) obtained by applying logarithm to the number of available intra-frame prediction modes may be encoded, when it is determined that the number of intra-frame prediction modes available for a 128×128 prediction block is 16, a value (log216) obtained by applying logarithm to the number of available intra-frame prediction modes may be encoded, and when it is determined that the number of intra-frame prediction modes available for a 256×256 prediction block is 8, a value (log28) obtained by applying logarithm to the number of available intra-frame prediction modes may be encoded.

[0606] For another example, the number of intra prediction modes available for each size of the prediction block may be predetermined in the upper layer header, the optimal number of intra prediction modes for each prediction block may be determined, and thus, index information indicating the number of available intra prediction modes in units of prediction blocks may be encoded. For example, when the number of intra prediction modes available for a 32×32 prediction block is 19, 35, or 67, index information indicating which of 19, 35, or 67 is optimal for the 32×32 prediction block may be encoded.

[0607] The encoding device may encode information indicating whether the number or type of intra prediction modes will be adjusted according to the size of the prediction block. The encoded information may be sent to the decoding device through the upper layer header. Here, the information may be a 1-bit flag, but is not limited thereto. The decoding device may determine in advance whether to adjust the number or type of prediction modes for each size of the prediction block based on the flag information.

[0608] Even when the information encoded in the upper layer header indicates that the number of available intra-frame prediction modes can be adjusted according to the size of the prediction block, intra-frame prediction of the conventional method can be performed for the current coding block, or intra-frame prediction can be performed for the current coding block by adjusting the number of available intra-frame prediction modes according to the size of the prediction block. Therefore, when the information encoded in the upper layer header indicates that the number of available intra-frame prediction modes can be adjusted according to the size of the prediction block, the encoding device can also encode information indicating whether the prediction block is encoded according to the conventional method (i.e., using a fixed number of intra-frame prediction modes) or the number of available intra-frame prediction modes is adjusted according to the size of the prediction block in units of prediction blocks. Here, the encoded information can be a 1-bit flag, but is not limited to this.

[0609] In S3502, it is shown that the number or type of intra-frame prediction modes can be controlled according to the shape of the current coding block. Specifically, the number of intra-frame prediction modes that can be used for the current coding block can be variably determined according to the shape of the current coding block. For example, when the current block is a non-square block (e.g., a rectangular block), it can be set for the current block: the intra-frame prediction mode in the horizontal direction can be used more than the intra-frame prediction mode in the vertical direction, or the intra-frame prediction mode in the vertical direction can be used more than the intra-frame prediction mode in the horizontal direction.

[0610] Specifically, when the shape of the current coding block is non-square, the number of intra-frame prediction modes in the horizontal direction and the number of intra-frame prediction modes in the vertical direction that can be used for the current block can be determined according to the ratio of the width to the height of the current coding block. For example, when the size of the current coding block is 8×16, since the height of the current coding block is twice the width, the number of horizontal intra-frame prediction modes that can be used for the current coding block can be approximately twice the number of horizontal intra-frame prediction modes. For example, when the number of directional intra-frame prediction modes that can be used for the current coding block is 25, the current coding block can be set to use 16 horizontal intra-frame prediction modes and 9 vertical intra-frame prediction modes.

[0611] The number of intra-frame prediction modes available for the current coding block can be determined by comparing the width or height of the current coding block with a predetermined threshold. Here, the threshold value can be sent by an upper layer header with a signal. For example, a value obtained by applying a logarithm (Log2) to the threshold value can be sent by an upper layer header with a signal. Optionally, the encoding device and the decoding device can derive the threshold value under the same conditions. Here, a threshold value can be set for each of the width and height, or the same value can be used for the width and height. For example, when the threshold value of the width is 32, and when the width of the current coding block is less than the threshold, the current coding block can use only 1 / 2N of the N horizontal intra-frame prediction modes. For example, when the number of horizontal prediction modes is 33, the current coding block can use 17 horizontal prediction modes.

[0612] Regardless of the shape of the current coding block, the intra-frame prediction mode available for the current coding block may include a non-directional intra-frame prediction mode (or a non-angular prediction mode). In addition, the number of directional prediction modes (i.e., angular prediction modes) available for the current coding block may vary according to the shape of the current coding block. As the number of intra-frame prediction modes available for the current coding block decreases or increases, the number of directional prediction modes available for the current coding block may also decrease or increase.

[0613] The directional prediction mode available for the current coding block may be determined as an integer unit directional prediction mode or a similar mode. Optionally, the directional prediction mode available for the current coding block may be determined by partitioning the entire directional prediction mode segment according to the number N of directional prediction modes to be used (N-1 equal partitions). Figure 36 to Figure 39 This has been described, so its detailed description will be omitted.

[0614] The encoding device may encode information indicating whether the number or type of intra prediction modes will be adjusted according to the shape of the prediction block. The encoded information may be sent to the decoding device through the upper layer header. Here, the information may be a 1-bit flag, but is not limited thereto. The decoding device may determine in advance whether to adjust the number or type of intra prediction modes for each shape of the prediction block based on the flag information.

[0615] Even when the information encoded in the upper layer header indicates that the number of available intra-frame prediction modes can be adjusted according to the shape of the prediction block, intra-frame prediction of the conventional method can be performed for the current coding block, or intra-frame prediction can be performed for the current coding block by adjusting the number of available intra-frame prediction modes according to the shape of the prediction block. Therefore, when the information encoded in the upper layer header indicates that the number of available intra-frame prediction modes can be adjusted according to the shape of the prediction block, the encoding device can also encode information indicating whether the prediction block is encoded according to the conventional method (i.e., using a fixed number of intra-frame prediction modes) or the number of available intra-frame prediction modes is adjusted according to the shape of the prediction block in units of prediction blocks. Here, the encoded information can be a 1-bit flag, but is not limited to this.

[0616] In S3503, it is shown that the number or type of intra prediction modes can be controlled according to neighboring blocks of the current coding block. Specifically, the number of intra prediction modes available for the current coding block can be determined according to the intra prediction modes of neighboring blocks adjacent to the current coding block.

[0617] For example, referring to the statistics of the intra prediction modes of the neighboring blocks of the current coding block, when the non-directional prediction mode and the directional prediction mode are mixed and the ratio of the non-directional prediction mode to the directional prediction mode is equal to or greater than the threshold ratio or equal to or less than the threshold ratio, the intra prediction characteristic of the current coding block may be determined to be ambiguous. When it is determined that the intra prediction characteristic of the current coding block is ambiguous, the number or type of intra prediction modes available for the current coding block may not be changed. Therefore, all intra prediction modes may be available for the current coding block.

[0618] For example, with reference to the intra prediction mode of the neighboring block of the current block, when there are 9 non-directional modes and 8 directional modes and there are 4 horizontal modes and 4 vertical modes among the directional modes, it is difficult to determine which of the non-directional mode, the vertical directional mode, or the horizontal directional mode can be expected to be used for the current coding block. When it is difficult to determine the intra prediction mode mainly used by the neighboring prediction block because the ratio of the non-directional prediction mode to the directional prediction mode of the neighboring block adjacent to the current prediction block is close to 1:1, or when it is difficult to determine the main direction of the neighboring prediction block because the neighboring prediction block is encoded using the directional prediction mode but the horizontal directional mode and the vertical directional mode are mixed, the number or type of intra prediction modes that can be used for the current coding block may not be changed.

[0619] In addition, with reference to the statistics of the intra-frame prediction mode adjacent to the current coding block, when it is determined that the non-directional prediction mode is used more than the directional prediction mode and the degree of use exceeds the threshold ratio, the prediction characteristic of the current coding block can be determined as a non-directional mode. In this case, the intra-frame prediction mode that can be used for the current coding block may necessarily include a non-directional mode, and may additionally include a predetermined number of directional modes. When the neighboring blocks of the current coding block are mainly encoded by the non-directional prediction mode, the contour with a specific direction is unlikely to appear in the current coding block. Therefore, even when only a non-directional prediction mode is used or only a non-directional prediction mode and a predetermined number of directional prediction modes (for example, two prediction modes of a vertical directional prediction mode and a directional prediction mode) are used, the best intra-frame prediction mode of the current coding block can be identified.

[0620] With reference to the statistics of the intra-frame prediction modes adjacent to the current coding block, when it is determined that the directional prediction mode is used more than the non-directional prediction mode and the degree of more exceeds the threshold ratio, the prediction characteristic of the current coding block can be determined as the directional mode. When the ratio between the horizontal directional prediction mode and the vertical directional prediction mode of the intra-frame prediction mode of the neighboring block is biased to one side (for example, when the horizontal directional prediction mode is used more than the vertical directional prediction mode and the degree of more exceeds the threshold ratio, when the vertical directional prediction mode is used more than the horizontal directional prediction mode and the degree of more exceeds the threshold ratio, etc.), the more used directional prediction mode among the horizontal directional prediction mode and the vertical directional prediction mode can be used to configure the intra-frame prediction mode that can be used for the current coding block. Here, in addition to the horizontal directional prediction mode or the vertical directional prediction mode, the intra-frame prediction mode that can be used for the current coding block can also include a non-directional prediction mode.

[0621] For example, when all intra prediction modes adjacent to the current coding block are directional prediction modes and there are 11 horizontal directional modes and 2 vertical directional modes among the intra prediction modes of the adjacent blocks, it is expected that the current block may have horizontal characteristics. Therefore, the non-directional prediction mode and the horizontal directional prediction mode may be used to determine the optimal intra prediction mode for the current coding block.

[0622] In the above example, the threshold ratio (the threshold ratio as a standard for the directional mode and the non-directional mode, the threshold ratio as a standard for the horizontal directional mode and the vertical directional mode, etc.) can be signaled through the upper layer header. For example, a value obtained by applying a logarithm (log2) to the threshold ratio can be sent through the upper layer header.

[0623] Regardless of the intra prediction mode adjacent to the current coding block, the intra prediction mode available for the current coding block may include a non-directional intra prediction mode (or non-angle prediction mode). In addition, the number of directional prediction modes (i.e., angle prediction modes) available for the current coding block may vary according to the mode of using the intra prediction mode adjacent to the current coding block. As the number of intra prediction modes available for the current coding block decreases or increases, the number of directional prediction modes available for the current coding block may also decrease or increase.

[0624] The directional prediction mode available for the current coding block may be determined as an integer unit directional prediction mode or a similar mode. Optionally, the directional prediction mode available for the current coding block may be determined by partitioning the entire directional prediction mode segment according to the number N of directional prediction modes to be used (N-1 equal partitions). Figure 36 to Figure 39 This has been described, so its detailed description will be omitted.

[0625] The encoding device may encode information indicating whether the number or type of intra prediction modes will be adjusted according to the usage pattern of the intra prediction mode of the neighboring block adjacent to the prediction block. The encoded information may be sent to the decoding device through the upper layer header. Here, the information may be a 1-bit flag, but is not limited thereto. The decoding device may determine in advance whether to adjust the number or type of intra prediction modes for each shape of the prediction block based on the flag information.

[0626] Even when the information encoded in the upper layer header indicates that the number of available intra-frame prediction modes can be adjusted according to the usage mode of the intra-frame prediction mode of the neighboring block adjacent to the prediction block, the intra-frame prediction of the conventional method can be performed for the current coding block, or the intra-frame prediction can be performed for the current coding block by adjusting the number of available intra-frame prediction modes according to the usage mode of the intra-frame prediction mode of the neighboring block. Therefore, when the information encoded in the upper layer header indicates that the number of available intra-frame prediction modes can be adjusted according to the usage mode of the intra-frame prediction mode of the neighboring block, the encoding device can also encode information indicating whether the prediction block is encoded according to the conventional method (i.e., using a fixed number of intra-frame prediction modes) or the number of available intra-frame prediction modes is adjusted according to the usage mode of the intra-frame prediction mode of the neighboring block in units of prediction blocks. Here, the encoded information can be a 1-bit flag, but is not limited to this.

[0627] The encoding process has been described with reference to Fig.35 , and the number of intra-frame prediction modes that can be used for the current block being decoded can also be adjusted during the decoding process. The decoding device can adjust the number of intra-frame prediction modes that can be used for the current decoding block based on information sent by signaling through the bitstream in consideration of the size, shape, usage pattern of the intra-frame prediction mode, etc. of the neighboring decoding blocks.

[0628] When determining the number of intra prediction modes available for the current coding block, the encoding device may determine the intra prediction mode of the current coding block among the intra prediction modes available for the current coding block, and may encode information about the determined intra prediction mode. Hereinafter, a method for encoding / decoding the intra prediction mode of the current block will be described in detail.

[0629] Fig.40 is a flowchart showing a process of encoding the best intra prediction mode for the current coding block.

[0630] Reference Fig.40 First, the encoding device may determine an MPM candidate for the current coding block (S4001). Here, considering that the number of directional prediction modes available for the current coding block is different from the number of directional prediction modes available for neighboring blocks of the current coding block, the encoding device may set a quantized directional prediction mode (or an angle of a quantized directional prediction mode) as an MPM candidate for the directional prediction mode.

[0631] For example, Fig.41 is a diagram showing an example of setting an MPM candidate. Fig.41 In , the use of three MPM candidates is illustrated. Fig.41 In the example shown in , L may be the intra-frame prediction mode with the highest frequency of occurrence among the neighboring blocks adjacent to the left side of the current coding block, or may be the intra-frame prediction mode of the neighboring block (or any neighboring block) at a predetermined position adjacent to the left side of the current coding block. In addition, A may be the intra-frame prediction mode with the highest frequency of occurrence among the neighboring blocks adjacent to the top side of the current coding block, or may be the intra-frame prediction mode of the neighboring block (or any neighboring block) at a predetermined position adjacent to the top side of the current coding block.

[0632] L, L-1, L+1, and A may represent the index of the intra-frame prediction mode. When the number of directional prediction modes available for the current coding block is different from the number of directional prediction modes available for the neighboring blocks of the current coding block, it may happen that the directional prediction mode used by the neighboring blocks is not available for the current coding block. For example, mode 18 among the intra-frame prediction modes available for the current coding block may refer to the horizontal directional prediction mode, however, mode 18 among the intra-frame prediction modes available for the neighboring blocks may refer to the upper left directional prediction mode instead of the horizontal directional mode.

[0633] In order to resolve this inconsistency, when a non-directional prediction mode is assigned to an MPM candidate, the index information may be used as is, and when a directional prediction mode is assigned to an MPM candidate, a prediction angle corresponding to the directional prediction mode may be assigned. When the quantized angle is set as an MPM candidate, the encoding device may determine the intra-frame prediction mode of the current coding block based on whether the prediction angle of the best directional prediction mode of the current coding block is equal to the quantized angle included in the MPM candidate. Therefore, when the MPM candidate is a non-directional prediction mode, the index of the intra-frame prediction mode (such as L, L-1, L+1, A, etc.) may be used as the MPM candidate, but when the MPM candidate is a directional prediction mode, the angle of the intra-frame prediction mode (such as L', (L-1)', (L+1)', A', etc.) may be used as the MPM candidate.

[0634] When a directional prediction mode matching the prediction angle of a neighboring block is not available for the current coding block, quantization that reduces the prediction angle of the neighboring block to the most similar prediction angle of the directional mode available for the current prediction block may be performed. Therefore, when the MPM candidate is a directional prediction mode, an MPM candidate indicating a quantized angle of the directional prediction mode (such as L', (L-1)', (L+1)', A', etc.) may be used.

[0635] For example, Fig.42 and Fig.43is a diagram showing an example of quantizing a prediction angle. Fig.43 shows the directional prediction modes that can be used for neighboring blocks adjacent to the current coding block, and Fig.42 The directional prediction modes that can be used for the current coding block are shown. Fig.42 and Fig.43 By comparison, it can be confirmed that Fig.43 The directional prediction mode indicated by the dotted line in is not available for the current coding block. Therefore, when a neighboring block is encoded using the directional prediction mode indicated by the dotted line, the prediction angle of the directional prediction mode indicated by the dotted line may be converted to the prediction angle of the most similar prediction mode among the directional prediction modes available for the current block, and the converted angle may be set as the MPM candidate.

[0636] In the above embodiments, it has been described that the MPM candidate may be set as the prediction angle of the directional prediction mode in consideration of the case where the number of directional prediction modes available for the current coding block is different from the number of directional prediction modes available for neighboring blocks of the current coding block.

[0637] For another example, when the number of directional prediction modes available for the current coding block is equal to the number of directional prediction modes available for the neighboring blocks of the current coding block, the MPM candidate may indicate the index of the intra-frame mode also used for the directional prediction mode. Optionally, when the number of directional prediction modes available for the current coding block is different from the number of directional prediction modes available for the neighboring blocks of the current coding block, the MPM candidate may be set to indicate the index of the intra-frame prediction mode also used for the directional prediction mode. In this case, the directional prediction mode of the neighboring block can be quantized (or converted) to the index of the mode with the most similar direction among the directional prediction modes available for the current block.

[0638] Fig.44 is a diagram illustrating another example of setting MPM candidates.

[0639] The encoding device may derive the MPM candidate of the current coding block based on the neighboring blocks adjacent to the current coding block. Here, the neighboring blocks adjacent to the current coding block may include at least one of a block adjacent to the top side of the current coding block, a block adjacent to the left side of the current coding block, and a block adjacent to the corner of the current coding block.

[0640] For example, Fig.45 is a diagram showing an example of neighboring blocks used to derive MPM candidates for a current coding block. Fig.45 In order to derive the MPM candidates of the current coding block, the left neighboring block A, the top neighboring block B, the bottom left neighboring block C, the top right neighboring block D and the top left neighboring block E can be used.

[0641] The encoding device can be based on Fig.44The MPM candidates are generated according to the priorities shown in . Assuming that the number of MPM candidates for the current coding block is 5, first, the intra-frame prediction modes of the neighboring blocks can be added as MPM candidates in the order of neighboring block A and neighboring block B. Next, non-directional modes such as planar mode and DC mode can be added as MPM candidates. Next, the intra-frame prediction modes of the neighboring blocks can be added as MPM candidates in the order of neighboring block C, neighboring block D, and neighboring block E.

[0642] When the number of MPM candidates does not reach the maximum number, and when there is a directional pattern among the MPM candidates determined so far, the encoding device may add a pattern having a direction similar to the directional pattern (for example, a directional pattern with an offset of ±1) as an MPM candidate.

[0643] However, when the number of MPM candidates does not reach the maximum number, prediction modes in the vertical direction, horizontal direction, and diagonal direction (for example, a prediction mode in the lower left direction (a prediction mode with index 2), a prediction mode in the upper left direction, a prediction mode in the upper right direction, etc.) may be added to the MPM candidates.

[0644] exist Fig.45 In FIG. 1 , it is shown that the MPM candidate can be derived from the neighboring blocks adjacent to the current coding block. Fig.41 and Fig.44 In the embodiment shown in , the MPM candidate may be derived based on the intra mode of a neighboring block not adjacent to the current coding block according to the size, shape or decoding status of the current coding block or a neighboring block adjacent to the current coding block.

[0645] For example, Fig.46 is a diagram illustrating an example of deriving MPM candidates through neighboring blocks that are not adjacent to a current coding block.

[0646] When non-square blocks (e.g., rectangular blocks whose width is greater than their height) continuously exist in the top direction of the current coding block and the height of the top neighboring block adjacent to the current coding block is less than the height of the current coding block, the encoding device may predict that the intra-frame prediction mode of the top neighboring block is different from the intra-frame prediction mode of the current coding block. Optionally, when the intra-frame prediction mode of the neighboring block adjacent to the top side of the current coding block is one of the vertically oriented prediction modes, the encoding device may predict that the intra-frame prediction mode of the top neighboring block is different from the intra-frame prediction mode of the current coding block.

[0647] In this case, the encoding device may consider deriving additional MPM candidates through at least one of the blocks adjacent to the current coding block (i.e., the left neighboring block, the upper left neighboring block, the upper right neighboring block, and the lower left neighboring block). Alternatively, the encoding device may derive additional MPM candidates through blocks adjacent to the neighboring blocks but not adjacent to the current coding block. For example, in Fig.23In the embodiment shown in , the encoding device may derive the MPM candidate based on the second top side block (i.e., the second top side neighboring block) that replaces the block adjacent to the top side of the current encoding block (i.e., the first top side neighboring block) or a block located farther in the top side direction. Alternatively, the encoding device may consider the MPM candidate using only the intra prediction mode of the neighboring blocks in a specific direction other than the top side direction.

[0648] When non-square blocks (e.g., rectangular blocks whose height is greater than their width) continuously exist in the left direction of the current coding block and the width of the left neighboring block adjacent to the current coding block is smaller than the width of the current coding block, the encoding device may predict that the intra-frame prediction mode of the left neighboring block is different from the intra-frame prediction mode of the current coding block. Optionally, when the intra-frame prediction mode of the neighboring block adjacent to the left side of the current coding block is one of the horizontally oriented prediction modes, the encoding device may predict that the intra-frame prediction mode of the left neighboring block is different from the intra-frame prediction mode of the current coding block.

[0649] In this case, the encoding device may consider deriving additional MPM candidates from at least one of the blocks adjacent to the current coding block (i.e., the top neighboring block, the upper left neighboring block, the upper right neighboring block, and the lower left neighboring block). Alternatively, the encoding device may derive additional MPM candidates from blocks adjacent to the neighboring blocks but not adjacent to the current coding block. For example, in Fig.46 In the embodiment shown in , the encoding device may derive the MPM candidate based on the second left block (i.e., the second left neighboring block) that replaces the block adjacent to the left side of the current encoding block (i.e., the first left neighboring block) or the block located farther in the left direction. Alternatively, the encoding device may consider the MPM candidate using only the intra prediction mode of the neighboring blocks in a specific direction other than the left direction.

[0650] When determining the MPM candidate of the current coding block, it can be determined whether there is an MPM candidate that is the same as the intra-frame prediction mode of the current coding block by comparing the intra-frame prediction mode of the current coding block with the MPM candidate. The encoding device can encode information indicating whether there is an MPM candidate that is the same as the intra-frame prediction mode of the current coding block based on the result of the determination (S4002). For example, when there is an MPM candidate that is the same as the intra-frame prediction mode of the current coding block, the information is encoded as true, and when there is no MPM candidate that is the same as the intra-frame prediction mode of the current coding block, the information is encoded as false.

[0651] When it is determined that there is an MPM candidate having the same intra prediction mode as the current coding block ( S4003 ), the encoding apparatus may encode index information specifying the MPM candidate having the same intra prediction mode as the current coding block among the MPM candidates ( S4004 ).

[0652] In addition, when it is determined that there is no MPM candidate identical to the intra-frame prediction mode of the current coding block (S4003), the encoding device may encode the optimal intra-frame prediction mode for the current coding block among the intra-frame prediction modes other than the intra-frame prediction mode set as the MPM candidate (S4005). Specifically, among all intra-frame prediction modes that can be used for the current coding block, after excluding the intra-frame prediction mode set as the MPM candidate, by allocating bits to represent the remaining intra-frame prediction modes, information corresponding to the intra-frame prediction mode of the current coding block among the remaining prediction modes may be encoded.

[0653] When encoding the remaining intra prediction modes when allocating bits, fixed bits may be allocated to represent the remaining intra prediction modes, but the remaining intra prediction modes may also be divided into N groups and the allocation bits may be set differently for each group. For example, when the number of intra prediction modes available in the current coding block is 67 and the number of MPM candidates is 6, the number of remaining intra prediction modes is 61. Here, when the remaining intra prediction modes are divided into two groups (A, B), 16 intra prediction modes may be allocated to group A and 45 intra prediction modes may be allocated to group B. Here, flag information indicating which group the intra prediction mode of the current coding block belongs to may be encoded. For group A, 4 bits may be allocated to encode the intra-frame prediction information of the current coding block, for group B, group B may be further divided into two subgroups (B-1, B-2), 19 intra-frame prediction modes may be allocated to group B-1, 26 intra-frame prediction modes may be allocated to group B-2, 5 bits may be allocated to group B-1, and 6 bits may be allocated to group B-2 to encode the intra-frame prediction mode of the current coding block. The encoded information may be encoded and sent to a decoding device through a bit stream.

[0654] Next, a description will be given of decoding the intra prediction mode of the current decoding block in the decoding device.

[0655] Fig.47 is a flow chart showing a process of decoding an intra prediction mode of a current decoding block.

[0656] Reference Fig.47 , the decoding device may determine the MPM candidates of the current decoding block (S4701). As in the above encoding process, the decoding device may determine the MPM candidates of the current decoding block in consideration of the intra prediction modes of the neighboring blocks adjacent to the current decoding block.

[0657] Thereafter, the decoding apparatus may decode information indicating whether there is an MPM candidate having the same intra prediction mode as that of the current decoding block among the MPM candidates from the bitstream (S4702). The information may be a 1-bit flag, but is not limited thereto.

[0658] When it is determined that there is an ...

Claims

1. A method for decoding an image signal, comprising: receiving a bitstream comprising an encoded picture of an image signal; Obtaining coefficients of a current coding block in the coded picture from a bitstream; Obtaining a residual block of the current coding block by performing at least one of inverse quantization and inverse transformation on coefficients of the current coding block; deriving an intra prediction mode for a current coding block from intra prediction modes available for the current coding block in the coded picture; performing intra prediction based on the derived intra prediction mode to generate a prediction block for the current coding block; as well as Reconstruct the current coding block based on the prediction block and residual block of the current coding block. The current coding block is determined based on at least one of a quadtree partition and a binary tree partition, Among them, the intra prediction modes that can be used for the current coding block are divided into multiple groups. The number of the plurality of groups is an integer greater than or equal to 3. The step of deriving the intra prediction mode of the current coding block includes: Obtaining from a bitstream one or more flags specifying a group to which an intra prediction mode of a current coding block belongs among the plurality of groups; Determine, based on the one or more flags, a group to which the intra prediction mode of the current coding block belongs; and Derives the intra prediction mode of the current coding block based on the determined group, The maximum number of flags obtained for the current coding block is equal to a value obtained by subtracting one from the number of the plurality of groups, And wherein, one of the multiple groups has multiple most probable mode MPM candidates, and the multiple most probable mode MPM candidates include the intra-frame prediction mode of the neighboring blocks adjacent to the current coding block and the directional mode derived by adding or subtracting a predetermined offset to the intra-frame prediction mode of the neighboring blocks.

2. The method according to claim 1, wherein: One of the plurality of groups includes only five MPM candidates for intra prediction of a current coding block.

3. The method according to claim 2, wherein: The MPM candidate is derived based on an intra prediction mode of a neighboring block adjacent to the current coding block, and wherein the neighboring block includes at least one of a left neighboring block and an upper neighboring block of the current coding block.

4. The method according to claim 3, wherein: The upper neighboring block indicates the rightmost block among the upper neighboring blocks adjacent to the current coding block.

5. The method according to claim 3, wherein: The left neighboring block indicates the lowest block among the left neighboring blocks adjacent to the current coding block.

6. A method for encoding an image signal, comprising: A screen for receiving an image signal; performing intra prediction based on an intra prediction mode to generate a prediction block for a current coding block in the picture; generating a residual block including residual data of the current coding block based on the original block and the prediction block of the current coding block; as well as encoding the residual block by performing at least one of transforming and quantizing residual data of the residual block, The current coding block is determined based on at least one of a quadtree partition and a binary tree partition, The intra-frame prediction mode is one of the intra-frame prediction modes that can be used for the current coding block. Among them, the intra prediction modes that can be used for the current coding block are divided into multiple groups. The number of the plurality of groups is an integer greater than or equal to 3. wherein determining the group to which the intra prediction mode of the current coding block belongs among the multiple groups, wherein one or more flags specifying a group to which the intra prediction mode of the current coding block belongs among the plurality of groups are encoded, The maximum number of flags encoded for the current coding block is equal to a value obtained by subtracting one from the number of the plurality of groups. And wherein, one of the multiple groups has multiple most probable mode MPM candidates, and the multiple most probable mode MPM candidates include the intra-frame prediction mode of the neighboring blocks adjacent to the current coding block and the directional mode derived by adding or subtracting a predetermined offset to the intra-frame prediction mode of the neighboring blocks.

7. The method according to claim 6, wherein: One of the plurality of groups includes only five MPM candidates for intra prediction of a current coding block.

8. The method according to claim 7, wherein: The MPM candidate is derived based on an intra prediction mode of a neighboring block adjacent to the current coding block, and wherein the neighboring block includes at least one of a left neighboring block and an upper neighboring block of the current coding block.

9. The method according to claim 8, wherein: The upper neighboring block indicates the rightmost block among the upper neighboring blocks adjacent to the current coding block.

10. The method according to claim 8, wherein: The left neighboring block indicates the lowest block among the left neighboring blocks adjacent to the current coding block.

11. A method for sending a bit stream, comprising: A screen for receiving an image signal; performing intra prediction based on an intra prediction mode to generate a prediction block for a current coding block in the picture; generating a residual block including residual data of the current coding block based on the original block and the prediction block of the current coding block; encoding the residual block by performing at least one of transformation and quantization on residual data of the residual block to generate a bitstream; as well as Send bitstream, The current coding block is determined based on at least one of a quadtree partition and a binary tree partition, The intra-frame prediction mode is one of the intra-frame prediction modes that can be used for the current coding block. Among them, the intra prediction modes that can be used for the current coding block are divided into multiple groups. The number of the plurality of groups is an integer greater than or equal to 3. wherein determining the group to which the intra prediction mode of the current coding block belongs among the multiple groups, wherein one or more flags specifying a group to which the intra prediction mode of the current coding block belongs among the plurality of groups are encoded, The maximum number of flags encoded for the current coding block is equal to a value obtained by subtracting one from the number of the plurality of groups. And wherein, one of the multiple groups has multiple most probable mode MPM candidates, and the multiple most probable mode MPM candidates include the intra-frame prediction mode of the neighboring blocks adjacent to the current coding block and the directional mode derived by adding or subtracting a predetermined offset to the intra-frame prediction mode of the neighboring blocks.

12. The method according to claim 11, wherein: One of the plurality of groups includes only five MPM candidates for intra prediction of a current coding block.

13. The method according to claim 12, wherein: The MPM candidate is derived based on an intra prediction mode of a neighboring block adjacent to the current coding block, and wherein the neighboring block includes at least one of a left neighboring block and an upper neighboring block of the current coding block.

14. The method according to claim 13, wherein: The upper neighboring block indicates the rightmost block among the upper neighboring blocks adjacent to the current coding block.

15. The method according to claim 13, wherein: The left neighboring block indicates the lowest block among the left neighboring blocks adjacent to the current coding block.

Citation Information

Patent Citations

  • Method of encoding intra mode by choosing most probable mode with high hit rate and apparatus for the same, and method of decoding and apparatus for the same

    KR1020130068479A

  • Method and an apparatus for coding an intra prediction mode

    WO2013074042A1