]> granicus.if.org Git - libvpx/commitdiff
Add GetKeyFrameGroupSize()
authorangiebird <angiebird@google.com>
Mon, 25 Nov 2019 20:26:08 +0000 (12:26 -0800)
committerangiebird <angiebird@google.com>
Fri, 6 Dec 2019 23:03:23 +0000 (15:03 -0800)
Makes vp9_get_frames_to_next_key() public.

Change-Id: I903cefbb3925d6ffc641412c6d60d95a2ff256a4

vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_firstpass.h
vp9/simple_encode.cc
vp9/simple_encode.h

index acc4be3fac92c28f42e078f3e24bbdd290dc9da1..57ab583cfcf4814e835436779d797a3629933322 100644 (file)
@@ -3068,10 +3068,10 @@ static int test_candidate_kf(const FIRST_PASS_INFO *first_pass_info,
 #define MAX_KF_TOT_BOOST 5400
 #endif
 
-static int get_frames_to_next_key(const VP9EncoderConfig *oxcf,
-                                  const FRAME_INFO *frame_info,
-                                  const FIRST_PASS_INFO *first_pass_info,
-                                  int kf_show_idx, int min_gf_interval) {
+int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf,
+                               const FRAME_INFO *frame_info,
+                               const FIRST_PASS_INFO *first_pass_info,
+                               int kf_show_idx, int min_gf_interval) {
   double recent_loop_decay[FRAMES_TO_CHECK_DECAY];
   int j;
   int frames_to_key;
@@ -3184,8 +3184,8 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) {
   kf_mod_err = calc_norm_frame_score(oxcf, frame_info, keyframe_stats,
                                      mean_mod_score, av_err);
 
-  rc->frames_to_key = get_frames_to_next_key(oxcf, frame_info, first_pass_info,
-                                             kf_show_idx, rc->min_gf_interval);
+  rc->frames_to_key = vp9_get_frames_to_next_key(
+      oxcf, frame_info, first_pass_info, kf_show_idx, rc->min_gf_interval);
 
   // If there is a max kf interval set by the user we must obey it.
   // We already breakout of the loop above at 2x max.
@@ -3648,7 +3648,7 @@ int vp9_get_coding_frame_num(const struct VP9EncoderConfig *oxcf,
 
   while (show_idx < first_pass_info->num_frames) {
     if (rc.frames_to_key == 0) {
-      rc.frames_to_key = get_frames_to_next_key(
+      rc.frames_to_key = vp9_get_frames_to_next_key(
           oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval);
       arf_active_or_kf = 1;
     } else {
index 408ff3a8b6c3c8f0629dcdf923c85c13acc8867a..cfbc143c304653075d7c9562013a699aaf0cec34 100644 (file)
@@ -13,9 +13,7 @@
 
 #include <assert.h>
 
-#if CONFIG_RATE_CTRL
 #include "vp9/common/vp9_onyxc_int.h"
-#endif
 #include "vp9/encoder/vp9_lookahead.h"
 #include "vp9/encoder/vp9_ratectrl.h"
 
@@ -248,8 +246,12 @@ void vp9_twopass_postencode_update(struct VP9_COMP *cpi);
 void calculate_coded_size(struct VP9_COMP *cpi, int *scaled_frame_width,
                           int *scaled_frame_height);
 
-#if CONFIG_RATE_CTRL
 struct VP9EncoderConfig;
+int vp9_get_frames_to_next_key(const struct VP9EncoderConfig *oxcf,
+                               const FRAME_INFO *frame_info,
+                               const FIRST_PASS_INFO *first_pass_info,
+                               int kf_show_idx, int min_gf_interval);
+#if CONFIG_RATE_CTRL
 int vp9_get_coding_frame_num(const struct VP9EncoderConfig *oxcf,
                              const FRAME_INFO *frame_info,
                              const FIRST_PASS_INFO *first_pass_info,
index f34df6801bee13226e509e05b1a7b7b614f9337b..6a35eb6bcfa0e6235c25887aaf3abdd3057ae8ed 100644 (file)
@@ -221,6 +221,13 @@ void SimpleEncode::EndEncode() {
   rewind(file_);
 }
 
+int SimpleEncode::GetKeyFrameGroupSize(int key_frame_index) const {
+  const VP9_COMP *cpi = impl_ptr_->cpi;
+  return vp9_get_frames_to_next_key(&cpi->oxcf, &cpi->frame_info,
+                                    &cpi->twopass.first_pass_info,
+                                    key_frame_index, cpi->rc.min_gf_interval);
+}
+
 void SimpleEncode::EncodeFrame(EncodeFrameResult *encode_frame_result) {
   VP9_COMP *cpi = impl_ptr_->cpi;
   struct lookahead_ctx *lookahead = cpi->lookahead;
index a05ef10cb32d8490a3b8b9700cb0022df4095d07..471b4e7a84daae348878d3881286eab7a630977a 100644 (file)
@@ -65,6 +65,13 @@ class SimpleEncode {
   // This function should be called after StartEncode() or EncodeFrame().
   void EndEncode();
 
+  // Given a key_frame_index, computes this key frame group's size.
+  // The key frame group size includes one key frame plus the number of
+  // following inter frames. Note that the key frame group size only counts the
+  // show frames. The number of no show frames like alternate refereces are not
+  // counted.
+  int GetKeyFrameGroupSize(int key_frame_index) const;
+
   // Encodes a frame
   // This function should be called after StartEncode() and before EndEncode().
   void EncodeFrame(EncodeFrameResult *encode_frame_result);