Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/oapv.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ static int enc_tile_comp(oapv_bs_t *bs, oapve_tile_t *tile, oapve_ctx_t *ctx, oa
ctx->fn_imgb_to_blk[c](o16, OAPV_BLK_W, OAPV_BLK_H, s_org, blk_x, (OAPV_BLK_W << 1), core->coef, ctx->bit_depth);

ctx->fn_enc_blk(ctx, core, OAPV_LOG2_BLK_W, OAPV_LOG2_BLK_H, c);
oapve_vlc_dc_coef(ctx, core, bs, core->dc_diff, c);
oapve_vlc_ac_coef(ctx, core, bs, core->coef, 0, c);
oapve_vlc_dc_coef(bs, core->dc_diff, &core->kparam_dc[c]);
oapve_vlc_ac_coef(bs, core->coef, &core->kparam_ac[c]);
DUMP_COEF(core->coef, OAPV_BLK_D, blk_x, blk_y, c);

if(rec != NULL) {
Expand Down Expand Up @@ -867,8 +867,8 @@ static int enc_tile(oapve_ctx_t *ctx, oapve_core_t *core, oapve_tile_t *tile)
}

for(int c = 0; c < ctx->num_comp; c++) {
core->prev_dc_ctx[c] = 20;
core->prev_1st_ac_ctx[c] = 0;
core->kparam_dc[c] = OAPV_KPARAM_DC_MAX;
core->kparam_ac[c] = OAPV_KPARAM_AC_MIN;
core->prev_dc[c] = 0;

int tc, s_org, s_rec;
Expand Down Expand Up @@ -913,7 +913,6 @@ static int enc_tile(oapve_ctx_t *ctx, oapve_core_t *core, oapve_tile_t *tile)
tile->bs_size = bs_size;

oapv_bs_t bs_th;
bs_th.is_bin_count = 0;
oapv_bsw_init(&bs_th, tile->bs_buf, tile->bs_size, NULL);
tile->tile_size = bs_size - OAPV_TILE_SIZE_LEN;

Expand Down
12 changes: 0 additions & 12 deletions src/oapv_bs.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ void oapv_bsw_init(oapv_bs_t *bs, u8 *buf, int size, oapv_bs_fn_flush_t fn_flush
bs->code = 0;
bs->leftbits = 32;
bs->fn_flush = (fn_flush == NULL ? bsw_flush : fn_flush);
bs->is_bin_count = 0;
bs->bin_count = 0;
}

void oapv_bsw_deinit(oapv_bs_t *bs)
Expand Down Expand Up @@ -99,11 +97,6 @@ int oapv_bsw_write1(oapv_bs_t *bs, int val)
{
oapv_assert(bs);

if(bs->is_bin_count) {
bs->bin_count++;
return 0;
}

bs->leftbits--;
bs->code |= ((val & 0x1) << bs->leftbits);

Expand All @@ -124,11 +117,6 @@ int oapv_bsw_write(oapv_bs_t *bs, u32 val, int len) /* len(1 ~ 32) */

oapv_assert(bs);

if(bs->is_bin_count) {
bs->bin_count += len;
return 0;
}

leftbits = bs->leftbits;
val <<= (32 - len);
bs->code |= (val >> (32 - leftbits));
Expand Down
2 changes: 0 additions & 2 deletions src/oapv_bs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ struct oapv_bs {
oapv_bs_fn_flush_t fn_flush; // function pointer for flush operation
int ndata[4]; // arbitrary data, if needs
void *pdata[4]; // arbitrary address, if needs
char is_bin_count;
u32 bin_count;
};

///////////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 9 additions & 6 deletions src/oapv_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "oapv.h"
#include "oapv_port.h"
#include "oapv_bs.h"
#include "oapv_tpool.h"

/* oapv encoder magic code */
Expand Down Expand Up @@ -224,11 +225,13 @@ typedef struct oapve_rc_tile {
struct oapve_core {
ALIGNED_16(s16 coef[OAPV_BLK_D]);
ALIGNED_16(s16 coef_rec[OAPV_BLK_D]);
oapve_ctx_t *ctx;
int prev_dc_ctx[N_C];
int prev_1st_ac_ctx[N_C];
int tile_idx;

int kparam_dc[N_C];
int kparam_ac[N_C];
int prev_dc[N_C];

int tile_idx;

int dc_diff; /* DC difference, which is represented in 17 bits */
/* and coded as abs_dc_coeff_diff and sign_dc_coeff_diff */
int qp[N_C]; // QPs for Y, Cb(U), Cr(V)
Expand All @@ -238,12 +241,12 @@ struct oapve_core {
s16 q_mat_dec[N_C][OAPV_BLK_D];
double err_scale_tbl[N_C][OAPV_BLK_D];
int thread_idx;

oapve_ctx_t *ctx;
/* platform specific data, if needed */
void *pf;
};

#include "oapv_bs.h"

typedef struct oapve_tile oapve_tile_t;
struct oapve_tile {
oapv_th_t th;
Expand Down
202 changes: 101 additions & 101 deletions src/oapv_tbl.c

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/oapv_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _OAPV_TBL_H_
#define _OAPV_TBL_H_
#ifndef __OAPV_TBL_H_34243243243342435479875463453543543542432432__
#define __OAPV_TBL_H_34243243243342435479875463453543543542432432__

#include "oapv_def.h"

extern const u8 oapv_tbl_log2[257];
extern const s8 oapv_tbl_tm8[8][8];
extern const int oapv_tbl_dq_scale[6];
extern const u8 oapv_tbl_scan[OAPV_BLK_D];
extern const u32 CODE_LUT_100[100][5][2];
extern int oapv_itrans_diff[64][64];
extern const u16 oapve_tbl_vlc_code[100][5][2];

#endif /* _OAPV_TBL_H_ */
#endif /* __OAPV_TBL_H_34243243243342435479875463453543543542432432__ */
13 changes: 5 additions & 8 deletions src/oapv_tq.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int oapve_rdoq(oapve_core_t* core, s16 *src_coef, s16 *dst_coef, int log2_cuw, i
s32 rice_level = 0;
s32 rice_run = 0;
s32 prev_run = 0;
s32 prev_level = core->prev_1st_ac_ctx[ch_type];
int k_ac = core->kparam_ac[ch_type];
s16 tmp_coef[OAPV_BLK_D];
s64 tmp_level_double[OAPV_BLK_D];
double best_cost = 0;
Expand Down Expand Up @@ -163,7 +163,7 @@ int oapve_rdoq(oapve_core_t* core, s16 *src_coef, s16 *dst_coef, int log2_cuw, i
return nnz;
}

rice_level = oapv_clip3(OAPV_KPARAM_DC_MIN, OAPV_KPARAM_DC_MAX, core->prev_dc_ctx[ch_type] >> 1);
rice_level = core->kparam_dc[ch_type];
rice_run = prev_run / 4;
if(rice_run > 2) {
rice_run = 2;
Expand All @@ -185,7 +185,7 @@ int oapve_rdoq(oapve_core_t* core, s16 *src_coef, s16 *dst_coef, int log2_cuw, i
err1 = (double)tmp_level_double[blk_pos] * core->err_scale_tbl[ch_type][blk_pos];
uncoded_cost = err1 * err1;

rice_level = oapv_clip3(OAPV_KPARAM_DC_MIN, OAPV_KPARAM_DC_MAX, core->prev_dc_ctx[ch_type] >> 1);
rice_level = core->kparam_dc[ch_type];

for(tmp_level = max_level; tmp_level >= min_level; tmp_level--) {
if(tmp_level == 0) {
Expand Down Expand Up @@ -229,10 +229,7 @@ int oapve_rdoq(oapve_core_t* core, s16 *src_coef, s16 *dst_coef, int log2_cuw, i
if(rice_run > 2) {
rice_run = 2;
}
rice_level = prev_level >> 2;
if(rice_level > 4) {
rice_level = OAPV_KPARAM_AC_MAX;
}
rice_level = k_ac;

for(tmp_level = max_level; tmp_level >= min_level; tmp_level--) {
if(tmp_level == 0) {
Expand Down Expand Up @@ -264,7 +261,7 @@ int oapve_rdoq(oapve_core_t* core, s16 *src_coef, s16 *dst_coef, int log2_cuw, i

if(dst_coef[blk_pos]) {
prev_run = run;
prev_level = abs(dst_coef[blk_pos]);
k_ac = KPARAM_AC(oapv_abs(dst_coef[blk_pos]));
run = 0;
nnz++;
}
Expand Down
4 changes: 4 additions & 0 deletions src/oapv_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
// operation: if(val < 0) return 1, else return 0
#define oapv_get_sign16(val) (((val) >> 15) & 1)

// macro to get a sign from a 32-bit value.
// operation: if(val < 0) return 1, else return 0
#define oapv_get_sign32(val) (((val) >> 31) & 1)

// macro to set sign to a 16-bit value.
// operation: if(sign == 0) return val, else if(sign == 1) return -val
#define oapv_set_sign16(val, sign) (((val) ^ ((s16)((sign) << 15) >> 15)) + (sign))
Expand Down
Loading