1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <stdbool.h>
#include "greatest.h"
#include "libmegapixels.h"
static enum greatest_test_res
check_bytesused(
uint32_t pixfmt,
uint32_t width,
uint32_t height,
uint32_t expected_width_to_bytes,
uint32_t expected_width_to_padding,
uint32_t expected_bytes_used
)
{
int format = libmegapixels_v4l_pixfmt_to_index(pixfmt);
uint32_t width_to_bytes = libmegapixels_mode_width_to_bytes(format, width);
uint32_t width_to_padding = libmegapixels_mode_width_to_padding(format, width);
uint32_t bytes_used = (width_to_bytes + width_to_padding) * height;
// printf(
// "\nFormat name: %s, width: %u, height: %u, width to bytes: %u, width to padding: %u, bytes used: %u\n",
// libmegapixels_format_name(format),
// width,
// height,
// width_to_bytes,
// width_to_padding,
// bytes_used
// );
ASSERT_EQ(width_to_bytes, expected_width_to_bytes);
ASSERT_EQ(width_to_padding, expected_width_to_padding);
ASSERT_EQ(bytes_used, expected_bytes_used);
PASS();
}
TEST bytesused_for_rggb8(void)
{
CHECK_CALL(check_bytesused(V4L2_PIX_FMT_SRGGB8, 4208, 3120, 4208, 0, 13128960));
PASS();
}
TEST bytesused_for_rggb10(void)
{
CHECK_CALL(check_bytesused(V4L2_PIX_FMT_SRGGB10, 4208, 3120, 8416, 0, 26257920));
PASS();
}
TEST bytesused_for_rggb10p(void)
{
CHECK_CALL(check_bytesused(V4L2_PIX_FMT_SRGGB10P, 4208, 3120, 5260, 4, 16423680));
PASS();
}
SUITE (test_suite)
{
RUN_TEST(bytesused_for_rggb8);
RUN_TEST(bytesused_for_rggb10);
RUN_TEST(bytesused_for_rggb10p);
}
GREATEST_MAIN_DEFS();
int
main(int argc, char **argv)
{
GREATEST_MAIN_BEGIN();
RUN_SUITE(test_suite);
GREATEST_MAIN_END();
}
|