Commit e1fc687e authored by Luc Trudeau's avatar Luc Trudeau

Group delta_q and delta_lf into delta struct

parent 0b7be94f
......@@ -850,7 +850,7 @@ static void decode_b(Dav1dTileContext *const t,
!(t->by & (31 >> !f->seq_hdr.sb128)))
{
const int prev_qidx = ts->last_qidx;
const int have_delta_q = f->frame_hdr.delta_q_present &&
const int have_delta_q = f->frame_hdr.delta.q.present &&
(bs != (f->seq_hdr.sb128 ? BS_128x128 : BS_64x64) || !b->skip);
if (have_delta_q) {
int delta_q = msac_decode_symbol_adapt(&ts->msac, ts->cdf.m.delta_q, 4);
......@@ -860,7 +860,7 @@ static void decode_b(Dav1dTileContext *const t,
}
if (delta_q) {
if (msac_decode_bool(&ts->msac, 128 << 7)) delta_q = -delta_q;
delta_q *= 1 << f->frame_hdr.delta_q_res_log2;
delta_q *= 1 << f->frame_hdr.delta.q.res_log2;
}
ts->last_qidx = iclip(ts->last_qidx + delta_q, 1, 255);
if (have_delta_q && DEBUG_BLOCK_INFO)
......@@ -879,20 +879,20 @@ static void decode_b(Dav1dTileContext *const t,
// delta_lf
int8_t prev_delta_lf[4];
memcpy(prev_delta_lf, ts->last_delta_lf, 4);
if (have_delta_q && f->frame_hdr.delta_lf_present) {
const int n_lfs = f->frame_hdr.delta_lf_multi ?
if (have_delta_q && f->frame_hdr.delta.lf.present) {
const int n_lfs = f->frame_hdr.delta.lf.multi ?
f->seq_hdr.layout != DAV1D_PIXEL_LAYOUT_I400 ? 4 : 2 : 1;
for (int i = 0; i < n_lfs; i++) {
int delta_lf = msac_decode_symbol_adapt(&ts->msac,
ts->cdf.m.delta_lf[i + f->frame_hdr.delta_lf_multi], 4);
ts->cdf.m.delta_lf[i + f->frame_hdr.delta.lf.multi], 4);
if (delta_lf == 3) {
const int n_bits = 1 + msac_decode_bools(&ts->msac, 3);
delta_lf = msac_decode_bools(&ts->msac, n_bits) + 1 + (1 << n_bits);
}
if (delta_lf) {
if (msac_decode_bool(&ts->msac, 128 << 7)) delta_lf = -delta_lf;
delta_lf *= 1 << f->frame_hdr.delta_lf_res_log2;
delta_lf *= 1 << f->frame_hdr.delta.lf.res_log2;
}
ts->last_delta_lf[i] = iclip(ts->last_delta_lf[i] + delta_lf, -63, 63);
if (have_delta_q && DEBUG_BLOCK_INFO)
......
......@@ -465,11 +465,17 @@ typedef struct Av1FrameHeader {
Av1SegmentationDataSet seg_data;
int lossless[NUM_SEGMENTS], qidx[NUM_SEGMENTS];
} segmentation;
int delta_q_present;
int delta_q_res_log2;
int delta_lf_present;
int delta_lf_res_log2;
int delta_lf_multi;
struct {
struct {
int present;
int res_log2;
} q;
struct {
int present;
int res_log2;
int multi;
} lf;
} delta;
int all_lossless;
struct {
int level_y[2];
......
......@@ -390,13 +390,13 @@ void dav1d_calc_lf_values(uint8_t (*const lflvl_values)[4][8][2],
dav1d_calc_lf_value(lflvl_values[s][0], 0, hdr->loopfilter.level_y[0],
lf_delta[0], segd ? segd->delta_lf_y_v : 0, mr_deltas);
dav1d_calc_lf_value(lflvl_values[s][1], 0, hdr->loopfilter.level_y[1],
lf_delta[hdr->delta_lf_multi ? 1 : 0],
lf_delta[hdr->delta.lf.multi ? 1 : 0],
segd ? segd->delta_lf_y_h : 0, mr_deltas);
dav1d_calc_lf_value(lflvl_values[s][2], 1, hdr->loopfilter.level_u,
lf_delta[hdr->delta_lf_multi ? 2 : 0],
lf_delta[hdr->delta.lf.multi ? 2 : 0],
segd ? segd->delta_lf_u : 0, mr_deltas);
dav1d_calc_lf_value(lflvl_values[s][3], 1, hdr->loopfilter.level_v,
lf_delta[hdr->delta_lf_multi ? 3 : 0],
lf_delta[hdr->delta.lf.multi ? 3 : 0],
segd ? segd->delta_lf_v : 0, mr_deltas);
}
}
......@@ -604,12 +604,12 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
#endif
// delta q
hdr->delta_q_present = hdr->quant.yac ? get_bits(gb, 1) : 0;
hdr->delta_q_res_log2 = hdr->delta_q_present ? get_bits(gb, 2) : 0;
hdr->delta_lf_present = hdr->delta_q_present && !hdr->allow_intrabc &&
hdr->delta.q.present = hdr->quant.yac ? get_bits(gb, 1) : 0;
hdr->delta.q.res_log2 = hdr->delta.q.present ? get_bits(gb, 2) : 0;
hdr->delta.lf.present = hdr->delta.q.present && !hdr->allow_intrabc &&
get_bits(gb, 1);
hdr->delta_lf_res_log2 = hdr->delta_lf_present ? get_bits(gb, 2) : 0;
hdr->delta_lf_multi = hdr->delta_lf_present ? get_bits(gb, 1) : 0;
hdr->delta.lf.res_log2 = hdr->delta.lf.present ? get_bits(gb, 2) : 0;
hdr->delta.lf.multi = hdr->delta.lf.present ? get_bits(gb, 1) : 0;
#if DEBUG_FRAME_HDR
printf("HDR: post-delta_q_lf_flags: off=%ld\n",
(gb->ptr - init_ptr) * 8 - gb->bits_left);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment