Implement Rec 601 Full Range support in SDLRenderer

This commit is contained in:
Cameron Gutman 2022-10-12 23:52:29 -05:00
parent 8d087ba5b1
commit 7a39daf179
2 changed files with 13 additions and 2 deletions

View file

@ -77,6 +77,7 @@ bool SdlRenderer::isPixelFormatSupported(int, AVPixelFormat pixelFormat)
switch (pixelFormat)
{
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUVJ420P:
case AV_PIX_FMT_NV12:
case AV_PIX_FMT_NV21:
return true;
@ -397,6 +398,7 @@ ReadbackRetry:
switch (frame->format)
{
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUVJ420P:
sdlFormat = SDL_PIXELFORMAT_YV12;
break;
case AV_PIX_FMT_CUDA:
@ -414,11 +416,19 @@ ReadbackRetry:
switch (colorspace)
{
case COLORSPACE_REC_709:
SDL_assert(!isFrameFullRange(frame));
SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_BT709);
break;
case COLORSPACE_REC_601:
default:
if (isFrameFullRange(frame)) {
// SDL's JPEG mode is Rec 601 Full Range
SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_JPEG);
}
else {
SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_BT601);
}
break;
default:
break;
}
@ -461,7 +471,7 @@ ReadbackRetry:
goto Exit;
#endif
}
else if (frame->format == AV_PIX_FMT_YUV420P) {
else if (frame->format == AV_PIX_FMT_YUV420P || frame->format == AV_PIX_FMT_YUVJ420P) {
SDL_UpdateYUVTexture(m_Texture, nullptr,
frame->data[0],
frame->linesize[0],

View file

@ -822,6 +822,7 @@ bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
// - AV_PIX_FMT_DRM_PRIME
// - AV_PIX_FMT_MMAL
// - AV_PIX_FMT_YUV420P
// - AV_PIX_FMT_YUVJ420P
// - AV_PIX_FMT_NV12
// - AV_PIX_FMT_NV21
{