shithub: libvpx

Download patch

ref: 705bf9de8c96cfe5301451f1d7e5c90a41c64e5f
parent: e6208a95073f12f035fb554c1bd3e6a32a92f877
author: angiebird <angiebird@google.com>
date: Fri Oct 9 13:12:51 EDT 2020

Add vpx_rc_frame_stats_t

Change-Id: I496ce13592f71779bb00cc8bbb601835bca8ff09

--- a/vp9/encoder/vp9_ext_ratectrl.c
+++ b/vp9/encoder/vp9_ext_ratectrl.c
@@ -38,32 +38,32 @@
 }
 
 static void gen_rc_firstpass_stats(const FIRSTPASS_STATS *stats,
-                                   double *rc_frame_stats) {
-  rc_frame_stats[0] = stats->frame;
-  rc_frame_stats[1] = stats->weight;
-  rc_frame_stats[2] = stats->intra_error;
-  rc_frame_stats[3] = stats->coded_error;
-  rc_frame_stats[4] = stats->sr_coded_error;
-  rc_frame_stats[5] = stats->frame_noise_energy;
-  rc_frame_stats[6] = stats->pcnt_inter;
-  rc_frame_stats[7] = stats->pcnt_motion;
-  rc_frame_stats[8] = stats->pcnt_second_ref;
-  rc_frame_stats[9] = stats->pcnt_neutral;
-  rc_frame_stats[10] = stats->pcnt_intra_low;
-  rc_frame_stats[11] = stats->pcnt_intra_high;
-  rc_frame_stats[12] = stats->intra_skip_pct;
-  rc_frame_stats[13] = stats->intra_smooth_pct;
-  rc_frame_stats[14] = stats->inactive_zone_rows;
-  rc_frame_stats[15] = stats->inactive_zone_cols;
-  rc_frame_stats[16] = stats->MVr;
-  rc_frame_stats[17] = stats->mvr_abs;
-  rc_frame_stats[18] = stats->MVc;
-  rc_frame_stats[19] = stats->mvc_abs;
-  rc_frame_stats[20] = stats->MVrv;
-  rc_frame_stats[21] = stats->MVcv;
-  rc_frame_stats[22] = stats->mv_in_out_count;
-  rc_frame_stats[23] = stats->duration;
-  rc_frame_stats[24] = stats->count;
+                                   vpx_rc_frame_stats_t *rc_frame_stats) {
+  rc_frame_stats->frame = stats->frame;
+  rc_frame_stats->weight = stats->weight;
+  rc_frame_stats->intra_error = stats->intra_error;
+  rc_frame_stats->coded_error = stats->coded_error;
+  rc_frame_stats->sr_coded_error = stats->sr_coded_error;
+  rc_frame_stats->frame_noise_energy = stats->frame_noise_energy;
+  rc_frame_stats->pcnt_inter = stats->pcnt_inter;
+  rc_frame_stats->pcnt_motion = stats->pcnt_motion;
+  rc_frame_stats->pcnt_second_ref = stats->pcnt_second_ref;
+  rc_frame_stats->pcnt_neutral = stats->pcnt_neutral;
+  rc_frame_stats->pcnt_intra_low = stats->pcnt_intra_low;
+  rc_frame_stats->pcnt_intra_high = stats->pcnt_intra_high;
+  rc_frame_stats->intra_skip_pct = stats->intra_skip_pct;
+  rc_frame_stats->intra_smooth_pct = stats->intra_smooth_pct;
+  rc_frame_stats->inactive_zone_rows = stats->inactive_zone_rows;
+  rc_frame_stats->inactive_zone_cols = stats->inactive_zone_cols;
+  rc_frame_stats->MVr = stats->MVr;
+  rc_frame_stats->mvr_abs = stats->mvr_abs;
+  rc_frame_stats->MVc = stats->MVc;
+  rc_frame_stats->mvc_abs = stats->mvc_abs;
+  rc_frame_stats->MVrv = stats->MVrv;
+  rc_frame_stats->MVcv = stats->MVcv;
+  rc_frame_stats->mv_in_out_count = stats->mv_in_out_count;
+  rc_frame_stats->duration = stats->duration;
+  rc_frame_stats->count = stats->count;
 }
 
 void vp9_extrc_send_firstpass_stats(const FIRST_PASS_INFO *first_pass_info,
@@ -75,7 +75,7 @@
     assert(rc_firstpass_stats->num_frames == first_pass_info->num_frames);
     for (i = 0; i < rc_firstpass_stats->num_frames; ++i) {
       gen_rc_firstpass_stats(&first_pass_info->stats[i],
-                             rc_firstpass_stats->frame_stats[i]);
+                             &rc_firstpass_stats->frame_stats[i]);
     }
     ext_ratectrl->funcs.send_firstpass_stats(ext_ratectrl->model,
                                              rc_firstpass_stats);
--- a/vpx/vpx_ext_ratectrl.h
+++ b/vpx/vpx_ext_ratectrl.h
@@ -35,8 +35,38 @@
   int64_t pixel_count;
 } vpx_rc_encodeframe_result_t;
 
+// This is a mirror of vp9's FIRSTPASS_STATS
+// Only spatial_layer_id is omitted
+typedef struct vpx_rc_frame_stats {
+  double frame;
+  double weight;
+  double intra_error;
+  double coded_error;
+  double sr_coded_error;
+  double frame_noise_energy;
+  double pcnt_inter;
+  double pcnt_motion;
+  double pcnt_second_ref;
+  double pcnt_neutral;
+  double pcnt_intra_low;
+  double pcnt_intra_high;
+  double intra_skip_pct;
+  double intra_smooth_pct;
+  double inactive_zone_rows;
+  double inactive_zone_cols;
+  double MVr;
+  double mvr_abs;
+  double MVc;
+  double mvc_abs;
+  double MVrv;
+  double MVcv;
+  double mv_in_out_count;
+  double duration;
+  double count;
+} vpx_rc_frame_stats_t;
+
 typedef struct vpx_rc_firstpass_stats {
-  double (*frame_stats)[25];
+  vpx_rc_frame_stats_t *frame_stats;
   int num_frames;
 } vpx_rc_firstpass_stats_t;