aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarish Mahendrakar <harish.mahendrakar@ittiam.com>2021-01-16 00:04:19 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-01-16 00:04:19 +0000
commit9c3f795d8032b5008f78f596fc42535c53184119 (patch)
treec2329bd86f1a1193a94da8cb42b70cc93dd3e732
parent4ecf0c2c2c1394e45f7c4905c5c0ea786b229338 (diff)
parentbfb696fad83d91cefc45b40f4a357e5247984bcd (diff)
downloadlibhevc-9c3f795d8032b5008f78f596fc42535c53184119.tar.gz
encoder: Do not use memcmp for volatile data am: 2913b0a5c2 am: bfb696fad8
Original change: https://android-review.googlesource.com/c/platform/external/libhevc/+/1552637 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I0d72e5f91830e0871e233570b83a69d25e94f4ae
-rw-r--r--encoder/ihevce_multi_thrd_funcs.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/encoder/ihevce_multi_thrd_funcs.c b/encoder/ihevce_multi_thrd_funcs.c
index e50ad2b..24629e3 100644
--- a/encoder/ihevce_multi_thrd_funcs.c
+++ b/encoder/ihevce_multi_thrd_funcs.c
@@ -112,7 +112,16 @@
/*****************************************************************************/
/* Function Definitions */
/*****************************************************************************/
-
+static inline WORD32 ihevce_is_nonzero(volatile UWORD8 *buf, WORD32 size)
+{
+ WORD32 i;
+ for (i = 0; i < size; i++)
+ {
+ if (buf[i])
+ return 1;
+ }
+ return 0;
+}
/**
*******************************************************************************
*
@@ -143,7 +152,6 @@ void *ihevce_pre_enc_grp_get_next_job(
multi_thrd_ctxt_t *ps_multi_thrd;
job_queue_handle_t *ps_job_queue_hdl;
void *pv_next = NULL;
- UWORD8 au1_in_dep_cmp[MAX_IN_DEP] = { 0 };
void *pv_job_q_mutex_hdl_pre_enc = NULL;
/* Derive local variables */
@@ -182,17 +190,7 @@ void *ihevce_pre_enc_grp_get_next_job(
if(1 == i4_blocking_mode)
{
- volatile WORD32 mem_diff;
- volatile UWORD8 *pu1_ref_buf = &au1_in_dep_cmp[0];
- volatile UWORD8 *pu1_curr_buf = &ps_job_queue->au1_in_dep[0];
-
- mem_diff = memcmp((void *)pu1_ref_buf, (void *)pu1_curr_buf, MAX_IN_DEP);
-
- /* wait until all dependency is resolved */
- while(0 != mem_diff)
- {
- mem_diff = memcmp((void *)pu1_ref_buf, (void *)pu1_curr_buf, MAX_IN_DEP);
- }
+ while(ihevce_is_nonzero(ps_job_queue->au1_in_dep, MAX_IN_DEP));
/* update the next job in the queue */
ps_job_queue_hdl->pv_next = ps_job_queue->pv_next;
@@ -200,7 +198,7 @@ void *ihevce_pre_enc_grp_get_next_job(
else
{
/* check for input dependency resolved */
- if((0 != memcmp(&au1_in_dep_cmp[0], &ps_job_queue->au1_in_dep[0], MAX_IN_DEP)))
+ if(ihevce_is_nonzero(ps_job_queue->au1_in_dep, MAX_IN_DEP))
{
/* return null */
pv_next = NULL;
@@ -252,7 +250,6 @@ void *ihevce_enc_grp_get_next_job(
job_queue_handle_t *ps_job_queue_hdl;
void *pv_next = NULL;
void *pv_job_q_mutex_hdl_enc_grp;
- UWORD8 au1_in_dep_cmp[MAX_IN_DEP] = { 0 };
/* Derive local variables */
ps_multi_thrd = (multi_thrd_ctxt_t *)pv_multi_thrd_ctxt;
@@ -289,17 +286,7 @@ void *ihevce_enc_grp_get_next_job(
if(1 == i4_blocking_mode)
{
- volatile WORD32 mem_diff;
- volatile UWORD8 *pu1_ref_buf = &au1_in_dep_cmp[0];
- volatile UWORD8 *pu1_curr_buf = &ps_job_queue->au1_in_dep[0];
-
- mem_diff = memcmp((void *)pu1_ref_buf, (void *)pu1_curr_buf, MAX_IN_DEP);
-
- /* wait until all dependency is resolved */
- while(0 != mem_diff)
- {
- mem_diff = memcmp((void *)pu1_ref_buf, (void *)pu1_curr_buf, MAX_IN_DEP);
- }
+ while(ihevce_is_nonzero(ps_job_queue->au1_in_dep, MAX_IN_DEP));
/* update the next job in the queue */
ps_job_queue_hdl->pv_next = ps_job_queue->pv_next;
@@ -307,7 +294,7 @@ void *ihevce_enc_grp_get_next_job(
else
{
/* check for input dependency resolved */
- if((0 != memcmp(&au1_in_dep_cmp[0], &ps_job_queue->au1_in_dep[0], MAX_IN_DEP)))
+ if(ihevce_is_nonzero(ps_job_queue->au1_in_dep, MAX_IN_DEP))
{
/* return null */
pv_next = NULL;