diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index e931c768428d45c6cd861c21cf1bf2f4f8d0c617..fe071402ab47237924068b96a820d17c56ae0100 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -301,7 +301,8 @@ static int request_frame(AVFilterLink *outlink)
 {
     MPTestContext *test = outlink->src->priv;
     AVFrame *picref;
-    int w = WIDTH, h = HEIGHT, cw = w>>test->hsub, ch = h>>test->vsub;
+    int w = WIDTH, h = HEIGHT,
+        cw = FF_CEIL_RSHIFT(w, test->hsub), ch = FF_CEIL_RSHIFT(h, test->vsub);
     unsigned int frame = test->frame_nb;
     enum test_type tt = test->test;
     int i;