  Conventional video compression (VC) methods are based on motion compensated
transform coding, and the steps of motion estimation, mode and quantization
parameter selection, and entropy coding are optimized individually due to the
combinatorial nature of the end-to-end optimization problem. Learned VC allows
end-to-end rate-distortion (R-D) optimized training of nonlinear transform,
motion and entropy model simultaneously. Most works on learned VC consider
end-to-end optimization of a sequential video codec based on R-D loss averaged
over pairs of successive frames. It is well-known in conventional VC that
hierarchical, bi-directional coding outperforms sequential compression because
of its ability to use both past and future reference frames. This paper
proposes a learned hierarchical bi-directional video codec (LHBDC) that
combines the benefits of hierarchical motion-compensated prediction and
end-to-end optimization. Experimental results show that we achieve the best R-D
results that are reported for learned VC schemes to date in both PSNR and
MS-SSIM. Compared to conventional video codecs, the R-D performance of our
end-to-end optimized codec outperforms those of both x265 and SVT-HEVC encoders
("veryslow" preset) in PSNR and MS-SSIM as well as HM 16.23 reference software
in MS-SSIM. We present ablation studies showing performance gains due to
proposed novel tools such as learned masking, flow-field subsampling, and
temporal flow vector prediction. The models and instructions to reproduce our
results can be found in https://github.com/makinyilmaz/LHBDC/
