| 1 | // This file is part of OpenCV project. |
|---|---|
| 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory |
| 3 | // of this distribution and at http://opencv.org/license.html. |
| 4 | // |
| 5 | // Copyright (C) 2021 Intel Corporation |
| 6 | |
| 7 | #ifndef GAPI_STREAMING_ONEVPL_ONEVPL_FILE_DATA_PROVIDER_HPP |
| 8 | #define GAPI_STREAMING_ONEVPL_ONEVPL_FILE_DATA_PROVIDER_HPP |
| 9 | |
| 10 | #include <stdio.h> |
| 11 | |
| 12 | #include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp> |
| 13 | #include <opencv2/gapi/streaming/onevpl/cfg_params.hpp> |
| 14 | |
| 15 | #include "streaming/onevpl/data_provider_defines.hpp" |
| 16 | |
| 17 | namespace cv { |
| 18 | namespace gapi { |
| 19 | namespace wip { |
| 20 | namespace onevpl { |
| 21 | |
| 22 | // With gcc13, std::unique_ptr(FILE, decltype(&fclose)> causes ignored-attributes warning. |
| 23 | // See https://stackoverflow.com/questions/76849365/can-we-add-attributes-to-standard-function-declarations-without-breaking-standar |
| 24 | #if defined(__GNUC__) && (__GNUC__ >= 13) |
| 25 | #pragma GCC diagnostic push |
| 26 | #pragma GCC diagnostic ignored "-Wignored-attributes" |
| 27 | #endif |
| 28 | |
| 29 | struct GAPI_EXPORTS FileDataProvider : public IDataProvider { |
| 30 | |
| 31 | using file_ptr = std::unique_ptr<FILE, decltype(&fclose)>; |
| 32 | FileDataProvider(const std::string& file_path, |
| 33 | const std::vector<CfgParam> &codec_params = {}, |
| 34 | uint32_t bitstream_data_size_value = 2000000); |
| 35 | ~FileDataProvider(); |
| 36 | |
| 37 | mfx_codec_id_type get_mfx_codec_id() const override; |
| 38 | bool fetch_bitstream_data(std::shared_ptr<mfx_bitstream> &out_bitsream) override; |
| 39 | bool empty() const override; |
| 40 | private: |
| 41 | file_ptr source_handle; |
| 42 | mfx_codec_id_type codec; |
| 43 | const uint32_t bitstream_data_size; |
| 44 | }; |
| 45 | |
| 46 | #if defined(__GNUC__) && (__GNUC__ == 13) |
| 47 | #pragma GCC diagnostic pop |
| 48 | #endif |
| 49 | |
| 50 | } // namespace onevpl |
| 51 | } // namespace wip |
| 52 | } // namespace gapi |
| 53 | } // namespace cv |
| 54 | |
| 55 | #endif // GAPI_STREAMING_ONEVPL_ONEVPL_FILE_DATA_PROVIDER_HPP |
| 56 |
