shithub: dav1d

Download patch

ref: e1fc687e1432e3e764c11712f3b5caba8b5dfcfe
parent: 0b7be94f2e7e5ac46351328734739f1b076712ac
author: Luc Trudeau <[email protected]>
date: Sat Sep 22 11:28:44 EDT 2018

Group delta_q and delta_lf into delta struct

--- a/src/decode.c
+++ b/src/decode.c
@@ -850,7 +850,7 @@
         !(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 @@
             }
             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,13 +879,13 @@
         // 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);
@@ -892,7 +892,7 @@
                 }
                 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)
--- a/src/levels.h
+++ b/src/levels.h
@@ -465,11 +465,17 @@
         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];
--- a/src/lf_mask.c
+++ b/src/lf_mask.c
@@ -390,13 +390,13 @@
         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);
     }
 }
--- a/src/obu.c
+++ b/src/obu.c
@@ -604,12 +604,12 @@
 #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);