Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya authored Oct 27, 2024
2 parents 8a103f9 + 456ed18 commit a360e50
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 13 deletions.
7 changes: 6 additions & 1 deletion NVEnc/NVEnc_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,15 @@ NVIDIA グラフィックドライバ 551.23
今後の更新で設定ファイルの互換性がなくなるかもしれません。

【メモ】
2024.10.27 (7.72)
[NVEncC]
- --vpp-libplacebo-shaderでlumaに対して処理を行うshaderが正常に動作しなかった問題を修正。
- --vpp-libplacebo-shaderのcolorsytem, transferを入力ファイルの情報に基づき自動的に設定するように。
- --dhdr10-infoが動作しなくなっていたのを修正。

2024.10.26 (7.71)
[NVEncC]
- Linuxでのlibplaceboフィルタの使用に対応。(配布バイナリではUbuntu 24.04のみ対応)
- libplaceboによるバンディング低減フィルタを追加。(--vpp-libplacebo-deband)
- libplaceboのcustom shaderを使用したフィルタを追加。 (--vpp-libplacebo-shader)
- --vpp-libplacebo-tonemappingのhelpを修正。

Expand Down
4 changes: 2 additions & 2 deletions NVEncC_Options.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2565,13 +2565,13 @@ Apply custom shaders in the specified path using [libplacebo](https://code.video
Output resolution of the filter.

- colorsystem=<string>
Color system to use. Default: bt709.
Color system to use. Default: auto detect.
```
unknown, bt601, bt709, smpte240m, bt2020nc, bt2020c, bt2100pq, bt2100hlg, dolbyvision, ycgco, rgb, xyz
```

- transfer=<string>
Output transfer function.
Output transfer function. Default: auto detect.
```
unknown, srgb, bt1886, linear,
gamma18, gamma20, gamma22, gamma24, gamma26, gamma28,
Expand Down
4 changes: 2 additions & 2 deletions NVEncC_Options.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2623,13 +2623,13 @@ nppc64_10.dll, nppif64_10.dll, nppig64_10.dllをNVEncC64と同じフォルダに
フィルタの出力解像度。

- colorsystem=<string>
使用する色空間を指定。デフォルトはbt709
使用する色空間を指定。デフォルトでは入力ファイルから自動的に設定される
```
unknown, bt601, bt709, smpte240m, bt2020nc, bt2020c, bt2100pq, bt2100hlg, dolbyvision, ycgco, rgb, xyz
```

- transfer=<string>
出力のトランスファ関数を指定。
出力のトランスファ関数を指定。デフォルトでは入力ファイルから自動的に設定される。
```
unknown, srgb, bt1886, linear,
gamma18, gamma20, gamma22, gamma24, gamma26, gamma28,
Expand Down
47 changes: 45 additions & 2 deletions NVEncCore/NVEncFilterLibplacebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1799,11 +1799,43 @@ RGY_ERR NVEncFilterLibplaceboShader::setLibplaceboParam(const NVEncFilterParam *
return RGY_ERR_UNKNOWN;
}

const auto vuiIn = prm->vui;
const auto inChromaFmt = RGY_CSP_CHROMA_FORMAT[param->frameIn.csp];
auto vui = prm->vui;
if (inChromaFmt == RGY_CHROMAFMT_RGB || inChromaFmt == RGY_CHROMAFMT_RGB_PACKED) {
vui.setIfUnsetUnknwonAuto(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
} else {
vui.setIfUnsetUnknwonAuto(VideoVUIInfo().to((CspMatrix)COLOR_VALUE_AUTO_RESOLUTION).to((CspColorprim)COLOR_VALUE_AUTO_RESOLUTION).to((CspTransfer)COLOR_VALUE_AUTO_RESOLUTION));
}
vui.apply_auto(VideoVUIInfo(), param->frameIn.height);

m_colorsystem = (pl_color_system)prm->shader.colorsystem;
if (m_colorsystem == PL_COLOR_SYSTEM_UNKNOWN) {
switch (vui.matrix) {
case RGY_MATRIX_RGB: m_colorsystem = PL_COLOR_SYSTEM_RGB; break;
case RGY_MATRIX_YCGCO: m_colorsystem = PL_COLOR_SYSTEM_YCGCO; break;
case RGY_MATRIX_BT470_BG:
case RGY_MATRIX_ST170_M: m_colorsystem = PL_COLOR_SYSTEM_BT_601; break;
case RGY_MATRIX_BT2020_CL: m_colorsystem = PL_COLOR_SYSTEM_BT_2020_C; break;
case RGY_MATRIX_BT2020_NCL: {
m_colorsystem = PL_COLOR_SYSTEM_BT_2020_NC;
if (vui.transfer == RGY_TRANSFER_ST2084) {
m_colorsystem = PL_COLOR_SYSTEM_BT_2100_PQ; break;
} else if (vui.transfer == RGY_TRANSFER_ARIB_B67) {
m_colorsystem = PL_COLOR_SYSTEM_BT_2100_HLG; break;
}
break;
}
case RGY_MATRIX_BT709:
default:
m_colorsystem = PL_COLOR_SYSTEM_BT_709; break;
}
}

m_transfer = (pl_color_transfer)(prm->shader.transfer);
m_range = (vuiIn.colorrange == RGY_COLORRANGE_FULL) ? PL_COLOR_LEVELS_FULL : PL_COLOR_LEVELS_LIMITED;
if (m_transfer == PL_COLOR_TRC_UNKNOWN) {
m_transfer = transfer_rgy_to_libplacebo(vui.transfer);
}
m_range = (vui.colorrange == RGY_COLORRANGE_FULL) ? PL_COLOR_LEVELS_FULL : PL_COLOR_LEVELS_LIMITED;
m_linear = prm->shader.linear;
m_chromaloc = chromaloc_rgy_to_libplacebo(prm->shader.chromaloc);

Expand Down Expand Up @@ -1889,6 +1921,17 @@ RGY_ERR NVEncFilterLibplaceboShader::procFrame(pl_tex texOut[RGY_MAX_PLANES], co
return RGY_ERR_NONE;
}

tstring NVEncFilterLibplaceboShader::printParams(const NVEncFilterParamLibplacebo *param) const {
auto prm = dynamic_cast<const NVEncFilterParamLibplaceboShader*>(param);
if (!prm) {
return param->print();
}
NVEncFilterParamLibplaceboShader current = *prm;
current.shader.colorsystem = (VppLibplaceboColorsystem)m_colorsystem;
current.shader.transfer = (VppLibplaceboToneMappingTransfer)m_transfer;
return current.print();
}

#else

NVEncFilterLibplaceboResample::NVEncFilterLibplaceboResample() : NVEncFilterDisabled() { m_name = _T("libplacebo-resample"); }
Expand Down
1 change: 1 addition & 0 deletions NVEncCore/NVEncFilterLibplacebo.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class NVEncFilterLibplaceboShader : public NVEncFilterLibplacebo {

virtual RGY_CSP getTextureCsp(const RGY_CSP csp) override;
virtual CUDAInteropDataFormat getTextureDataFormat([[maybe_unused]] const RGY_CSP csp) override;
virtual tstring printParams(const NVEncFilterParamLibplacebo *prm) const override;

std::unique_ptr<pl_hook, RGYLibplaceboDeleter<const pl_hook*>> m_shader;
pl_color_system m_colorsystem;
Expand Down
2 changes: 1 addition & 1 deletion NVEncCore/rgy_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9159,7 +9159,7 @@ tstring gen_cmd_help_vpp() {
) + print_list(list_vpp_libplacebo_colorsystem) + _T("\n");
str += strsprintf(_T("")
_T(" transfer=<string> Output transfer function.\n")
_T(" default: %s\n"), get_cx_desc(list_vpp_libplacebo_tone_mapping_transfer, FILTER_DEFAULT_LIBPLACEBO_SHADER_TRANSFER)
_T(" default: auto detect\n")
) + print_list(list_vpp_libplacebo_tone_mapping_transfer) + _T("\n");
str += strsprintf(_T("")
_T(" resampler=<string> Filter function to use when resample is required.\n")
Expand Down
3 changes: 3 additions & 0 deletions NVEncCore/rgy_libplacebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ RGYLibplaceboLoader::RGYLibplaceboLoader() :
m_pl_vulkan_release_ex(nullptr),
m_pl_vulkan_wrap(nullptr),
#endif
m_pl_gpu_finish(nullptr),
m_pl_tex_destroy(nullptr),
m_pl_tex_recreate(nullptr),
m_pl_log_create(nullptr),
Expand Down Expand Up @@ -136,6 +137,8 @@ bool RGYLibplaceboLoader::load() {
if (!loadFunc("pl_tex_destroy", (void**)&m_pl_tex_destroy)) return false;
if (!loadFunc("pl_tex_recreate", (void**)&m_pl_tex_recreate)) return false;

if (!loadFunc("pl_gpu_finish", (void**)&m_pl_gpu_finish)) return false;

char pl_log_create_str[256] = { 0 };
sprintf_s(pl_log_create_str, "pl_log_create_%d", PL_API_VER);
loadFunc(pl_log_create_str, (void**)&m_pl_log_create);
Expand Down
3 changes: 3 additions & 0 deletions NVEncCore/rgy_libplacebo.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class RGYLibplaceboLoader {
decltype(&pl_tex_destroy) m_pl_tex_destroy;
decltype(&pl_tex_recreate) m_pl_tex_recreate;

decltype(&pl_gpu_finish) m_pl_gpu_finish;

decltype(&pl_log_create) m_pl_log_create;
decltype(&pl_log_destroy) m_pl_log_destroy;

Expand Down Expand Up @@ -151,6 +153,7 @@ class RGYLibplaceboLoader {
#endif
auto p_tex_destroy() const { return m_pl_tex_destroy; }
auto p_tex_recreate() const { return m_pl_tex_recreate; }
auto p_gpu_finish() const { return m_pl_gpu_finish; }
auto p_log_create() const { return m_pl_log_create; }
auto p_log_destroy() const { return m_pl_log_destroy; }
auto p_dispatch_create() const { return m_pl_dispatch_create; }
Expand Down
2 changes: 1 addition & 1 deletion NVEncCore/rgy_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ RGY_ERR initWriters(
writerPrm.chapterNoTrim = common->chapterNoTrim;
writerPrm.attachments = common->attachmentSource;
writerPrm.hdrMetadataIn = hdrMetadataIn;
writerPrm.hdr10plusMetadataCopy = common->hdr10plusMetadataCopy;
writerPrm.hdr10plusMetadataCopy = common->hdr10plusMetadataCopy || common->dynamicHdr10plusJson.length() > 0;
writerPrm.doviRpu = doviRpu;
writerPrm.doviRpuMetadataCopy = common->doviRpuMetadataCopy;
writerPrm.doviProfile = common->doviProfile;
Expand Down
2 changes: 1 addition & 1 deletion NVEncCore/rgy_prm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ tstring VppLibplaceboShader::print() const {
str += strsprintf(_T("resampler=%s, "), get_cx_desc(list_vpp_resize, (int)resize_algo));
str += strsprintf(_T("colorsystem=%s, "), get_cx_desc(list_vpp_libplacebo_colorsystem, (int)colorsystem));
str += strsprintf(_T("transfer=%s, "), get_cx_desc(list_vpp_libplacebo_tone_mapping_transfer, (int)transfer));
str += strsprintf(_T("chromaloc=%s, "), get_cx_desc(list_chromaloc_str, (int)chromaloc));
//str += strsprintf(_T("chromaloc=%s, "), get_cx_desc(list_chromaloc_str, (int)chromaloc));
str += strsprintf(_T("radius=%.2f, "), radius);
str += strsprintf(_T("clamp=%.2f, "), clamp_);
str += strsprintf(_T("taper=%.2f, "), taper);
Expand Down
1 change: 1 addition & 0 deletions NVEncCore/rgy_prm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ enum class VppLibplaceboColorsystem {
};

const CX_DESC list_vpp_libplacebo_colorsystem[] = {
{ _T("auto"), (int)VppLibplaceboColorsystem::UNKNOWN },
{ _T("unknown"), (int)VppLibplaceboColorsystem::UNKNOWN },
{ _T("bt601"), (int)VppLibplaceboColorsystem::BT_601 },
{ _T("bt709"), (int)VppLibplaceboColorsystem::BT_709 },
Expand Down
6 changes: 3 additions & 3 deletions NVEncCore/rgy_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#ifndef __RGY_CONFIG_H__
#define __RGY_CONFIG_H__

#define VER_FILEVERSION 0,7,71,0
#define VER_STR_FILEVERSION "7.71"
#define VER_STR_FILEVERSION_TCHAR _T("7.71")
#define VER_FILEVERSION 0,7,72,0
#define VER_STR_FILEVERSION "7.72"
#define VER_STR_FILEVERSION_TCHAR _T("7.72")

#ifdef _M_IX86
#define BUILD_ARCH_STR _T("x86")
Expand Down
4 changes: 4 additions & 0 deletions NVEncCore/rgy_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ RGYVulkanFuncs::RGYVulkanFuncs() :
vkWaitForFences(nullptr),
vkCreateSemaphore(nullptr),
vkDestroySemaphore(nullptr),
vkWaitSemaphores(nullptr),
vkSignalSemaphore(nullptr),
vkCreateEvent(nullptr),
vkDestroyEvent(nullptr),
vkGetEventStatus(nullptr),
Expand Down Expand Up @@ -270,6 +272,8 @@ int RGYVulkanFuncs::init() {
LOAD(vkWaitForFences);
LOAD(vkCreateSemaphore);
LOAD(vkDestroySemaphore);
LOAD(vkWaitSemaphores);
LOAD(vkSignalSemaphore);
LOAD(vkCreateEvent);
LOAD(vkDestroyEvent);
LOAD(vkGetEventStatus);
Expand Down
2 changes: 2 additions & 0 deletions NVEncCore/rgy_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class RGYVulkanFuncs {
PFN_vkWaitForFences vkWaitForFences;
PFN_vkCreateSemaphore vkCreateSemaphore;
PFN_vkDestroySemaphore vkDestroySemaphore;
PFN_vkWaitSemaphores vkWaitSemaphores;
PFN_vkSignalSemaphore vkSignalSemaphore;
PFN_vkCreateEvent vkCreateEvent;
PFN_vkDestroyEvent vkDestroyEvent;
PFN_vkGetEventStatus vkGetEventStatus;
Expand Down

0 comments on commit a360e50

Please sign in to comment.