A method, implemented by an encoding device or a decoding device, for bi-directional optical flow prediction based on sample values from sample positions belonging to extended regions of predicted blocks used in the bi-directional optical flow prediction of a current block, the method comprising: obtaining a first motion vector, MV, of the current block relative to a first reference picture, wherein the first MV is a 1/16 th of a pixel accurate MV; obtaining a second MV of the current block relative to a second reference picture, wherein the second MV is a 1/16 th of a pixel accurate MV; obtaining a sub-pixel sample position in the extended region of the predicted block in the first reference picture based on the first MV, wherein the obtained sub-pixel sample position is pointed to by the first MV and includes a fractional part; obtaining a sub-pixel sample position in the extended region of the predicted block in the second reference picture based on the second MV, wherein the obtained sub-pixel sample position is pointed to by the second MV and includes a fractional part; processing the sub-pixel sample position obtained in the extended region of the predicted block in the first reference picture to obtain an integer pixel sample position in the first reference picture; processing the sub-pixel sample position obtained in the extended region of the predicted block in the second reference picture to obtain an integer pixel sample position in the second reference picture; performing bi-directional optical flow prediction by referring to a reference sample value at the obtained integer pixel sample position in the first reference picture and to a reference sample value at the obtained integer pixel sample position in the second reference picture; and characterized in that the processing the sub-pixel sample position obtained in the extended region of the predicted block in the first reference picture includes: rounding the obtained sub-pixel sample position separately in a horizontal direction and a vertical direction to the respective closest integer pixel sample position in the respective direction, to obtain the integer pixel sample position in the first reference picture based on the closest integer pixel sample positions in the horizontal direction and the vertical direction; and the processing the sub-pixel sample position obtained in the extended region of the predicted block in the second reference picture includes: rounding the obtained sub-pixel sample position separately in a horizontal direction and a vertical direction to the respective closest integer pixel sample position in the respective direction, to obtain the integer pixel sample position in the second reference picture based on the closest integer pixel sample positions in the horizontal direction and the vertical direction. obtaining a first motion vector, MV, of the current block relative to a first reference picture, wherein the first MV is a 1/16 th of a pixel accurate MV; obtaining a second MV of the current block relative to a second reference picture, wherein the second MV is a 1/16 th of a pixel accurate MV; obtaining a sub-pixel sample position in the extended region of the predicted block in the first reference picture based on the first MV, wherein the obtained sub-pixel sample position is pointed to by the first MV and includes a fractional part; obtaining a sub-pixel sample position in the extended region of the predicted block in the second reference picture based on the second MV, wherein the obtained sub-pixel sample position is pointed to by the second MV and includes a fractional part; processing the sub-pixel sample position obtained in the extended region of the predicted block in the first reference picture to obtain an integer pixel sample position in the first reference picture; processing the sub-pixel sample position obtained in the extended region of the predicted block in the second reference picture to obtain an integer pixel sample position in the second reference picture; performing bi-directional optical flow prediction by referring to a reference sample value at the obtained integer pixel sample position in the first reference picture and to a reference sample value at the obtained integer pixel sample position in the second reference picture; and characterized in that the processing the sub-pixel sample position obtained in the extended region of the predicted block in the first reference picture includes: rounding the obtained sub-pixel sample position separately in a horizontal direction and a vertical direction to the respective closest integer pixel sample position in the respective direction, to obtain the integer pixel sample position in the first reference picture based on the closest integer pixel sample positions in the horizontal direction and the vertical direction; and the processing the sub-pixel sample position obtained in the extended region of the predicted block in the second reference picture includes: rounding the obtained sub-pixel sample position separately in a horizontal direction and a vertical direction to the respective closest integer pixel sample position in the respective direction, to obtain the integer pixel sample position in the second reference picture based on the closest integer pixel sample positions in the horizontal direction and the vertical direction.