shithub: libvpx

Download patch

ref: cca347ed4e81eeed5b954f0ff11d12d21d20f9c4
parent: d1aeef94a510ffcef8411954697a9fd7e113572d
author: Dmitry Kovalev <[email protected]>
date: Thu Mar 6 13:58:17 EST 2014

Adding const to FIRSTPASS_STATS pointers.

Change-Id: Ia94d757de1d1b24609128cd40e68558078f50a38

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -95,7 +95,7 @@
 // Resets the first pass file to the given position using a relative seek from
 // the current position.
 static void reset_fpf_position(struct twopass_rc *p,
-                               FIRSTPASS_STATS *position) {
+                               const FIRSTPASS_STATS *position) {
   p->stats_in = position;
 }
 
@@ -903,7 +903,7 @@
 
 void vp9_init_second_pass(VP9_COMP *cpi) {
   FIRSTPASS_STATS this_frame;
-  FIRSTPASS_STATS *start_pos;
+  const FIRSTPASS_STATS *start_pos;
   struct twopass_rc *const twopass = &cpi->twopass;
   const VP9_CONFIG *const oxcf = &cpi->oxcf;
 
@@ -1011,7 +1011,7 @@
       loop_decay_rate >= 0.999 &&
       last_decay_rate < 0.9) {
     int j;
-    FIRSTPASS_STATS *position = cpi->twopass.stats_in;
+    const FIRSTPASS_STATS *position = cpi->twopass.stats_in;
     FIRSTPASS_STATS tmp_next_frame;
 
     // Look ahead a few frames to see if static condition persists...
@@ -1346,7 +1346,7 @@
 // Analyse and define a gf/arf group.
 static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
   FIRSTPASS_STATS next_frame = { 0 };
-  FIRSTPASS_STATS *start_pos;
+  const FIRSTPASS_STATS *start_pos;
   struct twopass_rc *const twopass = &cpi->twopass;
   int i;
   double boost_score = 0.0;
@@ -1793,19 +1793,12 @@
          ((next_frame->intra_error /
            DOUBLE_DIVIDE_CHECK(next_frame->coded_error)) > 3.5))))) {
     int i;
-    FIRSTPASS_STATS *start_pos;
-
-    FIRSTPASS_STATS local_next_frame;
-
+    const FIRSTPASS_STATS *start_pos = cpi->twopass.stats_in;
+    FIRSTPASS_STATS local_next_frame = *next_frame;
     double boost_score = 0.0;
     double old_boost_score = 0.0;
     double decay_accumulator = 1.0;
 
-    local_next_frame = *next_frame;
-
-    // Note the starting file position so we can reset to it.
-    start_pos = cpi->twopass.stats_in;
-
     // Examine how well the key frame predicts subsequent frames.
     for (i = 0; i < 16; ++i) {
       double next_iiratio = (IIKFACTOR1 * local_next_frame.intra_error /
@@ -1861,7 +1854,7 @@
   FIRSTPASS_STATS last_frame;
   FIRSTPASS_STATS first_frame;
   FIRSTPASS_STATS next_frame;
-  FIRSTPASS_STATS *start_position;
+  const FIRSTPASS_STATS *start_position;
 
   double decay_accumulator = 1.0;
   double zero_motion_accumulator = 1.0;
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -43,7 +43,9 @@
   unsigned int this_iiratio;
   FIRSTPASS_STATS total_stats;
   FIRSTPASS_STATS this_frame_stats;
-  FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
+  const FIRSTPASS_STATS *stats_in;
+  const FIRSTPASS_STATS *stats_in_start;
+  const FIRSTPASS_STATS *stats_in_end;
   FIRSTPASS_STATS total_left_stats;
   int first_pass_done;
   int64_t bits_left;
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -1879,13 +1879,12 @@
   if (cpi->pass == 1) {
     vp9_init_first_pass(cpi);
   } else if (cpi->pass == 2) {
-    size_t packet_sz = sizeof(FIRSTPASS_STATS);
-    int packets = (int)(oxcf->two_pass_stats_in.sz / packet_sz);
+    const size_t packet_sz = sizeof(FIRSTPASS_STATS);
+    const int packets = (int)(oxcf->two_pass_stats_in.sz / packet_sz);
 
     cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf;
     cpi->twopass.stats_in = cpi->twopass.stats_in_start;
-    cpi->twopass.stats_in_end = (void *)((char *)cpi->twopass.stats_in
-                                         + (packets - 1) * packet_sz);
+    cpi->twopass.stats_in_end = &cpi->twopass.stats_in[packets - 1];
     vp9_init_second_pass(cpi);
   }