diff --git a/lib/tlIO/NDIReadVideo.cpp b/lib/tlIO/NDIReadVideo.cpp index 2c290d85..9268093f 100644 --- a/lib/tlIO/NDIReadVideo.cpp +++ b/lib/tlIO/NDIReadVideo.cpp @@ -74,16 +74,8 @@ namespace tl DBG("P216"); // YCbCr color space using 4:2:2 in 16bpp. _avInputPixelFormat = AV_PIX_FMT_YUV422P16LE; - if (options.yuvToRGBConversion) - { - _avOutputPixelFormat = AV_PIX_FMT_RGB48; - _info.pixelType = image::PixelType::RGB_U16; - } - else - { - _avOutputPixelFormat = AV_PIX_FMT_YUV422P16LE; - _info.pixelType = image::PixelType::YUV_422P_U16; - } + _avOutputPixelFormat = AV_PIX_FMT_RGB48; + _info.pixelType = image::PixelType::RGB_U16; break; case NDIlib_FourCC_type_PA16: DBG("PA16"); @@ -119,17 +111,10 @@ namespace tl break; case NDIlib_FourCC_type_I420: DBG("I420"); + // @bug: this format is not supported by FFmpeg. It is YVU420P _avInputPixelFormat = AV_PIX_FMT_YUV420P; - if (options.yuvToRGBConversion) - { - _avOutputPixelFormat = AV_PIX_FMT_RGB24; - _info.pixelType = image::PixelType::RGB_U8; - } - else - { - _avOutputPixelFormat = _avInputPixelFormat; - _info.pixelType = image::PixelType::YUV_420P_U8; - } + _avOutputPixelFormat = _avInputPixelFormat; + _info.pixelType = image::PixelType::YUV_420P_U8; break; default: throw std::runtime_error("Unsupported pixel type"); @@ -275,6 +260,21 @@ namespace tl { throw std::runtime_error(string::Format("{0}: Cannot initialize sws context").arg(_fileName)); } + + int in_full, out_full, brightness, contrast, saturation; + const int *inv_table, *table; + + sws_getColorspaceDetails( + _swsContext, (int**)&inv_table, &in_full, + (int**)&table, &out_full, &brightness, &contrast, + &saturation); + + inv_table = sws_getCoefficients(AVCOL_SPC_RGB); + table = sws_getCoefficients(AVCOL_SPC_BT709); + + sws_setColorspaceDetails( + _swsContext, inv_table, in_full, table, out_full, + brightness, contrast, saturation); } }