@@ -42,37 +42,43 @@ typedef struct {
42
42
43
43
STATIC camera_dev_t camera_dev = {"/dev/video" , -1 };
44
44
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
+
45
60
static 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
+ }
56
65
}
66
+ return false;
57
67
}
58
68
59
69
static bool camera_check_buffer_length (uint16_t width , uint16_t height , camera_imageformat_t format , size_t length ) {
60
70
if (format == IMAGEFORMAT_JPG ) {
61
71
// In SPRESENSE SDK, JPEG compression quality=80 by default.
62
72
// In such setting, the maximum actual measured size of JPEG image
63
73
// 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 );
65
75
} else {
66
76
return false;
67
77
}
68
78
}
69
79
70
80
static 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 ;
76
82
}
77
83
78
84
static void camera_set_format (enum v4l2_buf_type type , uint32_t pixformat , uint16_t width , uint16_t height ) {
0 commit comments