Disable CDEF signaling when all segments are lossless.

This required moving the CDEF and lr signaling in the
uncompressed header to after segmentation is signaled.

The all_lossless logic was factored out into onyxc_int.h.

Change-Id: If8de03438d4e9f8cb49ed49b60a880962cc9d28b
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index f913328..6133edf 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -323,7 +323,7 @@
 
   struct loopfilter lf;
   struct segmentation seg;
-
+  int all_lossless;
   int frame_parallel_decode;  // frame-based threading.
 
 #if CONFIG_EXT_TX
@@ -1085,6 +1085,22 @@
 #endif
 }
 
+static INLINE int all_lossless(const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  int i;
+  int all_lossless = 1;
+  if (cm->seg.enabled) {
+    for (i = 0; i < MAX_SEGMENTS; ++i) {
+      if (!xd->lossless[i]) {
+        all_lossless = 0;
+        break;
+      }
+    }
+  } else {
+    all_lossless = xd->lossless[0];
+  }
+  return all_lossless;
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif