Skip to content

Commit

Permalink
NGX使用時にcolorspaceでcolorprimtransfer等が適切に設定されず、コンパイルエラーになるのを修正。 ( #626 )
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Oct 12, 2024
1 parent c1511a7 commit c7c97ee
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
8 changes: 4 additions & 4 deletions NVEncCore/NVEncFilterLibplacebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ RGY_ERR NVEncFilterLibplacebo::initCommon(shared_ptr<NVEncFilterParam> pParam) {
const auto inChromaFmt = RGY_CSP_CHROMA_FORMAT[pParam->frameIn.csp];
VideoVUIInfo vui = prm->vui;
if (inChromaFmt == RGY_CHROMAFMT_RGB || inChromaFmt == RGY_CHROMAFMT_RGB_PACKED) {
vui.setIfUnset(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
vui.setIfUnsetUnknwonAuto(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
} else {
vui.setIfUnset(VideoVUIInfo().to((CspMatrix)COLOR_VALUE_AUTO_RESOLUTION).to((CspColorprim)COLOR_VALUE_AUTO_RESOLUTION).to((CspTransfer)COLOR_VALUE_AUTO_RESOLUTION));
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(), pParam->frameIn.height);

Expand Down Expand Up @@ -1244,9 +1244,9 @@ RGY_ERR NVEncFilterLibplaceboToneMapping::setLibplaceboParam(const NVEncFilterPa
const auto inChromaFmt = RGY_CSP_CHROMA_FORMAT[param->frameIn.csp];
VideoVUIInfo vuiSrc = prm->vui;
if (inChromaFmt == RGY_CHROMAFMT_RGB || inChromaFmt == RGY_CHROMAFMT_RGB_PACKED) {
vuiSrc.setIfUnset(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
vuiSrc.setIfUnsetUnknwonAuto(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
} else {
vuiSrc.setIfUnset(VideoVUIInfo().to((CspMatrix)COLOR_VALUE_AUTO_RESOLUTION).to((CspColorprim)COLOR_VALUE_AUTO_RESOLUTION).to((CspTransfer)COLOR_VALUE_AUTO_RESOLUTION));
vuiSrc.setIfUnsetUnknwonAuto(VideoVUIInfo().to((CspMatrix)COLOR_VALUE_AUTO_RESOLUTION).to((CspColorprim)COLOR_VALUE_AUTO_RESOLUTION).to((CspTransfer)COLOR_VALUE_AUTO_RESOLUTION));
}
vuiSrc.apply_auto(VideoVUIInfo(), param->frameIn.height);

Expand Down
4 changes: 2 additions & 2 deletions NVEncCore/NVEncFilterNGX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ RGY_ERR NVEncFilterNGX::initCommon(shared_ptr<NVEncFilterParam> pParam) {
const auto inChromaFmt = RGY_CSP_CHROMA_FORMAT[pParam->frameIn.csp];
VideoVUIInfo vui = prm->vui;
if (inChromaFmt == RGY_CHROMAFMT_RGB || inChromaFmt == RGY_CHROMAFMT_RGB_PACKED) {
vui.setIfUnset(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
vui.setIfUnsetUnknwonAuto(VideoVUIInfo().to(RGY_MATRIX_RGB).to(RGY_PRIM_BT709).to(RGY_TRANSFER_IEC61966_2_1));
} else {
vui.setIfUnset(VideoVUIInfo().to((CspMatrix)COLOR_VALUE_AUTO_RESOLUTION).to((CspColorprim)COLOR_VALUE_AUTO_RESOLUTION).to((CspTransfer)COLOR_VALUE_AUTO_RESOLUTION));
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(), pParam->frameIn.height);

Expand Down
2 changes: 1 addition & 1 deletion NVEncCore/NVEncFilterTweak.cu
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ RGY_ERR NVEncFilterTweak::init(shared_ptr<NVEncFilterParam> pParam, shared_ptr<R
|| m_convC->GetFilterParam()->frameIn.csp != csp_rgb
|| m_convC->GetFilterParam()->frameOut.csp != pParam->frameIn.csp) {
VideoVUIInfo vui = prm->vui;
vui.setIfUnset(VideoVUIInfo().to((CspMatrix)COLOR_VALUE_AUTO_RESOLUTION).to((CspColorprim)COLOR_VALUE_AUTO_RESOLUTION).to((CspTransfer)COLOR_VALUE_AUTO_RESOLUTION));
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(), pParam->frameIn.height);

{
Expand Down
28 changes: 28 additions & 0 deletions NVEncCore/rgy_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,34 @@ struct VideoVUIInfo {
setDescriptPreset();
}

void setIfUnsetUnknwonAuto(const VideoVUIInfo &x) {
const auto defaultVUI = VideoVUIInfo();
if ( colorprim == RGY_PRIM_UNSPECIFIED
|| colorprim == RGY_PRIM_UNKNOWN
|| colorprim == RGY_PRIM_AUTO) {
colorprim = x.colorprim;
}
if ( matrix == RGY_MATRIX_UNSPECIFIED
|| matrix == RGY_MATRIX_AUTO) {
matrix = x.matrix;
}
if ( transfer == RGY_TRANSFER_UNKNOWN
|| transfer == RGY_TRANSFER_UNSPECIFIED
|| transfer == RGY_TRANSFER_AUTO) {
transfer = x.transfer;
}
if (format == defaultVUI.format) {
format = x.format;
}
if (colorrange == defaultVUI.colorrange) {
colorrange = x.colorrange;
}
if (chromaloc == defaultVUI.chromaloc) {
chromaloc = x.chromaloc;
}
setDescriptPreset();
}

bool operator==(const VideoVUIInfo &x) const {
return descriptpresent == x.descriptpresent
&& colorprim == x.colorprim
Expand Down

0 comments on commit c7c97ee

Please sign in to comment.