Clean up AOM_EFLAG_FREEZE_INTERNAL_STATE

Document that AOM_EFLAG_FREEZE_INTERNAL_STATE requires g_lag_in_frames
to be zero.

Set ppi->b_freeze_internal_state after validating that
AOM_EFLAG_FREEZE_INTERNAL_STATE is set with a zero g_lag_in_frames.

Ensure ppi->b_freeze_internal_state is set to 1 (rather than just a
nonzero value) when AOM_EFLAG_FREEZE_INTERNAL_STATE is set.

Change-Id: I401b96238aa7de436702eabc5a3072b35186cfa9
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h
index fa5117a..7c7579c 100644
--- a/aom/aom_encoder.h
+++ b/aom/aom_encoder.h
@@ -380,7 +380,7 @@
 /*!\brief Calculate PSNR for this frame, requires g_lag_in_frames to be 0 */
 #define AOM_EFLAG_CALCULATE_PSNR (1 << 1)
 /*!\brief Freeze internal state, do not update reference buffers, entropy
- * tables, rate control state, etc. */
+ * tables, rate control state, etc. Requires g_lag_in_frames to be 0. */
 #define AOM_EFLAG_FREEZE_INTERNAL_STATE (1 << 2)
 
 /*!\brief Encoder configuration structure
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 324cecb..e33e73d 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -3366,8 +3366,6 @@
   if (ppi->use_svc && ppi->cpi->svc.use_flexible_mode == 0 && flags == 0)
     av1_set_svc_fixed_mode(ppi->cpi);
 
-  ppi->b_freeze_internal_state = flags & AOM_EFLAG_FREEZE_INTERNAL_STATE;
-
   // Note(yunqing): While applying encoding flags, always start from enabling
   // all, and then modifying according to the flags. Previous frame's flags are
   // overwritten.
@@ -3424,6 +3422,9 @@
                             (flags & AOM_EFLAG_CALCULATE_PSNR);
 #endif  // CONFIG_INTERNAL_STATS
 
+    ppi->b_freeze_internal_state =
+        (flags & AOM_EFLAG_FREEZE_INTERNAL_STATE) != 0;
+
     if (img != NULL) {
       if (!ctx->pts_offset_initialized) {
         ctx->pts_offset = ptsvol;