@@ -42,37 +42,43 @@ typedef struct {
4242
4343STATIC camera_dev_t camera_dev = {"/dev/video" , -1 };
4444
45+ typedef struct {
46+ uint16_t width ;
47+ uint16_t height ;
48+ } image_size_t ;
49+
50+ STATIC const image_size_t image_size_table [] = {
51+ { VIDEO_HSIZE_QVGA , VIDEO_VSIZE_QVGA },
52+ { VIDEO_HSIZE_VGA , VIDEO_VSIZE_VGA },
53+ { VIDEO_HSIZE_HD , VIDEO_VSIZE_HD },
54+ { VIDEO_HSIZE_QUADVGA , VIDEO_VSIZE_QUADVGA },
55+ { VIDEO_HSIZE_FULLHD , VIDEO_VSIZE_FULLHD },
56+ { VIDEO_HSIZE_3M , VIDEO_VSIZE_3M },
57+ { VIDEO_HSIZE_5M , VIDEO_VSIZE_5M },
58+ };
59+
4560static bool camera_check_width_and_height (uint16_t width , uint16_t height ) {
46- if ((width == VIDEO_HSIZE_QVGA && height == VIDEO_VSIZE_QVGA ) ||
47- (width == VIDEO_HSIZE_VGA && height == VIDEO_VSIZE_VGA ) ||
48- (width == VIDEO_HSIZE_HD && height == VIDEO_VSIZE_HD ) ||
49- (width == VIDEO_HSIZE_QUADVGA && height == VIDEO_VSIZE_QUADVGA ) ||
50- (width == VIDEO_HSIZE_FULLHD && height == VIDEO_VSIZE_FULLHD ) ||
51- (width == VIDEO_HSIZE_3M && height == VIDEO_VSIZE_3M ) ||
52- (width == VIDEO_HSIZE_5M && height == VIDEO_VSIZE_5M )) {
53- return true;
54- } else {
55- return false;
61+ for (int i = 0 ; i < MP_ARRAY_SIZE (image_size_table ); i ++ ) {
62+ if (image_size_table [i ].width == width && image_size_table [i ].height == height ) {
63+ return true;
64+ }
5665 }
66+ return false;
5767}
5868
5969static bool camera_check_buffer_length (uint16_t width , uint16_t height , camera_imageformat_t format , size_t length ) {
6070 if (format == IMAGEFORMAT_JPG ) {
6171 // In SPRESENSE SDK, JPEG compression quality=80 by default.
6272 // In such setting, the maximum actual measured size of JPEG image
6373 // is about width * height * 2 / 9.
64- return length >= (size_t )(width * height * 2 / 9 ) ? true : false ;
74+ return length >= (size_t )(width * height * 2 / 9 );
6575 } else {
6676 return false;
6777 }
6878}
6979
7080static bool camera_check_format (camera_imageformat_t format ) {
71- if (format == IMAGEFORMAT_JPG ) {
72- return true;
73- } else {
74- return false;
75- }
81+ return format == IMAGEFORMAT_JPG ;
7682}
7783
7884static void camera_set_format (enum v4l2_buf_type type , uint32_t pixformat , uint16_t width , uint16_t height ) {
0 commit comments