A method for bi-directional optical flow, BDOF, based inter prediction for a current block of a video signal, comprising: determining a horizontal motion offset v x and a vertical motion offset v y of the current block, and wherein the vertical motion offset is derived based on the horizontal motion offset, a second variable s 2, a fourth variable s 4 and a fifth variable s 5, wherein: the fifth variable s 5 indicates a sum of a plurality of first terms, wherein each of the plurality of first terms is obtained from a sign of an element of a second matrix and an element of a first matrix, and the element of the first matrix corresponds to the element of the second matrix; wherein each element of the first matrix is obtained from a sum of a first horizontal predicted sample gradient that corresponds to a first reference frame of the current block and a second horizontal predicted sample gradient that corresponds to a second reference frame of the current block, wherein the first horizontal predicted sample gradient and the second horizontal predicted sample gradient correspond to the element of the first matrix; and each element of the second matrix is obtained from a sum of a first vertical predicted sample gradient that corresponds to the first reference frame of the current block and a second vertical predicted sample gradient that corresponds to the second reference frame of the current block, wherein the first vertical predicted sample gradient and the second vertical predicted sample gradient correspond to the element of the second matrix; and wherein: the second variable s 2 indicates a sum of absolute values of elements of the second matrix; and the fourth variable s 4 indicates a sum of a plurality of second terms, wherein each of the plurality of second terms is obtained from a sign of an element of the second matrix and an element of a third matrix, and the element of the third matrix corresponds to the element of the second matrix, and each element of the third matrix is a difference which is obtained from a first predicted sample of the first reference frame that corresponds to the element of the third matrix and a second predicted sample of the second reference frame that corresponds to the element of the third matrix; wherein the horizontal motion offset is derived based on a first variable s 1 and a third variable s 3; the first variable s 1 indicates a sum of absolute values of elements of the first matrix; and the third variable s 3 indicates a sum of a plurality of third terms, wherein each of the plurality of third terms is obtained from a sign of an element of the first matrix and an element of the third matrix, and the element of the third matrix corresponds to the element of the first matrix; and wherein the method further comprises determining prediction sample values in the current block using prediction sample values corresponding to the first reference frame, prediction sample values corresponding to the second reference frame, the horizontal motion offset, and the vertical motion offset. the fifth variable s 5 indicates a sum of a plurality of first terms, wherein each of the plurality of first terms is obtained from a sign of an element of a second matrix and an element of a first matrix, and the element of the first matrix corresponds to the element of the second matrix; wherein each element of the first matrix is obtained from a sum of a first horizontal predicted sample gradient that corresponds to a first reference frame of the current block and a second horizontal predicted sample gradient that corresponds to a second reference frame of the current block, wherein the first horizontal predicted sample gradient and the second horizontal predicted sample gradient correspond to the element of the first matrix; and each element of the second matrix is obtained from a sum of a first vertical predicted sample gradient that corresponds to the first reference frame of the current block and a second vertical predicted sample gradient that corresponds to the second reference frame of the current block, wherein the first vertical predicted sample gradient and the second vertical predicted sample gradient correspond to the element of the second matrix; and the second variable s 2 indicates a sum of absolute values of elements of the second matrix; and the fourth variable s 4 indicates a sum of a plurality of second terms, wherein each of the plurality of second terms is obtained from a sign of an element of the second matrix and an element of a third matrix, and the element of the third matrix corresponds to the element of the second matrix, and each element of the third matrix is a difference which is obtained from a first predicted sample of the first reference frame that corresponds to the element of the third matrix and a second predicted sample of the second reference frame that corresponds to the element of the third matrix; the horizontal motion offset is derived based on a first variable s 1 and a third variable s 3; the first variable s 1 indicates a sum of absolute values of elements of the first matrix; and the third variable s 3 indicates a sum of a plurality of third terms, wherein each of the plurality of third terms is obtained from a sign of an element of the first matrix and an element of the third matrix, and the element of the third matrix corresponds to the element of the first matrix; and