diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index 3f4a677bb3868f0081210c9a9e27f1ff16ef0db3..6e489a6f35ebb5c0b231a60c78373ecf2f376c3a 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -27,12 +27,14 @@ do_streamed_images()
 
 do_image_formats()
 {
-    file=${outfile}lavf%02d.$1
+    outfile="$datadir/images/$1/"
+    mkdir -p "$outfile"
+    file=${outfile}%02d.$1
     $echov $ffmpeg -t 0.5 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $2 $3 -flags +bitexact -sws_flags +accurate_rnd+bitexact $target_path/$file
     $ffmpeg -t 0.5 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $2 $3 -flags +bitexact -sws_flags +accurate_rnd+bitexact $target_path/$file
-    do_md5sum ${outfile}lavf02.$1 >> $logfile
+    do_md5sum ${outfile}02.$1 >> $logfile
     do_ffmpeg_crc $file $3 -i $target_path/$file
-    wc -c ${outfile}lavf02.$1 >> $logfile
+    wc -c ${outfile}02.$1 >> $logfile
 }
 
 do_audio_only()
diff --git a/tests/ref/lavf/bmp b/tests/ref/lavf/bmp
index 72cd57ae69df6554caba2c1cdee87c49e1be3bb9..8958855eee53b98b675bface25ad96bcd03697d8 100644
--- a/tests/ref/lavf/bmp
+++ b/tests/ref/lavf/bmp
@@ -1,3 +1,3 @@
-71f4d64a6b3c71f43a4eff526f84841c *./tests/data/lavf/lavf02.bmp
-./tests/data/lavf/lavf%02d.bmp CRC=0xe6c71946
-304182 ./tests/data/lavf/lavf02.bmp
+71f4d64a6b3c71f43a4eff526f84841c *./tests/data/images/bmp/02.bmp
+./tests/data/images/bmp/%02d.bmp CRC=0xe6c71946
+304182 ./tests/data/images/bmp/02.bmp
diff --git a/tests/ref/lavf/jpg b/tests/ref/lavf/jpg
index b924f4461c94e899e0ea05475a5f29355df1a17d..8b2ab409c7a88de80747f4d28925f4bc53c65ec2 100644
--- a/tests/ref/lavf/jpg
+++ b/tests/ref/lavf/jpg
@@ -1,3 +1,3 @@
-d56c19d41e9754939ea0f15d09bc4a32 *./tests/data/lavf/lavf02.jpg
-./tests/data/lavf/lavf%02d.jpg CRC=0xb8bc5a32
-31763 ./tests/data/lavf/lavf02.jpg
+d56c19d41e9754939ea0f15d09bc4a32 *./tests/data/images/jpg/02.jpg
+./tests/data/images/jpg/%02d.jpg CRC=0xb8bc5a32
+31763 ./tests/data/images/jpg/02.jpg
diff --git a/tests/ref/lavf/pcx b/tests/ref/lavf/pcx
index 491c16dd5c936f870301aed29ba38a90af9bf1bf..bdb2204c42e6a8b7b872b46d9a6f6afeba3e7279 100644
--- a/tests/ref/lavf/pcx
+++ b/tests/ref/lavf/pcx
@@ -1,3 +1,3 @@
-2df1d747fba23d03b6ff9c91b8b465c9 *./tests/data/lavf/lavf02.pcx
-./tests/data/lavf/lavf%02d.pcx CRC=0x6da01946
-364147 ./tests/data/lavf/lavf02.pcx
+2df1d747fba23d03b6ff9c91b8b465c9 *./tests/data/images/pcx/02.pcx
+./tests/data/images/pcx/%02d.pcx CRC=0x6da01946
+364147 ./tests/data/images/pcx/02.pcx
diff --git a/tests/ref/lavf/pgm b/tests/ref/lavf/pgm
index 420e6c487469e22089df43c0f7b2891bc611075d..4043f7a118e71878404d23d5133648c0cdff52c8 100644
--- a/tests/ref/lavf/pgm
+++ b/tests/ref/lavf/pgm
@@ -1,3 +1,3 @@
-388f5c51a678ca6a52cc006095c12f08 *./tests/data/lavf/lavf02.pgm
-./tests/data/lavf/lavf%02d.pgm CRC=0x418d2963
-101391 ./tests/data/lavf/lavf02.pgm
+388f5c51a678ca6a52cc006095c12f08 *./tests/data/images/pgm/02.pgm
+./tests/data/images/pgm/%02d.pgm CRC=0x418d2963
+101391 ./tests/data/images/pgm/02.pgm
diff --git a/tests/ref/lavf/ppm b/tests/ref/lavf/ppm
index 26a1250f65fd80323131a84e0f8bed8b6a0b0b22..97093aaac588b7197988220422e50afc17bca30e 100644
--- a/tests/ref/lavf/ppm
+++ b/tests/ref/lavf/ppm
@@ -1,3 +1,3 @@
-16d5dadf0b362fc8ba3cb676c5dde985 *./tests/data/lavf/lavf02.ppm
-./tests/data/lavf/lavf%02d.ppm CRC=0x6da01946
-304143 ./tests/data/lavf/lavf02.ppm
+16d5dadf0b362fc8ba3cb676c5dde985 *./tests/data/images/ppm/02.ppm
+./tests/data/images/ppm/%02d.ppm CRC=0x6da01946
+304143 ./tests/data/images/ppm/02.ppm
diff --git a/tests/ref/lavf/sgi b/tests/ref/lavf/sgi
index 402f6f017caf717775c5d5afc9847d74d90fb689..a43c1f42871dda0f30dca5c8130d618ac3dbdbde 100644
--- a/tests/ref/lavf/sgi
+++ b/tests/ref/lavf/sgi
@@ -1,3 +1,3 @@
-7054acafd275e51cec28d4518e213081 *./tests/data/lavf/lavf02.sgi
-./tests/data/lavf/lavf%02d.sgi CRC=0x6da01946
-308151 ./tests/data/lavf/lavf02.sgi
+7054acafd275e51cec28d4518e213081 *./tests/data/images/sgi/02.sgi
+./tests/data/images/sgi/%02d.sgi CRC=0x6da01946
+308151 ./tests/data/images/sgi/02.sgi
diff --git a/tests/ref/lavf/tga b/tests/ref/lavf/tga
index 75849c9bde9fb86399d6263af305fcba2d581a28..7efaf978283e159f12334c7a7c68ba4e6a12b04e 100644
--- a/tests/ref/lavf/tga
+++ b/tests/ref/lavf/tga
@@ -1,3 +1,3 @@
-c0305c53e6d79d4ed9f35f04f671246c *./tests/data/lavf/lavf02.tga
-./tests/data/lavf/lavf%02d.tga CRC=0xe6c71946
-304172 ./tests/data/lavf/lavf02.tga
+c0305c53e6d79d4ed9f35f04f671246c *./tests/data/images/tga/02.tga
+./tests/data/images/tga/%02d.tga CRC=0xe6c71946
+304172 ./tests/data/images/tga/02.tga
diff --git a/tests/ref/lavf/tiff b/tests/ref/lavf/tiff
index 082c7434e1256eb763e4e1633fdd023c3a3dbbfc..4b0b985f76f0d0f5a82619ca76cfb3d2aa827d54 100644
--- a/tests/ref/lavf/tiff
+++ b/tests/ref/lavf/tiff
@@ -1,3 +1,3 @@
-b3299346a8959553a437e486d8f3bf76 *./tests/data/lavf/lavf02.tiff
-./tests/data/lavf/lavf%02d.tiff CRC=0x6da01946
-307131 ./tests/data/lavf/lavf02.tiff
+b3299346a8959553a437e486d8f3bf76 *./tests/data/images/tiff/02.tiff
+./tests/data/images/tiff/%02d.tiff CRC=0x6da01946
+307131 ./tests/data/images/tiff/02.tiff