From 5e9c764903c6ae3c14aa3a71dd06402f0be6077f Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 20 Mar 2025 15:04:28 +0530 Subject: [PATCH] avcenc: Replacing KEEP_THREADS_ACTIVE with runtime check Test: avcenc -c enc.cfg Change-Id: If6c8c29d2b5b1322796b8b25dc74231d13b61243 --- Android.bp | 1 - CMakeLists.txt | 1 - common/ih264_list.c | 2 -- common/ih264_list.h | 4 --- common/ithread.c | 2 -- common/ithread.h | 4 --- encoder/ih264e_api.c | 69 ++++++++++++++++++------------------ encoder/ih264e_defs.h | 7 ---- encoder/ih264e_encode.c | 73 +++++++++++++++++++-------------------- encoder/ih264e_master.h | 5 --- encoder/ih264e_structs.h | 9 ++--- encoder/iv2.h | 3 ++ encoder/ive2.h | 11 +++--- encoder/libavcenc.cmake | 4 --- examples/avcenc/app.h | 2 ++ examples/avcenc/enc.cfg | 1 + examples/avcenc/main.c | 8 +++++ fuzzer/avc_enc_fuzzer.cpp | 4 +++ 18 files changed, 99 insertions(+), 111 deletions(-) diff --git a/Android.bp b/Android.bp index c918dd6..a8e8a4d 100644 --- a/Android.bp +++ b/Android.bp @@ -83,7 +83,6 @@ cc_defaults { "-Wall", "-Werror", "-Wno-error=constant-conversion", - "-UKEEP_THREADS_ACTIVE", ], arch: { arm: { diff --git a/CMakeLists.txt b/CMakeLists.txt index 03dc35d..a32ae8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ set(AVC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") option(ENABLE_MVC "Enables svcenc and svcdec builds" OFF) option(ENABLE_SVC "Enables svcenc and svcdec builds" OFF) option(ENABLE_TESTS "Enables gtest based unit tests" OFF) -option(KEEP_THREADS_ACTIVE "Enable KEEP THREADS ACTIVE" OFF) if("${AVC_ROOT}" STREQUAL "${AVC_CONFIG_DIR}") message( diff --git a/common/ih264_list.c b/common/ih264_list.c index 417ee7f..b3ecd4f 100644 --- a/common/ih264_list.c +++ b/common/ih264_list.c @@ -558,7 +558,6 @@ IH264_ERROR_T ih264_list_dequeue(list_t *ps_list, void *pv_buf, WORD32 blocking) return ret; } -#ifdef KEEP_THREADS_ACTIVE /** ******************************************************************************* * @@ -585,4 +584,3 @@ WORD32 ih264_get_job_count_in_list(list_t *ps_list) RETURN_IF((ih264_list_unlock(ps_list) != IH264_SUCCESS), 0); return jobs; } -#endif /* KEEP_THREADS_ACTIVE */ diff --git a/common/ih264_list.h b/common/ih264_list.h index 5416b65..ab8c8fd 100644 --- a/common/ih264_list.h +++ b/common/ih264_list.h @@ -100,10 +100,6 @@ IH264_ERROR_T ih264_list_queue(list_t *ps_list, void *pv_buf, WORD32 blocking); IH264_ERROR_T ih264_list_dequeue(list_t *ps_list, void *pv_buf, WORD32 blocking); -#ifdef KEEP_THREADS_ACTIVE - WORD32 ih264_get_job_count_in_list(list_t *ps_list); -#endif /* KEEP_THREADS_ACTIVE */ - #endif /* _IH264_LIST_H_ */ diff --git a/common/ithread.c b/common/ithread.c index 25cdff3..a947e33 100644 --- a/common/ithread.c +++ b/common/ithread.c @@ -235,7 +235,6 @@ WORD32 ithread_cond_signal(void *cond) return pthread_cond_signal((pthread_cond_t *)cond); } -#ifdef KEEP_THREADS_ACTIVE UWORD32 ithread_get_cond_size(void) { return sizeof(pthread_cond_t); @@ -245,4 +244,3 @@ WORD32 ithread_cond_broadcast(void *cond) { return pthread_cond_broadcast((pthread_cond_t *)cond); } -#endif /* KEEP_THREADS_ACTIVE */ diff --git a/common/ithread.h b/common/ithread.h index 6d957ad..562d37d 100644 --- a/common/ithread.h +++ b/common/ithread.h @@ -95,12 +95,8 @@ WORD32 ithread_cond_wait(void *cond, void *mutex); WORD32 ithread_cond_signal(void *cond); -#ifdef KEEP_THREADS_ACTIVE - UWORD32 ithread_get_cond_size(void); WORD32 ithread_cond_broadcast(void *cond); -#endif /* KEEP_THREADS_ACTIVE */ - #endif /* _ITHREAD_H_ */ diff --git a/encoder/ih264e_api.c b/encoder/ih264e_api.c index 5eaaee9..312bdb8 100644 --- a/encoder/ih264e_api.c +++ b/encoder/ih264e_api.c @@ -661,6 +661,7 @@ static IV_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, ps_ip->s_ive_ip.u4_max_srch_rng_x; s_ip.s_ive_ip.u4_max_srch_rng_y = ps_ip->s_ive_ip.u4_max_srch_rng_y; + s_ip.s_ive_ip.u4_keep_threads_active = ps_ip->s_ive_ip.u4_keep_threads_active; for (i = 0; i < MEM_REC_CNT; i++) { @@ -2857,13 +2858,14 @@ static WORD32 ih264e_init(codec_t *ps_codec) /* ctl mutex init */ ithread_mutex_init(ps_codec->pv_ctl_mutex); -#ifdef KEEP_THREADS_ACTIVE - /* thread pool mutex init */ - ithread_mutex_init(ps_codec->s_thread_pool.pv_thread_pool_mutex); + if (ps_codec->s_cfg.u4_keep_threads_active) + { + /* thread pool mutex init */ + ithread_mutex_init(ps_codec->s_thread_pool.pv_thread_pool_mutex); - /* thread pool conditional init */ - ithread_cond_init(ps_codec->s_thread_pool.pv_thread_pool_cond); -#endif /* KEEP_THREADS_ACTIVE */ + /* thread pool conditional init */ + ithread_cond_init(ps_codec->s_thread_pool.pv_thread_pool_cond); + } /* Set encoder chroma format */ ps_codec->e_codec_color_format = @@ -3502,11 +3504,11 @@ static WORD32 ih264e_fill_num_mem_rec(void *pv_api_ip, void *pv_api_op) } DEBUG("\nMemory record Id %d = %d \n", MEM_REC_SLICE_MAP, ps_mem_rec->u4_mem_size); -#ifdef KEEP_THREADS_ACTIVE + ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_HANDLE]; /************************************************************************ - * Request memory for thread pool context * - ***********************************************************************/ - ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_POOL]; + * Request memory for thread pool context * + ************************************************************************/ + if (ps_ip->s_ive_ip.u4_keep_threads_active) { /* total size of the mem record */ WORD32 total_size = 0; @@ -3523,19 +3525,16 @@ static WORD32 ih264e_fill_num_mem_rec(void *pv_api_ip, void *pv_api_op) /* Store the total calculated size in memory record */ ps_mem_rec->u4_mem_size = total_size; } - DEBUG("\nMemory record Id %d = %d \n", MEM_REC_THREAD_POOL, ps_mem_rec->u4_mem_size); -#else + else /************************************************************************ * Request memory to hold thread handles for each processing thread * ************************************************************************/ - ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_HANDLE]; { WORD32 handle_size = ithread_get_handle_size(); ps_mem_rec->u4_mem_size = MAX_PROCESS_THREADS * handle_size; } DEBUG("\nMemory record Id %d = %d \n", MEM_REC_THREAD_HANDLE, ps_mem_rec->u4_mem_size); -#endif /* KEEP_THREADS_ACTIVE */ /************************************************************************ * Request memory to hold mutex for control calls * @@ -4117,6 +4116,7 @@ static WORD32 ih264e_init_mem_rec(iv_obj_t *ps_codec_obj, ps_cfg->e_soc = ps_ip->s_ive_ip.e_soc; ps_cfg->u4_enable_recon = ps_ip->s_ive_ip.u4_enable_recon; ps_cfg->e_rc_mode = ps_ip->s_ive_ip.e_rc_mode; + ps_cfg->u4_keep_threads_active = ps_ip->s_ive_ip.u4_keep_threads_active; /* Validate params */ if ((ps_ip->s_ive_ip.u4_max_level < MIN_LEVEL) @@ -4449,8 +4449,8 @@ static WORD32 ih264e_init_mem_rec(iv_obj_t *ps_codec_obj, } } -#ifdef KEEP_THREADS_ACTIVE - ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_POOL]; + ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_HANDLE]; + if (ps_ip->s_ive_ip.u4_keep_threads_active) { /* temp var */ WORD32 i = 0; @@ -4471,9 +4471,11 @@ static WORD32 ih264e_init_mem_rec(iv_obj_t *ps_codec_obj, pu1_buf += ALIGN128(ithread_get_handle_size()); } } -#else - ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_HANDLE]; + else { + /* temp var */ + WORD32 i = 0; + WORD32 handle_size = ithread_get_handle_size(); for (i = 0; i < MAX_PROCESS_THREADS; i++) @@ -4482,7 +4484,6 @@ static WORD32 ih264e_init_mem_rec(iv_obj_t *ps_codec_obj, + (i * handle_size); } } -#endif /* KEEP_THREADS_ACTIVE */ ps_mem_rec = &ps_mem_rec_base[MEM_REC_CTL_MUTEX]; { @@ -4996,12 +4997,17 @@ static WORD32 ih264e_retrieve_memrec(iv_obj_t *ps_codec_obj, return IV_FAIL; } -#ifdef KEEP_THREADS_ACTIVE - ih264e_thread_pool_shutdown(ps_codec); -#else - /* join threads upon at end of sequence */ - ih264e_join_threads(ps_codec); -#endif /* KEEP_THREADS_ACTIVE */ + if (ps_codec->s_cfg.u4_keep_threads_active) + { + ih264e_thread_pool_shutdown(ps_codec); + ithread_cond_destroy(ps_codec->s_thread_pool.pv_thread_pool_cond); + ithread_mutex_destroy(ps_codec->s_thread_pool.pv_thread_pool_mutex); + } + else + { + /* join threads upon at end of sequence */ + ih264e_join_threads(ps_codec); + } /* collect list of memory records used by the encoder library */ memcpy(ps_ip->s_ive_ip.ps_mem_rec, ps_codec->ps_mem_rec_backup, @@ -5013,10 +5019,6 @@ static WORD32 ih264e_retrieve_memrec(iv_obj_t *ps_codec_obj, ih264_list_free(ps_codec->pv_proc_jobq); ithread_mutex_destroy(ps_codec->pv_ctl_mutex); ithread_mutex_destroy(ps_codec->pv_entropy_mutex); -#ifdef KEEP_THREADS_ACTIVE - ithread_cond_destroy(ps_codec->s_thread_pool.pv_thread_pool_cond); - ithread_mutex_destroy(ps_codec->s_thread_pool.pv_thread_pool_mutex); -#endif /* KEEP_THREADS_ACTIVE */ ih264_buf_mgr_free((buf_mgr_t *)ps_codec->pv_mv_buf_mgr); ih264_buf_mgr_free((buf_mgr_t *)ps_codec->pv_ref_buf_mgr); @@ -6196,10 +6198,11 @@ static WORD32 ih264e_reset(iv_obj_t *ps_codec_obj, if (ps_codec != NULL) { -#ifdef KEEP_THREADS_ACTIVE - /* Shutdown active threads before reinitialization */ - ih264e_thread_pool_shutdown(ps_codec); -#endif + if (ps_codec->s_cfg.u4_keep_threads_active) + { + /* Shutdown active threads before reinitialization */ + ih264e_thread_pool_shutdown(ps_codec); + } ih264e_init(ps_codec); } else diff --git a/encoder/ih264e_defs.h b/encoder/ih264e_defs.h index 205af8c..317e306 100644 --- a/encoder/ih264e_defs.h +++ b/encoder/ih264e_defs.h @@ -469,17 +469,10 @@ enum */ MEM_REC_SLICE_MAP, -#ifdef KEEP_THREADS_ACTIVE - /** - * Holds thread pool - */ - MEM_REC_THREAD_POOL, -#else /** * Holds thread handles */ MEM_REC_THREAD_HANDLE, -#endif /* KEEP_THREADS_ACTIVE */ /** * Holds control call mutex diff --git a/encoder/ih264e_encode.c b/encoder/ih264e_encode.c index f662b02..da93afa 100644 --- a/encoder/ih264e_encode.c +++ b/encoder/ih264e_encode.c @@ -109,7 +109,6 @@ /* Function Definitions */ /*****************************************************************************/ -#ifdef KEEP_THREADS_ACTIVE /** ******************************************************************************* * @@ -378,7 +377,6 @@ WORD32 ih264e_thread_pool_sync(codec_t *ps_codec) return ret; } -#else /** ****************************************************************************** @@ -420,7 +418,6 @@ void ih264e_join_threads(codec_t *ps_codec) ps_codec->i4_proc_thread_cnt = 0; } -#endif /* KEEP_THREADS_ACTIVE */ /** ****************************************************************************** @@ -859,10 +856,10 @@ WORD32 ih264e_encode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) ps_codec->i4_gen_header = 1; } -#ifdef KEEP_THREADS_ACTIVE /* initialize thread pool */ - ih264e_thread_pool_init(ps_codec); -#endif /* KEEP_THREADS_ACTIVE */ - + if (ps_codec->s_cfg.u4_keep_threads_active) + { + ih264e_thread_pool_init(ps_codec); + } } /* generate header and return when encoder is operated in header mode */ @@ -944,41 +941,43 @@ WORD32 ih264e_encode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) ps_video_encode_op->s_ive_op.u4_error_code, IV_FAIL); -#ifdef KEEP_THREADS_ACTIVE - /* reset thread pool and prepare for new frame */ - ih264e_thread_pool_activate(ps_codec); - - /* main thread */ - ih264e_process_thread(&ps_codec->as_process[0]); - - /* sync all threads */ - ih264e_thread_pool_sync(ps_codec); -#else - for (i = 0; i < num_thread_cnt; i++) + if (ps_codec->s_cfg.u4_keep_threads_active) { - ret = ithread_create(ps_codec->apv_proc_thread_handle[i], - NULL, - (void *)ih264e_process_thread, - &ps_codec->as_process[i + 1]); - if (ret != 0) + /* reset thread pool and prepare for new frame */ + ih264e_thread_pool_activate(ps_codec); + + /* main thread */ + ih264e_process_thread(&ps_codec->as_process[0]); + + /* sync all threads */ + ih264e_thread_pool_sync(ps_codec); + } + else + { + for (i = 0; i < num_thread_cnt; i++) { - printf("pthread Create Failed"); - assert(0); + ret = ithread_create(ps_codec->apv_proc_thread_handle[i], + NULL, + (void *)ih264e_process_thread, + &ps_codec->as_process[i + 1]); + if (ret != 0) + { + printf("pthread Create Failed"); + assert(0); + } + + ps_codec->ai4_process_thread_created[i] = 1; + + ps_codec->i4_proc_thread_cnt++; } - ps_codec->ai4_process_thread_created[i] = 1; + /* launch job */ + ih264e_process_thread(ps_proc); - ps_codec->i4_proc_thread_cnt++; + /* Join threads at the end of encoding a frame */ + ih264e_join_threads(ps_codec); } - - /* launch job */ - ih264e_process_thread(ps_proc); - - /* Join threads at the end of encoding a frame */ - ih264e_join_threads(ps_codec); -#endif /* KEEP_THREADS_ACTIVE */ - ih264_list_reset(ps_codec->pv_proc_jobq); ih264_list_reset(ps_codec->pv_entropy_jobq); @@ -1267,12 +1266,10 @@ WORD32 ih264e_encode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) ps_video_encode_op->s_ive_op.s_out_buf = s_out_buf.s_bits_buf; -#ifdef KEEP_THREADS_ACTIVE - if(ps_video_encode_op->s_ive_op.u4_is_last) + if (ps_codec->s_cfg.u4_keep_threads_active && ps_video_encode_op->s_ive_op.u4_is_last) { ih264e_thread_pool_shutdown(ps_codec); } -#endif return IV_SUCCESS; } diff --git a/encoder/ih264e_master.h b/encoder/ih264e_master.h index f9b003a..d652954 100644 --- a/encoder/ih264e_master.h +++ b/encoder/ih264e_master.h @@ -41,7 +41,6 @@ /*****************************************************************************/ /* Function Declarations */ /*****************************************************************************/ -#ifdef KEEP_THREADS_ACTIVE WORD32 ih264e_thread_pool_init(codec_t *ps_codec); @@ -53,12 +52,8 @@ WORD32 ih264e_thread_pool_activate(codec_t *ps_codec); WORD32 ih264e_thread_pool_sync(codec_t *ps_codec); -#else - void ih264e_join_threads(codec_t *ps_codec); -#endif /* KEEP_THREADS_ACTIVE */ - void ih264e_compute_quality_stats(process_ctxt_t *ps_proc); IH264E_ERROR_T ih264e_wait_for_thread(UWORD32 sleep_us); diff --git a/encoder/ih264e_structs.h b/encoder/ih264e_structs.h index 44112ea..1c34aa0 100644 --- a/encoder/ih264e_structs.h +++ b/encoder/ih264e_structs.h @@ -582,6 +582,9 @@ typedef struct /** SEI structure */ sei_params_t s_sei; + /** Enabling thread pool */ + UWORD32 u4_keep_threads_active; + }cfg_params_t; @@ -1155,7 +1158,6 @@ typedef struct } entropy_ctxt_t; -#ifdef KEEP_THREADS_ACTIVE /** ****************************************************************************** * @brief The thread_pool_t structure manages a pool of worker threads, @@ -1201,7 +1203,6 @@ typedef struct WORD32 i4_working_threads; } thread_pool_t; -#endif /* KEEP_THREADS_ACTIVE */ /** ****************************************************************************** @@ -2462,12 +2463,10 @@ struct _codec_t */ void *pv_out_buf_mgr_base; -#ifdef KEEP_THREADS_ACTIVE /** * Thread pool */ thread_pool_t s_thread_pool; -#endif /* KEEP_THREADS_ACTIVE */ /** * Buffer manager for output buffers @@ -2555,12 +2554,10 @@ struct _codec_t */ process_ctxt_t as_process[MAX_PROCESS_CTXT]; -#ifndef KEEP_THREADS_ACTIVE /** * Thread handle for each of the processing threads */ void *apv_proc_thread_handle[MAX_PROCESS_THREADS]; -#endif /** * Structure for global PSNR diff --git a/encoder/iv2.h b/encoder/iv2.h index ed17e81..79991f4 100644 --- a/encoder/iv2.h +++ b/encoder/iv2.h @@ -335,6 +335,9 @@ typedef struct { /** Maximum search range to be used in Y direction */ UWORD32 u4_max_srch_rng_y; + /** Enabling thread pool */ + UWORD32 u4_keep_threads_active; + }iv_fill_mem_rec_ip_t; diff --git a/encoder/ive2.h b/encoder/ive2.h index a67ef90..08d2031 100644 --- a/encoder/ive2.h +++ b/encoder/ive2.h @@ -325,11 +325,14 @@ typedef struct /** Slice parameter */ UWORD32 u4_slice_param; - /** Processor architecture */ - IV_ARCH_T e_arch; + /** Processor architecture */ + IV_ARCH_T e_arch; - /** SOC details */ - IV_SOC_T e_soc; + /** SOC details */ + IV_SOC_T e_soc; + + /** Enabling thread pool */ + UWORD32 u4_keep_threads_active; }ive_init_ip_t; diff --git a/encoder/libavcenc.cmake b/encoder/libavcenc.cmake index 430d613..a8b525c 100644 --- a/encoder/libavcenc.cmake +++ b/encoder/libavcenc.cmake @@ -90,7 +90,3 @@ add_library(libavcenc STATIC ${LIBAVC_COMMON_SRCS} ${LIBAVC_COMMON_ASMS} ${LIBAVCENC_SRCS} ${LIBAVCENC_ASMS}) target_compile_definitions(libavcenc PRIVATE N_MB_ENABLE) - -if(KEEP_THREADS_ACTIVE) - target_compile_definitions(libavcenc PRIVATE KEEP_THREADS_ACTIVE) -endif() diff --git a/examples/avcenc/app.h b/examples/avcenc/app.h index 9935e52..95bba6e 100644 --- a/examples/avcenc/app.h +++ b/examples/avcenc/app.h @@ -384,6 +384,8 @@ typedef struct ih264e_ctl_set_sei_ave_params_ip_t s_sei_ave_params; ih264e_ctl_set_sei_sii_params_ip_t s_sei_sii_params; + UWORD32 u4_keep_threads_active; + } app_ctxt_t; diff --git a/examples/avcenc/enc.cfg b/examples/avcenc/enc.cfg index ba62199..9ace863 100644 --- a/examples/avcenc/enc.cfg +++ b/examples/avcenc/enc.cfg @@ -44,4 +44,5 @@ --bframes 0 --adaptive_intra_refresh 0 --air_refresh_period 30 +--keep_threads_active 0 diff --git a/examples/avcenc/main.c b/examples/avcenc/main.c index 79629b7..67eb631 100644 --- a/examples/avcenc/main.c +++ b/examples/avcenc/main.c @@ -134,6 +134,7 @@ typedef enum MB_INFO_TYPE, PIC_INFO_FILE, PIC_INFO_TYPE, + KEEP_THREADS_ACTIVE, } ARGUMENT_T; /*****************************************************************************/ @@ -234,6 +235,7 @@ static const argument_t argument_mapping[] = { "--", "--mb_info_type", MB_INFO_TYPE, "MB info type\n"}, { "--", "--pic_info_file", PIC_INFO_FILE, "Pic info file\n"}, { "--", "--pic_info_type", PIC_INFO_TYPE, "Pic info type\n"}, + { "--", "--keep_threads_active", KEEP_THREADS_ACTIVE, "keep threads active\n"}, }; @@ -777,6 +779,10 @@ void parse_argument(app_ctxt_t *ps_app_ctxt, CHAR *argument, CHAR *value) sscanf(value, "%d", &ps_app_ctxt->u4_enable_intra_4x4); break; + case KEEP_THREADS_ACTIVE: + sscanf(value, "%d", &ps_app_ctxt->u4_keep_threads_active); + break; + case INVALID: default: printf("Ignoring argument : %s\n", argument); @@ -2728,6 +2734,7 @@ int main(int argc, char *argv[]) s_fill_mem_rec_ip.s_ive_ip.e_color_format = DEFAULT_INP_COLOR_FMT; s_fill_mem_rec_ip.s_ive_ip.u4_max_srch_rng_x = DEFAULT_MAX_SRCH_RANGE_X; s_fill_mem_rec_ip.s_ive_ip.u4_max_srch_rng_y = DEFAULT_MAX_SRCH_RANGE_Y; + s_fill_mem_rec_ip.s_ive_ip.u4_keep_threads_active = s_app_ctxt.u4_keep_threads_active; s_fill_mem_rec_op.s_ive_op.u4_size = sizeof(ih264e_fill_mem_rec_op_t); @@ -2810,6 +2817,7 @@ int main(int argc, char *argv[]) s_init_ip.s_ive_ip.u4_slice_param = s_app_ctxt.u4_slice_param; s_init_ip.s_ive_ip.e_arch = s_app_ctxt.e_arch; s_init_ip.s_ive_ip.e_soc = s_app_ctxt.e_soc; + s_init_ip.s_ive_ip.u4_keep_threads_active = s_app_ctxt.u4_keep_threads_active; s_init_op.s_ive_op.u4_size = sizeof(ih264e_init_op_t); diff --git a/fuzzer/avc_enc_fuzzer.cpp b/fuzzer/avc_enc_fuzzer.cpp index 17c4c5f..a7e60de 100644 --- a/fuzzer/avc_enc_fuzzer.cpp +++ b/fuzzer/avc_enc_fuzzer.cpp @@ -175,6 +175,7 @@ class Codec { uint32_t mForceIdrInterval = 0; // in number of frames uint32_t mDynamicBitRateInterval = 0; // in number of frames uint32_t mDynamicFrameRateInterval = 0; // in number of frames + uint32_t mKeepThreadsActive; uint64_t mBitrate = 6000000; float mFrameRate = 30; iv_obj_t *mCodecCtx = nullptr; @@ -234,6 +235,7 @@ bool Codec::initEncoder(const uint8_t **pdata, size_t *psize) { mForceIdrInterval = data[IDX_FORCE_IDR_INTERVAL] & 0x07; mDynamicBitRateInterval = data[IDX_DYNAMIC_BITRATE_INTERVAL] & 0x07; mDynamicFrameRateInterval = data[IDX_DYNAMIC_FRAME_RATE_INTERVAL] & 0x07; + mKeepThreadsActive = 0; /* Getting Number of MemRecords */ iv_num_mem_rec_ip_t sNumMemRecIp{}; @@ -280,6 +282,7 @@ bool Codec::initEncoder(const uint8_t **pdata, size_t *psize) { sFillMemRecIp.u4_max_reorder_cnt = 0; sFillMemRecIp.u4_max_srch_rng_x = 256; sFillMemRecIp.u4_max_srch_rng_y = 256; + sFillMemRecIp.u4_keep_threads_active = mKeepThreadsActive; if (IV_SUCCESS != ive_api_function(nullptr, &sFillMemRecIp, &sFillMemRecOp)) { return false; @@ -327,6 +330,7 @@ bool Codec::initEncoder(const uint8_t **pdata, size_t *psize) { sInitIp.u4_slice_param = mSliceParam; sInitIp.e_arch = mArch; sInitIp.e_soc = SOC_GENERIC; + sInitIp.u4_keep_threads_active = mKeepThreadsActive; if (IV_SUCCESS != ive_api_function(mCodecCtx, &sInitIp, &sInitOp)) { return false;