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.

75 lines
2.5KB

  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 "libavutil/imgutils.c"
  19. #undef printf
  20. int main(void)
  21. {
  22. const AVPixFmtDescriptor *desc = NULL;
  23. int64_t x, y;
  24. for (y = -1; y<UINT_MAX; y+= y/2 + 1) {
  25. for (x = -1; x<UINT_MAX; x+= x/2 + 1) {
  26. int ret = av_image_check_size(x, y, 0, NULL);
  27. printf("%d", ret >= 0);
  28. }
  29. printf("\n");
  30. }
  31. printf("\n");
  32. while (desc = av_pix_fmt_desc_next(desc)) {
  33. uint8_t *data[4];
  34. size_t sizes[4];
  35. ptrdiff_t linesizes1[4], offsets[3] = { 0 };
  36. int i, total_size, w = 64, h = 48, linesizes[4];
  37. enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
  38. if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
  39. continue;
  40. for (i = 0; i < 4; i++)
  41. linesizes1[i] = linesizes[i];
  42. if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
  43. continue;
  44. total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
  45. if (total_size < 0)
  46. continue;
  47. printf("%-16s", desc->name);
  48. for (i = 0; i < 4 && data[i]; i++);
  49. printf("planes: %d", i);
  50. // Test the output of av_image_fill_linesizes()
  51. printf(", linesizes:");
  52. for (i = 0; i < 4; i++)
  53. printf(" %3d", linesizes[i]);
  54. // Test the output of av_image_fill_plane_sizes()
  55. printf(", plane_sizes:");
  56. for (i = 0; i < 4; i++)
  57. printf(" %5"SIZE_SPECIFIER, sizes[i]);
  58. // Test the output of av_image_fill_pointers()
  59. for (i = 0; i < 3 && data[i + 1]; i++)
  60. offsets[i] = data[i + 1] - data[i];
  61. printf(", plane_offsets:");
  62. for (i = 0; i < 3; i++)
  63. printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
  64. printf(", total_size: %d\n", total_size);
  65. }
  66. return 0;
  67. }