diff options
author | Jerome Jiang <jianj@google.com> | 2023-05-04 14:28:29 -0400 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2023-05-08 13:27:26 -0400 |
commit | 745c6392f795f43138cfca164b9e54ef895f87b9 (patch) | |
tree | 10010ea6182111e8320f64ff64115484e5fef19f /test | |
parent | 1710c9282a11aaaccdf42b7507f570f58e39b7fd (diff) | |
download | libvpx-745c6392f795f43138cfca164b9e54ef895f87b9.tar libvpx-745c6392f795f43138cfca164b9e54ef895f87b9.tar.gz libvpx-745c6392f795f43138cfca164b9e54ef895f87b9.tar.bz2 libvpx-745c6392f795f43138cfca164b9e54ef895f87b9.zip |
Add VpxTplGopStats
Contains the size of GOP - also the size of the list of TPL stats for
each frame in this GOP.
VpxTplGopStats will be the unit for VP9E_GET_TPL_STATS control to return
TPL stats from the encoder.
Bug: b/273736974
Change-Id: I1682242fc6db4aafcd6314af023aa0d704976585
Diffstat (limited to 'test')
-rw-r--r-- | test/encode_api_test.cc | 34 | ||||
-rw-r--r-- | test/encode_test_driver.h | 2 |
2 files changed, 20 insertions, 16 deletions
diff --git a/test/encode_api_test.cc b/test/encode_api_test.cc index e435ed872..2b0aa1fdf 100644 --- a/test/encode_api_test.cc +++ b/test/encode_api_test.cc @@ -384,12 +384,15 @@ class EncodeApiGetTplStatsTest } } - vpx_codec_err_t AllocateTplList(VpxTplFrameStats **data) { - // Allocate MAX_ARF_GOP_SIZE * sizeof(VpxTplFrameStats) that will be filled - // by VP9E_GET_TPL_STATS - *data = + 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 == nullptr) return VPX_CODEC_MEM_ERROR; + if (data->frame_stats_list == nullptr) return VPX_CODEC_MEM_ERROR; return VPX_CODEC_OK; } @@ -398,22 +401,23 @@ class EncodeApiGetTplStatsTest while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) { switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: { - VpxTplFrameStats *tpl_stats = NULL; + VpxTplGopStats tpl_stats; EXPECT_EQ(AllocateTplList(&tpl_stats), VPX_CODEC_OK); - encoder->Control(VP9E_GET_TPL_STATS, tpl_stats); + encoder->Control(VP9E_GET_TPL_STATS, &tpl_stats); bool stats_not_all_zero = false; - for (unsigned int i = 0; i < cfg_.g_lag_in_frames; i++) { - if (tpl_stats[i].frame_width != 0) { - ASSERT_EQ(tpl_stats[i].frame_width, width_); - ASSERT_EQ(tpl_stats[i].frame_height, height_); - ASSERT_GT(tpl_stats[i].num_blocks, 0); - ASSERT_NE(tpl_stats[i].block_stats_list, nullptr); + 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); // Free the memory right away now as this is only a test. - free(tpl_stats); + free(tpl_stats.frame_stats_list); break; } default: break; @@ -430,7 +434,7 @@ TEST_P(EncodeApiGetTplStatsTest, GetTplStats) { width_ = 352; height_ = 288; ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", width_, - height_, 30, 1, 0, 150); + height_, 30, 1, 0, 50); ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); } diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h index a5cd8306e..922c49f42 100644 --- a/test/encode_test_driver.h +++ b/test/encode_test_driver.h @@ -154,7 +154,7 @@ class Encoder { ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); } - void Control(int ctrl_id, VpxTplFrameStats *arg) { + void Control(int ctrl_id, VpxTplGopStats *arg) { const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg); ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); } |