From a876f3bd8d31ae47e4f8148ec89edef1eb5dee5f Mon Sep 17 00:00:00 2001 From: Vincent Cheah Beng Keat Date: Wed, 12 Jun 2024 10:58:13 +0800 Subject: [PATCH 3/9] Enable YUV400 JPEG Enc for linux vaapi only Upstream-Status: Backport [https://github.com/intel/libvpl-tools/commit/ef82b8a608999e56a2449937d1fa4cbee274d9ab] Signed-off-by: Lim Siew Hoon --- .../sample_encode/src/pipeline_encode.cpp | 28 +++++++++++++++---- .../sample_encode/src/sample_encode.cpp | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/legacy/sample_encode/src/pipeline_encode.cpp b/tools/legacy/sample_encode/src/pipeline_encode.cpp index cda607b..b29dc29 100644 --- a/tools/legacy/sample_encode/src/pipeline_encode.cpp +++ b/tools/legacy/sample_encode/src/pipeline_encode.cpp @@ -846,9 +846,15 @@ mfxStatus CEncodingPipeline::CheckHyperEncodeParams(mfxHyperMode hyperMode) { #endif mfxU32 CEncodingPipeline::FileFourCC2EncFourCC(mfxU32 fcc) { - // File reader automatically converts I420 and YV12 to NV12 - if (fcc == MFX_FOURCC_I420 || fcc == MFX_FOURCC_YV12) + // File reader automatically converts I420, YV12 to NV12 + // On windows, YUV400 is automatically converts to NV12. + if (fcc == MFX_FOURCC_I420 || fcc == MFX_FOURCC_YV12 +#if (defined(_WIN64) || defined(_WIN32)) + || fcc == MFX_FOURCC_YUV400 +#endif + ) { return MFX_FOURCC_NV12; + } else return fcc; } @@ -1652,11 +1658,21 @@ mfxStatus CEncodingPipeline::Init(sInputParams* pParams) { // FileReader can convert yv12->nv12 without vpp, when hw impl if (pParams->bUseHWLib) { - m_InputFourCC = (pParams->FileInputFourCC == MFX_FOURCC_I420) ? MFX_FOURCC_NV12 - : pParams->FileInputFourCC; + m_InputFourCC = ((pParams->FileInputFourCC == MFX_FOURCC_I420) +#if (defined(_WIN64) || defined(_WIN32)) + || (pParams->FileInputFourCC == MFX_FOURCC_YUV400) +#endif + ) + ? MFX_FOURCC_NV12 + : pParams->FileInputFourCC; - pParams->EncodeFourCC = - (pParams->EncodeFourCC == MFX_FOURCC_I420) ? MFX_FOURCC_NV12 : pParams->EncodeFourCC; + pParams->EncodeFourCC = ((pParams->EncodeFourCC == MFX_FOURCC_I420) +#if (defined(_WIN64) || defined(_WIN32)) + || (pParams->EncodeFourCC == MFX_FOURCC_YUV400) +#endif + ) + ? MFX_FOURCC_NV12 + : pParams->EncodeFourCC; } else { m_InputFourCC = pParams->FileInputFourCC; diff --git a/tools/legacy/sample_encode/src/sample_encode.cpp b/tools/legacy/sample_encode/src/sample_encode.cpp index 7c722ea..ed142f5 100644 --- a/tools/legacy/sample_encode/src/sample_encode.cpp +++ b/tools/legacy/sample_encode/src/sample_encode.cpp @@ -95,7 +95,7 @@ void PrintHelp(char* strAppName, const char* strErrorMessage, ...) { printf( " [-nv12|nv16|yuy2|uyvy|ayuv|rgb4|bgr4|p010|y210|y410|a2rgb10|p016|p210|y216|i010|i420] - input color format (by default YUV420 is expected).\n"); printf( - " [-yuv400] - input color format is YUV400 (grayscale) and will be converted to NV12 for encoding (JPEG only).\n"); + " [-yuv400] - input color format is YUV400 (grayscale) and will be converted to NV12 for encoding (JPEG Windows only).\n"); printf( " [-msb10] - 10-bit color format is expected to have data in Most Significant Bits of words.\n (LSB data placement is expected by default).\n This option also disables data shifting during file reading.\n"); printf( -- 2.43.2