27{
28 list<pair<size_t,size_t>> sizes = { {1, 2}, {2, 1}, { 16, 1}, {16, 16}, {127, 255} };
29 for (auto &i : sizes) {
30 size_t size_x = i.first;
31 size_t size_y = i.second;
33 unsigned char uyvy_pattern[4] = { 'u', 'y', 'v', 'Y' };
34 size_t uyvy_buf_size = ((size_x + 1) & ~1) * 2 * size_y;
35
36 unsigned char uyvy_buf[uyvy_buf_size];
37 for (size_t i = 0; i < size_y * 2 * ((size_x + 1) & ~1); ++i) {
38 uyvy_buf[i] = uyvy_pattern[i % 4];
39 }
40
43 unsigned char *y_ptr = i420_buf;
44 for (size_t i = 0; i < size_y; ++i) {
45 for (size_t j = 0; j < size_x; ++j) {
46 ostringstream oss;
47 unsigned char expected = uyvy_pattern[((2 * j + 1) % 4)];
48 unsigned char actual = *y_ptr++;
49 oss << size_x << "X" << size_y << ": [" << i << ", " << j << "]";
51 }
52 }
53
54 unsigned char *u_ptr = i420_buf + size_x * size_y;
55 for (size_t i = 0; i < (size_y + 1) / 2; ++i) {
56 for (size_t j = 0; j < (size_x + 1) / 2; ++j) {
57 ostringstream oss;
58 unsigned char expected = 'u';
59 unsigned char actual = *u_ptr++;
60 oss << "[" << i << ", " << j << "]";
62 }
63 }
64
65 unsigned char *v_ptr = i420_buf + size_x * size_y + ((size_x + 1) / 2) * ((size_y + 1) / 2);
66 for (size_t i = 0; i < (size_y + 1) / 2; ++i) {
67 for (size_t j = 0; j < (size_x + 1) / 2; ++j) {
68 ostringstream oss;
69 unsigned char expected = 'v';
70 unsigned char actual = *v_ptr++;
71 oss << "[" << i << ", " << j << "]";
73 }
74 }
75 free(i420_buf);
76 }
77 return 0;
78}
void testcard_convert_buffer(codec_t in_c, codec_t out_c, unsigned char *out, unsigned const char *in, int width, int height)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual)
size_t vc_get_datalen(unsigned int width, unsigned int height, codec_t codec)