mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
New cabac coding function: kvz_cabac_encode_trunc_bin
This commit is contained in:
parent
80d6e4bf05
commit
f3acd245ae
41
src/cabac.c
41
src/cabac.c
|
@ -76,6 +76,17 @@ const uint8_t kvz_g_auc_renorm_table[32] =
|
||||||
6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2,
|
6, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
const uint8_t kvz_tb_max[257] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
|
4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||||
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||||
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8 };
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialize struct cabac_data.
|
* \brief Initialize struct cabac_data.
|
||||||
|
@ -214,6 +225,36 @@ void kvz_cabac_encode_bin_trm(cabac_data_t * const data, const uint8_t bin_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief encode truncated binary code
|
||||||
|
*/
|
||||||
|
void kvz_cabac_encode_trunc_bin(cabac_data_t * const data, const uint32_t bin_value, const uint32_t max_value) {
|
||||||
|
int thresh;
|
||||||
|
int symbol = bin_value;
|
||||||
|
if (max_value > 256) {
|
||||||
|
int threshVal = 1 << 8;
|
||||||
|
thresh = 8;
|
||||||
|
while (threshVal <= max_value) {
|
||||||
|
thresh++;
|
||||||
|
threshVal <<= 1;
|
||||||
|
}
|
||||||
|
thresh--;
|
||||||
|
} else {
|
||||||
|
thresh = kvz_tb_max[max_value];
|
||||||
|
}
|
||||||
|
|
||||||
|
int val = 1 << thresh;
|
||||||
|
|
||||||
|
int b = max_value - val;
|
||||||
|
if (symbol < val - b) {
|
||||||
|
CABAC_BINS_EP(data, symbol, thresh, "TruncSymbols");
|
||||||
|
} else {
|
||||||
|
symbol += val - b;
|
||||||
|
CABAC_BINS_EP(data, symbol, thresh + 1, "TruncSymbols");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief
|
* \brief
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -104,6 +104,7 @@ extern const uint8_t kvz_g_auc_renorm_table[32];
|
||||||
void kvz_cabac_start(cabac_data_t *data);
|
void kvz_cabac_start(cabac_data_t *data);
|
||||||
void kvz_cabac_encode_bin(cabac_data_t *data, uint32_t bin_value);
|
void kvz_cabac_encode_bin(cabac_data_t *data, uint32_t bin_value);
|
||||||
void kvz_cabac_encode_bin_ep(cabac_data_t *data, uint32_t bin_value);
|
void kvz_cabac_encode_bin_ep(cabac_data_t *data, uint32_t bin_value);
|
||||||
|
void kvz_cabac_encode_trunc_bin(cabac_data_t *data, uint32_t bin_value, uint32_t max_value);
|
||||||
void kvz_cabac_encode_bins_ep(cabac_data_t *data, uint32_t bin_values, int num_bins);
|
void kvz_cabac_encode_bins_ep(cabac_data_t *data, uint32_t bin_values, int num_bins);
|
||||||
void kvz_cabac_encode_bin_trm(cabac_data_t *data, uint8_t bin_value);
|
void kvz_cabac_encode_bin_trm(cabac_data_t *data, uint8_t bin_value);
|
||||||
void kvz_cabac_write(cabac_data_t *data);
|
void kvz_cabac_write(cabac_data_t *data);
|
||||||
|
|
Loading…
Reference in a new issue