mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 10:34:05 +00:00
Add guard against illegal SAO edge offsets.
This commit is contained in:
parent
22d21ffac2
commit
692ef3e9d9
|
@ -799,11 +799,14 @@ void encode_sao_color(encoder_control *encoder, sao_info *sao, color_index color
|
||||||
if (sao->type != SAO_TYPE_NONE) {
|
if (sao->type != SAO_TYPE_NONE) {
|
||||||
sao_eo_cat i;
|
sao_eo_cat i;
|
||||||
|
|
||||||
for (i = SAO_EO_CAT1; i <= SAO_EO_CAT4; ++i) {
|
// TR cMax=7 (for 8bit), cRiseParam=0
|
||||||
//CABAC_BIN_EP(&cabac, abs(sao->offsets[i]), "sao_offset_abs");
|
for (i = SAO_EO_CAT1; i <= SAO_EO_CAT2; ++i) {
|
||||||
// TR cMax=7 (for 8bit), cRiseParam=0
|
assert(sao->offsets[i] >= 0);
|
||||||
cabac_write_unary_max_symbol_ep(&cabac, abs(sao->offsets[i]),
|
cabac_write_unary_max_symbol_ep(&cabac, sao->offsets[i], SAO_ABS_OFFSET_MAX);
|
||||||
SAO_ABS_OFFSET_MAX);
|
}
|
||||||
|
for (i = SAO_EO_CAT3; i <= SAO_EO_CAT4; ++i) {
|
||||||
|
assert(sao->offsets[i] <= 0);
|
||||||
|
cabac_write_unary_max_symbol_ep(&cabac, -sao->offsets[i], SAO_ABS_OFFSET_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sao->type == SAO_TYPE_BAND) {
|
if (sao->type == SAO_TYPE_BAND) {
|
||||||
|
|
|
@ -249,6 +249,15 @@ void sao_search_best_mode(const pixel *data, const pixel *recdata,
|
||||||
offset = (cat_sum + (cat_cnt >> 1)) / cat_cnt;
|
offset = (cat_sum + (cat_cnt >> 1)) / cat_cnt;
|
||||||
offset = CLIP(-SAO_ABS_OFFSET_MAX, SAO_ABS_OFFSET_MAX, offset);
|
offset = CLIP(-SAO_ABS_OFFSET_MAX, SAO_ABS_OFFSET_MAX, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sharpening edge offsets can't be encoded, so set them to 0 here.
|
||||||
|
if (edge_cat >= SAO_EO_CAT1 && edge_cat <= SAO_EO_CAT2 && offset < 0) {
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
if (edge_cat >= SAO_EO_CAT3 && edge_cat <= SAO_EO_CAT4 && offset > 0) {
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
edge_offset[edge_cat] = offset;
|
edge_offset[edge_cat] = offset;
|
||||||
// The ddistortion is amount by which the SSE of data changes. It should
|
// The ddistortion is amount by which the SSE of data changes. It should
|
||||||
// be negative for all categories, if offset was chosen correctly.
|
// be negative for all categories, if offset was chosen correctly.
|
||||||
|
|
Loading…
Reference in a new issue