ref: df5230ef7656899f28e21792b0f903a4af4ee3ff
parent: 5698bc91b692dbcc2e92c2990c5a2d841cfbea1d
author: Niklas Haas <[email protected]>
date: Sat Oct 27 20:45:26 EDT 2018
obu: parse uv_mult etc. as signed integers The spec subtracts the signed offset from all of these when using them, like it does for e.g. ar_coeffs_y_plus_128, although for some reason the naming scheme is inconsistent here. Either way, it makes more sense to treat them as signed integers than unsigned integers. To avoid confusion since the name of the field is the same as the one in the spec, we mark the type as int8_t (resp. int16_t for the 9-bit field) to make it clear to the user that these are already signed integers.
--- a/src/levels.h
+++ b/src/levels.h
@@ -403,9 +403,9 @@
int8_t ar_coeffs_uv[2][25];
int ar_coeff_shift;
int grain_scale_shift;
- int uv_mult[2];
- int uv_luma_mult[2];
- int uv_offset[2];
+ int8_t uv_mult[2];
+ int8_t uv_luma_mult[2];
+ int16_t uv_offset[2];
int overlap_flag;
int clip_to_restricted_range;
} Av1FilmGrainData;
--- a/src/obu.c
+++ b/src/obu.c
@@ -1070,9 +1070,9 @@
fgd->grain_scale_shift = dav1d_get_bits(gb, 2);
for (int pl = 0; pl < 2; pl++)
if (fgd->num_uv_points[pl]) {
- fgd->uv_mult[pl] = dav1d_get_bits(gb, 8);
- fgd->uv_luma_mult[pl] = dav1d_get_bits(gb, 8);
- fgd->uv_offset[pl] = dav1d_get_bits(gb, 9);
+ fgd->uv_mult[pl] = dav1d_get_bits(gb, 8) - 128;
+ fgd->uv_luma_mult[pl] = dav1d_get_bits(gb, 8) - 128;
+ fgd->uv_offset[pl] = dav1d_get_bits(gb, 9) - 256;
}
fgd->overlap_flag = dav1d_get_bits(gb, 1);
fgd->clip_to_restricted_range = dav1d_get_bits(gb, 1);