2017-03-19 13:48:32 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2017-03-23 22:32:35 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-03-23 22:21:07 +00:00
|
|
|
#include "libavutil/mem.h"
|
2017-03-19 13:48:32 +00:00
|
|
|
#include "libswscale/swscale_internal.h"
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
const char *class;
|
|
|
|
int (*cond)(enum AVPixelFormat pix_fmt);
|
|
|
|
} query_tab[] = {
|
2017-03-23 21:46:28 +00:00
|
|
|
{"is16BPS", is16BPS},
|
|
|
|
{"isNBPS", isNBPS},
|
|
|
|
{"isBE", isBE},
|
|
|
|
{"isYUV", isYUV},
|
|
|
|
{"isPlanarYUV", isPlanarYUV},
|
2019-05-11 17:12:47 +00:00
|
|
|
{"isSemiPlanarYUV", isSemiPlanarYUV},
|
2017-03-23 21:46:28 +00:00
|
|
|
{"isRGB", isRGB},
|
|
|
|
{"Gray", isGray},
|
|
|
|
{"RGBinInt", isRGBinInt},
|
|
|
|
{"BGRinInt", isBGRinInt},
|
|
|
|
{"Bayer", isBayer},
|
|
|
|
{"AnyRGB", isAnyRGB},
|
|
|
|
{"ALPHA", isALPHA},
|
|
|
|
{"Packed", isPacked},
|
|
|
|
{"Planar", isPlanar},
|
|
|
|
{"PackedRGB", isPackedRGB},
|
|
|
|
{"PlanarRGB", isPlanarRGB},
|
|
|
|
{"usePal", usePal},
|
2017-03-19 13:48:32 +00:00
|
|
|
};
|
|
|
|
|
2017-03-23 22:32:35 +00:00
|
|
|
static int cmp_str(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
const char *s1 = *(const char **)a;
|
|
|
|
const char *s2 = *(const char **)b;
|
|
|
|
return strcmp(s1, s2);
|
|
|
|
}
|
|
|
|
|
2017-03-19 13:48:32 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
2017-03-23 22:21:07 +00:00
|
|
|
int i, j;
|
2017-03-19 13:48:32 +00:00
|
|
|
|
|
|
|
for (i = 0; i < FF_ARRAY_ELEMS(query_tab); i++) {
|
2017-03-23 22:21:07 +00:00
|
|
|
const char **pix_fmts = NULL;
|
|
|
|
int nb_pix_fmts = 0;
|
2017-03-19 13:48:32 +00:00
|
|
|
const AVPixFmtDescriptor *pix_desc = NULL;
|
2017-03-23 22:21:07 +00:00
|
|
|
|
2017-03-19 13:48:32 +00:00
|
|
|
while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
|
|
|
|
enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
|
2017-03-23 23:51:32 +00:00
|
|
|
if (query_tab[i].cond(pix_fmt)) {
|
|
|
|
const char *pix_name = pix_desc->name;
|
|
|
|
if (pix_fmt == AV_PIX_FMT_RGB32) pix_name = "rgb32";
|
|
|
|
else if (pix_fmt == AV_PIX_FMT_RGB32_1) pix_name = "rgb32_1";
|
|
|
|
else if (pix_fmt == AV_PIX_FMT_BGR32) pix_name = "bgr32";
|
|
|
|
else if (pix_fmt == AV_PIX_FMT_BGR32_1) pix_name = "bgr32_1";
|
|
|
|
|
|
|
|
av_dynarray_add(&pix_fmts, &nb_pix_fmts, (void *)pix_name);
|
|
|
|
}
|
2017-03-23 22:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pix_fmts) {
|
2017-03-23 22:32:35 +00:00
|
|
|
qsort(pix_fmts, nb_pix_fmts, sizeof(*pix_fmts), cmp_str);
|
|
|
|
|
2017-03-23 22:21:07 +00:00
|
|
|
printf("%s:\n", query_tab[i].class);
|
|
|
|
for (j = 0; j < nb_pix_fmts; j++)
|
|
|
|
printf(" %s\n", pix_fmts[j]);
|
|
|
|
printf("\n");
|
|
|
|
|
2017-07-30 18:48:04 +00:00
|
|
|
av_free(pix_fmts);
|
2017-03-19 13:48:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|