diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3f6b7d9b5eb963d533df45fc83ad57f2acf9d58b..d4ab49f119b048cb22bc29fd506629584026cc88 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -792,7 +792,8 @@ static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
         if (ofs <= 14) {
             layout[ofs++] = code;
             layout[ofs++] = value;
-        }
+        } else
+            break;  /* don't read byte by byte on sneaky files filled with lots of non-zeroes */
     } while (code != 0); /* SMPTE 377M E.2.46 */
 
     ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt);