Skip to content

fix(amf): attempt to use level 5.1/5.2 for hevc #3888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,18 @@
{"usage"s, &config::video.amd.amd_usage_hevc},
{"vbaq"s, &config::video.amd.amd_vbaq},
{"enforce_hrd"s, &config::video.amd.amd_enforce_hrd},
{"level"s, [](const config_t &cfg) {
auto size = cfg.width * cfg.height;

Check warning on line 769 in src/video.cpp

View check run for this annotation

Codecov / codecov/patch

src/video.cpp#L768-L769

Added lines #L768 - L769 were not covered by tests
// For 4K and below, try to use level 5.1 or 5.2 if possible
if (size <= 8912896) {
if (size * cfg.framerate <= 534773760) {
return "5.1"s;

Check warning on line 773 in src/video.cpp

View check run for this annotation

Codecov / codecov/patch

src/video.cpp#L773

Added line #L773 was not covered by tests
} else if (size * cfg.framerate <= 1069547520) {
return "5.2"s;

Check warning on line 775 in src/video.cpp

View check run for this annotation

Codecov / codecov/patch

src/video.cpp#L775

Added line #L775 was not covered by tests
}
}
return "auto"s;

Check warning on line 778 in src/video.cpp

View check run for this annotation

Codecov / codecov/patch

src/video.cpp#L778

Added line #L778 was not covered by tests
}},
},
{}, // SDR-specific options
{}, // HDR-specific options
Expand Down Expand Up @@ -1639,7 +1651,7 @@
ctx->thread_count = ctx->slices;

AVDictionary *options {nullptr};
auto handle_option = [&options](const encoder_t::option_t &option) {
auto handle_option = [&options, &config](const encoder_t::option_t &option) {
std::visit(
util::overloaded {
[&](int v) {
Expand All @@ -1653,7 +1665,7 @@
av_dict_set_int(&options, option.name.c_str(), **v, 0);
}
},
[&](std::function<int()> v) {
[&](const std::function<int()> &v) {

Check warning on line 1668 in src/video.cpp

View check run for this annotation

Codecov / codecov/patch

src/video.cpp#L1668

Added line #L1668 was not covered by tests
av_dict_set_int(&options, option.name.c_str(), v(), 0);
},
[&](const std::string &v) {
Expand All @@ -1663,6 +1675,9 @@
if (!v->empty()) {
av_dict_set(&options, option.name.c_str(), v->c_str(), 0);
}
},
[&](const std::function<const std::string(const config_t &cfg)> &v) {

Check warning on line 1679 in src/video.cpp

View check run for this annotation

Codecov / codecov/patch

src/video.cpp#L1679

Added line #L1679 was not covered by tests
av_dict_set(&options, option.name.c_str(), v(config).c_str(), 0);
}
},
option.value
Expand Down
2 changes: 1 addition & 1 deletion src/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace video {
option_t(const option_t &) = default;

std::string name;
std::variant<int, int *, std::optional<int> *, std::function<int()>, std::string, std::string *> value;
std::variant<int, int *, std::optional<int> *, std::function<int()>, std::string, std::string *, std::function<const std::string(const config_t &)>> value;

option_t(std::string &&name, decltype(value) &&value):
name {std::move(name)},
Expand Down
Loading