ref: d9470160313e6ccccce968b62e0de43ce5b638a2
parent: bd747b11cc509ccf9016061957f4e551c87fced9
author: Tristan Laurent <t.laurent@ateme.com>
date: Tue Nov 6 08:38:22 EST 2018
Add "disable_cdf_update" support
--- a/src/decode.c
+++ b/src/decode.c
@@ -2134,7 +2134,7 @@
ts->last_qidx = f->frame_hdr.quant.yac;
memset(ts->last_delta_lf, 0, sizeof(ts->last_delta_lf));
- msac_init(&ts->msac, data, sz);
+ msac_init(&ts->msac, data, sz, f->frame_hdr.disable_cdf_update);
ts->tiling.row = tile_row;
ts->tiling.col = tile_col;
--- a/src/msac.c
+++ b/src/msac.c
@@ -157,7 +157,8 @@
uint16_t *const cdf, const unsigned n_symbols)
{
const unsigned val = msac_decode_symbol(c, cdf, n_symbols);
- update_cdf(cdf, val, n_symbols);
+ if(c->allow_update_cdf)
+ update_cdf(cdf, val, n_symbols);
return val;
}
@@ -164,21 +165,23 @@
unsigned msac_decode_bool_adapt(MsacContext *const c, uint16_t *const cdf) {
const unsigned bit = msac_decode_bool(c, *cdf >> EC_PROB_SHIFT);
- // update_cdf() specialized for boolean CDFs
- const unsigned count = cdf[1];
- const int rate = (count >> 4) | 4;
- if (bit) {
- cdf[0] += (32768 - cdf[0]) >> rate;
- } else {
- cdf[0] -= cdf[0] >> rate;
+ if(c->allow_update_cdf){
+ // update_cdf() specialized for boolean CDFs
+ const unsigned count = cdf[1];
+ const int rate = (count >> 4) | 4;
+ if (bit) {
+ cdf[0] += (32768 - cdf[0]) >> rate;
+ } else {
+ cdf[0] -= cdf[0] >> rate;
+ }
+ cdf[1] = count + (count < 32);
}
- cdf[1] = count + (count < 32);
return bit;
}
void msac_init(MsacContext *const s, const uint8_t *const data,
- const size_t sz)
+ const size_t sz, const int disable_cdf_update_flag)
{
s->buf_pos = data;
s->buf_end = data + sz;
@@ -185,5 +188,6 @@
s->dif = ((ec_win)1 << (EC_WIN_SIZE - 1)) - 1;
s->rng = 0x8000;
s->cnt = -15;
+ s->allow_update_cdf = !disable_cdf_update_flag;
ctx_refill(s);
}
--- a/src/msac.h
+++ b/src/msac.h
@@ -40,12 +40,13 @@
ec_win dif;
uint16_t rng;
int cnt;
+ int allow_update_cdf;
} MsacContext;
#define EC_PROB_SHIFT 6
#define EC_BOOL_EPROB 256
-void msac_init(MsacContext *c, const uint8_t *data, size_t sz);
+void msac_init(MsacContext *c, const uint8_t *data, size_t sz, int disable_cdf_update_flag);
unsigned msac_decode_symbol(MsacContext *s, const uint16_t *cdf,
const unsigned n_symbols);
unsigned msac_decode_symbol_adapt(MsacContext *s, uint16_t *cdf,