A method of decoding an encoded video sequence including a plurality of images, with each image of the plurality of images including a plurality of blocks, the method comprising: providing first and second blocks of an image of the encoded video sequence, wherein the first and second blocks are adjacent blocks of the image; defining a line of pixels (p0 to p7, q0 to q7) extending across a boundary between the first and second blocks wherein the line of pixels includes a first plurality of pixels (p0-p7) of the first block and a second plurality of pixels (q0-q7) of the second block; calculating a first reference value, refP, based on a first pixel from the first plurality of pixels that is most distant from the boundary; calculating a second reference value, refQ, based on a second pixel from the second plurality of pixels that is most distant from the boundary; calculating a third reference value, refMiddle, based on a third pixel and a fourth pixel from the line of pixels (p0 to p7, q0 to q7), wherein the third pixel is in the line between the first pixel and the fourth pixel and wherein the fourth pixel is in the line between the third pixel and the second pixel, wherein the third pixel and the fourth pixel are closest to the boundary and wherein the third reference value, refMiddle, is positioned on the boundary; calculating filtered pixel values (p0' to p6', q0' to q6') for each pixel of the line of pixels between the first pixel and the second pixel using interpolation based on at least one of the first reference value, refP, and the second reference value, refQ, wherein calculating the filtered pixel values for the pixels in the line between the first pixel and the third reference value, refMiddle, is based on interpolation between the first reference value, refP, and the third reference value, refMiddle, and calculating the filtered pixel values for the pixels in the line between the second pixel and the third reference value, refMiddle, is based on interpolation between the second reference value, refQ, and the third reference value, refMiddle; generating first and second filtered blocks corresponding to the first and second blocks using the filtered pixel values (p0' to p6', q0' to q6'); and generating a decoded video sequence including a decoded image based on the first and second filtered blocks. providing first and second blocks of an image of the encoded video sequence, wherein the first and second blocks are adjacent blocks of the image; defining a line of pixels (p0 to p7, q0 to q7) extending across a boundary between the first and second blocks wherein the line of pixels includes a first plurality of pixels (p0-p7) of the first block and a second plurality of pixels (q0-q7) of the second block; calculating a first reference value, refP, based on a first pixel from the first plurality of pixels that is most distant from the boundary; calculating a second reference value, refQ, based on a second pixel from the second plurality of pixels that is most distant from the boundary; calculating a third reference value, refMiddle, based on a third pixel and a fourth pixel from the line of pixels (p0 to p7, q0 to q7), wherein the third pixel is in the line between the first pixel and the fourth pixel and wherein the fourth pixel is in the line between the third pixel and the second pixel, wherein the third pixel and the fourth pixel are closest to the boundary and wherein the third reference value, refMiddle, is positioned on the boundary; calculating filtered pixel values (p0' to p6', q0' to q6') for each pixel of the line of pixels between the first pixel and the second pixel using interpolation based on at least one of the first reference value, refP, and the second reference value, refQ, wherein calculating the filtered pixel values for the pixels in the line between the first pixel and the third reference value, refMiddle, is based on interpolation between the first reference value, refP, and the third reference value, refMiddle, and calculating the filtered pixel values for the pixels in the line between the second pixel and the third reference value, refMiddle, is based on interpolation between the second reference value, refQ, and the third reference value, refMiddle; generating first and second filtered blocks corresponding to the first and second blocks using the filtered pixel values (p0' to p6', q0' to q6'); and generating a decoded video sequence including a decoded image based on the first and second filtered blocks.