Refine rate estimate in trellis

Take into account cutoff parameter to switch between sets of contexts
for rate estimation in arithmetic coding version of trellis quantization
This commit is contained in:
Frank Bossen
2014-12-21 10:38:50 +01:00
parent 4802ddd7f7
commit 888d4075ee
3 changed files with 5 additions and 1 deletions

View File

@@ -940,6 +940,9 @@ jget_arith_rates (j_compress_ptr cinfo, int dc_tbl_no, int ac_tbl_no, arith_rate
{
int i;
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
r->arith_ac_K = cinfo->arith_ac_K[ac_tbl_no];
for (i = 0; i < DC_STAT_BINS; i++) {
int state = entropy->dc_stats[dc_tbl_no][i];
int mps_val = state >> 7;

View File

@@ -1520,7 +1520,7 @@ quantize_trellis_arith(j_compress_ptr cinfo, arith_rates *r, JBLOCKROW coef_bloc
if (v2 >>= 1) {
coef_bits += r->rate_ac[st][1];
m <<= 1;
st = 189; /* TODO: condition 189/217 */
st = (i <= r->arith_ac_K) ? 189 : 217;
while (v2 >>= 1) {
coef_bits += r->rate_ac[st][1];
m <<= 1;

View File

@@ -110,6 +110,7 @@ struct jpeg_comp_master {
typedef struct {
float rate_dc[DC_STAT_BINS][2];
float rate_ac[AC_STAT_BINS][2];
int arith_ac_K;
} arith_rates;
/* Main buffer control (downsampled-data buffer) */