shithub: libvpx

Download patch

ref: 812fbc5ecb014b8f3f4b95a23144821edc2a2eab
parent: cd9ae6d7582579d7a644b1bf9b7037d66c49dc3b
parent: 62da0bf162f369cd99f2ffe37e4cb21810422e37
author: Ronald S. Bultje <[email protected]>
date: Fri Sep 11 18:36:49 EDT 2015

Merge "Make reset_frame_context an enum."

--- a/vp10/common/entropymode.c
+++ b/vp10/common/entropymode.c
@@ -448,12 +448,12 @@
   vp10_init_mv_probs(cm);
   cm->fc->initialized = 1;
 
-  if (cm->frame_type == KEY_FRAME ||
-      cm->error_resilient_mode || cm->reset_frame_context == 3) {
+  if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
+      cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
     // Reset all frame contexts.
     for (i = 0; i < FRAME_CONTEXTS; ++i)
       cm->frame_contexts[i] = *cm->fc;
-  } else if (cm->reset_frame_context == 2) {
+  } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
     // Reset only the frame context specified in the frame header.
     cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
   }
--- a/vp10/common/onyxc_int.h
+++ b/vp10/common/onyxc_int.h
@@ -57,6 +57,12 @@
   REFERENCE_MODES       = 3,
 } REFERENCE_MODE;
 
+typedef enum {
+  RESET_FRAME_CONTEXT_NONE = 0,
+  RESET_FRAME_CONTEXT_CURRENT = 1,
+  RESET_FRAME_CONTEXT_ALL = 2,
+} RESET_FRAME_CONTEXT_MODE;
+
 typedef struct {
   int_mv mv[2];
   MV_REFERENCE_FRAME ref_frame[2];
@@ -161,10 +167,8 @@
 
   int allow_high_precision_mv;
 
-  // Flag signaling that the frame context should be reset to default values.
-  // 0 or 1 implies don't reset, 2 reset just the context specified in the
-  // frame header, 3 reset all contexts.
-  int reset_frame_context;
+  // Flag signaling which frame contexts should be reset to default values.
+  RESET_FRAME_CONTEXT_MODE reset_frame_context;
 
   // MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
   // MODE_INFO (8-pixel) units.
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -1849,8 +1849,33 @@
   } else {
     cm->intra_only = cm->show_frame ? 0 : vpx_rb_read_bit(rb);
 
-    cm->reset_frame_context = cm->error_resilient_mode ?
-        0 : vpx_rb_read_literal(rb, 2);
+    if (cm->error_resilient_mode) {
+        cm->reset_frame_context = RESET_FRAME_CONTEXT_ALL;
+    } else {
+#if CONFIG_MISC_FIXES
+      if (cm->intra_only) {
+          cm->reset_frame_context =
+              vpx_rb_read_bit(rb) ? RESET_FRAME_CONTEXT_ALL
+                                  : RESET_FRAME_CONTEXT_CURRENT;
+      } else {
+          cm->reset_frame_context =
+              vpx_rb_read_bit(rb) ? RESET_FRAME_CONTEXT_CURRENT
+                                  : RESET_FRAME_CONTEXT_NONE;
+          if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT)
+            cm->reset_frame_context =
+                  vpx_rb_read_bit(rb) ? RESET_FRAME_CONTEXT_ALL
+                                      : RESET_FRAME_CONTEXT_CURRENT;
+      }
+#else
+      static const RESET_FRAME_CONTEXT_MODE reset_frame_context_conv_tbl[4] = {
+        RESET_FRAME_CONTEXT_NONE, RESET_FRAME_CONTEXT_NONE,
+        RESET_FRAME_CONTEXT_CURRENT, RESET_FRAME_CONTEXT_ALL
+      };
+
+      cm->reset_frame_context =
+          reset_frame_context_conv_tbl[vpx_rb_read_literal(rb, 2)];
+#endif
+    }
 
     if (cm->intra_only) {
       if (!vp10_read_sync_code(rb))
--- a/vp10/encoder/bitstream.c
+++ b/vp10/encoder/bitstream.c
@@ -1092,8 +1092,25 @@
     if (!cm->show_frame)
       vpx_wb_write_bit(wb, cm->intra_only);
 
-    if (!cm->error_resilient_mode)
-      vpx_wb_write_literal(wb, cm->reset_frame_context, 2);
+    if (!cm->error_resilient_mode) {
+#if CONFIG_MISC_FIXES
+      if (cm->intra_only) {
+        vpx_wb_write_bit(wb,
+                         cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL);
+      } else {
+        vpx_wb_write_bit(wb,
+                         cm->reset_frame_context != RESET_FRAME_CONTEXT_NONE);
+        if (cm->reset_frame_context != RESET_FRAME_CONTEXT_NONE)
+          vpx_wb_write_bit(wb,
+                           cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL);
+      }
+#else
+      static const int reset_frame_context_conv_tbl[3] = { 0, 2, 3 };
+
+      vpx_wb_write_literal(wb,
+          reset_frame_context_conv_tbl[cm->reset_frame_context], 2);
+#endif
+    }
 
     if (cm->intra_only) {
       write_sync_code(wb);
--- a/vp10/encoder/encoder.c
+++ b/vp10/encoder/encoder.c
@@ -1422,7 +1422,7 @@
   cpi->refresh_golden_frame = 0;
   cpi->refresh_last_frame = 1;
   cm->refresh_frame_context = 1;
-  cm->reset_frame_context = 0;
+  cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
 
   vp10_reset_segment_features(&cm->seg);
   vp10_set_high_precision_mv(cpi, 0);
@@ -3554,11 +3554,11 @@
     // By default, encoder assumes decoder can use prev_mi.
     if (cm->error_resilient_mode) {
       cm->frame_parallel_decoding_mode = 1;
-      cm->reset_frame_context = 0;
+      cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
       cm->refresh_frame_context = 0;
     } else if (cm->intra_only) {
       // Only reset the current context.
-      cm->reset_frame_context = 2;
+      cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT;
     }
   }
 
@@ -3955,7 +3955,7 @@
     cpi->multi_arf_allowed = 0;
 
   // Normal defaults
-  cm->reset_frame_context = 0;
+  cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
   cm->refresh_frame_context = 1;
 
   cpi->refresh_last_frame = 1;