[FFmpeg-cvslog] Merge commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196'

Clément Bœsch git at videolan.org
Wed Jun 22 13:47:20 CEST 2016


ffmpeg | branch: master | Clément Bœsch <clement at stupeflix.com> | Wed Jun 22 13:44:29 2016 +0200| [5d48e4eafa6c4559683892b8638d10508125f3cf] | committer: Clément Bœsch

Merge commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196'

* commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196':
  tests: Move all test programs to a subdirectory

Merged-by: Clément Bœsch <clement at stupeflix.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d48e4eafa6c4559683892b8638d10508125f3cf
---

 .gitignore                                         |    1 -
 common.mak                                         |    7 +-
 libavcodec/Makefile                                |    2 +-
 libavcodec/tests/.gitignore                        |   16 +++
 libavcodec/{arm/dct-test.c => tests/arm/dct.c}     |    2 +-
 libavcodec/{avfft-test.c => tests/avfft.c}         |    2 +-
 libavcodec/{cabac-test.c => tests/cabac.c}         |    4 +-
 libavcodec/{dct-test.c => tests/dct.c}             |   23 ++--
 libavcodec/{fft-fixed-test.c => tests/fft-fixed.c} |    2 +-
 .../{fft-fixed32-test.c => tests/fft-fixed32.c}    |    2 +-
 libavcodec/{fft-test.c => tests/fft.c}             |    6 +-
 libavcodec/{golomb-test.c => tests/golomb.c}       |    6 +-
 libavcodec/{iirfilter-test.c => tests/iirfilter.c} |    2 +-
 .../{imgconvert-test.c => tests/imgconvert.c}      |    2 +-
 .../{jpeg2000dwt-test.c => tests/jpeg2000dwt.c}    |    2 +-
 libavcodec/{mathops-test.c => tests/mathops.c}     |    2 +-
 libavcodec/{motion-test.c => tests/motion.c}       |    2 +-
 libavcodec/{options-test.c => tests/options.c}     |    2 +-
 libavcodec/{ppc/dct-test.c => tests/ppc/dct.c}     |    2 +-
 .../{rangecoder-test.c => tests/rangecoder.c}      |    2 +-
 libavcodec/{snowenc-test.c => tests/snowenc.c}     |    2 +-
 libavcodec/{utils-test.c => tests/utils.c}         |    2 +-
 libavcodec/{x86/dct-test.c => tests/x86/dct.c}     |    6 +-
 libavdevice/tests/.gitignore                       |    1 +
 .../{timefilter-test.c => tests/timefilter.c}      |    2 +-
 libavfilter/tests/.gitignore                       |    3 +
 .../{drawutils-test.c => tests/drawutils.c}        |    2 +-
 libavfilter/{filtfmts-test.c => tests/filtfmts.c}  |    0
 libavfilter/{formats-test.c => tests/formats.c}    |    2 +-
 libavformat/matroskaenc.c                          |   21 ++--
 libavformat/tests/.gitignore                       |    6 +
 libavformat/{movenc-test.c => tests/movenc.c}      |    2 +-
 libavformat/{noproxy-test.c => tests/noproxy.c}    |    2 +-
 libavformat/{rtmpdh-test.c => tests/rtmpdh.c}      |    2 +-
 libavformat/{seek-test.c => tests/seek.c}          |    1 +
 libavformat/{srtp-test.c => tests/srtp.c}          |    4 +-
 libavformat/{url-test.c => tests/url.c}            |    2 +-
 libavresample/tests/.gitignore                     |    1 +
 .../{avresample-test.c => tests/avresample.c}      |    3 +-
 libavutil/Makefile                                 |    2 +-
 libavutil/des.c                                    |    2 +-
 libavutil/tests/.gitignore                         |   44 +++++++
 libavutil/{adler32-test.c => tests/adler32.c}      |    6 +-
 libavutil/{aes-test.c => tests/aes.c}              |    8 +-
 libavutil/{atomic-test.c => tests/atomic.c}        |    4 +-
 libavutil/{avstring-test.c => tests/avstring.c}    |    6 +-
 libavutil/{base64-test.c => tests/base64.c}        |    6 +-
 libavutil/{blowfish-test.c => tests/blowfish.c}    |    2 +-
 libavutil/{bprint-test.c => tests/bprint.c}        |    2 +-
 libavutil/{camellia-test.c => tests/camellia.c}    |    4 +-
 libavutil/{cast5-test.c => tests/cast5.c}          |    4 +-
 .../{color_utils-test.c => tests/color_utils.c}    |    2 +-
 libavutil/{cpu-test.c => tests/cpu.c}              |    5 +-
 libavutil/{crc-test.c => tests/crc.c}              |    2 +-
 libavutil/{des-test.c => tests/des.c}              |    4 +-
 libavutil/{dict-test.c => tests/dict.c}            |    2 +-
 libavutil/{display-test.c => tests/display.c}      |    2 +-
 libavutil/{error-test.c => tests/error.c}          |    2 +-
 libavutil/{eval-test.c => tests/eval.c}            |    6 +-
 libavutil/{fifo-test.c => tests/fifo.c}            |    2 +-
 libavutil/{file-test.c => tests/file.c}            |    2 +-
 libavutil/{float_dsp-test.c => tests/float_dsp.c}  |   14 +--
 libavutil/{hash-test.c => tests/hash.c}            |    2 +-
 libavutil/{hmac-test.c => tests/hmac.c}            |    2 +-
 libavutil/{lfg-test.c => tests/lfg.c}              |    6 +-
 libavutil/{lls-test.c => tests/lls.c}              |    6 +-
 libavutil/{log-test.c => tests/log.c}              |    2 +-
 libavutil/{lzo-test.c => tests/lzo.c}              |    8 +-
 libavutil/{md5-test.c => tests/md5.c}              |    2 +-
 libavutil/{murmur3-test.c => tests/murmur3.c}      |    6 +-
 libavutil/{opt-test.c => tests/opt.c}              |   16 +--
 .../{parseutils-test.c => tests/parseutils.c}      |    8 +-
 libavutil/{pca-test.c => tests/pca.c}              |    4 +-
 libavutil/{pixdesc-test.c => tests/pixdesc.c}      |    2 +-
 .../{pixelutils-test.c => tests/pixelutils.c}      |    2 +-
 .../{random_seed-test.c => tests/random_seed.c}    |    2 +-
 libavutil/{rational-test.c => tests/rational.c}    |    5 +-
 libavutil/{ripemd-test.c => tests/ripemd.c}        |    4 +-
 libavutil/{sha-test.c => tests/sha.c}              |    4 +-
 libavutil/{sha512-test.c => tests/sha512.c}        |    4 +-
 libavutil/{softfloat-test.c => tests/softfloat.c}  |    7 +-
 libavutil/{tea-test.c => tests/tea.c}              |    4 +-
 libavutil/{tree-test.c => tests/tree.c}            |    8 +-
 libavutil/{twofish-test.c => tests/twofish.c}      |    4 +-
 libavutil/{utf8-test.c => tests/utf8.c}            |    0
 libavutil/{xtea-test.c => tests/xtea.c}            |    4 +-
 library.mak                                        |    9 +-
 libswresample/tests/.gitignore                     |    1 +
 .../{swresample-test.c => tests/swresample.c}      |    3 +-
 libswscale/tests/.gitignore                        |    2 +
 .../{colorspace-test.c => tests/colorspace.c}      |    5 +-
 libswscale/{swscale-test.c => tests/swscale.c}     |    3 +-
 tests/fate-run.sh                                  |    2 +-
 tests/fate/fft.mak                                 |   16 +--
 tests/fate/filter-audio.mak                        |    4 +-
 tests/fate/filter-video.mak                        |    2 +-
 tests/fate/libavcodec.mak                          |   36 +++---
 tests/fate/libavdevice.mak                         |    4 +-
 tests/fate/libavformat.mak                         |   24 ++--
 tests/fate/libavutil.mak                           |  132 ++++++++++----------
 tests/fate/seek.mak                                |    8 +-
 101 files changed, 364 insertions(+), 285 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0eca7a1..2b251c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,6 @@
 *.so.*
 *.swp
 *.ver
-*-test
 *_g
 \#*
 .\#*
diff --git a/common.mak b/common.mak
index 700e4c1..59b039f 100644
--- a/common.mak
+++ b/common.mak
@@ -114,8 +114,8 @@ FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
 
 OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
 SLIBOBJS  := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
-TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
-TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
+TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
+TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
 HOSTOBJS  := $(HOSTPROGS:%=$(SUBDIR)%.o)
 HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
 TOOLS     += $(TOOLS-yes)
@@ -158,8 +158,7 @@ LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
 
 define RULES
 clean::
-	$(RM) $(HOSTPROGS)
-	$(RM) $(TOOLS)
+	$(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
 endef
 
 $(eval $(RULES))
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 91df1ac..7c3aa69 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1042,7 +1042,7 @@ HOSTPROGS = aacps_tablegen                                              \
 
 CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF)
 
-$(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o
+$(SUBDIR)tests/dct$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o
 $(SUBDIR)dv_tablegen$(HOSTEXESUF): $(SUBDIR)dvdata_host.o
 
 TRIG_TABLES  = cos cos_fixed sin
diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore
new file mode 100644
index 0000000..d8ab947
--- /dev/null
+++ b/libavcodec/tests/.gitignore
@@ -0,0 +1,16 @@
+/avfft
+/cabac
+/dct
+/fft
+/fft-fixed
+/fft-fixed32
+/golomb
+/iirfilter
+/imgconvert
+/jpeg2000dwt
+/mathops
+/motion
+/options
+/rangecoder
+/snowenc
+/utils
diff --git a/libavcodec/arm/dct-test.c b/libavcodec/tests/arm/dct.c
similarity index 97%
rename from libavcodec/arm/dct-test.c
rename to libavcodec/tests/arm/dct.c
index f9076b3..596d369 100644
--- a/libavcodec/arm/dct-test.c
+++ b/libavcodec/tests/arm/dct.c
@@ -18,7 +18,7 @@
 
 #include "config.h"
 
-#include "idct.h"
+#include "libavcodec/arm/idct.h"
 
 static const struct algo fdct_tab_arch[] = {
     { 0 }
diff --git a/libavcodec/avfft-test.c b/libavcodec/tests/avfft.c
similarity index 98%
rename from libavcodec/avfft-test.c
rename to libavcodec/tests/avfft.c
index c2d4cc4..6bc48ea 100644
--- a/libavcodec/avfft-test.c
+++ b/libavcodec/tests/avfft.c
@@ -18,7 +18,7 @@
 
 #include "config.h"
 #include "libavutil/mem.h"
-#include "avfft.h"
+#include "libavcodec/avfft.h"
 
 int main(int argc, char **argv)
 {
diff --git a/libavcodec/cabac-test.c b/libavcodec/tests/cabac.c
similarity index 98%
rename from libavcodec/cabac-test.c
rename to libavcodec/tests/cabac.c
index 47f31e9..affe4eb 100644
--- a/libavcodec/cabac-test.c
+++ b/libavcodec/tests/cabac.c
@@ -18,12 +18,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "cabac.c"
+#include "libavcodec/cabac.c"
 
 #define SIZE 10240
 
 #include "libavutil/lfg.h"
-#include "avcodec.h"
+#include "libavcodec/avcodec.h"
 
 static inline void put_cabac_bit(CABACContext *c, int b){
     put_bits(&c->pb, 1, b);
diff --git a/libavcodec/dct-test.c b/libavcodec/tests/dct.c
similarity index 97%
rename from libavcodec/dct-test.c
rename to libavcodec/tests/dct.c
index df1b75d..5303fdf 100644
--- a/libavcodec/dct-test.c
+++ b/libavcodec/tests/dct.c
@@ -36,17 +36,18 @@
 
 #include "libavutil/cpu.h"
 #include "libavutil/common.h"
+#include "libavutil/internal.h"
 #include "libavutil/lfg.h"
 #include "libavutil/time.h"
 
-#include "dct.h"
-#include "idctdsp.h"
-#include "simple_idct.h"
-#include "xvididct.h"
-#include "aandcttab.h"
-#include "faandct.h"
-#include "faanidct.h"
-#include "dctref.h"
+#include "libavcodec/dct.h"
+#include "libavcodec/idctdsp.h"
+#include "libavcodec/simple_idct.h"
+#include "libavcodec/xvididct.h"
+#include "libavcodec/aandcttab.h"
+#include "libavcodec/faandct.h"
+#include "libavcodec/faanidct.h"
+#include "libavcodec/dctref.h"
 
 struct algo {
     const char *name;
@@ -94,11 +95,11 @@ static const struct algo idct_tab[] = {
 };
 
 #if ARCH_ARM
-#include "arm/dct-test.c"
+#include "arm/dct.c"
 #elif ARCH_PPC
-#include "ppc/dct-test.c"
+#include "ppc/dct.c"
 #elif ARCH_X86
-#include "x86/dct-test.c"
+#include "x86/dct.c"
 #else
 static const struct algo fdct_tab_arch[] = { { 0 } };
 static const struct algo idct_tab_arch[] = { { 0 } };
diff --git a/libavcodec/fft-fixed-test.c b/libavcodec/tests/fft-fixed.c
similarity index 97%
rename from libavcodec/fft-fixed-test.c
rename to libavcodec/tests/fft-fixed.c
index 330211e..fe1b57a 100644
--- a/libavcodec/fft-fixed-test.c
+++ b/libavcodec/tests/fft-fixed.c
@@ -17,4 +17,4 @@
  */
 
 #define FFT_FLOAT 0
-#include "fft-test.c"
+#include "fft.c"
diff --git a/libavcodec/fft-fixed32-test.c b/libavcodec/tests/fft-fixed32.c
similarity index 97%
rename from libavcodec/fft-fixed32-test.c
rename to libavcodec/tests/fft-fixed32.c
index 4bd11ce..f33494f 100644
--- a/libavcodec/fft-fixed32-test.c
+++ b/libavcodec/tests/fft-fixed32.c
@@ -18,4 +18,4 @@
 
 #define FFT_FLOAT 0
 #define FFT_FIXED_32 1
-#include "fft-test.c"
+#include "fft.c"
diff --git a/libavcodec/fft-test.c b/libavcodec/tests/fft.c
similarity index 99%
rename from libavcodec/fft-test.c
rename to libavcodec/tests/fft.c
index d647fde..4717303 100644
--- a/libavcodec/fft-test.c
+++ b/libavcodec/tests/fft.c
@@ -39,10 +39,10 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/time.h"
 
-#include "fft.h"
+#include "libavcodec/fft.h"
 #if FFT_FLOAT
-#include "dct.h"
-#include "rdft.h"
+#include "libavcodec/dct.h"
+#include "libavcodec/rdft.h"
 #endif
 
 /* reference fft */
diff --git a/libavcodec/golomb-test.c b/libavcodec/tests/golomb.c
similarity index 96%
rename from libavcodec/golomb-test.c
rename to libavcodec/tests/golomb.c
index 2dfe917..965367b 100644
--- a/libavcodec/golomb-test.c
+++ b/libavcodec/tests/golomb.c
@@ -23,9 +23,9 @@
 
 #include "libavutil/mem.h"
 
-#include "get_bits.h"
-#include "golomb.h"
-#include "put_bits.h"
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/put_bits.h"
 
 #define COUNT 8191
 #define SIZE (COUNT * 4)
diff --git a/libavcodec/iirfilter-test.c b/libavcodec/tests/iirfilter.c
similarity index 98%
rename from libavcodec/iirfilter-test.c
rename to libavcodec/tests/iirfilter.c
index cd250a3..60cc6fc 100644
--- a/libavcodec/iirfilter-test.c
+++ b/libavcodec/tests/iirfilter.c
@@ -22,7 +22,7 @@
 
 #include "libavutil/libm.h"
 
-#include "iirfilter.h"
+#include "libavcodec/iirfilter.h"
 
 #define FILT_ORDER 4
 #define SIZE 1024
diff --git a/libavcodec/imgconvert-test.c b/libavcodec/tests/imgconvert.c
similarity index 98%
rename from libavcodec/imgconvert-test.c
rename to libavcodec/tests/imgconvert.c
index 96004d7..c598d46 100644
--- a/libavcodec/imgconvert-test.c
+++ b/libavcodec/tests/imgconvert.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "imgconvert.c"
+#include "libavcodec/imgconvert.c"
 
 #if FF_API_AVPICTURE
 FF_DISABLE_DEPRECATION_WARNINGS
diff --git a/libavcodec/jpeg2000dwt-test.c b/libavcodec/tests/jpeg2000dwt.c
similarity index 99%
rename from libavcodec/jpeg2000dwt-test.c
rename to libavcodec/tests/jpeg2000dwt.c
index 30f1ce1..80b33be 100644
--- a/libavcodec/jpeg2000dwt-test.c
+++ b/libavcodec/tests/jpeg2000dwt.c
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "jpeg2000dwt.c"
+#include "libavcodec/jpeg2000dwt.c"
 
 #include "libavutil/lfg.h"
 
diff --git a/libavcodec/mathops-test.c b/libavcodec/tests/mathops.c
similarity index 97%
rename from libavcodec/mathops-test.c
rename to libavcodec/tests/mathops.c
index d47f144..33a059c 100644
--- a/libavcodec/mathops-test.c
+++ b/libavcodec/tests/mathops.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "mathops.h"
+#include "libavcodec/mathops.h"
 
 #include <stdlib.h>
 
diff --git a/libavcodec/motion-test.c b/libavcodec/tests/motion.c
similarity index 99%
rename from libavcodec/motion-test.c
rename to libavcodec/tests/motion.c
index ebcf4aa..d89f940 100644
--- a/libavcodec/motion-test.c
+++ b/libavcodec/tests/motion.c
@@ -28,7 +28,7 @@
 #include <string.h>
 
 #include "config.h"
-#include "me_cmp.h"
+#include "libavcodec/me_cmp.h"
 #include "libavutil/internal.h"
 #include "libavutil/lfg.h"
 #include "libavutil/mem.h"
diff --git a/libavcodec/options-test.c b/libavcodec/tests/options.c
similarity index 99%
rename from libavcodec/options-test.c
rename to libavcodec/tests/options.c
index 0b064e6..7f0ee1d 100644
--- a/libavcodec/options-test.c
+++ b/libavcodec/tests/options.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "options.c"
+#include "libavcodec/options.c"
 
 static int dummy_init(AVCodecContext *ctx)
 {
diff --git a/libavcodec/ppc/dct-test.c b/libavcodec/tests/ppc/dct.c
similarity index 96%
rename from libavcodec/ppc/dct-test.c
rename to libavcodec/tests/ppc/dct.c
index 2328516..d95db52 100644
--- a/libavcodec/ppc/dct-test.c
+++ b/libavcodec/tests/ppc/dct.c
@@ -18,7 +18,7 @@
 
 #include "config.h"
 
-#include "fdct.h"
+#include "libavcodec/ppc/fdct.h"
 
 static const struct algo fdct_tab_arch[] = {
 #if HAVE_ALTIVEC
diff --git a/libavcodec/rangecoder-test.c b/libavcodec/tests/rangecoder.c
similarity index 97%
rename from libavcodec/rangecoder-test.c
rename to libavcodec/tests/rangecoder.c
index 2892949..2da5c0c 100644
--- a/libavcodec/rangecoder-test.c
+++ b/libavcodec/tests/rangecoder.c
@@ -22,7 +22,7 @@
 #include "libavutil/lfg.h"
 #include "libavutil/log.h"
 
-#include "rangecoder.h"
+#include "libavcodec/rangecoder.h"
 
 #define SIZE 10240
 
diff --git a/libavcodec/snowenc-test.c b/libavcodec/tests/snowenc.c
similarity index 99%
rename from libavcodec/snowenc-test.c
rename to libavcodec/tests/snowenc.c
index e1ed86f..d5f94e8 100644
--- a/libavcodec/snowenc-test.c
+++ b/libavcodec/tests/snowenc.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "snowenc.c"
+#include "libavcodec/snowenc.c"
 
 #undef malloc
 #undef free
diff --git a/libavcodec/utils-test.c b/libavcodec/tests/utils.c
similarity index 97%
rename from libavcodec/utils-test.c
rename to libavcodec/tests/utils.c
index 7b3b718..e2891fb 100644
--- a/libavcodec/utils-test.c
+++ b/libavcodec/tests/utils.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "avcodec.h"
+#include "libavcodec/avcodec.h"
 
 int main(void){
     AVCodec *codec = NULL;
diff --git a/libavcodec/x86/dct-test.c b/libavcodec/tests/x86/dct.c
similarity index 97%
rename from libavcodec/x86/dct-test.c
rename to libavcodec/tests/x86/dct.c
index 28ede16..b6cdfb3 100644
--- a/libavcodec/x86/dct-test.c
+++ b/libavcodec/tests/x86/dct.c
@@ -18,9 +18,9 @@
 
 #include "config.h"
 
-#include "fdct.h"
-#include "xvididct.h"
-#include "simple_idct.h"
+#include "libavcodec/x86/fdct.h"
+#include "libavcodec/x86/xvididct.h"
+#include "libavcodec/x86/simple_idct.h"
 
 #if (CONFIG_PRORES_DECODER || CONFIG_PRORES_LGPL_DECODER) && ARCH_X86_64 && HAVE_YASM
 void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
diff --git a/libavdevice/tests/.gitignore b/libavdevice/tests/.gitignore
new file mode 100644
index 0000000..b4a2281
--- /dev/null
+++ b/libavdevice/tests/.gitignore
@@ -0,0 +1 @@
+/timefilter
diff --git a/libavdevice/timefilter-test.c b/libavdevice/tests/timefilter.c
similarity index 99%
rename from libavdevice/timefilter-test.c
rename to libavdevice/tests/timefilter.c
index 39432d5..7c1ed0a 100644
--- a/libavdevice/timefilter-test.c
+++ b/libavdevice/tests/timefilter.c
@@ -21,7 +21,7 @@
 #include "libavutil/common.h"
 #include "libavutil/lfg.h"
 
-#include "timefilter.h"
+#include "libavdevice/timefilter.h"
 
 #define LFG_MAX ((1LL << 32) - 1)
 
diff --git a/libavfilter/tests/.gitignore b/libavfilter/tests/.gitignore
new file mode 100644
index 0000000..b605afa
--- /dev/null
+++ b/libavfilter/tests/.gitignore
@@ -0,0 +1,3 @@
+/drawutils
+/filtfmts
+/formats
diff --git a/libavfilter/drawutils-test.c b/libavfilter/tests/drawutils.c
similarity index 98%
rename from libavfilter/drawutils-test.c
rename to libavfilter/tests/drawutils.c
index 7b9f89f..7fe53dd 100644
--- a/libavfilter/drawutils-test.c
+++ b/libavfilter/tests/drawutils.c
@@ -19,7 +19,7 @@
 #include <stdio.h>
 
 #include "libavutil/pixdesc.h"
-#include "drawutils.h"
+#include "libavfilter/drawutils.h"
 
 int main(void)
 {
diff --git a/libavfilter/filtfmts-test.c b/libavfilter/tests/filtfmts.c
similarity index 100%
rename from libavfilter/filtfmts-test.c
rename to libavfilter/tests/filtfmts.c
diff --git a/libavfilter/formats-test.c b/libavfilter/tests/formats.c
similarity index 98%
rename from libavfilter/formats-test.c
rename to libavfilter/tests/formats.c
index a891638..0e8ba4a 100644
--- a/libavfilter/formats-test.c
+++ b/libavfilter/tests/formats.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "formats.c"
+#include "libavfilter/formats.c"
 
 #undef printf
 
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index ddac2d3..6252de8 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1559,23 +1559,20 @@ static int mkv_write_header(AVFormatContext *s)
     if ((tag = av_dict_get(s->metadata, "title", NULL, 0)))
         put_ebml_string(pb, MATROSKA_ID_TITLE, tag->value);
     if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
+        uint32_t segment_uid[4];
+        AVLFG lfg;
+
+        av_lfg_init(&lfg, av_get_random_seed());
+
+        for (i = 0; i < 4; i++)
+            segment_uid[i] = av_lfg_get(&lfg);
+
         put_ebml_string(pb, MATROSKA_ID_MUXINGAPP, LIBAVFORMAT_IDENT);
         if ((tag = av_dict_get(s->metadata, "encoding_tool", NULL, 0)))
             put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, tag->value);
         else
             put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
-
-        if (mkv->mode != MODE_WEBM) {
-            uint32_t segment_uid[4];
-            AVLFG lfg;
-
-            av_lfg_init(&lfg, av_get_random_seed());
-
-            for (i = 0; i < 4; i++)
-                segment_uid[i] = av_lfg_get(&lfg);
-
-            put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);
-        }
+        put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);
     } else {
         const char *ident = "Lavf";
         put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , ident);
diff --git a/libavformat/tests/.gitignore b/libavformat/tests/.gitignore
new file mode 100644
index 0000000..c8adb86
--- /dev/null
+++ b/libavformat/tests/.gitignore
@@ -0,0 +1,6 @@
+/movenc
+/noproxy
+/rtmpdh
+/seek
+/srtp
+/url
diff --git a/libavformat/movenc-test.c b/libavformat/tests/movenc.c
similarity index 99%
rename from libavformat/movenc-test.c
rename to libavformat/tests/movenc.c
index 6c7f0f6..786f1dc 100644
--- a/libavformat/movenc-test.c
+++ b/libavformat/tests/movenc.c
@@ -24,7 +24,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/md5.h"
 
-#include "avformat.h"
+#include "libavformat/avformat.h"
 
 #if HAVE_UNISTD_H
 #include <unistd.h>
diff --git a/libavformat/noproxy-test.c b/libavformat/tests/noproxy.c
similarity index 97%
rename from libavformat/noproxy-test.c
rename to libavformat/tests/noproxy.c
index 4524764..782356c 100644
--- a/libavformat/noproxy-test.c
+++ b/libavformat/tests/noproxy.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "network.h"
+#include "libavformat/network.h"
 
 static void test(const char *pattern, const char *host)
 {
diff --git a/libavformat/rtmpdh-test.c b/libavformat/tests/rtmpdh.c
similarity index 99%
rename from libavformat/rtmpdh-test.c
rename to libavformat/tests/rtmpdh.c
index e86fb18..929b3f3 100644
--- a/libavformat/rtmpdh-test.c
+++ b/libavformat/tests/rtmpdh.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "rtmpdh.c"
+#include "libavformat/rtmpdh.c"
 
 #include <stdio.h>
 
diff --git a/libavformat/seek-test.c b/libavformat/tests/seek.c
similarity index 99%
rename from libavformat/seek-test.c
rename to libavformat/tests/seek.c
index 904b435..7ed56ba 100644
--- a/libavformat/seek-test.c
+++ b/libavformat/tests/seek.c
@@ -26,6 +26,7 @@
 
 #include "libavutil/common.h"
 #include "libavutil/mathematics.h"
+
 #include "libavformat/avformat.h"
 
 static char buffer[20];
diff --git a/libavformat/srtp-test.c b/libavformat/tests/srtp.c
similarity index 98%
rename from libavformat/srtp-test.c
rename to libavformat/tests/srtp.c
index 1198f59..89450ce 100644
--- a/libavformat/srtp-test.c
+++ b/libavformat/tests/srtp.c
@@ -20,8 +20,8 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "rtpdec.h"
-#include "srtp.h"
+#include "libavformat/rtpdec.h"
+#include "libavformat/srtp.h"
 
 static const char *aes128_80_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn";
 
diff --git a/libavformat/url-test.c b/libavformat/tests/url.c
similarity index 98%
rename from libavformat/url-test.c
rename to libavformat/tests/url.c
index a1da82e..1623179 100644
--- a/libavformat/url-test.c
+++ b/libavformat/tests/url.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "url.h"
+#include "libavformat/url.h"
 
 static void test(const char *base, const char *rel)
 {
diff --git a/libavresample/tests/.gitignore b/libavresample/tests/.gitignore
new file mode 100644
index 0000000..1e15871
--- /dev/null
+++ b/libavresample/tests/.gitignore
@@ -0,0 +1 @@
+/avresample
diff --git a/libavresample/avresample-test.c b/libavresample/tests/avresample.c
similarity index 99%
rename from libavresample/avresample-test.c
rename to libavresample/tests/avresample.c
index 290ae94..8c377ba 100644
--- a/libavresample/avresample-test.c
+++ b/libavresample/tests/avresample.c
@@ -30,7 +30,8 @@
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/samplefmt.h"
-#include "avresample.h"
+
+#include "libavresample/avresample.h"
 
 static double dbl_rand(AVLFG *lfg)
 {
diff --git a/libavutil/Makefile b/libavutil/Makefile
index a35deb6..1f05215 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -221,4 +221,4 @@ TOOLS = crypto_bench ffhash ffeval ffescape
 tools/crypto_bench$(EXESUF): ELIBS += $(if $(VERSUS),$(subst +, -l,+$(VERSUS)),)
 tools/crypto_bench$(EXESUF): CFLAGS += -DUSE_EXT_LIBS=0$(if $(VERSUS),$(subst +,+USE_,+$(VERSUS)),)
 
-$(SUBDIR)lzo-test$(EXESUF): ELIBS = -llzo2
+$(SUBDIR)tests/lzo$(EXESUF): ELIBS = -llzo2
diff --git a/libavutil/des.c b/libavutil/des.c
index d375095..6957666 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -104,7 +104,7 @@ static const uint8_t S_boxes[8][32] = {
 #else
 /**
  * This table contains the results of applying both the S-box and P-shuffle.
- * It can be regenerated by compiling des-test.c with "-DCONFIG_SMALL -DGENTABLES".
+ * It can be regenerated by compiling tests/des.c with "-DCONFIG_SMALL -DGENTABLES".
  */
 static const uint32_t S_boxes_P_shuffle[8][64] = {
     { 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000,
diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
new file mode 100644
index 0000000..c23c44b
--- /dev/null
+++ b/libavutil/tests/.gitignore
@@ -0,0 +1,44 @@
+/adler32
+/aes
+/atomic
+/avstring
+/base64
+/blowfish
+/bprint
+/camellia
+/cast5
+/color_utils
+/cpu
+/crc
+/des
+/dict
+/display
+/error
+/eval
+/fifo
+/file
+/float_dsp
+/hash
+/hmac
+/lfg
+/lls
+/log
+/lzo
+/md5
+/murmur3
+/opt
+/parseutils
+/pca
+/pixdesc
+/pixelutils
+/random_seed
+/rational
+/ripemd
+/sha
+/sha512
+/softfloat
+/tea
+/tree
+/twofish
+/utf8
+/xtea
diff --git a/libavutil/adler32-test.c b/libavutil/tests/adler32.c
similarity index 94%
rename from libavutil/adler32-test.c
rename to libavutil/tests/adler32.c
index f93cf9d..511bf1e 100644
--- a/libavutil/adler32-test.c
+++ b/libavutil/tests/adler32.c
@@ -19,9 +19,9 @@
 // LCOV_EXCL_START
 #include <string.h>
 
-#include "log.h"
-#include "timer.h"
-#include "adler32.h"
+#include "libavutil/log.h"
+#include "libavutil/timer.h"
+#include "libavutil/adler32.h"
 
 #define LEN 7001
 
diff --git a/libavutil/aes-test.c b/libavutil/tests/aes.c
similarity index 97%
rename from libavutil/aes-test.c
rename to libavutil/tests/aes.c
index 2bdba8a..1291ad6 100644
--- a/libavutil/aes-test.c
+++ b/libavutil/tests/aes.c
@@ -19,10 +19,10 @@
 // LCOV_EXCL_START
 #include <string.h>
 
-#include "aes.h"
-#include "lfg.h"
-#include "log.h"
-#include "mem.h"
+#include "libavutil/aes.h"
+#include "libavutil/lfg.h"
+#include "libavutil/log.h"
+#include "libavutil/mem.h"
 
 int main(int argc, char **argv)
 {
diff --git a/libavutil/atomic-test.c b/libavutil/tests/atomic.c
similarity index 94%
rename from libavutil/atomic-test.c
rename to libavutil/tests/atomic.c
index 397d8c9..c92f220 100644
--- a/libavutil/atomic-test.c
+++ b/libavutil/tests/atomic.c
@@ -16,8 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "atomic.h"
-#include "avassert.h"
+#include "libavutil/atomic.h"
+#include "libavutil/avassert.h"
 
 int main(void)
 {
diff --git a/libavutil/avstring-test.c b/libavutil/tests/avstring.c
similarity index 96%
rename from libavutil/avstring-test.c
rename to libavutil/tests/avstring.c
index 3e29661..1242b3f 100644
--- a/libavutil/avstring-test.c
+++ b/libavutil/tests/avstring.c
@@ -18,9 +18,9 @@
 
 #include <stdio.h>
 
-#include "common.h"
-#include "mem.h"
-#include "avstring.h"
+#include "libavutil/common.h"
+#include "libavutil/mem.h"
+#include "libavutil/avstring.h"
 
 int main(void)
 {
diff --git a/libavutil/base64-test.c b/libavutil/tests/base64.c
similarity index 97%
rename from libavutil/base64-test.c
rename to libavutil/tests/base64.c
index 19ecd2b..88fd55c 100644
--- a/libavutil/base64-test.c
+++ b/libavutil/tests/base64.c
@@ -20,9 +20,9 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "common.h"
-#include "base64.h"
-#include "timer.h"
+#include "libavutil/common.h"
+#include "libavutil/base64.h"
+#include "libavutil/timer.h"
 
 #define MAX_DATA_SIZE    1024
 #define MAX_ENCODED_SIZE 2048
diff --git a/libavutil/blowfish-test.c b/libavutil/tests/blowfish.c
similarity index 99%
rename from libavutil/blowfish-test.c
rename to libavutil/tests/blowfish.c
index 3ad7cd7..2c2e004 100644
--- a/libavutil/blowfish-test.c
+++ b/libavutil/tests/blowfish.c
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "blowfish.h"
+#include "libavutil/blowfish.h"
 
 #define NUM_VARIABLE_KEY_TESTS 34
 
diff --git a/libavutil/bprint-test.c b/libavutil/tests/bprint.c
similarity index 99%
rename from libavutil/bprint-test.c
rename to libavutil/tests/bprint.c
index f081c44..d7f381d 100644
--- a/libavutil/bprint-test.c
+++ b/libavutil/tests/bprint.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "bprint.c"
+#include "libavutil/bprint.c"
 
 #undef printf
 
diff --git a/libavutil/camellia-test.c b/libavutil/tests/camellia.c
similarity index 98%
rename from libavutil/camellia-test.c
rename to libavutil/tests/camellia.c
index 0540ccc..1716b59 100644
--- a/libavutil/camellia-test.c
+++ b/libavutil/tests/camellia.c
@@ -19,8 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "camellia.h"
-#include "log.h"
+#include "libavutil/camellia.h"
+#include "libavutil/log.h"
 
 int main(int argc, char *argv[])
 {
diff --git a/libavutil/cast5-test.c b/libavutil/tests/cast5.c
similarity index 98%
rename from libavutil/cast5-test.c
rename to libavutil/tests/cast5.c
index e2269a7..ce3aa80 100644
--- a/libavutil/cast5-test.c
+++ b/libavutil/tests/cast5.c
@@ -19,8 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "cast5.h"
-#include "log.h"
+#include "libavutil/cast5.h"
+#include "libavutil/log.h"
 
 int main(int argc, char** argv)
 {
diff --git a/libavutil/color_utils-test.c b/libavutil/tests/color_utils.c
similarity index 97%
rename from libavutil/color_utils-test.c
rename to libavutil/tests/color_utils.c
index 083872c..ea01271 100644
--- a/libavutil/color_utils-test.c
+++ b/libavutil/tests/color_utils.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "color_utils.c"
+#include "libavutil/color_utils.c"
 
 int main(int argc, char *argv[])
 {
diff --git a/libavutil/cpu-test.c b/libavutil/tests/cpu.c
similarity index 98%
rename from libavutil/cpu-test.c
rename to libavutil/tests/cpu.c
index 35e7631..f02a54c 100644
--- a/libavutil/cpu-test.c
+++ b/libavutil/tests/cpu.c
@@ -19,8 +19,9 @@
 #include <stdio.h>
 
 #include "config.h"
-#include "cpu.h"
-#include "avstring.h"
+
+#include "libavutil/cpu.h"
+#include "libavutil/avstring.h"
 
 #if HAVE_UNISTD_H
 #include <unistd.h>
diff --git a/libavutil/crc-test.c b/libavutil/tests/crc.c
similarity index 98%
rename from libavutil/crc-test.c
rename to libavutil/tests/crc.c
index 199aea1..9825d6b 100644
--- a/libavutil/crc-test.c
+++ b/libavutil/tests/crc.c
@@ -19,7 +19,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "crc.h"
+#include "libavutil/crc.h"
 
 int main(void)
 {
diff --git a/libavutil/des-test.c b/libavutil/tests/des.c
similarity index 98%
rename from libavutil/des-test.c
rename to libavutil/tests/des.c
index 99453af..ed04fad 100644
--- a/libavutil/des-test.c
+++ b/libavutil/tests/des.c
@@ -16,14 +16,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "des.c"
+#include "libavutil/des.c"
 
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "time.h"
+#include "libavutil/time.h"
 
 static uint64_t rand64(void)
 {
diff --git a/libavutil/dict-test.c b/libavutil/tests/dict.c
similarity index 99%
rename from libavutil/dict-test.c
rename to libavutil/tests/dict.c
index e40b578..0039ba5 100644
--- a/libavutil/dict-test.c
+++ b/libavutil/tests/dict.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "dict.c"
+#include "libavutil/dict.c"
 
 static void print_dict(const AVDictionary *m)
 {
diff --git a/libavutil/display-test.c b/libavutil/tests/display.c
similarity index 98%
rename from libavutil/display-test.c
rename to libavutil/tests/display.c
index b42ab89..893ebb5 100644
--- a/libavutil/display-test.c
+++ b/libavutil/tests/display.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "display.c"
+#include "libavutil/display.c"
 
 static void print_matrix(int32_t matrix[9])
 {
diff --git a/libavutil/error-test.c b/libavutil/tests/error.c
similarity index 97%
rename from libavutil/error-test.c
rename to libavutil/tests/error.c
index 36240da..16efc8a 100644
--- a/libavutil/error-test.c
+++ b/libavutil/tests/error.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "error.c"
+#include "libavutil/error.c"
 
 #undef printf
 
diff --git a/libavutil/eval-test.c b/libavutil/tests/eval.c
similarity index 98%
rename from libavutil/eval-test.c
rename to libavutil/tests/eval.c
index 17a63cc..2a1afcc 100644
--- a/libavutil/eval-test.c
+++ b/libavutil/tests/eval.c
@@ -20,9 +20,9 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "libm.h"
-#include "timer.h"
-#include "eval.h"
+#include "libavutil/libm.h"
+#include "libavutil/timer.h"
+#include "libavutil/eval.h"
 
 static const double const_values[] = {
     M_PI,
diff --git a/libavutil/fifo-test.c b/libavutil/tests/fifo.c
similarity index 98%
rename from libavutil/fifo-test.c
rename to libavutil/tests/fifo.c
index 71a9172..e4d7edf 100644
--- a/libavutil/fifo-test.c
+++ b/libavutil/tests/fifo.c
@@ -18,7 +18,7 @@
 
 #include <stdio.h>
 
-#include "fifo.h"
+#include "libavutil/fifo.h"
 
 int main(void)
 {
diff --git a/libavutil/file-test.c b/libavutil/tests/file.c
similarity index 97%
rename from libavutil/file-test.c
rename to libavutil/tests/file.c
index 0324081..3608bcc 100644
--- a/libavutil/file-test.c
+++ b/libavutil/tests/file.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "file.c"
+#include "libavutil/file.c"
 
 #undef printf
 
diff --git a/libavutil/float_dsp-test.c b/libavutil/tests/float_dsp.c
similarity index 97%
rename from libavutil/float_dsp-test.c
rename to libavutil/tests/float_dsp.c
index 9963efb..053324d 100644
--- a/libavutil/float_dsp-test.c
+++ b/libavutil/tests/float_dsp.c
@@ -30,13 +30,13 @@
 #include "compat/getopt.c"
 #endif
 
-#include "common.h"
-#include "cpu.h"
-#include "internal.h"
-#include "lfg.h"
-#include "log.h"
-#include "random_seed.h"
-#include "float_dsp.h"
+#include "libavutil/common.h"
+#include "libavutil/cpu.h"
+#include "libavutil/internal.h"
+#include "libavutil/lfg.h"
+#include "libavutil/log.h"
+#include "libavutil/random_seed.h"
+#include "libavutil/float_dsp.h"
 
 #define LEN 240
 
diff --git a/libavutil/hash-test.c b/libavutil/tests/hash.c
similarity index 98%
rename from libavutil/hash-test.c
rename to libavutil/tests/hash.c
index bb7edf5..4f2ad52 100644
--- a/libavutil/hash-test.c
+++ b/libavutil/tests/hash.c
@@ -21,7 +21,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "hash.h"
+#include "libavutil/hash.h"
 
 #define SRC_BUF_SIZE 64
 #define DST_BUF_SIZE (AV_HASH_MAX_SIZE * 8)
diff --git a/libavutil/hmac-test.c b/libavutil/tests/hmac.c
similarity index 99%
rename from libavutil/hmac-test.c
rename to libavutil/tests/hmac.c
index 925f3df..5eeb63c 100644
--- a/libavutil/hmac-test.c
+++ b/libavutil/tests/hmac.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "hmac.c"
+#include "libavutil/hmac.c"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libavutil/lfg-test.c b/libavutil/tests/lfg.c
similarity index 96%
rename from libavutil/lfg-test.c
rename to libavutil/tests/lfg.c
index 2b6f382..1425e02 100644
--- a/libavutil/lfg-test.c
+++ b/libavutil/tests/lfg.c
@@ -16,9 +16,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "log.h"
-#include "timer.h"
-#include "lfg.h"
+#include "libavutil/log.h"
+#include "libavutil/timer.h"
+#include "libavutil/lfg.h"
 
 int main(void)
 {
diff --git a/libavutil/lls-test.c b/libavutil/tests/lls.c
similarity index 95%
rename from libavutil/lls-test.c
rename to libavutil/tests/lls.c
index 12215c5..965b0f4 100644
--- a/libavutil/lls-test.c
+++ b/libavutil/tests/lls.c
@@ -19,9 +19,9 @@
 #include <limits.h>
 #include <stdio.h>
 
-#include "internal.h"
-#include "lfg.h"
-#include "lls.h"
+#include "libavutil/internal.h"
+#include "libavutil/lfg.h"
+#include "libavutil/lls.h"
 
 int main(void)
 {
diff --git a/libavutil/log-test.c b/libavutil/tests/log.c
similarity index 98%
rename from libavutil/log-test.c
rename to libavutil/tests/log.c
index 14d4764..8fe9461 100644
--- a/libavutil/log-test.c
+++ b/libavutil/tests/log.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "log.c"
+#include "libavutil/log.c"
 
 #include <string.h>
 
diff --git a/libavutil/lzo-test.c b/libavutil/tests/lzo.c
similarity index 96%
rename from libavutil/lzo-test.c
rename to libavutil/tests/lzo.c
index e28fbe5..0147ab5 100644
--- a/libavutil/lzo-test.c
+++ b/libavutil/tests/lzo.c
@@ -20,9 +20,11 @@
 
 #include <stdio.h>
 #include <lzo/lzo1x.h>
-#include "log.h"
-#include "lzo.h"
-#include "mem.h"
+
+#include "libavutil/log.h"
+#include "libavutil/lzo.h"
+#include "libavutil/mem.h"
+
 #define MAXSZ (10*1024*1024)
 
 /* Define one of these to 1 if you wish to benchmark liblzo
diff --git a/libavutil/md5-test.c b/libavutil/tests/md5.c
similarity index 98%
rename from libavutil/md5-test.c
rename to libavutil/tests/md5.c
index 547f74b..42e4538 100644
--- a/libavutil/md5-test.c
+++ b/libavutil/tests/md5.c
@@ -19,7 +19,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "md5.h"
+#include "libavutil/md5.h"
 
 static void print_md5(uint8_t *md5)
 {
diff --git a/libavutil/murmur3-test.c b/libavutil/tests/murmur3.c
similarity index 95%
rename from libavutil/murmur3-test.c
rename to libavutil/tests/murmur3.c
index edc7a18..b8d6b1f 100644
--- a/libavutil/murmur3-test.c
+++ b/libavutil/tests/murmur3.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "intreadwrite.h"
-#include "mem.h"
-#include "murmur3.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+#include "libavutil/murmur3.h"
 
 int main(void)
 {
diff --git a/libavutil/opt-test.c b/libavutil/tests/opt.c
similarity index 98%
rename from libavutil/opt-test.c
rename to libavutil/tests/opt.c
index e41782b..568eb45 100644
--- a/libavutil/opt-test.c
+++ b/libavutil/tests/opt.c
@@ -19,14 +19,14 @@
 #include <limits.h>
 #include <stdio.h>
 
-#include "common.h"
-#include "channel_layout.h"
-#include "error.h"
-#include "log.h"
-#include "mem.h"
-#include "rational.h"
-#include "opt.h"
-#include "pixdesc.h"
+#include "libavutil/common.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/error.h"
+#include "libavutil/log.h"
+#include "libavutil/mem.h"
+#include "libavutil/rational.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 
 typedef struct TestContext {
     const AVClass *class;
diff --git a/libavutil/parseutils-test.c b/libavutil/tests/parseutils.c
similarity index 98%
rename from libavutil/parseutils-test.c
rename to libavutil/tests/parseutils.c
index fa9c1c1..682b390 100644
--- a/libavutil/parseutils-test.c
+++ b/libavutil/tests/parseutils.c
@@ -17,14 +17,14 @@
  */
 
 #define TEST
-#include "parseutils.c"
+#include "libavutil/parseutils.c"
 
 #include <stdint.h>
 #include <stdio.h>
 
-#include "common.h"
-#include "log.h"
-#include "rational.h"
+#include "libavutil/common.h"
+#include "libavutil/log.h"
+#include "libavutil/rational.h"
 
 static uint32_t randomv = MKTAG('L','A','V','U');
 
diff --git a/libavutil/pca-test.c b/libavutil/tests/pca.c
similarity index 98%
rename from libavutil/pca-test.c
rename to libavutil/tests/pca.c
index e56d618..2d9eb8f 100644
--- a/libavutil/pca-test.c
+++ b/libavutil/tests/pca.c
@@ -19,8 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "pca.c"
-#include "lfg.h"
+#include "libavutil/pca.c"
+#include "libavutil/lfg.h"
 
 #undef printf
 #include <stdio.h>
diff --git a/libavutil/pixdesc-test.c b/libavutil/tests/pixdesc.c
similarity index 98%
rename from libavutil/pixdesc-test.c
rename to libavutil/tests/pixdesc.c
index cd7d4c5..7fbfeea 100644
--- a/libavutil/pixdesc-test.c
+++ b/libavutil/tests/pixdesc.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "pixdesc.c"
+#include "libavutil/pixdesc.c"
 
 int main(void){
     int i;
diff --git a/libavutil/pixelutils-test.c b/libavutil/tests/pixelutils.c
similarity index 99%
rename from libavutil/pixelutils-test.c
rename to libavutil/tests/pixelutils.c
index eebc524..ec4dc8f 100644
--- a/libavutil/pixelutils-test.c
+++ b/libavutil/tests/pixelutils.c
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "pixelutils.c"
+#include "libavutil/pixelutils.c"
 
 #define W1 320
 #define H1 240
diff --git a/libavutil/random_seed-test.c b/libavutil/tests/random_seed.c
similarity index 97%
rename from libavutil/random_seed-test.c
rename to libavutil/tests/random_seed.c
index 182c8a6..ebe9b3e 100644
--- a/libavutil/random_seed-test.c
+++ b/libavutil/tests/random_seed.c
@@ -19,7 +19,7 @@
  */
 
 #define TEST 1
-#include "random_seed.c"
+#include "libavutil/random_seed.c"
 
 #undef printf
 #define N 256
diff --git a/libavutil/rational-test.c b/libavutil/tests/rational.c
similarity index 98%
rename from libavutil/rational-test.c
rename to libavutil/tests/rational.c
index 455d9c4..caec07d 100644
--- a/libavutil/rational-test.c
+++ b/libavutil/tests/rational.c
@@ -19,9 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "rational.c"
-
-#include "integer.h"
+#include "libavutil/rational.c"
+#include "libavutil/integer.h"
 
 int main(void)
 {
diff --git a/libavutil/ripemd-test.c b/libavutil/tests/ripemd.c
similarity index 98%
rename from libavutil/ripemd-test.c
rename to libavutil/tests/ripemd.c
index 2a60bbe..58e5fce 100644
--- a/libavutil/ripemd-test.c
+++ b/libavutil/tests/ripemd.c
@@ -21,8 +21,8 @@
 
 #include <stdio.h>
 
-#include "mem.h"
-#include "ripemd.h"
+#include "libavutil/mem.h"
+#include "libavutil/ripemd.h"
 
 int main(void)
 {
diff --git a/libavutil/sha-test.c b/libavutil/tests/sha.c
similarity index 98%
rename from libavutil/sha-test.c
rename to libavutil/tests/sha.c
index 7af2c04..a95b3a0 100644
--- a/libavutil/sha-test.c
+++ b/libavutil/tests/sha.c
@@ -18,8 +18,8 @@
 
 #include <stdio.h>
 
-#include "mem.h"
-#include "sha.h"
+#include "libavutil/mem.h"
+#include "libavutil/sha.h"
 
 int main(void)
 {
diff --git a/libavutil/sha512-test.c b/libavutil/tests/sha512.c
similarity index 98%
rename from libavutil/sha512-test.c
rename to libavutil/tests/sha512.c
index 32ff508..f3b90fd 100644
--- a/libavutil/sha512-test.c
+++ b/libavutil/tests/sha512.c
@@ -23,8 +23,8 @@
 
 #include <stdio.h>
 
-#include "mem.h"
-#include "sha512.h"
+#include "libavutil/mem.h"
+#include "libavutil/sha512.h"
 
 int main(void)
 {
diff --git a/libavutil/softfloat-test.c b/libavutil/tests/softfloat.c
similarity index 98%
rename from libavutil/softfloat-test.c
rename to libavutil/tests/softfloat.c
index 3293450..16788d4 100644
--- a/libavutil/softfloat-test.c
+++ b/libavutil/tests/softfloat.c
@@ -19,9 +19,10 @@
  */
 
 #include <inttypes.h>
-#include "softfloat.h"
-#include "common.h"
-#include "log.h"
+
+#include "libavutil/softfloat.h"
+#include "libavutil/common.h"
+#include "libavutil/log.h"
 
 #include <stdio.h>
 
diff --git a/libavutil/tea-test.c b/libavutil/tests/tea.c
similarity index 98%
rename from libavutil/tea-test.c
rename to libavutil/tests/tea.c
index 9bf059b..605bb52 100644
--- a/libavutil/tea-test.c
+++ b/libavutil/tests/tea.c
@@ -24,8 +24,8 @@
 
 #include <stdio.h>
 
-#include "common.h"
-#include "tea.h"
+#include "libavutil/common.h"
+#include "libavutil/tea.h"
 
 #define TEA_NUM_TESTS 4
 
diff --git a/libavutil/tree-test.c b/libavutil/tests/tree.c
similarity index 96%
rename from libavutil/tree-test.c
rename to libavutil/tests/tree.c
index d1df0b6..7503228 100644
--- a/libavutil/tree-test.c
+++ b/libavutil/tests/tree.c
@@ -16,13 +16,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "tree.c"
+#include "libavutil/tree.c"
 
 #include <stdint.h>
 
-#include "common.h"
-#include "lfg.h"
-#include "log.h"
+#include "libavutil/common.h"
+#include "libavutil/lfg.h"
+#include "libavutil/log.h"
 
 static int check(AVTreeNode *t)
 {
diff --git a/libavutil/twofish-test.c b/libavutil/tests/twofish.c
similarity index 98%
rename from libavutil/twofish-test.c
rename to libavutil/tests/twofish.c
index be0586a9..74e0926 100644
--- a/libavutil/twofish-test.c
+++ b/libavutil/tests/twofish.c
@@ -19,8 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "log.h"
-#include "twofish.h"
+#include "libavutil/log.h"
+#include "libavutil/twofish.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libavutil/utf8-test.c b/libavutil/tests/utf8.c
similarity index 100%
rename from libavutil/utf8-test.c
rename to libavutil/tests/utf8.c
diff --git a/libavutil/xtea-test.c b/libavutil/tests/xtea.c
similarity index 98%
rename from libavutil/xtea-test.c
rename to libavutil/tests/xtea.c
index e8f3915..a974600 100644
--- a/libavutil/xtea-test.c
+++ b/libavutil/tests/xtea.c
@@ -21,8 +21,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "intreadwrite.h"
-#include "xtea.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/xtea.h"
 
 #define XTEA_NUM_TESTS 6
 
diff --git a/library.mak b/library.mak
index 5bfa796..ae2d3f2 100644
--- a/library.mak
+++ b/library.mak
@@ -53,11 +53,12 @@ $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
 endif
 
 clean::
-	$(RM) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
-	    $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
-
+	$(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
+	    $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%)
+ 
 distclean:: clean
-	$(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
+	$(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) \
+            $(DISTCLEANSUFFIXES:%=$(SUBDIR)tests/%)
 
 install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
 	$(Q)mkdir -p "$(SHLIBDIR)"
diff --git a/libswresample/tests/.gitignore b/libswresample/tests/.gitignore
new file mode 100644
index 0000000..2dc986b
--- /dev/null
+++ b/libswresample/tests/.gitignore
@@ -0,0 +1 @@
+/swresample
diff --git a/libswresample/swresample-test.c b/libswresample/tests/swresample.c
similarity index 99%
rename from libswresample/swresample-test.c
rename to libswresample/tests/swresample.c
index 0aa47c8..9ba7735 100644
--- a/libswresample/swresample-test.c
+++ b/libswresample/tests/swresample.c
@@ -23,7 +23,8 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
-#include "swresample.h"
+
+#include "libswresample/swresample.h"
 
 #undef time
 #include "time.h"
diff --git a/libswscale/tests/.gitignore b/libswscale/tests/.gitignore
new file mode 100644
index 0000000..0ac3691
--- /dev/null
+++ b/libswscale/tests/.gitignore
@@ -0,0 +1,2 @@
+/colorspace
+/swscale
diff --git a/libswscale/colorspace-test.c b/libswscale/tests/colorspace.c
similarity index 98%
rename from libswscale/colorspace-test.c
rename to libswscale/tests/colorspace.c
index f6e0c92..d1eddc8 100644
--- a/libswscale/colorspace-test.c
+++ b/libswscale/tests/colorspace.c
@@ -23,10 +23,11 @@
 #include <stdlib.h>
 #include <inttypes.h>
 
-#include "swscale.h"
-#include "rgb2rgb.h"
 #include "libavutil/mem.h"
 
+#include "libswscale/swscale.h"
+#include "libswscale/rgb2rgb.h"
+
 #define SIZE    1000
 #define srcByte 0x55
 #define dstByte 0xBB
diff --git a/libswscale/swscale-test.c b/libswscale/tests/swscale.c
similarity index 99%
rename from libswscale/swscale-test.c
rename to libswscale/tests/swscale.c
index 4d8d08b..58c2114 100644
--- a/libswscale/swscale-test.c
+++ b/libswscale/tests/swscale.c
@@ -31,7 +31,8 @@
 #include "libavutil/crc.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/lfg.h"
-#include "swscale.h"
+
+#include "libswscale/swscale.h"
 
 /* HACK Duplicated from swscale_internal.h.
  * Should be removed when a cleaner pixel format system exists. */
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 3d58080..c898695 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -221,7 +221,7 @@ pixfmts(){
     prefilter_chain=$2
     nframes=${3:-1}
 
-    showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
+    showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts"
     scale_exclude_fmts=${outfile}_scale_exclude_fmts
     scale_in_fmts=${outfile}_scale_in_fmts
     scale_out_fmts=${outfile}_scale_out_fmts
diff --git a/tests/fate/fft.mak b/tests/fate/fft.mak
index 244f426..f42dded 100644
--- a/tests/fate/fft.mak
+++ b/tests/fate/fft.mak
@@ -23,8 +23,8 @@ fate-rdft-float: $(FATE_RDFT-yes)
 
 FATE_FFT_ALL = $(FATE_DCT-yes) $(FATE_FFT-yes) $(FATE_MDCT-yes) $(FATE_RDFT-yes)
 
-$(FATE_FFT_ALL): libavcodec/fft-test$(EXESUF)
-$(FATE_FFT_ALL): CMD = run libavcodec/fft-test $(CPUFLAGS:%=-c%) $(ARGS)
+$(FATE_FFT_ALL): libavcodec/tests/fft$(EXESUF)
+$(FATE_FFT_ALL): CMD = run libavcodec/tests/fft $(CPUFLAGS:%=-c%) $(ARGS)
 
 define DEF_FFT_FIXED
 FATE_FFT_FIXED-$(CONFIG_FFT)   += fate-fft-fixed-$(1)  fate-ifft-fixed-$(1)
@@ -43,8 +43,8 @@ fate-mdct-fixed: $(FATE_MDCT_FIXED-yes)
 
 FATE_FFT_FIXED_ALL = $(FATE_FFT_FIXED-yes) $(FATE_MDCT_FIXED-yes)
 
-$(FATE_FFT_FIXED_ALL): libavcodec/fft-fixed-test$(EXESUF)
-$(FATE_FFT_FIXED_ALL): CMD = run libavcodec/fft-fixed-test $(CPUFLAGS:%=-c%) $(ARGS)
+$(FATE_FFT_FIXED_ALL): libavcodec/tests/fft-fixed$(EXESUF)
+$(FATE_FFT_FIXED_ALL): CMD = run libavcodec/tests/fft-fixed $(CPUFLAGS:%=-c%) $(ARGS)
 
 $(FATE_FFT_ALL) $(FATE_FFT_FIXED_ALL): REF = /dev/null
 
@@ -60,13 +60,13 @@ endef
 
 $(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT_FIXED32,$(N))))
 
-fate-fft-fixed32-test: $(FATE_FFT_FIXED32)
-$(FATE_FFT_FIXED32): libavcodec/fft-fixed32-test$(EXESUF)
-$(FATE_FFT_FIXED32): CMD = run libavcodec/fft-fixed32-test $(CPUFLAGS:%=-c%) $(ARGS)
+fate-fft-fixed32: $(FATE_FFT_FIXED32)
+$(FATE_FFT_FIXED32): libavcodec/tests/fft-fixed32$(EXESUF)
+$(FATE_FFT_FIXED32): CMD = run libavcodec/tests/fft-fixed32 $(CPUFLAGS:%=-c%) $(ARGS)
 $(FATE_FFT_FIXED32): REF = /dev/null
 
 fate-dct: fate-dct-float
-fate-fft: fate-fft-float fate-fft-fixed fate-fft-fixed32-test
+fate-fft: fate-fft-float fate-fft-fixed fate-fft-fixed32
 fate-mdct: fate-mdct-float fate-mdct-fixed
 fate-rdft: fate-rdft-float
 
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 2bdb644..6fe2095 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -174,8 +174,8 @@ fate-filter-hdcd: CMP = oneline
 fate-filter-hdcd: REF = 5db465a58d2fd0d06ca944b883b33476
 
 FATE_AFILTER-yes += fate-filter-formats
-fate-filter-formats: libavfilter/formats-test$(EXESUF)
-fate-filter-formats: CMD = run libavfilter/formats-test
+fate-filter-formats: libavfilter/tests/formats$(EXESUF)
+fate-filter-formats: CMD = run libavfilter/tests/formats
 
 FATE_SAMPLES_AVCONV += $(FATE_AFILTER_SAMPLES-yes)
 FATE_FFMPEG += $(FATE_AFILTER-yes)
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 4b17d59..0084802 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -585,7 +585,7 @@ fate-filter-pixfmts-tinterlace_pad: CMD = pixfmts "pad"
 FATE_FILTER_PIXFMTS-$(CONFIG_VFLIP_FILTER) += fate-filter-pixfmts-vflip
 fate-filter-pixfmts-vflip: CMD = pixfmts
 
-$(FATE_FILTER_PIXFMTS-yes): libavfilter/filtfmts-test$(EXESUF)
+$(FATE_FILTER_PIXFMTS-yes): libavfilter/tests/filtfmts$(EXESUF)
 FATE_FILTER_VSYNTH-$(CONFIG_FORMAT_FILTER) += $(FATE_FILTER_PIXFMTS-yes)
 
 fate-filter-pixfmts: $(FATE_FILTER_PIXFMTS-yes)
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 5aba2ee..cf25285 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -1,46 +1,46 @@
 FATE_LIBAVCODEC-$(CONFIG_CABAC) += fate-cabac
-fate-cabac: libavcodec/cabac-test$(EXESUF)
-fate-cabac: CMD = run libavcodec/cabac-test
+fate-cabac: libavcodec/tests/cabac$(EXESUF)
+fate-cabac: CMD = run libavcodec/tests/cabac
 fate-cabac: REF = /dev/null
 
 FATE_LIBAVCODEC-$(CONFIG_GOLOMB) += fate-golomb
-fate-golomb: libavcodec/golomb-test$(EXESUF)
-fate-golomb: CMD = run libavcodec/golomb-test
+fate-golomb: libavcodec/tests/golomb$(EXESUF)
+fate-golomb: CMD = run libavcodec/tests/golomb
 fate-golomb: REF = /dev/null
 
 FATE_LIBAVCODEC-$(CONFIG_IDCTDSP) += fate-idct8x8
-fate-idct8x8: libavcodec/dct-test$(EXESUF)
-fate-idct8x8: CMD = run libavcodec/dct-test -i
+fate-idct8x8: libavcodec/tests/dct$(EXESUF)
+fate-idct8x8: CMD = run libavcodec/tests/dct -i
 fate-idct8x8: CMP = null
 fate-idct8x8: REF = /dev/null
 
 FATE_LIBAVCODEC-$(CONFIG_IIRFILTER) += fate-iirfilter
-fate-iirfilter: libavcodec/iirfilter-test$(EXESUF)
-fate-iirfilter: CMD = run libavcodec/iirfilter-test
+fate-iirfilter: libavcodec/tests/iirfilter$(EXESUF)
+fate-iirfilter: CMD = run libavcodec/tests/iirfilter
 
 FATE_LIBAVCODEC-yes += fate-libavcodec-options
-fate-libavcodec-options: libavcodec/options-test$(EXESUF)
-fate-libavcodec-options: CMD = run libavcodec/options-test
+fate-libavcodec-options: libavcodec/tests/options$(EXESUF)
+fate-libavcodec-options: CMD = run libavcodec/tests/options
 
 FATE_LIBAVCODEC-$(CONFIG_RANGECODER) += fate-rangecoder
-fate-rangecoder: libavcodec/rangecoder-test$(EXESUF)
-fate-rangecoder: CMD = run libavcodec/rangecoder-test
+fate-rangecoder: libavcodec/tests/rangecoder$(EXESUF)
+fate-rangecoder: CMD = run libavcodec/tests/rangecoder
 fate-rangecoder: CMP = null
 fate-rangecoder: REF = /dev/null
 
 FATE_LIBAVCODEC-yes += fate-mathops
-fate-mathops: libavcodec/mathops-test$(EXESUF)
-fate-mathops: CMD = run libavcodec/mathops-test
+fate-mathops: libavcodec/tests/mathops$(EXESUF)
+fate-mathops: CMD = run libavcodec/tests/mathops
 fate-mathops: CMP = null
 fate-mathops: REF = /dev/null
 
 FATE_LIBAVCODEC-$(CONFIG_JPEG2000_ENCODER) += fate-j2k-dwt
-fate-j2k-dwt: libavcodec/jpeg2000dwt-test$(EXESUF)
-fate-j2k-dwt: CMD = run libavcodec/jpeg2000dwt-test
+fate-j2k-dwt: libavcodec/tests/jpeg2000dwt$(EXESUF)
+fate-j2k-dwt: CMD = run libavcodec/tests/jpeg2000dwt
 
 FATE_LIBAVCODEC-yes += fate-libavcodec-utils
-fate-libavcodec-utils: libavcodec/utils-test$(EXESUF)
-fate-libavcodec-utils: CMD = run libavcodec/utils-test
+fate-libavcodec-utils: libavcodec/tests/utils$(EXESUF)
+fate-libavcodec-utils: CMD = run libavcodec/tests/utils
 fate-libavcodec-utils: CMP = null
 fate-libavcodec-utils: REF = /dev/null
 
diff --git a/tests/fate/libavdevice.mak b/tests/fate/libavdevice.mak
index b30ae99..e983327 100644
--- a/tests/fate/libavdevice.mak
+++ b/tests/fate/libavdevice.mak
@@ -1,6 +1,6 @@
 FATE_LIBAVDEVICE-$(CONFIG_JACK_INDEV) += fate-timefilter
-fate-timefilter: libavdevice/timefilter-test$(EXESUF)
-fate-timefilter: CMD = run libavdevice/timefilter-test
+fate-timefilter: libavdevice/tests/timefilter$(EXESUF)
+fate-timefilter: CMD = run libavdevice/tests/timefilter
 
 FATE-$(CONFIG_AVDEVICE) += $(FATE_LIBAVDEVICE-yes)
 fate-libavdevice: $(FATE_LIBAVDEVICE-yes)
diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak
index f88d6fa..cf1ba18 100644
--- a/tests/fate/libavformat.mak
+++ b/tests/fate/libavformat.mak
@@ -1,26 +1,26 @@
 #FATE_LIBAVFORMAT-$(HAVE_PTHREADS) += fate-async
-#fate-async: libavformat/async-test$(EXESUF)
-#fate-async: CMD = run libavformat/async-test
+#fate-async: libavformat/tests/async$(EXESUF)
+#fate-async: CMD = run libavformat/tests/async
 
 FATE_LIBAVFORMAT-$(CONFIG_NETWORK) += fate-noproxy
-fate-noproxy: libavformat/noproxy-test$(EXESUF)
-fate-noproxy: CMD = run libavformat/noproxy-test
+fate-noproxy: libavformat/tests/noproxy$(EXESUF)
+fate-noproxy: CMD = run libavformat/tests/noproxy
 
 FATE_LIBAVFORMAT-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += fate-rtmpdh
-fate-rtmpdh: libavformat/rtmpdh-test$(EXESUF)
-fate-rtmpdh: CMD = run libavformat/rtmpdh-test
+fate-rtmpdh: libavformat/tests/rtmpdh$(EXESUF)
+fate-rtmpdh: CMD = run libavformat/tests/rtmpdh
 
 FATE_LIBAVFORMAT-$(CONFIG_SRTP) += fate-srtp
-fate-srtp: libavformat/srtp-test$(EXESUF)
-fate-srtp: CMD = run libavformat/srtp-test
+fate-srtp: libavformat/tests/srtp$(EXESUF)
+fate-srtp: CMD = run libavformat/tests/srtp
 
 FATE_LIBAVFORMAT-yes += fate-url
-fate-url: libavformat/url-test$(EXESUF)
-fate-url: CMD = run libavformat/url-test
+fate-url: libavformat/tests/url$(EXESUF)
+fate-url: CMD = run libavformat/tests/url
 
 FATE_LIBAVFORMAT-$(CONFIG_MOV_MUXER) += fate-movenc
-fate-movenc: libavformat/movenc-test$(EXESUF)
-fate-movenc: CMD = run libavformat/movenc-test
+fate-movenc: libavformat/tests/movenc$(EXESUF)
+fate-movenc: CMD = run libavformat/tests/movenc
 
 FATE_LIBAVFORMAT += $(FATE_LIBAVFORMAT-yes)
 FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT)
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 7f4fb7a..6fbad64 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -1,145 +1,145 @@
 FATE_LIBAVUTIL += fate-adler32
-fate-adler32: libavutil/adler32-test$(EXESUF)
-fate-adler32: CMD = run libavutil/adler32-test
+fate-adler32: libavutil/tests/adler32$(EXESUF)
+fate-adler32: CMD = run libavutil/tests/adler32
 fate-adler32: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-aes
-fate-aes: libavutil/aes-test$(EXESUF)
-fate-aes: CMD = run libavutil/aes-test
+fate-aes: libavutil/tests/aes$(EXESUF)
+fate-aes: CMD = run libavutil/tests/aes
 fate-aes: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-camellia
-fate-camellia: libavutil/camellia-test$(EXESUF)
-fate-camellia: CMD = run libavutil/camellia-test
+fate-camellia: libavutil/tests/camellia$(EXESUF)
+fate-camellia: CMD = run libavutil/tests/camellia
 fate-camellia: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-cast5
-fate-cast5: libavutil/cast5-test$(EXESUF)
-fate-cast5: CMD = run libavutil/cast5-test
+fate-cast5: libavutil/tests/cast5$(EXESUF)
+fate-cast5: CMD = run libavutil/tests/cast5
 fate-cast5: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-atomic
-fate-atomic: libavutil/atomic-test$(EXESUF)
-fate-atomic: CMD = run libavutil/atomic-test
+fate-atomic: libavutil/tests/atomic$(EXESUF)
+fate-atomic: CMD = run libavutil/tests/atomic
 fate-atomic: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-avstring
-fate-avstring: libavutil/avstring-test$(EXESUF)
-fate-avstring: CMD = run libavutil/avstring-test
+fate-avstring: libavutil/tests/avstring$(EXESUF)
+fate-avstring: CMD = run libavutil/tests/avstring
 
 FATE_LIBAVUTIL += fate-base64
-fate-base64: libavutil/base64-test$(EXESUF)
-fate-base64: CMD = run libavutil/base64-test
+fate-base64: libavutil/tests/base64$(EXESUF)
+fate-base64: CMD = run libavutil/tests/base64
 
 FATE_LIBAVUTIL += fate-blowfish
-fate-blowfish: libavutil/blowfish-test$(EXESUF)
-fate-blowfish: CMD = run libavutil/blowfish-test
+fate-blowfish: libavutil/tests/blowfish$(EXESUF)
+fate-blowfish: CMD = run libavutil/tests/blowfish
 
 FATE_LIBAVUTIL += fate-bprint
-fate-bprint: libavutil/bprint-test$(EXESUF)
-fate-bprint: CMD = run libavutil/bprint-test
+fate-bprint: libavutil/tests/bprint$(EXESUF)
+fate-bprint: CMD = run libavutil/tests/bprint
 
 FATE_LIBAVUTIL += fate-cpu
-fate-cpu: libavutil/cpu-test$(EXESUF)
-fate-cpu: CMD = runecho libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%)
+fate-cpu: libavutil/tests/cpu$(EXESUF)
+fate-cpu: CMD = runecho libavutil/tests/cpu $(CPUFLAGS:%=-c%) $(THREADS:%=-t%)
 fate-cpu: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-crc
-fate-crc: libavutil/crc-test$(EXESUF)
-fate-crc: CMD = run libavutil/crc-test
+fate-crc: libavutil/tests/crc$(EXESUF)
+fate-crc: CMD = run libavutil/tests/crc
 
 FATE_LIBAVUTIL += fate-color_utils
-fate-color_utils: libavutil/color_utils-test$(EXESUF)
-fate-color_utils: CMD = run libavutil/color_utils-test
+fate-color_utils: libavutil/tests/color_utils$(EXESUF)
+fate-color_utils: CMD = run libavutil/tests/color_utils
 
 FATE_LIBAVUTIL += fate-des
-fate-des: libavutil/des-test$(EXESUF)
-fate-des: CMD = run libavutil/des-test
+fate-des: libavutil/tests/des$(EXESUF)
+fate-des: CMD = run libavutil/tests/des
 fate-des: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-dict
-fate-dict: libavutil/dict-test$(EXESUF)
-fate-dict: CMD = run libavutil/dict-test
+fate-dict: libavutil/tests/dict$(EXESUF)
+fate-dict: CMD = run libavutil/tests/dict
 
 FATE_LIBAVUTIL += fate-eval
-fate-eval: libavutil/eval-test$(EXESUF)
-fate-eval: CMD = run libavutil/eval-test
+fate-eval: libavutil/tests/eval$(EXESUF)
+fate-eval: CMD = run libavutil/tests/eval
 
 FATE_LIBAVUTIL += fate-fifo
-fate-fifo: libavutil/fifo-test$(EXESUF)
-fate-fifo: CMD = run libavutil/fifo-test
+fate-fifo: libavutil/tests/fifo$(EXESUF)
+fate-fifo: CMD = run libavutil/tests/fifo
 
 FATE_LIBAVUTIL += fate-float-dsp
-fate-float-dsp: libavutil/float_dsp-test$(EXESUF)
-fate-float-dsp: CMD = run libavutil/float_dsp-test $(CPUFLAGS:%=-c%)
+fate-float-dsp: libavutil/tests/float_dsp$(EXESUF)
+fate-float-dsp: CMD = run libavutil/tests/float_dsp $(CPUFLAGS:%=-c%)
 fate-float-dsp: CMP = null
 fate-float-dsp: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-hash
-fate-hash: libavutil/hash-test$(EXESUF)
-fate-hash: CMD = run libavutil/hash-test
+fate-hash: libavutil/tests/hash$(EXESUF)
+fate-hash: CMD = run libavutil/tests/hash
 
 FATE_LIBAVUTIL += fate-hmac
-fate-hmac: libavutil/hmac-test$(EXESUF)
-fate-hmac: CMD = run libavutil/hmac-test
+fate-hmac: libavutil/tests/hmac$(EXESUF)
+fate-hmac: CMD = run libavutil/tests/hmac
 
 FATE_LIBAVUTIL += fate-md5
-fate-md5: libavutil/md5-test$(EXESUF)
-fate-md5: CMD = run libavutil/md5-test
+fate-md5: libavutil/tests/md5$(EXESUF)
+fate-md5: CMD = run libavutil/tests/md5
 
 FATE_LIBAVUTIL += fate-murmur3
-fate-murmur3: libavutil/murmur3-test$(EXESUF)
-fate-murmur3: CMD = run libavutil/murmur3-test
+fate-murmur3: libavutil/tests/murmur3$(EXESUF)
+fate-murmur3: CMD = run libavutil/tests/murmur3
 
 FATE_LIBAVUTIL += fate-parseutils
-fate-parseutils: libavutil/parseutils-test$(EXESUF)
-fate-parseutils: CMD = run libavutil/parseutils-test
+fate-parseutils: libavutil/tests/parseutils$(EXESUF)
+fate-parseutils: CMD = run libavutil/tests/parseutils
 
 FATE_LIBAVUTIL-$(CONFIG_PIXELUTILS) += fate-pixelutils
-fate-pixelutils: libavutil/pixelutils-test$(EXESUF)
-fate-pixelutils: CMD = run libavutil/pixelutils-test
+fate-pixelutils: libavutil/tests/pixelutils$(EXESUF)
+fate-pixelutils: CMD = run libavutil/tests/pixelutils
 
 FATE_LIBAVUTIL += fate-display
-fate-display: libavutil/display-test$(EXESUF)
-fate-display: CMD = run libavutil/display-test
+fate-display: libavutil/tests/display$(EXESUF)
+fate-display: CMD = run libavutil/tests/display
 
 FATE_LIBAVUTIL += fate-random_seed
-fate-random_seed: libavutil/random_seed-test$(EXESUF)
-fate-random_seed: CMD = run libavutil/random_seed-test
+fate-random_seed: libavutil/tests/random_seed$(EXESUF)
+fate-random_seed: CMD = run libavutil/tests/random_seed
 
 FATE_LIBAVUTIL += fate-ripemd
-fate-ripemd: libavutil/ripemd-test$(EXESUF)
-fate-ripemd: CMD = run libavutil/ripemd-test
+fate-ripemd: libavutil/tests/ripemd$(EXESUF)
+fate-ripemd: CMD = run libavutil/tests/ripemd
 
 FATE_LIBAVUTIL += fate-sha
-fate-sha: libavutil/sha-test$(EXESUF)
-fate-sha: CMD = run libavutil/sha-test
+fate-sha: libavutil/tests/sha$(EXESUF)
+fate-sha: CMD = run libavutil/tests/sha
 
 FATE_LIBAVUTIL += fate-sha512
-fate-sha512: libavutil/sha512-test$(EXESUF)
-fate-sha512: CMD = run libavutil/sha512-test
+fate-sha512: libavutil/tests/sha512$(EXESUF)
+fate-sha512: CMD = run libavutil/tests/sha512
 
 FATE_LIBAVUTIL += fate-tree
-fate-tree: libavutil/tree-test$(EXESUF)
-fate-tree: CMD = run libavutil/tree-test
+fate-tree: libavutil/tests/tree$(EXESUF)
+fate-tree: CMD = run libavutil/tests/tree
 fate-tree: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-twofish
-fate-twofish: libavutil/twofish-test$(EXESUF)
-fate-twofish: CMD = run libavutil/twofish-test
+fate-twofish: libavutil/tests/twofish$(EXESUF)
+fate-twofish: CMD = run libavutil/tests/twofish
 fate-twofish: REF = /dev/null
 
 FATE_LIBAVUTIL += fate-xtea
-fate-xtea: libavutil/xtea-test$(EXESUF)
-fate-xtea: CMD = run libavutil/xtea-test
+fate-xtea: libavutil/tests/xtea$(EXESUF)
+fate-xtea: CMD = run libavutil/tests/xtea
 
 FATE_LIBAVUTIL += fate-tea
-fate-tea: libavutil/tea-test$(EXESUF)
-fate-tea: CMD = run libavutil/tea-test
+fate-tea: libavutil/tests/tea$(EXESUF)
+fate-tea: CMD = run libavutil/tests/tea
 
 FATE_LIBAVUTIL += fate-opt
-fate-opt: libavutil/opt-test$(EXESUF)
-fate-opt: CMD = run libavutil/opt-test
+fate-opt: libavutil/tests/opt$(EXESUF)
+fate-opt: CMD = run libavutil/tests/opt
 
 FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
 FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
diff --git a/tests/fate/seek.mak b/tests/fate/seek.mak
index 6e4df91..f120f56 100644
--- a/tests/fate/seek.mak
+++ b/tests/fate/seek.mak
@@ -245,13 +245,13 @@ FATE_SEEK += $(FATE_SEEK_LAVF-yes:%=fate-seek-lavf-%)
 
 FATE_SEEK_EXTRA-$(CONFIG_MP3_DEMUXER)   += fate-seek-extra-mp3
 FATE_SEEK_EXTRA-$(call ALLYES, CACHE_PROTOCOL PIPE_PROTOCOL MP3_DEMUXER) += fate-seek-cache-pipe
-fate-seek-extra-mp3:  CMD = run libavformat/seek-test$(EXESUF) $(TARGET_SAMPLES)/gapless/gapless.mp3 -fastseek 1
-fate-seek-cache-pipe: CMD = cat $(TARGET_SAMPLES)/gapless/gapless.mp3 | run libavformat/seek-test$(EXESUF) cache:pipe:0 -read_ahead_limit -1
+fate-seek-extra-mp3:  CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_SAMPLES)/gapless/gapless.mp3 -fastseek 1
+fate-seek-cache-pipe: CMD = cat $(TARGET_SAMPLES)/gapless/gapless.mp3 | run libavformat/tests/seek$(EXESUF) cache:pipe:0 -read_ahead_limit -1
 FATE_SEEK_EXTRA += $(FATE_SEEK_EXTRA-yes)
 
 
-$(FATE_SEEK) $(FATE_SAMPLES_SEEK) $(FATE_SEEK_EXTRA): libavformat/seek-test$(EXESUF)
-$(FATE_SEEK) $(FATE_SAMPLES_SEEK): CMD = run libavformat/seek-test$(EXESUF) $(TARGET_PATH)/tests/data/$(SRC)
+$(FATE_SEEK) $(FATE_SAMPLES_SEEK) $(FATE_SEEK_EXTRA): libavformat/tests/seek$(EXESUF)
+$(FATE_SEEK) $(FATE_SAMPLES_SEEK): CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_PATH)/tests/data/$(SRC)
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK): fate-seek-%: fate-%
 fate-seek-%: REF = $(SRC_PATH)/tests/ref/seek/$(@:fate-seek-%=%)
 


======================================================================

diff --cc .gitignore
index 0eca7a1,5464bba..2b251c9
--- a/.gitignore
+++ b/.gitignore
@@@ -18,18 -17,12 +18,17 @@@
  *.so.*
  *.swp
  *.ver
- *-test
 +*_g
 +\#*
 +.\#*
  /.config
  /.version
 -/avconv
 -/avplay
 -/avprobe
 -/avversion.h
 +/ffmpeg
 +/ffplay
 +/ffprobe
 +/ffserver
  /config.*
  /coverage.info
 +/avversion.h
  /lcov/
 +/src
diff --cc common.mak
index 700e4c1,d62f899..59b039f
--- a/common.mak
+++ b/common.mak
@@@ -113,9 -15,8 +113,9 @@@ LDLIBS       = $(FFLIBS:%=%$(BUILDSUF)
  FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
  
  OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
 +SLIBOBJS  := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
- TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
- TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
+ TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
+ TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
  HOSTOBJS  := $(HOSTPROGS:%=$(SUBDIR)%.o)
  HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
  TOOLS     += $(TOOLS-yes)
diff --cc libavcodec/tests/.gitignore
index 0000000,31fa59b..d8ab947
mode 000000,100644..100644
--- a/libavcodec/tests/.gitignore
+++ b/libavcodec/tests/.gitignore
@@@ -1,0 -1,6 +1,16 @@@
++/avfft
++/cabac
+ /dct
+ /fft
+ /fft-fixed
++/fft-fixed32
+ /golomb
+ /iirfilter
++/imgconvert
++/jpeg2000dwt
++/mathops
++/motion
++/options
+ /rangecoder
++/snowenc
++/utils
diff --cc libavcodec/tests/avfft.c
index c2d4cc4,0000000..6bc48ea
mode 100644,000000..100644
--- a/libavcodec/tests/avfft.c
+++ b/libavcodec/tests/avfft.c
@@@ -1,53 -1,0 +1,53 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include "config.h"
 +#include "libavutil/mem.h"
- #include "avfft.h"
++#include "libavcodec/avfft.h"
 +
 +int main(int argc, char **argv)
 +{
 +    int i;
 +#define LEN 1024
 +    FFTSample *ref  = av_malloc_array(LEN, sizeof(*ref));
 +    FFTSample *data = av_malloc_array(LEN, sizeof(*data));
 +    RDFTContext *rdft_context  = av_rdft_init(10, DFT_R2C);
 +    RDFTContext *irdft_context = av_rdft_init(10, IDFT_C2R);
 +
 +    if (!ref || !data || !rdft_context || !irdft_context)
 +        return 2;
 +    for (i=0; i<LEN; i++) {
 +        ref[i] = data[i] = i*456 + 123 + i*i;
 +    }
 +    av_rdft_calc(rdft_context, data);
 +    av_rdft_calc(irdft_context, data);
 +
 +    for (i=0; i<LEN; i++) {
 +        if (fabs(ref[i] - data[i]/LEN*2) > 1) {
 +            fprintf(stderr, "Failed at %d (%f %f)\n", i, ref[i], data[i]/LEN*2);
 +            return 1;
 +        }
 +    }
 +
 +    av_rdft_end(rdft_context);
 +    av_rdft_end(irdft_context);
 +    av_free(data);
 +    av_free(ref);
 +
 +    return 0;
 +}
diff --cc libavcodec/tests/cabac.c
index 47f31e9,0000000..affe4eb
mode 100644,000000..100644
--- a/libavcodec/tests/cabac.c
+++ b/libavcodec/tests/cabac.c
@@@ -1,165 -1,0 +1,165 @@@
 +/*
 + * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "cabac.c"
++#include "libavcodec/cabac.c"
 +
 +#define SIZE 10240
 +
 +#include "libavutil/lfg.h"
- #include "avcodec.h"
++#include "libavcodec/avcodec.h"
 +
 +static inline void put_cabac_bit(CABACContext *c, int b){
 +    put_bits(&c->pb, 1, b);
 +    for(;c->outstanding_count; c->outstanding_count--){
 +        put_bits(&c->pb, 1, 1-b);
 +    }
 +}
 +
 +static inline void renorm_cabac_encoder(CABACContext *c){
 +    while(c->range < 0x100){
 +        //FIXME optimize
 +        if(c->low<0x100){
 +            put_cabac_bit(c, 0);
 +        }else if(c->low<0x200){
 +            c->outstanding_count++;
 +            c->low -= 0x100;
 +        }else{
 +            put_cabac_bit(c, 1);
 +            c->low -= 0x200;
 +        }
 +
 +        c->range+= c->range;
 +        c->low += c->low;
 +    }
 +}
 +
 +static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
 +    int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state];
 +
 +    if(bit == ((*state)&1)){
 +        c->range -= RangeLPS;
 +        *state    = ff_h264_mlps_state[128 + *state];
 +    }else{
 +        c->low += c->range - RangeLPS;
 +        c->range = RangeLPS;
 +        *state= ff_h264_mlps_state[127 - *state];
 +    }
 +
 +    renorm_cabac_encoder(c);
 +}
 +
 +/**
 + * @param bit 0 -> write zero bit, !=0 write one bit
 + */
 +static void put_cabac_bypass(CABACContext *c, int bit){
 +    c->low += c->low;
 +
 +    if(bit){
 +        c->low += c->range;
 +    }
 +//FIXME optimize
 +    if(c->low<0x200){
 +        put_cabac_bit(c, 0);
 +    }else if(c->low<0x400){
 +        c->outstanding_count++;
 +        c->low -= 0x200;
 +    }else{
 +        put_cabac_bit(c, 1);
 +        c->low -= 0x400;
 +    }
 +}
 +
 +/**
 + *
 + * @return the number of bytes written
 + */
 +static int put_cabac_terminate(CABACContext *c, int bit){
 +    c->range -= 2;
 +
 +    if(!bit){
 +        renorm_cabac_encoder(c);
 +    }else{
 +        c->low += c->range;
 +        c->range= 2;
 +
 +        renorm_cabac_encoder(c);
 +
 +        av_assert0(c->low <= 0x1FF);
 +        put_cabac_bit(c, c->low>>9);
 +        put_bits(&c->pb, 2, ((c->low>>7)&3)|1);
 +
 +        flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
 +    }
 +
 +    return (put_bits_count(&c->pb)+7)>>3;
 +}
 +
 +int main(void){
 +    CABACContext c;
 +    uint8_t b[9*SIZE];
 +    uint8_t r[9*SIZE];
 +    int i, ret = 0;
 +    uint8_t state[10]= {0};
 +    AVLFG prng;
 +
 +    av_lfg_init(&prng, 1);
 +    ff_init_cabac_encoder(&c, b, SIZE);
 +
 +    for(i=0; i<SIZE; i++){
 +        if(2*i<SIZE) r[i] = av_lfg_get(&prng) % 7;
 +        else         r[i] = (i>>8)&1;
 +    }
 +
 +    for(i=0; i<SIZE; i++){
 +        put_cabac_bypass(&c, r[i]&1);
 +    }
 +
 +    for(i=0; i<SIZE; i++){
 +        put_cabac(&c, state, r[i]&1);
 +    }
 +
 +    i= put_cabac_terminate(&c, 1);
 +    b[i++] = av_lfg_get(&prng);
 +    b[i  ] = av_lfg_get(&prng);
 +
 +    ff_init_cabac_decoder(&c, b, SIZE);
 +
 +    memset(state, 0, sizeof(state));
 +
 +    for(i=0; i<SIZE; i++){
 +        if( (r[i]&1) != get_cabac_bypass(&c) ) {
 +            av_log(NULL, AV_LOG_ERROR, "CABAC bypass failure at %d\n", i);
 +            ret = 1;
 +        }
 +    }
 +
 +    for(i=0; i<SIZE; i++){
 +        if( (r[i]&1) != get_cabac_noinline(&c, state) ) {
 +            av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
 +            ret = 1;
 +        }
 +    }
 +    if(!get_cabac_terminate(&c)) {
 +        av_log(NULL, AV_LOG_ERROR, "where's the Terminator?\n");
 +        ret = 1;
 +    }
 +
 +    return ret;
 +}
diff --cc libavcodec/tests/dct.c
index df1b75d,6c6a4e0..5303fdf
--- a/libavcodec/tests/dct.c
+++ b/libavcodec/tests/dct.c
@@@ -39,14 -40,14 +40,14 @@@
  #include "libavutil/lfg.h"
  #include "libavutil/time.h"
  
- #include "dct.h"
- #include "idctdsp.h"
- #include "simple_idct.h"
- #include "xvididct.h"
- #include "aandcttab.h"
- #include "faandct.h"
- #include "faanidct.h"
- #include "dctref.h"
 -#include "libavcodec/aandcttab.h"
+ #include "libavcodec/dct.h"
 -#include "libavcodec/dctref.h"
 -#include "libavcodec/faandct.h"
 -#include "libavcodec/faanidct.h"
+ #include "libavcodec/idctdsp.h"
+ #include "libavcodec/simple_idct.h"
+ #include "libavcodec/xvididct.h"
++#include "libavcodec/aandcttab.h"
++#include "libavcodec/faandct.h"
++#include "libavcodec/faanidct.h"
++#include "libavcodec/dctref.h"
  
  struct algo {
      const char *name;
diff --cc libavcodec/tests/fft-fixed32.c
index 4bd11ce,0000000..f33494f
mode 100644,000000..100644
--- a/libavcodec/tests/fft-fixed32.c
+++ b/libavcodec/tests/fft-fixed32.c
@@@ -1,21 -1,0 +1,21 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#define FFT_FLOAT 0
 +#define FFT_FIXED_32 1
- #include "fft-test.c"
++#include "fft.c"
diff --cc libavcodec/tests/golomb.c
index 2dfe917,7587402..965367b
--- a/libavcodec/tests/golomb.c
+++ b/libavcodec/tests/golomb.c
@@@ -23,9 -21,9 +23,9 @@@
  
  #include "libavutil/mem.h"
  
- #include "get_bits.h"
- #include "golomb.h"
- #include "put_bits.h"
+ #include "libavcodec/get_bits.h"
 -#include "libavcodec/put_bits.h"
+ #include "libavcodec/golomb.h"
++#include "libavcodec/put_bits.h"
  
  #define COUNT 8191
  #define SIZE (COUNT * 4)
diff --cc libavcodec/tests/imgconvert.c
index 96004d7,0000000..c598d46
mode 100644,000000..100644
--- a/libavcodec/tests/imgconvert.c
+++ b/libavcodec/tests/imgconvert.c
@@@ -1,50 -1,0 +1,50 @@@
 +/*
 + * Misc image conversion routines
 + * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "imgconvert.c"
++#include "libavcodec/imgconvert.c"
 +
 +#if FF_API_AVPICTURE
 +FF_DISABLE_DEPRECATION_WARNINGS
 +int main(void){
 +    int i;
 +    int err=0;
 +    int skip = 0;
 +
 +    for (i=0; i<AV_PIX_FMT_NB*2; i++) {
 +        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
 +        if(!desc || !desc->name) {
 +            skip ++;
 +            continue;
 +        }
 +        if (skip) {
 +            av_log(NULL, AV_LOG_INFO, "%3d unused pixel format values\n", skip);
 +            skip = 0;
 +        }
 +        av_log(NULL, AV_LOG_INFO, "pix fmt %s yuv_plan:%d avg_bpp:%d\n", desc->name, is_yuv_planar(desc), av_get_padded_bits_per_pixel(desc));
 +        if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) != (desc->nb_components != 2 && desc->nb_components != 4)) {
 +            av_log(NULL, AV_LOG_ERROR, "Alpha flag mismatch\n");
 +            err = 1;
 +        }
 +    }
 +    return err;
 +}
 +FF_ENABLE_DEPRECATION_WARNINGS
 +#endif /* FF_API_AVPICTURE */
diff --cc libavcodec/tests/jpeg2000dwt.c
index 30f1ce1,0000000..80b33be
mode 100644,000000..100644
--- a/libavcodec/tests/jpeg2000dwt.c
+++ b/libavcodec/tests/jpeg2000dwt.c
@@@ -1,141 -1,0 +1,141 @@@
 +/*
 + * Discrete wavelet transform
 + * Copyright (c) 2007 Kamil Nowosad
 + * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu at gmail.com>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "jpeg2000dwt.c"
++#include "libavcodec/jpeg2000dwt.c"
 +
 +#include "libavutil/lfg.h"
 +
 +#define MAX_W 256
 +
 +static int test_dwt(int *array, int *ref, int border[2][2], int decomp_levels, int type, int max_diff) {
 +    int ret, j;
 +    DWTContext s1={{{0}}}, *s= &s1;
 +    int64_t err2 = 0;
 +
 +    ret = ff_jpeg2000_dwt_init(s,  border, decomp_levels, type);
 +    if (ret < 0) {
 +        fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
 +        return 1;
 +    }
 +    ret = ff_dwt_encode(s, array);
 +    if (ret < 0) {
 +        fprintf(stderr, "ff_dwt_encode failed\n");
 +        return 1;
 +    }
 +    ret = ff_dwt_decode(s, array);
 +    if (ret < 0) {
 +        fprintf(stderr, "ff_dwt_encode failed\n");
 +        return 1;
 +    }
 +    for (j = 0; j<MAX_W * MAX_W; j++) {
 +        if (FFABS(array[j] - ref[j]) > max_diff) {
 +            fprintf(stderr, "missmatch at %d (%d != %d) decomp:%d border %d %d %d %d\n",
 +                    j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]);
 +            return 2;
 +        }
 +        err2 += (array[j] - ref[j]) * (array[j] - ref[j]);
 +        array[j] = ref[j];
 +    }
 +    ff_dwt_destroy(s);
 +
 +    printf("%s, decomp:%2d border %3d %3d %3d %3d milli-err2:%9"PRId64"\n",
 +           type == FF_DWT53 ? "5/3i" : "9/7i",
 +           decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1],
 +           1000*err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0])));
 +
 +    return 0;
 +}
 +
 +static int test_dwtf(float *array, float *ref, int border[2][2], int decomp_levels, float max_diff) {
 +    int ret, j;
 +    DWTContext s1={{{0}}}, *s= &s1;
 +    double err2 = 0;
 +
 +    ret = ff_jpeg2000_dwt_init(s,  border, decomp_levels, FF_DWT97);
 +    if (ret < 0) {
 +        fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
 +        return 1;
 +    }
 +    ret = ff_dwt_encode(s, array);
 +    if (ret < 0) {
 +        fprintf(stderr, "ff_dwt_encode failed\n");
 +        return 1;
 +    }
 +    ret = ff_dwt_decode(s, array);
 +    if (ret < 0) {
 +        fprintf(stderr, "ff_dwt_encode failed\n");
 +        return 1;
 +    }
 +    for (j = 0; j<MAX_W * MAX_W; j++) {
 +        if (FFABS(array[j] - ref[j]) > max_diff) {
 +            fprintf(stderr, "missmatch at %d (%f != %f) decomp:%d border %d %d %d %d\n",
 +                    j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]);
 +            return 2;
 +        }
 +        err2 += (array[j] - ref[j]) * (array[j] - ref[j]);
 +        array[j] = ref[j];
 +    }
 +    ff_dwt_destroy(s);
 +
 +    printf("9/7f, decomp:%2d border %3d %3d %3d %3d err2:%20.3f\n",
 +           decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1],
 +           err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0])));
 +
 +    return 0;
 +}
 +
 +static int array[MAX_W * MAX_W];
 +static int ref  [MAX_W * MAX_W];
 +static float arrayf[MAX_W * MAX_W];
 +static float reff  [MAX_W * MAX_W];
 +
 +int main(void) {
 +    AVLFG prng;
 +    int i,j;
 +    int border[2][2];
 +    int ret, decomp_levels;
 +
 +    av_lfg_init(&prng, 1);
 +
 +    for (i = 0; i<MAX_W * MAX_W; i++)
 +        arrayf[i] = reff[i] = array[i] = ref[i] =  av_lfg_get(&prng) % 2048;
 +
 +    for (i = 0; i < 100; i++) {
 +        for (j=0; j<4; j++)
 +            border[j>>1][j&1] = av_lfg_get(&prng) % MAX_W;
 +        if (border[0][0] >= border[0][1] || border[1][0] >= border[1][1])
 +            continue;
 +        decomp_levels = av_lfg_get(&prng) % FF_DWT_MAX_DECLVLS;
 +
 +        ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53, 0);
 +        if (ret)
 +            return ret;
 +        ret = test_dwt(array, ref, border, decomp_levels, FF_DWT97_INT, FFMIN(7+5*decomp_levels, 15+3*decomp_levels));
 +        if (ret)
 +            return ret;
 +        ret = test_dwtf(arrayf, reff, border, decomp_levels, 0.05);
 +        if (ret)
 +            return ret;
 +    }
 +
 +    return 0;
 +}
diff --cc libavcodec/tests/mathops.c
index d47f144,0000000..33a059c
mode 100644,000000..100644
--- a/libavcodec/tests/mathops.c
+++ b/libavcodec/tests/mathops.c
@@@ -1,41 -1,0 +1,41 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "mathops.h"
++#include "libavcodec/mathops.h"
 +
 +#include <stdlib.h>
 +
 +int main(void)
 +{
 +    unsigned u;
 +
 +    for(u=0; u<65536; u++) {
 +        unsigned s = u*u;
 +        unsigned root = ff_sqrt(s);
 +        unsigned root_m1 = ff_sqrt(s-1);
 +        if (s && root != u) {
 +            fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
 +            return 1;
 +        }
 +        if (u && root_m1 != u - 1) {
 +            fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
 +            return 1;
 +        }
 +    }
 +    return 0;
 +}
diff --cc libavcodec/tests/motion.c
index ebcf4aa,0000000..d89f940
mode 100644,000000..100644
--- a/libavcodec/tests/motion.c
+++ b/libavcodec/tests/motion.c
@@@ -1,152 -1,0 +1,152 @@@
 +/*
 + * (c) 2001 Fabrice Bellard
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +/**
 + * @file
 + * motion test.
 + */
 +
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <string.h>
 +
 +#include "config.h"
- #include "me_cmp.h"
++#include "libavcodec/me_cmp.h"
 +#include "libavutil/internal.h"
 +#include "libavutil/lfg.h"
 +#include "libavutil/mem.h"
 +#include "libavutil/time.h"
 +
 +#undef printf
 +
 +#define WIDTH 64
 +#define HEIGHT 64
 +
 +static uint8_t img1[WIDTH * HEIGHT];
 +static uint8_t img2[WIDTH * HEIGHT];
 +
 +static void fill_random(uint8_t *tab, int size)
 +{
 +    int i;
 +    AVLFG prng;
 +
 +    av_lfg_init(&prng, 1);
 +    for(i=0;i<size;i++) {
 +        tab[i] = av_lfg_get(&prng) % 256;
 +    }
 +}
 +
 +static void help(void)
 +{
 +    printf("motion-test [-h]\n"
 +           "test motion implementations\n");
 +}
 +
 +#define NB_ITS 500
 +
 +int dummy;
 +
 +static void test_motion(const char *name,
 +                 me_cmp_func test_func, me_cmp_func ref_func)
 +{
 +    int x, y, d1, d2, it;
 +    uint8_t *ptr;
 +    int64_t ti;
 +    printf("testing '%s'\n", name);
 +
 +    /* test correctness */
 +    for(it=0;it<20;it++) {
 +
 +        fill_random(img1, WIDTH * HEIGHT);
 +        fill_random(img2, WIDTH * HEIGHT);
 +
 +        for(y=0;y<HEIGHT-17;y++) {
 +            for(x=0;x<WIDTH-17;x++) {
 +                ptr = img2 + y * WIDTH + x;
 +                d1 = test_func(NULL, img1, ptr, WIDTH, 8);
 +                d2 = ref_func(NULL, img1, ptr, WIDTH, 8);
 +                if (d1 != d2) {
 +                    printf("error: mmx=%d c=%d\n", d1, d2);
 +                }
 +            }
 +        }
 +    }
 +    emms_c();
 +
 +    /* speed test */
 +    ti = av_gettime_relative();
 +    d1 = 0;
 +    for(it=0;it<NB_ITS;it++) {
 +        for(y=0;y<HEIGHT-17;y++) {
 +            for(x=0;x<WIDTH-17;x++) {
 +                ptr = img2 + y * WIDTH + x;
 +                d1 += test_func(NULL, img1, ptr, WIDTH, 8);
 +            }
 +        }
 +    }
 +    emms_c();
 +    dummy = d1; /* avoid optimization */
 +    ti = av_gettime_relative() - ti;
 +
 +    printf("  %0.0f kop/s\n",
 +           (double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) /
 +           (double)(ti / 1000.0));
 +}
 +
 +
 +int main(int argc, char **argv)
 +{
 +    AVCodecContext *ctx;
 +    int c;
 +    MECmpContext cctx, mmxctx;
 +    int flags[2] = { AV_CPU_FLAG_MMX, AV_CPU_FLAG_MMXEXT };
 +    int flags_size = HAVE_MMXEXT ? 2 : 1;
 +
 +    if (argc > 1) {
 +        help();
 +        return 1;
 +    }
 +
 +    printf("ffmpeg motion test\n");
 +
 +    ctx = avcodec_alloc_context3(NULL);
 +    ctx->flags |= AV_CODEC_FLAG_BITEXACT;
 +    av_force_cpu_flags(0);
 +    memset(&cctx, 0, sizeof(cctx));
 +    ff_me_cmp_init(&cctx, ctx);
 +    for (c = 0; c < flags_size; c++) {
 +        int x;
 +        av_force_cpu_flags(flags[c]);
 +        memset(&mmxctx, 0, sizeof(mmxctx));
 +        ff_me_cmp_init(&mmxctx, ctx);
 +
 +        for (x = 0; x < 2; x++) {
 +            printf("%s for %dx%d pixels\n", c ? "mmx2" : "mmx",
 +                   x ? 8 : 16, x ? 8 : 16);
 +            test_motion("mmx",     mmxctx.pix_abs[x][0], cctx.pix_abs[x][0]);
 +            test_motion("mmx_x2",  mmxctx.pix_abs[x][1], cctx.pix_abs[x][1]);
 +            test_motion("mmx_y2",  mmxctx.pix_abs[x][2], cctx.pix_abs[x][2]);
 +            test_motion("mmx_xy2", mmxctx.pix_abs[x][3], cctx.pix_abs[x][3]);
 +        }
 +    }
 +    av_free(ctx);
 +
 +    return 0;
 +}
diff --cc libavcodec/tests/options.c
index 0b064e6,0000000..7f0ee1d
mode 100644,000000..100644
--- a/libavcodec/tests/options.c
+++ b/libavcodec/tests/options.c
@@@ -1,194 -1,0 +1,194 @@@
 +/*
 + * Copyright (c) 2001 Fabrice Bellard
 + * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "options.c"
++#include "libavcodec/options.c"
 +
 +static int dummy_init(AVCodecContext *ctx)
 +{
 +    //TODO: this code should set every possible pointer that could be set by codec and is not an option;
 +    ctx->extradata_size = 8;
 +    ctx->extradata = av_malloc(ctx->extradata_size);
 +    return 0;
 +}
 +
 +static int dummy_close(AVCodecContext *ctx)
 +{
 +    av_freep(&ctx->extradata);
 +    ctx->extradata_size = 0;
 +    return 0;
 +}
 +
 +static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 +{
 +    return AVERROR(ENOSYS);
 +}
 +
 +typedef struct Dummy12Context {
 +    AVClass  *av_class;
 +    int      num;
 +    char*    str;
 +} Dummy12Context;
 +
 +typedef struct Dummy3Context {
 +    void     *fake_av_class;
 +    int      num;
 +    char*    str;
 +} Dummy3Context;
 +
 +#define OFFSET(x) offsetof(Dummy12Context, x)
 +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 +static const AVOption dummy_options[] = {
 +    { "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src default value" }, 0, 0, VE},
 +    { "num", "set num", OFFSET(num), AV_OPT_TYPE_INT,    { .i64 = 1500100900 },    0, INT_MAX, VE},
 +    { NULL },
 +};
 +
 +static const AVClass dummy_v1_class = {
 +    .class_name = "dummy_v1_class",
 +    .item_name  = av_default_item_name,
 +    .option     = dummy_options,
 +    .version    = LIBAVUTIL_VERSION_INT,
 +};
 +
 +static const AVClass dummy_v2_class = {
 +    .class_name = "dummy_v2_class",
 +    .item_name  = av_default_item_name,
 +    .option     = dummy_options,
 +    .version    = LIBAVUTIL_VERSION_INT,
 +};
 +
 +/* codec with options */
 +static AVCodec dummy_v1_encoder = {
 +    .name             = "dummy_v1_codec",
 +    .type             = AVMEDIA_TYPE_VIDEO,
 +    .id               = AV_CODEC_ID_NONE - 1,
 +    .encode2          = dummy_encode,
 +    .init             = dummy_init,
 +    .close            = dummy_close,
 +    .priv_class       = &dummy_v1_class,
 +    .priv_data_size   = sizeof(Dummy12Context),
 +};
 +
 +/* codec with options, different class */
 +static AVCodec dummy_v2_encoder = {
 +    .name             = "dummy_v2_codec",
 +    .type             = AVMEDIA_TYPE_VIDEO,
 +    .id               = AV_CODEC_ID_NONE - 2,
 +    .encode2          = dummy_encode,
 +    .init             = dummy_init,
 +    .close            = dummy_close,
 +    .priv_class       = &dummy_v2_class,
 +    .priv_data_size   = sizeof(Dummy12Context),
 +};
 +
 +/* codec with priv data, but no class */
 +static AVCodec dummy_v3_encoder = {
 +    .name             = "dummy_v3_codec",
 +    .type             = AVMEDIA_TYPE_VIDEO,
 +    .id               = AV_CODEC_ID_NONE - 3,
 +    .encode2          = dummy_encode,
 +    .init             = dummy_init,
 +    .close            = dummy_close,
 +    .priv_data_size   = sizeof(Dummy3Context),
 +};
 +
 +/* codec without priv data */
 +static AVCodec dummy_v4_encoder = {
 +    .name             = "dummy_v4_codec",
 +    .type             = AVMEDIA_TYPE_VIDEO,
 +    .id               = AV_CODEC_ID_NONE - 4,
 +    .encode2          = dummy_encode,
 +    .init             = dummy_init,
 +    .close            = dummy_close,
 +};
 +
 +static void test_copy_print_codec(const AVCodecContext *ctx)
 +{
 +    printf("%-14s: %dx%d prv: %s",
 +           ctx->codec ? ctx->codec->name : "NULL",
 +           ctx->width, ctx->height,
 +           ctx->priv_data ? "set" : "null");
 +    if (ctx->codec && ctx->codec->priv_class && ctx->codec->priv_data_size) {
 +        int64_t i64;
 +        char *str = NULL;
 +        av_opt_get_int(ctx->priv_data, "num", 0, &i64);
 +        av_opt_get(ctx->priv_data, "str", 0, (uint8_t**)&str);
 +        printf(" opts: %"PRId64" %s", i64, str);
 +        av_free(str);
 +    }
 +    printf("\n");
 +}
 +
 +static void test_copy(const AVCodec *c1, const AVCodec *c2)
 +{
 +    AVCodecContext *ctx1, *ctx2;
 +    printf("%s -> %s\nclosed:\n", c1 ? c1->name : "NULL", c2 ? c2->name : "NULL");
 +    ctx1 = avcodec_alloc_context3(c1);
 +    ctx2 = avcodec_alloc_context3(c2);
 +    ctx1->width = ctx1->height = 128;
 +    if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) {
 +        av_opt_set(ctx2->priv_data, "num", "667", 0);
 +        av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0);
 +    }
 +    avcodec_copy_context(ctx2, ctx1);
 +    test_copy_print_codec(ctx1);
 +    test_copy_print_codec(ctx2);
 +    if (ctx1->codec) {
 +        int ret;
 +        printf("opened:\n");
 +        ret = avcodec_open2(ctx1, ctx1->codec, NULL);
 +        if (ret < 0) {
 +            fprintf(stderr, "avcodec_open2 failed\n");
 +            exit(1);
 +        }
 +        if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) {
 +            av_opt_set(ctx2->priv_data, "num", "667", 0);
 +            av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0);
 +        }
 +        avcodec_copy_context(ctx2, ctx1);
 +        test_copy_print_codec(ctx1);
 +        test_copy_print_codec(ctx2);
 +        avcodec_close(ctx1);
 +    }
 +    avcodec_free_context(&ctx1);
 +    avcodec_free_context(&ctx2);
 +}
 +
 +int main(void)
 +{
 +    AVCodec *dummy_codec[] = {
 +        &dummy_v1_encoder,
 +        &dummy_v2_encoder,
 +        &dummy_v3_encoder,
 +        &dummy_v4_encoder,
 +        NULL,
 +    };
 +    int i, j;
 +
 +    for (i = 0; dummy_codec[i]; i++)
 +        avcodec_register(dummy_codec[i]);
 +
 +    printf("testing avcodec_copy_context()\n");
 +    for (i = 0; i < FF_ARRAY_ELEMS(dummy_codec); i++)
 +        for (j = 0; j < FF_ARRAY_ELEMS(dummy_codec); j++)
 +            test_copy(dummy_codec[i], dummy_codec[j]);
 +    return 0;
 +}
diff --cc libavcodec/tests/ppc/dct.c
index 2328516,3d160d3..d95db52
--- a/libavcodec/tests/ppc/dct.c
+++ b/libavcodec/tests/ppc/dct.c
@@@ -18,10 -18,10 +18,10 @@@
  
  #include "config.h"
  
- #include "fdct.h"
+ #include "libavcodec/ppc/fdct.h"
  
  static const struct algo fdct_tab_arch[] = {
 -#if HAVE_ALTIVEC && HAVE_BIGENDIAN
 +#if HAVE_ALTIVEC
      { "altivecfdct", ff_fdct_altivec, FF_IDCT_PERM_NONE, AV_CPU_FLAG_ALTIVEC },
  #endif
      { 0 }
diff --cc libavcodec/tests/snowenc.c
index e1ed86f,0000000..d5f94e8
mode 100644,000000..100644
--- a/libavcodec/tests/snowenc.c
+++ b/libavcodec/tests/snowenc.c
@@@ -1,147 -1,0 +1,147 @@@
 +/*
 + * Copyright (C) 2004 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "snowenc.c"
++#include "libavcodec/snowenc.c"
 +
 +#undef malloc
 +#undef free
 +#undef printf
 +
 +#include "libavutil/lfg.h"
 +#include "libavutil/mathematics.h"
 +
 +int main(void){
 +#define width  256
 +#define height 256
 +    int buffer[2][width*height];
 +    SnowContext s;
 +    int i;
 +    AVLFG prng;
 +    s.spatial_decomposition_count=6;
 +    s.spatial_decomposition_type=1;
 +
 +    s.temp_dwt_buffer  = av_mallocz_array(width, sizeof(DWTELEM));
 +    s.temp_idwt_buffer = av_mallocz_array(width, sizeof(IDWTELEM));
 +
 +    if (!s.temp_dwt_buffer || !s.temp_idwt_buffer) {
 +        fprintf(stderr, "Failed to allocate memory\n");
 +        return 1;
 +    }
 +
 +    av_lfg_init(&prng, 1);
 +
 +    printf("testing 5/3 DWT\n");
 +    for(i=0; i<width*height; i++)
 +        buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
 +
 +    ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +    ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +
 +    for(i=0; i<width*height; i++)
 +        if(buffer[0][i]!= buffer[1][i]) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
 +
 +    printf("testing 9/7 DWT\n");
 +    s.spatial_decomposition_type=0;
 +    for(i=0; i<width*height; i++)
 +        buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
 +
 +    ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +    ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +
 +    for(i=0; i<width*height; i++)
 +        if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
 +
 +    {
 +    int level, orientation, x, y;
 +    int64_t errors[8][4];
 +    int64_t g=0;
 +
 +        memset(errors, 0, sizeof(errors));
 +        s.spatial_decomposition_count=3;
 +        s.spatial_decomposition_type=0;
 +        for(level=0; level<s.spatial_decomposition_count; level++){
 +            for(orientation=level ? 1 : 0; orientation<4; orientation++){
 +                int w= width  >> (s.spatial_decomposition_count-level);
 +                int h= height >> (s.spatial_decomposition_count-level);
 +                int stride= width  << (s.spatial_decomposition_count-level);
 +                DWTELEM *buf= buffer[0];
 +                int64_t error=0;
 +
 +                if(orientation&1) buf+=w;
 +                if(orientation>1) buf+=stride>>1;
 +
 +                memset(buffer[0], 0, sizeof(int)*width*height);
 +                buf[w/2 + h/2*stride]= 256*256;
 +                ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +                for(y=0; y<height; y++){
 +                    for(x=0; x<width; x++){
 +                        int64_t d= buffer[0][x + y*width];
 +                        error += d*d;
 +                        if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d);
 +                    }
 +                    if(FFABS(height/2-y)<9 && level==2) printf("\n");
 +                }
 +                error= (int)(sqrt(error)+0.5);
 +                errors[level][orientation]= error;
 +                if(g) g=av_gcd(g, error);
 +                else g= error;
 +            }
 +        }
 +        printf("static int const visual_weight[][4]={\n");
 +        for(level=0; level<s.spatial_decomposition_count; level++){
 +            printf("  {");
 +            for(orientation=0; orientation<4; orientation++){
 +                printf("%8"PRId64",", errors[level][orientation]/g);
 +            }
 +            printf("},\n");
 +        }
 +        printf("};\n");
 +        {
 +            int level=2;
 +            int w= width  >> (s.spatial_decomposition_count-level);
 +            //int h= height >> (s.spatial_decomposition_count-level);
 +            int stride= width  << (s.spatial_decomposition_count-level);
 +            DWTELEM *buf= buffer[0];
 +            int64_t error=0;
 +
 +            buf+=w;
 +            buf+=stride>>1;
 +
 +            memset(buffer[0], 0, sizeof(int)*width*height);
 +            for(y=0; y<height; y++){
 +                for(x=0; x<width; x++){
 +                    int tab[4]={0,2,3,1};
 +                    buffer[0][x+width*y]= 256*256*tab[(x&1) + 2*(y&1)];
 +                }
 +            }
 +            ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 +            for(y=0; y<height; y++){
 +                for(x=0; x<width; x++){
 +                    int64_t d= buffer[0][x + y*width];
 +                    error += d*d;
 +                    if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9) printf("%8"PRId64" ", d);
 +                }
 +                if(FFABS(height/2-y)<9) printf("\n");
 +            }
 +        }
 +
 +    }
 +    return 0;
 +}
diff --cc libavcodec/tests/utils.c
index 7b3b718,0000000..e2891fb
mode 100644,000000..100644
--- a/libavcodec/tests/utils.c
+++ b/libavcodec/tests/utils.c
@@@ -1,37 -1,0 +1,37 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "avcodec.h"
++#include "libavcodec/avcodec.h"
 +
 +int main(void){
 +    AVCodec *codec = NULL;
 +    int ret = 0;
 +    avcodec_register_all();
 +
 +    while (codec = av_codec_next(codec)) {
 +        if (av_codec_is_encoder(codec)) {
 +            if (codec->type == AVMEDIA_TYPE_AUDIO) {
 +                if (!codec->sample_fmts) {
 +                    av_log(NULL, AV_LOG_FATAL, "Encoder %s is missing the sample_fmts field\n", codec->name);
 +                    ret = 1;
 +                }
 +            }
 +        }
 +    }
 +    return ret;
 +}
diff --cc libavcodec/tests/x86/dct.c
index 28ede16,2ddb555..b6cdfb3
--- a/libavcodec/tests/x86/dct.c
+++ b/libavcodec/tests/x86/dct.c
@@@ -18,41 -18,10 +18,41 @@@
  
  #include "config.h"
  
- #include "fdct.h"
- #include "xvididct.h"
- #include "simple_idct.h"
+ #include "libavcodec/x86/fdct.h"
+ #include "libavcodec/x86/xvididct.h"
+ #include "libavcodec/x86/simple_idct.h"
  
 +#if (CONFIG_PRORES_DECODER || CONFIG_PRORES_LGPL_DECODER) && ARCH_X86_64 && HAVE_YASM
 +void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
 +                                int16_t *block, int16_t *qmat);
 +
 +#define PR_WRAP(INSN) \
 +static void ff_prores_idct_put_10_##INSN##_wrap(int16_t *dst){ \
 +    LOCAL_ALIGNED(16, int16_t, qmat, [64]); \
 +    LOCAL_ALIGNED(16, int16_t, tmp, [64]); \
 +    int i; \
 + \
 +    for(i=0; i<64; i++){ \
 +        qmat[i]=4; \
 +        tmp[i]= dst[i]; \
 +    } \
 +    ff_prores_idct_put_10_##INSN (dst, 16, tmp, qmat); \
 + \
 +    for(i=0; i<64; i++) { \
 +         dst[i] -= 512; \
 +    } \
 +}
 +
 +PR_WRAP(sse2)
 +
 +# if HAVE_AVX_EXTERNAL
 +void ff_prores_idct_put_10_avx(uint16_t *dst, int linesize,
 +                               int16_t *block, int16_t *qmat);
 +PR_WRAP(avx)
 +# endif
 +
 +#endif
 +
  static const struct algo fdct_tab_arch[] = {
  #if HAVE_MMX_INLINE
      { "MMX",    ff_fdct_mmx,    FF_IDCT_PERM_NONE, AV_CPU_FLAG_MMX },
diff --cc libavdevice/tests/.gitignore
index 0000000,0000000..b4a2281
new file mode 100644
--- /dev/null
+++ b/libavdevice/tests/.gitignore
@@@ -1,0 -1,0 +1,1 @@@
++/timefilter
diff --cc libavfilter/tests/.gitignore
index 0000000,a55b386..b605afa
mode 000000,100644..100644
--- a/libavfilter/tests/.gitignore
+++ b/libavfilter/tests/.gitignore
@@@ -1,0 -1,1 +1,3 @@@
++/drawutils
+ /filtfmts
++/formats
diff --cc libavfilter/tests/drawutils.c
index 7b9f89f,0000000..7fe53dd
mode 100644,000000..100644
--- a/libavfilter/tests/drawutils.c
+++ b/libavfilter/tests/drawutils.c
@@@ -1,56 -1,0 +1,56 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <stdio.h>
 +
 +#include "libavutil/pixdesc.h"
- #include "drawutils.h"
++#include "libavfilter/drawutils.h"
 +
 +int main(void)
 +{
 +    enum AVPixelFormat f;
 +    const AVPixFmtDescriptor *desc;
 +    FFDrawContext draw;
 +    FFDrawColor color;
 +    int r, i;
 +
 +    for (f = 0; av_pix_fmt_desc_get(f); f++) {
 +        desc = av_pix_fmt_desc_get(f);
 +        if (!desc->name)
 +            continue;
 +        printf("Testing %s...%*s", desc->name,
 +               (int)(16 - strlen(desc->name)), "");
 +        r = ff_draw_init(&draw, f, 0);
 +        if (r < 0) {
 +            char buf[128];
 +            av_strerror(r, buf, sizeof(buf));
 +            printf("no: %s\n", buf);
 +            continue;
 +        }
 +        ff_draw_color(&draw, &color, (uint8_t[]) { 1, 0, 0, 1 });
 +        for (i = 0; i < sizeof(color); i++)
 +            if (((uint8_t *)&color)[i] != 128)
 +                break;
 +        if (i == sizeof(color)) {
 +            printf("fallback color\n");
 +            continue;
 +        }
 +        printf("ok\n");
 +    }
 +    return 0;
 +}
diff --cc libavfilter/tests/formats.c
index a891638,0000000..0e8ba4a
mode 100644,000000..100644
--- a/libavfilter/tests/formats.c
+++ b/libavfilter/tests/formats.c
@@@ -1,65 -1,0 +1,65 @@@
 +/*
 + * Copyright (c) 2007 Bobby Bingham
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "formats.c"
++#include "libavfilter/formats.c"
 +
 +#undef printf
 +
 +int main(void)
 +{
 +    const int64_t *cl;
 +    char buf[512];
 +    int i;
 +    const char *teststrings[] ={
 +        "blah",
 +        "1",
 +        "2",
 +        "-1",
 +        "60",
 +        "65",
 +        "1c",
 +        "2c",
 +        "-1c",
 +        "60c",
 +        "65c",
 +        "5.1",
 +        "stereo",
 +        "1+1+1+1",
 +        "1c+1c+1c+1c",
 +        "2c+1c",
 +        "0x3",
 +    };
 +
 +    for (cl = avfilter_all_channel_layouts; *cl != -1; cl++) {
 +        av_get_channel_layout_string(buf, sizeof(buf), -1, *cl);
 +        printf("%s\n", buf);
 +    }
 +
 +    for ( i = 0; i<FF_ARRAY_ELEMS(teststrings); i++) {
 +        int64_t layout = -1;
 +        int count = -1;
 +        int ret;
 +        ret = ff_parse_channel_layout(&layout, &count, teststrings[i], NULL);
 +
 +        printf ("%d = ff_parse_channel_layout(%016"PRIX64", %2d, %s);\n", ret ? -1 : 0, layout, count, teststrings[i]);
 +    }
 +
 +    return 0;
 +}
diff --cc libavformat/matroskaenc.c
index ddac2d3,2260d42..6252de8
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@@ -1564,30 -1223,7 +1572,19 @@@ static int mkv_write_header(AVFormatCon
              put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, tag->value);
          else
              put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
- 
-         if (mkv->mode != MODE_WEBM) {
-             uint32_t segment_uid[4];
-             AVLFG lfg;
- 
-             av_lfg_init(&lfg, av_get_random_seed());
- 
-             for (i = 0; i < 4; i++)
-                 segment_uid[i] = av_lfg_get(&lfg);
- 
-             put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);
-         }
+         put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);
 +    } else {
 +        const char *ident = "Lavf";
 +        put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , ident);
 +        put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, ident);
 +    }
 +
 +    if (ff_parse_creation_time_metadata(s, &creation_time, 0) > 0) {
 +        // Adjust time so it's relative to 2001-01-01 and convert to nanoseconds.
 +        int64_t date_utc = (creation_time - 978307200000000LL) * 1000;
 +        uint8_t date_utc_buf[8];
 +        AV_WB64(date_utc_buf, date_utc);
 +        put_ebml_binary(pb, MATROSKA_ID_DATEUTC, date_utc_buf, 8);
      }
  
      // reserve space for the duration
diff --cc libavformat/tests/.gitignore
index 0000000,cfd51f2..c8adb86
mode 000000,100644..100644
--- a/libavformat/tests/.gitignore
+++ b/libavformat/tests/.gitignore
@@@ -1,0 -1,5 +1,6 @@@
+ /movenc
+ /noproxy
++/rtmpdh
+ /seek
+ /srtp
+ /url
diff --cc libavutil/Makefile
index a35deb6,11d9179..1f05215
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@@ -194,31 -136,9 +194,31 @@@ TESTPROGS = adler3
              hmac                                                        \
              lfg                                                         \
              lls                                                         \
 +            log                                                         \
              md5                                                         \
 +            murmur3                                                     \
              opt                                                         \
 +            pca                                                         \
              parseutils                                                  \
 +            pixdesc                                                     \
 +            pixelutils                                                  \
 +            random_seed                                                 \
 +            rational                                                    \
 +            ripemd                                                      \
              sha                                                         \
 +            sha512                                                      \
 +            softfloat                                                   \
              tree                                                        \
 +            twofish                                                     \
 +            utf8                                                        \
              xtea                                                        \
 +            tea                                                         \
 +
 +TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo
 +
 +TOOLS = crypto_bench ffhash ffeval ffescape
 +
 +tools/crypto_bench$(EXESUF): ELIBS += $(if $(VERSUS),$(subst +, -l,+$(VERSUS)),)
 +tools/crypto_bench$(EXESUF): CFLAGS += -DUSE_EXT_LIBS=0$(if $(VERSUS),$(subst +,+USE_,+$(VERSUS)),)
 +
- $(SUBDIR)lzo-test$(EXESUF): ELIBS = -llzo2
++$(SUBDIR)tests/lzo$(EXESUF): ELIBS = -llzo2
diff --cc libavutil/tests/.gitignore
index 0000000,c4d1d06..c23c44b
mode 000000,100644..100644
--- a/libavutil/tests/.gitignore
+++ b/libavutil/tests/.gitignore
@@@ -1,0 -1,21 +1,44 @@@
+ /adler32
+ /aes
+ /atomic
+ /avstring
+ /base64
+ /blowfish
++/bprint
++/camellia
++/cast5
++/color_utils
+ /cpu
+ /crc
+ /des
++/dict
++/display
++/error
+ /eval
+ /fifo
++/file
+ /float_dsp
++/hash
+ /hmac
+ /lfg
+ /lls
++/log
++/lzo
+ /md5
++/murmur3
+ /opt
+ /parseutils
++/pca
++/pixdesc
++/pixelutils
++/random_seed
++/rational
++/ripemd
+ /sha
++/sha512
++/softfloat
++/tea
+ /tree
++/twofish
++/utf8
+ /xtea
diff --cc libavutil/tests/adler32.c
index f93cf9d,3236900..511bf1e
--- a/libavutil/tests/adler32.c
+++ b/libavutil/tests/adler32.c
@@@ -16,12 -16,11 +16,12 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +// LCOV_EXCL_START
  #include <string.h>
  
- #include "log.h"
- #include "timer.h"
- #include "adler32.h"
+ #include "libavutil/log.h"
+ #include "libavutil/timer.h"
+ #include "libavutil/adler32.h"
  
  #define LEN 7001
  
diff --cc libavutil/tests/aes.c
index 2bdba8a,49ca553..1291ad6
--- a/libavutil/tests/aes.c
+++ b/libavutil/tests/aes.c
@@@ -16,13 -16,12 +16,13 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 -#include "libavutil/aes.c"
 -
 +// LCOV_EXCL_START
  #include <string.h>
  
- #include "aes.h"
- #include "lfg.h"
- #include "log.h"
- #include "mem.h"
++#include "libavutil/aes.h"
+ #include "libavutil/lfg.h"
+ #include "libavutil/log.h"
++#include "libavutil/mem.h"
  
  int main(int argc, char **argv)
  {
diff --cc libavutil/tests/atomic.c
index 397d8c9,70636f4..c92f220
--- a/libavutil/tests/atomic.c
+++ b/libavutil/tests/atomic.c
@@@ -16,8 -16,9 +16,8 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
- #include "atomic.h"
- #include "avassert.h"
 -#include <assert.h>
 -
+ #include "libavutil/atomic.h"
++#include "libavutil/avassert.h"
  
  int main(void)
  {
diff --cc libavutil/tests/base64.c
index 19ecd2b,16ea399..88fd55c
--- a/libavutil/tests/base64.c
+++ b/libavutil/tests/base64.c
@@@ -20,9 -19,8 +20,9 @@@
  #include <stdint.h>
  #include <stdio.h>
  
- #include "common.h"
- #include "base64.h"
- #include "timer.h"
+ #include "libavutil/common.h"
+ #include "libavutil/base64.h"
++#include "libavutil/timer.h"
  
  #define MAX_DATA_SIZE    1024
  #define MAX_ENCODED_SIZE 2048
diff --cc libavutil/tests/bprint.c
index f081c44,0000000..d7f381d
mode 100644,000000..100644
--- a/libavutil/tests/bprint.c
+++ b/libavutil/tests/bprint.c
@@@ -1,93 -1,0 +1,93 @@@
 +/*
 + * Copyright (c) 2012 Nicolas George
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "bprint.c"
++#include "libavutil/bprint.c"
 +
 +#undef printf
 +
 +static void bprint_pascal(AVBPrint *b, unsigned size)
 +{
 +    unsigned i, j;
 +    unsigned p[42];
 +
 +    av_assert0(size < FF_ARRAY_ELEMS(p));
 +
 +    p[0] = 1;
 +    av_bprintf(b, "%8d\n", 1);
 +    for (i = 1; i <= size; i++) {
 +        p[i] = 1;
 +        for (j = i - 1; j > 0; j--)
 +            p[j] = p[j] + p[j - 1];
 +        for (j = 0; j <= i; j++)
 +            av_bprintf(b, "%8d", p[j]);
 +        av_bprintf(b, "\n");
 +    }
 +}
 +
 +int main(void)
 +{
 +    AVBPrint b;
 +    char buf[256];
 +    struct tm testtime = { .tm_year = 100, .tm_mon = 11, .tm_mday = 20 };
 +
 +    av_bprint_init(&b, 0, -1);
 +    bprint_pascal(&b, 5);
 +    printf("Short text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
 +    printf("%s\n", b.str);
 +    av_bprint_finalize(&b, NULL);
 +
 +    av_bprint_init(&b, 0, -1);
 +    bprint_pascal(&b, 25);
 +    printf("Long text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
 +    av_bprint_finalize(&b, NULL);
 +
 +    av_bprint_init(&b, 0, 2048);
 +    bprint_pascal(&b, 25);
 +    printf("Long text in limited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
 +    av_bprint_finalize(&b, NULL);
 +
 +    av_bprint_init(&b, 0, 1);
 +    bprint_pascal(&b, 5);
 +    printf("Short text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
 +
 +    av_bprint_init(&b, 0, 1);
 +    bprint_pascal(&b, 25);
 +    printf("Long text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str)/8*8, b.len);
 +    /* Note that the size of the automatic buffer is arch-dependent. */
 +
 +    av_bprint_init(&b, 0, 0);
 +    bprint_pascal(&b, 25);
 +    printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
 +
 +    av_bprint_init_for_buffer(&b, buf, sizeof(buf));
 +    bprint_pascal(&b, 25);
 +    printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(buf), b.len);
 +
 +    av_bprint_init(&b, 0, -1);
 +    av_bprint_strftime(&b, "%Y-%m-%d", &testtime);
 +    printf("strftime full: %u/%u \"%s\"\n", (unsigned)strlen(buf), b.len, b.str);
 +    av_bprint_finalize(&b, NULL);
 +
 +    av_bprint_init(&b, 0, 8);
 +    av_bprint_strftime(&b, "%Y-%m-%d", &testtime);
 +    printf("strftime truncated: %u/%u \"%s\"\n", (unsigned)strlen(buf), b.len, b.str);
 +
 +    return 0;
 +}
diff --cc libavutil/tests/camellia.c
index 0540ccc,0000000..1716b59
mode 100644,000000..100644
--- a/libavutil/tests/camellia.c
+++ b/libavutil/tests/camellia.c
@@@ -1,75 -1,0 +1,75 @@@
 +/*
 + * An implementation of the CAMELLIA algorithm as mentioned in RFC3713
 + * Copyright (c) 2014 Supraja Meedinti
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "camellia.h"
- #include "log.h"
++#include "libavutil/camellia.h"
++#include "libavutil/log.h"
 +
 +int main(int argc, char *argv[])
 +{
 +    const uint8_t Key[3][32] = {
 +        {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
 +        {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77},
 +        {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}
 +    };
 +    const uint8_t rct[3][16] = {
 +        {0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73, 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43},
 +        {0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9,0x96, 0xf8, 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9},
 +        {0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09}
 +    };
 +    const uint8_t rpt[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10};
 +    const int kbits[3] = {128, 192, 256};
 +    int i, j, err = 0;
 +    uint8_t temp[32], iv[16];
 +    struct AVCAMELLIA *cs;
 +    cs = av_camellia_alloc();
 +    if (!cs)
 +        return 1;
 +    for (j = 0; j < 3; j++) {
 +        av_camellia_init(cs, Key[j], kbits[j]);
 +        av_camellia_crypt(cs, temp, rpt, 1, NULL, 0);
 +        for (i = 0; i < 16; i++) {
 +            if (rct[j][i] != temp[i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[j][i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +        av_camellia_crypt(cs, temp, rct[j], 1, NULL, 1);
 +        for (i = 0; i < 16; i++) {
 +            if (rpt[i] != temp[i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +    }
 +    av_camellia_init(cs, Key[0], 128);
 +    memcpy(iv, "HALLO123HALLO123", 16);
 +    av_camellia_crypt(cs, temp, rpt, 2, iv, 0);
 +    memcpy(iv, "HALLO123HALLO123", 16);
 +    av_camellia_crypt(cs, temp, temp, 2, iv, 1);
 +    for (i = 0; i < 32; i++) {
 +        if (rpt[i] != temp[i]) {
 +            av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]);
 +            err = 1;
 +        }
 +    }
 +    av_free(cs);
 +    return err;
 +}
diff --cc libavutil/tests/cast5.c
index e2269a7,0000000..ce3aa80
mode 100644,000000..100644
--- a/libavutil/tests/cast5.c
+++ b/libavutil/tests/cast5.c
@@@ -1,103 -1,0 +1,103 @@@
 +/*
 + * An implementation of the CAST128 algorithm as mentioned in RFC2144
 + * Copyright (c) 2014 Supraja Meedinti
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "cast5.h"
- #include "log.h"
++#include "libavutil/cast5.h"
++#include "libavutil/log.h"
 +
 +int main(int argc, char** argv)
 +{
 +
 +    static const uint8_t Key[3][16] = {
 +        {0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a},
 +        {0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 0x23, 0x45},
 +        {0x01, 0x23, 0x45, 0x67, 0x12}
 +    };
 +    static const uint8_t rpt[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
 +    static const uint8_t rct[3][8] = {
 +        {0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2},
 +        {0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b},
 +        {0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e}
 +    };
 +    static const uint8_t rct2[2][16] = {
 +        {0xee, 0xa9, 0xd0, 0xa2, 0x49, 0xfd, 0x3b, 0xa6, 0xb3, 0x43, 0x6f, 0xb8, 0x9d, 0x6d, 0xca, 0x92},
 +        {0xb2, 0xc9, 0x5e, 0xb0, 0x0c, 0x31, 0xad, 0x71, 0x80, 0xac, 0x05, 0xb8, 0xe8, 0x3d, 0x69, 0x6e}
 +    };
 +    static const uint8_t iv[8] = {0xee, 0xa9, 0xd0, 0xa2, 0x49, 0xfd, 0x3b, 0xa6};
 +    static uint8_t rpt2[2][16];
 +    int i, j, err = 0;
 +    static const int key_bits[3] = {128, 80, 40};
 +    uint8_t temp[8];
 +    struct AVCAST5 *cs;
 +    cs = av_cast5_alloc();
 +    if (!cs)
 +        return 1;
 +    for (j = 0; j < 3; j++){
 +
 +        av_cast5_init(cs, Key[j], key_bits[j]);
 +        av_cast5_crypt(cs, temp, rpt, 1, 0);
 +        for (i = 0;i < 8; i++){
 +            if (rct[j][i] != temp[i]){
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[j][i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +
 +        av_cast5_crypt(cs, temp, rct[j], 1, 1);
 +        for (i =0; i < 8; i++) {
 +            if (rpt[i] != temp[i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +    }
 +    memcpy(rpt2[0], Key[0], 16);
 +    memcpy(rpt2[1], Key[0], 16);
 +    for (i = 0; i < 1000000; i++){
 +        av_cast5_init(cs, rpt2[1], 128);
 +        av_cast5_crypt(cs, rpt2[0], rpt2[0], 2, 0);
 +        av_cast5_init(cs, rpt2[0], 128);
 +        av_cast5_crypt(cs, rpt2[1], rpt2[1], 2, 0);
 +    }
 +    for (j = 0; j < 2; j++) {
 +        for (i = 0; i < 16; i++) {
 +            if (rct2[j][i] != rpt2[j][i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct2[j][i], rpt2[j][i]);
 +                err = 1;
 +            }
 +        }
 +    }
 +    for (j = 0; j < 3; j++) {
 +
 +        av_cast5_init(cs, Key[j], key_bits[j]);
 +        memcpy(temp, iv, 8);
 +        av_cast5_crypt2(cs, rpt2[0], rct2[0], 2, temp, 0);
 +        memcpy(temp, iv, 8);
 +        av_cast5_crypt2(cs, rpt2[0], rpt2[0], 2, temp, 1);
 +        for (i = 0; i < 16; i++) {
 +            if (rct2[0][i] != rpt2[0][i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct2[0][i], rpt2[0][i]);
 +                err = 1;
 +            }
 +        }
 +    }
 +    av_free(cs);
 +    return err;
 +}
diff --cc libavutil/tests/color_utils.c
index 083872c,0000000..ea01271
mode 100644,000000..100644
--- a/libavutil/tests/color_utils.c
+++ b/libavutil/tests/color_utils.c
@@@ -1,43 -1,0 +1,43 @@@
 +/*
 + * Copyright (c) 2015 Kevin Wheatley <kevin.j.wheatley at gmail.com>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "color_utils.c"
++#include "libavutil/color_utils.c"
 +
 +int main(int argc, char *argv[])
 +{
 +  int i, j;
 +  static const double test_data[] = {
 +      -0.1, -0.018053968510807, -0.01, -0.00449, 0.0, 0.00316227760, 0.005,
 +      0.009, 0.015, 0.1, 1.0, 52.37, 125.098765, 1999.11123, 6945.443,
 +      15123.4567, 19845.88923, 98678.4231, 99999.899998
 +  };
 +
 +  for(i = 0; i < AVCOL_TRC_NB; i++) {
 +      avpriv_trc_function func = avpriv_get_trc_function_from_trc(i);
 +      for(j = 0; j < FF_ARRAY_ELEMS(test_data); j++) {
 +          if(func != NULL) {
 +              double result = func(test_data[j]);
 +              printf("AVColorTransferCharacteristic=%d calling func(%f) expected=%f\n",
 +                     i, test_data[j], result);
 +          }
 +      }
 +  }
 +
 +}
diff --cc libavutil/tests/cpu.c
index 35e7631,176b7eb..f02a54c
--- a/libavutil/tests/cpu.c
+++ b/libavutil/tests/cpu.c
@@@ -16,16 -16,11 +16,17 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#include <stdio.h>
 +
  #include "config.h"
- #include "cpu.h"
- #include "avstring.h"
+ 
++#include "libavutil/cpu.h"
++#include "libavutil/avstring.h"
 +
  #if HAVE_UNISTD_H
  #include <unistd.h>
 -#elif !HAVE_GETOPT
 +#endif
 +#if !HAVE_GETOPT
  #include "compat/getopt.c"
  #endif
  
diff --cc libavutil/tests/dict.c
index e40b578,0000000..0039ba5
mode 100644,000000..100644
--- a/libavutil/tests/dict.c
+++ b/libavutil/tests/dict.c
@@@ -1,133 -1,0 +1,133 @@@
 +/*
 + * copyright (c) 2009 Michael Niedermayer
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "dict.c"
++#include "libavutil/dict.c"
 +
 +static void print_dict(const AVDictionary *m)
 +{
 +    AVDictionaryEntry *t = NULL;
 +    while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
 +        printf("%s %s   ", t->key, t->value);
 +    printf("\n");
 +}
 +
 +static void test_separators(const AVDictionary *m, const char pair, const char val)
 +{
 +    AVDictionary *dict = NULL;
 +    char pairs[] = {pair , '\0'};
 +    char vals[]  = {val, '\0'};
 +
 +    char *buffer = NULL;
 +    av_dict_copy(&dict, m, 0);
 +    print_dict(dict);
 +    av_dict_get_string(dict, &buffer, val, pair);
 +    printf("%s\n", buffer);
 +    av_dict_free(&dict);
 +    av_dict_parse_string(&dict, buffer, vals, pairs, 0);
 +    av_freep(&buffer);
 +    print_dict(dict);
 +    av_dict_free(&dict);
 +}
 +
 +int main(void)
 +{
 +    AVDictionary *dict = NULL;
 +    AVDictionaryEntry *e;
 +    char *buffer = NULL;
 +
 +    printf("Testing av_dict_get_string() and av_dict_parse_string()\n");
 +    av_dict_get_string(dict, &buffer, '=', ',');
 +    printf("%s\n", buffer);
 +    av_freep(&buffer);
 +    av_dict_set(&dict, "aaa", "aaa", 0);
 +    av_dict_set(&dict, "b,b", "bbb", 0);
 +    av_dict_set(&dict, "c=c", "ccc", 0);
 +    av_dict_set(&dict, "ddd", "d,d", 0);
 +    av_dict_set(&dict, "eee", "e=e", 0);
 +    av_dict_set(&dict, "f,f", "f=f", 0);
 +    av_dict_set(&dict, "g=g", "g,g", 0);
 +    test_separators(dict, ',', '=');
 +    av_dict_free(&dict);
 +    av_dict_set(&dict, "aaa", "aaa", 0);
 +    av_dict_set(&dict, "bbb", "bbb", 0);
 +    av_dict_set(&dict, "ccc", "ccc", 0);
 +    av_dict_set(&dict, "\\,=\'\"", "\\,=\'\"", 0);
 +    test_separators(dict, '"',  '=');
 +    test_separators(dict, '\'', '=');
 +    test_separators(dict, ',', '"');
 +    test_separators(dict, ',', '\'');
 +    test_separators(dict, '\'', '"');
 +    test_separators(dict, '"', '\'');
 +    av_dict_free(&dict);
 +
 +    printf("\nTesting av_dict_set()\n");
 +    av_dict_set(&dict, "a", "a", 0);
 +    av_dict_set(&dict, "b", av_strdup("b"), AV_DICT_DONT_STRDUP_VAL);
 +    av_dict_set(&dict, av_strdup("c"), "c", AV_DICT_DONT_STRDUP_KEY);
 +    av_dict_set(&dict, av_strdup("d"), av_strdup("d"), AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
 +    av_dict_set(&dict, "e", "e", AV_DICT_DONT_OVERWRITE);
 +    av_dict_set(&dict, "e", "f", AV_DICT_DONT_OVERWRITE);
 +    av_dict_set(&dict, "f", "f", 0);
 +    av_dict_set(&dict, "f", NULL, 0);
 +    av_dict_set(&dict, "ff", "f", 0);
 +    av_dict_set(&dict, "ff", "f", AV_DICT_APPEND);
 +    e = NULL;
 +    while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
 +        printf("%s %s\n", e->key, e->value);
 +    av_dict_free(&dict);
 +
 +    av_dict_set(&dict, NULL, "a", 0);
 +    av_dict_set(&dict, NULL, "b", 0);
 +    av_dict_get(dict, NULL, NULL, 0);
 +    e = NULL;
 +    while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
 +        printf("'%s' '%s'\n", e->key, e->value);
 +    av_dict_free(&dict);
 +
 +
 +    //valgrind sensible test
 +    printf("\nTesting av_dict_set_int()\n");
 +    av_dict_set_int(&dict, "1", 1, AV_DICT_DONT_STRDUP_VAL);
 +    av_dict_set_int(&dict, av_strdup("2"), 2, AV_DICT_DONT_STRDUP_KEY);
 +    av_dict_set_int(&dict, av_strdup("3"), 3, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
 +    av_dict_set_int(&dict, "4", 4, 0);
 +    av_dict_set_int(&dict, "5", 5, AV_DICT_DONT_OVERWRITE);
 +    av_dict_set_int(&dict, "5", 6, AV_DICT_DONT_OVERWRITE);
 +    av_dict_set_int(&dict, "12", 1, 0);
 +    av_dict_set_int(&dict, "12", 2, AV_DICT_APPEND);
 +    e = NULL;
 +    while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
 +        printf("%s %s\n", e->key, e->value);
 +    av_dict_free(&dict);
 +
 +    //valgrind sensible test
 +    printf("\nTesting av_dict_set() with existing AVDictionaryEntry.key as key\n");
 +    av_dict_set(&dict, "key", "old", 0);
 +    e = av_dict_get(dict, "key", NULL, 0);
 +    av_dict_set(&dict, e->key, "new val OK", 0);
 +    e = av_dict_get(dict, "key", NULL, 0);
 +    printf("%s\n", e->value);
 +    av_dict_set(&dict, e->key, e->value, 0);
 +    e = av_dict_get(dict, "key", NULL, 0);
 +    printf("%s\n", e->value);
 +    av_dict_free(&dict);
 +
 +    return 0;
 +}
diff --cc libavutil/tests/display.c
index b42ab89,0000000..893ebb5
mode 100644,000000..100644
--- a/libavutil/tests/display.c
+++ b/libavutil/tests/display.c
@@@ -1,61 -1,0 +1,61 @@@
 +/*
 + * Copyright (c) 2014 Vittorio Giovara <vittorio.giovara at gmail.com>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "display.c"
++#include "libavutil/display.c"
 +
 +static void print_matrix(int32_t matrix[9])
 +{
 +    int i, j;
 +
 +    for (i = 0; i < 3; ++i) {
 +        for (j = 0; j < 3 - 1; ++j)
 +            printf("%d ", matrix[i*3 + j]);
 +
 +        printf("%d\n", matrix[i*3 + j]);
 +    }
 +}
 +
 +int main(void)
 +{
 +    int32_t matrix[9];
 +
 +    // Set the matrix to 90 degrees
 +    av_display_rotation_set(matrix, 90);
 +    print_matrix(matrix);
 +    printf("degrees: %f\n", av_display_rotation_get(matrix));
 +
 +    // Set the matrix to -45 degrees
 +    av_display_rotation_set(matrix, -45);
 +    print_matrix(matrix);
 +    printf("degrees: %f\n", av_display_rotation_get(matrix));
 +
 +    // flip horizontal
 +    av_display_matrix_flip(matrix, 1, 0);
 +    print_matrix(matrix);
 +    printf("degrees: %f\n", av_display_rotation_get(matrix));
 +
 +    // flip vertical
 +    av_display_matrix_flip(matrix, 0, 1);
 +    print_matrix(matrix);
 +    printf("degrees: %f\n", av_display_rotation_get(matrix));
 +
 +    return 0;
 +
 +}
diff --cc libavutil/tests/error.c
index 36240da,0000000..16efc8a
mode 100644,000000..100644
--- a/libavutil/tests/error.c
+++ b/libavutil/tests/error.c
@@@ -1,37 -1,0 +1,37 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "error.c"
++#include "libavutil/error.c"
 +
 +#undef printf
 +
 +int main(void)
 +{
 +    int i;
 +
 +    for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
 +        const struct error_entry *entry = &error_entries[i];
 +        printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
 +    }
 +
 +    for (i = 0; i < 256; i++) {
 +        printf("%d: %s\n", -i, av_err2str(-i));
 +    }
 +
 +    return 0;
 +}
diff --cc libavutil/tests/file.c
index 0324081,0000000..3608bcc
mode 100644,000000..100644
--- a/libavutil/tests/file.c
+++ b/libavutil/tests/file.c
@@@ -1,34 -1,0 +1,34 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "file.c"
++#include "libavutil/file.c"
 +
 +#undef printf
 +
 +int main(void)
 +{
 +    uint8_t *buf;
 +    size_t size;
 +    if (av_file_map("file.c", &buf, &size, 0, NULL) < 0)
 +        return 1;
 +
 +    buf[0] = 's';
 +    printf("%s", buf);
 +    av_file_unmap(buf, size);
 +    return 0;
 +}
diff --cc libavutil/tests/float_dsp.c
index 9963efb,ab6bf6a..053324d
--- a/libavutil/tests/float_dsp.c
+++ b/libavutil/tests/float_dsp.c
@@@ -23,20 -20,13 +23,20 @@@
  #include <stdint.h>
  #include <stdlib.h>
  #include <string.h>
 -
 +#if HAVE_UNISTD_H
 +#include <unistd.h> /* for getopt */
 +#endif
 +#if !HAVE_GETOPT
 +#include "compat/getopt.c"
 +#endif
 +
- #include "common.h"
- #include "cpu.h"
- #include "internal.h"
- #include "lfg.h"
- #include "log.h"
- #include "random_seed.h"
- #include "float_dsp.h"
++#include "libavutil/common.h"
+ #include "libavutil/cpu.h"
+ #include "libavutil/internal.h"
+ #include "libavutil/lfg.h"
+ #include "libavutil/log.h"
+ #include "libavutil/random_seed.h"
+ #include "libavutil/float_dsp.h"
  
  #define LEN 240
  
diff --cc libavutil/tests/hash.c
index bb7edf5,0000000..4f2ad52
mode 100644,000000..100644
--- a/libavutil/tests/hash.c
+++ b/libavutil/tests/hash.c
@@@ -1,65 -1,0 +1,65 @@@
 +/*
 + * Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger at gmx.de>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <stdio.h>
 +#include <string.h>
 +
- #include "hash.h"
++#include "libavutil/hash.h"
 +
 +#define SRC_BUF_SIZE 64
 +#define DST_BUF_SIZE (AV_HASH_MAX_SIZE * 8)
 +
 +int main(void)
 +{
 +   struct AVHashContext *ctx = NULL;
 +   int i, j, numhashes = 0;
 +   static const uint8_t src[SRC_BUF_SIZE] = { 0 };
 +   uint8_t dst[DST_BUF_SIZE];
 +
 +   while (av_hash_names(numhashes))
 +       numhashes++;
 +
 +   for (i = 0; i < numhashes; i++) {
 +       if (av_hash_alloc(&ctx, av_hash_names(i)) < 0)
 +           return 1;
 +
 +       av_hash_init(ctx);
 +       av_hash_update(ctx, src, SRC_BUF_SIZE);
 +       memset(dst, 0, DST_BUF_SIZE);
 +       av_hash_final_hex(ctx, dst, DST_BUF_SIZE);
 +       printf("%s hex: %s\n", av_hash_get_name(ctx), dst);
 +
 +       av_hash_init(ctx);
 +       av_hash_update(ctx, src, SRC_BUF_SIZE);
 +       av_hash_final_bin(ctx, dst, DST_BUF_SIZE);
 +       printf("%s bin: ", av_hash_get_name(ctx));
 +       for (j = 0; j < av_hash_get_size(ctx); j++) {
 +           printf("%#x ", dst[j]);
 +       }
 +       printf("\n");
 +
 +       av_hash_init(ctx);
 +       av_hash_update(ctx, src, SRC_BUF_SIZE);
 +       av_hash_final_b64(ctx, dst, DST_BUF_SIZE);
 +       printf("%s b64: %s\n", av_hash_get_name(ctx), dst);
 +       av_hash_freep(&ctx);
 +   }
 +   return 0;
 +}
diff --cc libavutil/tests/log.c
index 14d4764,0000000..8fe9461
mode 100644,000000..100644
--- a/libavutil/tests/log.c
+++ b/libavutil/tests/log.c
@@@ -1,71 -1,0 +1,71 @@@
 +/*
 + * log functions
 + * Copyright (c) 2003 Michel Bardiaux
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "log.c"
++#include "libavutil/log.c"
 +
 +#include <string.h>
 +
 +static int call_log_format_line2(const char *fmt, char *buffer, int buffer_size, ...)
 +{
 +    va_list args;
 +    int ret;
 +    int print_prefix=1;
 +    va_start(args, buffer_size);
 +    ret = av_log_format_line2(NULL, AV_LOG_INFO, fmt, args, buffer, buffer_size, &print_prefix);
 +    va_end(args);
 +    return ret;
 +}
 +
 +int main(int argc, char **argv)
 +{
 +    int i;
 +    av_log_set_level(AV_LOG_DEBUG);
 +    for (use_color=0; use_color<=256; use_color = 255*use_color+1) {
 +        av_log(NULL, AV_LOG_FATAL, "use_color: %d\n", use_color);
 +        for (i = AV_LOG_DEBUG; i>=AV_LOG_QUIET; i-=8) {
 +            av_log(NULL, i, " %d", i);
 +            av_log(NULL, AV_LOG_INFO, "e ");
 +            av_log(NULL, i + 256*123, "C%d", i);
 +            av_log(NULL, AV_LOG_INFO, "e");
 +        }
 +        av_log(NULL, AV_LOG_PANIC, "\n");
 +    }
 +    {
 +        int result;
 +        char buffer[4];
 +        result = call_log_format_line2("foo", NULL, 0);
 +        if(result != 3) {
 +            printf("Test NULL buffer failed.\n");
 +            return 1;
 +        }
 +        result = call_log_format_line2("foo", buffer, 2);
 +        if(result != 3 || strncmp(buffer, "f", 2)) {
 +            printf("Test buffer too small failed.\n");
 +            return 1;
 +        }
 +        result = call_log_format_line2("foo", buffer, 4);
 +        if(result != 3 || strncmp(buffer, "foo", 4)) {
 +            printf("Test buffer sufficiently big failed.\n");
 +            return 1;
 +        }
 +    }
 +    return 0;
 +}
diff --cc libavutil/tests/lzo.c
index e28fbe5,0000000..0147ab5
mode 100644,000000..100644
--- a/libavutil/tests/lzo.c
+++ b/libavutil/tests/lzo.c
@@@ -1,77 -1,0 +1,79 @@@
 +/*
 + * Copyright (c) 2006 Reimar Doeffinger
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <stdio.h>
 +#include <lzo/lzo1x.h>
- #include "log.h"
- #include "lzo.h"
- #include "mem.h"
++
++#include "libavutil/log.h"
++#include "libavutil/lzo.h"
++#include "libavutil/mem.h"
++
 +#define MAXSZ (10*1024*1024)
 +
 +/* Define one of these to 1 if you wish to benchmark liblzo
 + * instead of our native implementation. */
 +#define BENCHMARK_LIBLZO_SAFE   0
 +#define BENCHMARK_LIBLZO_UNSAFE 0
 +
 +int main(int argc, char *argv[]) {
 +    FILE *in = fopen(argv[1], "rb");
 +    int comp_level = argc > 2 ? atoi(argv[2]) : 0;
 +    uint8_t *orig = av_malloc(MAXSZ + 16);
 +    uint8_t *comp = av_malloc(2*MAXSZ + 16);
 +    uint8_t *decomp = av_malloc(MAXSZ + 16);
 +    size_t s = fread(orig, 1, MAXSZ, in);
 +    lzo_uint clen = 0;
 +    long tmp[LZO1X_MEM_COMPRESS];
 +    int inlen, outlen;
 +    int i;
 +    av_log_set_level(AV_LOG_DEBUG);
 +    if (comp_level == 0) {
 +        lzo1x_1_compress(orig, s, comp, &clen, tmp);
 +    } else if (comp_level == 11) {
 +        lzo1x_1_11_compress(orig, s, comp, &clen, tmp);
 +    } else if (comp_level == 12) {
 +        lzo1x_1_12_compress(orig, s, comp, &clen, tmp);
 +    } else if (comp_level == 15) {
 +        lzo1x_1_15_compress(orig, s, comp, &clen, tmp);
 +    } else
 +        lzo1x_999_compress(orig, s, comp, &clen, tmp);
 +    for (i = 0; i < 300; i++) {
 +START_TIMER
 +        inlen = clen; outlen = MAXSZ;
 +#if BENCHMARK_LIBLZO_SAFE
 +        if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL))
 +#elif BENCHMARK_LIBLZO_UNSAFE
 +        if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL))
 +#else
 +        if (av_lzo1x_decode(decomp, &outlen, comp, &inlen))
 +#endif
 +            av_log(NULL, AV_LOG_ERROR, "decompression error\n");
 +STOP_TIMER("lzod")
 +    }
 +    if (memcmp(orig, decomp, s))
 +        av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n");
 +    else
 +        av_log(NULL, AV_LOG_ERROR, "decompression OK\n");
 +    fclose(in);
 +    av_free(orig);
 +    av_free(comp);
 +    av_free(decomp);
 +    return 0;
 +}
diff --cc libavutil/tests/murmur3.c
index edc7a18,0000000..b8d6b1f
mode 100644,000000..100644
--- a/libavutil/tests/murmur3.c
+++ b/libavutil/tests/murmur3.c
@@@ -1,58 -1,0 +1,58 @@@
 +/*
 + * Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger at gmx.de>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "intreadwrite.h"
- #include "mem.h"
- #include "murmur3.h"
++#include "libavutil/intreadwrite.h"
++#include "libavutil/mem.h"
++#include "libavutil/murmur3.h"
 +
 +int main(void)
 +{
 +    int i;
 +    uint8_t hash_result[16] = {0};
 +    struct AVMurMur3 *ctx = av_murmur3_alloc();
 +#if 1
 +    uint8_t in[256] = {0};
 +    uint8_t *hashes = av_mallocz(256 * 16);
 +    for (i = 0; i < 256; i++)
 +    {
 +        in[i] = i;
 +        av_murmur3_init_seeded(ctx, 256 - i);
 +        // Note: this actually tests hashing 0 bytes
 +        av_murmur3_update(ctx, in, i);
 +        av_murmur3_final(ctx, hashes + 16 * i);
 +    }
 +    av_murmur3_init_seeded(ctx, 0);
 +    av_murmur3_update(ctx, hashes, 256 * 16);
 +    av_murmur3_final(ctx, hash_result);
 +    av_free(hashes);
 +    av_freep(&ctx);
 +    printf("result: 0x%"PRIx64" 0x%"PRIx64"\n", AV_RL64(hash_result), AV_RL64(hash_result + 8));
 +    // official reference value is 32 bit
 +    return AV_RL32(hash_result) != 0x6384ba69;
 +#else
 +    uint8_t *in = av_mallocz(512*1024);
 +    av_murmur3_init(ctx);
 +    for (i = 0; i < 40*1024; i++)
 +        av_murmur3_update(ctx, in, 512*1024);
 +    av_murmur3_final(ctx, hash_result);
 +    av_free(in);
 +    return hash_result[0];
 +#endif
 +}
diff --cc libavutil/tests/opt.c
index e41782b,350ce3d..568eb45
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@@ -19,14 -19,12 +19,14 @@@
  #include <limits.h>
  #include <stdio.h>
  
- #include "common.h"
- #include "channel_layout.h"
- #include "error.h"
- #include "log.h"
- #include "mem.h"
- #include "rational.h"
- #include "opt.h"
- #include "pixdesc.h"
+ #include "libavutil/common.h"
++#include "libavutil/channel_layout.h"
+ #include "libavutil/error.h"
+ #include "libavutil/log.h"
+ #include "libavutil/mem.h"
+ #include "libavutil/rational.h"
+ #include "libavutil/opt.h"
++#include "libavutil/pixdesc.h"
  
  typedef struct TestContext {
      const AVClass *class;
diff --cc libavutil/tests/parseutils.c
index fa9c1c1,805c01f..682b390
--- a/libavutil/tests/parseutils.c
+++ b/libavutil/tests/parseutils.c
@@@ -16,26 -16,18 +16,26 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#define TEST
- #include "parseutils.c"
++#include "libavutil/parseutils.c"
 +
  #include <stdint.h>
  #include <stdio.h>
  
- #include "common.h"
- #include "log.h"
- #include "rational.h"
+ #include "libavutil/common.h"
+ #include "libavutil/log.h"
+ #include "libavutil/rational.h"
 -#include "libavutil/parseutils.h"
  
 -int main(void)
 +static uint32_t randomv = MKTAG('L','A','V','U');
 +
 +static uint32_t av_get_random_seed_deterministic(void)
 +{
 +    return randomv = randomv * 1664525 + 1013904223;
 +}
 +
 +static void test_av_parse_video_rate(void)
  {
      int i;
 -    uint8_t rgba[4];
      static const char *const rates[] = {
          "-inf",
          "inf",
diff --cc libavutil/tests/pca.c
index e56d618,0000000..2d9eb8f
mode 100644,000000..100644
--- a/libavutil/tests/pca.c
+++ b/libavutil/tests/pca.c
@@@ -1,102 -1,0 +1,102 @@@
 +/*
 + * principal component analysis (PCA)
 + * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "pca.c"
- #include "lfg.h"
++#include "libavutil/pca.c"
++#include "libavutil/lfg.h"
 +
 +#undef printf
 +#include <stdio.h>
 +#include <stdlib.h>
 +
 +int main(void){
 +    PCA *pca;
 +    int i, j, k;
 +#define LEN 8
 +    double eigenvector[LEN*LEN];
 +    double eigenvalue[LEN];
 +    AVLFG prng;
 +
 +    av_lfg_init(&prng, 1);
 +
 +    pca= ff_pca_init(LEN);
 +
 +    for(i=0; i<9000000; i++){
 +        double v[2*LEN+100];
 +        double sum=0;
 +        int pos = av_lfg_get(&prng) % LEN;
 +        int v2  = av_lfg_get(&prng) % 101 - 50;
 +        v[0]    = av_lfg_get(&prng) % 101 - 50;
 +        for(j=1; j<8; j++){
 +            if(j<=pos) v[j]= v[0];
 +            else       v[j]= v2;
 +            sum += v[j];
 +        }
 +/*        for(j=0; j<LEN; j++){
 +            v[j] -= v[pos];
 +        }*/
 +//        sum += av_lfg_get(&prng) % 10;
 +/*        for(j=0; j<LEN; j++){
 +            v[j] -= sum/LEN;
 +        }*/
 +//        lbt1(v+100,v+100,LEN);
 +        ff_pca_add(pca, v);
 +    }
 +
 +
 +    ff_pca(pca, eigenvector, eigenvalue);
 +    for(i=0; i<LEN; i++){
 +        pca->count= 1;
 +        pca->mean[i]= 0;
 +
 +//        (0.5^|x|)^2 = 0.5^2|x| = 0.25^|x|
 +
 +
 +//        pca.covariance[i + i*LEN]= pow(0.5, fabs
 +        for(j=i; j<LEN; j++){
 +            printf("%f ", pca->covariance[i + j*LEN]);
 +        }
 +        printf("\n");
 +    }
 +
 +    for(i=0; i<LEN; i++){
 +        double v[LEN];
 +        double error=0;
 +        memset(v, 0, sizeof(v));
 +        for(j=0; j<LEN; j++){
 +            for(k=0; k<LEN; k++){
 +                v[j] += pca->covariance[FFMIN(k,j) + FFMAX(k,j)*LEN] * eigenvector[i + k*LEN];
 +            }
 +            v[j] /= eigenvalue[i];
 +            error += fabs(v[j] - eigenvector[i + j*LEN]);
 +        }
 +        printf("%f ", error);
 +    }
 +    printf("\n");
 +
 +    for(i=0; i<LEN; i++){
 +        for(j=0; j<LEN; j++){
 +            printf("%9.6f ", eigenvector[i + j*LEN]);
 +        }
 +        printf("  %9.1f %f\n", eigenvalue[i], eigenvalue[i]/eigenvalue[0]);
 +    }
 +
 +    return 0;
 +}
diff --cc libavutil/tests/pixdesc.c
index cd7d4c5,0000000..7fbfeea
mode 100644,000000..100644
--- a/libavutil/tests/pixdesc.c
+++ b/libavutil/tests/pixdesc.c
@@@ -1,46 -1,0 +1,46 @@@
 +/*
 + * pixel format descriptor
 + * Copyright (c) 2009 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "pixdesc.c"
++#include "libavutil/pixdesc.c"
 +
 +int main(void){
 +    int i;
 +    int err=0;
 +    int skip = 0;
 +
 +    for (i=0; i<AV_PIX_FMT_NB*2; i++) {
 +        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
 +        if(!desc || !desc->name) {
 +            skip ++;
 +            continue;
 +        }
 +        if (skip) {
 +            av_log(NULL, AV_LOG_INFO, "%3d unused pixel format values\n", skip);
 +            skip = 0;
 +        }
 +        av_log(NULL, AV_LOG_INFO, "pix fmt %s avg_bpp:%d colortype:%d\n", desc->name, av_get_padded_bits_per_pixel(desc), get_color_type(desc));
 +        if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) != (desc->nb_components != 2 && desc->nb_components != 4)) {
 +            av_log(NULL, AV_LOG_ERROR, "Alpha flag mismatch\n");
 +            err = 1;
 +        }
 +    }
 +    return err;
 +}
diff --cc libavutil/tests/pixelutils.c
index eebc524,0000000..ec4dc8f
mode 100644,000000..100644
--- a/libavutil/tests/pixelutils.c
+++ b/libavutil/tests/pixelutils.c
@@@ -1,152 -1,0 +1,152 @@@
 +/*
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "pixelutils.c"
++#include "libavutil/pixelutils.c"
 +
 +#define W1 320
 +#define H1 240
 +#define W2 640
 +#define H2 480
 +
 +static int run_single_test(const char *test,
 +                           const uint8_t *block1, ptrdiff_t stride1,
 +                           const uint8_t *block2, ptrdiff_t stride2,
 +                           int align, int n)
 +{
 +    int out, ref;
 +    av_pixelutils_sad_fn f_ref = sad_c[n - 1];
 +    av_pixelutils_sad_fn f_out = av_pixelutils_get_sad_fn(n, n, align, NULL);
 +
 +    switch (align) {
 +    case 0: block1++; block2++; break;
 +    case 1:           block2++; break;
 +    case 2:                     break;
 +    }
 +
 +    out = f_out(block1, stride1, block2, stride2);
 +    ref = f_ref(block1, stride1, block2, stride2);
 +    printf("[%s] [%c%c] SAD [%s] %dx%d=%d ref=%d\n",
 +           out == ref ? "OK" : "FAIL",
 +           align ? 'A' : 'U', align == 2 ? 'A' : 'U',
 +           test, 1<<n, 1<<n, out, ref);
 +    return out != ref;
 +}
 +
 +static int run_test(const char *test,
 +                    const uint8_t *b1, const uint8_t *b2)
 +{
 +    int i, a, ret = 0;
 +
 +    for (a = 0; a < 3; a++) {
 +        const uint8_t *block1 = b1;
 +        const uint8_t *block2 = b2;
 +
 +        switch (a) {
 +        case 0: block1++; block2++; break;
 +        case 1:           block2++; break;
 +        case 2:                     break;
 +        }
 +        for (i = 1; i <= FF_ARRAY_ELEMS(sad_c); i++) {
 +            int r = run_single_test(test, b1, W1, b2, W2, a, i);
 +            if (r)
 +                ret = r;
 +        }
 +    }
 +    return ret;
 +}
 +
 +int main(void)
 +{
 +    int i, align, ret;
 +    uint8_t *buf1 = av_malloc(W1*H1);
 +    uint8_t *buf2 = av_malloc(W2*H2);
 +    uint32_t state = 0;
 +
 +    if (!buf1 || !buf2) {
 +        fprintf(stderr, "malloc failure\n");
 +        ret = 1;
 +        goto end;
 +    }
 +
 +    ff_check_pixfmt_descriptors();
 +
 +#define RANDOM_INIT(buf, size) do {             \
 +    int k;                                      \
 +    for (k = 0; k < size; k++) {                \
 +        state = state * 1664525 + 1013904223;   \
 +        buf[k] = state>>24;                     \
 +    }                                           \
 +} while (0)
 +
 +    /* Normal test with different strides */
 +    RANDOM_INIT(buf1, W1*H1);
 +    RANDOM_INIT(buf2, W2*H2);
 +    ret = run_test("random", buf1, buf2);
 +    if (ret < 0)
 +        goto end;
 +
 +    /* Check for maximum SAD */
 +    memset(buf1, 0xff, W1*H1);
 +    memset(buf2, 0x00, W2*H2);
 +    ret = run_test("max", buf1, buf2);
 +    if (ret < 0)
 +        goto end;
 +
 +    /* Check for minimum SAD */
 +    memset(buf1, 0x90, W1*H1);
 +    memset(buf2, 0x90, W2*H2);
 +    ret = run_test("min", buf1, buf2);
 +    if (ret < 0)
 +        goto end;
 +
 +    /* Exact buffer sizes, to check for overreads */
 +    for (i = 1; i <= 4; i++) {
 +        for (align = 0; align < 3; align++) {
 +            int size1, size2;
 +
 +            av_freep(&buf1);
 +            av_freep(&buf2);
 +
 +            size1 = size2 = 1 << (i << 1);
 +
 +            switch (align) {
 +            case 0: size1++; size2++; break;
 +            case 1:          size2++; break;
 +            case 2:                   break;
 +            }
 +
 +            buf1 = av_malloc(size1);
 +            buf2 = av_malloc(size2);
 +            if (!buf1 || !buf2) {
 +                fprintf(stderr, "malloc failure\n");
 +                ret = 1;
 +                goto end;
 +            }
 +            RANDOM_INIT(buf1, size1);
 +            RANDOM_INIT(buf2, size2);
 +            ret = run_single_test("small", buf1, 1<<i, buf2, 1<<i, align, i);
 +            if (ret < 0)
 +                goto end;
 +        }
 +    }
 +
 +end:
 +    av_free(buf1);
 +    av_free(buf2);
 +    return ret;
 +}
diff --cc libavutil/tests/random_seed.c
index 182c8a6,0000000..ebe9b3e
mode 100644,000000..100644
--- a/libavutil/tests/random_seed.c
+++ b/libavutil/tests/random_seed.c
@@@ -1,46 -1,0 +1,46 @@@
 +/*
 + * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier at gmail.com>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#define TEST 1
- #include "random_seed.c"
++#include "libavutil/random_seed.c"
 +
 +#undef printf
 +#define N 256
 +#include <stdio.h>
 +
 +int main(void)
 +{
 +    int i, j, retry;
 +    uint32_t seeds[N];
 +
 +    for (retry=0; retry<3; retry++){
 +        for (i=0; i<N; i++){
 +            seeds[i] = av_get_random_seed();
 +            for (j=0; j<i; j++)
 +                if (seeds[j] == seeds[i])
 +                    goto retry;
 +        }
 +        printf("seeds OK\n");
 +        return 0;
 +        retry:;
 +    }
 +    printf("FAIL at %d with %X\n", j, seeds[j]);
 +    return 1;
 +}
diff --cc libavutil/tests/rational.c
index 455d9c4,0000000..caec07d
mode 100644,000000..100644
--- a/libavutil/tests/rational.c
+++ b/libavutil/tests/rational.c
@@@ -1,135 -1,0 +1,134 @@@
 +/*
 + * rational numbers
 + * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "rational.c"
- 
- #include "integer.h"
++#include "libavutil/rational.c"
++#include "libavutil/integer.h"
 +
 +int main(void)
 +{
 +    AVRational a,b,r;
 +    int i,j,k;
 +    static const int64_t numlist[] = {
 +        INT64_MIN, INT64_MIN+1, INT64_MAX, INT32_MIN, INT32_MAX, 1,0,-1,
 +        123456789, INT32_MAX-1, INT32_MAX+1LL, UINT32_MAX-1, UINT32_MAX, UINT32_MAX+1LL
 +    };
 +
 +    for (a.num = -2; a.num <= 2; a.num++) {
 +        for (a.den = -2; a.den <= 2; a.den++) {
 +            for (b.num = -2; b.num <= 2; b.num++) {
 +                for (b.den = -2; b.den <= 2; b.den++) {
 +                    int c = av_cmp_q(a,b);
 +                    double d = av_q2d(a) == av_q2d(b) ?
 +                               0 : (av_q2d(a) - av_q2d(b));
 +                    if (d > 0)       d = 1;
 +                    else if (d < 0)  d = -1;
 +                    else if (d != d) d = INT_MIN;
 +                    if (c != d)
 +                        av_log(NULL, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num,
 +                               a.den, b.num, b.den, c,d);
 +                    r = av_sub_q(av_add_q(b,a), b);
 +                    if(b.den && (r.num*a.den != a.num*r.den || !r.num != !a.num || !r.den != !a.den))
 +                        av_log(NULL, AV_LOG_ERROR, "%d/%d ", r.num, r.den);
 +                }
 +            }
 +        }
 +    }
 +
 +    for (i = 0; i < FF_ARRAY_ELEMS(numlist); i++) {
 +        int64_t a = numlist[i];
 +
 +        for (j = 0; j < FF_ARRAY_ELEMS(numlist); j++) {
 +            int64_t b = numlist[j];
 +            if (b<=0)
 +                continue;
 +            for (k = 0; k < FF_ARRAY_ELEMS(numlist); k++) {
 +                int64_t c = numlist[k];
 +                int64_t res;
 +                AVInteger ai;
 +
 +                if (c<=0)
 +                    continue;
 +                res = av_rescale_rnd(a,b,c, AV_ROUND_ZERO);
 +
 +                ai = av_mul_i(av_int2i(a), av_int2i(b));
 +                ai = av_div_i(ai, av_int2i(c));
 +
 +                if (av_cmp_i(ai, av_int2i(INT64_MAX)) > 0 && res == INT64_MIN)
 +                    continue;
 +                if (av_cmp_i(ai, av_int2i(INT64_MIN)) < 0 && res == INT64_MIN)
 +                    continue;
 +                if (av_cmp_i(ai, av_int2i(res)) == 0)
 +                    continue;
 +
 +                // Special exception for INT64_MIN, remove this in case INT64_MIN is handled without off by 1 error
 +                if (av_cmp_i(ai, av_int2i(res-1)) == 0 && a == INT64_MIN)
 +                    continue;
 +
 +                av_log(NULL, AV_LOG_ERROR, "%"PRId64" * %"PRId64" / %"PRId64" = %"PRId64" or %"PRId64"\n", a,b,c, res, av_i2int(ai));
 +            }
 +        }
 +    }
 +
 +    for (a.num = 1; a.num <= 10; a.num++) {
 +        for (a.den = 1; a.den <= 10; a.den++) {
 +            if (av_gcd(a.num, a.den) > 1)
 +                continue;
 +            for (b.num = 1; b.num <= 10; b.num++) {
 +                for (b.den = 1; b.den <= 10; b.den++) {
 +                    int start;
 +                    if (av_gcd(b.num, b.den) > 1)
 +                        continue;
 +                    if (av_cmp_q(b, a) < 0)
 +                        continue;
 +                    for (start = 0; start < 10 ; start++) {
 +                        int acc= start;
 +                        int i;
 +
 +                        for (i = 0; i<100; i++) {
 +                            int exact = start + av_rescale_q(i+1, b, a);
 +                            acc = av_add_stable(a, acc, b, 1);
 +                            if (FFABS(acc - exact) > 2) {
 +                                av_log(NULL, AV_LOG_ERROR, "%d/%d %d/%d, %d %d\n", a.num,
 +                                       a.den, b.num, b.den, acc, exact);
 +                                return 1;
 +                            }
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +    }
 +
 +    for (a.den = 1; a.den < 0x100000000U/3; a.den*=3) {
 +        for (a.num = -1; a.num < (1<<27); a.num += 1 + a.num/100) {
 +            float f  = av_int2float(av_q2intfloat(a));
 +            float f2 = av_q2d(a);
 +            if (fabs(f - f2) > fabs(f)/5000000) {
 +                av_log(NULL, AV_LOG_ERROR, "%d/%d %f %f\n", a.num,
 +                       a.den, f, f2);
 +                return 1;
 +            }
 +
 +        }
 +    }
 +
 +    return 0;
 +}
diff --cc libavutil/tests/ripemd.c
index 2a60bbe,0000000..58e5fce
mode 100644,000000..100644
--- a/libavutil/tests/ripemd.c
+++ b/libavutil/tests/ripemd.c
@@@ -1,80 -1,0 +1,80 @@@
 +/*
 + * Copyright (C) 2007 Michael Niedermayer <michaelni at gmx.at>
 + * Copyright (C) 2013 James Almer
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <stdio.h>
 +
- #include "mem.h"
- #include "ripemd.h"
++#include "libavutil/mem.h"
++#include "libavutil/ripemd.h"
 +
 +int main(void)
 +{
 +    int i, j, k;
 +    struct AVRIPEMD *ctx;
 +    unsigned char digest[40];
 +    static const int lengths[4] = { 128, 160, 256, 320 };
 +
 +    ctx = av_ripemd_alloc();
 +    if (!ctx)
 +        return 1;
 +
 +    for (j = 0; j < 4; j++) {
 +        printf("Testing RIPEMD-%d\n", lengths[j]);
 +        for (k = 0; k < 3; k++) {
 +            av_ripemd_init(ctx, lengths[j]);
 +            if (k == 0)
 +                av_ripemd_update(ctx, "abc", 3);
 +            else if (k == 1)
 +                av_ripemd_update(ctx, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56);
 +            else
 +                for (i = 0; i < 1000*1000; i++)
 +                    av_ripemd_update(ctx, "a", 1);
 +            av_ripemd_final(ctx, digest);
 +            for (i = 0; i < lengths[j] >> 3; i++)
 +                printf("%02X", digest[i]);
 +            putchar('\n');
 +        }
 +        switch (j) { //test vectors (from ISO:IEC 10118-3 (2004) and http://homes.esat.kuleuven.be/~bosselae/ripemd160.html)
 +        case 0:
 +            printf("c14a1219 9c66e4ba 84636b0f 69144c77\n"
 +                   "a1aa0689 d0fafa2d dc22e88b 49133a06\n"
 +                   "4a7f5723 f954eba1 216c9d8f 6320431f\n");
 +            break;
 +        case 1:
 +            printf("8eb208f7 e05d987a 9b044a8e 98c6b087 f15a0bfc\n"
 +                   "12a05338 4a9c0c88 e405a06c 27dcf49a da62eb2b\n"
 +                   "52783243 c1697bdb e16d37f9 7f68f083 25dc1528\n");
 +            break;
 +        case 2:
 +            printf("afbd6e22 8b9d8cbb cef5ca2d 03e6dba1 0ac0bc7d cbe4680e 1e42d2e9 75459b65\n"
 +                   "38430455 83aac6c8 c8d91285 73e7a980 9afb2a0f 34ccc36e a9e72f16 f6368e3f\n"
 +                   "ac953744 e10e3151 4c150d4d 8d7b6773 42e33399 788296e4 3ae4850c e4f97978\n");
 +            break;
 +        case 3:
 +            printf("de4c01b3 054f8930 a79d09ae 738e9230 1e5a1708 5beffdc1 b8d11671 3e74f82f a942d64c dbc4682d\n"
 +                   "d034a795 0cf72202 1ba4b84d f769a5de 2060e259 df4c9bb4 a4268c0e 935bbc74 70a969c9 d072a1ac\n"
 +                   "bdee37f4 371e2064 6b8b0d86 2dda1629 2ae36f40 965e8c85 09e63d1d bddecc50 3e2b63eb 9245bb66\n");
 +            break;
 +        }
 +    }
 +    av_free(ctx);
 +
 +    return 0;
 +}
diff --cc libavutil/tests/sha.c
index 7af2c04,0f1d514..a95b3a0
--- a/libavutil/tests/sha.c
+++ b/libavutil/tests/sha.c
@@@ -16,11 -16,10 +16,11 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 -#include "libavutil/sha.c"
 -
  #include <stdio.h>
  
- #include "mem.h"
- #include "sha.h"
++#include "libavutil/mem.h"
++#include "libavutil/sha.h"
 +
  int main(void)
  {
      int i, j, k;
diff --cc libavutil/tests/sha512.c
index 32ff508,0000000..f3b90fd
mode 100644,000000..100644
--- a/libavutil/tests/sha512.c
+++ b/libavutil/tests/sha512.c
@@@ -1,90 -1,0 +1,90 @@@
 +/*
 + * Copyright (C) 2007 Michael Niedermayer <michaelni at gmx.at>
 + * Copyright (C) 2009 Konstantin Shishkov
 + * Copyright (C) 2013 James Almer
 + * based on BSD-licensed SHA-2 code by Aaron D. Gifford
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <stdio.h>
 +
- #include "mem.h"
- #include "sha512.h"
++#include "libavutil/mem.h"
++#include "libavutil/sha512.h"
 +
 +int main(void)
 +{
 +    int i, j, k;
 +    struct AVSHA512 *ctx;
 +    unsigned char digest[64];
 +    static const int lengths[4] = { 224, 256, 384, 512 };
 +
 +    ctx = av_sha512_alloc();
 +    if (!ctx)
 +        return 1;
 +
 +    for (j = 0; j < 4; j++) {
 +        if (j < 2) printf("Testing SHA-512/%d\n", lengths[j]);
 +        else       printf("Testing SHA-%d\n", lengths[j]);
 +        for (k = 0; k < 3; k++) {
 +            av_sha512_init(ctx, lengths[j]);
 +            if (k == 0)
 +                av_sha512_update(ctx, "abc", 3);
 +            else if (k == 1)
 +                av_sha512_update(ctx, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
 +                                       "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112);
 +            else
 +                for (i = 0; i < 1000*1000; i++)
 +                    av_sha512_update(ctx, "a", 1);
 +            av_sha512_final(ctx, digest);
 +            for (i = 0; i < lengths[j] >> 3; i++)
 +                printf("%02X", digest[i]);
 +            putchar('\n');
 +        }
 +        switch (j) { //test vectors (from FIPS PUB 180-4 Apendix A)
 +        case 0:
 +            printf("4634270f 707b6a54 daae7530 460842e2 0e37ed26 5ceee9a4 3e8924aa\n"
 +                   "23fec5bb 94d60b23 30819264 0b0c4533 35d66473 4fe40e72 68674af9\n"
 +                   "37ab331d 76f0d36d e422bd0e deb22a28 accd487b 7a8453ae 965dd287\n");
 +            break;
 +        case 1:
 +            printf("53048e26 81941ef9 9b2e29b7 6b4c7dab e4c2d0c6 34fc6d46 e0e2f131 07e7af23\n"
 +                   "3928e184 fb8690f8 40da3988 121d31be 65cb9d3e f83ee614 6feac861 e19b563a\n"
 +                   "9a59a052 930187a9 7038cae6 92f30708 aa649192 3ef51943 94dc68d5 6c74fb21\n");
 +            break;
 +        case 2:
 +            printf("cb00753f 45a35e8b b5a03d69 9ac65007 272c32ab 0eded163 "
 +                   "1a8b605a 43ff5bed 8086072b a1e7cc23 58baeca1 34c825a7\n"
 +                   "09330c33 f71147e8 3d192fc7 82cd1b47 53111b17 3b3b05d2 "
 +                   "2fa08086 e3b0f712 fcc7c71a 557e2db9 66c3e9fa 91746039\n"
 +                   "9d0e1809 716474cb 086e834e 310a4a1c ed149e9c 00f24852 "
 +                   "7972cec5 704c2a5b 07b8b3dc 38ecc4eb ae97ddd8 7f3d8985\n");
 +            break;
 +        case 3:
 +            printf("ddaf35a1 93617aba cc417349 ae204131 12e6fa4e 89a97ea2 0a9eeee6 4b55d39a "
 +                   "2192992a 274fc1a8 36ba3c23 a3feebbd 454d4423 643ce80e 2a9ac94f a54ca49f\n"
 +                   "8e959b75 dae313da 8cf4f728 14fc143f 8f7779c6 eb9f7fa1 7299aead b6889018 "
 +                   "501d289e 4900f7e4 331b99de c4b5433a c7d329ee b6dd2654 5e96e55b 874be909\n"
 +                   "e718483d 0ce76964 4e2e42c7 bc15b463 8e1f98b1 3b204428 5632a803 afa973eb "
 +                   "de0ff244 877ea60a 4cb0432c e577c31b eb009c5c 2c49aa2e 4eadb217 ad8cc09b\n");
 +            break;
 +        }
 +    }
 +    av_free(ctx);
 +
 +    return 0;
 +}
diff --cc libavutil/tests/softfloat.c
index 3293450,0000000..16788d4
mode 100644,000000..100644
--- a/libavutil/tests/softfloat.c
+++ b/libavutil/tests/softfloat.c
@@@ -1,155 -1,0 +1,156 @@@
 +/*
 + * copyright (c) 2006 Michael Niedermayer <michaelni at gmx.at>
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <inttypes.h>
- #include "softfloat.h"
- #include "common.h"
- #include "log.h"
++
++#include "libavutil/softfloat.h"
++#include "libavutil/common.h"
++#include "libavutil/log.h"
 +
 +#include <stdio.h>
 +
 +static const SoftFloat FLOAT_0_017776489257 = {0x1234, 12};
 +static const SoftFloat FLOAT_1374_40625 = {0xabcd, 25};
 +static const SoftFloat FLOAT_0_1249694824218 = {0xFFF, 15};
 +
 +
 +int main(void){
 +    SoftFloat one= av_int2sf(1, 0);
 +    SoftFloat sf1, sf2, sf3;
 +    double d1, d2, d3;
 +    int i, j;
 +    av_log_set_level(AV_LOG_DEBUG);
 +
 +    d1= 1;
 +    for(i= 0; i<10; i++){
 +        d1= 1/(d1+1);
 +    }
 +    printf("test1 double=%d\n", (int)(d1 * (1<<24)));
 +
 +    sf1= one;
 +    for(i= 0; i<10; i++){
 +        sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
 +    }
 +    printf("test1 sf    =%d\n", av_sf2int(sf1, 24));
 +
 +
 +    for(i= 0; i<100; i++){
 +        START_TIMER
 +        d1= i;
 +        d2= i/100.0;
 +        for(j= 0; j<1000; j++){
 +            d1= (d1+1)*d2;
 +        }
 +        STOP_TIMER("float add mul")
 +    }
 +    printf("test2 double=%d\n", (int)(d1 * (1<<24)));
 +
 +    for(i= 0; i<100; i++){
 +        START_TIMER
 +        sf1= av_int2sf(i, 0);
 +        sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
 +        for(j= 0; j<1000; j++){
 +            sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
 +        }
 +        STOP_TIMER("softfloat add mul")
 +    }
 +    printf("test2 sf    =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
 +
 +    d1 = 0.0177764893;
 +    d2 = 1374.40625;
 +    d3 = 0.1249694824;
 +    d2 += d1;
 +    d3 += d2;
 +    printf("test3 double: %.10lf\n", d3);
 +
 +    sf1 = FLOAT_0_017776489257;
 +    sf2 = FLOAT_1374_40625;
 +    sf3 = FLOAT_0_1249694824218;
 +    sf2 = av_add_sf(sf1, sf2);
 +    sf3 = av_add_sf(sf3, sf2);
 +    printf("test3 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf3), sf3.mant, sf3.exp);
 +
 +    sf1 = av_int2sf(0xFFFFFFF0, 0);
 +    printf("test4 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp);
 +    sf1 = av_int2sf(0x00000010, 0);
 +    printf("test4 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp);
 +
 +    sf1 = av_int2sf(0x1FFFFFFF, 0);
 +    printf("test4 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp);
 +    sf1 = av_int2sf(0xE0000001, 0);
 +    printf("test4 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp);
 +
 +
 +    sf1 = (SoftFloat){ 0x20000000,   MIN_EXP };
 +    sf1 = av_mul_sf(sf1, sf1);
 +    printf("test5 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp);
 +
 +    sf1 = (SoftFloat){ 0x20000000,   MIN_EXP };
 +    sf2 = (SoftFloat){ 0x20000000,   MAX_EXP };
 +    i = av_cmp_sf(sf1, sf2);
 +    j = av_cmp_sf(sf2, sf1);
 +    sf1 = av_div_sf(sf1, sf2);
 +    printf("test6 softfloat: %.10lf (0x%08x %d) %d %d\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp, i, j);
 +
 +    for(i= -50; i<50; i++) {
 +        sf1= av_int2sf(i, 0);
 +        for(j= -50; j<50; j++) {
 +            int c;
 +            sf2= av_int2sf(j, 0);
 +            c = av_cmp_sf(sf1, sf2);
 +            if (FFDIFFSIGN(i,j) != c && (FFDIFFSIGN(i,j)^c)<0) {
 +                printf("av_cmp_sf failed at %d %d as %X\n", i, j, c);
 +            }
 +            c = av_gt_sf(sf1, sf2);
 +            if ((i>j) != c) {
 +                printf("av_gt_sf failed at %d %d as %X\n", i, j, c);
 +            }
 +        }
 +        sf1 = av_int2sf(1, i);
 +        for(j = -50; j < 50; j++) {
 +            int c;
 +            sf2 = av_int2sf(1, j);
 +            c = av_cmp_sf(sf2, sf1);
 +            if (FFDIFFSIGN(i,j) != c && (FFDIFFSIGN(i,j)^c) < 0) {
 +                printf("av_cmp_sf failed2 at %d %d as %X\n", i, j, c);
 +            }
 +            c = av_gt_sf(sf1, sf2);
 +            if ((i<j) != c) {
 +                printf("av_gt_sf failed2 at %d %d as %X\n", i, j, c);
 +            }
 +        }
 +    }
 +
 +
 +    for(i= 0; i<4*36; i++){
 +        int s, c;
 +        double errs, errc;
 +
 +        av_sincos_sf(i*(1ULL<<32)/36/4, &s, &c);
 +        errs = (double)s/ (1<<30) - sin(i*M_PI/36);
 +        errc = (double)c/ (1<<30) - cos(i*M_PI/36);
 +        if (fabs(errs) > 0.00000002 || fabs(errc) >0.001) {
 +            printf("sincos FAIL %d %f %f %f %f\n", i, (float)s/ (1<<30), (float)c/ (1<<30), sin(i*M_PI/36), cos(i*M_PI/36));
 +        }
 +
 +    }
 +    return 0;
 +
 +}
diff --cc libavutil/tests/tea.c
index 9bf059b,0000000..605bb52
mode 100644,000000..100644
--- a/libavutil/tests/tea.c
+++ b/libavutil/tests/tea.c
@@@ -1,115 -1,0 +1,115 @@@
 +/*
 + * A 32-bit implementation of the TEA algorithm
 + * Copyright (c) 2015 Vesselin Bontchev
 + *
 + * Loosely based on the implementation of David Wheeler and Roger Needham,
 + * https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm#Reference_code
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include <stdio.h>
 +
- #include "common.h"
- #include "tea.h"
++#include "libavutil/common.h"
++#include "libavutil/tea.h"
 +
 +#define TEA_NUM_TESTS 4
 +
 +// https://github.com/logandrews/TeaCrypt/blob/master/tea/tea_test.go
 +static const uint8_t tea_test_key[TEA_NUM_TESTS][16] = {
 +    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 +      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 +    },
 +    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 +      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 +    },
 +    { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
 +      0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
 +    },
 +    { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
 +      0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
 +    }
 +};
 +
 +static const uint8_t tea_test_pt[TEA_NUM_TESTS][8] = {
 +    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
 +    { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 },
 +    { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 },
 +    { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }
 +};
 +
 +static const uint8_t tea_test_ct[TEA_NUM_TESTS][8] = {
 +    { 0x41, 0xEA, 0x3A, 0x0A, 0x94, 0xBA, 0xA9, 0x40 },
 +    { 0x6A, 0x2F, 0x9C, 0xF3, 0xFC, 0xCF, 0x3C, 0x55 },
 +    { 0xDE, 0xB1, 0xC0, 0xA2, 0x7E, 0x74, 0x5D, 0xB3 },
 +    { 0x12, 0x6C, 0x6B, 0x92, 0xC0, 0x65, 0x3A, 0x3E }
 +};
 +
 +static void test_tea(struct AVTEA *ctx, uint8_t *dst, const uint8_t *src,
 +                     const uint8_t *ref, int len, uint8_t *iv, int dir,
 +                     const char *test)
 +{
 +    av_tea_crypt(ctx, dst, src, len, iv, dir);
 +    if (memcmp(dst, ref, 8*len)) {
 +        int i;
 +        printf("%s failed\ngot      ", test);
 +        for (i = 0; i < 8*len; i++)
 +            printf("%02x ", dst[i]);
 +        printf("\nexpected ");
 +        for (i = 0; i < 8*len; i++)
 +            printf("%02x ", ref[i]);
 +        printf("\n");
 +        exit(1);
 +    }
 +}
 +
 +int main(void)
 +{
 +    struct AVTEA *ctx;
 +    uint8_t buf[8], iv[8];
 +    int i;
 +    static const uint8_t src[32] = "HelloWorldHelloWorldHelloWorld";
 +    uint8_t ct[32];
 +    uint8_t pl[32];
 +
 +    ctx = av_tea_alloc();
 +    if (!ctx)
 +        return 1;
 +
 +    for (i = 0; i < TEA_NUM_TESTS; i++) {
 +        av_tea_init(ctx, tea_test_key[i], 64);
 +
 +        test_tea(ctx, buf, tea_test_pt[i], tea_test_ct[i], 1, NULL, 0, "encryption");
 +        test_tea(ctx, buf, tea_test_ct[i], tea_test_pt[i], 1, NULL, 1, "decryption");
 +
 +        /* encrypt */
 +        memcpy(iv, "HALLO123", 8);
 +        av_tea_crypt(ctx, ct, src, 4, iv, 0);
 +
 +        /* decrypt into pl */
 +        memcpy(iv, "HALLO123", 8);
 +        test_tea(ctx, pl, ct, src, 4, iv, 1, "CBC decryption");
 +
 +        memcpy(iv, "HALLO123", 8);
 +        test_tea(ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption");
 +    }
 +
 +    printf("Test encryption/decryption success.\n");
 +    av_free(ctx);
 +
 +    return 0;
 +}
diff --cc libavutil/tests/twofish.c
index be0586a9,0000000..74e0926
mode 100644,000000..100644
--- a/libavutil/tests/twofish.c
+++ b/libavutil/tests/twofish.c
@@@ -1,94 -1,0 +1,94 @@@
 +/*
 + * An implementation of the TwoFish algorithm
 + * Copyright (c) 2015 Supraja Meedinti
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
- #include "log.h"
- #include "twofish.h"
++#include "libavutil/log.h"
++#include "libavutil/twofish.h"
 +
 +#include <stdio.h>
 +#include <stdlib.h>
 +
 +int main(int argc, char *argv[])
 +{
 +    uint8_t Key[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
 +    };
 +    const uint8_t rct[6][16] = {
 +        {0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32, 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a},
 +        {0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf, 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48},
 +        {0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8, 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20},
 +        {0x5d, 0x9d, 0x4e, 0xef, 0xfa, 0x91, 0x51, 0x57, 0x55, 0x24, 0xf1, 0x15, 0x81, 0x5a, 0x12, 0xe0},
 +        {0xe7, 0x54, 0x49, 0x21, 0x2b, 0xee, 0xf9, 0xf4, 0xa3, 0x90, 0xbd, 0x86, 0x0a, 0x64, 0x09, 0x41},
 +        {0x37, 0xfe, 0x26, 0xff, 0x1c, 0xf6, 0x61, 0x75, 0xf5, 0xdd, 0xf4, 0xc3, 0x3b, 0x97, 0xa2, 0x05}
 +    };
 +    uint8_t temp[32], iv[16], rpt[32] = {0};
 +    const int kbits[3] = {128, 192, 256};
 +    int i, j, err = 0;
 +    struct AVTWOFISH *cs;
 +    cs = av_twofish_alloc();
 +    if (!cs)
 +        return 1;
 +    for (j = 1; j < 3; j++) {
 +        av_twofish_init(cs, Key, kbits[j]);
 +        av_twofish_crypt(cs, temp, rpt, 1, NULL, 0);
 +        for (i = 0; i < 16; i++) {
 +            if (rct[j][i] != temp[i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[j][i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +        av_twofish_crypt(cs, temp, rct[j], 1, NULL, 1);
 +        for (i = 0; i < 16; i++) {
 +            if (rpt[i] != temp[i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +    }
 +    for (j = 0; j < 3; j++) {
 +        memset(Key, 0, sizeof(Key));
 +        memset(rpt, 0, sizeof(rpt));
 +        for (i = 1; i < 50; i++) {
 +            av_twofish_init(cs, Key, kbits[j]);
 +            av_twofish_crypt(cs, temp, rpt, 1, NULL, 0);
 +            memcpy(Key+16,Key,(kbits[j]-128) >> 3);
 +            memcpy(Key,rpt,16);
 +            memcpy(rpt,temp,16);
 +        }
 +        for (i = 0; i < 16; i++) {
 +            if (rct[3 + j][i] != temp[i]) {
 +                av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[3 + j][i], temp[i]);
 +                err = 1;
 +            }
 +        }
 +    }
 +    memset(rpt, 0, sizeof(rpt));
 +    memcpy(iv, "HALLO123HALLO123", 16);
 +    av_twofish_crypt(cs, temp, rpt, 2, iv, 0);
 +    memcpy(iv, "HALLO123HALLO123", 16);
 +    av_twofish_crypt(cs, temp, temp, 2, iv, 1);
 +    for (i = 0; i < 32; i++) {
 +        if (rpt[i] != temp[i]) {
 +            av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]);
 +            err = 1;
 +        }
 +    }
 +    av_free(cs);
 +    return err;
 +}
diff --cc libavutil/tests/utf8.c
index 37a2802,0000000..37a2802
mode 100644,000000..100644
--- a/libavutil/tests/utf8.c
+++ b/libavutil/tests/utf8.c
diff --cc library.mak
index 5bfa796,712b7e1..ae2d3f2
--- a/library.mak
+++ b/library.mak
@@@ -43,21 -38,18 +43,22 @@@ $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o 
  $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
  	$(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
  
 -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS)
 +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
  	$(SLIB_CREATE_DEF_CMD)
 -	$$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
 +	$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDLIBFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
  	$(SLIB_EXTRA_CMD)
  
 +ifdef SUBDIR
 +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
 +endif
 +
  clean::
- 	$(RM) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
- 	    $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
- 
+ 	$(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
+ 	    $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%)
 -
++ 
  distclean:: clean
- 	$(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
+ 	$(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) \
+             $(DISTCLEANSUFFIXES:%=$(SUBDIR)tests/%)
  
  install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
  	$(Q)mkdir -p "$(SHLIBDIR)"
diff --cc libswresample/tests/.gitignore
index 0000000,0000000..2dc986b
new file mode 100644
--- /dev/null
+++ b/libswresample/tests/.gitignore
@@@ -1,0 -1,0 +1,1 @@@
++/swresample
diff --cc libswresample/tests/swresample.c
index 0aa47c8,0000000..9ba7735
mode 100644,000000..100644
--- a/libswresample/tests/swresample.c
+++ b/libswresample/tests/swresample.c
@@@ -1,421 -1,0 +1,422 @@@
 +/*
 + * Copyright (C) 2011-2012 Michael Niedermayer (michaelni at gmx.at)
 + * Copyright (c) 2002 Fabrice Bellard
 + *
 + * This file is part of libswresample
 + *
 + * libswresample is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * libswresample is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with libswresample; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include "libavutil/avassert.h"
 +#include "libavutil/channel_layout.h"
 +#include "libavutil/common.h"
 +#include "libavutil/opt.h"
- #include "swresample.h"
++
++#include "libswresample/swresample.h"
 +
 +#undef time
 +#include "time.h"
 +#undef fprintf
 +
 +#define SAMPLES 1000
 +
 +#define SWR_CH_MAX 32
 +
 +#define ASSERT_LEVEL 2
 +
 +static double get(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f){
 +    const uint8_t *p;
 +    if(av_sample_fmt_is_planar(f)){
 +        f= av_get_alt_sample_fmt(f, 0);
 +        p= a[ch];
 +    }else{
 +        p= a[0];
 +        index= ch + index*ch_count;
 +    }
 +
 +    switch(f){
 +    case AV_SAMPLE_FMT_U8 : return ((const uint8_t*)p)[index]/127.0-1.0;
 +    case AV_SAMPLE_FMT_S16: return ((const int16_t*)p)[index]/32767.0;
 +    case AV_SAMPLE_FMT_S32: return ((const int32_t*)p)[index]/2147483647.0;
 +    case AV_SAMPLE_FMT_FLT: return ((const float  *)p)[index];
 +    case AV_SAMPLE_FMT_DBL: return ((const double *)p)[index];
 +    default: av_assert0(0);
 +    }
 +}
 +
 +static void  set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v){
 +    uint8_t *p;
 +    if(av_sample_fmt_is_planar(f)){
 +        f= av_get_alt_sample_fmt(f, 0);
 +        p= a[ch];
 +    }else{
 +        p= a[0];
 +        index= ch + index*ch_count;
 +    }
 +    switch(f){
 +    case AV_SAMPLE_FMT_U8 : ((uint8_t*)p)[index]= av_clip_uint8 (lrint((v+1.0)*127));     break;
 +    case AV_SAMPLE_FMT_S16: ((int16_t*)p)[index]= av_clip_int16 (lrint(v*32767));         break;
 +    case AV_SAMPLE_FMT_S32: ((int32_t*)p)[index]= av_clipl_int32(llrint(v*2147483647));   break;
 +    case AV_SAMPLE_FMT_FLT: ((float  *)p)[index]= v;                                      break;
 +    case AV_SAMPLE_FMT_DBL: ((double *)p)[index]= v;                                      break;
 +    default: av_assert2(0);
 +    }
 +}
 +
 +static void shift(uint8_t *a[], int index, int ch_count, enum AVSampleFormat f){
 +    int ch;
 +
 +    if(av_sample_fmt_is_planar(f)){
 +        f= av_get_alt_sample_fmt(f, 0);
 +        for(ch= 0; ch<ch_count; ch++)
 +            a[ch] += index*av_get_bytes_per_sample(f);
 +    }else{
 +        a[0] += index*ch_count*av_get_bytes_per_sample(f);
 +    }
 +}
 +
 +static const enum AVSampleFormat formats[] = {
 +    AV_SAMPLE_FMT_S16,
 +    AV_SAMPLE_FMT_FLTP,
 +    AV_SAMPLE_FMT_S16P,
 +    AV_SAMPLE_FMT_FLT,
 +    AV_SAMPLE_FMT_S32P,
 +    AV_SAMPLE_FMT_S32,
 +    AV_SAMPLE_FMT_U8P,
 +    AV_SAMPLE_FMT_U8,
 +    AV_SAMPLE_FMT_DBLP,
 +    AV_SAMPLE_FMT_DBL,
 +};
 +
 +static const int rates[] = {
 +    8000,
 +    11025,
 +    16000,
 +    22050,
 +    32000,
 +    48000,
 +};
 +
 +static const uint64_t layouts[]={
 +    AV_CH_LAYOUT_MONO                    ,
 +    AV_CH_LAYOUT_STEREO                  ,
 +    AV_CH_LAYOUT_2_1                     ,
 +    AV_CH_LAYOUT_SURROUND                ,
 +    AV_CH_LAYOUT_4POINT0                 ,
 +    AV_CH_LAYOUT_2_2                     ,
 +    AV_CH_LAYOUT_QUAD                    ,
 +    AV_CH_LAYOUT_5POINT0                 ,
 +    AV_CH_LAYOUT_5POINT1                 ,
 +    AV_CH_LAYOUT_5POINT0_BACK            ,
 +    AV_CH_LAYOUT_5POINT1_BACK            ,
 +    AV_CH_LAYOUT_7POINT0                 ,
 +    AV_CH_LAYOUT_7POINT1                 ,
 +    AV_CH_LAYOUT_7POINT1_WIDE            ,
 +};
 +
 +static void setup_array(uint8_t *out[SWR_CH_MAX], uint8_t *in, enum AVSampleFormat format, int samples){
 +    if(av_sample_fmt_is_planar(format)){
 +        int i;
 +        int plane_size= av_get_bytes_per_sample(format&0xFF)*samples;
 +        format&=0xFF;
 +        for(i=0; i<SWR_CH_MAX; i++){
 +            out[i]= in + i*plane_size;
 +        }
 +    }else{
 +        out[0]= in;
 +    }
 +}
 +
 +static int cmp(const void *a, const void *b){
 +    return *(const int *)a - *(const int *)b;
 +}
 +
 +static void audiogen(void *data, enum AVSampleFormat sample_fmt,
 +                     int channels, int sample_rate, int nb_samples)
 +{
 +    int i, ch, k;
 +    double v, f, a, ampa;
 +    double tabf1[SWR_CH_MAX];
 +    double tabf2[SWR_CH_MAX];
 +    double taba[SWR_CH_MAX];
 +    unsigned static rnd;
 +
 +#define PUT_SAMPLE set(data, ch, k, channels, sample_fmt, v);
 +#define uint_rand(x) ((x) = (x) * 1664525 + 1013904223)
 +#define dbl_rand(x) (uint_rand(x)*2.0 / (double)UINT_MAX - 1)
 +    k = 0;
 +
 +    /* 1 second of single freq sinus at 1000 Hz */
 +    a = 0;
 +    for (i = 0; i < 1 * sample_rate && k < nb_samples; i++, k++) {
 +        v = sin(a) * 0.30;
 +        for (ch = 0; ch < channels; ch++)
 +            PUT_SAMPLE
 +        a += M_PI * 1000.0 * 2.0 / sample_rate;
 +    }
 +
 +    /* 1 second of varying frequency between 100 and 10000 Hz */
 +    a = 0;
 +    for (i = 0; i < 1 * sample_rate && k < nb_samples; i++, k++) {
 +        v = sin(a) * 0.30;
 +        for (ch = 0; ch < channels; ch++)
 +            PUT_SAMPLE
 +        f  = 100.0 + (((10000.0 - 100.0) * i) / sample_rate);
 +        a += M_PI * f * 2.0 / sample_rate;
 +    }
 +
 +    /* 0.5 second of low amplitude white noise */
 +    for (i = 0; i < sample_rate / 2 && k < nb_samples; i++, k++) {
 +        v = dbl_rand(rnd) * 0.30;
 +        for (ch = 0; ch < channels; ch++)
 +            PUT_SAMPLE
 +    }
 +
 +    /* 0.5 second of high amplitude white noise */
 +    for (i = 0; i < sample_rate / 2 && k < nb_samples; i++, k++) {
 +        v = dbl_rand(rnd);
 +        for (ch = 0; ch < channels; ch++)
 +            PUT_SAMPLE
 +    }
 +
 +    /* 1 second of unrelated ramps for each channel */
 +    for (ch = 0; ch < channels; ch++) {
 +        taba[ch]  = 0;
 +        tabf1[ch] = 100 + uint_rand(rnd) % 5000;
 +        tabf2[ch] = 100 + uint_rand(rnd) % 5000;
 +    }
 +    for (i = 0; i < 1 * sample_rate && k < nb_samples; i++, k++) {
 +        for (ch = 0; ch < channels; ch++) {
 +            v = sin(taba[ch]) * 0.30;
 +            PUT_SAMPLE
 +            f = tabf1[ch] + (((tabf2[ch] - tabf1[ch]) * i) / sample_rate);
 +            taba[ch] += M_PI * f * 2.0 / sample_rate;
 +        }
 +    }
 +
 +    /* 2 seconds of 500 Hz with varying volume */
 +    a    = 0;
 +    ampa = 0;
 +    for (i = 0; i < 2 * sample_rate && k < nb_samples; i++, k++) {
 +        for (ch = 0; ch < channels; ch++) {
 +            double amp = (1.0 + sin(ampa)) * 0.15;
 +            if (ch & 1)
 +                amp = 0.30 - amp;
 +            v = sin(a) * amp;
 +            PUT_SAMPLE
 +            a    += M_PI * 500.0 * 2.0 / sample_rate;
 +            ampa += M_PI *  2.0 / sample_rate;
 +        }
 +    }
 +}
 +
 +int main(int argc, char **argv){
 +    int in_sample_rate, out_sample_rate, ch ,i, flush_count;
 +    uint64_t in_ch_layout, out_ch_layout;
 +    enum AVSampleFormat in_sample_fmt, out_sample_fmt;
 +    uint8_t array_in[SAMPLES*8*8];
 +    uint8_t array_mid[SAMPLES*8*8*3];
 +    uint8_t array_out[SAMPLES*8*8+100];
 +    uint8_t *ain[SWR_CH_MAX];
 +    uint8_t *aout[SWR_CH_MAX];
 +    uint8_t *amid[SWR_CH_MAX];
 +    int flush_i=0;
 +    int mode;
 +    int num_tests = 10000;
 +    uint32_t seed = 0;
 +    uint32_t rand_seed = 0;
 +    int remaining_tests[FF_ARRAY_ELEMS(rates) * FF_ARRAY_ELEMS(layouts) * FF_ARRAY_ELEMS(formats) * FF_ARRAY_ELEMS(layouts) * FF_ARRAY_ELEMS(formats)];
 +    int max_tests = FF_ARRAY_ELEMS(remaining_tests);
 +    int test;
 +    int specific_test= -1;
 +
 +    struct SwrContext * forw_ctx= NULL;
 +    struct SwrContext *backw_ctx= NULL;
 +
 +    if (argc > 1) {
 +        if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
 +            av_log(NULL, AV_LOG_INFO, "Usage: swresample-test [<num_tests>[ <test>]]  \n"
 +                   "num_tests           Default is %d\n", num_tests);
 +            return 0;
 +        }
 +        num_tests = strtol(argv[1], NULL, 0);
 +        if(num_tests < 0) {
 +            num_tests = -num_tests;
 +            rand_seed = time(0);
 +        }
 +        if(num_tests<= 0 || num_tests>max_tests)
 +            num_tests = max_tests;
 +        if(argc > 2) {
 +            specific_test = strtol(argv[1], NULL, 0);
 +        }
 +    }
 +
 +    for(i=0; i<max_tests; i++)
 +        remaining_tests[i] = i;
 +
 +    for(test=0; test<num_tests; test++){
 +        unsigned r;
 +        uint_rand(seed);
 +        r = (seed * (uint64_t)(max_tests - test)) >>32;
 +        FFSWAP(int, remaining_tests[r], remaining_tests[max_tests - test - 1]);
 +    }
 +    qsort(remaining_tests + max_tests - num_tests, num_tests, sizeof(remaining_tests[0]), cmp);
 +    in_sample_rate=16000;
 +    for(test=0; test<num_tests; test++){
 +        char  in_layout_string[256];
 +        char out_layout_string[256];
 +        unsigned vector= remaining_tests[max_tests - test - 1];
 +        int in_ch_count;
 +        int out_count, mid_count, out_ch_count;
 +
 +        in_ch_layout    = layouts[vector % FF_ARRAY_ELEMS(layouts)]; vector /= FF_ARRAY_ELEMS(layouts);
 +        out_ch_layout   = layouts[vector % FF_ARRAY_ELEMS(layouts)]; vector /= FF_ARRAY_ELEMS(layouts);
 +        in_sample_fmt   = formats[vector % FF_ARRAY_ELEMS(formats)]; vector /= FF_ARRAY_ELEMS(formats);
 +        out_sample_fmt  = formats[vector % FF_ARRAY_ELEMS(formats)]; vector /= FF_ARRAY_ELEMS(formats);
 +        out_sample_rate = rates  [vector % FF_ARRAY_ELEMS(rates  )]; vector /= FF_ARRAY_ELEMS(rates);
 +        av_assert0(!vector);
 +
 +        if(specific_test == 0){
 +            if(out_sample_rate != in_sample_rate || in_ch_layout != out_ch_layout)
 +                continue;
 +        }
 +
 +        in_ch_count= av_get_channel_layout_nb_channels(in_ch_layout);
 +        out_ch_count= av_get_channel_layout_nb_channels(out_ch_layout);
 +        av_get_channel_layout_string( in_layout_string, sizeof( in_layout_string),  in_ch_count,  in_ch_layout);
 +        av_get_channel_layout_string(out_layout_string, sizeof(out_layout_string), out_ch_count, out_ch_layout);
 +        fprintf(stderr, "TEST: %s->%s, rate:%5d->%5d, fmt:%s->%s\n",
 +                in_layout_string, out_layout_string,
 +                in_sample_rate, out_sample_rate,
 +                av_get_sample_fmt_name(in_sample_fmt), av_get_sample_fmt_name(out_sample_fmt));
 +        forw_ctx  = swr_alloc_set_opts(forw_ctx, out_ch_layout, out_sample_fmt,  out_sample_rate,
 +                                                    in_ch_layout,  in_sample_fmt,  in_sample_rate,
 +                                        0, 0);
 +        backw_ctx = swr_alloc_set_opts(backw_ctx, in_ch_layout,  in_sample_fmt,             in_sample_rate,
 +                                                    out_ch_layout, out_sample_fmt, out_sample_rate,
 +                                        0, 0);
 +        if(!forw_ctx) {
 +            fprintf(stderr, "Failed to init forw_cts\n");
 +            return 1;
 +        }
 +        if(!backw_ctx) {
 +            fprintf(stderr, "Failed to init backw_ctx\n");
 +            return 1;
 +        }
 +        if (uint_rand(rand_seed) % 3 == 0)
 +            av_opt_set_int(forw_ctx, "ich", 0, 0);
 +        if (uint_rand(rand_seed) % 3 == 0)
 +            av_opt_set_int(forw_ctx, "och", 0, 0);
 +
 +        if(swr_init( forw_ctx) < 0)
 +            fprintf(stderr, "swr_init(->) failed\n");
 +        if(swr_init(backw_ctx) < 0)
 +            fprintf(stderr, "swr_init(<-) failed\n");
 +                //FIXME test planar
 +        setup_array(ain , array_in ,  in_sample_fmt,   SAMPLES);
 +        setup_array(amid, array_mid, out_sample_fmt, 3*SAMPLES);
 +        setup_array(aout, array_out,  in_sample_fmt           ,   SAMPLES);
 +#if 0
 +        for(ch=0; ch<in_ch_count; ch++){
 +            for(i=0; i<SAMPLES; i++)
 +                set(ain, ch, i, in_ch_count, in_sample_fmt, sin(i*i*3/SAMPLES));
 +        }
 +#else
 +        audiogen(ain, in_sample_fmt, in_ch_count, SAMPLES/6+1, SAMPLES);
 +#endif
 +        mode = uint_rand(rand_seed) % 3;
 +        if(mode==0 /*|| out_sample_rate == in_sample_rate*/) {
 +            mid_count= swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain, SAMPLES);
 +        } else if(mode==1){
 +            mid_count= swr_convert(forw_ctx, amid,         0, (const uint8_t **)ain, SAMPLES);
 +            mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain,       0);
 +        } else {
 +            int tmp_count;
 +            mid_count= swr_convert(forw_ctx, amid,         0, (const uint8_t **)ain,       1);
 +            av_assert0(mid_count==0);
 +            shift(ain,  1, in_ch_count, in_sample_fmt);
 +            mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain,       0);
 +            shift(amid,  mid_count, out_ch_count, out_sample_fmt); tmp_count = mid_count;
 +            mid_count+=swr_convert(forw_ctx, amid,         2, (const uint8_t **)ain,       2);
 +            shift(amid,  mid_count-tmp_count, out_ch_count, out_sample_fmt); tmp_count = mid_count;
 +            shift(ain,  2, in_ch_count, in_sample_fmt);
 +            mid_count+=swr_convert(forw_ctx, amid,         1, (const uint8_t **)ain, SAMPLES-3);
 +            shift(amid,  mid_count-tmp_count, out_ch_count, out_sample_fmt); tmp_count = mid_count;
 +            shift(ain, -3, in_ch_count, in_sample_fmt);
 +            mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain,       0);
 +            shift(amid,  -tmp_count, out_ch_count, out_sample_fmt);
 +        }
 +        out_count= swr_convert(backw_ctx,aout, SAMPLES, (const uint8_t **)amid, mid_count);
 +
 +        for(ch=0; ch<in_ch_count; ch++){
 +            double sse, maxdiff=0;
 +            double sum_a= 0;
 +            double sum_b= 0;
 +            double sum_aa= 0;
 +            double sum_bb= 0;
 +            double sum_ab= 0;
 +            for(i=0; i<out_count; i++){
 +                double a= get(ain , ch, i, in_ch_count, in_sample_fmt);
 +                double b= get(aout, ch, i, in_ch_count, in_sample_fmt);
 +                sum_a += a;
 +                sum_b += b;
 +                sum_aa+= a*a;
 +                sum_bb+= b*b;
 +                sum_ab+= a*b;
 +                maxdiff= FFMAX(maxdiff, fabs(a-b));
 +            }
 +            sse= sum_aa + sum_bb - 2*sum_ab;
 +            if(sse < 0 && sse > -0.00001) sse=0; //fix rounding error
 +
 +            fprintf(stderr, "[e:%f c:%f max:%f] len:%5d\n", out_count ? sqrt(sse/out_count) : 0, sum_ab/(sqrt(sum_aa*sum_bb)), maxdiff, out_count);
 +        }
 +
 +        flush_i++;
 +        flush_i%=21;
 +        flush_count = swr_convert(backw_ctx,aout, flush_i, 0, 0);
 +        shift(aout,  flush_i, in_ch_count, in_sample_fmt);
 +        flush_count+= swr_convert(backw_ctx,aout, SAMPLES-flush_i, 0, 0);
 +        shift(aout, -flush_i, in_ch_count, in_sample_fmt);
 +        if(flush_count){
 +            for(ch=0; ch<in_ch_count; ch++){
 +                double sse, maxdiff=0;
 +                double sum_a= 0;
 +                double sum_b= 0;
 +                double sum_aa= 0;
 +                double sum_bb= 0;
 +                double sum_ab= 0;
 +                for(i=0; i<flush_count; i++){
 +                    double a= get(ain , ch, i+out_count, in_ch_count, in_sample_fmt);
 +                    double b= get(aout, ch, i, in_ch_count, in_sample_fmt);
 +                    sum_a += a;
 +                    sum_b += b;
 +                    sum_aa+= a*a;
 +                    sum_bb+= b*b;
 +                    sum_ab+= a*b;
 +                    maxdiff= FFMAX(maxdiff, fabs(a-b));
 +                }
 +                sse= sum_aa + sum_bb - 2*sum_ab;
 +                if(sse < 0 && sse > -0.00001) sse=0; //fix rounding error
 +
 +                fprintf(stderr, "[e:%f c:%f max:%f] len:%5d F:%3d\n", sqrt(sse/flush_count), sum_ab/(sqrt(sum_aa*sum_bb)), maxdiff, flush_count, flush_i);
 +            }
 +        }
 +
 +
 +        fprintf(stderr, "\n");
 +    }
 +
 +    return 0;
 +}
diff --cc libswscale/tests/colorspace.c
index f6e0c92,962b11a..d1eddc8
--- a/libswscale/tests/colorspace.c
+++ b/libswscale/tests/colorspace.c
@@@ -23,10 -23,11 +23,11 @@@
  #include <stdlib.h>
  #include <inttypes.h>
  
- #include "swscale.h"
- #include "rgb2rgb.h"
  #include "libavutil/mem.h"
  
 -#include "libswscale/rgb2rgb.h"
+ #include "libswscale/swscale.h"
++#include "libswscale/rgb2rgb.h"
+ 
  #define SIZE    1000
  #define srcByte 0x55
  #define dstByte 0xBB
diff --cc tests/fate-run.sh
index 3d58080,d11ca3c..c898695
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@@ -216,24 -165,17 +216,24 @@@ video_filter()
  
  pixfmts(){
      filter=${test#filter-pixfmts-}
 +    filter=${filter%_*}
      filter_args=$1
 +    prefilter_chain=$2
 +    nframes=${3:-1}
  
-     showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
+     showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts"
 -    exclude_fmts=${outfile}${filter}_exclude_fmts
 -    out_fmts=${outfile}${filter}_out_fmts
 +    scale_exclude_fmts=${outfile}_scale_exclude_fmts
 +    scale_in_fmts=${outfile}_scale_in_fmts
 +    scale_out_fmts=${outfile}_scale_out_fmts
 +    in_fmts=${outfile}_in_fmts
  
      # exclude pixel formats which are not supported as input
 -    avconv -pix_fmts list 2>/dev/null | awk 'NR > 8 && /^\..\./ { print $2 }' | sort >$exclude_fmts
 -    $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ print $3 }' | sort | comm -23 - $exclude_fmts >$out_fmts
 +    $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
 +    $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
 +    comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
  
 -    pix_fmts=$($showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ print $3 }' | sort | comm -12 - $out_fmts)
 +    $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
 +    pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
  
      outertest=$test
      for pix_fmt in $pix_fmts; do
diff --cc tests/fate/fft.mak
index 244f426,3360a07..f42dded
--- a/tests/fate/fft.mak
+++ b/tests/fate/fft.mak
@@@ -48,25 -48,8 +48,25 @@@ $(FATE_FFT_FIXED_ALL): CMD = run libavc
  
  $(FATE_FFT_ALL) $(FATE_FFT_FIXED_ALL): REF = /dev/null
  
 +define DEF_FFT_FIXED32
 +FATE_FFT_FIXED32 += fate-fft-fixed32-$(1)   fate-ifft-fixed32-$(1)  \
 +                  fate-mdct-fixed32-$(1) fate-imdct-fixed32-$(1)
 +
 +fate-fft-fixed32-$(1):   ARGS = -n$(1)
 +fate-ifft-fixed32-$(1):  ARGS = -n$(1) -i
 +#fate-mdct-fixed32-$(1):  ARGS = -n$(1) -m
 +fate-imdct-fixed32-$(1): ARGS = -n$(1) -m -i
 +endef
 +
 +$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT_FIXED32,$(N))))
 +
- fate-fft-fixed32-test: $(FATE_FFT_FIXED32)
- $(FATE_FFT_FIXED32): libavcodec/fft-fixed32-test$(EXESUF)
- $(FATE_FFT_FIXED32): CMD = run libavcodec/fft-fixed32-test $(CPUFLAGS:%=-c%) $(ARGS)
++fate-fft-fixed32: $(FATE_FFT_FIXED32)
++$(FATE_FFT_FIXED32): libavcodec/tests/fft-fixed32$(EXESUF)
++$(FATE_FFT_FIXED32): CMD = run libavcodec/tests/fft-fixed32 $(CPUFLAGS:%=-c%) $(ARGS)
 +$(FATE_FFT_FIXED32): REF = /dev/null
 +
  fate-dct: fate-dct-float
- fate-fft: fate-fft-float fate-fft-fixed fate-fft-fixed32-test
 -fate-fft: fate-fft-float fate-fft-fixed
++fate-fft: fate-fft-float fate-fft-fixed fate-fft-fixed32
  fate-mdct: fate-mdct-float fate-mdct-fixed
  fate-rdft: fate-rdft-float
  
diff --cc tests/fate/filter-audio.mak
index 2bdb644,363ae2e..6fe2095
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@@ -167,16 -81,5 +167,16 @@@ fate-filter-volume: CMD = md5 -i $(SRC
  fate-filter-volume: CMP = oneline
  fate-filter-volume: REF = 4d6ba75ef3e32d305d066b9bc771d6f4
  
 -FATE_SAMPLES_AVCONV += $(FATE_AFILTER-yes)
 -fate-afilter: $(FATE_AFILTER-yes)
 +FATE_AFILTER_SAMPLES-$(call FILTERDEMDECENCMUX, HDCD, FLAC, FLAC, PCM_S24LE, PCM_S24LE) += fate-filter-hdcd
 +fate-filter-hdcd: SRC = $(TARGET_SAMPLES)/filter/hdcd.flac
 +fate-filter-hdcd: CMD = md5 -i $(SRC) -af hdcd -f s24le
 +fate-filter-hdcd: CMP = oneline
 +fate-filter-hdcd: REF = 5db465a58d2fd0d06ca944b883b33476
 +
 +FATE_AFILTER-yes += fate-filter-formats
- fate-filter-formats: libavfilter/formats-test$(EXESUF)
- fate-filter-formats: CMD = run libavfilter/formats-test
++fate-filter-formats: libavfilter/tests/formats$(EXESUF)
++fate-filter-formats: CMD = run libavfilter/tests/formats
 +
 +FATE_SAMPLES_AVCONV += $(FATE_AFILTER_SAMPLES-yes)
 +FATE_FFMPEG += $(FATE_AFILTER-yes)
 +fate-afilter: $(FATE_AFILTER-yes) $(FATE_AFILTER_SAMPLES-yes)
diff --cc tests/fate/filter-video.mak
index 4b17d59,d931548..0084802
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@@ -525,70 -139,30 +525,70 @@@ fate-filter-pixdesc: $(FATE_FILTER_PIXD
  FATE_FILTER_VSYNTH-yes += $(FATE_FILTER_PIXDESC-yes)
  
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-copy
 +FATE_FILTER_PIXFMTS-$(CONFIG_COPY_FILTER) += fate-filter-pixfmts-copy
  fate-filter-pixfmts-copy:  CMD = pixfmts
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-crop
 +FATE_FILTER_PIXFMTS-$(CONFIG_CROP_FILTER) += fate-filter-pixfmts-crop
  fate-filter-pixfmts-crop:  CMD = pixfmts "100:100:100:100"
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-hflip
 +FATE_FILTER_PIXFMTS-$(CONFIG_FIELD_FILTER) += fate-filter-pixfmts-field
 +fate-filter-pixfmts-field: CMD = pixfmts "bottom"
 +
 +FATE_FILTER_PIXFMTS-$(call ALLYES, TELECINE_FILTER FIELDMATCH_FILTER) += fate-filter-pixfmts-fieldmatch
 +fate-filter-pixfmts-fieldmatch: CMD = pixfmts "" "telecine," 25
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_FIELDORDER_FILTER) += fate-filter-pixfmts-fieldorder
 +fate-filter-pixfmts-fieldorder: CMD = pixfmts "tff" "setfield=bff,"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_HFLIP_FILTER) += fate-filter-pixfmts-hflip
  fate-filter-pixfmts-hflip: CMD = pixfmts
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-null
 +#FATE_FILTER_PIXFMTS-$(CONFIG_HISTEQ_FILTER) += fate-filter-pixfmts-histeq
 +#fate-filter-pixfmts-histeq: CMD = pixfmts "antibanding=strong"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_IL_FILTER) += fate-filter-pixfmts-il
 +fate-filter-pixfmts-il:    CMD = pixfmts "luma_mode=d:chroma_mode=d:alpha_mode=d"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_KERNDEINT_FILTER) += fate-filter-pixfmts-kerndeint
 +fate-filter-pixfmts-kerndeint: CMD = pixfmts "" "tinterlace=interleave_top,"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_LUT_FILTER) += fate-filter-pixfmts-lut
 +fate-filter-pixfmts-lut: CMD = pixfmts "c0=2*val:c1=2*val:c2=val/2:c3=negval+40"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_NULL_FILTER) += fate-filter-pixfmts-null
  fate-filter-pixfmts-null:  CMD = pixfmts
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-pad
 +FATE_FILTER_PIXFMTS-$(CONFIG_PAD_FILTER) += fate-filter-pixfmts-pad
  fate-filter-pixfmts-pad:   CMD = pixfmts "500:400:20:20"
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-scale
 +FATE_FILTER_PIXFMTS-$(call ALLYES, TELECINE_FILTER PULLUP_FILTER) += fate-filter-pixfmts-pullup
 +fate-filter-pixfmts-pullup: CMD = pixfmts "" "telecine," 25
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_ROTATE_FILTER) += fate-filter-pixfmts-rotate
 +fate-filter-pixfmts-rotate: CMD = pixfmts "2*PI*n/50"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_SCALE_FILTER) += fate-filter-pixfmts-scale
  fate-filter-pixfmts-scale: CMD = pixfmts "200:100"
  
 -FATE_FILTER_PIXFMTS += fate-filter-pixfmts-vflip
 +FATE_FILTER_PIXFMTS-$(CONFIG_SUPER2XSAI_FILTER) += fate-filter-pixfmts-super2xsai
 +fate-filter-pixfmts-super2xsai: CMD = pixfmts
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_SWAPUV_FILTER) += fate-filter-pixfmts-swapuv
 +fate-filter-pixfmts-swapuv: CMD = pixfmts
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_TINTERLACE_FILTER) += fate-filter-pixfmts-tinterlace_merge
 +fate-filter-pixfmts-tinterlace_merge: CMD = pixfmts "merge"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_TINTERLACE_FILTER) += fate-filter-pixfmts-tinterlace_pad
 +fate-filter-pixfmts-tinterlace_pad: CMD = pixfmts "pad"
 +
 +FATE_FILTER_PIXFMTS-$(CONFIG_VFLIP_FILTER) += fate-filter-pixfmts-vflip
  fate-filter-pixfmts-vflip: CMD = pixfmts
  
- $(FATE_FILTER_PIXFMTS-yes): libavfilter/filtfmts-test$(EXESUF)
 -$(FATE_FILTER_PIXFMTS): libavfilter/tests/filtfmts$(EXESUF)
 -FATE_FILTER_VSYNTH-$(CONFIG_FORMAT_FILTER) += $(FATE_FILTER_PIXFMTS)
++$(FATE_FILTER_PIXFMTS-yes): libavfilter/tests/filtfmts$(EXESUF)
 +FATE_FILTER_VSYNTH-$(CONFIG_FORMAT_FILTER) += $(FATE_FILTER_PIXFMTS-yes)
  
 +fate-filter-pixfmts: $(FATE_FILTER_PIXFMTS-yes)
  
  $(FATE_FILTER_VSYNTH-yes): $(VREF)
  $(FATE_FILTER_VSYNTH-yes): SRC = $(TARGET_PATH)/tests/vsynth1/%02d.pgm
diff --cc tests/fate/libavcodec.mak
index 5aba2ee,d656ace..cf25285
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@@ -1,11 -1,6 +1,11 @@@
 +FATE_LIBAVCODEC-$(CONFIG_CABAC) += fate-cabac
- fate-cabac: libavcodec/cabac-test$(EXESUF)
- fate-cabac: CMD = run libavcodec/cabac-test
++fate-cabac: libavcodec/tests/cabac$(EXESUF)
++fate-cabac: CMD = run libavcodec/tests/cabac
 +fate-cabac: REF = /dev/null
 +
  FATE_LIBAVCODEC-$(CONFIG_GOLOMB) += fate-golomb
- fate-golomb: libavcodec/golomb-test$(EXESUF)
- fate-golomb: CMD = run libavcodec/golomb-test
+ fate-golomb: libavcodec/tests/golomb$(EXESUF)
+ fate-golomb: CMD = run libavcodec/tests/golomb
  fate-golomb: REF = /dev/null
  
  FATE_LIBAVCODEC-$(CONFIG_IDCTDSP) += fate-idct8x8
@@@ -15,34 -10,14 +15,34 @@@ fate-idct8x8: CMP = nul
  fate-idct8x8: REF = /dev/null
  
  FATE_LIBAVCODEC-$(CONFIG_IIRFILTER) += fate-iirfilter
- fate-iirfilter: libavcodec/iirfilter-test$(EXESUF)
- fate-iirfilter: CMD = run libavcodec/iirfilter-test
+ fate-iirfilter: libavcodec/tests/iirfilter$(EXESUF)
+ fate-iirfilter: CMD = run libavcodec/tests/iirfilter
  
 +FATE_LIBAVCODEC-yes += fate-libavcodec-options
- fate-libavcodec-options: libavcodec/options-test$(EXESUF)
- fate-libavcodec-options: CMD = run libavcodec/options-test
++fate-libavcodec-options: libavcodec/tests/options$(EXESUF)
++fate-libavcodec-options: CMD = run libavcodec/tests/options
 +
  FATE_LIBAVCODEC-$(CONFIG_RANGECODER) += fate-rangecoder
- fate-rangecoder: libavcodec/rangecoder-test$(EXESUF)
- fate-rangecoder: CMD = run libavcodec/rangecoder-test
+ fate-rangecoder: libavcodec/tests/rangecoder$(EXESUF)
+ fate-rangecoder: CMD = run libavcodec/tests/rangecoder
  fate-rangecoder: CMP = null
  fate-rangecoder: REF = /dev/null
  
 +FATE_LIBAVCODEC-yes += fate-mathops
- fate-mathops: libavcodec/mathops-test$(EXESUF)
- fate-mathops: CMD = run libavcodec/mathops-test
++fate-mathops: libavcodec/tests/mathops$(EXESUF)
++fate-mathops: CMD = run libavcodec/tests/mathops
 +fate-mathops: CMP = null
 +fate-mathops: REF = /dev/null
 +
 +FATE_LIBAVCODEC-$(CONFIG_JPEG2000_ENCODER) += fate-j2k-dwt
- fate-j2k-dwt: libavcodec/jpeg2000dwt-test$(EXESUF)
- fate-j2k-dwt: CMD = run libavcodec/jpeg2000dwt-test
++fate-j2k-dwt: libavcodec/tests/jpeg2000dwt$(EXESUF)
++fate-j2k-dwt: CMD = run libavcodec/tests/jpeg2000dwt
 +
 +FATE_LIBAVCODEC-yes += fate-libavcodec-utils
- fate-libavcodec-utils: libavcodec/utils-test$(EXESUF)
- fate-libavcodec-utils: CMD = run libavcodec/utils-test
++fate-libavcodec-utils: libavcodec/tests/utils$(EXESUF)
++fate-libavcodec-utils: CMD = run libavcodec/tests/utils
 +fate-libavcodec-utils: CMP = null
 +fate-libavcodec-utils: REF = /dev/null
 +
  FATE-$(CONFIG_AVCODEC) += $(FATE_LIBAVCODEC-yes)
  fate-libavcodec: $(FATE_LIBAVCODEC-yes)
diff --cc tests/fate/libavformat.mak
index f88d6fa,30f0e03..cf1ba18
--- a/tests/fate/libavformat.mak
+++ b/tests/fate/libavformat.mak
@@@ -1,27 -1,22 +1,27 @@@
 +#FATE_LIBAVFORMAT-$(HAVE_PTHREADS) += fate-async
- #fate-async: libavformat/async-test$(EXESUF)
- #fate-async: CMD = run libavformat/async-test
++#fate-async: libavformat/tests/async$(EXESUF)
++#fate-async: CMD = run libavformat/tests/async
 +
  FATE_LIBAVFORMAT-$(CONFIG_NETWORK) += fate-noproxy
- fate-noproxy: libavformat/noproxy-test$(EXESUF)
- fate-noproxy: CMD = run libavformat/noproxy-test
+ fate-noproxy: libavformat/tests/noproxy$(EXESUF)
+ fate-noproxy: CMD = run libavformat/tests/noproxy
  
  FATE_LIBAVFORMAT-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += fate-rtmpdh
- fate-rtmpdh: libavformat/rtmpdh-test$(EXESUF)
- fate-rtmpdh: CMD = run libavformat/rtmpdh-test
+ fate-rtmpdh: libavformat/tests/rtmpdh$(EXESUF)
+ fate-rtmpdh: CMD = run libavformat/tests/rtmpdh
  
  FATE_LIBAVFORMAT-$(CONFIG_SRTP) += fate-srtp
- fate-srtp: libavformat/srtp-test$(EXESUF)
- fate-srtp: CMD = run libavformat/srtp-test
+ fate-srtp: libavformat/tests/srtp$(EXESUF)
+ fate-srtp: CMD = run libavformat/tests/srtp
  
  FATE_LIBAVFORMAT-yes += fate-url
- fate-url: libavformat/url-test$(EXESUF)
- fate-url: CMD = run libavformat/url-test
+ fate-url: libavformat/tests/url$(EXESUF)
+ fate-url: CMD = run libavformat/tests/url
  
  FATE_LIBAVFORMAT-$(CONFIG_MOV_MUXER) += fate-movenc
- fate-movenc: libavformat/movenc-test$(EXESUF)
- fate-movenc: CMD = run libavformat/movenc-test
+ fate-movenc: libavformat/tests/movenc$(EXESUF)
+ fate-movenc: CMD = run libavformat/tests/movenc
  
 -FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT-yes)
 +FATE_LIBAVFORMAT += $(FATE_LIBAVFORMAT-yes)
 +FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT)
  fate-libavformat: $(FATE_LIBAVFORMAT)
diff --cc tests/fate/libavutil.mak
index 7f4fb7a,69e4042..6fbad64
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@@ -4,143 -4,79 +4,143 @@@ fate-adler32: CMD = run libavutil/tests
  fate-adler32: REF = /dev/null
  
  FATE_LIBAVUTIL += fate-aes
- fate-aes: libavutil/aes-test$(EXESUF)
- fate-aes: CMD = run libavutil/aes-test
+ fate-aes: libavutil/tests/aes$(EXESUF)
+ fate-aes: CMD = run libavutil/tests/aes
  fate-aes: REF = /dev/null
  
 +FATE_LIBAVUTIL += fate-camellia
- fate-camellia: libavutil/camellia-test$(EXESUF)
- fate-camellia: CMD = run libavutil/camellia-test
++fate-camellia: libavutil/tests/camellia$(EXESUF)
++fate-camellia: CMD = run libavutil/tests/camellia
 +fate-camellia: REF = /dev/null
 +
 +FATE_LIBAVUTIL += fate-cast5
- fate-cast5: libavutil/cast5-test$(EXESUF)
- fate-cast5: CMD = run libavutil/cast5-test
++fate-cast5: libavutil/tests/cast5$(EXESUF)
++fate-cast5: CMD = run libavutil/tests/cast5
 +fate-cast5: REF = /dev/null
 +
  FATE_LIBAVUTIL += fate-atomic
- fate-atomic: libavutil/atomic-test$(EXESUF)
- fate-atomic: CMD = run libavutil/atomic-test
+ fate-atomic: libavutil/tests/atomic$(EXESUF)
+ fate-atomic: CMD = run libavutil/tests/atomic
  fate-atomic: REF = /dev/null
  
  FATE_LIBAVUTIL += fate-avstring
- fate-avstring: libavutil/avstring-test$(EXESUF)
- fate-avstring: CMD = run libavutil/avstring-test
+ fate-avstring: libavutil/tests/avstring$(EXESUF)
+ fate-avstring: CMD = run libavutil/tests/avstring
  
  FATE_LIBAVUTIL += fate-base64
- fate-base64: libavutil/base64-test$(EXESUF)
- fate-base64: CMD = run libavutil/base64-test
+ fate-base64: libavutil/tests/base64$(EXESUF)
+ fate-base64: CMD = run libavutil/tests/base64
  
  FATE_LIBAVUTIL += fate-blowfish
- fate-blowfish: libavutil/blowfish-test$(EXESUF)
- fate-blowfish: CMD = run libavutil/blowfish-test
+ fate-blowfish: libavutil/tests/blowfish$(EXESUF)
+ fate-blowfish: CMD = run libavutil/tests/blowfish
  
 +FATE_LIBAVUTIL += fate-bprint
- fate-bprint: libavutil/bprint-test$(EXESUF)
- fate-bprint: CMD = run libavutil/bprint-test
++fate-bprint: libavutil/tests/bprint$(EXESUF)
++fate-bprint: CMD = run libavutil/tests/bprint
 +
  FATE_LIBAVUTIL += fate-cpu
- fate-cpu: libavutil/cpu-test$(EXESUF)
- fate-cpu: CMD = runecho libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%)
+ fate-cpu: libavutil/tests/cpu$(EXESUF)
 -fate-cpu: CMD = run libavutil/tests/cpu $(CPUFLAGS:%=-c%) $(THREADS:%=-t%)
++fate-cpu: CMD = runecho libavutil/tests/cpu $(CPUFLAGS:%=-c%) $(THREADS:%=-t%)
  fate-cpu: REF = /dev/null
  
  FATE_LIBAVUTIL += fate-crc
- fate-crc: libavutil/crc-test$(EXESUF)
- fate-crc: CMD = run libavutil/crc-test
+ fate-crc: libavutil/tests/crc$(EXESUF)
+ fate-crc: CMD = run libavutil/tests/crc
  
 +FATE_LIBAVUTIL += fate-color_utils
- fate-color_utils: libavutil/color_utils-test$(EXESUF)
- fate-color_utils: CMD = run libavutil/color_utils-test
++fate-color_utils: libavutil/tests/color_utils$(EXESUF)
++fate-color_utils: CMD = run libavutil/tests/color_utils
 +
  FATE_LIBAVUTIL += fate-des
- fate-des: libavutil/des-test$(EXESUF)
- fate-des: CMD = run libavutil/des-test
+ fate-des: libavutil/tests/des$(EXESUF)
+ fate-des: CMD = run libavutil/tests/des
  fate-des: REF = /dev/null
  
 +FATE_LIBAVUTIL += fate-dict
- fate-dict: libavutil/dict-test$(EXESUF)
- fate-dict: CMD = run libavutil/dict-test
++fate-dict: libavutil/tests/dict$(EXESUF)
++fate-dict: CMD = run libavutil/tests/dict
 +
  FATE_LIBAVUTIL += fate-eval
- fate-eval: libavutil/eval-test$(EXESUF)
- fate-eval: CMD = run libavutil/eval-test
+ fate-eval: libavutil/tests/eval$(EXESUF)
+ fate-eval: CMD = run libavutil/tests/eval
  
  FATE_LIBAVUTIL += fate-fifo
- fate-fifo: libavutil/fifo-test$(EXESUF)
- fate-fifo: CMD = run libavutil/fifo-test
+ fate-fifo: libavutil/tests/fifo$(EXESUF)
+ fate-fifo: CMD = run libavutil/tests/fifo
  
  FATE_LIBAVUTIL += fate-float-dsp
- fate-float-dsp: libavutil/float_dsp-test$(EXESUF)
- fate-float-dsp: CMD = run libavutil/float_dsp-test $(CPUFLAGS:%=-c%)
+ fate-float-dsp: libavutil/tests/float_dsp$(EXESUF)
 -fate-float-dsp: CMD = run libavutil/tests/float_dsp
++fate-float-dsp: CMD = run libavutil/tests/float_dsp $(CPUFLAGS:%=-c%)
  fate-float-dsp: CMP = null
  fate-float-dsp: REF = /dev/null
  
 +FATE_LIBAVUTIL += fate-hash
- fate-hash: libavutil/hash-test$(EXESUF)
- fate-hash: CMD = run libavutil/hash-test
++fate-hash: libavutil/tests/hash$(EXESUF)
++fate-hash: CMD = run libavutil/tests/hash
 +
  FATE_LIBAVUTIL += fate-hmac
- fate-hmac: libavutil/hmac-test$(EXESUF)
- fate-hmac: CMD = run libavutil/hmac-test
+ fate-hmac: libavutil/tests/hmac$(EXESUF)
+ fate-hmac: CMD = run libavutil/tests/hmac
  
  FATE_LIBAVUTIL += fate-md5
- fate-md5: libavutil/md5-test$(EXESUF)
- fate-md5: CMD = run libavutil/md5-test
+ fate-md5: libavutil/tests/md5$(EXESUF)
+ fate-md5: CMD = run libavutil/tests/md5
  
 +FATE_LIBAVUTIL += fate-murmur3
- fate-murmur3: libavutil/murmur3-test$(EXESUF)
- fate-murmur3: CMD = run libavutil/murmur3-test
++fate-murmur3: libavutil/tests/murmur3$(EXESUF)
++fate-murmur3: CMD = run libavutil/tests/murmur3
 +
  FATE_LIBAVUTIL += fate-parseutils
- fate-parseutils: libavutil/parseutils-test$(EXESUF)
- fate-parseutils: CMD = run libavutil/parseutils-test
+ fate-parseutils: libavutil/tests/parseutils$(EXESUF)
+ fate-parseutils: CMD = run libavutil/tests/parseutils
  
 +FATE_LIBAVUTIL-$(CONFIG_PIXELUTILS) += fate-pixelutils
- fate-pixelutils: libavutil/pixelutils-test$(EXESUF)
- fate-pixelutils: CMD = run libavutil/pixelutils-test
++fate-pixelutils: libavutil/tests/pixelutils$(EXESUF)
++fate-pixelutils: CMD = run libavutil/tests/pixelutils
 +
 +FATE_LIBAVUTIL += fate-display
- fate-display: libavutil/display-test$(EXESUF)
- fate-display: CMD = run libavutil/display-test
++fate-display: libavutil/tests/display$(EXESUF)
++fate-display: CMD = run libavutil/tests/display
 +
 +FATE_LIBAVUTIL += fate-random_seed
- fate-random_seed: libavutil/random_seed-test$(EXESUF)
- fate-random_seed: CMD = run libavutil/random_seed-test
++fate-random_seed: libavutil/tests/random_seed$(EXESUF)
++fate-random_seed: CMD = run libavutil/tests/random_seed
 +
 +FATE_LIBAVUTIL += fate-ripemd
- fate-ripemd: libavutil/ripemd-test$(EXESUF)
- fate-ripemd: CMD = run libavutil/ripemd-test
++fate-ripemd: libavutil/tests/ripemd$(EXESUF)
++fate-ripemd: CMD = run libavutil/tests/ripemd
 +
  FATE_LIBAVUTIL += fate-sha
- fate-sha: libavutil/sha-test$(EXESUF)
- fate-sha: CMD = run libavutil/sha-test
+ fate-sha: libavutil/tests/sha$(EXESUF)
+ fate-sha: CMD = run libavutil/tests/sha
  
 +FATE_LIBAVUTIL += fate-sha512
- fate-sha512: libavutil/sha512-test$(EXESUF)
- fate-sha512: CMD = run libavutil/sha512-test
++fate-sha512: libavutil/tests/sha512$(EXESUF)
++fate-sha512: CMD = run libavutil/tests/sha512
 +
  FATE_LIBAVUTIL += fate-tree
- fate-tree: libavutil/tree-test$(EXESUF)
- fate-tree: CMD = run libavutil/tree-test
+ fate-tree: libavutil/tests/tree$(EXESUF)
+ fate-tree: CMD = run libavutil/tests/tree
  fate-tree: REF = /dev/null
  
 +FATE_LIBAVUTIL += fate-twofish
- fate-twofish: libavutil/twofish-test$(EXESUF)
- fate-twofish: CMD = run libavutil/twofish-test
++fate-twofish: libavutil/tests/twofish$(EXESUF)
++fate-twofish: CMD = run libavutil/tests/twofish
 +fate-twofish: REF = /dev/null
 +
  FATE_LIBAVUTIL += fate-xtea
- fate-xtea: libavutil/xtea-test$(EXESUF)
- fate-xtea: CMD = run libavutil/xtea-test
+ fate-xtea: libavutil/tests/xtea$(EXESUF)
+ fate-xtea: CMD = run libavutil/tests/xtea
  
 +FATE_LIBAVUTIL += fate-tea
- fate-tea: libavutil/tea-test$(EXESUF)
- fate-tea: CMD = run libavutil/tea-test
++fate-tea: libavutil/tests/tea$(EXESUF)
++fate-tea: CMD = run libavutil/tests/tea
 +
 +FATE_LIBAVUTIL += fate-opt
- fate-opt: libavutil/opt-test$(EXESUF)
- fate-opt: CMD = run libavutil/opt-test
++fate-opt: libavutil/tests/opt$(EXESUF)
++fate-opt: CMD = run libavutil/tests/opt
 +
 +FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
  FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
  fate-libavutil: $(FATE_LIBAVUTIL)
diff --cc tests/fate/seek.mak
index 6e4df91,60adab2..f120f56
--- a/tests/fate/seek.mak
+++ b/tests/fate/seek.mak
@@@ -241,18 -218,9 +241,18 @@@ fate-seek-lavf-yuv4mpeg: SRC = lavf/lav
  
  FATE_SEEK += $(FATE_SEEK_LAVF-yes:%=fate-seek-lavf-%)
  
 -$(FATE_SEEK): libavformat/tests/seek$(EXESUF)
 -$(FATE_SEEK): CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_PATH)/tests/data/$(SRC)
 -$(FATE_SEEK): fate-seek-%: fate-%
 +# extra files
 +
 +FATE_SEEK_EXTRA-$(CONFIG_MP3_DEMUXER)   += fate-seek-extra-mp3
 +FATE_SEEK_EXTRA-$(call ALLYES, CACHE_PROTOCOL PIPE_PROTOCOL MP3_DEMUXER) += fate-seek-cache-pipe
- fate-seek-extra-mp3:  CMD = run libavformat/seek-test$(EXESUF) $(TARGET_SAMPLES)/gapless/gapless.mp3 -fastseek 1
- fate-seek-cache-pipe: CMD = cat $(TARGET_SAMPLES)/gapless/gapless.mp3 | run libavformat/seek-test$(EXESUF) cache:pipe:0 -read_ahead_limit -1
++fate-seek-extra-mp3:  CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_SAMPLES)/gapless/gapless.mp3 -fastseek 1
++fate-seek-cache-pipe: CMD = cat $(TARGET_SAMPLES)/gapless/gapless.mp3 | run libavformat/tests/seek$(EXESUF) cache:pipe:0 -read_ahead_limit -1
 +FATE_SEEK_EXTRA += $(FATE_SEEK_EXTRA-yes)
 +
 +
- $(FATE_SEEK) $(FATE_SAMPLES_SEEK) $(FATE_SEEK_EXTRA): libavformat/seek-test$(EXESUF)
- $(FATE_SEEK) $(FATE_SAMPLES_SEEK): CMD = run libavformat/seek-test$(EXESUF) $(TARGET_PATH)/tests/data/$(SRC)
++$(FATE_SEEK) $(FATE_SAMPLES_SEEK) $(FATE_SEEK_EXTRA): libavformat/tests/seek$(EXESUF)
++$(FATE_SEEK) $(FATE_SAMPLES_SEEK): CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_PATH)/tests/data/$(SRC)
 +$(FATE_SEEK) $(FATE_SAMPLES_SEEK): fate-seek-%: fate-%
  fate-seek-%: REF = $(SRC_PATH)/tests/ref/seek/$(@:fate-seek-%=%)
  
  FATE_AVCONV += $(FATE_SEEK)




More information about the ffmpeg-cvslog mailing list