Skip to content

Commit

Permalink
SubtitleProvider: Export additional color information
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Feb 9, 2022
1 parent 74697b7 commit fb4ef7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ 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 },
{ 0 }
};
// 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)
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions decoder/LAVVideo/subtitles/LAVSubtitleProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fb4ef7b

Please sign in to comment.