Skip to content

Commit af6dedd

Browse files
committed
encode_api_test: add ConfigResizeChangeThreadCount
Update thread counts and resolution to ensure allocations are updated correctly. VP8 is disabled to avoid a crash. Bug: chromium:1486441 Change-Id: Ie89776d9818d27dc351eff298a44c699e850761b
1 parent 67bfb41 commit af6dedd

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

Diff for: test/encode_api_test.cc

+49-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ TEST(EncodeAPI, SetRoi) {
308308

309309
void InitCodec(const vpx_codec_iface_t &iface, int width, int height,
310310
vpx_codec_ctx_t *enc, vpx_codec_enc_cfg_t *cfg) {
311-
ASSERT_EQ(vpx_codec_enc_config_default(&iface, cfg, 0), VPX_CODEC_OK);
312311
cfg->g_w = width;
313312
cfg->g_h = height;
314313
cfg->g_lag_in_frames = 0;
@@ -346,6 +345,7 @@ TEST(EncodeAPI, ConfigChangeThreadCount) {
346345
vpx_codec_ctx_t ctx = {};
347346
} enc;
348347

348+
ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, 0), VPX_CODEC_OK);
349349
EXPECT_NO_FATAL_FAILURE(
350350
InitCodec(*iface, kWidth, kHeight, &enc.ctx, &cfg));
351351
if (IsVP9(iface)) {
@@ -364,6 +364,54 @@ TEST(EncodeAPI, ConfigChangeThreadCount) {
364364
}
365365
}
366366

367+
TEST(EncodeAPI, ConfigResizeChangeThreadCount) {
368+
constexpr int kInitWidth = 1024;
369+
constexpr int kInitHeight = 1024;
370+
371+
for (const auto *iface : kCodecIfaces) {
372+
SCOPED_TRACE(vpx_codec_iface_name(iface));
373+
if (!IsVP9(iface)) {
374+
GTEST_SKIP() << "TODO(https://crbug.com/1486441) remove this condition "
375+
"after VP8 is fixed.";
376+
}
377+
for (int i = 0; i < (IsVP9(iface) ? 2 : 1); ++i) {
378+
vpx_codec_enc_cfg_t cfg = {};
379+
struct Encoder {
380+
~Encoder() { EXPECT_EQ(vpx_codec_destroy(&ctx), VPX_CODEC_OK); }
381+
vpx_codec_ctx_t ctx = {};
382+
} enc;
383+
384+
ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, 0), VPX_CODEC_OK);
385+
// Start in threaded mode to ensure resolution and thread related
386+
// allocations are updated correctly across changes in resolution and
387+
// thread counts. See https://crbug.com/1486441.
388+
cfg.g_threads = 4;
389+
EXPECT_NO_FATAL_FAILURE(
390+
InitCodec(*iface, kInitWidth, kInitHeight, &enc.ctx, &cfg));
391+
if (IsVP9(iface)) {
392+
EXPECT_EQ(vpx_codec_control_(&enc.ctx, VP9E_SET_TILE_COLUMNS, 6),
393+
VPX_CODEC_OK);
394+
EXPECT_EQ(vpx_codec_control_(&enc.ctx, VP9E_SET_ROW_MT, i),
395+
VPX_CODEC_OK);
396+
}
397+
398+
cfg.g_w = 1000;
399+
cfg.g_h = 608;
400+
EXPECT_EQ(vpx_codec_enc_config_set(&enc.ctx, &cfg), VPX_CODEC_OK)
401+
<< vpx_codec_error_detail(&enc.ctx);
402+
403+
cfg.g_w = 16;
404+
cfg.g_h = 720;
405+
406+
for (const auto threads : { 1, 4, 8, 6, 2, 1 }) {
407+
cfg.g_threads = threads;
408+
EXPECT_NO_FATAL_FAILURE(EncodeWithConfig(cfg, &enc.ctx))
409+
<< "iteration: " << i << " threads: " << threads;
410+
}
411+
}
412+
}
413+
}
414+
367415
#if CONFIG_VP9_ENCODER
368416
class EncodeApiGetTplStatsTest
369417
: public ::libvpx_test::EncoderTest,

0 commit comments

Comments
 (0)