mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #21022 from sivanov-work:async_mfp_demux
G-API: oneVPL Implement asynchronous MFP demux data provider * Add dummy dmux * Initial commit for draft versionn * Demux for low res file works * Add media source resolver to work over incorrect MIME * Add MFP Demux logger * stash changes * Extend IDataProvider with CodecId, Add troubleshooting info * Add IDapaProvider dispatcher * Add ComPtrGuard wrappers * Add new unit test scope for MFP demux & Add minor changes * Enhance UTs * Remove ATL header * Remove ATL another one * Fix build * Add static for some methods * Initial commit * Add async demuxing * Apply tdd idea * Intro IDataProvider changes: +fetch_bitstream, -fetch_data * Fix UTs * Remove IDataProvider::CodecId & Fix EOF hang * Remove sync demux * Remove mfp async dependencies * Remove VPL dependencies from IDataProvider declaration * Apply comments * Fix compilation * Suppress unused warning * Apply some comments * Apply some comments * Apply comments
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <opencv2/gapi/streaming/format.hpp>
|
||||
|
||||
#include <opencv2/gapi/streaming/onevpl/source.hpp>
|
||||
#include "streaming/onevpl/data_provider_defines.hpp"
|
||||
|
||||
#ifdef HAVE_ONEVPL
|
||||
|
||||
@@ -268,13 +269,47 @@ 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);
|
||||
}
|
||||
|
||||
size_t fetch_data(size_t out_data_size, void* out_data_buf) override {
|
||||
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();
|
||||
}
|
||||
@@ -284,6 +319,7 @@ struct StreamDataProvider : public cv::gapi::wip::onevpl::IDataProvider {
|
||||
private:
|
||||
std::istream& data_stream;
|
||||
};
|
||||
#endif // HAVE_ONEVPL
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_P(GAPI_Streaming, SmokeTest_ConstInput_GMat)
|
||||
@@ -2232,7 +2268,7 @@ TEST(OneVPL_Source, Init)
|
||||
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)));
|
||||
std::shared_ptr<cv::gapi::wip::onevpl::IDataProvider> stream_data_provider = std::make_shared<StreamDataProvider>(stream);
|
||||
auto stream_data_provider = std::make_shared<StreamDataProvider>(stream);
|
||||
|
||||
cv::Ptr<cv::gapi::wip::IStreamSource> cap;
|
||||
bool cap_created = false;
|
||||
|
||||
Reference in New Issue
Block a user