package: v4l2test: Fix zero size file for rawdata format

This commit is contained in:
mason.huo
2022-08-03 16:07:57 +08:00
parent 9234eab162
commit 5c3b022a79
3 changed files with 23 additions and 2 deletions
+19
View File
@@ -33,6 +33,25 @@ void dump_fourcc(uint32_t fourcc)
fourcc >> 24);
}
int is_raw_v4l2fmt(uint32_t format)
{
int ret;
switch (format) {
case V4L2_PIX_FMT_SRGGB12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SBGGR12:
ret = 1;
break;
default:
ret = 0;
break;
}
return ret;
}
// convert v4l2 format to fb format
int v4l2fmt_to_fbfmt(uint32_t format)
{
+1 -1
View File
@@ -80,7 +80,7 @@ extern void jpegWrite(unsigned char* img, char* jpegFilename,
uint32_t width, uint32_t height, int jpegQuality);
extern int write_JPEG_file(char * filename,unsigned char *image_buffer,
int image_width, int image_height, int quality);
extern int is_raw_v4l2fmt(uint32_t format);
// inline int clip(int value, int min, int max) {
// return (value > max ? max : value < min ? min : value);
// }
+3 -1
View File
@@ -614,7 +614,9 @@ static void mainloop()
exit(EXIT_FAILURE);
}
if (!gp_cfg_param->rec_fp && gp_cfg_param->jpegFilename) {
if (!gp_cfg_param->rec_fp &&
gp_cfg_param->jpegFilename &&
!is_raw_v4l2fmt(gp_cfg_param->v4l2_param.format)) {
gp_cfg_param->rec_fp = fopen(gp_cfg_param->jpegFilename, "w+");
if (!gp_cfg_param->rec_fp) {
LOG(STF_LEVEL_ERR, "can't open %s\n", gp_cfg_param->jpegFilename);