From fb4ef7b161e2dcb6091691f9ee589c6580d15113 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Wed, 9 Feb 2022 10:24:26 +0100 Subject: [PATCH] SubtitleProvider: Export additional color information --- decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp | 13 +++++++++++++ decoder/LAVVideo/subtitles/LAVSubtitleProvider.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp index 0127c0ee8..5f66629ef 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp +++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp @@ -36,6 +36,8 @@ static const SubRenderOption options[] = { { "name", OFFSET(name), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, { "version", OFFSET(version), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, { "yuvMatrix", OFFSET(yuvMatrix), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, + { "outputLevels", OFFSET(outputLevels), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, + { "colorPrimaries", OFFSET(primaries), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, { "isBitmap", OFFSET(isBitmap), SROPT_TYPE_BOOL, SROPT_FLAG_READONLY }, { "isMovable", OFFSET(isMovable), SROPT_TYPE_BOOL, SROPT_FLAG_READONLY }, { "combineBitmaps", OFFSET(combineBitmaps), SROPT_TYPE_BOOL, 0 }, @@ -43,6 +45,9 @@ static const SubRenderOption options[] = { }; // clang-format on +#define COLOR_PRIM_NTSC _T("601_525") +#define COLOR_PRIM_PAL _T("601_625") + CLAVSubtitleProvider::CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsumer *pConsumer) : CSubRenderOptionsImpl(::options, &context) , CUnknown(L"CLAVSubtitleProvider", nullptr) @@ -55,6 +60,8 @@ CLAVSubtitleProvider::CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsu context.name = TEXT(LAV_VIDEO); context.version = TEXT(LAV_VERSION_STR); context.yuvMatrix = _T("None"); + context.outputLevels = _T("PC"); + context.primaries = COLOR_PRIM_NTSC; context.isBitmap = true; context.isMovable = true; AddRef(); @@ -136,6 +143,12 @@ STDMETHODIMP CLAVSubtitleProvider::RequestFrame(REFERENCE_TIME start, REFERENCE_ } } + // update primaries based on the video dimensions + if (m_pAVCtx->height == 480) + this->context.primaries = COLOR_PRIM_NTSC; + else if (m_pAVCtx->height == 576) + this->context.primaries = COLOR_PRIM_PAL; + RECT outputRect; ::SetRect(&outputRect, 0, 0, m_pAVCtx->width, m_pAVCtx->height); subtitleFrame->SetOutputRect(outputRect); diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h index defb1c59b..bc9a90d58 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h +++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h @@ -29,6 +29,8 @@ typedef struct LAVSubtitleProviderContext LPWSTR name; ///< name of the Provider LPWSTR version; ///< Version of the Provider LPWSTR yuvMatrix; ///< YUV Matrix + LPWSTR outputLevels; ///< RGB output levels + LPWSTR primaries; ///< Color Primaries bool combineBitmaps; ///< Control if the provider combines all bitmaps into one bool isBitmap;