Move eob/lossless check into av1_optimize_b

This will guarantee that av1_optimize_b will be turned off when
lossless mode is on

Remove heuristic lossless check in optimize_b_greedy

Change-Id: I636c776f3f6b632eb03bc57a470ea43aae4fe0f6
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index e4d27b0..cbe6402 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1542,8 +1542,7 @@
   const int coeff_ctx = combine_entropy_contexts(*a, *l);
   av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
                   coeff_ctx, AV1_XFORM_QUANT_FP);
-  if (x->plane[plane].eobs[block] && !xd->lossless[mbmi->segment_id])
-    av1_optimize_b(cm, x, plane, block, tx_size, coeff_ctx);
+  av1_optimize_b(cm, x, plane, block, tx_size, coeff_ctx);
 
   if (!is_inter_block(mbmi)) {
     struct macroblock_plane *const p = &x->plane[plane];
@@ -2897,9 +2896,7 @@
 #endif  // CONFIG_CB4X4
                         BLOCK_8X8, tx_size, coeff_ctx, xform_quant);
 
-        if (!is_lossless) {
-          av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
-        }
+        av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
 
         ratey +=
             av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order, tempa + idx,
@@ -5206,8 +5203,7 @@
       coeff_ctx = combine_entropy_contexts(*(ta + (k & 1)), *(tl + (k >> 1)));
       av1_xform_quant(cm, x, 0, block, idy + (i >> 1), idx + (i & 0x01),
                       BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
-      if (xd->lossless[xd->mi[0]->mbmi.segment_id] == 0)
-        av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
+      av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
       av1_dist_block(cpi, x, 0, BLOCK_8X8, block, idy + (i >> 1),
                      idx + (i & 0x1), tx_size, &dist, &ssz,
                      OUTPUT_HAS_PREDICTED_PIXELS);
@@ -6569,8 +6565,7 @@
             dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
             av1_xform_quant(cm, x, 0, block, idy + idy_, idx + idx_, BLOCK_8X8,
                             tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
-            if (xd->lossless[xd->mi[0]->mbmi.segment_id] == 0)
-              av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
+            av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
 
             eob = p->eobs[block];
             av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size,