From 5c3b022a7935f9c30f0bec8c0e1438e8de93b0c3 Mon Sep 17 00:00:00 2001 From: "mason.huo" Date: Wed, 3 Aug 2022 16:07:57 +0800 Subject: [PATCH] package: v4l2test: Fix zero size file for rawdata format --- package/starfive/v4l2_test/common.c | 19 +++++++++++++++++++ package/starfive/v4l2_test/common.h | 2 +- package/starfive/v4l2_test/v4l2_test.c | 4 +++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/package/starfive/v4l2_test/common.c b/package/starfive/v4l2_test/common.c index a10a8ddd..1e48846e 100644 --- a/package/starfive/v4l2_test/common.c +++ b/package/starfive/v4l2_test/common.c @@ -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) { diff --git a/package/starfive/v4l2_test/common.h b/package/starfive/v4l2_test/common.h index e2892186..48660ab9 100644 --- a/package/starfive/v4l2_test/common.h +++ b/package/starfive/v4l2_test/common.h @@ -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); // } diff --git a/package/starfive/v4l2_test/v4l2_test.c b/package/starfive/v4l2_test/v4l2_test.c index 239d62d0..6901f896 100644 --- a/package/starfive/v4l2_test/v4l2_test.c +++ b/package/starfive/v4l2_test/v4l2_test.c @@ -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);