i444tonv12_eg.cc 927 B

12345678910111213141516171819202122232425262728
  1. #include "libyuv/convert.h"
  2. #include <stdio.h> // for printf
  3. #include <string.h> // for memset
  4. int main(int, char**) {
  5. unsigned char src_i444[640 * 400 * 3];
  6. unsigned char dst_nv12[640 * 400 * 3 / 2];
  7. for (size_t i = 0; i < sizeof(src_i444); ++i) {
  8. src_i444[i] = i & 255;
  9. }
  10. memset(dst_nv12, 0, sizeof(dst_nv12));
  11. libyuv::I444ToNV12(&src_i444[0], 640, // source Y
  12. &src_i444[640 * 400], 640, // source U
  13. &src_i444[640 * 400 * 2], 640, // source V
  14. &dst_nv12[0], 640, // dest Y
  15. &dst_nv12[640 * 400], 640, // dest UV
  16. 640, 400); // width and height
  17. int checksum = 0;
  18. for (size_t i = 0; i < sizeof(dst_nv12); ++i) {
  19. checksum += dst_nv12[i];
  20. }
  21. printf("checksum %x %s\n", checksum, checksum == 0x2ec0c00 ? "PASS" : "FAIL");
  22. return 0;
  23. }