From 08e1376d81f380a22fc7d4c1f783e83364d4ceb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 19 Mar 2017 14:48:32 +0100 Subject: [PATCH] fate: add fate-sws-pixdesc-query Test the pixel format querying within libswscale. --- libswscale/Makefile | 1 + libswscale/tests/.gitignore | 1 + libswscale/tests/pixdesc_query.c | 90 ++++ tests/Makefile | 1 + tests/fate/libswscale.mak | 7 + tests/ref/fate/sws-pixdesc-query | 806 +++++++++++++++++++++++++++++++ 6 files changed, 906 insertions(+) create mode 100644 libswscale/tests/pixdesc_query.c create mode 100644 tests/fate/libswscale.mak create mode 100644 tests/ref/fate/sws-pixdesc-query 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..bc49809d4b --- /dev/null +++ b/libswscale/tests/pixdesc_query.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 Clément Bœsch + * + * 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(is16BPS) +DECLARE_WRAPPER(isNBPS) +DECLARE_WRAPPER(isBE) +DECLARE_WRAPPER(isYUV) +DECLARE_WRAPPER(isPlanarYUV) +DECLARE_WRAPPER(isRGB) +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[] = { + {"is16BPS", is16BPS_func}, + {"isNBPS", isNBPS_func}, + {"isBE", isBE_func}, + {"isYUV", isYUV_func}, + {"isPlanarYUV", isPlanarYUV_func}, + {"isRGB", isRGB_func}, + {"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..1f0584474b --- /dev/null +++ b/tests/ref/fate/sws-pixdesc-query @@ -0,0 +1,806 @@ +is16BPS: + gray16be + gray16le + rgb48be + rgb48le + yuv420p16le + yuv420p16be + yuv422p16le + yuv422p16be + yuv444p16le + yuv444p16be + bgr48be + bgr48le + gbrp16be + gbrp16le + yuva420p16be + yuva420p16le + yuva422p16be + yuva422p16le + yuva444p16be + yuva444p16le + rgba64be + rgba64le + bgra64be + bgra64le + ya16be + ya16le + gbrap16be + gbrap16le + ayuv64le + ayuv64be + p016le + p016be + +isNBPS: + yuv420p9be + yuv420p9le + yuv420p10be + yuv420p10le + yuv422p10be + yuv422p10le + yuv444p9be + yuv444p9le + yuv444p10be + yuv444p10le + yuv422p9be + yuv422p9le + gbrp9be + gbrp9le + gbrp10be + gbrp10le + yuva420p9be + yuva420p9le + yuva422p9be + yuva422p9le + yuva444p9be + yuva444p9le + yuva420p10be + yuva420p10le + yuva422p10be + yuva422p10le + yuva444p10be + yuva444p10le + xyz12le + xyz12be + nv20le + nv20be + yuv420p12be + yuv420p12le + yuv420p14be + yuv420p14le + yuv422p12be + yuv422p12le + yuv422p14be + yuv422p14le + yuv444p12be + yuv444p12le + yuv444p14be + yuv444p14le + gbrp12be + gbrp12le + gbrp14be + gbrp14le + yuv440p10le + yuv440p10be + yuv440p12le + yuv440p12be + p010le + p010be + gbrap12be + gbrap12le + gbrap10be + gbrap10le + gray12be + gray12le + gray10be + gray10le + +isBE: + gray16be + rgb48be + rgb565be + rgb555be + bgr565be + bgr555be + yuv420p16be + yuv422p16be + yuv444p16be + rgb444be + bgr444be + bgr48be + yuv420p9be + yuv420p10be + yuv422p10be + yuv444p9be + yuv444p10be + yuv422p9be + gbrp9be + gbrp10be + gbrp16be + yuva420p9be + yuva422p9be + yuva444p9be + yuva420p10be + yuva422p10be + yuva444p10be + yuva420p16be + yuva422p16be + yuva444p16be + xyz12be + nv20be + rgba64be + bgra64be + ya16be + gbrap16be + yuv420p12be + yuv420p14be + yuv422p12be + yuv422p14be + yuv444p12be + yuv444p14be + gbrp12be + gbrp14be + bayer_bggr16be + bayer_rggb16be + bayer_gbrg16be + bayer_grbg16be + yuv440p10be + yuv440p12be + ayuv64be + p010be + gbrap12be + gbrap10be + gray12be + gray10be + p016be + +isYUV: + yuv420p + yuyv422 + yuv422p + yuv444p + yuv410p + yuv411p + yuvj420p + yuvj422p + yuvj444p + uyvy422 + uyyvyy411 + nv12 + nv21 + yuv440p + yuvj440p + yuva420p + yuv420p16le + yuv420p16be + yuv422p16le + yuv422p16be + yuv444p16le + yuv444p16be + ya8 + yuv420p9be + yuv420p9le + yuv420p10be + yuv420p10le + yuv422p10be + yuv422p10le + yuv444p9be + yuv444p9le + yuv444p10be + yuv444p10le + yuv422p9be + yuv422p9le + yuva422p + yuva444p + yuva420p9be + yuva420p9le + yuva422p9be + yuva422p9le + yuva444p9be + yuva444p9le + yuva420p10be + yuva420p10le + yuva422p10be + yuva422p10le + yuva444p10be + yuva444p10le + yuva420p16be + yuva420p16le + yuva422p16be + yuva422p16le + yuva444p16be + yuva444p16le + xyz12le + xyz12be + nv16 + nv20le + nv20be + yvyu422 + ya16be + ya16le + yuv420p12be + yuv420p12le + yuv420p14be + yuv420p14le + yuv422p12be + yuv422p12le + yuv422p14be + yuv422p14le + yuv444p12be + yuv444p12le + yuv444p14be + yuv444p14le + yuvj411p + yuv440p10le + yuv440p10be + yuv440p12le + yuv440p12be + ayuv64le + ayuv64be + p010le + p010be + p016le + p016be + +isPlanarYUV: + 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 + yuva422p + yuva444p + yuva420p9be + yuva420p9le + yuva422p9be + yuva422p9le + yuva444p9be + yuva444p9le + yuva420p10be + yuva420p10le + yuva422p10be + yuva422p10le + yuva444p10be + yuva444p10le + yuva420p16be + yuva420p16le + yuva422p16be + yuva422p16le + yuva444p16be + yuva444p16le + nv16 + nv20le + nv20be + yuv420p12be + yuv420p12le + yuv420p14be + yuv420p14le + yuv422p12be + yuv422p12le + yuv422p14be + yuv422p14le + yuv444p12be + yuv444p12le + yuv444p14be + yuv444p14le + yuvj411p + yuv440p10le + yuv440p10be + yuv440p12le + yuv440p12be + p010le + p010be + p016le + p016be + +isRGB: + 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 + 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 + +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 +