shithub: dav1d

Download patch

ref: 80e1d0cd23b1a7fb1901e12478caf029f316ba11
parent: 8a19ee0e5644a7f204c18823c93b1b2797676b5b
author: Martin Storsjö <[email protected]>
date: Mon Feb 4 10:46:10 EST 2019

cdef: Add a CDEF_ prefix to the HAVE_LEFT etc enum values

This reduces potential ambiguity across the codebase, as the enum
is CDEF specific, and there is another similar enum for loop restoration.

Alternatively an independent enum could be used for both CDEF and loop
restoration.

--- a/src/cdef.h
+++ b/src/cdef.h
@@ -34,10 +34,10 @@
 #include "common/bitdepth.h"
 
 enum CdefEdgeFlags {
-    HAVE_LEFT = 1 << 0,
-    HAVE_RIGHT = 1 << 1,
-    HAVE_TOP = 1 << 2,
-    HAVE_BOTTOM = 1 << 3,
+    CDEF_HAVE_LEFT = 1 << 0,
+    CDEF_HAVE_RIGHT = 1 << 1,
+    CDEF_HAVE_TOP = 1 << 2,
+    CDEF_HAVE_BOTTOM = 1 << 3,
 };
 
 #ifdef BITDEPTH
--- a/src/cdef_apply_tmpl.c
+++ b/src/cdef_apply_tmpl.c
@@ -85,7 +85,7 @@
 {
     const int bitdepth_min_8 = BITDEPTH == 8 ? 0 : f->cur.p.bpc - 8;
     const Dav1dDSPContext *const dsp = f->dsp;
-    enum CdefEdgeFlags edges = HAVE_BOTTOM | (by_start > 0 ? HAVE_TOP : 0);
+    enum CdefEdgeFlags edges = CDEF_HAVE_BOTTOM | (by_start > 0 ? CDEF_HAVE_TOP : 0);
     pixel *ptrs[3] = { p[0], p[1], p[2] };
     const int sbsz = 16;
     const int sb64w = f->sb128w << 1;
@@ -101,11 +101,11 @@
     // the backup of pre-filter data is empty, and the restore is therefore
     // unnecessary as well.
 
-    for (int bit = 0, by = by_start; by < by_end; by += 2, edges |= HAVE_TOP) {
+    for (int bit = 0, by = by_start; by < by_end; by += 2, edges |= CDEF_HAVE_TOP) {
         const int tf = f->lf.top_pre_cdef_toggle;
-        if (by + 2 >= f->bh) edges &= ~HAVE_BOTTOM;
+        if (by + 2 >= f->bh) edges &= ~CDEF_HAVE_BOTTOM;
 
-        if (edges & HAVE_BOTTOM) {
+        if (edges & CDEF_HAVE_BOTTOM) {
             // backup pre-filter data for next iteration
             backup2lines(f->lf.cdef_line_ptr[!tf], ptrs, f->cur.stride,
                          8, f->bw * 4, layout);
@@ -113,9 +113,9 @@
 
         pixel lr_bak[2 /* idx */][3 /* plane */][8 /* y */][2 /* x */];
         pixel *iptrs[3] = { ptrs[0], ptrs[1], ptrs[2] };
-        edges &= ~HAVE_LEFT;
-        edges |= HAVE_RIGHT;
-        for (int sbx = 0, last_skip = 1; sbx < sb64w; sbx++, edges |= HAVE_LEFT) {
+        edges &= ~CDEF_HAVE_LEFT;
+        edges |= CDEF_HAVE_RIGHT;
+        for (int sbx = 0, last_skip = 1; sbx < sb64w; sbx++, edges |= CDEF_HAVE_LEFT) {
             const int sb128x = sbx >>1;
             const int sb64_idx = ((by & sbsz) >> 3) + (sbx & 1);
             const int cdef_idx = lflvl[sb128x].cdef_idx[sb64_idx];
@@ -131,9 +131,9 @@
             const int uv_lvl = f->frame_hdr->cdef.uv_strength[cdef_idx];
             pixel *bptrs[3] = { iptrs[0], iptrs[1], iptrs[2] };
             for (int bx = sbx * sbsz; bx < imin((sbx + 1) * sbsz, f->bw);
-                 bx += 2, edges |= HAVE_LEFT)
+                 bx += 2, edges |= CDEF_HAVE_LEFT)
             {
-                if (bx + 2 >= f->bw) edges &= ~HAVE_RIGHT;
+                if (bx + 2 >= f->bw) edges &= ~CDEF_HAVE_RIGHT;
 
                 // check if this 8x8 block had any coded coefficients; if not,
                 // go to the next block
@@ -146,12 +146,12 @@
                     goto next_b;
                 }
 
-                if (last_skip && edges & HAVE_LEFT) {
+                if (last_skip && edges & CDEF_HAVE_LEFT) {
                     // we didn't backup the prefilter data because it wasn't
                     // there, so do it here instead
                     backup2x8(lr_bak[bit], bptrs, f->cur.stride, 0, layout);
                 }
-                if (edges & HAVE_RIGHT) {
+                if (edges & CDEF_HAVE_RIGHT) {
                     // backup pre-filter data for next iteration
                     backup2x8(lr_bak[!bit], bptrs, f->cur.stride, 8, layout);
                 }
--- a/src/cdef_tmpl.c
+++ b/src/cdef_tmpl.c
@@ -61,19 +61,19 @@
 {
     // fill extended input buffer
     int x_start = -2, x_end = w + 2, y_start = -2, y_end = h + 2;
-    if (!(edges & HAVE_TOP)) {
+    if (!(edges & CDEF_HAVE_TOP)) {
         fill(tmp - 2 - 2 * tmp_stride, tmp_stride, w + 4, 2);
         y_start = 0;
     }
-    if (!(edges & HAVE_BOTTOM)) {
+    if (!(edges & CDEF_HAVE_BOTTOM)) {
         fill(tmp + h * tmp_stride - 2, tmp_stride, w + 4, 2);
         y_end -= 2;
     }
-    if (!(edges & HAVE_LEFT)) {
+    if (!(edges & CDEF_HAVE_LEFT)) {
         fill(tmp + y_start * tmp_stride - 2, tmp_stride, 2, y_end - y_start);
         x_start = 0;
     }
-    if (!(edges & HAVE_RIGHT)) {
+    if (!(edges & CDEF_HAVE_RIGHT)) {
         fill(tmp + y_start * tmp_stride + w, tmp_stride, 2, y_end - y_start);
         x_end -= 2;
     }