]> granicus.if.org Git - libvpx/commitdiff
Add init/update_frame_indexes()
authorangiebird <angiebird@google.com>
Thu, 27 Feb 2020 00:43:50 +0000 (16:43 -0800)
committerangiebird <angiebird@google.com>
Tue, 3 Mar 2020 04:17:09 +0000 (20:17 -0800)
We will init and update current_video_frame and
current_frame_coding_index in the functions.

So it's easier to keep track of when the frame indexes are updated.

Change-Id: Id6ba46643f8923348bb4f81c5dd9ace553244057

vp9/common/vp9_onyxc_int.h
vp9/decoder/vp9_decoder.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_firstpass.c

index f3942a8f070f6511ec19247254996b6ba0d627f3..60759f3b31f9b127037c70ffa6d07afbacb2b741 100644 (file)
@@ -226,7 +226,16 @@ typedef struct VP9Common {
   unsigned int frame_context_idx; /* Context to use/update */
   FRAME_COUNTS counts;
 
+  // TODO(angiebird): current_video_frame/current_frame_coding_index into a
+  // structure
   unsigned int current_video_frame;
+#if CONFIG_RATE_CTRL
+  // Each show or no show frame is assigned with a coding index based on its
+  // coding order (starting from zero).
+
+  // Current frame's coding index.
+  int current_frame_coding_index;
+#endif
   BITSTREAM_PROFILE profile;
 
   // VPX_BITS_8 in profile 0 or 1, VPX_BITS_10 or VPX_BITS_12 in profile 2 or 3.
@@ -254,6 +263,22 @@ typedef struct VP9Common {
   int lf_row;
 } VP9_COMMON;
 
+static INLINE void init_frame_indexes(VP9_COMMON *cm) {
+  cm->current_video_frame = 0;
+#if CONFIG_RATE_CTRL
+  cm->current_frame_coding_index = 0;
+#endif  // CONFIG_RATE_CTRL
+}
+
+static INLINE void update_frame_indexes(VP9_COMMON *cm, int show_frame) {
+  if (show_frame) {
+    ++cm->current_video_frame;
+  }
+#if CONFIG_RATE_CTRL
+  ++cm->current_frame_coding_index;
+#endif  // CONFIG_RATE_CTRL
+}
+
 typedef struct {
   int frame_width;
   int frame_height;
index 0aed3d717c5630fa2070635e69a2fdbb55e857c2..bcade52c4e4eec5e34d2f6b65925d6bac97c5b54 100644 (file)
@@ -188,7 +188,7 @@ VP9Decoder *vp9_decoder_create(BufferPool *const pool) {
   memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
   memset(&cm->next_ref_frame_map, -1, sizeof(cm->next_ref_frame_map));
 
-  cm->current_video_frame = 0;
+  init_frame_indexes(cm);
   pbi->ready_for_new_data = 1;
   pbi->common.buffer_pool = pool;
 
index bd64cfeabcbc15bad08bcd81dc95c961360dc1f7..a35b4afff0d02a09a8142484ce693bde2e06a610 100644 (file)
@@ -2311,7 +2311,7 @@ VP9_COMP *vp9_create_compressor(const VP9EncoderConfig *oxcf,
 
   vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc);
 
-  cm->current_video_frame = 0;
+  init_frame_indexes(cm);
   cpi->partition_search_skippable_frame = 0;
   cpi->tile_data = NULL;
 
@@ -5342,7 +5342,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
     vp9_swap_mi_and_prev_mi(cm);
     // Don't increment frame counters if this was an altref buffer
     // update not a real frame
-    ++cm->current_video_frame;
+    update_frame_indexes(cm, cm->show_frame);
     if (cpi->use_svc) vp9_inc_frame_in_layer(cpi);
   }
 
index 73ac4d639103478ffdefabf52dec79e5602a0354..e3f622f9b10008617363e369d719acdd1967df06 100644 (file)
@@ -1478,7 +1478,8 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
     fclose(recon_file);
   }
 
-  ++cm->current_video_frame;
+  // In the first pass, every frame is considered as a show frame.
+  update_frame_indexes(cm, /*show_frame=*/1);
   if (cpi->use_svc) vp9_inc_frame_in_layer(cpi);
 }