Skip to content

Commit 10c5912

Browse files
authored
Remove unused bs functions (#196)
* removed unused functions in bsr Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * added protection code in case of large (impossible) k value Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * add thread return value Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * fixed thread error handling Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * refactoring Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * refactoring Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> --------- Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com>
1 parent 170001f commit 10c5912

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/oapv.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,7 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid
19951995
ret = dec_frm_prepare(ctx, ofrms->frm[frame_cnt].imgb);
19961996
oapv_assert_g(OAPV_SUCCEEDED(ret), ERR);
19971997

1998-
int res;
1998+
int res, ret_thread;
19991999
oapv_tpool_t *tpool = ctx->tpool;
20002000
int parallel_task = 1;
20012001
int tidx = 0;
@@ -2007,11 +2007,11 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid
20072007
tpool->run(ctx->thread_id[tidx], dec_thread_tile,
20082008
(void *)ctx->core[tidx]);
20092009
}
2010-
ret = dec_thread_tile((void *)ctx->core[tidx]);
2010+
ret_thread = dec_thread_tile((void *)ctx->core[tidx]);
20112011
for(tidx = 0; tidx < parallel_task - 1; tidx++) {
20122012
tpool->join(ctx->thread_id[tidx], &res);
20132013
if(OAPV_FAILED(res)) {
2014-
ret = res;
2014+
ret_thread = res;
20152015
}
20162016
}
20172017
/****************************************************/
@@ -2025,13 +2025,16 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid
20252025
if(ret == OAPV_OK && ctx->use_frm_hash) {
20262026
oapv_imgb_set_md5(ctx->imgb);
20272027
}
2028-
ret = dec_frm_finish(ctx); // FIX-ME
2028+
ret = dec_frm_finish(ctx);
20292029
oapv_assert_g(OAPV_SUCCEEDED(ret), ERR);
20302030

20312031
ofrms->frm[frame_cnt].pbu_type = pbuh.pbu_type;
20322032
ofrms->frm[frame_cnt].group_id = pbuh.group_id;
20332033
stat->frm_size[frame_cnt] = pbu_size + 4 /* byte size of 'pbu_size' syntax */;
20342034
frame_cnt++;
2035+
2036+
/* here, check return values of each thread */
2037+
oapv_assert_gv(OAPV_SUCCEEDED(ret_thread), ret, ret_thread, ERR);
20352038
}
20362039
else if(pbuh.pbu_type == OAPV_PBU_TYPE_METADATA) {
20372040
ret = oapvd_vlc_metadata(bs, pbu_size, mid, pbuh.group_id);

src/oapv_bs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ int oapv_bsw_write(oapv_bs_t *bs, u32 val, int len)
146146
#if ENABLE_DECODER
147147
///////////////////////////////////////////////////////////////////////////////
148148

149-
static void inline bsr_skip_code(oapv_bs_t *bs, int size)
149+
static inline void bsr_skip_code(oapv_bs_t *bs, int size)
150150
{
151151
oapv_assert(size <= 32);
152152
oapv_assert(bs->leftbits >= size);

src/oapv_vlc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ static int dec_vlc_read_kparam0(oapv_bs_t *bs)
650650
k++;
651651
}
652652
}
653+
oapv_assert_rv(k < 32, -1); /* prevent too large (impossible) k value */
654+
653655
if(k > 0) {
654656
symbol += ((u32)0xFFFFFFFF) >> (32 - k);
655657

@@ -736,6 +738,9 @@ static int dec_vlc_read(oapv_bs_t *bs, int k)
736738
}
737739
}
738740
}
741+
742+
oapv_assert_rv(k < 32, -1); /* prevent too large (impossible) k value */
743+
739744
if(k > 0) {
740745
while(bs->leftbits < k) {
741746
symbol += bs->code >> (64 - k);
@@ -858,6 +863,8 @@ int oapvd_vlc_ac_coef(oapv_bs_t *bs, s16 *coef, int *kparam_ac)
858863
run = dec_vlc_read(bs, k_run);
859864
}
860865

866+
oapv_assert_rv(run >= 0, OAPV_ERR_MALFORMED_BITSTREAM);
867+
861868
// here, no need to set 'zero-run' in coef; it's already initialized to zero.
862869

863870
scan_pos_offset += run;

0 commit comments

Comments
 (0)