[NORMATIVE] No loop restoration for lossless frame

Disable reading (and writing) these parameters from (and to) the bitstream.

BUG=aomedia:1428

Change-Id: I1d2142af3677cdcb34c212cfb54c6c342bc5897b
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index 1045338..2728e4e 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -1381,6 +1381,7 @@
 
 void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
                                        AV1_COMMON *cm) {
+  assert(!cm->all_lossless);
   const int num_planes = av1_num_planes(cm);
   typedef void (*copy_fun)(const YV12_BUFFER_CONFIG *src,
                            YV12_BUFFER_CONFIG *dst);
@@ -1549,6 +1550,8 @@
   if (bsize != cm->seq_params.sb_size) return 0;
   if (cm->rst_info[plane].frame_restoration_type == RESTORE_NONE) return 0;
 
+  assert(!cm->all_lossless);
+
   const int is_uv = plane > 0;
 
 // Which tile contains the superblock? Find that tile's top-left in mi-units,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index a5d0842..be50334 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -901,6 +901,7 @@
 
 static void decode_restoration_mode(AV1_COMMON *cm,
                                     struct aom_read_bit_buffer *rb) {
+  assert(!cm->all_lossless);
   const int num_planes = av1_num_planes(cm);
   if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
   int all_none = 1, chroma_none = 1;
@@ -1075,6 +1076,8 @@
   RestorationUnitInfo *rui = &rsi->unit_info[rtile_idx];
   if (rsi->frame_restoration_type == RESTORE_NONE) return;
 
+  assert(!cm->all_lossless);
+
   const int wiener_win = (plane > 0) ? WIENER_WIN_CHROMA : WIENER_WIN;
   WienerInfo *wiener_info = xd->wiener_info + plane;
   SgrprojInfo *sgrproj_info = xd->sgrproj_info + plane;
@@ -3180,10 +3183,17 @@
   }
   cm->all_lossless = all_lossless(cm, xd);
   setup_segmentation_dequant(cm);
-  if (!cm->all_lossless) {
+  if (cm->all_lossless) {
+    assert(cm->cdef_bits == 0 && cm->cdef_strengths[0] == 0 &&
+           cm->cdef_uv_strengths[0] == 0);
+    assert(cm->rst_info[0].frame_restoration_type == RESTORE_NONE &&
+           cm->rst_info[1].frame_restoration_type == RESTORE_NONE &&
+           cm->rst_info[2].frame_restoration_type == RESTORE_NONE);
+  } else {
     setup_cdef(cm, rb);
+    decode_restoration_mode(cm, rb);
   }
-  decode_restoration_mode(cm, rb);
+
   cm->tx_mode = read_tx_mode(cm, rb);
   cm->reference_mode = read_frame_reference_mode(cm, rb);
   if (cm->reference_mode != SINGLE_REFERENCE) setup_compound_reference_mode(cm);
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 931f30d..c9d4e39 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1906,6 +1906,7 @@
 
 static void encode_restoration_mode(AV1_COMMON *cm,
                                     struct aom_write_bit_buffer *wb) {
+  assert(!cm->all_lossless);
   if (cm->allow_intrabc && NO_FILTER_FOR_IBC) return;
   const int num_planes = av1_num_planes(cm);
   int all_none = 1, chroma_none = 1;
@@ -2072,6 +2073,8 @@
   RestorationType frame_rtype = rsi->frame_restoration_type;
   if (frame_rtype == RESTORE_NONE) return;
 
+  assert(!cm->all_lossless);
+
   const int wiener_win = (plane > 0) ? WIENER_WIN_CHROMA : WIENER_WIN;
   WienerInfo *wiener_info = xd->wiener_info + plane;
   SgrprojInfo *sgrproj_info = xd->sgrproj_info + plane;
@@ -3340,8 +3343,9 @@
   }
   if (!cm->all_lossless) {
     encode_cdef(cm, wb);
+    encode_restoration_mode(cm, wb);
   }
-  encode_restoration_mode(cm, wb);
+
   write_tx_mode(cm, &cm->tx_mode, wb);
 
   if (cpi->allow_comp_inter_inter) {