An order of scanning the adjacent samples 2410 may be determined based on whether adjacent blocks of the current block 2420 are decoded. When a left block of the current block 2400 is decoded, the neighboring samples 2410 are scanned from a lower left adjacent sample to an upper left adjacent sample of the current block 2400 in an upward direction, from the upper left adjacent sample to an upper right adjacent sample of the current block 2400 in a right direction, and from the upper right adjacent sample to a lower right adjacent sample of the current block 2400 in a downward direction. On the other hand, when the left block of the current block 2400 is not decoded and a right block is decoded, the neighboring samples 2410 are scanned from the lower right adjacent sample to the upper right adjacent sample of the current block 2400 in an upward direction, from the upper right adjacent sample to the upper left adjacent sample of the current block 2400 in a left direction, and from the upper left adjacent sample to the lower left adjacent sample of the current block 2400 in a downward direction.
Also, when a prediction mode of the current block 2400 is an affine merge mode, the processor 1710 may obtain a reference picture index indicating a reference picture from the decoded adjacent block 2420.