mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #21049 from sivanov-work:vpl_dx11_merge
G-API: oneVPL merge DX11 acceleration * Merge DX11 initial * Fold conditions row in MACRO in utils * Inject DeviceSelector * Turn on DeviceSelector in DX11 * Change sharedLock logic & Move FMT checking in FrameAdapter c-tor * Move out NumSuggestFrame to configure params * Drain file source fix * Fix compilation * Force zero initializetion of SharedLock * Fix some compiler warnings * Fix integer comparison warnings * Fix integers in sample * Integrate Demux * Fix compilation * Add predefined names for some CfgParam * Trigger CI * Fix MultithreadCtx bug, Add Dx11 GetBlobParam(), Get rif of ATL CComPtr * Fix UT: remove unit test with deprecated video from opencv_extra * Add creators for most usable CfgParam * Eliminate some warnings * Fix warning in GAPI_Assert * Apply comments * Add VPL wrapped header with MSVC pragma to get rid of global warning masking
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../test_precomp.hpp"
|
||||
|
||||
#include "../common/gapi_tests_common.hpp"
|
||||
#include "../common/gapi_streaming_tests_common.hpp"
|
||||
|
||||
#include <thread> // sleep_for (Delay)
|
||||
|
||||
@@ -24,18 +24,8 @@
|
||||
#include <opencv2/gapi/streaming/cap.hpp>
|
||||
#include <opencv2/gapi/streaming/desync.hpp>
|
||||
#include <opencv2/gapi/streaming/format.hpp>
|
||||
#include <opencv2/gapi/gstreaming.hpp>
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/source.hpp>
|
||||
#include "streaming/onevpl/data_provider_defines.hpp"
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
|
||||
#if (MFX_VERSION >= 2000)
|
||||
#include <vpl/mfxdispatcher.h>
|
||||
#endif
|
||||
|
||||
#include <vpl/mfx.h>
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
@@ -116,7 +106,7 @@ struct GAPI_Streaming: public ::testing::TestWithParam<std::tuple<KernelPackage,
|
||||
using namespace cv::gapi;
|
||||
auto args = cv::compile_args(use_only{pkg});
|
||||
if (cap) {
|
||||
args += cv::compile_args(streaming::queue_capacity{cap.value()});
|
||||
args += cv::compile_args(cv::gapi::streaming::queue_capacity{cap.value()});
|
||||
}
|
||||
return args;
|
||||
}
|
||||
@@ -269,57 +259,6 @@ void checkPullOverload(const cv::Mat& ref,
|
||||
EXPECT_EQ(0., cv::norm(ref, out_mat, cv::NORM_INF));
|
||||
}
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
struct StreamDataProvider : public cv::gapi::wip::onevpl::IDataProvider {
|
||||
|
||||
StreamDataProvider(std::istream& in) : data_stream (in) {
|
||||
EXPECT_TRUE(in);
|
||||
}
|
||||
|
||||
mfx_codec_id_type get_mfx_codec_id() const override {
|
||||
return MFX_CODEC_HEVC;
|
||||
}
|
||||
|
||||
bool fetch_bitstream_data(std::shared_ptr<mfx_bitstream> &out_bitstream) override {
|
||||
if (empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out_bitstream) {
|
||||
out_bitstream = std::make_shared<mfx_bitstream>();
|
||||
out_bitstream->MaxLength = 2000000;
|
||||
out_bitstream->Data = (mfxU8 *)calloc(out_bitstream->MaxLength, sizeof(mfxU8));
|
||||
if(!out_bitstream->Data) {
|
||||
throw std::runtime_error("Cannot allocate bitstream.Data bytes: " +
|
||||
std::to_string(out_bitstream->MaxLength * sizeof(mfxU8)));
|
||||
}
|
||||
out_bitstream->CodecId = get_mfx_codec_id();
|
||||
}
|
||||
|
||||
mfxU8 *p0 = out_bitstream->Data;
|
||||
mfxU8 *p1 = out_bitstream->Data + out_bitstream->DataOffset;
|
||||
EXPECT_FALSE(out_bitstream->DataOffset > out_bitstream->MaxLength - 1);
|
||||
EXPECT_FALSE(out_bitstream->DataLength + out_bitstream->DataOffset > out_bitstream->MaxLength);
|
||||
|
||||
std::copy_n(p1, out_bitstream->DataLength, p0);
|
||||
|
||||
out_bitstream->DataOffset = 0;
|
||||
out_bitstream->DataLength += static_cast<mfxU32>(fetch_data(out_bitstream->MaxLength - out_bitstream->DataLength,
|
||||
out_bitstream->Data + out_bitstream->DataLength));
|
||||
return out_bitstream->DataLength != 0;
|
||||
}
|
||||
|
||||
size_t fetch_data(size_t out_data_size, void* out_data_buf) {
|
||||
data_stream.read(reinterpret_cast<char*>(out_data_buf), out_data_size);
|
||||
return (size_t)data_stream.gcount();
|
||||
}
|
||||
bool empty() const override {
|
||||
return data_stream.eof() || data_stream.bad();
|
||||
}
|
||||
private:
|
||||
std::istream& data_stream;
|
||||
};
|
||||
#endif // HAVE_ONEVPL
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_P(GAPI_Streaming, SmokeTest_ConstInput_GMat)
|
||||
@@ -2244,31 +2183,21 @@ TEST(GAPI_Streaming, TestPythonAPI)
|
||||
}
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
const unsigned char hevc_header[] = {
|
||||
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0C, 0x06, 0xFF, 0xFF, 0x01, 0x40, 0x00,
|
||||
0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0x00,
|
||||
0x00, 0x04, 0x02, 0x10, 0x30, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x03,
|
||||
0x01, 0xE5, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x06, 0x01, 0x40, 0x00, 0x00,
|
||||
0x03, 0x00, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0x00, 0x00,
|
||||
0xA0, 0x10, 0x20, 0x61, 0x63, 0x41, 0x00, 0x86, 0x49, 0x1B, 0x2B, 0x20, 0x00,
|
||||
0x00, 0x00, 0x01, 0x44, 0x01, 0xC0, 0x71, 0xC0, 0xD9, 0x20, 0x00, 0x00, 0x00,
|
||||
0x01, 0x26, 0x01, 0xAF, 0x0C
|
||||
};
|
||||
|
||||
TEST(OneVPL_Source, Init)
|
||||
{
|
||||
using CfgParam = cv::gapi::wip::onevpl::CfgParam;
|
||||
|
||||
std::vector<CfgParam> src_params;
|
||||
src_params.push_back(CfgParam::create<uint32_t>("mfxImplDescription.Impl",
|
||||
MFX_IMPL_TYPE_HARDWARE));
|
||||
src_params.push_back(CfgParam::create<uint32_t>("mfxImplDescription.AccelerationMode",
|
||||
MFX_ACCEL_MODE_VIA_D3D11, false));
|
||||
src_params.push_back(CfgParam::create<uint32_t>("mfxImplDescription.mfxDecoderDescription.decoder.CodecID",
|
||||
MFX_CODEC_HEVC));
|
||||
src_params.push_back(CfgParam::create_implementation(MFX_IMPL_TYPE_HARDWARE));
|
||||
src_params.push_back(CfgParam::create_acceleration_mode(MFX_ACCEL_MODE_VIA_D3D11));
|
||||
src_params.push_back(CfgParam::create_decoder_id(MFX_CODEC_HEVC));
|
||||
std::stringstream stream(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
|
||||
EXPECT_TRUE(stream.write(reinterpret_cast<char*>(const_cast<unsigned char *>(hevc_header)),
|
||||
sizeof(hevc_header)));
|
||||
auto stream_data_provider = std::make_shared<StreamDataProvider>(stream);
|
||||
|
||||
EXPECT_TRUE(stream.write(reinterpret_cast<char*>(const_cast<unsigned char *>(streaming::onevpl::hevc_header)),
|
||||
sizeof(streaming::onevpl::hevc_header)));
|
||||
std::shared_ptr<cv::gapi::wip::onevpl::IDataProvider> stream_data_provider =
|
||||
std::make_shared<streaming::onevpl::StreamDataProvider>(stream);
|
||||
|
||||
cv::Ptr<cv::gapi::wip::IStreamSource> cap;
|
||||
bool cap_created = false;
|
||||
@@ -2285,7 +2214,7 @@ TEST(OneVPL_Source, Init)
|
||||
}
|
||||
EXPECT_TRUE(stream_data_provider->empty());
|
||||
}
|
||||
#endif
|
||||
#endif // HAVE_ONEVPL
|
||||
|
||||
TEST(GAPI_Streaming, TestDesyncRMat) {
|
||||
cv::GMat in;
|
||||
|
||||
Reference in New Issue
Block a user