drawutils.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <stdio.h>
  19. #include "libavutil/pixdesc.h"
  20. #include "libavfilter/drawutils.h"
  21. int main(void)
  22. {
  23. enum AVPixelFormat f;
  24. const AVPixFmtDescriptor *desc;
  25. FFDrawContext draw;
  26. FFDrawColor color;
  27. int r, i;
  28. for (f = 0; av_pix_fmt_desc_get(f); f++) {
  29. desc = av_pix_fmt_desc_get(f);
  30. if (!desc->name)
  31. continue;
  32. printf("Testing %s...%*s", desc->name,
  33. (int)(16 - strlen(desc->name)), "");
  34. r = ff_draw_init(&draw, f, 0);
  35. if (r < 0) {
  36. char buf[128];
  37. av_strerror(r, buf, sizeof(buf));
  38. printf("no: %s\n", buf);
  39. continue;
  40. }
  41. ff_draw_color(&draw, &color, (uint8_t[]) { 1, 0, 0, 1 });
  42. for (i = 0; i < sizeof(color); i++)
  43. if (((uint8_t *)&color)[i] != 128)
  44. break;
  45. if (i == sizeof(color)) {
  46. printf("fallback color\n");
  47. continue;
  48. }
  49. printf("ok\n");
  50. }
  51. return 0;
  52. }