rtc: Fix to lossless mode for nonrd (speed >= 7).

Add a check at the end of pickmode to force the
skip flags off for lossless encoding.

Re-enable the lossless_test for speed 7-10.
Bug:aomedia:3412

Change-Id: Id24438b26f464aac40f3d4cf0535217a0eac95e6
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 10a5823..a412d32 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -3321,16 +3321,22 @@
   mi->mode = best_pickmode->best_mode;
   mi->ref_frame[0] = best_pickmode->best_ref_frame;
   mi->ref_frame[1] = best_pickmode->best_second_ref_frame;
-  txfm_info->skip_txfm = best_pickmode->best_mode_skip_txfm;
-  if (!txfm_info->skip_txfm) {
-    // For inter modes: copy blk_skip from best_pickmode.
-    // If palette or intra mode was selected as best then
-    // blk_skip is already copied into the ctx.
-    // TODO(marpan): Look into removing blk_skip from best_pickmode
-    // and just copy directly into the ctx for inter.
-    if (best_pickmode->best_mode >= INTRA_MODE_END)
-      memcpy(ctx->blk_skip, best_pickmode->blk_skip,
-             sizeof(best_pickmode->blk_skip[0]) * ctx->num_4x4_blk);
+  // For lossless/Q=0: always force the skip flags off.
+  if (cm->quant_params.base_qindex == 0) {
+    txfm_info->skip_txfm = 0;
+    memset(ctx->blk_skip, 0, sizeof(ctx->blk_skip[0]) * ctx->num_4x4_blk);
+  } else {
+    txfm_info->skip_txfm = best_pickmode->best_mode_skip_txfm;
+    if (!txfm_info->skip_txfm) {
+      // For inter modes: copy blk_skip from best_pickmode.
+      // If palette or intra mode was selected as best then
+      // blk_skip is already copied into the ctx.
+      // TODO(marpan): Look into removing blk_skip from best_pickmode
+      // and just copy directly into the ctx for inter.
+      if (best_pickmode->best_mode >= INTRA_MODE_END)
+        memcpy(ctx->blk_skip, best_pickmode->blk_skip,
+               sizeof(best_pickmode->blk_skip[0]) * ctx->num_4x4_blk);
+    }
   }
   if (has_second_ref(mi)) {
     mi->comp_group_idx = 0;
diff --git a/test/lossless_test.cc b/test/lossless_test.cc
index c224ab3..d4eab51 100644
--- a/test/lossless_test.cc
+++ b/test/lossless_test.cc
@@ -186,21 +186,6 @@
   TestLosslessEncodingCtrl();
 }
 
-// TODO(aomedia:3412): remove this after lossless mode is fixed.
-using DISABLED_LosslessRealtimeTestLarge = LosslessTestLarge;
-
-TEST_P(DISABLED_LosslessRealtimeTestLarge, TestLosslessEncoding) {
-  TestLosslessEncoding();
-}
-
-TEST_P(DISABLED_LosslessRealtimeTestLarge, TestLosslessEncoding444) {
-  TestLosslessEncoding444();
-}
-
-TEST_P(DISABLED_LosslessRealtimeTestLarge, TestLosslessEncodingCtrl) {
-  TestLosslessEncodingCtrl();
-}
-
 AV1_INSTANTIATE_TEST_SUITE(LosslessTestLarge,
                            ::testing::Values(::libaom_test::kOnePassGood,
                                              ::libaom_test::kTwoPassGood),
@@ -215,13 +200,5 @@
 AV1_INSTANTIATE_TEST_SUITE(LosslessRealtimeTestLarge,
                            ::testing::Values(::libaom_test::kRealTime),
                            ::testing::Values(AOM_Q, AOM_VBR, AOM_CBR, AOM_CQ),
-                           ::testing::Values(6));  // cpu_used
-
-// TODO(aomedia:3412): merge this to LosslessRealtimeTestLarge after lossless
-// mode is fixed for these speed settings.
-AV1_INSTANTIATE_TEST_SUITE(DISABLED_LosslessRealtimeTestLarge,
-                           ::testing::Values(::libaom_test::kRealTime),
-                           ::testing::Values(AOM_Q, AOM_VBR, AOM_CBR, AOM_CQ),
-                           ::testing::Range(7, 11));  // cpu_used
-
+                           ::testing::Range(6, 11));  // cpu_used
 }  // namespace