Skip to content

Commit

Permalink
Add BT.2020 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
madshi authored and Cyberbeing committed Sep 27, 2018
1 parent 1b6f195 commit 4804cf2
Show file tree
Hide file tree
Showing 18 changed files with 399 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/filters/transform/vsfilter/Copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
//color space
tmp.Format( _T("Colorspace: %ls %ls (%ls)\n"),
ColorConvTable::GetDefaultRangeType()==ColorConvTable::RANGE_PC ? _T("PC"):_T("TV"),
ColorConvTable::GetDefaultYUVType()==ColorConvTable::BT601 ? _T("BT.601"):_T("BT.709"),
ColorConvTable::GetDefaultYUVType()==ColorConvTable::BT601 ? _T("BT.601"): (ColorConvTable::GetDefaultYUVType()==ColorConvTable::BT709 ? _T("BT.709"):_T("BT.2020")),
m_xy_int_opt[INT_COLOR_SPACE]==CDirectVobSub::YuvMatrix_AUTO ? _T("Auto") :
m_xy_int_opt[INT_COLOR_SPACE]==CDirectVobSub::GUESS ? _T("Guessed") : _T("Forced") );
msg += tmp;
Expand Down
16 changes: 16 additions & 0 deletions src/filters/transform/vsfilter/DirectVobSub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ CDirectVobSub::CDirectVobSub( const Option *options, CCritSec * pLock )
if( m_xy_int_opt[INT_COLOR_SPACE]!=YuvMatrix_AUTO &&
m_xy_int_opt[INT_COLOR_SPACE]!=BT_601 &&
m_xy_int_opt[INT_COLOR_SPACE]!=BT_709 &&
m_xy_int_opt[INT_COLOR_SPACE]!=BT_2020 &&
m_xy_int_opt[INT_COLOR_SPACE]!=GUESS)
{
m_xy_int_opt[INT_COLOR_SPACE] = YuvMatrix_AUTO;
Expand Down Expand Up @@ -1258,6 +1259,10 @@ CDirectVobSub::CDirectVobSub( const Option *options, CCritSec * pLock )
{
m_xy_str_opt[STRING_PGS_YUV_MATRIX] = _T("BT709");
}
else if (str_pgs_yuv_setting.Right(4).CompareNoCase(_T("2020"))==0)
{
m_xy_str_opt[STRING_PGS_YUV_MATRIX] = _T("BT2020");
}
else
{
m_xy_str_opt[STRING_PGS_YUV_MATRIX] = _T("GUESS");
Expand Down Expand Up @@ -1477,6 +1482,10 @@ CDVS4XySubFilter::CDVS4XySubFilter( const Option *options, CCritSec * pLock )
{
m_xy_int_opt[INT_COLOR_SPACE] = DirectVobSubImpl::BT_709;
}
else if (str_color_space.Right(4).CompareNoCase(_T("2020"))==0)
{
m_xy_int_opt[INT_COLOR_SPACE] = DirectVobSubImpl::BT_2020;
}
else if (str_color_space.Right(5).CompareNoCase(_T("GUESS"))==0)
{
m_xy_int_opt[INT_COLOR_SPACE] = DirectVobSubImpl::GUESS;
Expand Down Expand Up @@ -1614,6 +1623,10 @@ CDVS4XySubFilter::CDVS4XySubFilter( const Option *options, CCritSec * pLock )
{
m_xy_str_opt[STRING_PGS_YUV_MATRIX] = _T("BT709");
}
else if (str_pgs_yuv_setting.Right(4).CompareNoCase(_T("2020"))==0)
{
m_xy_str_opt[STRING_PGS_YUV_MATRIX] = _T("BT2020");
}
else
{
m_xy_str_opt[STRING_PGS_YUV_MATRIX] = _T("GUESS");
Expand Down Expand Up @@ -1706,6 +1719,9 @@ STDMETHODIMP CDVS4XySubFilter::UpdateRegistry()
case DirectVobSubImpl::BT_709:
str_color_space += _T(".BT709");
break;
case DirectVobSubImpl::BT_2020:
str_color_space += _T(".BT2020");
break;
case DirectVobSubImpl::GUESS:
str_color_space += _T(".GUESS");
break;
Expand Down
1 change: 1 addition & 0 deletions src/filters/transform/vsfilter/DirectVobSub.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DirectVobSubImpl : public IDirectVobSub2, public XyOptionsImpl, public IFi
YuvMatrix_AUTO = 0
,BT_601
,BT_709
,BT_2020
,GUESS
};
enum YuvRange
Expand Down
14 changes: 14 additions & 0 deletions src/filters/transform/vsfilter/DirectVobSubFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,9 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
case CSimpleTextSubtitle::YCbCrMatrix_BT709:
m_video_yuv_matrix_decided_by_sub = ColorConvTable::BT709;
break;
case CSimpleTextSubtitle::YCbCrMatrix_BT2020:
m_video_yuv_matrix_decided_by_sub = ColorConvTable::BT2020;
break;
default:
m_video_yuv_matrix_decided_by_sub = ColorConvTable::NONE;
break;
Expand Down Expand Up @@ -1753,6 +1756,10 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
{
color_type = CompositionObject::YUV_Rec709;
}
else if ( m_xy_str_opt[STRING_PGS_YUV_MATRIX].CompareNoCase(_T("BT2020"))==0 )
{
color_type = CompositionObject::YUV_Rec2020;
}

m_video_yuv_matrix_decided_by_sub = (m_w > m_bt601Width || m_h > m_bt601Height) ? ColorConvTable::BT709 :
ColorConvTable::BT601;
Expand Down Expand Up @@ -2132,6 +2139,10 @@ void CDirectVobSubFilter::SetYuvMatrix()
{
yuv_matrix = ColorConvTable::BT709;
}
else if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(4).CompareNoCase(L"2020")==0)
{
yuv_matrix = ColorConvTable::BT2020;
}
else
{
XY_LOG_WARN(L"Can NOT get useful YUV range from consumer:"<<m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].GetString());
Expand All @@ -2150,6 +2161,9 @@ void CDirectVobSubFilter::SetYuvMatrix()
case CDirectVobSub::BT_709:
yuv_matrix = ColorConvTable::BT709;
break;
case CDirectVobSub::BT_2020:
yuv_matrix = ColorConvTable::BT2020;
break;
case CDirectVobSub::GUESS:
default:
yuv_matrix = (m_w > m_bt601Width || m_h > m_bt601Height) ? ColorConvTable::BT709 : ColorConvTable::BT601;
Expand Down
6 changes: 6 additions & 0 deletions src/filters/transform/vsfilter/DirectVobSubPropPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ void CDVSMiscPPage::UpdateControlData(bool fSave)
if( m_colorSpace != CDirectVobSub::YuvMatrix_AUTO &&
m_colorSpace != CDirectVobSub::BT_601 &&
m_colorSpace != CDirectVobSub::BT_709 &&
m_colorSpace != CDirectVobSub::BT_2020 &&
m_colorSpace != CDirectVobSub::GUESS )
{
m_colorSpace = CDirectVobSub::YuvMatrix_AUTO;
Expand All @@ -883,6 +884,8 @@ void CDVSMiscPPage::UpdateControlData(bool fSave)
m_colorSpaceDropList.SetItemData( CDirectVobSub::BT_601, CDirectVobSub::BT_601 );
m_colorSpaceDropList.AddString( CString(_T("BT.709")) );
m_colorSpaceDropList.SetItemData( CDirectVobSub::BT_709, CDirectVobSub::BT_709);
m_colorSpaceDropList.AddString( CString(_T("BT.2020")) );
m_colorSpaceDropList.SetItemData( CDirectVobSub::BT_2020, CDirectVobSub::BT_2020);
m_colorSpaceDropList.AddString( CString(_T("Guess")) );
m_colorSpaceDropList.SetItemData( CDirectVobSub::GUESS, CDirectVobSub::GUESS );
m_colorSpaceDropList.SetCurSel( m_colorSpace );
Expand Down Expand Up @@ -2243,6 +2246,7 @@ void CXySubFilterMorePPage::UpdateControlData(bool fSave)
if( m_yuv_matrix != CDirectVobSub::YuvMatrix_AUTO &&
m_yuv_matrix != CDirectVobSub::BT_601 &&
m_yuv_matrix != CDirectVobSub::BT_709 &&
m_yuv_matrix != CDirectVobSub::BT_2020 &&
m_yuv_matrix != CDirectVobSub::GUESS )
{
m_yuv_matrix = CDirectVobSub::YuvMatrix_AUTO;
Expand All @@ -2254,6 +2258,8 @@ void CXySubFilterMorePPage::UpdateControlData(bool fSave)
m_combo_yuv_matrix.SetItemData( CDirectVobSub::BT_601, CDirectVobSub::BT_601 );
m_combo_yuv_matrix.AddString( CString(_T("BT.709")) );
m_combo_yuv_matrix.SetItemData( CDirectVobSub::BT_709, CDirectVobSub::BT_709);
m_combo_yuv_matrix.AddString( CString(_T("BT.2020")) );
m_combo_yuv_matrix.SetItemData( CDirectVobSub::BT_2020, CDirectVobSub::BT_2020);
m_combo_yuv_matrix.AddString( CString(_T("Guess")) );
m_combo_yuv_matrix.SetItemData( CDirectVobSub::GUESS, CDirectVobSub::GUESS );
m_combo_yuv_matrix.SetCurSel( m_yuv_matrix );
Expand Down
6 changes: 6 additions & 0 deletions src/filters/transform/vsfilter/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class CFilter : public CUnknown, public CDirectVobSub, public CAMThread, public
case CSimpleTextSubtitle::YCbCrMatrix_BT709:
yuv_matrix = ColorConvTable::BT709;
break;
case CSimpleTextSubtitle::YCbCrMatrix_BT2020:
yuv_matrix = ColorConvTable::BT2020;
break;
case CSimpleTextSubtitle::YCbCrMatrix_AUTO:
default:
yuv_matrix = ColorConvTable::BT601;
Expand All @@ -141,6 +144,9 @@ class CFilter : public CUnknown, public CDirectVobSub, public CAMThread, public
case CDirectVobSub::BT_709:
yuv_matrix = ColorConvTable::BT709;
break;
case CDirectVobSub::BT_2020:
yuv_matrix = ColorConvTable::BT2020;
break;
case CDirectVobSub::GUESS:
yuv_matrix = (dst.w > m_bt601Width || dst.h > m_bt601Height) ? ColorConvTable::BT709 : ColorConvTable::BT601;
break;
Expand Down
33 changes: 33 additions & 0 deletions src/filters/transform/vsfilter/xy_sub_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,10 @@ void XySubFilter::SetYuvMatrix()
{
yuv_matrix = ColorConvTable::BT709;
}
else if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(4).CompareNoCase(L"2020")==0)
{
yuv_matrix = ColorConvTable::BT2020;
}
else
{
XY_LOG_WARN(L"Can NOT get useful YUV range from consumer:"<<m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].GetString());
Expand All @@ -1333,6 +1337,9 @@ void XySubFilter::SetYuvMatrix()
case DirectVobSubImpl::BT_709:
yuv_matrix = ColorConvTable::BT709;
break;
case DirectVobSubImpl::BT_2020:
yuv_matrix = ColorConvTable::BT2020;
break;
case DirectVobSubImpl::GUESS:
default:
if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(3).CompareNoCase(L"601")==0)
Expand All @@ -1343,6 +1350,10 @@ void XySubFilter::SetYuvMatrix()
{
yuv_matrix = ColorConvTable::BT709;
}
else if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(4).CompareNoCase(L"2020")==0)
{
yuv_matrix = ColorConvTable::BT2020;
}
else
{
XY_LOG_WARN(L"Can NOT get useful YUV range from consumer:"<<m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].GetString());
Expand Down Expand Up @@ -1411,6 +1422,9 @@ void XySubFilter::SetYuvMatrix()
else if (yuv_matrix==ColorConvTable::BT709) {
m_xy_str_opt[STRING_YUV_MATRIX] += L".709";
}
else if (yuv_matrix==ColorConvTable::BT2020) {
m_xy_str_opt[STRING_YUV_MATRIX] += L".2020";
}
else {
XY_LOG_WARN("This is unexpected."<<XY_LOG_VAR_2_STR(yuv_matrix));
m_xy_str_opt[STRING_YUV_MATRIX] = L"None";
Expand Down Expand Up @@ -1453,6 +1467,10 @@ void XySubFilter::SetYuvMatrix()
{
m_xy_str_opt[STRING_YUV_MATRIX] += L"709";
}
else if ( m_xy_str_opt[STRING_PGS_YUV_MATRIX].CompareNoCase(_T("BT2020"))==0 )
{
m_xy_str_opt[STRING_YUV_MATRIX] += L"2020";
}
else
{
if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(3).CompareNoCase(L"601")==0)
Expand All @@ -1463,6 +1481,10 @@ void XySubFilter::SetYuvMatrix()
{
m_xy_str_opt[STRING_YUV_MATRIX] += L"709";
}
else if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(4).CompareNoCase(L"2020")==0)
{
m_xy_str_opt[STRING_YUV_MATRIX] += L"2020";
}
else
{
XY_LOG_WARN(L"Can NOT get useful YUV range from consumer:"<<m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].GetString()
Expand Down Expand Up @@ -1739,6 +1761,9 @@ void XySubFilter::SetSubtitle( ISubStream* pSubStream, bool fApplyDefStyle /*= t
case CSimpleTextSubtitle::YCbCrMatrix_BT709:
m_video_yuv_matrix_decided_by_sub = ColorConvTable::BT709;
break;
case CSimpleTextSubtitle::YCbCrMatrix_BT2020:
m_video_yuv_matrix_decided_by_sub = ColorConvTable::BT2020;
break;
default:
m_video_yuv_matrix_decided_by_sub = ColorConvTable::NONE;
break;
Expand Down Expand Up @@ -1796,6 +1821,10 @@ void XySubFilter::SetSubtitle( ISubStream* pSubStream, bool fApplyDefStyle /*= t
{
color_type = CompositionObject::YUV_Rec709;
}
else if ( m_xy_str_opt[STRING_PGS_YUV_MATRIX].CompareNoCase(_T("BT2020"))==0 )
{
color_type = CompositionObject::YUV_Rec2020;
}
else
{
if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(3).CompareNoCase(L"601")==0)
Expand All @@ -1806,6 +1835,10 @@ void XySubFilter::SetSubtitle( ISubStream* pSubStream, bool fApplyDefStyle /*= t
{
color_type = CompositionObject::YUV_Rec709;
}
else if (m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].Right(4).CompareNoCase(L"2020")==0)
{
color_type = CompositionObject::YUV_Rec2020;
}
else
{
XY_LOG_WARN(L"Can NOT get useful YUV matrix from consumer:"<<m_xy_str_opt[STRING_CONSUMER_YUV_MATRIX].GetString());
Expand Down
5 changes: 4 additions & 1 deletion src/filters/transform/vsfilter/xy_sub_filter_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,9 @@ void XySubFilterConsumer::SetYuvMatrix()
case CDirectVobSub::BT_709:
yuv_matrix = ColorConvTable::BT709;
break;
case CDirectVobSub::BT_2020:
yuv_matrix = ColorConvTable::BT2020;
break;
case CDirectVobSub::GUESS:
default:
yuv_matrix = (m_w > m_bt601Width || m_h > m_bt601Height) ? ColorConvTable::BT709 : ColorConvTable::BT601;
Expand Down Expand Up @@ -1270,7 +1273,7 @@ void XySubFilterConsumer::PrintMessages(BYTE* pOut)
//color space
tmp.Format( _T("Colorspace: %ls %ls (%ls)\n"),
ColorConvTable::GetDefaultRangeType()==ColorConvTable::RANGE_PC ? _T("PC"):_T("TV"),
ColorConvTable::GetDefaultYUVType()==ColorConvTable::BT601 ? _T("BT.601"):_T("BT.709"),
ColorConvTable::GetDefaultYUVType()==ColorConvTable::BT601 ? _T("BT.601"):(ColorConvTable::GetDefaultYUVType()==ColorConvTable::BT2020 ? _T("BT.2020"):_T("BT.709")),
m_xy_int_opt[INT_COLOR_SPACE]==CDirectVobSub::YuvMatrix_AUTO ? _T("Auto") :
m_xy_int_opt[INT_COLOR_SPACE]==CDirectVobSub::GUESS ? _T("Guessed") : _T("Forced") );
msg += tmp;
Expand Down
Loading

0 comments on commit 4804cf2

Please sign in to comment.