diff --git a/libswscale/Makefile b/libswscale/Makefile
index 0272039a6c..183167cced 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -26,4 +26,5 @@ OBJS-$(CONFIG_SHARED)        += log2_tab.o
 SLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
 
 TESTPROGS = colorspace                                                  \
+            pixdesc_query                                               \
             swscale                                                     \
diff --git a/libswscale/tests/.gitignore b/libswscale/tests/.gitignore
index 0ac3691ecd..1a26f038c4 100644
--- a/libswscale/tests/.gitignore
+++ b/libswscale/tests/.gitignore
@@ -1,2 +1,3 @@
 /colorspace
+/pixdesc_query
 /swscale
diff --git a/libswscale/tests/pixdesc_query.c b/libswscale/tests/pixdesc_query.c
new file mode 100644
index 0000000000..d1ce1eb4a8
--- /dev/null
+++ b/libswscale/tests/pixdesc_query.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017 Clément Bœsch <u pkh me>
+ *
+ * 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 "libswscale/swscale_internal.h"
+
+/* TODO: drop this wrapper when all the is*() becomes functions */
+#define DECLARE_WRAPPER(macro)                       \
+static int macro##_func(enum AVPixelFormat pix_fmt)  \
+{                                                    \
+    return macro(pix_fmt);                           \
+}
+
+DECLARE_WRAPPER(isGray)
+DECLARE_WRAPPER(isRGBinInt)
+DECLARE_WRAPPER(isBGRinInt)
+DECLARE_WRAPPER(isRGBinBytes)
+DECLARE_WRAPPER(isBGRinBytes)
+DECLARE_WRAPPER(isBayer)
+DECLARE_WRAPPER(isAnyRGB)
+DECLARE_WRAPPER(isALPHA)
+DECLARE_WRAPPER(isPacked)
+DECLARE_WRAPPER(isPlanar)
+DECLARE_WRAPPER(isPackedRGB)
+DECLARE_WRAPPER(isPlanarRGB)
+DECLARE_WRAPPER(usePal)
+
+static const struct {
+    const char *class;
+    int (*cond)(enum AVPixelFormat pix_fmt);
+} query_tab[] = {
+    {"Gray",        isGray_func},
+    {"RGBinInt",    isRGBinInt_func},
+    {"BGRinInt",    isBGRinInt_func},
+    {"RGBinBytes",  isRGBinBytes_func},
+    {"BGRinBytes",  isBGRinBytes_func},
+    {"Bayer",       isBayer_func},
+    {"AnyRGB",      isAnyRGB_func},
+    {"ALPHA",       isALPHA_func},
+    {"Packed",      isPacked_func},
+    {"Planar",      isPlanar_func},
+    {"PackedRGB",   isPackedRGB_func},
+    {"PlanarRGB",   isPlanarRGB_func},
+    {"usePal",      usePal_func},
+};
+
+int main(void)
+{
+    int i;
+
+    for (i = 0; i < FF_ARRAY_ELEMS(query_tab); i++) {
+        const AVPixFmtDescriptor *pix_desc = NULL;
+        printf("%s:\n", query_tab[i].class);
+        while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
+            enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
+            if (query_tab[i].cond(pix_fmt))
+                printf("  %s\n", pix_desc->name);
+        }
+        printf("\n");
+    }
+    return 0;
+}
diff --git a/tests/Makefile b/tests/Makefile
index 53d900bdba..66d99106ff 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -145,6 +145,7 @@ include $(SRC_PATH)/tests/fate/libavformat.mak
 include $(SRC_PATH)/tests/fate/libavresample.mak
 include $(SRC_PATH)/tests/fate/libavutil.mak
 include $(SRC_PATH)/tests/fate/libswresample.mak
+include $(SRC_PATH)/tests/fate/libswscale.mak
 include $(SRC_PATH)/tests/fate/lossless-audio.mak
 include $(SRC_PATH)/tests/fate/lossless-video.mak
 include $(SRC_PATH)/tests/fate/matroska.mak
diff --git a/tests/fate/libswscale.mak b/tests/fate/libswscale.mak
new file mode 100644
index 0000000000..e72fe590a8
--- /dev/null
+++ b/tests/fate/libswscale.mak
@@ -0,0 +1,7 @@
+FATE_LIBSWSCALE += fate-sws-pixdesc-query
+fate-sws-pixdesc-query: libswscale/tests/pixdesc_query$(EXESUF)
+fate-sws-pixdesc-query: CMD = run libswscale/tests/pixdesc_query
+
+FATE_LIBSWSCALE += $(FATE_LIBSWSCALE-yes)
+FATE-$(CONFIG_SWSCALE) += $(FATE_LIBSWSCALE)
+fate-libswscale: $(FATE_LIBSWSCALE)
diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
new file mode 100644
index 0000000000..013c59da50
--- /dev/null
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -0,0 +1,416 @@
+Gray:
+  gray
+  gray16be
+  gray16le
+  ya8
+  ya16be
+  ya16le
+  gray12be
+  gray12le
+  gray10be
+  gray10le
+
+RGBinInt:
+  rgb24
+  monow
+  monob
+  rgb8
+  rgb4
+  rgb4_byte
+  abgr
+  bgra
+  rgb48be
+  rgb48le
+  rgb565be
+  rgb565le
+  rgb555be
+  rgb555le
+  rgb444le
+  rgb444be
+  rgba64be
+  rgba64le
+
+BGRinInt:
+  bgr24
+  monow
+  monob
+  bgr8
+  bgr4
+  bgr4_byte
+  argb
+  rgba
+  bgr565be
+  bgr565le
+  bgr555be
+  bgr555le
+  bgr444le
+  bgr444be
+  bgr48be
+  bgr48le
+  bgra64be
+  bgra64le
+
+RGBinBytes:
+  rgb24
+  argb
+  rgba
+  rgb48be
+  rgb48le
+  rgba64be
+  rgba64le
+
+BGRinBytes:
+  bgr24
+  abgr
+  bgra
+  bgr48be
+  bgr48le
+  bgra64be
+  bgra64le
+
+Bayer:
+  bayer_bggr8
+  bayer_rggb8
+  bayer_gbrg8
+  bayer_grbg8
+  bayer_bggr16le
+  bayer_bggr16be
+  bayer_rggb16le
+  bayer_rggb16be
+  bayer_gbrg16le
+  bayer_gbrg16be
+  bayer_grbg16le
+  bayer_grbg16be
+
+AnyRGB:
+  rgb24
+  bgr24
+  monow
+  monob
+  bgr8
+  bgr4
+  bgr4_byte
+  rgb8
+  rgb4
+  rgb4_byte
+  argb
+  rgba
+  abgr
+  bgra
+  rgb48be
+  rgb48le
+  rgb565be
+  rgb565le
+  rgb555be
+  rgb555le
+  bgr565be
+  bgr565le
+  bgr555be
+  bgr555le
+  rgb444le
+  rgb444be
+  bgr444le
+  bgr444be
+  bgr48be
+  bgr48le
+  gbrp
+  gbrp9be
+  gbrp9le
+  gbrp10be
+  gbrp10le
+  gbrp16be
+  gbrp16le
+  rgba64be
+  rgba64le
+  bgra64be
+  bgra64le
+  gbrap
+  gbrap16be
+  gbrap16le
+  0rgb
+  rgb0
+  0bgr
+  bgr0
+  gbrp12be
+  gbrp12le
+  gbrp14be
+  gbrp14le
+  bayer_bggr8
+  bayer_rggb8
+  bayer_gbrg8
+  bayer_grbg8
+  bayer_bggr16le
+  bayer_bggr16be
+  bayer_rggb16le
+  bayer_rggb16be
+  bayer_gbrg16le
+  bayer_gbrg16be
+  bayer_grbg16le
+  bayer_grbg16be
+  gbrap12be
+  gbrap12le
+  gbrap10be
+  gbrap10le
+
+ALPHA:
+  pal8
+  argb
+  rgba
+  abgr
+  bgra
+  yuva420p
+  ya8
+  yuva422p
+  yuva444p
+  yuva420p9be
+  yuva420p9le
+  yuva422p9be
+  yuva422p9le
+  yuva444p9be
+  yuva444p9le
+  yuva420p10be
+  yuva420p10le
+  yuva422p10be
+  yuva422p10le
+  yuva444p10be
+  yuva444p10le
+  yuva420p16be
+  yuva420p16le
+  yuva422p16be
+  yuva422p16le
+  yuva444p16be
+  yuva444p16le
+  rgba64be
+  rgba64le
+  bgra64be
+  bgra64le
+  ya16be
+  ya16le
+  gbrap
+  gbrap16be
+  gbrap16le
+  ayuv64le
+  ayuv64be
+  gbrap12be
+  gbrap12le
+  gbrap10be
+  gbrap10le
+
+Packed:
+  yuyv422
+  rgb24
+  bgr24
+  monow
+  monob
+  pal8
+  uyvy422
+  bgr8
+  bgr4
+  bgr4_byte
+  rgb8
+  rgb4
+  rgb4_byte
+  argb
+  rgba
+  abgr
+  bgra
+  rgb48be
+  rgb48le
+  rgb565be
+  rgb565le
+  rgb555be
+  rgb555le
+  bgr565be
+  bgr565le
+  bgr555be
+  bgr555le
+  rgb444le
+  rgb444be
+  bgr444le
+  bgr444be
+  ya8
+  bgr48be
+  bgr48le
+  rgba64be
+  rgba64le
+  bgra64be
+  bgra64le
+  yvyu422
+  ya16be
+  ya16le
+  ayuv64le
+  ayuv64be
+
+Planar:
+  yuv420p
+  yuv422p
+  yuv444p
+  yuv410p
+  yuv411p
+  yuvj420p
+  yuvj422p
+  yuvj444p
+  nv12
+  nv21
+  yuv440p
+  yuvj440p
+  yuva420p
+  yuv420p16le
+  yuv420p16be
+  yuv422p16le
+  yuv422p16be
+  yuv444p16le
+  yuv444p16be
+  yuv420p9be
+  yuv420p9le
+  yuv420p10be
+  yuv420p10le
+  yuv422p10be
+  yuv422p10le
+  yuv444p9be
+  yuv444p9le
+  yuv444p10be
+  yuv444p10le
+  yuv422p9be
+  yuv422p9le
+  gbrp
+  gbrp9be
+  gbrp9le
+  gbrp10be
+  gbrp10le
+  gbrp16be
+  gbrp16le
+  yuva422p
+  yuva444p
+  yuva420p9be
+  yuva420p9le
+  yuva422p9be
+  yuva422p9le
+  yuva444p9be
+  yuva444p9le
+  yuva420p10be
+  yuva420p10le
+  yuva422p10be
+  yuva422p10le
+  yuva444p10be
+  yuva444p10le
+  yuva420p16be
+  yuva420p16le
+  yuva422p16be
+  yuva422p16le
+  yuva444p16be
+  yuva444p16le
+  nv16
+  nv20le
+  nv20be
+  gbrap
+  gbrap16be
+  gbrap16le
+  yuv420p12be
+  yuv420p12le
+  yuv420p14be
+  yuv420p14le
+  yuv422p12be
+  yuv422p12le
+  yuv422p14be
+  yuv422p14le
+  yuv444p12be
+  yuv444p12le
+  yuv444p14be
+  yuv444p14le
+  gbrp12be
+  gbrp12le
+  gbrp14be
+  gbrp14le
+  yuvj411p
+  yuv440p10le
+  yuv440p10be
+  yuv440p12le
+  yuv440p12be
+  p010le
+  p010be
+  gbrap12be
+  gbrap12le
+  gbrap10be
+  gbrap10le
+  p016le
+  p016be
+
+PackedRGB:
+  rgb24
+  bgr24
+  bgr8
+  bgr4
+  bgr4_byte
+  rgb8
+  rgb4
+  rgb4_byte
+  argb
+  rgba
+  abgr
+  bgra
+  rgb48be
+  rgb48le
+  rgb565be
+  rgb565le
+  rgb555be
+  rgb555le
+  bgr565be
+  bgr565le
+  bgr555be
+  bgr555le
+  rgb444le
+  rgb444be
+  bgr444le
+  bgr444be
+  bgr48be
+  bgr48le
+  rgba64be
+  rgba64le
+  bgra64be
+  bgra64le
+  0rgb
+  rgb0
+  0bgr
+  bgr0
+  bayer_bggr8
+  bayer_rggb8
+  bayer_gbrg8
+  bayer_grbg8
+  bayer_bggr16le
+  bayer_bggr16be
+  bayer_rggb16le
+  bayer_rggb16be
+  bayer_gbrg16le
+  bayer_gbrg16be
+  bayer_grbg16le
+  bayer_grbg16be
+
+PlanarRGB:
+  gbrp
+  gbrp9be
+  gbrp9le
+  gbrp10be
+  gbrp10le
+  gbrp16be
+  gbrp16le
+  gbrap
+  gbrap16be
+  gbrap16le
+  gbrp12be
+  gbrp12le
+  gbrp14be
+  gbrp14le
+  gbrap12be
+  gbrap12le
+  gbrap10be
+  gbrap10le
+
+usePal:
+  gray
+  pal8
+  bgr8
+  bgr4_byte
+  rgb8
+  rgb4_byte
+
