Remove VP9E_GET_TPL_STATS
authorJerome Jiang <jianj@google.com>
Fri, 15 Dec 2023 20:49:01 +0000 (15:49 -0500)
committerJerome Jiang <jianj@google.com>
Mon, 18 Dec 2023 17:23:32 +0000 (12:23 -0500)
This is never used.
A callback in external rc func was added and used instead.

Change-Id: Iade6f361072f0c28af98904baf457d2f0e9ca904
(cherry picked from commit 41ced868a69625372c95ff0b2bd5f90987516c3b)

test/encode_api_test.cc
vp9/vp9_cx_iface.c
vpx/vp8cx.h

index 0aa8739..ee7d8d2 100644 (file)
@@ -912,138 +912,6 @@ TEST(EncodeAPI, Buganizer311294795) {
   encoder.Encode(false);
   encoder.Encode(false);
 }
-
-class EncodeApiGetTplStatsTest
-    : public ::libvpx_test::EncoderTest,
-      public ::testing::TestWithParam<const libvpx_test::CodecFactory *> {
- public:
-  EncodeApiGetTplStatsTest() : EncoderTest(GetParam()), test_io_(false) {}
-  ~EncodeApiGetTplStatsTest() override = default;
-
- protected:
-  void SetUp() override {
-    InitializeConfig();
-    SetMode(::libvpx_test::kTwoPassGood);
-  }
-
-  void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
-                          ::libvpx_test::Encoder *encoder) override {
-    if (video->frame() == 0) {
-      encoder->Control(VP9E_SET_TPL, 1);
-    }
-  }
-
-  vpx_codec_err_t AllocateTplList(VpxTplGopStats *data) {
-    // Allocate MAX_ARF_GOP_SIZE (50) * sizeof(VpxTplFrameStats) that will be
-    // filled by VP9E_GET_TPL_STATS.
-    // MAX_ARF_GOP_SIZE is used here because the test doesn't know the size of
-    // each GOP before getting TPL stats from the encoder.
-    data->size = 50;
-    data->frame_stats_list =
-        static_cast<VpxTplFrameStats *>(calloc(50, sizeof(VpxTplFrameStats)));
-    if (data->frame_stats_list == nullptr) return VPX_CODEC_MEM_ERROR;
-    return VPX_CODEC_OK;
-  }
-
-  void CompareTplGopStats(const VpxTplGopStats &ref_gop_stats,
-                          const VpxTplGopStats &test_gop_stats) {
-    ASSERT_EQ(ref_gop_stats.size, test_gop_stats.size);
-    for (int frame = 0; frame < ref_gop_stats.size; frame++) {
-      const VpxTplFrameStats &ref_frame_stats =
-          ref_gop_stats.frame_stats_list[frame];
-      const VpxTplFrameStats &test_frame_stats =
-          test_gop_stats.frame_stats_list[frame];
-      ASSERT_EQ(ref_frame_stats.num_blocks, test_frame_stats.num_blocks);
-      ASSERT_EQ(ref_frame_stats.frame_width, test_frame_stats.frame_width);
-      ASSERT_EQ(ref_frame_stats.frame_height, test_frame_stats.frame_height);
-      for (int block = 0; block < ref_frame_stats.num_blocks; block++) {
-        const VpxTplBlockStats &ref_block_stats =
-            ref_frame_stats.block_stats_list[block];
-        const VpxTplBlockStats &test_block_stats =
-            test_frame_stats.block_stats_list[block];
-        ASSERT_EQ(ref_block_stats.inter_cost, test_block_stats.inter_cost);
-        ASSERT_EQ(ref_block_stats.intra_cost, test_block_stats.intra_cost);
-        ASSERT_EQ(ref_block_stats.mv_c, test_block_stats.mv_c);
-        ASSERT_EQ(ref_block_stats.mv_r, test_block_stats.mv_r);
-        ASSERT_EQ(ref_block_stats.recrf_dist, test_block_stats.recrf_dist);
-        ASSERT_EQ(ref_block_stats.recrf_rate, test_block_stats.recrf_rate);
-        ASSERT_EQ(ref_block_stats.ref_frame_index,
-                  test_block_stats.ref_frame_index);
-      }
-    }
-  }
-
-  void PostEncodeFrameHook(::libvpx_test::Encoder *encoder) override {
-    ::libvpx_test::CxDataIterator iter = encoder->GetCxData();
-    while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) {
-      switch (pkt->kind) {
-        case VPX_CODEC_CX_FRAME_PKT: {
-          VpxTplGopStats tpl_stats;
-          EXPECT_EQ(AllocateTplList(&tpl_stats), VPX_CODEC_OK);
-          encoder->Control(VP9E_GET_TPL_STATS, &tpl_stats);
-          bool stats_not_all_zero = false;
-          for (int i = 0; i < tpl_stats.size; i++) {
-            VpxTplFrameStats *frame_stats_list = tpl_stats.frame_stats_list;
-            if (frame_stats_list[i].frame_width != 0) {
-              ASSERT_EQ(frame_stats_list[i].frame_width, width_);
-              ASSERT_EQ(frame_stats_list[i].frame_height, height_);
-              ASSERT_GT(frame_stats_list[i].num_blocks, 0);
-              ASSERT_NE(frame_stats_list[i].block_stats_list, nullptr);
-              stats_not_all_zero = true;
-            }
-          }
-          ASSERT_TRUE(stats_not_all_zero);
-          if (test_io_ && tpl_stats.size > 0) {
-            libvpx_test::TempOutFile *temp_out_file =
-                new (std::nothrow) libvpx_test::TempOutFile("w+");
-            ASSERT_NE(temp_out_file, nullptr);
-            ASSERT_NE(temp_out_file->file(), nullptr);
-            vpx_write_tpl_gop_stats(temp_out_file->file(), &tpl_stats);
-            rewind(temp_out_file->file());
-            VpxTplGopStats gop_stats_io;
-            ASSERT_EQ(
-                vpx_read_tpl_gop_stats(temp_out_file->file(), &gop_stats_io),
-                VPX_CODEC_OK);
-            CompareTplGopStats(gop_stats_io, tpl_stats);
-            vpx_free_tpl_gop_stats(&gop_stats_io);
-            delete temp_out_file;
-          }
-          free(tpl_stats.frame_stats_list);
-          break;
-        }
-        default: break;
-      }
-    }
-  }
-
-  int width_;
-  int height_;
-  bool test_io_;
-};
-
-TEST_P(EncodeApiGetTplStatsTest, GetTplStats) {
-  cfg_.g_lag_in_frames = 25;
-  width_ = 352;
-  height_ = 288;
-  ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", width_,
-                                       height_, 30, 1, 0, 50);
-  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
-}
-
-TEST_P(EncodeApiGetTplStatsTest, GetTplStatsIO) {
-  cfg_.g_lag_in_frames = 25;
-  width_ = 352;
-  height_ = 288;
-  test_io_ = true;
-  ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", width_,
-                                       height_, 30, 1, 0, 50);
-  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
-}
-
-INSTANTIATE_TEST_SUITE_P(
-    VP9, EncodeApiGetTplStatsTest,
-    ::testing::Values(
-        static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)));
 #endif  // CONFIG_VP9_ENCODER
 
 }  // namespace
index d4c41d1..e738fed 100644 (file)
@@ -1809,24 +1809,6 @@ static vpx_codec_err_t ctrl_get_svc_ref_frame_config(vpx_codec_alg_priv_t *ctx,
   return VPX_CODEC_OK;
 }
 
-static vpx_codec_err_t ctrl_get_tpl_stats(vpx_codec_alg_priv_t *ctx,
-                                          va_list args) {
-  VP9_COMP *const cpi = ctx->cpi;
-  VpxTplGopStats *data = va_arg(args, VpxTplGopStats *);
-  VpxTplFrameStats *frame_stats_list = cpi->tpl_gop_stats.frame_stats_list;
-  int i;
-  if (data == NULL) {
-    return VPX_CODEC_INVALID_PARAM;
-  }
-  data->size = cpi->tpl_gop_stats.size;
-
-  for (i = 0; i < data->size; i++) {
-    data->frame_stats_list[i] = frame_stats_list[i];
-  }
-
-  return VPX_CODEC_OK;
-}
-
 static vpx_codec_err_t ctrl_set_svc_ref_frame_config(vpx_codec_alg_priv_t *ctx,
                                                      va_list args) {
   VP9_COMP *const cpi = ctx->cpi;
@@ -2086,7 +2068,6 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { VP9E_GET_ACTIVEMAP, ctrl_get_active_map },
   { VP9E_GET_LEVEL, ctrl_get_level },
   { VP9E_GET_SVC_REF_FRAME_CONFIG, ctrl_get_svc_ref_frame_config },
-  { VP9E_GET_TPL_STATS, ctrl_get_tpl_stats },
 
   { -1, NULL },
 };
index d098c4c..2875e18 100644 (file)
@@ -768,18 +768,6 @@ enum vp8e_enc_control_id {
    *
    */
   VP9E_SET_QUANTIZER_ONE_PASS,
-
-  /*!\brief Codec control to get TPL stats for the current GOP.
-   *
-   * Allocation and free of memory of size MAX_ARF_GOP_SIZE (50) *
-   * sizeof(VpxTplFrameStats) should be done by applications.
-   *
-   * VPX_CODEC_INVALID_PARAM will be returned if the pointer passed in is NULL.
-   *
-   * Supported in codecs: VP9
-   *
-   */
-  VP9E_GET_TPL_STATS,
 };
 
 /*!\brief vpx 1-D scaling mode
@@ -1110,8 +1098,6 @@ VPX_CTRL_USE_TYPE(VP8E_SET_RTC_EXTERNAL_RATECTRL, int)
 #define VPX_CTRL_VP8E_SET_RTC_EXTERNAL_RATECTRL
 VPX_CTRL_USE_TYPE(VP9E_SET_QUANTIZER_ONE_PASS, int)
 #define VPX_CTRL_VP9E_SET_QUANTIZER_ONE_PASS
-VPX_CTRL_USE_TYPE(VP9E_GET_TPL_STATS, void *)
-#define VPX_CTRL_VP9E_GET_TPL_STATS
 
 /*!\endcond */
 /*! @} - end defgroup vp8_encoder */