From 2147ca817c69fb58481365e71cdc719010c17a15 Mon Sep 17 00:00:00 2001 From: "Androniychuk, Pavel" Date: Fri, 1 Nov 2024 09:27:29 -0700 Subject: [PATCH] Bump version to 24.4.2 --- CMakeLists.txt | 2 +- README.md | 3 +- _studio/mfx_lib/CMakeLists.txt | 2 + _studio/mfx_lib/decode/CMakeLists.txt | 1 + .../decode/av1/src/mfx_av1_dec_decode.cpp | 17 +- .../decode/h265/src/mfx_h265_dec_decode.cpp | 4 +- .../mjpeg/include/mfx_mjpeg_dec_decode.h | 38 +- .../decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp | 342 +-- .../decode/mpeg2/hw/src/mfx_mpeg2_decode.cpp | 4 +- .../decode/vp8/src/mfx_vp8_dec_decode_hw.cpp | 18 +- .../decode/vp9/src/mfx_vp9_dec_decode_hw.cpp | 18 +- _studio/mfx_lib/encode_hw/CMakeLists.txt | 7 +- .../av1ehw_base_cdef.cpp} | 7 +- .../av1ehw_base_cdef.h} | 4 +- .../av1/agnostic/base/av1ehw_base_data.h | 2 + .../base/av1ehw_base_interpo_filter.cpp | 109 + .../base/av1ehw_base_interpo_filter.h | 52 + .../av1/linux/Xe2/av1ehw_xe2_lin.cpp | 4 +- .../linux/base/av1ehw_base_va_packer_lin.cpp | 6 +- .../h264/include/mfx_h264_encode_hw_utils.h | 2 + .../h264/src/mfx_h264_encode_hw_utils_new.cpp | 2 - .../hevc/agnostic/base/hevcehw_base_data.h | 1 + .../vp9/include/mfx_vp9_encode_hw_ddi.h | 1 + .../vp9/include/mfx_vp9_encode_hw_vaapi.h | 3 +- .../vp9/src/mfx_vp9_encode_hw_vaapi.cpp | 23 +- _studio/mfx_lib/ext/CMakeLists.txt | 1 + _studio/mfx_lib/pxp/CMakeLists.txt | 1 + _studio/mfx_lib/shared/src/libmfxsw.cpp | 3 +- _studio/mfx_lib/vpp/CMakeLists.txt | 1 + .../include/mfx_vpp_ai_frame_interpolation.h | 3 + _studio/mfx_lib/vpp/include/mfx_vpp_hw.h | 3 + .../src/mfx_vpp_ai_frame_interpolation.cpp | 60 +- _studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp | 23 +- .../mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp | 6 +- _studio/shared/enctools/CMakeLists.txt | 1 + .../shared/include/libmfx_allocator_vaapi.h | 25 +- _studio/shared/include/mfx_config.h | 1 + _studio/shared/src/libmfx_allocator.cpp | 13 +- _studio/shared/src/libmfx_allocator_vaapi.cpp | 14 +- _studio/shared/src/libmfx_core_vaapi.cpp | 60 +- _studio/shared/src/mfx_umc_alloc_wrapper.cpp | 7 +- .../h265_dec/include/umc_h265_dec_defs.h | 4 +- .../src/umc_h265_bitstream_headers.cpp | 8 +- .../h265_dec/src/umc_h265_task_supplier.cpp | 7 +- .../umc/codec/jpeg_common/src/bitstreamin.cpp | 14 +- .../umc/codec/jpeg_dec/include/dechtbl.h | 40 - .../umc/codec/jpeg_dec/include/decqtbl.h | 18 - .../umc/codec/jpeg_dec/include/jpegdec.h | 5 +- .../jpeg_dec/include/umc_mjpeg_mfx_decode.h | 8 - .../shared/umc/codec/jpeg_dec/src/dechtbl.cpp | 117 +- .../shared/umc/codec/jpeg_dec/src/decqtbl.cpp | 103 +- .../shared/umc/codec/jpeg_dec/src/jpegdec.cpp | 2468 +---------------- .../jpeg_dec/src/umc_mjpeg_mfx_decode.cpp | 222 +- .../src/umc_mjpeg_mfx_decode_base.cpp | 4 +- .../mpeg2_dec/src/umc_mpeg2_splitter.cpp | 2 +- .../codec/mpeg2_dec/src/umc_mpeg2_utils.cpp | 2 +- builder/BuildOptions.cmake | 10 - debian/changelog | 6 + debian/control | 2 +- 59 files changed, 472 insertions(+), 3462 deletions(-) rename _studio/mfx_lib/encode_hw/av1/agnostic/{Xe2/av1ehw_xe2_cdef.cpp => base/av1ehw_base_cdef.cpp} (98%) rename _studio/mfx_lib/encode_hw/av1/agnostic/{Xe2/av1ehw_xe2_cdef.h => base/av1ehw_base_cdef.h} (98%) create mode 100644 _studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.cpp create mode 100644 _studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 143464b34..8b4d8f28c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ endif() # Througout this project MFX_VERSION refers to uAPI version and MEDIA_VERSION refers to product version -set(MEDIA_VERSION 24.3.4) # auto-update +set(MEDIA_VERSION 24.4.2) # auto-update set(MEDIA_VERSION_STR "${MEDIA_VERSION}${MEDIA_VERSION_EXTRA}" CACHE STRING "" FORCE) if(CMAKE_SYSTEM_NAME MATCHES WindowsStore) diff --git a/README.md b/README.md index c56766c48..da918db9c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Intel® Video Processing Library (Intel® VPL) GPU Runtime is a Runtime implementation of [Intel® VPL](https://github.com/intel/libvpl/) API for Intel Gen GPUs. Runtime provides access to hardware-accelerated video decode, encode and filtering. -**Supported video encoders**: HEVC, AVC, MPEG-2, JPEG, VP9 +**Supported video encoders**: HEVC, AVC, MPEG-2, JPEG, VP9, AV1 **Supported video decoders**: HEVC, AVC, VP8, VP9, MPEG-2, VC1, JPEG, AV1, VVC **Supported video pre-processing filters**: Color Conversion, Deinterlace, Denoise, Resize, Rotate, Composition @@ -38,6 +38,7 @@ Intel® VPL Gen Runtime implementation supports the following hardware platforms - Alchemist(DG2)/ATSM - MTL/ARL (MTL: Meteor Lake, ARL-S/H: Arrow Lake) - LNL (Lunar Lake) +- BMG (Battlemage) # Dependencies Intel® VPL GPU Runtime depends on [LibVA](https://github.com/intel/libva/). diff --git a/_studio/mfx_lib/CMakeLists.txt b/_studio/mfx_lib/CMakeLists.txt index 072af64f0..c02214e58 100644 --- a/_studio/mfx_lib/CMakeLists.txt +++ b/_studio/mfx_lib/CMakeLists.txt @@ -119,12 +119,14 @@ target_include_directories(mfxcore PUBLIC scheduler/include ${OPENCL_INCLUDE} + ${VULKAN_INCLUDE} ) if (CMAKE_SYSTEM_NAME MATCHES Linux) target_include_directories(mfxcore PUBLIC scheduler/linux/include + ${VULKAN_INCLUDE} ) endif() diff --git a/_studio/mfx_lib/decode/CMakeLists.txt b/_studio/mfx_lib/decode/CMakeLists.txt index d1c465dca..cd0081e92 100644 --- a/_studio/mfx_lib/decode/CMakeLists.txt +++ b/_studio/mfx_lib/decode/CMakeLists.txt @@ -81,6 +81,7 @@ if (MFX_ENABLE_MJPEG_VIDEO_DECODE) ${MSDK_UMC_ROOT}/codec/color_space_converter/include mjpeg/include ${OPENCL_INCLUDE} + ${VULKAN_INCLUDE} ) set(MJPEG_VIDEO_DECODE_SRC diff --git a/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp b/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp index a63fbb36d..89f266917 100755 --- a/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp +++ b/_studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp @@ -205,14 +205,9 @@ mfxStatus VideoDECODEAV1::Init(mfxVideoParam* par) m_init_par = (mfxVideoParamWrapper)(*par); - if (0 == m_init_par.mfx.FrameInfo.FrameRateExtN || 0 == m_init_par.mfx.FrameInfo.FrameRateExtD) - { - m_init_par.mfx.FrameInfo.FrameRateExtD = 1; - m_init_par.mfx.FrameInfo.FrameRateExtN = 30; - } - m_first_par = m_init_par; - m_in_framerate = (mfxF64) m_first_par.mfx.FrameInfo.FrameRateExtD / m_first_par.mfx.FrameInfo.FrameRateExtN; + m_in_framerate = (m_first_par.mfx.FrameInfo.FrameRateExtD && m_first_par.mfx.FrameInfo.FrameRateExtN) ? + ((mfxF64) m_first_par.mfx.FrameInfo.FrameRateExtD / m_first_par.mfx.FrameInfo.FrameRateExtN) : (mfxF64)1.0 / 30; m_decoder->SetInFrameRate(m_in_framerate); //mfxFrameAllocResponse response{}; @@ -506,13 +501,9 @@ mfxStatus VideoDECODEAV1::Reset(mfxVideoParam* par) m_first_par = *par; - if (0 == m_first_par.mfx.FrameInfo.FrameRateExtN || 0 == m_first_par.mfx.FrameInfo.FrameRateExtD) - { - m_first_par.mfx.FrameInfo.FrameRateExtD = 1; - m_first_par.mfx.FrameInfo.FrameRateExtN = 30; - } + m_in_framerate = (m_first_par.mfx.FrameInfo.FrameRateExtD && m_first_par.mfx.FrameInfo.FrameRateExtN) ? + ((mfxF64)m_first_par.mfx.FrameInfo.FrameRateExtD / m_first_par.mfx.FrameInfo.FrameRateExtN) : (mfxF64)1.0 / 30; - m_in_framerate = (mfxF64) m_first_par.mfx.FrameInfo.FrameRateExtD / m_first_par.mfx.FrameInfo.FrameRateExtN; m_decoder->SetInFrameRate(m_in_framerate); return MFX_ERR_NONE; diff --git a/_studio/mfx_lib/decode/h265/src/mfx_h265_dec_decode.cpp b/_studio/mfx_lib/decode/h265/src/mfx_h265_dec_decode.cpp index b7e5a82da..75ca33c69 100644 --- a/_studio/mfx_lib/decode/h265/src/mfx_h265_dec_decode.cpp +++ b/_studio/mfx_lib/decode/h265/src/mfx_h265_dec_decode.cpp @@ -549,8 +549,8 @@ mfxStatus VideoDECODEH265::GetVideoParam(mfxVideoParam *par) if (!par->mfx.FrameInfo.FrameRateExtD && !par->mfx.FrameInfo.FrameRateExtN) { - par->mfx.FrameInfo.FrameRateExtN = 30; - par->mfx.FrameInfo.FrameRateExtD = 1; + par->mfx.FrameInfo.FrameRateExtN = 0; + par->mfx.FrameInfo.FrameRateExtD = 0; } } diff --git a/_studio/mfx_lib/decode/mjpeg/include/mfx_mjpeg_dec_decode.h b/_studio/mfx_lib/decode/mjpeg/include/mfx_mjpeg_dec_decode.h index 4d9eac936..11486a344 100644 --- a/_studio/mfx_lib/decode/mjpeg/include/mfx_mjpeg_dec_decode.h +++ b/_studio/mfx_lib/decode/mjpeg/include/mfx_mjpeg_dec_decode.h @@ -1,4 +1,4 @@ -// Copyright (c) 2004-2020 Intel Corporation +// Copyright (c) 2004-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -32,10 +32,6 @@ #include -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -#include -#endif - #include "mfx_task.h" #include "umc_media_data.h" @@ -134,38 +130,6 @@ class VideoDECODEMJPEGBase_HW : public VideoDECODEMJPEGBase UMC::VideoAccelerator * m_va; }; -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -// Forward declaration of used classes -class CJpegTask; - -class VideoDECODEMJPEGBase_SW : public VideoDECODEMJPEGBase -{ -public: - VideoDECODEMJPEGBase_SW(); - - mfxStatus Init(mfxVideoParam *decPar, mfxFrameAllocRequest *request, mfxFrameAllocResponse *response, mfxFrameAllocRequest *request_internal, bool isUseExternalFrames, VideoCORE *core) override; - mfxStatus Reset(mfxVideoParam *par) override; - mfxStatus Close(void) override; - - mfxStatus GetVideoParam(mfxVideoParam *par) override; - mfxStatus RunThread(void *pParam, mfxU32 threadNumber, mfxU32 callNumber) override; - mfxStatus CompleteTask(void *pParam, mfxStatus taskRes) override; - mfxStatus CheckTaskAvailability(mfxU32 maxTaskNumber) override; - mfxStatus ReserveUMCDecoder(UMC::MJPEGVideoDecoderBaseMFX* &pMJPEGVideoDecoder, mfxFrameSurface1 *surf) override; - void ReleaseReservedTask() override; - mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic) override; - mfxStatus AllocateFrameData(UMC::FrameData *&data) override; - mfxStatus FillEntryPoint(MFX_ENTRY_POINT *pEntryPoint, mfxFrameSurface1 *surface_work, mfxFrameSurface1 *surface_out) override; - -protected: - CJpegTask *pLastTask; - // Free tasks queue (if SW is used) - std::queue> m_freeTasks; - // Count of created tasks (if SW is used) - mfxU16 m_tasksCount; -}; -#endif - class VideoDECODEMJPEG : public VideoDECODE { public: diff --git a/_studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp b/_studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp index f5bff1f37..87f16b3a2 100644 --- a/_studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp +++ b/_studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2004-2023 Intel Corporation +// Copyright (c) 2004-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -27,12 +27,6 @@ #include "mfx_common.h" #include "mfx_common_decode_int.h" -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -#include "mfx_mjpeg_task.h" -#include "umc_mjpeg_mfx_decode.h" -#include "mfx_thread_task.h" -#endif - #include "mfx_enc_common.h" #include "umc_jpeg_frame_constructor.h" @@ -86,7 +80,6 @@ class MFX_JPEG_Utility private: - static bool IsNeedPartialAcceleration(VideoCORE * core, mfxVideoParam * par); static bool IsFormatSupport(mfxVideoParam * in); }; @@ -182,11 +175,7 @@ mfxStatus VideoDECODEMJPEG::Init(mfxVideoParam *par) if (MFX_PLATFORM_SOFTWARE == m_platform) { -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - decoder.reset(new VideoDECODEMJPEGBase_SW); -#else MFX_RETURN(MFX_ERR_UNSUPPORTED); -#endif } else { @@ -411,8 +400,8 @@ mfxStatus VideoDECODEMJPEG::GetVideoParam(mfxVideoParam *par) if (!par->mfx.FrameInfo.FrameRateExtD && !par->mfx.FrameInfo.FrameRateExtN) { - par->mfx.FrameInfo.FrameRateExtN = 30; - par->mfx.FrameInfo.FrameRateExtD = 1; + par->mfx.FrameInfo.FrameRateExtN = 0; + par->mfx.FrameInfo.FrameRateExtD = 0; } } @@ -722,7 +711,7 @@ mfxStatus VideoDECODEMJPEG::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1 (MFX_PICSTRUCT_FIELD_TFF)); (*surface_out)->Data.TimeStamp = GetMfxTimeStamp(dst->GetTime()); - if(MFX_TIME_STAMP_INVALID == (*surface_out)->Data.TimeStamp) + if ((MFX_TIME_STAMP_INVALID == (*surface_out)->Data.TimeStamp) && m_vPar.mfx.FrameInfo.FrameRateExtN) { (*surface_out)->Data.TimeStamp = ((mfxU64)m_frameOrder * m_vPar.mfx.FrameInfo.FrameRateExtD * MFX_TIME_STAMP_FREQUENCY) / m_vPar.mfx.FrameInfo.FrameRateExtN; } @@ -1030,90 +1019,6 @@ bool VideoDECODEMJPEG::IsSameVideoParam(mfxVideoParam * newPar, mfxVideoParam * /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // MFX_JPEG_Utility implementation /////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool MFX_JPEG_Utility::IsNeedPartialAcceleration(VideoCORE * core, mfxVideoParam * par) -{ - if (!par) - return false; - - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB && - par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444) - return true; - - - switch (par->mfx.FrameInfo.FourCC) - { - case MFX_FOURCC_NV12: - if (par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444 || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422V || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV411 || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_MONOCHROME) - return false; - else - return true; - case MFX_FOURCC_YUY2: - if (par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422V || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_MONOCHROME || - par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444) - return false; - else - return true; - case MFX_FOURCC_UYVY: - if( par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && - (par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 || par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H) - ) return false; - else - return true; - case MFX_FOURCC_RGB4: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444) - return true; - else - return false; - case MFX_FOURCC_YUV400: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV400) - return true; - else - return false; - case MFX_FOURCC_YUV411: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV411) - return true; - else - return false; - case MFX_FOURCC_YUV422V: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV422V) - return true; - else - return false; - case MFX_FOURCC_YUV422H: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV422H) - return true; - else - return false; - case MFX_FOURCC_IMC3: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV420) - return true; - else - return false; - case MFX_FOURCC_YUV444: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444) - return true; - else - return false; - case MFX_FOURCC_RGBP: - case MFX_FOURCC_BGRP: - if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444) - return true; - else - return false; - default: - return true; - } - - return false; -} eMFXPlatform MFX_JPEG_Utility::GetPlatform(VideoCORE * core, mfxVideoParam * par) { @@ -1159,8 +1064,12 @@ bool MFX_JPEG_Utility::IsFormatSupport(mfxVideoParam * in) bool support = false; mfxU32 fourCC = in->mfx.FrameInfo.FourCC; - mfxU16 chromaFormat = in->mfx.FrameInfo.ChromaFormat; + mfxU16 chromaFormat = in->mfx.JPEGChromaFormat; mfxU16 colorFormat = in->mfx.JPEGColorFormat; + + if (colorFormat == MFX_JPEG_COLORFORMAT_RGB && chromaFormat != MFX_CHROMAFORMAT_YUV444) + return support; + switch (chromaFormat) { case MFX_CHROMAFORMAT_MONOCHROME: @@ -2101,237 +2010,4 @@ mfxStatus VideoDECODEMJPEGBase_HW::CompleteTask(void *pParam, mfxStatus ) return MFX_ERR_NONE; } -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -VideoDECODEMJPEGBase_SW::VideoDECODEMJPEGBase_SW() -{ - pLastTask = NULL; - m_tasksCount = 0; -} - -mfxStatus VideoDECODEMJPEGBase_SW::Init(mfxVideoParam *decPar, mfxFrameAllocRequest *, mfxFrameAllocResponse *, mfxFrameAllocRequest *, bool, VideoCORE *) -{ -#if !defined(MSDK_USE_EXTERNAL_IPP) - auto ippSt = MfxIppInit(); - MFX_CHECK(ippSt == ippStsNoErr, MFX_ERR_UNSUPPORTED); -#endif - - ConvertMFXParamsToUMC(decPar, &umcVideoParams); - umcVideoParams.numThreads = m_vPar.mfx.NumThread; - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::Reset(mfxVideoParam *par) -{ - m_tasksCount = 0; - pLastTask = nullptr; - { - std::lock_guard guard(m_guard); - while(!m_freeTasks.empty()) - { - m_freeTasks.pop(); - } - } - - memset(&m_stat, 0, sizeof(mfxDecodeStat)); - m_vPar = *par; - - UMC::Status umcSts = m_surface_source->Reset(); - MFX_CHECK(umcSts == UMC::UMC_OK, MFX_ERR_MEMORY_ALLOC); - - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::Close() -{ - m_tasksCount = 0; - pLastTask = nullptr; - memset(&m_stat, 0, sizeof(mfxDecodeStat)); - - // delete free tasks queue - { - std::lock_guard guard(m_guard); - while (!m_freeTasks.empty()) - { - m_freeTasks.pop(); - } - } - - UMC::Status umcSts = m_surface_source->Close(); - MFX_CHECK(umcSts == UMC::UMC_OK, ConvertUMCStatusToMfx(umcSts)); - - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::GetVideoParam(mfxVideoParam *par) -{ - mfxExtJPEGQuantTables* jpegQT = (mfxExtJPEGQuantTables*) mfx::GetExtBuffer( par->ExtParam, par->NumExtParam, MFX_EXTBUFF_JPEG_QT ); - mfxExtJPEGHuffmanTables* jpegHT = (mfxExtJPEGHuffmanTables*) mfx::GetExtBuffer( par->ExtParam, par->NumExtParam, MFX_EXTBUFF_JPEG_HUFFMAN ); - - if(!jpegQT && !jpegHT) - return MFX_ERR_NONE; - - MFX_CHECK(pLastTask, MFX_ERR_UNSUPPORTED); - - return VideoDECODEMJPEGBase::GetVideoParam(par, pLastTask->m_pMJPEGVideoDecoder.get()); -} - -mfxStatus VideoDECODEMJPEGBase_SW::ReserveUMCDecoder(UMC::MJPEGVideoDecoderBaseMFX* &pMJPEGVideoDecoder, mfxFrameSurface1 *surf) -{ - pMJPEGVideoDecoder = 0; - MFX_SAFE_CALL(m_surface_source->SetCurrentMFXSurface(surf)); - - pMJPEGVideoDecoder = m_freeTasks.front()->m_pMJPEGVideoDecoder.get(); - //pMJPEGVideoDecoder->Reset(); - return MFX_ERR_NONE; -} - -void VideoDECODEMJPEGBase_SW::ReleaseReservedTask() -{ - if (!m_freeTasks.empty()) - m_freeTasks.front()->Reset(); -} - -mfxStatus VideoDECODEMJPEGBase_SW::AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic) -{ - // select the field position. 0 means top, 1 means bottom. - mfxU32 fieldPos = m_freeTasks.front()->NumPicCollected(); - - if (MFX_PICSTRUCT_FIELD_BFF == m_vPar.mfx.FrameInfo.PicStruct) - { - // change field order in BFF case - fieldPos ^= 1; - } - - // add picture to the task - MFX_SAFE_CALL(m_freeTasks.front()->AddPicture(pSrcData, fieldPos)); - numPic = m_freeTasks.front()->NumPicCollected(); - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::FillEntryPoint(MFX_ENTRY_POINT *pEntryPoint, mfxFrameSurface1 *surface_work, mfxFrameSurface1 *surface_out) -{ - // remove the ready task from the queue - { - std::lock_guard guard(m_guard); - pLastTask = m_freeTasks.front().release(); - m_freeTasks.pop(); - } - - pLastTask->surface_work = surface_work; - pLastTask->surface_out = surface_out; - - pEntryPoint->requiredNumThreads = std::min(pLastTask->m_pMJPEGVideoDecoder->NumDecodersAllocated(), - pLastTask->NumPiecesCollected()); - pEntryPoint->pParam = pLastTask; - - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::AllocateFrameData(UMC::FrameData *&data) -{ - CJpegTask *pTask = m_freeTasks.front().get(); - - // prepare the decoder(s) - UMC::Status umcRes = pTask->m_pMJPEGVideoDecoder->AllocateFrame(); - if (UMC::UMC_OK != umcRes) - { - return ConvertUMCStatusToMfx(umcRes); - } - - // save parameters to the task - pTask->dst = pTask->m_pMJPEGVideoDecoder.get()->GetDst(); - - UMC::FrameData *dst = m_freeTasks.front()->dst; - dst->SetTime(m_freeTasks.front()->GetPictureBuffer(0).timeStamp); - data = dst; - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::CheckTaskAvailability(mfxU32 maxTaskNumber) -{ - if (m_freeTasks.empty()) - { - if (m_tasksCount >= maxTaskNumber) - { - return MFX_WRN_DEVICE_BUSY; - } - - std::unique_ptr pTask(new CJpegTask()); - m_tasksCount++; - - // initialize the task - MFX_SAFE_CALL(pTask->Initialize(umcVideoParams, - m_surface_source.get(), - m_vPar.mfx.Rotation, - m_vPar.mfx.JPEGChromaFormat, - m_vPar.mfx.JPEGColorFormat)); - - // save the task object into the queue - { - std::lock_guard guard(m_guard); - m_freeTasks.push(std::move(pTask)); - } - } - - return MFX_ERR_NONE; -} - -mfxStatus VideoDECODEMJPEGBase_SW::RunThread(void *pParam, mfxU32 threadNumber, mfxU32 callNumber) -{ - CJpegTask *task = (CJpegTask *) pParam; - if (!task) - MFX_RETURN(MFX_ERR_NULL_PTR); - - // check the number of call. one call = one piece decoded. all extra call - // should go exit. - if (callNumber >= task->NumPiecesCollected()) - { - return MFX_TASK_DONE; - } - - // do decoding process - UMC::Status umcSts = task->m_pMJPEGVideoDecoder->DecodePicture(*task, threadNumber, callNumber); - MFX_CHECK(umcSts == UMC::UMC_OK, MFX_ERR_INVALID_VIDEO_PARAM); - - return ((callNumber + 1) == task->NumPiecesCollected()) ? (MFX_TASK_DONE) : (MFX_TASK_WORKING); -} - -mfxStatus VideoDECODEMJPEGBase_SW::CompleteTask(void *pParam, mfxStatus taskRes) -{ - CJpegTask &task = *((CJpegTask *) pParam); - - // do color conversion and other useless stuff - if (MFX_ERR_NONE == taskRes) - { - UMC::Status umcRes = UMC::UMC_OK; - - umcRes = task.m_pMJPEGVideoDecoder->PostProcessing(task.GetPictureBuffer(0).timeStamp); - if (UMC::UMC_OK != umcRes) - { - return ConvertUMCStatusToMfx(umcRes); - } - - // decoding is ready. prepare to output: - mfxStatus mfxSts = m_surface_source->PrepareToOutput(task.surface_out, - task.dst->GetFrameMID(), - &m_vPar, mfxU32(~MFX_COPY_USE_VACOPY_ANY)); - if (mfxSts < MFX_ERR_NONE) - { - return mfxSts; - } - - task.m_pMJPEGVideoDecoder->CloseFrame(); - - m_stat.NumFrame++; - } - - task.Reset(); - { - std::lock_guard guard(m_guard); - m_freeTasks.emplace(&task); - } - return MFX_ERR_NONE; -} -#endif //ifdef MFX_ENABLE_JPEG_SW_FALLBACK - #endif // MFX_ENABLE_MJPEG_VIDEO_DECODE \ No newline at end of file diff --git a/_studio/mfx_lib/decode/mpeg2/hw/src/mfx_mpeg2_decode.cpp b/_studio/mfx_lib/decode/mpeg2/hw/src/mfx_mpeg2_decode.cpp index a80f47d91..70ae0d51d 100644 --- a/_studio/mfx_lib/decode/mpeg2/hw/src/mfx_mpeg2_decode.cpp +++ b/_studio/mfx_lib/decode/mpeg2/hw/src/mfx_mpeg2_decode.cpp @@ -554,8 +554,8 @@ mfxStatus VideoDECODEMPEG2::GetVideoParam(mfxVideoParam *par) if (!par->mfx.FrameInfo.FrameRateExtD && !par->mfx.FrameInfo.FrameRateExtN) { - par->mfx.FrameInfo.FrameRateExtN = 30; - par->mfx.FrameInfo.FrameRateExtD = 1; + par->mfx.FrameInfo.FrameRateExtN = 0; + par->mfx.FrameInfo.FrameRateExtD = 0; } } diff --git a/_studio/mfx_lib/decode/vp8/src/mfx_vp8_dec_decode_hw.cpp b/_studio/mfx_lib/decode/vp8/src/mfx_vp8_dec_decode_hw.cpp index 090d4f055..2b45d0d73 100644 --- a/_studio/mfx_lib/decode/vp8/src/mfx_vp8_dec_decode_hw.cpp +++ b/_studio/mfx_lib/decode/vp8/src/mfx_vp8_dec_decode_hw.cpp @@ -165,13 +165,8 @@ mfxStatus VideoDECODEVP8_HW::Init(mfxVideoParam *p_video_param) m_init_w = p_video_param->mfx.FrameInfo.Width; m_init_h = p_video_param->mfx.FrameInfo.Height; - if(m_on_init_video_params.mfx.FrameInfo.FrameRateExtN == 0 || m_on_init_video_params.mfx.FrameInfo.FrameRateExtD == 0) - { - m_on_init_video_params.mfx.FrameInfo.FrameRateExtD = 1000; - m_on_init_video_params.mfx.FrameInfo.FrameRateExtN = 30000; - } - - m_in_framerate = (mfxF64) m_on_init_video_params.mfx.FrameInfo.FrameRateExtD / m_on_init_video_params.mfx.FrameInfo.FrameRateExtN; + m_in_framerate = (m_on_init_video_params.mfx.FrameInfo.FrameRateExtN && m_on_init_video_params.mfx.FrameInfo.FrameRateExtD) ? + (mfxF64) m_on_init_video_params.mfx.FrameInfo.FrameRateExtD / m_on_init_video_params.mfx.FrameInfo.FrameRateExtN : (mfxF64) 1 / 30; m_video_params = m_on_init_video_params; @@ -321,13 +316,8 @@ mfxStatus VideoDECODEVP8_HW::Reset(mfxVideoParam *p_video_param) m_on_init_video_params = *p_video_param; m_video_params = m_on_init_video_params; - if (m_on_init_video_params.mfx.FrameInfo.FrameRateExtN == 0 || m_on_init_video_params.mfx.FrameInfo.FrameRateExtD == 0) - { - m_on_init_video_params.mfx.FrameInfo.FrameRateExtD = 1000; - m_on_init_video_params.mfx.FrameInfo.FrameRateExtN = 30000; - } - - m_in_framerate = (mfxF64) m_on_init_video_params.mfx.FrameInfo.FrameRateExtD / m_on_init_video_params.mfx.FrameInfo.FrameRateExtN; + m_in_framerate = (m_on_init_video_params.mfx.FrameInfo.FrameRateExtN && m_on_init_video_params.mfx.FrameInfo.FrameRateExtD) ? + (mfxF64) m_on_init_video_params.mfx.FrameInfo.FrameRateExtD / m_on_init_video_params.mfx.FrameInfo.FrameRateExtN : (mfxF64) 1 / 30; if(CheckHardwareSupport(m_p_core, p_video_param) == false) { diff --git a/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp b/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp index c248fd7f9..2d0117a11 100644 --- a/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp +++ b/_studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp @@ -411,13 +411,8 @@ mfxStatus VideoDECODEVP9_HW::Init(mfxVideoParam *par) m_vInitPar.IOPattern & MFX_IOPATTERN_OUT_VIDEO_MEMORY) | (m_vInitPar.IOPattern & MFX_IOPATTERN_OUT_SYSTEM_MEMORY); - if (0 == m_vInitPar.mfx.FrameInfo.FrameRateExtN || 0 == m_vInitPar.mfx.FrameInfo.FrameRateExtD) - { - m_vInitPar.mfx.FrameInfo.FrameRateExtD = 1000; - m_vInitPar.mfx.FrameInfo.FrameRateExtN = 30000; - } - - m_in_framerate = (mfxF64) m_vInitPar.mfx.FrameInfo.FrameRateExtD / m_vInitPar.mfx.FrameInfo.FrameRateExtN; + m_in_framerate = (m_vInitPar.mfx.FrameInfo.FrameRateExtN && m_vInitPar.mfx.FrameInfo.FrameRateExtD) ? + (mfxF64) m_vInitPar.mfx.FrameInfo.FrameRateExtD / m_vInitPar.mfx.FrameInfo.FrameRateExtN : (mfxF64) 1 / 30; if ((m_vPar.mfx.FrameInfo.AspectRatioH == 0) && (m_vPar.mfx.FrameInfo.AspectRatioW == 0)) { @@ -581,13 +576,8 @@ mfxStatus VideoDECODEVP9_HW::Reset(mfxVideoParam *par) m_vPar = *par; - if (0 == m_vPar.mfx.FrameInfo.FrameRateExtN || 0 == m_vPar.mfx.FrameInfo.FrameRateExtD) - { - m_vPar.mfx.FrameInfo.FrameRateExtD = m_vInitPar.mfx.FrameInfo.FrameRateExtD; - m_vPar.mfx.FrameInfo.FrameRateExtN = m_vInitPar.mfx.FrameInfo.FrameRateExtN; - } - - m_in_framerate = (mfxF64) m_vPar.mfx.FrameInfo.FrameRateExtD / m_vPar.mfx.FrameInfo.FrameRateExtN; + m_in_framerate = (m_vPar.mfx.FrameInfo.FrameRateExtN && m_vPar.mfx.FrameInfo.FrameRateExtD) ? + (mfxF64) m_vPar.mfx.FrameInfo.FrameRateExtD / m_vPar.mfx.FrameInfo.FrameRateExtN : (mfxF64) 1 / 30; m_index = 0; return MFX_ERR_NONE; diff --git a/_studio/mfx_lib/encode_hw/CMakeLists.txt b/_studio/mfx_lib/encode_hw/CMakeLists.txt index 8cb419e64..6ca137f3e 100644 --- a/_studio/mfx_lib/encode_hw/CMakeLists.txt +++ b/_studio/mfx_lib/encode_hw/CMakeLists.txt @@ -215,6 +215,8 @@ if (MFX_ENABLE_AV1_VIDEO_ENCODE) ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_iddi_packer.h ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_impl.h + ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_interpo_filter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_interpo_filter.h ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_packer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_packer.h ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_query_impl_desc.cpp @@ -237,6 +239,8 @@ if (MFX_ENABLE_AV1_VIDEO_ENCODE) ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_enctools_com.h ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_scc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_scc.h + ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_cdef.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/base/av1ehw_base_cdef.h ) set(AV1_VIDEO_ENCODE_SRC @@ -258,8 +262,6 @@ if (MFX_ENABLE_AV1_VIDEO_ENCODE) ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/Xe2/av1ehw_xe2_scc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/Xe2/av1ehw_xe2_scc.h - ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/Xe2/av1ehw_xe2_cdef.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/av1/agnostic/Xe2/av1ehw_xe2_cdef.h ) custom_source_group("av1" ${AV1_VIDEO_ENCODE_SRC}) @@ -336,6 +338,7 @@ target_include_directories(encode_hw ${MSDK_UMC_ROOT}/codec/brc/include ${MSDK_UMC_ROOT}/codec/color_space_converter/include ${OPENCL_INCLUDE} + ${VULKAN_INCLUDE} ) target_link_libraries(encode_hw diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/Xe2/av1ehw_xe2_cdef.cpp b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_cdef.cpp similarity index 98% rename from _studio/mfx_lib/encode_hw/av1/agnostic/Xe2/av1ehw_xe2_cdef.cpp rename to _studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_cdef.cpp index 755f7422b..d3c8ee5a5 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/Xe2/av1ehw_xe2_cdef.cpp +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_cdef.cpp @@ -22,15 +22,14 @@ #if defined(MFX_ENABLE_AV1_VIDEO_ENCODE) #include "av1ehw_base_data.h" -#include "av1ehw_xe2_cdef.h" +#include "av1ehw_base_cdef.h" using namespace AV1EHW; using namespace AV1EHW::Base; -using namespace AV1EHW::Xe2; namespace AV1EHW { -namespace Xe2 +namespace Base { inline static void TuneCDEFLowQP(uint32_t* strength, int32_t qp) @@ -273,7 +272,7 @@ void CDEF::Query1NoCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push) }); } -} //namespace Xe2 +} //namespace Base } //namespace AV1EHW #endif //defined(MFX_ENABLE_AV1_VIDEO_ENCODE) diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/Xe2/av1ehw_xe2_cdef.h b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_cdef.h similarity index 98% rename from _studio/mfx_lib/encode_hw/av1/agnostic/Xe2/av1ehw_xe2_cdef.h rename to _studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_cdef.h index 13c6e9c09..d1a129ba8 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/Xe2/av1ehw_xe2_cdef.h +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_cdef.h @@ -25,7 +25,7 @@ namespace AV1EHW { -namespace Xe2 +namespace Base { class CDEF : public FeatureBase @@ -44,7 +44,7 @@ namespace Xe2 virtual void Query1NoCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push) override; }; -} //Xe2 +} //Base } //namespace AV1EHW #endif //defined(MFX_ENABLE_AV1_VIDEO_ENCODE) diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h index ba7740a9c..db7ed7559 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h @@ -847,6 +847,7 @@ namespace Base BitOffsets Offsets = {}; mfxU8 MinBaseQIndex = 0; mfxU8 MaxBaseQIndex = 0; + mfxU8 AdaptiveTUEnabled = 0; RefListType RefList = {}; DpbType DPB; @@ -1327,6 +1328,7 @@ namespace Base , FEATURE_MAX_FRAME_SIZE , FEATURE_HDR , FEATURE_QUALITYINFO + , FEATURE_INTERPO_FILTER , NUM_FEATURES }; diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.cpp b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.cpp new file mode 100644 index 000000000..e3b87a2c8 --- /dev/null +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.cpp @@ -0,0 +1,109 @@ +// Copyright (c) 2023-2024 Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include "mfx_common.h" +#if defined(MFX_ENABLE_AV1_VIDEO_ENCODE) + +#include "av1ehw_base_data.h" +#include "av1ehw_base_interpo_filter.h" + +using namespace AV1EHW; + +namespace AV1EHW +{ +namespace Base +{ +static inline void UpdateInterpFilterForNonRAB(mfxU16 width, mfxU8 QP, Base::FH& currFH) +{ + if (width <= 500 && QP <= 220) + { + currFH.interpolation_filter = EIGHTTAP_SHARP; + } +} + +static inline void UpdateInterpFilterForBPyramid(mfxU16 width, mfxU8 QP, mfxU16 GopRefDist, Base::FH& currFH) +{ + if ((currFH.order_hint % (GopRefDist / 2)) == 0) + { + if (width <= 900 && QP <= 255) + { + currFH.interpolation_filter = EIGHTTAP_SHARP; + } + } + else + { + if (width <= 2000 && QP <= 255) + { + currFH.interpolation_filter = EIGHTTAP_SHARP; + } + } +} + +static mfxStatus PostUpdateInterpFilter( + const mfxVideoParam& par + , mfxU8 QP + , Base::FH& currFH) +{ + if (currFH.frame_type != KEY_FRAME) + { + const mfxExtCodingOption2& CO2 = ExtBuffer::Get(par); + const mfxU16 Width = par.mfx.FrameInfo.CropW; + const mfxU16 GopRefDist = par.mfx.GopRefDist; + bool haveRAB = HaveRABFrames(par); + bool isBPyramid = (CO2.BRefType == MFX_B_REF_PYRAMID) ? true : false; + + if (!haveRAB) + { + // for no RAB Gop. + UpdateInterpFilterForNonRAB(Width, QP, currFH); + } + else if (isBPyramid && GopRefDist == 8) + { + // for RAB BPyramid + UpdateInterpFilterForBPyramid(Width, QP, GopRefDist, currFH); + } + } + + return MFX_ERR_NONE; +} + +void InterpoFilter::PostReorderTask(const FeatureBlocks& /*blocks*/, TPushPostRT Push) +{ + Push(BLK_ConfigureTask + , [this]( + StorageW& global + , StorageW& s_task) -> mfxStatus + { + const auto &par = GetRTDefaults(global).mvp; + const mfxExtAV1AuxData &auxPar = ExtBuffer::Get(par); + + if (auxPar.InterpFilter == MFX_AV1_INTERP_DEFAULT) + { + return PostUpdateInterpFilter(par, Task::Common::Get(s_task).QpY, Task::FH::Get(s_task)); + } + + return MFX_ERR_NONE; + }); +} + +} //namespace Base +} //namespace AV1EHW + +#endif //defined(MFX_ENABLE_AV1_VIDEO_ENCODE) diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.h b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.h new file mode 100644 index 000000000..2e495f429 --- /dev/null +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_interpo_filter.h @@ -0,0 +1,52 @@ +// Copyright (c) 2023-2024 Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "mfx_common.h" +#if defined(MFX_ENABLE_AV1_VIDEO_ENCODE) + +#include "av1ehw_base.h" + +namespace AV1EHW +{ +namespace Base +{ + class InterpoFilter + : public FeatureBase + { + public: +#define DECL_BLOCK_LIST\ + DECL_BLOCK(ConfigureTask ) +#define DECL_FEATURE_NAME "INTERPOLATION_FILTER" +#include "av1ehw_decl_blocks.h" + + InterpoFilter(mfxU32 FeatureId) + : FeatureBase(FeatureId) + {} + + protected: + virtual void PostReorderTask(const FeatureBlocks& /*blocks*/, TPushPostRT Push) override; + + }; +} //Base +} //namespace AV1EHW + +#endif //defined(MFX_ENABLE_AV1_VIDEO_ENCODE) diff --git a/_studio/mfx_lib/encode_hw/av1/linux/Xe2/av1ehw_xe2_lin.cpp b/_studio/mfx_lib/encode_hw/av1/linux/Xe2/av1ehw_xe2_lin.cpp index 67407876e..4e463e43e 100644 --- a/_studio/mfx_lib/encode_hw/av1/linux/Xe2/av1ehw_xe2_lin.cpp +++ b/_studio/mfx_lib/encode_hw/av1/linux/Xe2/av1ehw_xe2_lin.cpp @@ -26,7 +26,7 @@ #include "av1ehw_base_tile.h" #include "av1ehw_xe2_lin.h" #include "av1ehw_xe2_scc.h" -#include "av1ehw_xe2_cdef.h" +#include "av1ehw_base_cdef.h" using namespace AV1EHW; using namespace AV1EHW::Base; @@ -41,7 +41,7 @@ Linux::Xe2::MFXVideoENCODEAV1_HW::MFXVideoENCODEAV1_HW( newFeatures.emplace_back(new AV1EHW::Base::Segmentation(AV1EHW::Base::FEATURE_SEGMENTATION)); newFeatures.emplace_back(new AV1EHW::Xe2::SCC(FEATURE_SCC)); - newFeatures.emplace_back(new AV1EHW::Xe2::CDEF(FEATURE_XE2CDEF)); + newFeatures.emplace_back(new AV1EHW::Base::CDEF(FEATURE_XE2CDEF)); for (auto& pFeature : newFeatures) pFeature->Init(mode, *this); diff --git a/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp b/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp index f6853c6e0..68b472c68 100644 --- a/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp +++ b/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp @@ -825,7 +825,11 @@ void VAPacker::SubmitTask(const FeatureBlocks& blocks, TPushST Push) auto& par = Glob::DDI_SubmitParam::Get(global); par.clear(); - par.push_back(PackVaBuffer(VAEncSequenceParameterBufferType, m_sps)); + if (IsI(task.FrameType)) + { + par.push_back(PackVaBuffer(VAEncSequenceParameterBufferType, m_sps)); + } + par.push_back(PackVaBuffer(VAEncPictureParameterBufferType, m_pps)); if (!m_tile_groups_task.empty()) diff --git a/_studio/mfx_lib/encode_hw/h264/include/mfx_h264_encode_hw_utils.h b/_studio/mfx_lib/encode_hw/h264/include/mfx_h264_encode_hw_utils.h index 9d41a2043..0349b3ba0 100644 --- a/_studio/mfx_lib/encode_hw/h264/include/mfx_h264_encode_hw_utils.h +++ b/_studio/mfx_lib/encode_hw/h264/include/mfx_h264_encode_hw_utils.h @@ -1049,6 +1049,7 @@ namespace MfxHwH264Encode , m_vmeData(0) , m_fwdRef(0) , m_bwdRef(0) + , m_adaptiveTUEnabled(0) , m_fieldPicFlag(0) , m_singleFieldMode(false) , m_fieldCounter(0) @@ -1339,6 +1340,7 @@ namespace MfxHwH264Encode DdiTask const * m_fwdRef; DdiTask const * m_bwdRef; + mfxU8 m_adaptiveTUEnabled; mfxU8 m_fieldPicFlag; // true for frames with interlaced content bool m_singleFieldMode; // true for FEI single-field processing mode diff --git a/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_encode_hw_utils_new.cpp b/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_encode_hw_utils_new.cpp index 4843c3cce..1683320e6 100644 --- a/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_encode_hw_utils_new.cpp +++ b/_studio/mfx_lib/encode_hw/h264/src/mfx_h264_encode_hw_utils_new.cpp @@ -26,7 +26,6 @@ #include "mfx_h264_encode_hw_utils.h" #include "mfx_common_int.h" #include "ippi.h" - using namespace MfxHwH264Encode; @@ -2201,7 +2200,6 @@ void MfxHwH264Encode::ConfigureTask( task.m_encOrderIdr = prevIdrFrameFlag ? prevTask.m_encOrder : prevTask.m_encOrderIdr; task.m_encOrderI = prevIFrameFlag ? prevTask.m_encOrder : prevTask.m_encOrderI; - task.m_isUseRawRef = IsOn(extOpt2.UseRawRef); task.m_isSkipped = false; if (task.m_isUseRawRef && extOpt2Runtime) diff --git a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_data.h b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_data.h index 9ab95f394..d60d759de 100644 --- a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_data.h +++ b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_data.h @@ -817,6 +817,7 @@ namespace Base mfxI8 m_minQP = 0; mfxI8 m_maxQP = 0; + mfxU8 AdaptiveTUEnabled = 0; mfxU8 SliceNUT = 0; mfxU32 InsertHeaders = 0; mfxU32 RepackHeaders = 0; diff --git a/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_ddi.h b/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_ddi.h index c78475a86..8e6c8c43f 100644 --- a/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_ddi.h +++ b/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_ddi.h @@ -96,6 +96,7 @@ typedef struct tagENCODE_CAPS_VP9 USHORT MaxNumOfDirtyRect; USHORT MaxNumOfMoveRect; UINT MaxNum_Reference0; + UCHAR SegIdBlockSizeSupport; } ENCODE_CAPS_VP9; diff --git a/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_vaapi.h b/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_vaapi.h index d8353af33..7e65297f5 100644 --- a/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_vaapi.h +++ b/_studio/mfx_lib/encode_hw/vp9/include/mfx_vp9_encode_hw_vaapi.h @@ -38,7 +38,8 @@ namespace MfxHwVP9Encode BLOCK_16x16 = 0, BLOCK_32x32 = 1, BLOCK_64x64 = 2, - BLOCK_8x8 = 4 + BLOCK_8x8 = 3, + BLOCK_UNSUPPORTED = 8 }; typedef struct diff --git a/_studio/mfx_lib/encode_hw/vp9/src/mfx_vp9_encode_hw_vaapi.cpp b/_studio/mfx_lib/encode_hw/vp9/src/mfx_vp9_encode_hw_vaapi.cpp index 8b1f0827f..71b8a01c6 100644 --- a/_studio/mfx_lib/encode_hw/vp9/src/mfx_vp9_encode_hw_vaapi.cpp +++ b/_studio/mfx_lib/encode_hw/vp9/src/mfx_vp9_encode_hw_vaapi.cpp @@ -86,8 +86,9 @@ namespace MfxHwVP9Encode case MFX_VP9_SEGMENT_ID_BLOCK_SIZE_64x64: return BLOCK_64x64; case MFX_VP9_SEGMENT_ID_BLOCK_SIZE_16x16: - default: return BLOCK_16x16; + default: + return BLOCK_UNSUPPORTED; } } @@ -111,7 +112,8 @@ namespace MfxHwVP9Encode mfxVideoParam const & /*par*/, VAEncPictureParameterBufferVP9 & pps, std::vector const & reconQueue, - BitOffsets const &offsets) + BitOffsets const &offsets, + ENCODE_CAPS_VP9 caps) { MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_HOTSPOTS, "FillPpsBuffer"); @@ -187,6 +189,8 @@ namespace MfxHwVP9Encode #if VA_CHECK_VERSION(1, 23, 0) mfxExtVP9Segmentation const & seg = GetActualExtBufferRef(*task.m_pParam, task.m_ctrl); pps.seg_id_block_size = MapSegIdBlockSizeToVAAPI(seg.SegmentIdBlockSize); + if (((1 << pps.seg_id_block_size) & caps.SegIdBlockSizeSupport) == 0) + MFX_RETURN(MFX_ERR_UNSUPPORTED); #endif pps.pic_flags.bits.segmentation_update_map = task.m_frameParam.segmentationUpdateMap; pps.pic_flags.bits.segmentation_temporal_update = task.m_frameParam.segmentationTemporalUpdate; @@ -701,6 +705,9 @@ mfxStatus VAAPIEncoder::CreateAuxilliaryDevice( VAConfigAttribEncMacroblockInfo, VAConfigAttribEncMaxRefFrames, VAConfigAttribEncSkipFrame, +#if VA_CHECK_VERSION(1, 23, 0) + VAConfigAttribEncVP9, +#endif }; std::vector attrs; @@ -781,7 +788,12 @@ mfxStatus VAAPIEncoder::CreateAuxilliaryDevice( m_caps.FrameLevelRateCtrl = attrs[idx_map[VAConfigAttribProcessingRate]].value == VA_PROCESSING_RATE_ENCODE; m_caps.BRCReset = attrs[idx_map[VAConfigAttribProcessingRate]].value == VA_PROCESSING_RATE_ENCODE; } - +#if VA_CHECK_VERSION(1, 23, 0) + if (attrs[idx_map[VAConfigAttribEncVP9]].value != VA_ATTRIB_NOT_SUPPORTED) + { + m_caps.SegIdBlockSizeSupport = attrs[idx_map[VAConfigAttribEncVP9]].value; + } +#endif HardcodeCaps(m_caps); return MFX_ERR_NONE; @@ -1051,8 +1063,10 @@ mfxStatus VAAPIEncoder::Execute( mfxU16 bytesWritten = PrepareFrameHeader(*task.m_pParam, pBuf, (mfxU32)m_frameHeaderBuf.size(), task, m_seqParam, offsets); MFX_CHECK(bytesWritten != 0, MFX_ERR_MORE_DATA); + mfxStatus sts = MFX_ERR_NONE; // update params - FillPpsBuffer(task, m_video, m_pps, m_reconQueue, offsets); + sts = FillPpsBuffer(task, m_video, m_pps, m_reconQueue, offsets, m_caps); + MFX_CHECK_STS(sts); FillSegMap(task, m_video, m_pmfxCore, m_segPar); //=============================================================================================== @@ -1074,7 +1088,6 @@ mfxStatus VAAPIEncoder::Execute( //------------------------------------------------------------------ // buffer creation & configuration //------------------------------------------------------------------ - mfxStatus sts; { // 1. sequence level { diff --git a/_studio/mfx_lib/ext/CMakeLists.txt b/_studio/mfx_lib/ext/CMakeLists.txt index c9f8207d3..2b001d4ba 100644 --- a/_studio/mfx_lib/ext/CMakeLists.txt +++ b/_studio/mfx_lib/ext/CMakeLists.txt @@ -172,6 +172,7 @@ if(MFX_ENABLE_KERNELS) PUBLIC ${genx_include_dirs} ${mctf_include_dir} + ${VULKAN_INCLUDE} ) target_sources(mfx_ext PRIVATE diff --git a/_studio/mfx_lib/pxp/CMakeLists.txt b/_studio/mfx_lib/pxp/CMakeLists.txt index 08123c441..45c4de64a 100644 --- a/_studio/mfx_lib/pxp/CMakeLists.txt +++ b/_studio/mfx_lib/pxp/CMakeLists.txt @@ -22,6 +22,7 @@ target_include_directories(pxp_hw ${MSDK_UMC_ROOT}/codec/h265_dec/include ${MSDK_UMC_ROOT}/codec/vvc_dec/include ${OPENCL_INCLUDE} + ${VULKAN_INCLUDE} ) target_link_libraries(pxp_hw diff --git a/_studio/mfx_lib/shared/src/libmfxsw.cpp b/_studio/mfx_lib/shared/src/libmfxsw.cpp index af295f895..597bf76f8 100644 --- a/_studio/mfx_lib/shared/src/libmfxsw.cpp +++ b/_studio/mfx_lib/shared/src/libmfxsw.cpp @@ -812,7 +812,8 @@ mfxHDL* MFX_CDECL MFXQueryImplsDescription(mfxImplCapsDeliveryFormat format, mfx } }; - for (auto type : { MFX_SURFACE_TYPE_VAAPI }) + for (auto type : { MFX_SURFACE_TYPE_VAAPI + }) { auto& surface_type = holder->PushBack(holder->SurfaceTypes); holder->NumSurfaceTypes++; diff --git a/_studio/mfx_lib/vpp/CMakeLists.txt b/_studio/mfx_lib/vpp/CMakeLists.txt index 9b378c6d5..3ee16faee 100644 --- a/_studio/mfx_lib/vpp/CMakeLists.txt +++ b/_studio/mfx_lib/vpp/CMakeLists.txt @@ -21,6 +21,7 @@ target_include_directories(vpp_hw PUBLIC include ${OPENCL_INCLUDE} + ${VULKAN_INCLUDE} ${MSDK_STUDIO_ROOT}/mfx_lib/ext/ai_vfi ) diff --git a/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h b/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h index c10f528f2..74bfb5de3 100644 --- a/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h +++ b/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h @@ -48,6 +48,8 @@ class MFXVideoFrameInterpolation MFXVideoFrameInterpolation(); virtual ~MFXVideoFrameInterpolation(); + static mfxStatus Query(VideoCORE* core); + mfxStatus Init( VideoCORE* core, const mfxFrameInfo& inInfo, @@ -90,6 +92,7 @@ class MFXVideoFrameInterpolation Ratio m_ratio; mfxU16 m_outStamp; mfxU16 m_outTick; + bool m_sequenceEnd; mfxU16 m_IOPattern; diff --git a/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h b/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h index c7480c26e..03bab9fb0 100644 --- a/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h +++ b/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h @@ -281,6 +281,7 @@ namespace MfxHwVideoProcessing , skipQueryStatus(false) , pAuxData(NULL) , pSubResource(NULL) + , m_aiVfiSequenceEnd(false) { #ifdef MFX_ENABLE_MCTF memset(&MctfData, 0, sizeof(IntMctfParams)); @@ -318,6 +319,8 @@ namespace MfxHwVideoProcessing ReleaseResource* pSubResource; std::vector m_refList; //m_refList.size() == bkwdRefCount +fwdRefCount + + bool m_aiVfiSequenceEnd; }; struct ExtendedConfig diff --git a/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp b/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp index 602ecc0ca..35b0f5852 100644 --- a/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp +++ b/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp @@ -31,6 +31,7 @@ #define HEIGHT2 (mfxU16)1440 MFXVideoFrameInterpolation::MFXVideoFrameInterpolation() : + m_sequenceEnd(false), m_inputFwd(), m_inputBkwd(), m_enableScd(false), @@ -211,12 +212,20 @@ mfxStatus MFXVideoFrameInterpolation::InitVppAndAllocateSurface( const mfxFrameInfo& outInfo, const mfxVideoSignalInfo& videoSignalInfo) { + std::vector extBufferPre, extBufferPost; + + mfxExtVPPScaling m_scalingConfig = {}; + m_scalingConfig.Header.BufferId = MFX_EXTBUFF_VPP_SCALING; + m_scalingConfig.Header.BufferSz = sizeof(mfxExtVPPScaling); + m_scalingConfig.ScalingMode = MFX_SCALING_MODE_INTEL_GEN_COMPUTE; + //m_scalingConfig.InterpolationMethod = MFX_INTERPOLATION_NEAREST_NEIGHBOR; + extBufferPre.push_back(&m_scalingConfig.Header); + extBufferPost.push_back(&m_scalingConfig.Header); + mfxExtVideoSignalInfo vsInPre = {}; mfxExtVideoSignalInfo vsOutPre = {}; mfxExtVideoSignalInfo vsInPost = {}; mfxExtVideoSignalInfo vsOutPost = {}; - mfxExtBuffer* extBufferPre[2] = {}; - mfxExtBuffer* extBufferPost[2] = {}; if (videoSignalInfo.enabled) { mfxVideoSignalInfo vsInfoIn = videoSignalInfo; @@ -241,16 +250,16 @@ mfxStatus MFXVideoFrameInterpolation::InitVppAndAllocateSurface( vsOutPre.VideoFormat = vsInfoOut.VideoFormat; vsOutPre.VideoFullRange = vsInfoOut.VideoFullRange; - extBufferPre[0] = &vsInPre.Header; - extBufferPre[1] = &vsOutPre.Header; + extBufferPre.push_back(&vsInPre.Header); + extBufferPre.push_back(&vsOutPre.Header); vsInPost = vsOutPre; vsInPost.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO_IN; vsOutPost = vsInPre; vsOutPost.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO_OUT; - extBufferPost[0] = &vsInPost.Header; - extBufferPost[1] = &vsOutPost.Header; + extBufferPost.push_back(&vsInPost.Header); + extBufferPost.push_back(&vsOutPost.Header); } m_vppForFi = IsVppNeededForVfi(inInfo, outInfo); @@ -276,11 +285,8 @@ mfxStatus MFXVideoFrameInterpolation::InitVppAndAllocateSurface( vppParams.vpp.Out.FourCC = MFX_FOURCC_BGR4; vppParams.vpp.Out.PicStruct = inInfo.PicStruct; - if (videoSignalInfo.enabled) - { - vppParams.NumExtParam = 2; - vppParams.ExtParam = &(extBufferPre[0]); - } + vppParams.NumExtParam = (mfxU16)extBufferPre.size(); + vppParams.ExtParam = extBufferPre.data(); sts = m_vppBeforeFi0->Init(&vppParams); MFX_CHECK_STS(sts); @@ -318,11 +324,8 @@ mfxStatus MFXVideoFrameInterpolation::InitVppAndAllocateSurface( vppParams.vpp.In.FourCC = MFX_FOURCC_BGR4; vppParams.vpp.Out = outInfo; - if (videoSignalInfo.enabled) - { - vppParams.NumExtParam = 2; - vppParams.ExtParam = &(extBufferPost[0]); - } + vppParams.NumExtParam = (mfxU16)extBufferPost.size(); + vppParams.ExtParam = extBufferPost.data(); sts = m_vppAfterFi->Init(&vppParams); MFX_CHECK_STS(sts); @@ -366,7 +369,16 @@ mfxStatus MFXVideoFrameInterpolation::UpdateTsAndGetStatus( mfxFrameSurface1* output, mfxStatus* intSts) { - if (nullptr == input) return MFX_ERR_MORE_DATA; + if (nullptr == input) + { + // nullptr == input means input sequence reaches its end + if (m_sequenceEnd) + { + return MFX_ERR_MORE_DATA; + } + if (m_outStamp == (m_ratio - 1)) m_sequenceEnd = true; + return MFX_ERR_NONE; + } mfxStatus sts = MFX_ERR_NONE; if (m_outStamp == 0) @@ -734,4 +746,18 @@ mfxStatus MFXVideoFrameInterpolation::AddTaskQueue(mfxU32 taskIndex) m_outStamp = 0; } return MFX_ERR_NONE; +} + +mfxStatus MFXVideoFrameInterpolation::Query(VideoCORE* core) +{ + MFX_CHECK_NULL_PTR1(core); + auto platform = core->GetHWType(); + if (platform == MFX_HW_DG2 || platform >= MFX_HW_MTL) + { + return MFX_ERR_NONE; + } + else + { + MFX_RETURN(MFX_ERR_UNSUPPORTED); + } } \ No newline at end of file diff --git a/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp b/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp index 0c0517dc5..dada3be42 100644 --- a/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp +++ b/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp @@ -1664,11 +1664,20 @@ mfxStatus TaskManager::FillTask( m_resMngr.m_surf[VPP_IN][pTask->input.resIdx].SetFree(false); } } - + mfxStatus sts = MFX_ERR_NONE; m_actualNumber += 1; // make sense for simple mode only - MFX_CHECK_NULL_PTR1(pTask->input.pSurf); - mfxStatus sts = m_core->IncreaseReference(*pTask->input.pSurf); - MFX_CHECK_STS(sts); + + if ((FRC_AI_INTERPOLATION & m_extMode) && !pTask->input.pSurf) + { + // input sequence reaches its end + pTask->m_aiVfiSequenceEnd = true; + } + else + { + MFX_CHECK_NULL_PTR1(pTask->input.pSurf); + sts = m_core->IncreaseReference(*pTask->input.pSurf); + MFX_CHECK_STS(sts); + } sts = m_core->IncreaseReference(*pTask->output.pSurf); MFX_CHECK_STS(sts); @@ -4222,6 +4231,12 @@ mfxStatus VideoVPPHW::MergeRuntimeParams(const DdiTask *pTask, MfxHwVideoProcess mfxStatus VideoVPPHW::SyncTaskSubmission(DdiTask* pTask) { mfxStatus sts = MFX_ERR_NONE; + + if (pTask->m_aiVfiSequenceEnd) + { + pTask->skipQueryStatus = true; + return sts; + } #ifdef MFX_ENABLE_MCTF if (pTask->outputForApp.pSurf) { diff --git a/_studio/mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp b/_studio/mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp index 28dffdf3f..4ac82c205 100644 --- a/_studio/mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp +++ b/_studio/mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp @@ -384,7 +384,7 @@ bool IsCompositionMode(mfxVideoParam* pParam) return false; } -mfxStatus ExtendedQuery(VideoCORE *, mfxU32 filterName, mfxExtBuffer* pHint) +mfxStatus ExtendedQuery(VideoCORE *core, mfxU32 filterName, mfxExtBuffer* pHint) { if( MFX_EXTBUFF_VPP_DENOISE == filterName || MFX_EXTBUFF_VPP_DENOISE2 == filterName @@ -437,6 +437,10 @@ mfxStatus ExtendedQuery(VideoCORE *, mfxU32 filterName, mfxExtBuffer* pHint) { MFX_RETURN(CheckScalingParam(pHint)); } + else if (MFX_EXTBUFF_VPP_AI_FRAME_INTERPOLATION == filterName) + { + MFX_RETURN(MFXVideoFrameInterpolation::Query(core)); + } else // ignore { return MFX_ERR_NONE; diff --git a/_studio/shared/enctools/CMakeLists.txt b/_studio/shared/enctools/CMakeLists.txt index ff2e3aedb..69015464e 100644 --- a/_studio/shared/enctools/CMakeLists.txt +++ b/_studio/shared/enctools/CMakeLists.txt @@ -34,6 +34,7 @@ target_include_directories(enctools_base PUBLIC include ${OPENCL_INCLUDE} + ${VULKAN_INCLUDE} ) target_link_libraries(enctools_base PRIVATE diff --git a/_studio/shared/include/libmfx_allocator_vaapi.h b/_studio/shared/include/libmfx_allocator_vaapi.h index bf83f9750..64e5ac93c 100644 --- a/_studio/shared/include/libmfx_allocator_vaapi.h +++ b/_studio/shared/include/libmfx_allocator_vaapi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2020 Intel Corporation +// Copyright (c) 2011-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,6 +30,7 @@ #include "mfxvideo++int.h" #include "libmfx_allocator.h" + // VAAPI Allocator internal Mem ID struct vaapiMemIdInt { @@ -233,23 +234,33 @@ class vaapi_surface_wrapper : public vaapi_resource_wrapper virtual mfxStatus Lock(mfxFrameData& frame_data, mfxU32 flags) override; virtual mfxStatus Unlock() override; -private: - virtual mfxStatus Export(const mfxSurfaceHeader& export_header, mfxSurfaceBase*& exported_surface, mfxFrameSurfaceInterfaceImpl* p_base_surface) override; + std::shared_ptr& GetCreateHelper() + { + std::lock_guard guard(m_mutex); + + if (!m_import_export_helper) + m_import_export_helper.reset(new ImportExportHelper()); + return m_import_export_helper; + } + +private: std::pair TryImportSurface (const mfxFrameInfo& info, mfxSurfaceHeader* import_surface); std::pair TryImportSurfaceVAAPI(const mfxFrameInfo& info, mfxSurfaceVAAPI& import_surface); - mfxStatus CopyImportSurface (const mfxFrameInfo& info, mfxSurfaceHeader* import_surface); mfxStatus CopyImportSurfaceVAAPI(const mfxFrameInfo& info, mfxSurfaceVAAPI& import_surface); SurfaceScopedLock m_surface_lock; // If m_imported == true we will not delete vaapi surface in destructor - bool m_imported = false; - mfxU16 m_type; - mfxU32 m_fourcc; + bool m_imported = false; + mfxU16 m_type; + mfxU32 m_fourcc; + std::mutex m_mutex; + std::shared_ptr m_import_export_helper; + }; struct mfxFrameSurface1_hw_vaapi : public RWAcessSurface diff --git a/_studio/shared/include/mfx_config.h b/_studio/shared/include/mfx_config.h index f347c88b1..6a6ae0368 100644 --- a/_studio/shared/include/mfx_config.h +++ b/_studio/shared/include/mfx_config.h @@ -71,6 +71,7 @@ #define MFX_ENABLE_PROTECT #endif + /* * Traces */ diff --git a/_studio/shared/src/libmfx_allocator.cpp b/_studio/shared/src/libmfx_allocator.cpp index 58e08f24c..7d8323c41 100644 --- a/_studio/shared/src/libmfx_allocator.cpp +++ b/_studio/shared/src/libmfx_allocator.cpp @@ -746,18 +746,7 @@ mfx::mfx_shared_lib_holder* ImportExportHelper::GetHelper(mfxSurfaceType shared_ lock.unlock(); mfx::mfx_shared_lib_holder* ret = nullptr; uniq_ptr_mfx_shared_lib_holder loaded_lib; -#ifdef MFX_ENABLE_SHARING_OPENCL - switch (shared_library_type) - { -//#ifdef MFX_ENABLE_SHARING_OPENCL - case MFX_SURFACE_TYPE_OPENCL_IMG2D: - loaded_lib = LoadAndInit(); - break; -//#endif - default: - break; - } -#endif + if (loaded_lib) { diff --git a/_studio/shared/src/libmfx_allocator_vaapi.cpp b/_studio/shared/src/libmfx_allocator_vaapi.cpp index e9207533b..d01faa775 100644 --- a/_studio/shared/src/libmfx_allocator_vaapi.cpp +++ b/_studio/shared/src/libmfx_allocator_vaapi.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Intel Corporation +// Copyright (c) 2007-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -18,14 +18,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "mfx_common.h" +#include "mfx_common.h" #include #include #include "ippcore.h" -#include "ipps.h" #include "libmfx_allocator_vaapi.h" #include "mfx_utils.h" @@ -959,6 +958,7 @@ std::pair vaapi_surface_wrapper::TryImportSurface(const mfxFram case MFX_SURFACE_TYPE_VAAPI: return TryImportSurfaceVAAPI(info, *(reinterpret_cast(import_surface))); + default: return { MFX_STS_TRACE(MFX_ERR_UNSUPPORTED), false }; } @@ -1022,6 +1022,8 @@ std::pair vaapi_surface_wrapper::TryImportSurfaceVAAPI(const mf return { MFX_ERR_NONE, true }; } + + mfxStatus vaapi_surface_wrapper::CopyImportSurface(const mfxFrameInfo& info, mfxSurfaceHeader* import_surface) { MFX_CHECK_NULL_PTR1(import_surface); @@ -1031,6 +1033,7 @@ mfxStatus vaapi_surface_wrapper::CopyImportSurface(const mfxFrameInfo& info, mfx case MFX_SURFACE_TYPE_VAAPI: MFX_RETURN(CopyImportSurfaceVAAPI(info, *(reinterpret_cast(import_surface)))); + default: MFX_RETURN(MFX_ERR_UNSUPPORTED); } @@ -1051,6 +1054,8 @@ mfxStatus vaapi_surface_wrapper::CopyImportSurfaceVAAPI(const mfxFrameInfo& info return MFX_ERR_NONE; } + + vaapi_surface_wrapper::~vaapi_surface_wrapper() { if (!m_imported) @@ -1086,11 +1091,14 @@ mfxStatus vaapi_surface_wrapper::Unlock() mfxStatus vaapi_surface_wrapper::Export(const mfxSurfaceHeader& export_header, mfxSurfaceBase*& exported_surface, mfxFrameSurfaceInterfaceImpl* p_base_surface) { + switch (export_header.SurfaceType) { case MFX_SURFACE_TYPE_VAAPI: exported_surface = mfxSurfaceVAAPIImpl::Create(export_header, p_base_surface, m_pVADisplay, m_resource_id); break; + + default: MFX_RETURN(MFX_ERR_UNSUPPORTED); } diff --git a/_studio/shared/src/libmfx_core_vaapi.cpp b/_studio/shared/src/libmfx_core_vaapi.cpp index d37e647d3..2fb0f9b71 100644 --- a/_studio/shared/src/libmfx_core_vaapi.cpp +++ b/_studio/shared/src/libmfx_core_vaapi.cpp @@ -130,10 +130,10 @@ class VACopyWrapper enum eEngine { INVALID = uint32_t(-1) + , DEFAULT = VA_EXEC_MODE_DEFAULT , BLT = VA_EXEC_MODE_POWER_SAVING - , VE = VA_EXEC_MODE_DEFAULT , EU = VA_EXEC_MODE_PERFORMANCE - , DEFAULT = 0xff + , VE = EU + 1 }; struct FCCDesc @@ -318,33 +318,11 @@ class VACopyWrapper static const std::map FccMap; VADisplay m_dpy = nullptr; uint32_t m_copyEngine = INVALID; - uint32_t m_copyEngineSupported = 0; VACopyWrapper(VADisplay dpy) : m_dpy(dpy) { - int nAttr = vaMaxNumDisplayAttributes(m_dpy); - - std::vector attrs(nAttr); - - if (VA_STATUS_SUCCESS != vaQueryDisplayAttributes(m_dpy, attrs.data(), &nAttr)) - nAttr = 0; - - auto itEnd = std::next(attrs.begin(), nAttr); - auto it = std::find_if(attrs.begin(), itEnd - , [](const VADisplayAttribute& attr) { return attr.type == VADisplayAttribCopy; }); - - if (it != itEnd) - { - m_copyEngineSupported = it->value; - - if (m_copyEngineSupported & (1 << EU)) - m_copyEngine = EU; - else if (m_copyEngineSupported & (1 << BLT)) - m_copyEngine = BLT; - else if (m_copyEngineSupported & (1 << VE)) - m_copyEngine = VE; - } + m_copyEngine = DEFAULT; } bool IsSupported() const @@ -387,7 +365,6 @@ class VACopyWrapper auto copyMode = GetMode(src, dst); MFX_CHECK(copyMode != VACOPY_UNSUPPORTED, MFX_ERR_UNSUPPORTED); - MFX_CHECK(forceEngine == DEFAULT || ((1 << forceEngine) & m_copyEngineSupported), MFX_ERR_UNSUPPORTED); if ( src.Info.Width != dst.Info.Width || src.Info.Height != dst.Info.Height) @@ -560,8 +537,28 @@ class VACopyWrapper || fourcc == MFX_FOURCC_P016; } - static bool IsVaCopySupportSurface(const mfxFrameSurface1& dst_surface, const mfxFrameSurface1& src_surface) + static bool IsVaCopySupportSurface(const mfxFrameSurface1& dst_surface, const mfxFrameSurface1& src_surface, eMFXHWType platform) { + if (dst_surface.Info.FourCC != src_surface.Info.FourCC) + { + return false; + } + + if (platform >= MFX_HW_MTL) + { + if (dst_surface.Info.FourCC != MFX_FOURCC_NV12 && + dst_surface.Info.FourCC != MFX_FOURCC_P010 && + dst_surface.Info.FourCC != MFX_FOURCC_P016 && + dst_surface.Info.FourCC != MFX_FOURCC_YUY2 && + dst_surface.Info.FourCC != MFX_FOURCC_Y210 && + dst_surface.Info.FourCC != MFX_FOURCC_Y216 && + dst_surface.Info.FourCC != MFX_FOURCC_Y416 + ) + { + return false; + } + } + auto CheckOneSurface = [](const mfxFrameSurface1& sw_surface) { // Only start addresses with 4k aligment for UsrPtr surface are supported, refer: https://dri.freedesktop.org/docs/drm/gpu/driver-uapi.html#c.drm_i915_gem_userptr @@ -1923,14 +1920,9 @@ VAAPIVideoCORE_VPL::DoFastCopyExtended( // Check if requested copy backend is CM and CM is capable to perform copy bool canUseCMCopy = (gpuCopyMode & MFX_COPY_USE_CM) && m_pCmCopy && (m_ForcedGpuCopyState != MFX_GPUCOPY_OFF) && CmCopyWrapper::CanUseCmCopy(pDst, pSrc); - if (m_pVaCopy && (VACopyWrapper::IsVaCopySupportSurface(*pDst, *pSrc)) && (gpuCopyMode & MFX_COPY_USE_VACOPY_ANY) && (m_ForcedGpuCopyState != MFX_GPUCOPY_OFF)) + if (m_pVaCopy && (VACopyWrapper::IsVaCopySupportSurface(*pDst, *pSrc, m_HWType)) && (gpuCopyMode & MFX_COPY_USE_VACOPY_ANY) && (m_ForcedGpuCopyState != MFX_GPUCOPY_OFF)) { - auto vacopyMode = - ((gpuCopyMode & MFX_COPY_USE_VACOPY_ANY) == MFX_COPY_USE_VACOPY_ANY) ? VACopyWrapper::DEFAULT - : (gpuCopyMode & MFX_COPY_USE_VACOPY_EU) ? VACopyWrapper::EU - : (gpuCopyMode & MFX_COPY_USE_VACOPY_BLT) ? VACopyWrapper::BLT - : VACopyWrapper::VE - ; + auto vacopyMode = VACopyWrapper::DEFAULT; if (m_HWType == MFX_HW_DG2) { diff --git a/_studio/shared/src/mfx_umc_alloc_wrapper.cpp b/_studio/shared/src/mfx_umc_alloc_wrapper.cpp index f8f208d9a..ee80503ce 100644 --- a/_studio/shared/src/mfx_umc_alloc_wrapper.cpp +++ b/_studio/shared/src/mfx_umc_alloc_wrapper.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2023 Intel Corporation +// Copyright (c) 2008-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -1372,12 +1372,7 @@ void SurfaceSource::CreateUMCAllocator(const mfxVideoParam & video_param, eMFXPl if (MFX_PLATFORM_SOFTWARE == platform) { -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - MFX_CHECK_WITH_THROW_STS(video_param.mfx.CodecId == MFX_CODEC_JPEG, MFX_ERR_UNSUPPORTED); - m_umc_allocator_adapter.reset(new mfx_UMC_FrameAllocator()); -#else MFX_CHECK_WITH_THROW_STS(false, MFX_ERR_UNSUPPORTED); -#endif } else { diff --git a/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h b/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h index 11ddc4ead..fc4d78123 100644 --- a/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h +++ b/_studio/shared/umc/codec/h265_dec/include/umc_h265_dec_defs.h @@ -581,8 +581,8 @@ struct H265TimingInfo public: H265TimingInfo() : vps_timing_info_present_flag(false) - , vps_num_units_in_tick(1000) - , vps_time_scale(30000) + , vps_num_units_in_tick(0) + , vps_time_scale(0) , vps_poc_proportional_to_timing_flag(false) , vps_num_ticks_poc_diff_one(0) {} diff --git a/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp b/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp index e8101044d..917cb9698 100755 --- a/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp +++ b/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2020 Intel Corporation +// Copyright (c) 2012-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -331,7 +331,7 @@ UMC::Status H265HeadersBitstream::GetVideoParamSet(H265VideoParamSet *pcVPS) } pcVPS->vps_max_layer_id = GetBits(6); - if (pcVPS->vps_max_layer_id >= MAX_NUH_LAYER_ID) + if (pcVPS->vps_max_layer_id > MAX_NUH_LAYER_ID) throw h265_exception(UMC::UMC_ERR_INVALID_STREAM); pcVPS->vps_num_layer_sets = GetVLCElementU() + 1; @@ -2102,8 +2102,10 @@ UMC::Status H265HeadersBitstream::GetNALUnitType(NalUnitType &nal_unit_type, uin nal_unit_type = (NalUnitType)GetBits(6); uint32_t nuh_layer_id = GetBits(6); - if (nuh_layer_id) + if (nuh_layer_id > MAX_NUH_LAYER_ID) throw h265_exception(UMC::UMC_ERR_INVALID_STREAM); + if (nuh_layer_id) + return UMC::UMC_ERR_UNSUPPORTED;//only support layer 0 which is the basic layer uint32_t const nuh_temporal_id_plus1 = GetBits(3); if (!nuh_temporal_id_plus1) diff --git a/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp b/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp index a23eb43f7..d69909587 100755 --- a/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp +++ b/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp @@ -1432,9 +1432,10 @@ UMC::Status TaskSupplier_H265::DecodeHeaders(UMC::MediaDataEx *nalUnit) NalUnitType nal_unit_type; uint32_t temporal_id = 0; - bitStream.GetNALUnitType(nal_unit_type, temporal_id); - - switch(nal_unit_type) + umcRes = bitStream.GetNALUnitType(nal_unit_type, temporal_id); + if (umcRes != UMC::UMC_OK) + return umcRes; + switch (nal_unit_type) { case NAL_UT_VPS: umcRes = xDecodeVPS(&bitStream); diff --git a/_studio/shared/umc/codec/jpeg_common/src/bitstreamin.cpp b/_studio/shared/umc/codec/jpeg_common/src/bitstreamin.cpp index 6e701b6bc..5b80cd1e8 100644 --- a/_studio/shared/umc/codec/jpeg_common/src/bitstreamin.cpp +++ b/_studio/shared/umc/codec/jpeg_common/src/bitstreamin.cpp @@ -261,10 +261,7 @@ JERRCODE CBitStreamInput::SeekAfterByte(uint8_t byte, int* skipped) { JERRCODE jerr; int cnt, res = 0; - unsigned char bytes[] = { byte }; - unsigned char* buf; - std::size_t p; - std::string pattern(bytes, bytes + 1); + uint8_t* p; for (;;) { @@ -274,19 +271,18 @@ JERRCODE CBitStreamInput::SeekAfterByte(uint8_t byte, int* skipped) if(JPEG_OK != jerr) return jerr; } - buf = (unsigned char*) &m_pData[m_currPos]; + cnt = m_DataLen - m_currPos; - std::string search(buf, buf + cnt); + p = std::find(m_pData + m_currPos, m_pData + m_DataLen, byte); + if(p != m_pData + m_DataLen) break; - p = search.find(pattern); - if(p != std::string::npos) break; res += cnt; m_currPos += cnt; m_nUsedBytes += cnt; } - cnt = (int) p; + cnt = (int) (p - m_pData - m_currPos); res += cnt; ++cnt; m_currPos += cnt; diff --git a/_studio/shared/umc/codec/jpeg_dec/include/dechtbl.h b/_studio/shared/umc/codec/jpeg_dec/include/dechtbl.h index 7b2569c3b..6e5e33ac9 100644 --- a/_studio/shared/umc/codec/jpeg_dec/include/dechtbl.h +++ b/_studio/shared/umc/codec/jpeg_dec/include/dechtbl.h @@ -26,20 +26,9 @@ #include "ippj.h" #include "jpegbase.h" -#if defined(MFX_ENABLE_JPEG_SW_FALLBACK) - - #if defined(MSDK_USE_EXTERNAL_IPP) - #include "ipp2mfx.h" - #endif -#endif - class CJPEGDecoderHuffmanTable { private: -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - IppiDecodeHuffmanSpec* m_table; -#endif - uint8_t m_bits[16]; uint8_t m_vals[256]; bool m_bEmpty; @@ -66,38 +55,9 @@ class CJPEGDecoderHuffmanTable bool IsValid(void) { return m_bValid; } void SetInvalid(void) { m_bValid = 0; return; } -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - operator IppiDecodeHuffmanSpec*(void) { return m_table; } -#endif - const uint8_t* GetBits() const { return m_bits; } const uint8_t* GetValues() const { return m_vals; } }; - -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -class CJPEGDecoderHuffmanState -{ -private: - IppiDecodeHuffmanState* m_state; - -public: - CJPEGDecoderHuffmanState(void); - virtual ~CJPEGDecoderHuffmanState(void); - - CJPEGDecoderHuffmanState(const CJPEGDecoderHuffmanState&) = delete; - CJPEGDecoderHuffmanState(CJPEGDecoderHuffmanState&&) = delete; - CJPEGDecoderHuffmanState& operator=(const CJPEGDecoderHuffmanState&) = delete; - CJPEGDecoderHuffmanState& operator=(CJPEGDecoderHuffmanState&&) = delete; - - JERRCODE Create(void); - JERRCODE Destroy(void); - - JERRCODE Init(void); - - operator IppiDecodeHuffmanState*(void) { return m_state; } -}; -#endif - #endif // MFX_ENABLE_MJPEG_VIDEO_DECODE #endif // __DECHTBL_H__ diff --git a/_studio/shared/umc/codec/jpeg_dec/include/decqtbl.h b/_studio/shared/umc/codec/jpeg_dec/include/decqtbl.h index 10c1399c0..2c6bbfed7 100644 --- a/_studio/shared/umc/codec/jpeg_dec/include/decqtbl.h +++ b/_studio/shared/umc/codec/jpeg_dec/include/decqtbl.h @@ -26,21 +26,10 @@ #include "ippj.h" #include "jpegbase.h" -#if defined(MFX_ENABLE_JPEG_SW_FALLBACK) - #if defined(MSDK_USE_EXTERNAL_IPP) - #include "ipp2mfx.h" - #endif -#endif - class CJPEGDecoderQuantTable { private: uint8_t m_rbf[DCTSIZE2*sizeof(uint16_t)+(CPU_CACHE_LINE-1)]; -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - uint8_t m_qbf[DCTSIZE2*sizeof(float)+(CPU_CACHE_LINE-1)]; - uint16_t* m_qnt16u; - float* m_qnt32f; -#endif public: int m_id; @@ -55,13 +44,6 @@ class CJPEGDecoderQuantTable JERRCODE Init(int id,uint8_t raw[DCTSIZE2]); JERRCODE Init(int id,uint16_t raw[DCTSIZE2]); -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - JERRCODE ConvertToLowPrecision(void); - JERRCODE ConvertToHighPrecision(void); - - operator uint16_t*() { return m_precision == 0 ? m_qnt16u : 0; } - operator float*() { return m_precision == 1 ? m_qnt32f : 0; } -#endif }; diff --git a/_studio/shared/umc/codec/jpeg_dec/include/jpegdec.h b/_studio/shared/umc/codec/jpeg_dec/include/jpegdec.h index ee96c2db2..02f573659 100644 --- a/_studio/shared/umc/codec/jpeg_dec/include/jpegdec.h +++ b/_studio/shared/umc/codec/jpeg_dec/include/jpegdec.h @@ -1,4 +1,4 @@ -// Copyright (c) 2001-2019 Intel Corporation +// Copyright (c) 2001-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -162,9 +162,6 @@ class CJPEGDecoder : public CJPEGDecoderBase #endif IMAGE m_dst; -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - CJPEGDecoderHuffmanState m_state; -#endif public: JERRCODE Init(void); diff --git a/_studio/shared/umc/codec/jpeg_dec/include/umc_mjpeg_mfx_decode.h b/_studio/shared/umc/codec/jpeg_dec/include/umc_mjpeg_mfx_decode.h index 2edd4d57a..13dc6dc76 100644 --- a/_studio/shared/umc/codec/jpeg_dec/include/umc_mjpeg_mfx_decode.h +++ b/_studio/shared/umc/codec/jpeg_dec/include/umc_mjpeg_mfx_decode.h @@ -74,9 +74,6 @@ class MJPEGVideoDecoderMFX : public MJPEGVideoDecoderBaseMFX virtual FrameData *GetDst(void); - // Get next frame - virtual Status DecodePicture(const CJpegTask &task, const mfxU32 threadNumber, const mfxU32 callNumber); - void SetFrameAllocator(FrameAllocator * frameAllocator) override; Status DecodeHeader(MediaData* in); @@ -120,11 +117,6 @@ class MJPEGVideoDecoderMFX : public MJPEGVideoDecoderBaseMFX void AdjustFrameSize(mfxSize & size) override; - Status DecodePiece(const mfxU32 fieldNum, - const mfxU32 restartNum, - const mfxU32 restartsToDecode, - const mfxU32 threadNum); - Status _DecodeHeader(int32_t* nUsedBytes, const uint32_t threadNum); int32_t m_frameNo; diff --git a/_studio/shared/umc/codec/jpeg_dec/src/dechtbl.cpp b/_studio/shared/umc/codec/jpeg_dec/src/dechtbl.cpp index fee074d98..b6f58130a 100644 --- a/_studio/shared/umc/codec/jpeg_dec/src/dechtbl.cpp +++ b/_studio/shared/umc/codec/jpeg_dec/src/dechtbl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2001-2019 Intel Corporation +// Copyright (c) 2001-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,9 +29,6 @@ CJPEGDecoderHuffmanTable::CJPEGDecoderHuffmanTable(void) { m_id = 0; m_hclass = 0; -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - m_table = 0; -#endif m_bEmpty = 1; m_bValid = 0; @@ -51,30 +48,6 @@ CJPEGDecoderHuffmanTable::~CJPEGDecoderHuffmanTable(void) JERRCODE CJPEGDecoderHuffmanTable::Create(void) { -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - int size; - int status; - - status = mfxiDecodeHuffmanSpecGetBufSize_JPEG_8u(&size); - if(ippStsNoErr != status) - { - LOG1("IPP Error: mfxiDecodeHuffmanSpecGetBufSize_JPEG_8u() failed - ",status); - return JPEG_ERR_INTERNAL; - } - - if(0 != m_table) - { - free(m_table); - m_table = 0; - } - - m_table = (IppiDecodeHuffmanSpec*)malloc(size); - if(0 == m_table) - { - LOG0("IPP Error: malloc() failed"); - return JPEG_ERR_ALLOC; - } -#endif m_bEmpty = 0; m_bValid = 0; @@ -90,13 +63,6 @@ JERRCODE CJPEGDecoderHuffmanTable::Destroy(void) memset(m_bits, 0, sizeof(m_bits)); memset(m_vals, 0, sizeof(m_vals)); -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - if(0 != m_table) - { - free(m_table); - m_table = 0; - } -#endif m_bValid = 0; m_bEmpty = 1; @@ -112,91 +78,10 @@ JERRCODE CJPEGDecoderHuffmanTable::Init(int id,int hclass,uint8_t* bits,uint8_t* MFX_INTERNAL_CPY(m_bits,bits,16); MFX_INTERNAL_CPY(m_vals,vals,256); -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - int status = mfxiDecodeHuffmanSpecInit_JPEG_8u(m_bits,m_vals,m_table); - if(ippStsNoErr != status) - { - LOG1("IPP Error: mfxiDecodeHuffmanSpecInit_JPEG_8u() failed - ",status); - return JPEG_ERR_DHT_DATA; - } -#endif m_bValid = 1; m_bEmpty = 0; return JPEG_OK; } // CJPEGDecoderHuffmanTable::Init() - - -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -CJPEGDecoderHuffmanState::CJPEGDecoderHuffmanState(void) -{ - m_state = 0; - return; -} // ctor - - -CJPEGDecoderHuffmanState::~CJPEGDecoderHuffmanState(void) -{ - Destroy(); - return; -} // dtor - - -JERRCODE CJPEGDecoderHuffmanState::Create(void) -{ - int size; - int status; - - status = mfxiDecodeHuffmanStateGetBufSize_JPEG_8u(&size); - if(ippStsNoErr != status) - { - LOG1("IPP Error: mfxiDecodeHuffmanStateGetBufSize_JPEG_8u() failed - ",status); - return JPEG_ERR_INTERNAL; - } - - if(0 != m_state) - { - free(m_state); - m_state = 0; - } - - m_state = (IppiDecodeHuffmanState*)malloc(size); - if(0 == m_state) - { - LOG0("IPP Error: malloc() failed"); - return JPEG_ERR_ALLOC; - } - - return JPEG_OK; -} // CJPEGDecoderHuffmanState::Create() - - -JERRCODE CJPEGDecoderHuffmanState::Destroy(void) -{ - if(0 != m_state) - { - free(m_state); - m_state = 0; - } - - return JPEG_OK; -} // CJPEGDecoderHuffmanState::Destroy() - - -JERRCODE CJPEGDecoderHuffmanState::Init(void) -{ - int status; - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - LOG1("IPP Error: mfxiDecodeHuffmanStateInit_JPEG_8u() failed - ",status); - return JPEG_ERR_INTERNAL; - } - - return JPEG_OK; -} // CJPEGDecoderHuffmanState::Init() -#endif // #ifdef MFX_ENABLE_JPEG_SW_FALLBACK - #endif // MFX_ENABLE_MJPEG_VIDEO_DECODE diff --git a/_studio/shared/umc/codec/jpeg_dec/src/decqtbl.cpp b/_studio/shared/umc/codec/jpeg_dec/src/decqtbl.cpp index 98947e37a..1f289a339 100644 --- a/_studio/shared/umc/codec/jpeg_dec/src/decqtbl.cpp +++ b/_studio/shared/umc/codec/jpeg_dec/src/decqtbl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2001-2019 Intel Corporation +// Copyright (c) 2001-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -43,12 +43,6 @@ CJPEGDecoderQuantTable::CJPEGDecoderQuantTable(void) m_raw16u = UMC::align_pointer(m_rbf,CPU_CACHE_LINE); memset(m_rbf, 0, sizeof(m_rbf)); -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - m_qnt16u = UMC::align_pointer(m_qbf,CPU_CACHE_LINE); - m_qnt32f = UMC::align_pointer(m_qbf,CPU_CACHE_LINE); - - memset(m_qbf, 0, sizeof(m_qbf)); -#endif return; } // ctor @@ -60,9 +54,7 @@ CJPEGDecoderQuantTable::~CJPEGDecoderQuantTable(void) m_initialized = 0; memset(m_rbf, 0, sizeof(m_rbf)); -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - memset(m_qbf, 0, sizeof(m_qbf)); -#endif + return; } // dtor @@ -73,112 +65,21 @@ JERRCODE CJPEGDecoderQuantTable::Init(int id,uint8_t raw[64]) m_precision = 0; // 8-bit precision MFX_INTERNAL_CPY(m_raw8u,raw,DCTSIZE2); - -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - int status = mfxiQuantInvTableInit_JPEG_8u16u(m_raw8u,m_qnt16u); - if(ippStsNoErr != status) - { - LOG1("IPP Error: mfxiQuantInvTableInit_JPEG_8u16u() failed - ",status); - return JPEG_ERR_INTERNAL; - } -#endif m_initialized = 1; return JPEG_OK; } // CJPEGDecoderQuantTable::Init() -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -static -int mfxiQuantInvTableInit_JPEG_16u32f( - uint16_t* raw, - float* qnt) -{ - uint16_t wb[DCTSIZE2]; - int status; - - status = mfxiZigzagInv8x8_16s_C1((int16_t*)raw,(int16_t*)wb); - if(ippStsNoErr != status) - { - return status; - } - - for(int i = 0; i < DCTSIZE2; i++) - ((float*)qnt)[i] = (float)((uint16_t*)wb)[i]; - - return ippStsNoErr; -} // mfxiQuantInvTableInit_JPEG_16u32f() -#endif - JERRCODE CJPEGDecoderQuantTable::Init(int id,uint16_t raw[64]) { m_id = id & 0x0f; m_precision = 1; // 16-bit precision MFX_INTERNAL_CPY((int16_t*)m_raw16u, (int16_t*)raw, DCTSIZE2*sizeof(int16_t)); -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - int status = mfxiQuantInvTableInit_JPEG_16u32f(m_raw16u,m_qnt32f); - if(ippStsNoErr != status) - { - LOG1("IPP Error: mfxiQuantInvTableInit_JPEG_16u32f() failed - ",status); - return JPEG_ERR_INTERNAL; - } -#endif m_initialized = 1; return JPEG_OK; } // CJPEGDecoderQuantTable::Init() -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -JERRCODE CJPEGDecoderQuantTable::ConvertToLowPrecision(void) -{ - int status; - - status = mfxiZigzagInv8x8_16s_C1((int16_t*)m_raw16u,(int16_t*)m_qnt16u); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_precision = 0; // 8-bit precision - m_initialized = 1; - - return JPEG_OK; -} // CJPEGDecoderQuantTable::ConvertToLowPrecision() - - -JERRCODE CJPEGDecoderQuantTable::ConvertToHighPrecision(void) -{ - int step; - mfxSize roi = { DCTSIZE, DCTSIZE }; - uint16_t wb[DCTSIZE2]; - int status; - - step = DCTSIZE * sizeof(int16_t); - - status = mfxiConvert_8u16u_C1R(m_raw8u,DCTSIZE*sizeof(uint8_t),wb,step,roi); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - status = mfxiCopy_16s_C1R((int16_t*)wb,step,(int16_t*)m_raw16u,step,roi); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - status = mfxiQuantInvTableInit_JPEG_16u32f(m_raw16u,m_qnt32f); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_precision = 1; // 16-bit precision - m_initialized = 1; - - return JPEG_OK; -} // CJPEGDecoderQuantTable::ConvertToHighPrecision() -#endif - #endif // MFX_ENABLE_MJPEG_VIDEO_DECODE diff --git a/_studio/shared/umc/codec/jpeg_dec/src/jpegdec.cpp b/_studio/shared/umc/codec/jpeg_dec/src/jpegdec.cpp index 6802291d2..089c10f0d 100644 --- a/_studio/shared/umc/codec/jpeg_dec/src/jpegdec.cpp +++ b/_studio/shared/umc/codec/jpeg_dec/src/jpegdec.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2001-2020 Intel Corporation +// Copyright (c) 2001-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -184,78 +184,6 @@ void CJPEGDecoder::Reset(void) return; } // CJPEGDecoder::Reset(void) - -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - -JERRCODE CJPEGDecoder::Clean(void) -{ - int i; - - m_jpeg_comment_detected = 0; - - if(0 != m_jpeg_comment) - { - free(m_jpeg_comment); - m_jpeg_comment = 0; - m_jpeg_comment_size = 0; - } - - m_avi1_app0_detected = 0; - m_avi1_app0_polarity = 0; - m_avi1_app0_reserved = 0; - m_avi1_app0_field_size = 0; - m_avi1_app0_field_size2 = 0; - - m_jfif_app0_detected = 0; - m_jfxx_app0_detected = 0; - - m_exif_app1_detected = 0; - - if(0 != m_exif_app1_data) - { - free(m_exif_app1_data); - m_exif_app1_data = 0; - } - - m_adobe_app14_detected = 0; - - m_curr_scan->ncomps = 0; - m_init_done = 0; - - for(i = 0; i < MAX_COMPS_PER_SCAN; i++) - { - if(0 != m_ccomp[i].m_curr_row) - { - free(m_ccomp[i].m_curr_row); - m_ccomp[i].m_curr_row = 0; - } - if(0 != m_ccomp[i].m_prev_row) - { - free(m_ccomp[i].m_prev_row); - m_ccomp[i].m_prev_row = 0; - } - } - - for(i = 0; i < MAX_HUFF_TABLES; i++) - { - m_dctbl[i].Destroy(); - m_actbl[i].Destroy(); - } - - if(0 != m_block_buffer) - { - free(m_block_buffer); - m_block_buffer = 0; - } - m_block_buffer_size = 0; - - m_state.Destroy(); - - return JPEG_OK; -} // CJPEGDecoder::Clean() -#endif // MFX_ENABLE_JPEG_SW_FALLBACK - - JERRCODE CJPEGDecoder::SetDestination( uint8_t* pDst, int dstStep, @@ -383,39 +311,6 @@ JERRCODE CJPEGDecoder::SetDestination( return JPEG_OK; } // CJPEGDecoder::SetDestination() -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -JERRCODE CJPEGDecoder::ProcessRestart(void) -{ - JERRCODE jerr; - int status; - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - LOG0("Error: mfxiDecodeHuffmanStateInit_JPEG_8u() failed"); - return JPEG_ERR_INTERNAL; - } - - for(int n = 0; n < m_jpeg_ncomp; n++) - { - m_ccomp[n].m_lastDC = 0; - } - - jerr = ParseRST(); - if(JPEG_OK != jerr) - { - LOG0("Error: ParseRST() failed"); - return jerr; - } - - m_rst_go = 1; - m_restarts_to_go = m_curr_scan->jpeg_restart_interval; - - return JPEG_OK; -} // CJPEGDecoder::ProcessRestart() -#endif // MFX_ENABLE_JPEG_SW_FALLBACK - - JERRCODE CJPEGDecoder::ParseAPP1(void) { int i; @@ -1323,173 +1218,6 @@ JERRCODE CJPEGDecoder::ParseJPEGBitStream(JOPERATION op) return jerr; } // CJPEGDecoder::ParseJPEGBitStream() -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - -JERRCODE CJPEGDecoder::Init(void) -{ - int i; - int tr_buf_size = 0; - CJPEGColorComponent* curr_comp; - JERRCODE jerr; - - if(m_init_done) - return JPEG_OK; - - m_num_threads = get_num_threads(); - - // need to add support for images with more than 4 components per frame - - if(m_dst.precision <= 8) - { - switch (m_jpeg_dct_scale) - { - case JD_1_1: - default: - { - m_dd_factor = 1; - } - break; - - case JD_1_2: - { - m_dd_factor = 2; - } - break; - - case JD_1_4: - { - m_dd_factor = 4; - } - break; - - case JD_1_8: - { - m_dd_factor = 8; - } - break; - } - } - - for(i = 0; i < m_jpeg_ncomp; i++) - { - curr_comp = &m_ccomp[i]; - - switch(m_jpeg_mode) - { - case JPEG_BASELINE: - case JPEG_EXTENDED: - { - int ds = (m_dst.precision <= 8) ? sizeof(uint8_t) : sizeof(int16_t); - - int lnz_ds = curr_comp->m_vsampling * curr_comp->m_hsampling; - curr_comp->m_lnz_bufsize = lnz_ds * m_numxMCU; - curr_comp->m_lnz_ds = lnz_ds; - - curr_comp->m_cc_height = m_mcuHeight; - curr_comp->m_cc_step = m_numxMCU * m_mcuWidth * ds; - - curr_comp->m_ss_height = curr_comp->m_cc_height / curr_comp->m_v_factor; - curr_comp->m_ss_step = curr_comp->m_cc_step / curr_comp->m_h_factor; - - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - curr_comp->m_ss_height += 2; // add border lines (top and bottom) - } - - tr_buf_size = m_numxMCU * m_nblock * DCTSIZE2 * sizeof(int16_t) * m_num_threads; - - break; - } // JPEG_BASELINE - - case JPEG_PROGRESSIVE: - { - int lnz_ds = curr_comp->m_vsampling * curr_comp->m_hsampling; - curr_comp->m_lnz_bufsize = lnz_ds * m_numxMCU; - curr_comp->m_lnz_ds = lnz_ds; - - curr_comp->m_cc_height = m_mcuHeight; - curr_comp->m_cc_step = m_numxMCU * m_mcuWidth; - - curr_comp->m_ss_height = curr_comp->m_cc_height / curr_comp->m_v_factor; - curr_comp->m_ss_step = curr_comp->m_cc_step / curr_comp->m_h_factor; - - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - curr_comp->m_ss_height += 2; // add border lines (top and bottom) - } - - tr_buf_size = m_numxMCU * m_numyMCU * m_nblock * DCTSIZE2 * sizeof(int16_t); - - break; - } // JPEG_PROGRESSIVE - - case JPEG_LOSSLESS: - { - int lnz_ds = curr_comp->m_vsampling * curr_comp->m_hsampling; - curr_comp->m_lnz_bufsize = lnz_ds * m_numxMCU; - curr_comp->m_lnz_ds = lnz_ds; - - curr_comp->m_cc_height = m_mcuHeight; - curr_comp->m_cc_step = m_numxMCU * m_mcuWidth * sizeof(int16_t); - - curr_comp->m_ss_height = curr_comp->m_cc_height / curr_comp->m_v_factor; - curr_comp->m_ss_step = curr_comp->m_cc_step / curr_comp->m_h_factor; - - if(m_curr_scan->ncomps == m_jpeg_ncomp) - tr_buf_size = m_numxMCU * m_nblock * sizeof(int16_t); - else - tr_buf_size = m_numxMCU * m_numyMCU * m_nblock * sizeof(int16_t); - - curr_comp->m_curr_row = (int16_t*)malloc(curr_comp->m_cc_step * sizeof(int16_t)); - if(0 == curr_comp->m_curr_row) - return JPEG_ERR_ALLOC; - - curr_comp->m_prev_row = (int16_t*)malloc(curr_comp->m_cc_step * sizeof(int16_t)); - if(0 == curr_comp->m_prev_row) - return JPEG_ERR_ALLOC; - - break; - } // JPEG_LOSSLESS - - default: - return JPEG_ERR_PARAMS; - } // m_jpeg_mode - - // color convert buffer - jerr = curr_comp->CreateBufferCC(m_num_threads); - if(JPEG_OK != jerr) - return jerr; - - jerr = curr_comp->CreateBufferSS(m_num_threads); - if(JPEG_OK != jerr) - return jerr; - - jerr = curr_comp->CreateBufferLNZ(m_num_threads); - if(JPEG_OK != jerr) - return jerr; - - } // m_jpeg_ncomp - - if(0 == m_block_buffer) - { - m_block_buffer = (int16_t*)malloc(tr_buf_size); - if(0 == m_block_buffer) - { - return JPEG_ERR_ALLOC; - } - m_block_buffer_size = tr_buf_size; - memset((uint8_t*)m_block_buffer, 0, tr_buf_size); - } - - m_state.Create(); - - m_init_done = 1; - - return JPEG_OK; -} // CJPEGDecoder::Init() -#endif // MFX_ENABLE_JPEG_SW_FALLBACK - - static uint32_t JPEG_BPP[JC_MAX] = { @@ -2430,2156 +2158,92 @@ JERRCODE CJPEGDecoder::ProcessBuffer(int nMCURow, int thread_id) return JPEG_OK; } // JERRCODE CJPEGDecoder::ProcessBuffer() - -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK -JERRCODE CJPEGDecoder::DecodeHuffmanMCURowBL(int16_t* pMCUBuf, uint32_t colMCU, uint32_t maxMCU) +JERRCODE CJPEGDecoder::ReconstructMCURowLS( + int16_t* pMCUBuf, + int nMCURow, + int thread_id) { - int n, k, l; - uint32_t j; - int srcLen; - int currPos; - uint8_t* src; - JERRCODE jerr; + int n; + int dstStep; + int16_t* ptr; + int16_t* pCurrRow; + int16_t* pPrevRow; + uint8_t* pDst8u = 0; + int16_t* pDst16s = 0; + mfxSize roi; int status; + CJPEGColorComponent* curr_comp; - src = m_BitStreamIn.GetDataPtr(); - srcLen = m_BitStreamIn.GetDataLen(); + roi.width = m_dst.width; + roi.height = 1; - for(j = colMCU; j < maxMCU; j++) + for(n = 0; n < m_jpeg_ncomp; n++) { - if(m_curr_scan->jpeg_restart_interval) + curr_comp = &m_ccomp[n]; + + if(m_dst.precision <= 8) { - if(m_restarts_to_go == 0) - { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } - } + dstStep = curr_comp->m_cc_step; + pDst8u = curr_comp->GetCCBufferPtr(thread_id); } - - for(n = m_curr_scan->first_comp; n < m_curr_scan->first_comp + m_curr_scan->ncomps; n++) + else { - int16_t* lastDC = &m_ccomp[n].m_lastDC; - if (m_ccomp[n].m_dc_selector >= MAX_HUFF_TABLES) - { - return JPEG_ERR_PARAMS; - } - if (m_dctbl[m_ccomp[n].m_dc_selector].IsEmpty()) - return JPEG_ERR_PARAMS; - if (m_ccomp[n].m_ac_selector >= MAX_HUFF_TABLES) - { - return JPEG_ERR_PARAMS; - } - - IppiDecodeHuffmanSpec* dctbl = m_dctbl[m_ccomp[n].m_dc_selector]; - IppiDecodeHuffmanSpec* actbl = m_actbl[m_ccomp[n].m_ac_selector]; - - for(k = 0; k < m_ccomp[n].m_scan_vsampling; k++) - { - for(l = 0; l < m_ccomp[n].m_scan_hsampling; l++) - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - if(NULL==actbl||NULL==dctbl) - { - return JPEG_ERR_BAD_DATA; - } - status = mfxiDecodeHuffman8x8_JPEG_1u16s_C1( - src,srcLen,&currPos,pMCUBuf,lastDC,(int*)&m_marker, - dctbl,actbl,m_state); - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffman8x8_JPEG_1u16s_C1() failed!"); - m_marker = JM_NONE; - return JPEG_ERR_INTERNAL; - } - - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - - m_restarts_to_go--; - } // for m_numxMCU - - return JPEG_OK; - -} // JERRCODE CJPEGDecoder::DecodeHuffmanMCURowBL(int16_t* pMCUBuf, uint32_t colMCU, uint32_t maxMCU) - - -JERRCODE CJPEGDecoder::DecodeHuffmanMCURowLS(int16_t* pMCUBuf) -{ - int c; - uint8_t* src; - int16_t* dst[4]; - int srcLen; - int currPos; - const IppiDecodeHuffmanSpec* dctbl[4]; - JERRCODE jerr; - int status; - - for(c = 0; c < m_jpeg_ncomp; c++) - { - dst[c] = pMCUBuf + c * m_numxMCU; - dctbl[c] = m_dctbl[m_ccomp[c].m_dc_selector]; - } + dstStep = curr_comp->m_cc_step; + pDst16s = (int16_t*)curr_comp->GetCCBufferPtr(thread_id); + } - src = m_BitStreamIn.GetDataPtr(); - srcLen = m_BitStreamIn.GetDataLen(); + if(m_jpeg_ncomp == m_curr_scan->ncomps) + ptr = pMCUBuf + n*m_numxMCU; + else + ptr = pMCUBuf + n*m_numxMCU*m_numyMCU + nMCURow*m_numxMCU; -#if defined (HUFF_ROW_API) + pCurrRow = curr_comp->m_curr_row; + pPrevRow = curr_comp->m_prev_row; - if(m_curr_scan->jpeg_restart_interval) - { - if(m_restarts_to_go == 0) + if(0 != nMCURow && 0 == m_rst_go) { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } + status = mfxiReconstructPredRow_JPEG_16s_C1( + ptr,pPrevRow,pCurrRow,m_dst.width,m_ss); + } + else + { + status = mfxiReconstructPredFirstRow_JPEG_16s_C1( + ptr,pCurrRow,m_dst.width,m_jpeg_precision,m_al); } - } - - m_BitStreamIn.FillBuffer(); - - currPos = m_BitStreamIn.GetCurrPos(); - status = mfxiDecodeHuffmanRow_JPEG_1u16s_C1P4( - src,srcLen,&currPos,dst, m_numxMCU, m_jpeg_ncomp, (int*)&m_marker, - dctbl,m_state); + if(ippStsNoErr != status) + { + return JPEG_ERR_INTERNAL; + } - m_BitStreamIn.SetCurrPos(currPos); + // do point-transform if any + status = mfxsLShiftC_16s(pCurrRow,m_al,pPrevRow,m_dst.width); + if(ippStsNoErr != status) + { + return JPEG_ERR_INTERNAL; + } - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffmanRow_JPEG_1u16s_C1P4() failed!"); - return JPEG_ERR_INTERNAL; - } + if(m_dst.precision <= 8) + { + status = mfxiAndC_16u_C1IR(0xFF, (uint16_t*)pPrevRow, m_dst.width*sizeof(int16_t),roi); + status = mfxiConvert_16u8u_C1R((uint16_t*)pPrevRow,m_dst.width*sizeof(int16_t),pDst8u,dstStep,roi); + } + else + status = mfxsCopy_16s(pPrevRow,pDst16s,m_dst.width); - m_restarts_to_go -= m_numxMCU; + if(ippStsNoErr != status) + { + return JPEG_ERR_INTERNAL; + } -#else + curr_comp->m_curr_row = pPrevRow; + curr_comp->m_prev_row = pCurrRow; + } // for m_jpeg_ncomp - int j, h, v; - CJPEGColorComponent* curr_comp; - - for(j = 0; j < m_numxMCU; j++) - { - if(m_curr_scan->jpeg_restart_interval) - { - if(m_restarts_to_go == 0) - { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } - } - } - - for(c = 0; c < m_jpeg_ncomp; c++) - { - curr_comp = &m_ccomp[c]; - - for(v = 0; v < curr_comp->m_vsampling; v++) - { - for(h = 0; h < curr_comp->m_hsampling; h++) - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - - status = mfxiDecodeHuffmanOne_JPEG_1u16s_C1( - src,srcLen,&currPos,dst[c],(int*)&m_marker, - dctbl[c],m_state); - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffmanOne_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - - dst[c]++; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - - m_restarts_to_go --; - } // for m_numxMCU -#endif - - return JPEG_OK; -} // CJPEGDecoder::DecodeHuffmanMCURowLS() - -JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8_NxN(int16_t* pMCUBuf, - uint32_t colMCU, - uint32_t maxMCU) -{ - int c, k, l, curr_lnz; - uint32_t mcu_col; - uint8_t* lnz = 0; - uint8_t* dst = 0; - int dstStep = m_ccWidth; - int status; - CJPEGColorComponent* curr_comp; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - const int thread_id = 0; - - for(mcu_col = colMCU; mcu_col < maxMCU; mcu_col++) - { - for(c = 0; c < m_jpeg_ncomp; c++) - { - curr_comp = &m_ccomp[c]; - lnz = m_ccomp[c].GetLNZBufferPtr(thread_id); - curr_lnz = mcu_col * curr_comp->m_lnz_ds; - - if (curr_comp->m_q_selector >= MAX_QUANT_TABLES) - { - return JPEG_ERR_PARAMS; - } - uint16_t* qtbl = m_qntbl[curr_comp->m_q_selector]; - if(!qtbl) - { - LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8_NxN() m_qntbl[] is empty for ", - curr_comp->m_q_selector); - return JPEG_ERR_INTERNAL; - } - - for(k = 0; k < curr_comp->m_vsampling; k++) - { - if(curr_comp->m_hsampling == m_max_hsampling && - curr_comp->m_vsampling == m_max_vsampling) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*8*curr_comp->m_hsampling + k*8*dstStep; - } - else - { - dstStep = curr_comp->m_ss_step; - dst = curr_comp->GetSSBufferPtr(thread_id) + mcu_col*8*curr_comp->m_hsampling + k*8*dstStep; - - curr_comp->m_need_upsampling = 1; - } - - // skip border row (when 244 or 411 sampling) - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - dst += dstStep; - } - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += l*8; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - - if(lnz[curr_lnz] == 1) // 1x1 - { - status = mfxiDCTQuantInv8x8LS_1x1_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - } - else if(lnz[curr_lnz] < 5 && pMCUBuf[16] == 0) //2x2 - { - status = mfxiDCTQuantInv8x8LS_2x2_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - } - else if(lnz[curr_lnz] <= 24 //4x4 - && pMCUBuf[32] == 0 - && pMCUBuf[33] == 0 - && pMCUBuf[34] == 0 - && pMCUBuf[4] == 0 - && pMCUBuf[12] == 0) - { - status = mfxiDCTQuantInv8x8LS_4x4_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - } - else // 8x8 - { - status = mfxiDCTQuantInv8x8LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - } - - curr_lnz = curr_lnz + 1; - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8_NxNLS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } // for m_numxMCU - - return JPEG_OK; -} // CJPEGDecoder::ReconstructMCURowBL8x8_NxN() - - -JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8(int16_t* pMCUBuf, - uint32_t colMCU, - uint32_t maxMCU) -{ - int c, k, l; - uint32_t mcu_col; - uint8_t* dst = 0; - uint8_t* p = 0; - int dstStep = m_ccWidth; - uint16_t* qtbl; - int status; - CJPEGColorComponent* curr_comp; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - const uint32_t thread_id = 0; - - for(mcu_col = colMCU; mcu_col < maxMCU; mcu_col++) - { - for(c = m_curr_scan->first_comp; c < m_curr_scan->first_comp + m_curr_scan->ncomps; c++) - { - curr_comp = &m_ccomp[c]; - if(curr_comp->m_q_selector >= MAX_QUANT_TABLES) - { - return JPEG_ERR_PARAMS; - } - qtbl = m_qntbl[curr_comp->m_q_selector]; - if(!qtbl) - { - LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8_NxN() m_qntbl[] is empty for ", - curr_comp->m_q_selector); - return JPEG_ERR_INTERNAL; - } - - for(k = 0; k < curr_comp->m_scan_vsampling; k++) - { - if(curr_comp->m_hsampling == m_max_hsampling && - curr_comp->m_vsampling == m_max_vsampling) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*8*curr_comp->m_scan_hsampling + k*8*dstStep; - } - else - { - dstStep = curr_comp->m_ss_step; - dst = curr_comp->GetSSBufferPtr(thread_id) + mcu_col*8*curr_comp->m_scan_hsampling + k*8*dstStep; - - curr_comp->m_need_upsampling = 1; - } - - for(l = 0; l < curr_comp->m_scan_hsampling; l++) - { - p = dst + l*8; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - - status = mfxiDCTQuantInv8x8LS_JPEG_16s8u_C1R(pMCUBuf, p, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } // for m_numxMCU - - return JPEG_OK; - -} // CJPEGDecoder::ReconstructMCURowBL8x8() - - -JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8To4x4(int16_t* pMCUBuf, - uint32_t colMCU, - uint32_t maxMCU) -{ - int c, k, l; - uint32_t mcu_col; - uint8_t* dst = 0; - int dstStep = m_ccWidth; - uint16_t* qtbl; - int status; - CJPEGColorComponent* curr_comp; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - const int thread_id = 0; - - for(mcu_col = colMCU; mcu_col < maxMCU; mcu_col++) - { - for(c = 0; c < m_jpeg_ncomp; c++) - { - curr_comp = &m_ccomp[c]; - if(curr_comp->m_q_selector >= MAX_QUANT_TABLES) - { - return JPEG_ERR_PARAMS; - } - qtbl = m_qntbl[curr_comp->m_q_selector]; - if(!qtbl) - { - LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8To4x4() m_qntbl[] is empty for ", - curr_comp->m_q_selector); - return JPEG_ERR_INTERNAL; - } - - for(k = 0; k < curr_comp->m_vsampling; k++) - { - if(curr_comp->m_hsampling == m_max_hsampling && - curr_comp->m_vsampling == m_max_vsampling) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*4*curr_comp->m_hsampling + k*4*dstStep; - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*4; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDCTQuantInv8x8To4x4LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8To4x4LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - else - { - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2 && m_dst.order == JD_PIXEL) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*8*curr_comp->m_hsampling + k*8*dstStep; - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*8; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDCTQuantInv8x8LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - else - { - dstStep = curr_comp->m_ss_step; - dst = curr_comp->GetSSBufferPtr(thread_id) + mcu_col*4*curr_comp->m_hsampling + k*4*dstStep; - - curr_comp->m_need_upsampling = 1; - - // skip border row (when 244 or 411 sampling) - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - dst += dstStep; - } - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*4; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDCTQuantInv8x8To4x4LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8To4x4LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } // for m_numxMCU - - return JPEG_OK; -} // CJPEGDecoder::ReconstructMCURowBL8x8To4x4() - - -JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8To2x2(int16_t* pMCUBuf, - uint32_t colMCU, - uint32_t maxMCU) -{ - int c, k, l; - uint32_t mcu_col; - uint8_t* dst = 0; - int dstStep = m_ccWidth; - uint16_t* qtbl; - int status; - CJPEGColorComponent* curr_comp; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - const int thread_id = 0; - - for(mcu_col = colMCU; mcu_col < maxMCU; mcu_col++) - { - for(c = 0; c < m_jpeg_ncomp; c++) - { - curr_comp = &m_ccomp[c]; - if(curr_comp->m_q_selector >= MAX_QUANT_TABLES) - { - return JPEG_ERR_PARAMS; - } - qtbl = m_qntbl[curr_comp->m_q_selector]; - if(!qtbl) - { - LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8To4x4() m_qntbl[] is empty for ", - curr_comp->m_q_selector); - return JPEG_ERR_INTERNAL; - } - - for(k = 0; k < curr_comp->m_vsampling; k++) - { - if(curr_comp->m_hsampling == m_max_hsampling && - curr_comp->m_vsampling == m_max_vsampling) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*2*curr_comp->m_hsampling + k*2*dstStep; - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*2; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDCTQuantInv8x8To2x2LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8To2x2LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - else - { - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2 && m_dst.order == JD_PIXEL) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*4*curr_comp->m_hsampling + k*4*dstStep; - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*4; - - status = mfxiDCTQuantInv8x8To4x4LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8To4x4LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - else - { - dstStep = curr_comp->m_ss_step; - dst = curr_comp->GetSSBufferPtr(thread_id) + mcu_col*2*curr_comp->m_hsampling + k*2*dstStep; - - curr_comp->m_need_upsampling = 1; - - // skip border row (when 244 or 411 sampling) - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - dst += dstStep; - } - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*2; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDCTQuantInv8x8To2x2LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8To2x2LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } // for m_numxMCU - - return JPEG_OK; -} // CJPEGDecoder::ReconstructMCURowBL8x8To2x2() - - -JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8To1x1(int16_t* pMCUBuf, - uint32_t colMCU, - uint32_t maxMCU) -{ - int c, k, l; - uint32_t mcu_col; - uint8_t* dst = 0; - int dstStep = m_ccWidth; - uint16_t* qtbl; - int status; - - CJPEGColorComponent* curr_comp; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - const int thread_id = 0; - - for(mcu_col = colMCU; mcu_col < maxMCU; mcu_col++) - { - for(c = 0; c < m_jpeg_ncomp; c++) - { - curr_comp = &m_ccomp[c]; - if(curr_comp->m_q_selector >= MAX_QUANT_TABLES) - { - return JPEG_ERR_PARAMS; - } - qtbl = m_qntbl[curr_comp->m_q_selector]; - if(!qtbl) - { - LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8To1x1() m_qntbl[] is empty for ", - curr_comp->m_q_selector); - return JPEG_ERR_INTERNAL; - } - - for(k = 0; k < curr_comp->m_vsampling; k++) - { - if(curr_comp->m_hsampling == m_max_hsampling && - curr_comp->m_vsampling == m_max_vsampling) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*curr_comp->m_hsampling + k*dstStep; - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += (l == 0) ? 0 : 1; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - DCT_QUANT_INV8x8To1x1LS(pMCUBuf, dst, qtbl); - -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - else - { - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2 && m_dst.order == JD_PIXEL) - { - dstStep = curr_comp->m_cc_step; - dst = curr_comp->GetCCBufferPtr(thread_id) + mcu_col*2*curr_comp->m_hsampling + k*2*dstStep; - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += ((l == 0) ? 0 : 1)*2; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDCTQuantInv8x8To2x2LS_JPEG_16s8u_C1R(pMCUBuf, dst, dstStep, qtbl); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8To2x2LS_JPEG_16s8u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } - else - { - dstStep = curr_comp->m_ss_step; - dst = curr_comp->GetSSBufferPtr(thread_id) + mcu_col*curr_comp->m_hsampling + k*dstStep; - - curr_comp->m_need_upsampling = 1; - - // skip border row (when 244 or 411 sampling) - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - dst += dstStep; - } - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += (l == 0) ? 0 : 1; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - DCT_QUANT_INV8x8To1x1LS(pMCUBuf, dst, qtbl); - -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } // if - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } // for m_numxMCU - - return JPEG_OK; -} // CJPEGDecoder::ReconstructMCURowBL8x8To1x1() - - -JERRCODE CJPEGDecoder::ReconstructMCURowEX(int16_t* pMCUBuf, - uint32_t colMCU, - uint32_t maxMCU) -{ - int c, k, l; - uint32_t mcu_col; - uint16_t* dst = 0; - int dstStep; - float* qtbl; - int status; - CJPEGColorComponent* curr_comp; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - const int thread_id = 0; - - for(mcu_col = colMCU; mcu_col < maxMCU; mcu_col++) - { - for(c = 0; c < m_jpeg_ncomp; c++) - { - curr_comp = &m_ccomp[c]; - - if(curr_comp->m_q_selector >= MAX_QUANT_TABLES) - { - return JPEG_ERR_PARAMS; - } - qtbl = m_qntbl[curr_comp->m_q_selector]; - if(!qtbl) - { - LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8To1x1() m_qntbl[] is empty for ", - curr_comp->m_q_selector); - return JPEG_ERR_INTERNAL; - } - - for(k = 0; k < curr_comp->m_vsampling; k++) - { - if(curr_comp->m_hsampling == m_max_hsampling && - curr_comp->m_vsampling == m_max_vsampling) - { - dstStep = curr_comp->m_cc_step; - dst = (uint16_t*)(curr_comp->GetCCBufferPtr(thread_id) + mcu_col*8*curr_comp->m_hsampling*sizeof(int16_t) + k*8*dstStep*sizeof(int16_t)); - } - else - { - dstStep = curr_comp->m_ss_step; - dst = (uint16_t*)(curr_comp->GetSSBufferPtr(thread_id) + mcu_col*8*curr_comp->m_hsampling*sizeof(int16_t) + k*8*dstStep*sizeof(int16_t)); - - curr_comp->m_need_upsampling = 1; - } - - // skip border row (when 244 or 411 sampling) - if(curr_comp->m_h_factor == 2 && curr_comp->m_v_factor == 2) - { - dst += dstStep; - } - - for(l = 0; l < curr_comp->m_hsampling; l++) - { - dst += l*8; - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - - status = mfxiDCTQuantInv8x8LS_JPEG_16s16u_C1R( - pMCUBuf,dst,dstStep,qtbl); - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDCTQuantInv8x8LS_JPEG_16s16u_C1R() failed!"); - return JPEG_ERR_INTERNAL; - } - - -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - - pMCUBuf += DCTSIZE2; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } // for m_numxMCU - - return JPEG_OK; -} // CJPEGDecoder::ReconstructMCURowEX() - -#endif // MFX_ENABLE_JPEG_SW_FALLBACK - - -JERRCODE CJPEGDecoder::ReconstructMCURowLS( - int16_t* pMCUBuf, - int nMCURow, - int thread_id) -{ - int n; - int dstStep; - int16_t* ptr; - int16_t* pCurrRow; - int16_t* pPrevRow; - uint8_t* pDst8u = 0; - int16_t* pDst16s = 0; - mfxSize roi; - int status; - CJPEGColorComponent* curr_comp; - - roi.width = m_dst.width; - roi.height = 1; - - for(n = 0; n < m_jpeg_ncomp; n++) - { - curr_comp = &m_ccomp[n]; - - if(m_dst.precision <= 8) - { - dstStep = curr_comp->m_cc_step; - pDst8u = curr_comp->GetCCBufferPtr(thread_id); - } - else - { - dstStep = curr_comp->m_cc_step; - pDst16s = (int16_t*)curr_comp->GetCCBufferPtr(thread_id); - } - - if(m_jpeg_ncomp == m_curr_scan->ncomps) - ptr = pMCUBuf + n*m_numxMCU; - else - ptr = pMCUBuf + n*m_numxMCU*m_numyMCU + nMCURow*m_numxMCU; - - pCurrRow = curr_comp->m_curr_row; - pPrevRow = curr_comp->m_prev_row; - - if(0 != nMCURow && 0 == m_rst_go) - { - status = mfxiReconstructPredRow_JPEG_16s_C1( - ptr,pPrevRow,pCurrRow,m_dst.width,m_ss); - } - else - { - status = mfxiReconstructPredFirstRow_JPEG_16s_C1( - ptr,pCurrRow,m_dst.width,m_jpeg_precision,m_al); - } - - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - // do point-transform if any - status = mfxsLShiftC_16s(pCurrRow,m_al,pPrevRow,m_dst.width); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - if(m_dst.precision <= 8) - { - status = mfxiAndC_16u_C1IR(0xFF, (uint16_t*)pPrevRow, m_dst.width*sizeof(int16_t),roi); - status = mfxiConvert_16u8u_C1R((uint16_t*)pPrevRow,m_dst.width*sizeof(int16_t),pDst8u,dstStep,roi); - } - else - status = mfxsCopy_16s(pPrevRow,pDst16s,m_dst.width); - - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - curr_comp->m_curr_row = pPrevRow; - curr_comp->m_prev_row = pCurrRow; - } // for m_jpeg_ncomp - - m_rst_go = 0; - - return JPEG_OK; -} // CJPEGDecoder::ReconstructMCURowLS() - -#ifdef MFX_ENABLE_JPEG_SW_FALLBACK - -JERRCODE CJPEGDecoder::DecodeScanBaseline(void) -{ - int status; - JERRCODE jerr = JPEG_OK; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - if(0 == m_curr_scan->scan_no) - { - m_curr_scan->first_comp = 0; - } - else if(1 == m_curr_scan->scan_no && (2 == m_curr_scan->ncomps || (1 == m_curr_scan->ncomps && 3 == m_num_scans))) - { - m_curr_scan->first_comp = 1; - } - else if((1 == m_curr_scan->scan_no && 1 == m_curr_scan->ncomps && 2 == m_num_scans) || 2 == m_curr_scan->scan_no) - { - m_curr_scan->first_comp = 2; - } - else - { - return JPEG_ERR_SOS_DATA; - } - - m_marker = JM_NONE; - - // workaround for 8-bit qnt tables in 12-bit scans - if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[0].ConvertToHighPrecision(); - - if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[1].ConvertToHighPrecision(); - - if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[2].ConvertToHighPrecision(); - - if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[3].ConvertToHighPrecision(); - - // workaround for 16-bit qnt tables in 8-bit scans - if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[0].ConvertToLowPrecision(); - - if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[1].ConvertToLowPrecision(); - - if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[2].ConvertToLowPrecision(); - - if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[3].ConvertToLowPrecision(); - - if(m_dctbl[0].IsEmpty()) - { - jerr = m_dctbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[0].Init(0,0,(uint8_t*)&DefaultLuminanceDCBits[0],(uint8_t*)&DefaultLuminanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_dctbl[1].IsEmpty()) - { - jerr = m_dctbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[1].Init(1,0,(uint8_t*)&DefaultChrominanceDCBits[0],(uint8_t*)&DefaultChrominanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[0].IsEmpty()) - { - jerr = m_actbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[0].Init(0,1,(uint8_t*)&DefaultLuminanceACBits[0],(uint8_t*)&DefaultLuminanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[1].IsEmpty()) - { - jerr = m_actbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[1].Init(1,1,(uint8_t*)&DefaultChrominanceACBits[0],(uint8_t*)&DefaultChrominanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - { - int16_t* pMCUBuf; - uint32_t rowMCU, colMCU, maxMCU; - uint32_t numxMCU = m_curr_scan->numxMCU; - uint32_t numyMCU = m_curr_scan->numyMCU; - - // the pointer to Buffer for a current thread. - pMCUBuf = m_block_buffer; - - // set the iterators - rowMCU = 0; - colMCU = 0; - maxMCU = numxMCU; - if (m_curr_scan->jpeg_restart_interval) - { - if(numxMCU == 0) - return JPEG_ERR_PARAMS; - rowMCU = m_mcu_decoded / numxMCU; - colMCU = m_mcu_decoded % numxMCU; - maxMCU = (numxMCU < colMCU + m_mcu_to_decode) ? - (numxMCU) : - (colMCU + m_mcu_to_decode); - } - - while (rowMCU < numyMCU) - { - // decode a MCU row -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - if (m_numxMCU * m_nblock * DCTSIZE2 > (uint32_t)m_block_buffer_size) - return JPEG_ERR_BUFF; - mfxsZero_16s(pMCUBuf, m_numxMCU * m_nblock * DCTSIZE2); - - jerr = DecodeHuffmanMCURowBL(pMCUBuf, colMCU, maxMCU); - if (JPEG_OK != jerr) - return jerr; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_huff += (c1 - c0); -#endif - - // reconstruct a MCU row -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - if(m_jpeg_precision == 12) - jerr = ReconstructMCURowEX(pMCUBuf, colMCU, maxMCU); - else - { - switch (m_jpeg_dct_scale) - { - default: - case JD_1_1: - { - if(m_use_qdct) - jerr = ReconstructMCURowBL8x8_NxN(pMCUBuf, colMCU, maxMCU); - else - jerr = ReconstructMCURowBL8x8(pMCUBuf, colMCU, maxMCU); - } - break; - - case JD_1_2: - { - jerr = ReconstructMCURowBL8x8To4x4(pMCUBuf, colMCU, maxMCU); - } - break; - - case JD_1_4: - { - jerr = ReconstructMCURowBL8x8To2x2(pMCUBuf, colMCU, maxMCU); - } - break; - - case JD_1_8: - { - jerr = ReconstructMCURowBL8x8To1x1(pMCUBuf, colMCU, maxMCU); - } - break; - } - } - - if (JPEG_OK != jerr) - return jerr; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - - jerr = UpSampling(rowMCU, colMCU, maxMCU); - if (JPEG_OK != jerr) - return jerr; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_ss += c1 - c0; -#endif - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - jerr = ColorConvert(rowMCU, colMCU, maxMCU); - if (JPEG_OK != jerr) - return jerr; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_cc += c1 - c0; -#endif - - // increment interators - if (m_curr_scan->jpeg_restart_interval) - { - m_mcu_decoded += (maxMCU - colMCU); - m_mcu_to_decode -= (maxMCU - colMCU); - if (0 == m_mcu_to_decode) - { - return JPEG_OK; - } - maxMCU = (numxMCU < m_mcu_to_decode) ? - (numxMCU) : - (m_mcu_to_decode); - } - else - { - maxMCU = numxMCU; - } - - rowMCU += 1; - colMCU = 0; - } - } - - return JPEG_OK; -} // CJPEGDecoder::DecodeScanBaseline() - - -JERRCODE CJPEGDecoder::DecodeScanBaselineIN(void) -{ - int status; - JERRCODE jerr = JPEG_OK; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_marker = JM_NONE; - - // workaround for 8-bit qnt tables in 12-bit scans - if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[0].ConvertToHighPrecision(); - - if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[1].ConvertToHighPrecision(); - - if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[2].ConvertToHighPrecision(); - - if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[3].ConvertToHighPrecision(); - - // workaround for 16-bit qnt tables in 8-bit scans - if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[0].ConvertToLowPrecision(); - - if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[1].ConvertToLowPrecision(); - - if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[2].ConvertToLowPrecision(); - - if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[3].ConvertToLowPrecision(); - - if(m_dctbl[0].IsEmpty()) - { - jerr = m_dctbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[0].Init(0,0,(uint8_t*)&DefaultLuminanceDCBits[0],(uint8_t*)&DefaultLuminanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_dctbl[1].IsEmpty()) - { - jerr = m_dctbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[1].Init(1,0,(uint8_t*)&DefaultChrominanceDCBits[0],(uint8_t*)&DefaultChrominanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[0].IsEmpty()) - { - jerr = m_actbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[0].Init(0,1,(uint8_t*)&DefaultLuminanceACBits[0],(uint8_t*)&DefaultLuminanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[1].IsEmpty()) - { - jerr = m_actbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[1].Init(1,1,(uint8_t*)&DefaultChrominanceACBits[0],(uint8_t*)&DefaultChrominanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - { - int16_t* pMCUBuf; - uint32_t rowMCU, colMCU, maxMCU; - - // the pointer to Buffer for a current thread. - pMCUBuf = m_block_buffer; - - // set the iterators - rowMCU = 0; - colMCU = 0; - maxMCU = m_numxMCU; - if (m_curr_scan->jpeg_restart_interval) - { - rowMCU = m_mcu_decoded / m_numxMCU; - colMCU = m_mcu_decoded % m_numxMCU; - maxMCU = (m_numxMCU < colMCU + m_mcu_to_decode) ? - (m_numxMCU) : - (colMCU + m_mcu_to_decode); - } - - while (rowMCU < m_numyMCU) - { - // decode a MCU row -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - mfxsZero_16s(pMCUBuf,m_numxMCU * m_nblock * DCTSIZE2); - - jerr = DecodeHuffmanMCURowBL(pMCUBuf, colMCU, maxMCU); - if (JPEG_OK != jerr) - return jerr; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_huff += (c1 - c0); -#endif - - // reconstruct a MCU row -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - if(m_jpeg_precision == 12) - jerr = ReconstructMCURowEX(pMCUBuf, colMCU, maxMCU); - else - { - switch (m_jpeg_dct_scale) - { - default: - case JD_1_1: - { - if(m_use_qdct) - jerr = ReconstructMCURowBL8x8_NxN(pMCUBuf, colMCU, maxMCU); - else - jerr = ReconstructMCURowBL8x8(pMCUBuf, colMCU, maxMCU); - } - break; - - case JD_1_2: - { - jerr = ReconstructMCURowBL8x8To4x4(pMCUBuf, colMCU, maxMCU); - } - break; - - case JD_1_4: - { - jerr = ReconstructMCURowBL8x8To2x2(pMCUBuf, colMCU, maxMCU); - } - break; - - case JD_1_8: - { - jerr = ReconstructMCURowBL8x8To1x1(pMCUBuf, colMCU, maxMCU); - } - break; - } - } - - if(JPEG_OK != jerr) - continue; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - - jerr = UpSampling(rowMCU, colMCU, maxMCU); - if(JPEG_OK != jerr) - continue; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_ss += c1 - c0; -#endif - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - jerr = ColorConvert(rowMCU, colMCU, maxMCU); - if(JPEG_OK != jerr) - continue; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_cc += c1 - c0; -#endif - - // increment interators - if (m_curr_scan->jpeg_restart_interval) - { - m_mcu_decoded += (maxMCU - colMCU); - m_mcu_to_decode -= (maxMCU - colMCU); - if (0 == m_mcu_to_decode) - { - return JPEG_ERR_BUFF; - } - maxMCU = (m_numxMCU < m_mcu_to_decode) ? - (m_numxMCU) : - (m_mcu_to_decode); - } - else - { - maxMCU = m_numxMCU; - } - - rowMCU += 1; - colMCU = 0; - } - } - - return JPEG_OK; - -} // CJPEGDecoder::DecodeScanBaselineIN() - - -JERRCODE CJPEGDecoder::DecodeScanBaselineIN_P(void) -{ - int status; - JERRCODE jerr = JPEG_OK; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_marker = JM_NONE; - - // workaround for 8-bit qnt tables in 12-bit scans - if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[0].ConvertToHighPrecision(); - - if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[1].ConvertToHighPrecision(); - - if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[2].ConvertToHighPrecision(); - - if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 0 && m_jpeg_precision == 12) - m_qntbl[3].ConvertToHighPrecision(); - - // workaround for 16-bit qnt tables in 8-bit scans - if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[0].ConvertToLowPrecision(); - - if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[1].ConvertToLowPrecision(); - - if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[2].ConvertToLowPrecision(); - - if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 1 && m_jpeg_precision == 8) - m_qntbl[3].ConvertToLowPrecision(); - - if(m_dctbl[0].IsEmpty()) - { - jerr = m_dctbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[0].Init(0,0,(uint8_t*)&DefaultLuminanceDCBits[0],(uint8_t*)&DefaultLuminanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_dctbl[1].IsEmpty()) - { - jerr = m_dctbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[1].Init(1,0,(uint8_t*)&DefaultChrominanceDCBits[0],(uint8_t*)&DefaultChrominanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[0].IsEmpty()) - { - jerr = m_actbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[0].Init(0,1,(uint8_t*)&DefaultLuminanceACBits[0],(uint8_t*)&DefaultLuminanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[1].IsEmpty()) - { - jerr = m_actbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[1].Init(1,1,(uint8_t*)&DefaultChrominanceACBits[0],(uint8_t*)&DefaultChrominanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - -#ifdef _OPENMP -#pragma omp parallel default(shared) if(m_jpeg_sampling != JS_420) -#endif - { - int i; - int idThread = 0; - int16_t* pMCUBuf; // the pointer to Buffer for a current thread. - -#ifdef _OPENMP - idThread = omp_get_thread_num(); // the thread id of the calling thread. -#endif - - pMCUBuf = m_block_buffer + idThread * m_numxMCU * m_nblock * DCTSIZE2; - - i = 0; - - while(i < (int) m_numyMCU) - { -#ifdef _OPENMP -#pragma omp critical (IPP_JPEG_OMP) -#endif - { - if(i < (int) m_numyMCU) - { -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - mfxsZero_16s(pMCUBuf,m_numxMCU * m_nblock * DCTSIZE2); - - jerr = DecodeHuffmanMCURowBL(pMCUBuf, 0, m_numxMCU); -// if(JPEG_OK != jerr) -// i = m_numyMCU; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_huff += (c1 - c0); -#endif - } - } - - if(i < (int) m_numyMCU) - { -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - if(m_jpeg_precision == 12) - jerr = ReconstructMCURowEX(pMCUBuf, 0, m_numxMCU); - else - { - switch (m_jpeg_dct_scale) - { - case JD_1_1: - { - if(m_use_qdct) - jerr = ReconstructMCURowBL8x8_NxN(pMCUBuf, 0, m_numxMCU); - else - jerr = ReconstructMCURowBL8x8(pMCUBuf, 0, m_numxMCU); - } - break; - - case JD_1_2: - { - jerr = ReconstructMCURowBL8x8To4x4(pMCUBuf, 0, m_numxMCU); - } - break; - - case JD_1_4: - { - jerr = ReconstructMCURowBL8x8To2x2(pMCUBuf, 0, m_numxMCU); - } - break; - - case JD_1_8: - { - jerr = ReconstructMCURowBL8x8To1x1(pMCUBuf, 0, m_numxMCU); - } - break; - - default: - break; - } - } - - if(JPEG_OK != jerr) - continue; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_dct += c1 - c0; -#endif - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - - jerr = ProcessBuffer(i,idThread); - if(JPEG_OK != jerr) - continue; - -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_ss += c1 - c0; -#endif - } - - i++; - } // for m_numyMCU - } // OMP - - return JPEG_OK; -} // CJPEGDecoder::DecodeScanBaselineIN_P() - - -JERRCODE CJPEGDecoder::DecodeScanBaselineNI(void) -{ - int i, j, k, l, c; - int srcLen; - int currPos; - uint8_t* src; - int16_t* block; - JERRCODE jerr; - int status; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - - m_ac_scans_completed += m_curr_scan->ncomps; - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_marker = JM_NONE; - - src = m_BitStreamIn.GetDataPtr(); - srcLen = m_BitStreamIn.GetDataLen(); - - if(m_dctbl[0].IsEmpty()) - { - jerr = m_dctbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[0].Init(0,0,(uint8_t*)&DefaultLuminanceDCBits[0],(uint8_t*)&DefaultLuminanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_dctbl[1].IsEmpty()) - { - jerr = m_dctbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_dctbl[1].Init(1,0,(uint8_t*)&DefaultChrominanceDCBits[0],(uint8_t*)&DefaultChrominanceDCValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[0].IsEmpty()) - { - jerr = m_actbl[0].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[0].Init(0,1,(uint8_t*)&DefaultLuminanceACBits[0],(uint8_t*)&DefaultLuminanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - if(m_actbl[1].IsEmpty()) - { - jerr = m_actbl[1].Create(); - if(JPEG_OK != jerr) - return jerr; - - jerr = m_actbl[1].Init(1,1,(uint8_t*)&DefaultChrominanceACBits[0],(uint8_t*)&DefaultChrominanceACValues[0]); - if(JPEG_OK != jerr) - return jerr; - } - - for(i = 0; i < (int) m_numyMCU; i++) - { - for(k = 0; k < m_ccomp[m_curr_comp_no].m_vsampling; k++) - { - if(i*m_ccomp[m_curr_comp_no].m_vsampling*8 + k*8 >= m_jpeg_height) - break; - - for(j = 0; j < (int) m_numxMCU; j++) - { - for(c = 0; c < m_curr_scan->ncomps; c++) - { - block = m_block_buffer + (DCTSIZE2*m_nblock*(j+(i*m_numxMCU))); - - // skip any relevant components - for(c = 0; c < m_ccomp[m_curr_comp_no].m_comp_no; c++) - { - block += (DCTSIZE2*m_ccomp[c].m_nblocks); - } - - // Skip over relevant 8x8 blocks from this component. - block += (k * DCTSIZE2 * m_ccomp[m_curr_comp_no].m_hsampling); - - for(l = 0; l < m_ccomp[m_curr_comp_no].m_hsampling; l++) - { - // Ignore the last column(s) of the image. - if(((j*m_ccomp[m_curr_comp_no].m_hsampling*8) + (l*8)) >= m_jpeg_width) - break; - - if(m_curr_scan->jpeg_restart_interval) - { - if(m_restarts_to_go == 0) - { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } - } - } - - int16_t* lastDC = &m_ccomp[m_curr_comp_no].m_lastDC; - IppiDecodeHuffmanSpec* dctbl = m_dctbl[m_ccomp[m_curr_comp_no].m_dc_selector]; - IppiDecodeHuffmanSpec* actbl = m_actbl[m_ccomp[m_curr_comp_no].m_ac_selector]; - - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDecodeHuffman8x8_JPEG_1u16s_C1( - src,srcLen,&currPos,block,lastDC,(int*)&m_marker, - dctbl,actbl,m_state); -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_huff += (c1 - c0); -#endif - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffman8x8_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - - block += DCTSIZE2; - - m_restarts_to_go --; - } // for m_hsampling - } // for m_scan_ncomps - } // for m_numxMCU - } // for m_vsampling - } // for m_numyMCU - - return JPEG_OK; -} // CJPEGDecoder::DecodeScanBaselineNI() - - -JERRCODE CJPEGDecoder::DecodeScanProgressive(void) -{ - int i, j, k, n, l, c; - int srcLen; - int currPos; - uint8_t* src; - int16_t* block; - JERRCODE jerr; - int status; - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_marker = JM_NONE; - - src = m_BitStreamIn.GetDataPtr(); - srcLen = m_BitStreamIn.GetDataLen(); - - if(m_ss != 0 && m_se != 0) - { - // AC scan - for(i = 0; i < (int) m_numyMCU; i++) - { - for(k = 0; k < m_ccomp[m_curr_comp_no].m_vsampling; k++) - { - if(i*m_ccomp[m_curr_comp_no].m_vsampling*8 + k*8 >= m_jpeg_height) - break; - - for(j = 0; j < (int) m_numxMCU; j++) - { - block = m_block_buffer + (DCTSIZE2*m_nblock*(j+(i*m_numxMCU))); - - // skip any relevant components - for(c = 0; c < m_ccomp[m_curr_comp_no].m_comp_no; c++) - { - block += (DCTSIZE2*m_ccomp[c].m_nblocks); - } - - // Skip over relevant 8x8 blocks from this component. - block += (k * DCTSIZE2 * m_ccomp[m_curr_comp_no].m_hsampling); - - for(l = 0; l < m_ccomp[m_curr_comp_no].m_hsampling; l++) - { - // Ignore the last column(s) of the image. - if(((j*m_ccomp[m_curr_comp_no].m_hsampling*8) + (l*8)) >= m_jpeg_width) - break; - - if(m_curr_scan->jpeg_restart_interval) - { - if(m_restarts_to_go == 0) - { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } - } - } - - IppiDecodeHuffmanSpec* actbl = m_actbl[m_ccomp[m_curr_comp_no].m_ac_selector]; - - if(m_ah == 0) - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - - status = mfxiDecodeHuffman8x8_ACFirst_JPEG_1u16s_C1( - src,srcLen,&currPos,block,(int*)&m_marker, - m_ss,m_se,m_al,actbl,m_state); - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffman8x8_ACFirst_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - } - else - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - - status = mfxiDecodeHuffman8x8_ACRefine_JPEG_1u16s_C1( - src,srcLen,&currPos,block,(int*)&m_marker, - m_ss,m_se,m_al,actbl,m_state); - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffman8x8_ACRefine_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - } - - block += DCTSIZE2; - - m_restarts_to_go --; - } // for m_hsampling - } // for m_numxMCU - } // for m_vsampling - } // for m_numyMCU - - if(m_al == 0 && m_se == 63) - { - m_ccomp[m_curr_comp_no].m_ac_scan_completed = 1; - } - } - else - { - // DC scan - for(i = 0; i < (int) m_numyMCU; i++) - { - for(j = 0; j < (int) m_numxMCU; j++) - { - if(m_curr_scan->jpeg_restart_interval) - { - if(m_restarts_to_go == 0) - { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } - } - } - - block = m_block_buffer + (DCTSIZE2*m_nblock*(j+(i*m_numxMCU))); - - if(m_ah == 0) - { - // first DC scan - for(n = 0; n < m_jpeg_ncomp; n++) - { - int16_t* lastDC = &m_ccomp[n].m_lastDC; - IppiDecodeHuffmanSpec* dctbl = m_dctbl[m_ccomp[n].m_dc_selector]; - - for(k = 0; k < m_ccomp[n].m_vsampling; k++) - { - for(l = 0; l < m_ccomp[n].m_hsampling; l++) - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - - status = mfxiDecodeHuffman8x8_DCFirst_JPEG_1u16s_C1( - src,srcLen,&currPos,block,lastDC,(int*)&m_marker, - m_al,dctbl,m_state); - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffman8x8_DCFirst_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - - block += DCTSIZE2; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } - else - { - // refine DC scan - for(n = 0; n < m_jpeg_ncomp; n++) - { - for(k = 0; k < m_ccomp[n].m_vsampling; k++) - { - for(l = 0; l < m_ccomp[n].m_hsampling; l++) - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - - status = mfxiDecodeHuffman8x8_DCRefine_JPEG_1u16s_C1( - src,srcLen,&currPos,block,(int*)&m_marker, - m_al,m_state); - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffman8x8_DCRefine_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - - block += DCTSIZE2; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - } - m_restarts_to_go --; - } // for m_numxMCU - } // for m_numyMCU - - if(m_al == 0) - { - m_dc_scan_completed = 1; - } - } - - return JPEG_OK; -} // CJPEGDecoder::DecodeScanProgressive() - - -JERRCODE CJPEGDecoder::DecodeScanLosslessIN(void) -{ - int i; - int16_t* pMCUBuf; - JERRCODE jerr; - int status; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_marker = JM_NONE; - - m_ac_scans_completed += m_curr_scan->ncomps; - - pMCUBuf = m_block_buffer; - - for(i = 0; i < (int) m_numyMCU; i++) - { -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - jerr = DecodeHuffmanMCURowLS(pMCUBuf); - if(JPEG_OK != jerr) - { - return jerr; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_huff += c1 - c0; -#endif - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - jerr = ReconstructMCURowLS(pMCUBuf, i); - if(JPEG_OK != jerr) - { - return jerr; - } -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_diff += c1 - c0; -#endif - - if(m_curr_scan->ncomps == m_jpeg_ncomp) - { -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - jerr = ColorConvert(i, 0, m_numxMCU); - if(JPEG_OK != jerr) - return jerr; -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_cc += c1 - c0; -#endif - } - } // for m_numyMCU - - return JPEG_OK; -} // CJPEGDecoder::DecodeScanLosslessIN() - - -JERRCODE CJPEGDecoder::DecodeScanLosslessNI(void) -{ - int i, j, n, v, h; - uint8_t* src; - int srcLen; - int currPos; - int16_t* ptr; - int16_t* pMCUBuf; - JERRCODE jerr; - int status; -#ifdef __TIMING__ - unsigned long long c0; - unsigned long long c1; -#endif - - status = mfxiDecodeHuffmanStateInit_JPEG_8u(m_state); - if(ippStsNoErr != status) - { - return JPEG_ERR_INTERNAL; - } - - m_marker = JM_NONE; - - m_ac_scans_completed += m_curr_scan->ncomps; - - pMCUBuf = m_block_buffer + m_curr_comp_no*m_numxMCU*m_numyMCU; - - src = m_BitStreamIn.GetDataPtr(); - srcLen = m_BitStreamIn.GetDataLen(); - - for(i = 0; i < (int) m_numyMCU; i++) - { - for(j = 0; j < (int) m_numxMCU; j++) - { - if(m_curr_scan->jpeg_restart_interval) - { - if(m_restarts_to_go == 0) - { - jerr = ProcessRestart(); - if(JPEG_OK != jerr) - { - LOG0("Error: ProcessRestart() failed!"); - return jerr; - } - } - } - - for(n = 0; n < m_curr_scan->ncomps; n++) - { - CJPEGColorComponent* curr_comp = &m_ccomp[m_curr_comp_no]; - IppiDecodeHuffmanSpec* dctbl = m_dctbl[curr_comp->m_dc_selector]; - - ptr = pMCUBuf + j*m_mcuWidth; - - for(v = 0; v < curr_comp->m_vsampling; v++) - { - for(h = 0; h < curr_comp->m_hsampling; h++) - { - m_BitStreamIn.FillBuffer(SAFE_NBYTES); - - currPos = m_BitStreamIn.GetCurrPos(); - -#ifdef __TIMING__ - c0 = mfxGetCpuClocks(); -#endif - status = mfxiDecodeHuffmanOne_JPEG_1u16s_C1( - src,srcLen,&currPos,ptr,(int*)&m_marker, - dctbl,m_state); -#ifdef __TIMING__ - c1 = mfxGetCpuClocks(); - m_clk_huff += c1 - c0; -#endif - - m_BitStreamIn.SetCurrPos(currPos); - - if(ippStsNoErr > status) - { - LOG0("Error: mfxiDecodeHuffmanOne_JPEG_1u16s_C1() failed!"); - return JPEG_ERR_INTERNAL; - } - - ptr++; - } // for m_hsampling - } // for m_vsampling - } // for m_jpeg_ncomp - - m_restarts_to_go --; - } // for m_numxMCU - - pMCUBuf += m_numxMCU; - } // for m_numyMCU + m_rst_go = 0; return JPEG_OK; -} // CJPEGDecoder::DecodeScanLosslessNI() - -#endif // MFX_ENABLE_JPEG_SW_FALLBACK +} // CJPEGDecoder::ReconstructMCURowLS() JERRCODE CJPEGDecoder::ReadHeader( int* width, diff --git a/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode.cpp b/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode.cpp index 458663a07..03c1b7648 100644 --- a/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode.cpp +++ b/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode.cpp @@ -299,8 +299,8 @@ Status MJPEGVideoDecoderMFX::FillVideoParam(mfxVideoParam *par, bool /*full*/) par->mfx.FrameInfo.AspectRatioW = 0; par->mfx.FrameInfo.AspectRatioH = 0; - par->mfx.FrameInfo.FrameRateExtD = 1; - par->mfx.FrameInfo.FrameRateExtN = 30; + par->mfx.FrameInfo.FrameRateExtD = 0; + par->mfx.FrameInfo.FrameRateExtN = 0; par->mfx.CodecProfile = 1; par->mfx.CodecLevel = 1; @@ -545,121 +545,6 @@ Status MJPEGVideoDecoderMFX::SetColorSpace(uint16_t chromaFormat, uint16_t color } // MJPEGVideoDecoderMFX::SetRotation(uint16_t rotation) -Status MJPEGVideoDecoderMFX::DecodePicture(const CJpegTask &task, - const mfxU32 threadNumber, - const mfxU32 callNumber) -{ - Status umcRes = UMC_OK; - mfxU32 picNum, pieceNum; - mfxI32 curr_scan_no; - JERRCODE jerr; - int i; -/* - if(0 == out) - return UMC_ERR_NULL_PTR; - *out = 0;*/ - MFX_LTRACE_1(MFX_TRACE_LEVEL_INTERNAL, "MJPEG, frame: ", "%d", m_frameNo); - - // find appropriate source picture buffer - picNum = 0; - pieceNum = callNumber; - while (task.GetPictureBuffer(picNum).numPieces <= pieceNum) - { - pieceNum -= task.GetPictureBuffer(picNum).numPieces; - picNum += 1; - } - const CJpegTaskBuffer &picBuffer = task.GetPictureBuffer(picNum); - - // check if there is a need to decode the header - if (m_pLastPicBuffer[threadNumber] != &picBuffer) - { - int32_t nUsedBytes = 0; - - // set the source data - jerr = m_dec[threadNumber]->SetSource((uint8_t *) picBuffer.pBuf, - picBuffer.imageHeaderSize + picBuffer.scanSize[0]); - if (JPEG_OK != jerr) - return UMC_ERR_FAILED; - - umcRes = _DecodeHeader(&nUsedBytes, threadNumber); - if (UMC_OK != umcRes) - { - return umcRes; - } - // save the pointer to the last decoded picture - m_pLastPicBuffer[threadNumber] = &picBuffer; - - m_dec[threadNumber]->m_curr_scan = &m_dec[threadNumber]->m_scans[0]; - } - - // determinate scan number contained current piece - if(picBuffer.scanOffset[0] <= picBuffer.pieceOffset[pieceNum] && - (picBuffer.pieceOffset[pieceNum] < picBuffer.scanOffset[1] || 0 == picBuffer.scanOffset[1])) - { - curr_scan_no = 0; - } - else if(picBuffer.scanOffset[1] <= picBuffer.pieceOffset[pieceNum] && - (picBuffer.pieceOffset[pieceNum] < picBuffer.scanOffset[2] || 0 == picBuffer.scanOffset[2])) - { - curr_scan_no = 1; - } - else if(picBuffer.scanOffset[2] <= picBuffer.pieceOffset[pieceNum]) - { - curr_scan_no = 2; - } - else - { - return UMC_ERR_FAILED; - } - - // check if there is a need to decode scan header and DRI segment - if(m_dec[threadNumber]->m_curr_scan->scan_no != curr_scan_no) - { - for(i = 1; i <= curr_scan_no; i++) - { - m_dec[threadNumber]->m_curr_scan = &m_dec[threadNumber]->m_scans[i]; - - if(picBuffer.scanTablesOffset[i] != 0) - { - int32_t nUsedBytes = 0; - jerr = m_dec[threadNumber]->SetSource((uint8_t *) picBuffer.pBuf + picBuffer.scanTablesOffset[i], - picBuffer.scanTablesSize[i] + picBuffer.scanSize[i]); - if (JPEG_OK != jerr) - return UMC_ERR_FAILED; - - umcRes = _DecodeHeader(&nUsedBytes, threadNumber); - if (UMC_OK != umcRes) - { - return umcRes; - } - } - } - } - - m_dec[threadNumber]->m_num_scans = picBuffer.numScans; - - // set the next piece to the decoder - jerr = m_dec[threadNumber]->SetSource(picBuffer.pBuf + picBuffer.pieceOffset[pieceNum], - picBuffer.pieceSize[pieceNum]); - if(JPEG_OK != jerr) - return UMC_ERR_FAILED; - - // decode a next piece from the picture - umcRes = DecodePiece(picBuffer.fieldPos, - (mfxU32)picBuffer.pieceRSTOffset[pieceNum], - (mfxU32)(picBuffer.pieceRSTOffset[pieceNum+1] - picBuffer.pieceRSTOffset[pieceNum]), - threadNumber); - - if (UMC_OK != umcRes) - { - task.surface_out->Data.Corrupted = 1; - return umcRes; - } - - return UMC_OK; - -} // Status MJPEGVideoDecoderMFX::DecodePicture(const CJpegTask &task, - Status MJPEGVideoDecoderMFX::PostProcessing(double pts) { VideoData rotatedFrame; @@ -1024,109 +909,6 @@ Status MJPEGVideoDecoderMFX::_DecodeHeader(int32_t* cnt, const uint32_t threadNu return UMC_OK; } -Status MJPEGVideoDecoderMFX::DecodePiece(const mfxU32 fieldNum, - const mfxU32 restartNum, - const mfxU32 restartsToDecode, - const mfxU32 threadNum) -{ - int32_t dstPlaneStep[4]; - uint8_t* pDstPlane[4]; - int32_t dstStep; - uint8_t* pDst; - //JSS sampling = (JSS)m_frameSampling; - JERRCODE jerr = JPEG_OK; - mfxSize dimension = m_frameDims; - - if (!m_IsInit) - return UMC_ERR_NOT_INITIALIZED; - - if (RGB32 == m_internalFrame.GetColorFormat()) - { - dstStep = (int32_t)m_internalFrame.GetPlanePitch(0); - pDst = (uint8_t*)m_internalFrame.GetPlanePointer(0); - if (m_interleaved) - { - if (fieldNum & 1)//!m_firstField) - pDst += dstStep; - dstStep *= 2; - - dimension.height /= 2; - } - - jerr = m_dec[threadNum]->SetDestination(pDst, dstStep, dimension, m_frameChannels, JC_BGRA, JS_444); - } - else if (YUV444 == m_internalFrame.GetColorFormat()) - { - pDstPlane[0] = (uint8_t*)m_internalFrame.GetPlanePointer(0); - pDstPlane[1] = (uint8_t*)m_internalFrame.GetPlanePointer(1); - pDstPlane[2] = (uint8_t*)m_internalFrame.GetPlanePointer(2); - pDstPlane[3] = 0; - - dstPlaneStep[0] = (int32_t)m_internalFrame.GetPlanePitch(0); - dstPlaneStep[1] = (int32_t)m_internalFrame.GetPlanePitch(1); - dstPlaneStep[2] = (int32_t)m_internalFrame.GetPlanePitch(2); - dstPlaneStep[3] = 0; - - if (m_interleaved) - { - for (int32_t i = 0; i < 3; i++) - { - if (fieldNum & 1)//!m_firstField) - pDstPlane[i] += dstPlaneStep[i]; - dstPlaneStep[i] *= 2; - } - - dimension.height /= 2; - } - - jerr = m_dec[threadNum]->SetDestination(pDstPlane, dstPlaneStep, dimension, m_frameChannels, JC_YCBCR, JS_444); - } - else if (NV12 == m_internalFrame.GetColorFormat()) - { - pDstPlane[0] = (uint8_t*)m_internalFrame.GetPlanePointer(0); - pDstPlane[1] = (uint8_t*)m_internalFrame.GetPlanePointer(1); - pDstPlane[2] = 0; - pDstPlane[3] = 0; - - dstPlaneStep[0] = (int32_t)m_internalFrame.GetPlanePitch(0); - dstPlaneStep[1] = (int32_t)m_internalFrame.GetPlanePitch(1); - dstPlaneStep[2] = 0; - dstPlaneStep[3] = 0; - - if (m_interleaved) - { - for (int32_t i = 0; i < 3; i++) - { - if (fieldNum & 1)//!m_firstField) - pDstPlane[i] += dstPlaneStep[i]; - dstPlaneStep[i] *= 2; - } - - dimension.height /= 2; - } - - jerr = m_dec[threadNum]->SetDestination(pDstPlane, dstPlaneStep, dimension, m_frameChannels, JC_NV12, JS_420); - } - else - { - return UMC_ERR_FAILED; - } - - if(JPEG_OK != jerr) - return UMC_ERR_FAILED; - - jerr = m_dec[threadNum]->ReadData(restartNum, restartsToDecode); - - if(JPEG_ERR_BUFF == jerr) - return UMC_ERR_NOT_ENOUGH_DATA; - - if(JPEG_OK != jerr) - return UMC_ERR_FAILED; - - return UMC_OK; - -} // Status MJPEGVideoDecoderMFX::DecodePiece(const mfxU32 fieldNum, - void MJPEGVideoDecoderMFX::SetFrameAllocator(FrameAllocator * frameAllocator) { assert(frameAllocator); diff --git a/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode_base.cpp b/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode_base.cpp index 18b784dc6..e0ac26c81 100644 --- a/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode_base.cpp +++ b/_studio/shared/umc/codec/jpeg_dec/src/umc_mjpeg_mfx_decode_base.cpp @@ -231,8 +231,8 @@ Status MJPEGVideoDecoderBaseMFX::FillVideoParam(mfxVideoParam *par, bool /*full* par->mfx.FrameInfo.AspectRatioW = 0; par->mfx.FrameInfo.AspectRatioH = 0; - par->mfx.FrameInfo.FrameRateExtD = 1; - par->mfx.FrameInfo.FrameRateExtN = 30; + par->mfx.FrameInfo.FrameRateExtD = 0; + par->mfx.FrameInfo.FrameRateExtN = 0; par->mfx.CodecProfile = 1; par->mfx.CodecLevel = 1; diff --git a/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_splitter.cpp b/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_splitter.cpp index 68401a85a..8b4b7caab 100644 --- a/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_splitter.cpp +++ b/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_splitter.cpp @@ -84,7 +84,7 @@ namespace UMC_MPEG2_DECODER else // start code wasn't found { // Load the data excepte last 1 or 2 bytes if they have zero values (Considering [... 0x0 0x0] [0x1 ...]) to the cache - uint32_t numZerosAtEnd = (0 == end[-1]) ? 1 + (0 == end[-2]) : 0; + uint32_t numZerosAtEnd = (0 == end[-1]) ? 1 + (in->GetDataSize() > 1 ? (0 == end[-2]) : 0) : 0; readSize = (uint32_t)(end - begin - numZerosAtEnd); m_cache.insert(m_cache.end(), (uint8_t *)begin, (uint8_t *)(end - numZerosAtEnd)); } diff --git a/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_utils.cpp b/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_utils.cpp index dfc48840e..f7124e319 100644 --- a/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_utils.cpp +++ b/_studio/shared/umc/codec/mpeg2_dec/src/umc_mpeg2_utils.cpp @@ -245,7 +245,7 @@ namespace UMC_MPEG2_DECODER case 6: frameRateN = 50; frameRateD = 1; break; case 7: frameRateN = 60000; frameRateD = 1001; break; case 8: frameRateN = 60; frameRateD = 1; break; - default: frameRateN = 30; frameRateD = 1; + default: frameRateN = 0; frameRateD = 0; } return; } diff --git a/builder/BuildOptions.cmake b/builder/BuildOptions.cmake index c93a7c12f..17ad949d5 100644 --- a/builder/BuildOptions.cmake +++ b/builder/BuildOptions.cmake @@ -25,8 +25,6 @@ include(CMakeDependentOption) option( MFX_ENABLE_EXT "Build with extensions?" ON ) cmake_dependent_option( MFX_ENABLE_KERNELS "Enable media kernels?" ON "MFX_ENABLE_EXT" OFF ) -option( MFX_ENABLE_JPEG_SW_FALLBACK "Enabled software fallback for JPEG ?" ON ) - option( ENABLE_OPENCL "Build targets dependent on OpenCL?" ON ) @@ -81,14 +79,6 @@ if (BUILD_KERNELS) endif() -# Supported frameworks for surface sharing -# Temporarily disable OpenCL surface sharing on Linux until code is ready -if (CMAKE_SYSTEM_NAME MATCHES Windows) - option( MFX_ENABLE_SHARING_OPENCL "Enable surface sharing between VPL and OpenCL." ON) -else() - set( MFX_ENABLE_SHARING_OPENCL OFF) -endif() - option( MFX_ENABLE_VVC_VIDEO_DECODE "Enabled VVC decoder?" ON) option( MFX_ENABLE_AV1_VIDEO_DECODE "Enabled AV1 decoder?" ON) option( MFX_ENABLE_VP8_VIDEO_DECODE "Enabled VP8 decoder?" ON) diff --git a/debian/changelog b/debian/changelog index 9ed026b0a..16bada122 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +onevpl-intel-gpu (24.4.2-0ubuntu1~24.10~ppa1) oracular; urgency=medium + + * bump version to 24.4.2 + + -- Pavel Androniychuk Fri, 01 Nov 2024 09:26:32 -0700 + onevpl-intel-gpu (24.3.4-0ubuntu1~24.04~ppa1) noble; urgency=medium * bump version to 24.3.4 diff --git a/debian/control b/debian/control index d3b003fdf..672b5d953 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper-compat (= 13), cmake, libdrm-dev, libpciaccess-dev, - libva-dev (>= 2.17), + libva-dev (>= 2.27), libx11-dev, libx11-xcb-dev, libxcb-dri3-dev,