You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.8KB

  1. /*
  2. * Copyright (c) 2017 Clément Bœsch <u pkh me>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdlib.h>
  21. #include "libavutil/mem.h"
  22. #include "libswscale/swscale_internal.h"
  23. static const struct {
  24. const char *class;
  25. int (*cond)(enum AVPixelFormat pix_fmt);
  26. } query_tab[] = {
  27. {"is16BPS", is16BPS},
  28. {"isNBPS", isNBPS},
  29. {"isBE", isBE},
  30. {"isYUV", isYUV},
  31. {"isPlanarYUV", isPlanarYUV},
  32. {"isRGB", isRGB},
  33. {"Gray", isGray},
  34. {"RGBinInt", isRGBinInt},
  35. {"BGRinInt", isBGRinInt},
  36. {"Bayer", isBayer},
  37. {"AnyRGB", isAnyRGB},
  38. {"ALPHA", isALPHA},
  39. {"Packed", isPacked},
  40. {"Planar", isPlanar},
  41. {"PackedRGB", isPackedRGB},
  42. {"PlanarRGB", isPlanarRGB},
  43. {"usePal", usePal},
  44. };
  45. static int cmp_str(const void *a, const void *b)
  46. {
  47. const char *s1 = *(const char **)a;
  48. const char *s2 = *(const char **)b;
  49. return strcmp(s1, s2);
  50. }
  51. int main(void)
  52. {
  53. int i, j;
  54. for (i = 0; i < FF_ARRAY_ELEMS(query_tab); i++) {
  55. const char **pix_fmts = NULL;
  56. int nb_pix_fmts = 0;
  57. const AVPixFmtDescriptor *pix_desc = NULL;
  58. while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
  59. enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
  60. if (query_tab[i].cond(pix_fmt)) {
  61. const char *pix_name = pix_desc->name;
  62. if (pix_fmt == AV_PIX_FMT_RGB32) pix_name = "rgb32";
  63. else if (pix_fmt == AV_PIX_FMT_RGB32_1) pix_name = "rgb32_1";
  64. else if (pix_fmt == AV_PIX_FMT_BGR32) pix_name = "bgr32";
  65. else if (pix_fmt == AV_PIX_FMT_BGR32_1) pix_name = "bgr32_1";
  66. av_dynarray_add(&pix_fmts, &nb_pix_fmts, (void *)pix_name);
  67. }
  68. }
  69. if (pix_fmts) {
  70. qsort(pix_fmts, nb_pix_fmts, sizeof(*pix_fmts), cmp_str);
  71. printf("%s:\n", query_tab[i].class);
  72. for (j = 0; j < nb_pix_fmts; j++)
  73. printf(" %s\n", pix_fmts[j]);
  74. printf("\n");
  75. av_free(pix_fmts);
  76. }
  77. }
  78. return 0;
  79. }