Reduce memory usage of test with large frame size
authorJerome Jiang <jianj@google.com>
Fri, 20 Oct 2023 18:25:14 +0000 (14:25 -0400)
committerJerome Jiang <jianj@google.com>
Fri, 20 Oct 2023 19:40:43 +0000 (15:40 -0400)
 - Use smaller frame size that still triggers the overflow
 - Do not run encoder as the encoder init also triggers the overflow

Bug: chromium:1492864
Change-Id: I392549abf69f1cfb3754cc847a214513ec9bedc5

test/encode_api_test.cc

index cf89fd1..270be36 100644 (file)
@@ -409,10 +409,12 @@ TEST(EncodeAPI, ConfigResizeChangeThreadCount) {
 }
 
 #if CONFIG_VP9_ENCODER
+// Frame size needed to trigger the overflow exceeds the max buffer allowed on
+// 32-bit systems defined by VPX_MAX_ALLOCABLE_MEMORY
 #if VPX_ARCH_X86_64 || VPX_ARCH_AARCH64
 TEST(EncodeAPI, ConfigLargeTargetBitrateVp9) {
-  constexpr int kWidth = 16383;
-  constexpr int kHeight = 16383;
+  constexpr int kWidth = 12383;
+  constexpr int kHeight = 8192;
   constexpr auto *iface = &vpx_codec_vp9_cx_algo;
   SCOPED_TRACE(vpx_codec_iface_name(iface));
   vpx_codec_enc_cfg_t cfg = {};
@@ -425,10 +427,11 @@ TEST(EncodeAPI, ConfigLargeTargetBitrateVp9) {
   // The following setting will cause avg_frame_bandwidth in rate control to be
   // larger than INT_MAX
   cfg.rc_target_bitrate = INT_MAX;
+  // Framerate 0.1 (equivalent to timebase 10) is the smallest framerate allowed
+  // by libvpx
   cfg.g_timebase.den = 1;
   cfg.g_timebase.num = 10;
-  EXPECT_NO_FATAL_FAILURE(InitCodec(*iface, kWidth, kHeight, &enc.ctx, &cfg));
-  EXPECT_NO_FATAL_FAILURE(EncodeWithConfig(cfg, &enc.ctx))
+  EXPECT_NO_FATAL_FAILURE(InitCodec(*iface, kWidth, kHeight, &enc.ctx, &cfg))
       << "target bitrate: " << cfg.rc_target_bitrate << " framerate: "
       << static_cast<double>(cfg.g_timebase.den) / cfg.g_timebase.num;
 }