diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index a1e038e583fd0fe4c988cf82313cf5ce3ce0fa79..60baedb47f3f777515e41966dc42120b6729b296 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -2125,7 +2125,7 @@ int mpeg4_decode_picture_header(MpegEncContext * s)
             break;
         }
         state = ((state << 8) | v) & 0xffffff;
-        if( get_bits_count(&s->gb) > s->gb.size*8){
+        if( get_bits_count(&s->gb) > s->gb.size*8-32){
             printf("no VOP startcode found\n");
             return -1;
         }