Method for encoding/decoding image using bi-directional optical flow prediction
An image encoding/decoding method is disclosed. An image decoding method of the present invention may comprises determining step for determining whether or not to derive second motion information when a current block includes first motion information only and for which bi-directional prediction is available, a deriving step for deriving the second motion information based on the first motion information, and a predicting step for generating a prediction block of the current block by performing BIO prediction based on the first motion information and the second motion information.
1 . A method of decoding an image, the method comprising:
dividing a current block to acquire a subblock of the current block;
determining whether to perform a subblock based BI-DIRECTIONAL OPTICAL FLOW (BIO) prediction on the subblock;
deriving a first direction prediction sample and a second direction prediction sample of the subblock;
deriving a BIO offset of the subblock;
generating a final prediction sample of the subblock block using the first direction prediction sample, the second direction prediction sample and the BIO offset; and
generating a reconstructed sample of the current block based on the final prediction sample,
wherein whether to perform the subblock based BIO prediction determines based on a result of comparing a threshold value and a difference between the first direction prediction sample and the second direction prediction sample,
wherein the threshold value is set using on a size of the current block,
wherein the deriving a BIO offset comprising:
deriving a gradient using neighboring samples;
deriving a motion refining vector; and
deriving the BIO offset based on the gradient and the motion refining vector,
wherein the gradient is, when a position of the neighboring sample is a subpixel position, derived by rounding to an integer pixel position close to the subpixel position.
2 . A method of encoding an image, the method comprising:
dividing a current block to acquire a subblock of the current block;
determining whether to perform a subblock based BI-DIRECTIONAL OPTICAL FLOW (BIO) prediction on the subblock;
deriving a first direction prediction sample and a second direction prediction sample of the subblock;
deriving a BIO offset of the subblock; and
generating a final prediction sample of the subblock using the first direction prediction sample, the second direction prediction sample and the BIO offset, and
encoding a bitstream based on the final prediction sample,
wherein whether to perform the subblock based BIO prediction determines based on a result of comparing a threshold value and a difference between the first direction prediction sample and the second direction prediction sample,
wherein the threshold value is set using on a size of the current block,
wherein the deriving a BIO offset comprising:
deriving a gradient using neighboring samples;
deriving a motion refining vector; and
deriving the BIO offset based on the gradient and the motion refining vector,
wherein the gradient is, when a position of the neighboring sample is a subpixel position, derived by rounding to an integer pixel position close to the subpixel position.
3 . A non-transitory computer-readable recording medium storing instructions, which when executed by at least one processor perform a method for generating and transmitting a bitstream including encoded video data the method comprising:
dividing a current block to acquire a subblock of the current block;
determining whether to perform a subblock based BI-DIRECTIONAL OPTICAL FLOW (BIO) prediction on the subblock;
deriving a first direction prediction sample and a second direction prediction sample of the subblock;
deriving a BIO offset of the subblock; and
generating a final prediction sample of the subblock using the first direction prediction sample, the second direction prediction sample and the BIO offset; and
encoding the bitstream based on the final prediction sample,
wherein whether to perform the subblock based BIO prediction in units of subblock determines based on a result of comparing a threshold value and a difference between the first direction prediction sample and the second direction prediction sample,
wherein the threshold value is set using on a size of the current block,
wherein the deriving a BIO offset comprising:
deriving a gradient using neighboring samples;
deriving a motion refining vector; and
deriving the BIO offset based on the gradient and the motion refining vector,
wherein the gradient is, when a position of the neighboring sample is a subpixel position, derived by rounding to an integer pixel position close to the subpixel position.