diff --git a/src/hal/hisi/v4_hal.c b/src/hal/hisi/v4_hal.c index 7198a4c..85f194c 100644 --- a/src/hal/hisi/v4_hal.c +++ b/src/hal/hisi/v4_hal.c @@ -140,6 +140,23 @@ int v4_channel_create(char index, char mirror, char flip, char framerate) return EXIT_SUCCESS; } +int v4_channel_grayscale(char enable) +{ + int ret; + + for (char i = 0; i < V4_VENC_CHN_NUM; i++) { + v4_venc_para param; + if (!v4_state[i].enable) continue; + if (ret = v4_venc.fnGetChannelParam(i, ¶m)) + return ret; + param.grayscaleOn = enable; + if (ret = v4_venc.fnSetChannelParam(i, ¶m)) + return ret; + } + + return EXIT_SUCCESS; +} + int v4_channel_unbind(char index) { int ret; diff --git a/src/hal/hisi/v4_hal.h b/src/hal/hisi/v4_hal.h index 0238e79..b9fa6f3 100644 --- a/src/hal/hisi/v4_hal.h +++ b/src/hal/hisi/v4_hal.h @@ -30,6 +30,7 @@ int v4_audio_init(void); int v4_channel_bind(char index); int v4_channel_create(char index, char mirror, char flip, char framerate); +int v4_channel_grayscale(char enable); int v4_channel_unbind(char index); void *v4_image_thread(void); diff --git a/src/hal/hisi/v4_venc.h b/src/hal/hisi/v4_venc.h index ec24e53..0d4ec10 100644 --- a/src/hal/hisi/v4_venc.h +++ b/src/hal/hisi/v4_venc.h @@ -260,6 +260,17 @@ typedef struct { v4_venc_packinfo packetInfo[8]; } v4_venc_pack; +typedef struct { + int grayscaleOn; + unsigned int prio; + unsigned int maxStrmCnt; + unsigned int wakeFrmCnt; + int cropOn; + v4_common_rect crop; + int srcFps; + int dstFps; +} v4_venc_para; + typedef struct { unsigned int leftPics; unsigned int leftBytes; @@ -363,9 +374,11 @@ typedef struct { int (*fnCreateChannel)(int channel, v4_venc_chn *config); int (*fnGetChannelConfig)(int channel, v4_venc_chn *config); + int (*fnGetChannelParam)(int channel, v4_venc_para *config); int (*fnDestroyChannel)(int channel); int (*fnResetChannel)(int channel); int (*fnSetChannelConfig)(int channel, v4_venc_chn *config); + int (*fnSetChannelParam)(int channel, v4_venc_para *config); int (*fnSetColorToGray)(int channel, int *active); int (*fnFreeDescriptor)(int channel); @@ -410,6 +423,12 @@ static int v4_venc_load(v4_venc_impl *venc_lib) { return EXIT_FAILURE; } + if (!(venc_lib->fnGetChannelParam = (int(*)(int channel, v4_venc_para *config)) + dlsym(venc_lib->handle, "HI_MPI_VENC_GetChnParam"))) { + fprintf(stderr, "[v4_venc] Failed to acquire symbol HI_MPI_VENC_GetChnParam!\n"); + return EXIT_FAILURE; + } + if (!(venc_lib->fnResetChannel = (int(*)(int channel)) dlsym(venc_lib->handle, "HI_MPI_VENC_ResetChn"))) { fprintf(stderr, "[v4_venc] Failed to acquire symbol HI_MPI_VENC_ResetChn!\n"); @@ -422,6 +441,12 @@ static int v4_venc_load(v4_venc_impl *venc_lib) { return EXIT_FAILURE; } + if (!(venc_lib->fnSetChannelParam = (int(*)(int channel, v4_venc_para *config)) + dlsym(venc_lib->handle, "HI_MPI_VENC_SetChnParam"))) { + fprintf(stderr, "[v4_venc] Failed to acquire symbol HI_MPI_VENC_SetChnParam!\n"); + return EXIT_FAILURE; + } + if (!(venc_lib->fnFreeDescriptor = (int(*)(int channel)) dlsym(venc_lib->handle, "HI_MPI_VENC_CloseFd"))) { fprintf(stderr, "[v4_venc] Failed to acquire symbol HI_MPI_VENC_CloseFd!\n"); diff --git a/src/hal/sstar/i6_hal.c b/src/hal/sstar/i6_hal.c index 113800b..ee94550 100644 --- a/src/hal/sstar/i6_hal.c +++ b/src/hal/sstar/i6_hal.c @@ -571,7 +571,7 @@ int i6_video_destroy_all(void) return EXIT_SUCCESS; } -int i6_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdata *jpeg) +int i6_video_snapshot_grab(char index, char quality, hal_jpegdata *jpeg) { int ret; @@ -596,8 +596,6 @@ int i6_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdat goto abort; } - i6_channel_grayscale(grayscale); - unsigned int count = 1; if (i6_venc.fnStartReceivingEx(index, &count)) { fprintf(stderr, "[i6_venc] Requesting one frame " diff --git a/src/hal/sstar/i6_hal.h b/src/hal/sstar/i6_hal.h index d6fef98..89257ae 100644 --- a/src/hal/sstar/i6_hal.h +++ b/src/hal/sstar/i6_hal.h @@ -39,7 +39,7 @@ int i6_region_setbitmap(int handle, hal_bitmap *bitmap); int i6_video_create(char index, hal_vidconfig *config); int i6_video_destroy(char index); int i6_video_destroy_all(void); -int i6_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdata *jpeg); +int i6_video_snapshot_grab(char index, char quality, hal_jpegdata *jpeg); void *i6_video_thread(void); void i6_system_deinit(void); diff --git a/src/hal/sstar/i6c_hal.c b/src/hal/sstar/i6c_hal.c index f4c07ad..bb6d0da 100644 --- a/src/hal/sstar/i6c_hal.c +++ b/src/hal/sstar/i6c_hal.c @@ -676,7 +676,7 @@ int i6c_video_destroy_all(void) return EXIT_SUCCESS; } -int i6c_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdata *jpeg) +int i6c_video_snapshot_grab(char index, char quality, hal_jpegdata *jpeg) { int ret; char device = @@ -705,8 +705,6 @@ int i6c_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegda goto abort; } - i6c_channel_grayscale(grayscale); - unsigned int count = 1; if (i6c_venc.fnStartReceivingEx(device, index, &count)) { fprintf(stderr, "[i6c_venc] Requesting one frame " diff --git a/src/hal/sstar/i6c_hal.h b/src/hal/sstar/i6c_hal.h index 28be876..6a51548 100644 --- a/src/hal/sstar/i6c_hal.h +++ b/src/hal/sstar/i6c_hal.h @@ -39,7 +39,7 @@ int i6c_region_setbitmap(int handle, hal_bitmap *bitmap); int i6c_video_create(char index, hal_vidconfig *config); int i6c_video_destroy(char index, char jpeg); int i6c_video_destroy_all(void); -int i6c_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdata *jpeg); +int i6c_video_snapshot_grab(char index, char quality, hal_jpegdata *jpeg); void *i6c_video_thread(void); void i6c_system_deinit(void); diff --git a/src/hal/sstar/i6f_hal.c b/src/hal/sstar/i6f_hal.c index e1c95de..b3526fc 100644 --- a/src/hal/sstar/i6f_hal.c +++ b/src/hal/sstar/i6f_hal.c @@ -633,7 +633,7 @@ int i6f_video_destroy_all(void) return EXIT_SUCCESS; } -int i6f_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdata *jpeg) +int i6f_video_snapshot_grab(char index, char quality, hal_jpegdata *jpeg) { int ret; char device = @@ -664,8 +664,6 @@ int i6f_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegda goto abort; } - i6f_channel_grayscale(grayscale); - unsigned int count = 1; if (i6f_venc.fnStartReceivingEx(device, index, &count)) { fprintf(stderr, "[i6f_venc] Requesting one frame " diff --git a/src/hal/sstar/i6f_hal.h b/src/hal/sstar/i6f_hal.h index 483ef88..4d53d38 100644 --- a/src/hal/sstar/i6f_hal.h +++ b/src/hal/sstar/i6f_hal.h @@ -37,7 +37,7 @@ int i6f_region_setbitmap(int handle, hal_bitmap *bitmap); int i6f_video_create(char index, hal_vidconfig *config); int i6f_video_destroy(char index, char jpeg); int i6f_video_destroy_all(void); -int i6f_video_snapshot_grab(char index, char quality, char grayscale, hal_jpegdata *jpeg); +int i6f_video_snapshot_grab(char index, char quality, hal_jpegdata *jpeg); void *i6f_video_thread(void); void i6f_system_deinit(void); diff --git a/src/jpeg.c b/src/jpeg.c index cce217d..f4d6895 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -114,12 +114,9 @@ int jpeg_get(short width, short height, char quality, char grayscale, int ret; switch (plat) { - case HAL_PLATFORM_I6: ret = i6_video_snapshot_grab(jpeg_index, quality, - grayscale, jpeg); break; - case HAL_PLATFORM_I6C: ret = i6c_video_snapshot_grab(jpeg_index, quality, - grayscale, jpeg); break; - case HAL_PLATFORM_I6F: ret = i6f_video_snapshot_grab(jpeg_index, quality, - grayscale, jpeg); break; + case HAL_PLATFORM_I6: ret = i6_video_snapshot_grab(jpeg_index, quality, jpeg); break; + case HAL_PLATFORM_I6C: ret = i6c_video_snapshot_grab(jpeg_index, quality, jpeg); break; + case HAL_PLATFORM_I6F: ret = i6f_video_snapshot_grab(jpeg_index, quality, jpeg); break; case HAL_PLATFORM_V3: ret = v3_video_snapshot_grab(jpeg_index, jpeg); break; case HAL_PLATFORM_V4: ret = v4_video_snapshot_grab(jpeg_index, jpeg); break; case HAL_PLATFORM_T31: ret = t31_video_snapshot_grab(app_config.mjpeg_enable ? diff --git a/src/video.c b/src/video.c index 0475f39..88566ec 100644 --- a/src/video.c +++ b/src/video.c @@ -103,6 +103,7 @@ void set_grayscale(bool active) { case HAL_PLATFORM_I6C: i6c_channel_grayscale(active); break; case HAL_PLATFORM_I6F: i6f_channel_grayscale(active); break; case HAL_PLATFORM_V3: v3_channel_grayscale(active); break; + case HAL_PLATFORM_V4: v4_channel_grayscale(active); break; case HAL_PLATFORM_T31: t31_channel_grayscale(active); break; } pthread_mutex_unlock(&mutex);