mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1855550 - VP8: disallow thread count changes. r=jesup, a=dsmith
Cherry-pick of upstream libvpx commits:af6dedd715
3fbd1dca6a
Differential Revision: https://phabricator.services.mozilla.com/D189428
This commit is contained in:
parent
e90c526730
commit
55bff5a718
@ -307,7 +307,6 @@ TEST(EncodeAPI, SetRoi) {
|
|||||||
|
|
||||||
void InitCodec(const vpx_codec_iface_t &iface, int width, int height,
|
void InitCodec(const vpx_codec_iface_t &iface, int width, int height,
|
||||||
vpx_codec_ctx_t *enc, vpx_codec_enc_cfg_t *cfg) {
|
vpx_codec_ctx_t *enc, vpx_codec_enc_cfg_t *cfg) {
|
||||||
ASSERT_EQ(vpx_codec_enc_config_default(&iface, cfg, 0), VPX_CODEC_OK);
|
|
||||||
cfg->g_w = width;
|
cfg->g_w = width;
|
||||||
cfg->g_h = height;
|
cfg->g_h = height;
|
||||||
cfg->g_lag_in_frames = 0;
|
cfg->g_lag_in_frames = 0;
|
||||||
@ -345,6 +344,7 @@ TEST(EncodeAPI, ConfigChangeThreadCount) {
|
|||||||
vpx_codec_ctx_t ctx = {};
|
vpx_codec_ctx_t ctx = {};
|
||||||
} enc;
|
} enc;
|
||||||
|
|
||||||
|
ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, 0), VPX_CODEC_OK);
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
InitCodec(*iface, kWidth, kHeight, &enc.ctx, &cfg));
|
InitCodec(*iface, kWidth, kHeight, &enc.ctx, &cfg));
|
||||||
if (IsVP9(iface)) {
|
if (IsVP9(iface)) {
|
||||||
@ -363,6 +363,50 @@ TEST(EncodeAPI, ConfigChangeThreadCount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(EncodeAPI, ConfigResizeChangeThreadCount) {
|
||||||
|
constexpr int kInitWidth = 1024;
|
||||||
|
constexpr int kInitHeight = 1024;
|
||||||
|
|
||||||
|
for (const auto *iface : kCodecIfaces) {
|
||||||
|
SCOPED_TRACE(vpx_codec_iface_name(iface));
|
||||||
|
for (int i = 0; i < (IsVP9(iface) ? 2 : 1); ++i) {
|
||||||
|
vpx_codec_enc_cfg_t cfg = {};
|
||||||
|
struct Encoder {
|
||||||
|
~Encoder() { EXPECT_EQ(vpx_codec_destroy(&ctx), VPX_CODEC_OK); }
|
||||||
|
vpx_codec_ctx_t ctx = {};
|
||||||
|
} enc;
|
||||||
|
|
||||||
|
ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, 0), VPX_CODEC_OK);
|
||||||
|
// Start in threaded mode to ensure resolution and thread related
|
||||||
|
// allocations are updated correctly across changes in resolution and
|
||||||
|
// thread counts. See https://crbug.com/1486441.
|
||||||
|
cfg.g_threads = 4;
|
||||||
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
|
InitCodec(*iface, kInitWidth, kInitHeight, &enc.ctx, &cfg));
|
||||||
|
if (IsVP9(iface)) {
|
||||||
|
EXPECT_EQ(vpx_codec_control_(&enc.ctx, VP9E_SET_TILE_COLUMNS, 6),
|
||||||
|
VPX_CODEC_OK);
|
||||||
|
EXPECT_EQ(vpx_codec_control_(&enc.ctx, VP9E_SET_ROW_MT, i),
|
||||||
|
VPX_CODEC_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.g_w = 1000;
|
||||||
|
cfg.g_h = 608;
|
||||||
|
EXPECT_EQ(vpx_codec_enc_config_set(&enc.ctx, &cfg), VPX_CODEC_OK)
|
||||||
|
<< vpx_codec_error_detail(&enc.ctx);
|
||||||
|
|
||||||
|
cfg.g_w = 16;
|
||||||
|
cfg.g_h = 720;
|
||||||
|
|
||||||
|
for (const auto threads : { 1, 4, 8, 6, 2, 1 }) {
|
||||||
|
cfg.g_threads = threads;
|
||||||
|
EXPECT_NO_FATAL_FAILURE(EncodeWithConfig(cfg, &enc.ctx))
|
||||||
|
<< "iteration: " << i << " threads: " << threads;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_VP9_ENCODER
|
#if CONFIG_VP9_ENCODER
|
||||||
class EncodeApiGetTplStatsTest
|
class EncodeApiGetTplStatsTest
|
||||||
: public ::libvpx_test::EncoderTest,
|
: public ::libvpx_test::EncoderTest,
|
||||||
|
@ -1447,6 +1447,12 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) {
|
|||||||
last_h = cpi->oxcf.Height;
|
last_h = cpi->oxcf.Height;
|
||||||
prev_number_of_layers = cpi->oxcf.number_of_layers;
|
prev_number_of_layers = cpi->oxcf.number_of_layers;
|
||||||
|
|
||||||
|
if (cpi->initial_width) {
|
||||||
|
// TODO(https://crbug.com/1486441): Allow changing thread counts; the
|
||||||
|
// allocation is done once in vp8_create_compressor().
|
||||||
|
oxcf->multi_threaded = cpi->oxcf.multi_threaded;
|
||||||
|
}
|
||||||
|
|
||||||
cpi->oxcf = *oxcf;
|
cpi->oxcf = *oxcf;
|
||||||
|
|
||||||
switch (cpi->oxcf.Mode) {
|
switch (cpi->oxcf.Mode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user