]> granicus.if.org Git - libvpx/commitdiff
Fixed a bug of setting wrong first pass mb stats pointer
authorPengchong Jin <pengchong@google.com>
Thu, 17 Jul 2014 18:54:43 +0000 (11:54 -0700)
committerPengchong Jin <pengchong@google.com>
Thu, 17 Jul 2014 19:04:15 +0000 (12:04 -0700)
The bug sets the wrong pointer to the first pass mb stats
if the encoder does the re-coding in the second pass.

Change-Id: I8a11f45dd7dceb38de814adec24cecccae370d00

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_firstpass.h

index 7ba7cae72b4546fdc625a882028c168b5f7daed9..adc65533224b06fbe4ba21f6cf0f88d3ea597ad5 100644 (file)
@@ -3034,6 +3034,21 @@ static void encode_tiles(VP9_COMP *cpi) {
   }
 }
 
+#if CONFIG_FP_MB_STATS
+static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats,
+                            VP9_COMMON *cm, uint8_t **this_frame_mb_stats) {
+  uint8_t *mb_stats_in = firstpass_mb_stats->mb_stats_start +
+      cm->current_video_frame * cm->MBs * sizeof(uint8_t);
+
+  if (mb_stats_in > firstpass_mb_stats->mb_stats_end)
+    return EOF;
+
+  *this_frame_mb_stats = mb_stats_in;
+
+  return 1;
+}
+#endif
+
 static void encode_frame_internal(VP9_COMP *cpi) {
   SPEED_FEATURES *const sf = &cpi->sf;
   RD_OPT *const rd_opt = &cpi->rd;
@@ -3101,6 +3116,13 @@ static void encode_frame_internal(VP9_COMP *cpi) {
     struct vpx_usec_timer emr_timer;
     vpx_usec_timer_start(&emr_timer);
 
+#if CONFIG_FP_MB_STATS
+  if (cpi->use_fp_mb_stats) {
+    input_fpmb_stats(&cpi->twopass.firstpass_mb_stats, cm,
+                     &cpi->twopass.this_frame_mb_stats);
+  }
+#endif
+
     encode_tiles(cpi);
 
     vpx_usec_timer_mark(&emr_timer);
index 04d5181789f675d69c08eea5bb43c542131b8ba6..f40cc56eb4d4f744252d85203cf83271d7a028d0 100644 (file)
@@ -940,8 +940,6 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf) {
 
         cpi->twopass.firstpass_mb_stats.mb_stats_start =
             oxcf->firstpass_mb_stats_in.buf;
-        cpi->twopass.firstpass_mb_stats.mb_stats_in =
-            cpi->twopass.firstpass_mb_stats.mb_stats_start;
         cpi->twopass.firstpass_mb_stats.mb_stats_end =
             cpi->twopass.firstpass_mb_stats.mb_stats_start +
             (ps - 1) * cpi->common.MBs * sizeof(uint8_t);
index 2a5f594e99e0ab9a38537cab5d531a7e497702ad..3178ed859126fa511ff73713da385a306394c082 100644 (file)
@@ -148,16 +148,6 @@ static void output_stats(FIRSTPASS_STATS *stats,
 }
 
 #if CONFIG_FP_MB_STATS
-static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats,
-                            VP9_COMMON *cm, uint8_t **this_frame_mb_stats) {
-  if (firstpass_mb_stats->mb_stats_in > firstpass_mb_stats->mb_stats_end)
-    return EOF;
-
-  *this_frame_mb_stats = firstpass_mb_stats->mb_stats_in;
-  firstpass_mb_stats->mb_stats_in += cm->MBs * sizeof(uint8_t);
-  return 1;
-}
-
 static void output_fpmb_stats(uint8_t *this_frame_mb_stats, VP9_COMMON *cm,
                          struct vpx_codec_pkt_list *pktlist) {
   struct vpx_codec_cx_pkt pkt;
@@ -2232,13 +2222,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
 
   // Update the total stats remaining structure.
   subtract_stats(&twopass->total_left_stats, &this_frame);
-
-#if CONFIG_FP_MB_STATS
-  if (cpi->use_fp_mb_stats) {
-    input_fpmb_stats(&twopass->firstpass_mb_stats, cm,
-                     &twopass->this_frame_mb_stats);
-  }
-#endif
 }
 
 void vp9_twopass_postencode_update(VP9_COMP *cpi) {
index 714a67fd875202bcb2ee0ba3107920f7fd931b7e..84860b967bb582bb8f3ed33f5e9399f545862e98 100644 (file)
@@ -20,7 +20,6 @@ extern "C" {
 
 #if CONFIG_FP_MB_STATS
 typedef struct {
-  uint8_t *mb_stats_in;
   uint8_t *mb_stats_start;
   uint8_t *mb_stats_end;
 } FIRSTPASS_MB_STATS;