diff --git a/_studio/mfx_lib/encode_hw/mjpeg/include/mfx_mjpeg_encode_hw.h b/_studio/mfx_lib/encode_hw/mjpeg/include/mfx_mjpeg_encode_hw.h index a6cd292fa3..428ec0d84d 100644 --- a/_studio/mfx_lib/encode_hw/mjpeg/include/mfx_mjpeg_encode_hw.h +++ b/_studio/mfx_lib/encode_hw/mjpeg/include/mfx_mjpeg_encode_hw.h @@ -102,6 +102,16 @@ class MFXVideoENCODEMJPEG_HW : public VideoENCODE { MFX_RETURN(MFX_ERR_UNDEFINED_BEHAVIOR); } + mfxU16 GetMemType(mfxVideoParam par) override + { + mfxU16 memory_type = mfxU16(par.IOPattern == MFX_IOPATTERN_IN_SYSTEM_MEMORY ? MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_SYSTEM_MEMORY : MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_DXVA2_DECODER_TARGET); + + if (par.mfx.FrameInfo.FourCC == MFX_FOURCC_BGR4) + memory_type |= MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET; + + return memory_type; + } + MFX_PROPAGATE_GetSurface_VideoENCODE_Definition; protected: diff --git a/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw.cpp b/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw.cpp index 332f637288..b3466d965e 100644 --- a/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw.cpp +++ b/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw.cpp @@ -213,7 +213,12 @@ mfxStatus MFXVideoENCODEMJPEG_HW::QueryImplsDescription( ah.PushBack(memCaps.ColorFormats) = MFX_FOURCC_YUY2; ah.PushBack(memCaps.ColorFormats) = MFX_FOURCC_RGB4; ah.PushBack(memCaps.ColorFormats) = MFX_FOURCC_BGR4; +#if defined(LINUX) + ah.PushBack(memCaps.ColorFormats) = MFX_FOURCC_YUV400; + memCaps.NumColorFormats = 6; +#else memCaps.NumColorFormats = 5; +#endif ah.PushBack(profileCaps.MemDesc); profileCaps.MemDesc[1] = profileCaps.MemDesc[0]; @@ -392,6 +397,7 @@ mfxStatus MFXVideoENCODEMJPEG_HW::Query(VideoCORE * core, mfxVideoParam *in, mfx if ((fourCC == 0 && chromaFormat == 0) || (fourCC == MFX_FOURCC_NV12 && (chromaFormat == MFX_CHROMAFORMAT_YUV420 || chromaFormat == MFX_CHROMAFORMAT_YUV400)) || + (fourCC == MFX_FOURCC_YUV400 && chromaFormat == MFX_CHROMAFORMAT_YUV400) || (fourCC == MFX_FOURCC_YUY2 && chromaFormat == MFX_CHROMAFORMAT_YUV422H) || ((fourCC == MFX_FOURCC_RGB4 || fourCC == MFX_FOURCC_BGR4) && chromaFormat == MFX_CHROMAFORMAT_YUV444)) { @@ -691,6 +697,7 @@ mfxStatus MFXVideoENCODEMJPEG_HW::Init(mfxVideoParam *par) mfxU16 doubleBytesPerPx = 0; switch(m_vParam.mfx.FrameInfo.FourCC) { + case MFX_FOURCC_YUV400: case MFX_FOURCC_NV12: case MFX_FOURCC_YV12: doubleBytesPerPx = 3; diff --git a/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw_utils.cpp b/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw_utils.cpp index b1ab556e5e..469da22c6f 100644 --- a/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw_utils.cpp +++ b/_studio/mfx_lib/encode_hw/mjpeg/src/mfx_mjpeg_encode_hw_utils.cpp @@ -100,6 +100,7 @@ mfxStatus MfxHwMJpegEncode::CheckJpegParam(VideoCORE *core, mfxVideoParam & par, mfxF64 BytesPerPx = 0; switch (par.mfx.FrameInfo.FourCC) { + case MFX_FOURCC_YUV400: case MFX_FOURCC_NV12: case MFX_FOURCC_YV12: BytesPerPx = 1.5; @@ -286,7 +287,7 @@ mfxStatus ExecuteBuffers::Init(mfxVideoParam const *par, mfxEncodeCtrl const * c m_pps.num_components = 3; else if (fourCC == MFX_FOURCC_YUY2 && chromaFormat == MFX_CHROMAFORMAT_YUV422H) m_pps.num_components = 3; - else if (fourCC == MFX_FOURCC_NV12 && chromaFormat == MFX_CHROMAFORMAT_YUV400) + else if ((fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUV400) && chromaFormat == MFX_CHROMAFORMAT_YUV400) m_pps.num_components = 1; else if ((fourCC == MFX_FOURCC_RGB4 || fourCC == MFX_FOURCC_BGR4) && chromaFormat == MFX_CHROMAFORMAT_YUV444) m_pps.num_components = 3; diff --git a/_studio/mfx_lib/shared/src/libmfxsw_encode.cpp b/_studio/mfx_lib/shared/src/libmfxsw_encode.cpp index fe85c64c56..92420ad235 100644 --- a/_studio/mfx_lib/shared/src/libmfxsw_encode.cpp +++ b/_studio/mfx_lib/shared/src/libmfxsw_encode.cpp @@ -510,7 +510,7 @@ static mfxStatus SetupCache(mfxSession session, const mfxVideoParam& par) if (session->m_pCORE->IsExternalFrameAllocator()) return MFX_ERR_NONE; - mfxU16 memory_type = mfxU16(par.IOPattern == MFX_IOPATTERN_IN_SYSTEM_MEMORY ? MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_SYSTEM_MEMORY : MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_DXVA2_DECODER_TARGET); + mfxU16 memory_type = session->m_pENCODE->GetMemType(par); auto& pCache = session->m_pENCODE->m_pSurfaceCache; diff --git a/_studio/shared/include/mfxvideo++int.h b/_studio/shared/include/mfxvideo++int.h index aa39c49ebe..897b22fd26 100644 --- a/_studio/shared/include/mfxvideo++int.h +++ b/_studio/shared/include/mfxvideo++int.h @@ -451,6 +451,12 @@ class VideoENCODE return MFX_ERR_NONE; } + virtual + mfxU16 GetMemType(mfxVideoParam par) + { + return mfxU16(par.IOPattern == MFX_IOPATTERN_IN_SYSTEM_MEMORY ? MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_SYSTEM_MEMORY : MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_DXVA2_DECODER_TARGET); + } + virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf, mfxSurfaceHeader* import_surface) = 0; std::unique_ptr, std::function*)>> m_pSurfaceCache; diff --git a/_studio/shared/src/libmfx_allocator_vaapi.cpp b/_studio/shared/src/libmfx_allocator_vaapi.cpp index 40fa128b2e..e9207533b8 100644 --- a/_studio/shared/src/libmfx_allocator_vaapi.cpp +++ b/_studio/shared/src/libmfx_allocator_vaapi.cpp @@ -603,6 +603,7 @@ mfxStatus mfxDefaultAllocatorVAAPI::SetFrameData(const VAImage &va_image, mfxU32 frame_data.A = frame_data.R + 3; break; + case MFX_FOURCC_YUV400: case VA_FOURCC_P208: frame_data.Y = p_buffer + va_image.offsets[0]; break;