When a reference line is unavailable, a reference line at a corresponding position may be excluded from a reference region. Alternatively, an unavailable reference line may be substituted by using an available reference line. Herein, an available reference line may include a peripheral sample of an unavailable reference line, a peripheral sample of a current block, etc. Herein, a peripheral sample may mean a sample neighboring at least one of a left, right, top, bottom or diagonal direction.
In reference to 
A second candidate group may be determined by an operation which subtracts/adds a predetermined value of m from/to a MPM (embodiment 1). The operation may be performed for a plurality of MPM, respectively. It may be restricted so that the operation is not performed for a planar mode or a DC mode among the MPM. Herein, a value of m may be an integer such as 2, 3, 4, or more. The value of m may be greater than a value of n mentioned in 
The above-described subtraction/addition operation may be performed based on a result of comparison between a mode value of a MPM and a base mode value. A base mode value may mean mode 2, mode 18 (a horizontal mode), mode 34 (a diagonal mode), mode 50 (a vertical mode) or mode 66. In this description, mode A may mean an intra prediction mode having a mode value of A.