From 4ead07c23a73ebbedb4041f4a00a42f55b6e1f1c Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Tue, 8 Jun 2021 04:12:55 +0200 Subject: [PATCH] ffmpeg: Apply coding guidelines --- source/encoders/encoder-ffmpeg.cpp | 64 ++++++++++--------- source/encoders/encoder-ffmpeg.hpp | 8 +-- source/encoders/handlers/amf_h264_handler.cpp | 8 +-- source/encoders/handlers/amf_hevc_handler.cpp | 12 ++-- source/encoders/handlers/amf_shared.cpp | 2 +- .../encoders/handlers/nvenc_h264_handler.cpp | 8 +-- .../encoders/handlers/nvenc_hevc_handler.cpp | 12 ++-- source/encoders/handlers/nvenc_shared.cpp | 2 +- .../encoders/handlers/prores_aw_handler.cpp | 2 +- source/ffmpeg/avframe-queue.cpp | 2 +- source/ffmpeg/avframe-queue.hpp | 4 +- source/ffmpeg/hwapi/base.hpp | 4 +- source/ffmpeg/hwapi/d3d11.cpp | 2 +- source/ffmpeg/hwapi/d3d11.hpp | 8 +-- source/ffmpeg/swscale.cpp | 2 +- source/ffmpeg/swscale.hpp | 4 +- source/ffmpeg/tools.cpp | 12 ++-- source/ffmpeg/tools.hpp | 4 +- 18 files changed, 82 insertions(+), 78 deletions(-) diff --git a/source/encoders/encoder-ffmpeg.cpp b/source/encoders/encoder-ffmpeg.cpp index 86c74bb..5fb5cdc 100644 --- a/source/encoders/encoder-ffmpeg.cpp +++ b/source/encoders/encoder-ffmpeg.cpp @@ -115,7 +115,7 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool #ifdef WIN32 auto gctx = gs::context(); if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) { - _hwapi = std::make_shared<::ffmpeg::hwapi::d3d11>(); + _hwapi = std::make_shared<::streamfx::ffmpeg::hwapi::d3d11>(); } #endif if (!_hwapi) { @@ -150,7 +150,7 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool auto gctx = gs::context(); int res = avcodec_open2(_context, _codec, NULL); if (res < 0) { - throw std::runtime_error(::ffmpeg::tools::get_error_description(res)); + throw std::runtime_error(::streamfx::ffmpeg::tools::get_error_description(res)); } } @@ -230,7 +230,7 @@ bool ffmpeg_instance::update(obs_data_t* settings) } // Apply GPU Selection - if (!_hwinst && ::ffmpeg::tools::can_hardware_encode(_codec)) { + if (!_hwinst && ::streamfx::ffmpeg::tools::can_hardware_encode(_codec)) { av_opt_set_int(_context, "gpu", (int)obs_data_get_int(settings, ST_KEY_FFMPEG_GPU), AV_OPT_SEARCH_CHILDREN); } @@ -276,24 +276,26 @@ bool ffmpeg_instance::update(obs_data_t* settings) DLOG_INFO("[%s] Custom Settings: %s", _codec->name, obs_data_get_string(settings, ST_KEY_FFMPEG_CUSTOMSETTINGS)); DLOG_INFO("[%s] Standard Compliance: %s", _codec->name, - ::ffmpeg::tools::get_std_compliance_name(_context->strict_std_compliance)); + ::streamfx::ffmpeg::tools::get_std_compliance_name(_context->strict_std_compliance)); DLOG_INFO("[%s] Threading: %s (with %i threads)", _codec->name, - ::ffmpeg::tools::get_thread_type_name(_context->thread_type), _context->thread_count); + ::streamfx::ffmpeg::tools::get_thread_type_name(_context->thread_type), _context->thread_count); DLOG_INFO("[%s] Video:", _codec->name); if (_hwinst) { DLOG_INFO("[%s] Texture: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _context->width, - _context->height, ::ffmpeg::tools::get_pixel_format_name(_context->sw_pix_fmt), - ::ffmpeg::tools::get_color_space_name(_context->colorspace), + _context->height, ::streamfx::ffmpeg::tools::get_pixel_format_name(_context->sw_pix_fmt), + ::streamfx::ffmpeg::tools::get_color_space_name(_context->colorspace), av_color_range_name(_context->color_range)); } else { DLOG_INFO("[%s] Input: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_source_width(), - _scaler.get_source_height(), ::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()), - ::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()), + _scaler.get_source_height(), + ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()), + ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()), _scaler.is_source_full_range() ? "Full" : "Partial"); DLOG_INFO("[%s] Output: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_target_width(), - _scaler.get_target_height(), ::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()), - ::ffmpeg::tools::get_color_space_name(_scaler.get_target_colorspace()), + _scaler.get_target_height(), + ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()), + ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_target_colorspace()), _scaler.is_target_full_range() ? "Full" : "Partial"); if (!_hwinst) DLOG_INFO("[%s] On GPU Index: %lli", _codec->name, obs_data_get_int(settings, ST_KEY_FFMPEG_GPU)); @@ -372,8 +374,8 @@ bool ffmpeg_instance::encode_video(struct encoder_frame* frame, struct encoder_p int res = _scaler.convert(reinterpret_cast(frame->data), reinterpret_cast(frame->linesize), 0, _context->height, vframe->data, vframe->linesize); if (res <= 0) { - DLOG_ERROR("Failed to convert frame: %s (%" PRId32 ").", ::ffmpeg::tools::get_error_description(res), - res); + DLOG_ERROR("Failed to convert frame: %s (%" PRId32 ").", + ::streamfx::ffmpeg::tools::get_error_description(res), res); return false; } } @@ -422,13 +424,13 @@ void ffmpeg_instance::initialize_sw(obs_data_t* settings) auto voi = video_output_get_info(obs_encoder_video(_self)); // Find a suitable Pixel Format. - AVPixelFormat _pixfmt_source = ::ffmpeg::tools::obs_videoformat_to_avpixelformat(voi->format); + AVPixelFormat _pixfmt_source = ::streamfx::ffmpeg::tools::obs_videoformat_to_avpixelformat(voi->format); AVPixelFormat _pixfmt_target = static_cast(obs_data_get_int(settings, ST_KEY_FFMPEG_COLORFORMAT)); if (_pixfmt_target == AV_PIX_FMT_NONE) { // Find the best conversion format. if (_codec->pix_fmts) { - _pixfmt_target = ::ffmpeg::tools::get_least_lossy_format(_codec->pix_fmts, _pixfmt_source); + _pixfmt_target = ::streamfx::ffmpeg::tools::get_least_lossy_format(_codec->pix_fmts, _pixfmt_source); } else { // If there are no supported formats, just pass in the current one. _pixfmt_target = _pixfmt_source; } @@ -446,14 +448,14 @@ void ffmpeg_instance::initialize_sw(obs_data_t* settings) if (!is_format_supported) { std::stringstream sstr; - sstr << "Color Format '" << ::ffmpeg::tools::get_pixel_format_name(_pixfmt_target) + sstr << "Color Format '" << ::streamfx::ffmpeg::tools::get_pixel_format_name(_pixfmt_target) << "' is not supported by the encoder."; throw std::runtime_error(sstr.str().c_str()); } } // Setup from OBS information. - ::ffmpeg::tools::context_setup_from_obs(voi, _context); + ::streamfx::ffmpeg::tools::context_setup_from_obs(voi, _context); // Override with other information. _context->width = static_cast(obs_encoder_get_width(_self)); @@ -477,9 +479,10 @@ void ffmpeg_instance::initialize_sw(obs_data_t* settings) if (!_scaler.initialize(SWS_POINT)) { std::stringstream sstr; sstr << "Initializing scaler failed for conversion from '" - << ::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()) << "' to '" - << ::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()) << "' with color space '" - << ::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()) << "' and " + << ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()) << "' to '" + << ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()) + << "' with color space '" + << ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()) << "' and " << (_scaler.is_source_full_range() ? "full" : "partial") << " range."; throw std::runtime_error(sstr.str()); } @@ -495,7 +498,7 @@ void ffmpeg_instance::initialize_hw(obs_data_t*) const video_output_info* voi = video_output_get_info(obs_encoder_video(_self)); // Apply pixel format settings. - ::ffmpeg::tools::context_setup_from_obs(voi, _context); + ::streamfx::ffmpeg::tools::context_setup_from_obs(voi, _context); _context->sw_pix_fmt = _context->pix_fmt; _context->pix_fmt = AV_PIX_FMT_D3D11; @@ -516,7 +519,7 @@ void ffmpeg_instance::initialize_hw(obs_data_t*) std::array buffer; size_t len = static_cast(snprintf(buffer.data(), buffer.size(), "Initializing hardware context failed with error: %s (%" PRIu32 ")", - ::ffmpeg::tools::get_error_description(res), res)); + ::streamfx::ffmpeg::tools::get_error_description(res), res)); throw std::runtime_error(std::string(buffer.data(), buffer.data() + len)); } #endif @@ -557,7 +560,7 @@ std::shared_ptr ffmpeg_instance::pop_free_frame() int res = av_frame_get_buffer(frame.get(), 32); if (res < 0) { - throw std::runtime_error(::ffmpeg::tools::get_error_description(res)); + throw std::runtime_error(::streamfx::ffmpeg::tools::get_error_description(res)); } } } @@ -601,7 +604,7 @@ void ffmpeg_instance::get_video_info(struct video_scale_info* info) { if (!is_hardware_encode()) { // Override input with supported format if software encode. - info->format = ::ffmpeg::tools::avpixelformat_to_obs_videoformat(_scaler.get_source_format()); + info->format = ::streamfx::ffmpeg::tools::avpixelformat_to_obs_videoformat(_scaler.get_source_format()); } } @@ -720,8 +723,8 @@ bool ffmpeg_instance::encode_avframe(std::shared_ptr frame, encoder_pac sent_frame = true; break; default: - DLOG_ERROR("Failed to encode frame: %s (%" PRId32 ").", ::ffmpeg::tools::get_error_description(res), - res); + DLOG_ERROR("Failed to encode frame: %s (%" PRId32 ").", + ::streamfx::ffmpeg::tools::get_error_description(res), res); return false; } } @@ -746,8 +749,8 @@ bool ffmpeg_instance::encode_avframe(std::shared_ptr frame, encoder_pac } break; default: - DLOG_ERROR("Failed to receive packet: %s (%" PRId32 ").", ::ffmpeg::tools::get_error_description(res), - res); + DLOG_ERROR("Failed to receive packet: %s (%" PRId32 ").", + ::streamfx::ffmpeg::tools::get_error_description(res), res); return false; } } @@ -895,7 +898,7 @@ void ffmpeg_instance::parse_ffmpeg_commandline(std::string text) int res = av_opt_set(_context, key.c_str(), value.c_str(), AV_OPT_SEARCH_CHILDREN); if (res < 0) { DLOG_WARNING("Option '%s' (key: '%s', value: '%s') encountered error: %s", opt.c_str(), key.c_str(), - value.c_str(), ::ffmpeg::tools::get_error_description(res)); + value.c_str(), ::streamfx::ffmpeg::tools::get_error_description(res)); } } catch (const std::exception& ex) { DLOG_ERROR("Option '%s' encountered exception: %s", opt.c_str(), ex.what()); @@ -1091,7 +1094,8 @@ obs_properties_t* ffmpeg_factory::get_properties2(instance_t* data) OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); obs_property_list_add_int(p, D_TRANSLATE(S_STATE_AUTOMATIC), static_cast(AV_PIX_FMT_NONE)); for (auto ptr = _avcodec->pix_fmts; *ptr != AV_PIX_FMT_NONE; ptr++) { - obs_property_list_add_int(p, ::ffmpeg::tools::get_pixel_format_name(*ptr), static_cast(*ptr)); + obs_property_list_add_int(p, ::streamfx::ffmpeg::tools::get_pixel_format_name(*ptr), + static_cast(*ptr)); } } diff --git a/source/encoders/encoder-ffmpeg.hpp b/source/encoders/encoder-ffmpeg.hpp index 4f1fc1b..e882c7d 100644 --- a/source/encoders/encoder-ffmpeg.hpp +++ b/source/encoders/encoder-ffmpeg.hpp @@ -57,11 +57,11 @@ namespace streamfx::encoder::ffmpeg { std::shared_ptr _handler; - ::ffmpeg::swscale _scaler; - AVPacket _packet; + ::streamfx::ffmpeg::swscale _scaler; + AVPacket _packet; - std::shared_ptr<::ffmpeg::hwapi::base> _hwapi; - std::shared_ptr<::ffmpeg::hwapi::instance> _hwinst; + std::shared_ptr<::streamfx::ffmpeg::hwapi::base> _hwapi; + std::shared_ptr<::streamfx::ffmpeg::hwapi::instance> _hwinst; std::size_t _lag_in_frames; std::size_t _sent_frames; diff --git a/source/encoders/handlers/amf_h264_handler.cpp b/source/encoders/handlers/amf_h264_handler.cpp index 93d5c11..0f7b2be 100644 --- a/source/encoders/handlers/amf_h264_handler.cpp +++ b/source/encoders/handlers/amf_h264_handler.cpp @@ -131,10 +131,10 @@ void amf_h264_handler::log_options(obs_data_t* settings, const AVCodec* codec, A amf::log_options(settings, codec, context); DLOG_INFO("[%s] H.264/AVC:", codec->name); - ::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile", - [](int64_t v, std::string_view o) { return std::string(o); }); - ::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level", - [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile", + [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level", + [](int64_t v, std::string_view o) { return std::string(o); }); } void amf_h264_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec) diff --git a/source/encoders/handlers/amf_hevc_handler.cpp b/source/encoders/handlers/amf_hevc_handler.cpp index d925bca..17d7989 100644 --- a/source/encoders/handlers/amf_hevc_handler.cpp +++ b/source/encoders/handlers/amf_hevc_handler.cpp @@ -138,12 +138,12 @@ void amf_hevc_handler::log_options(obs_data_t* settings, const AVCodec* codec, A amf::log_options(settings, codec, context); DLOG_INFO("[%s] H.265/HEVC:", codec->name); - ::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile", - [](int64_t v, std::string_view o) { return std::string(o); }); - ::ffmpeg::tools::print_av_option_string2(context, "level", " Level", - [](int64_t v, std::string_view o) { return std::string(o); }); - ::ffmpeg::tools::print_av_option_string2(context, "tier", " Tier", - [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile", + [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, "level", " Level", + [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, "tier", " Tier", + [](int64_t v, std::string_view o) { return std::string(o); }); } void amf_hevc_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec) diff --git a/source/encoders/handlers/amf_shared.cpp b/source/encoders/handlers/amf_shared.cpp index 560017d..7f12429 100644 --- a/source/encoders/handlers/amf_shared.cpp +++ b/source/encoders/handlers/amf_shared.cpp @@ -425,7 +425,7 @@ void amf::update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* con void amf::log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) { - using namespace ::ffmpeg; + using namespace ::streamfx::ffmpeg; DLOG_INFO("[%s] AMD AMF:", codec->name); tools::print_av_option_string2(context, "usage", " Usage", diff --git a/source/encoders/handlers/nvenc_h264_handler.cpp b/source/encoders/handlers/nvenc_h264_handler.cpp index 6523e92..6026732 100644 --- a/source/encoders/handlers/nvenc_h264_handler.cpp +++ b/source/encoders/handlers/nvenc_h264_handler.cpp @@ -134,10 +134,10 @@ void nvenc_h264_handler::log_options(obs_data_t* settings, const AVCodec* codec, nvenc::log_options(settings, codec, context); DLOG_INFO("[%s] H.264/AVC:", codec->name); - ::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile", - [](int64_t v, std::string_view o) { return std::string(o); }); - ::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level", - [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile", + [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level", + [](int64_t v, std::string_view o) { return std::string(o); }); } void nvenc_h264_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec) diff --git a/source/encoders/handlers/nvenc_hevc_handler.cpp b/source/encoders/handlers/nvenc_hevc_handler.cpp index dfa23d3..860d8e4 100644 --- a/source/encoders/handlers/nvenc_hevc_handler.cpp +++ b/source/encoders/handlers/nvenc_hevc_handler.cpp @@ -140,12 +140,12 @@ void nvenc_hevc_handler::log_options(obs_data_t* settings, const AVCodec* codec, nvenc::log_options(settings, codec, context); DLOG_INFO("[%s] H.265/HEVC:", codec->name); - ::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile", - [](int64_t v, std::string_view o) { return std::string(o); }); - ::ffmpeg::tools::print_av_option_string2(context, "level", " Level", - [](int64_t v, std::string_view o) { return std::string(o); }); - ::ffmpeg::tools::print_av_option_string2(context, "tier", " Tier", - [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile", + [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, "level", " Level", + [](int64_t v, std::string_view o) { return std::string(o); }); + ::streamfx::ffmpeg::tools::print_av_option_string2(context, "tier", " Tier", + [](int64_t v, std::string_view o) { return std::string(o); }); } void nvenc_hevc_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec) diff --git a/source/encoders/handlers/nvenc_shared.cpp b/source/encoders/handlers/nvenc_shared.cpp index 81dda51..fc4a6de 100644 --- a/source/encoders/handlers/nvenc_shared.cpp +++ b/source/encoders/handlers/nvenc_shared.cpp @@ -695,7 +695,7 @@ void nvenc::update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* c void nvenc::log_options(obs_data_t*, const AVCodec* codec, AVCodecContext* context) { - using namespace ::ffmpeg; + using namespace ::streamfx::ffmpeg; DLOG_INFO("[%s] NVIDIA NVENC:", codec->name); tools::print_av_option_string2(context, "preset", " Preset", diff --git a/source/encoders/handlers/prores_aw_handler.cpp b/source/encoders/handlers/prores_aw_handler.cpp index dee0b72..e63681d 100644 --- a/source/encoders/handlers/prores_aw_handler.cpp +++ b/source/encoders/handlers/prores_aw_handler.cpp @@ -102,7 +102,7 @@ void prores_aw_handler::update(obs_data_t* settings, const AVCodec*, AVCodecCont void prores_aw_handler::log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) { DLOG_INFO("[%s] Apple ProRes:", codec->name); - ::ffmpeg::tools::print_av_option_string(context, "profile", " Profile", [&codec](int64_t v) { + ::streamfx::ffmpeg::tools::print_av_option_string(context, "profile", " Profile", [&codec](int64_t v) { int val = static_cast(v); for (auto ptr = codec->profiles; (ptr->profile != FF_PROFILE_UNKNOWN) && (ptr != nullptr); ptr++) { if (ptr->profile == val) { diff --git a/source/ffmpeg/avframe-queue.cpp b/source/ffmpeg/avframe-queue.cpp index 8396bcc..059e066 100644 --- a/source/ffmpeg/avframe-queue.cpp +++ b/source/ffmpeg/avframe-queue.cpp @@ -22,7 +22,7 @@ #include "avframe-queue.hpp" #include "tools.hpp" -using namespace ffmpeg; +using namespace streamfx::ffmpeg; std::shared_ptr avframe_queue::create_frame() { diff --git a/source/ffmpeg/avframe-queue.hpp b/source/ffmpeg/avframe-queue.hpp index ebf452c..9926ef1 100644 --- a/source/ffmpeg/avframe-queue.hpp +++ b/source/ffmpeg/avframe-queue.hpp @@ -35,7 +35,7 @@ extern "C" { #endif } -namespace ffmpeg { +namespace streamfx::ffmpeg { class avframe_queue { std::deque> _frames; std::mutex _lock; @@ -71,4 +71,4 @@ namespace ffmpeg { std::size_t size(); }; -} // namespace ffmpeg +} // namespace streamfx::ffmpeg diff --git a/source/ffmpeg/hwapi/base.hpp b/source/ffmpeg/hwapi/base.hpp index 5df8bce..b49f603 100644 --- a/source/ffmpeg/hwapi/base.hpp +++ b/source/ffmpeg/hwapi/base.hpp @@ -36,7 +36,7 @@ extern "C" { #endif } -namespace ffmpeg::hwapi { +namespace streamfx::ffmpeg::hwapi { struct device { std::pair id; std::string name; @@ -67,4 +67,4 @@ namespace ffmpeg::hwapi { virtual std::shared_ptr create_from_obs() = 0; }; -} // namespace ffmpeg::hwapi +} // namespace streamfx::ffmpeg::hwapi diff --git a/source/ffmpeg/hwapi/d3d11.cpp b/source/ffmpeg/hwapi/d3d11.cpp index 2726c8c..130a1db 100644 --- a/source/ffmpeg/hwapi/d3d11.cpp +++ b/source/ffmpeg/hwapi/d3d11.cpp @@ -37,7 +37,7 @@ extern "C" { #pragma warning(pop) } -using namespace ffmpeg::hwapi; +using namespace streamfx::ffmpeg::hwapi; d3d11::d3d11() : _dxgi_module(0), _d3d11_module(0) { diff --git a/source/ffmpeg/hwapi/d3d11.hpp b/source/ffmpeg/hwapi/d3d11.hpp index 292bf85..369a65f 100644 --- a/source/ffmpeg/hwapi/d3d11.hpp +++ b/source/ffmpeg/hwapi/d3d11.hpp @@ -34,8 +34,8 @@ #pragma warning(pop) #endif -namespace ffmpeg::hwapi { - class d3d11 : public ffmpeg::hwapi::base { +namespace streamfx::ffmpeg::hwapi { + class d3d11 : public streamfx::ffmpeg::hwapi::base { typedef HRESULT(__stdcall* CreateDXGIFactory_t)(REFIID, void**); typedef HRESULT(__stdcall* CreateDXGIFactory1_t)(REFIID, void**); typedef HRESULT(__stdcall* D3D11CreateDevice_t)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT, @@ -62,7 +62,7 @@ namespace ffmpeg::hwapi { virtual std::shared_ptr create_from_obs() override; }; - class d3d11_instance : public ffmpeg::hwapi::instance { + class d3d11_instance : public streamfx::ffmpeg::hwapi::instance { ATL::CComPtr _device; ATL::CComPtr _context; @@ -80,4 +80,4 @@ namespace ffmpeg::hwapi { virtual std::shared_ptr avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key) override; }; -} // namespace ffmpeg::hwapi +} // namespace streamfx::ffmpeg::hwapi diff --git a/source/ffmpeg/swscale.cpp b/source/ffmpeg/swscale.cpp index 91d253c..0ab25a0 100644 --- a/source/ffmpeg/swscale.cpp +++ b/source/ffmpeg/swscale.cpp @@ -22,7 +22,7 @@ #include "swscale.hpp" #include -using namespace ffmpeg; +using namespace streamfx::ffmpeg; swscale::swscale() {} diff --git a/source/ffmpeg/swscale.hpp b/source/ffmpeg/swscale.hpp index 7b4957d..8293305 100644 --- a/source/ffmpeg/swscale.hpp +++ b/source/ffmpeg/swscale.hpp @@ -35,7 +35,7 @@ extern "C" { #endif } -namespace ffmpeg { +namespace streamfx::ffmpeg { class swscale { std::pair source_size; AVPixelFormat source_format = AV_PIX_FMT_NONE; @@ -85,4 +85,4 @@ namespace ffmpeg { int32_t convert(const uint8_t* const source_data[], const int source_stride[], int32_t source_row, int32_t source_rows, uint8_t* const target_data[], const int target_stride[]); }; -} // namespace ffmpeg +} // namespace streamfx::ffmpeg diff --git a/source/ffmpeg/tools.cpp b/source/ffmpeg/tools.cpp index 8431a38..d766114 100644 --- a/source/ffmpeg/tools.cpp +++ b/source/ffmpeg/tools.cpp @@ -34,7 +34,7 @@ extern "C" { #pragma warning(pop) } -using namespace ffmpeg; +using namespace streamfx::ffmpeg; const char* tools::get_pixel_format_name(AVPixelFormat v) { @@ -154,7 +154,7 @@ AVColorSpace tools::obs_to_av_color_space(video_colorspace v) } } -AVColorPrimaries ffmpeg::tools::obs_to_av_color_primary(video_colorspace v) +AVColorPrimaries streamfx::ffmpeg::tools::obs_to_av_color_primary(video_colorspace v) { switch (v) { case VIDEO_CS_601: // BT.601 @@ -168,7 +168,7 @@ AVColorPrimaries ffmpeg::tools::obs_to_av_color_primary(video_colorspace v) } } -AVColorTransferCharacteristic ffmpeg::tools::obs_to_av_color_transfer_characteristics(video_colorspace v) +AVColorTransferCharacteristic streamfx::ffmpeg::tools::obs_to_av_color_transfer_characteristics(video_colorspace v) { switch (v) { case VIDEO_CS_601: // BT.601 @@ -299,7 +299,7 @@ void tools::print_av_option_bool(AVCodecContext* ctx_codec, void* ctx_option, co int64_t v = 0; if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) { DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.c_str(), - ffmpeg::tools::get_error_description(err)); + streamfx::ffmpeg::tools::get_error_description(err)); } else { DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.c_str(), (inverse ? v != 0 : v == 0) ? "Disabled" : "Enabled", @@ -322,7 +322,7 @@ void tools::print_av_option_int(AVCodecContext* ctx_codec, void* ctx_option, con DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.c_str()); } else { DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.c_str(), - ffmpeg::tools::get_error_description(err)); + streamfx::ffmpeg::tools::get_error_description(err)); } } else { DLOG_INFO("[%s] %s: %" PRId64 " %s%s", ctx_codec->codec->name, text.c_str(), v, suffix.c_str(), @@ -342,7 +342,7 @@ void tools::print_av_option_string(AVCodecContext* ctx_codec, void* ctx_option, int64_t v = 0; if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) { DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.c_str(), - ffmpeg::tools::get_error_description(err)); + streamfx::ffmpeg::tools::get_error_description(err)); } else { std::string name = ""; if (decoder) diff --git a/source/ffmpeg/tools.hpp b/source/ffmpeg/tools.hpp index ee6561f..336c92e 100644 --- a/source/ffmpeg/tools.hpp +++ b/source/ffmpeg/tools.hpp @@ -35,7 +35,7 @@ extern "C" { #endif } -namespace ffmpeg::tools { +namespace streamfx::ffmpeg::tools { const char* get_pixel_format_name(AVPixelFormat v); const char* get_color_space_name(AVColorSpace v); @@ -80,4 +80,4 @@ namespace ffmpeg::tools { void print_av_option_string2(AVCodecContext* ctx_codec, void* ctx_option, std::string_view option, std::string_view text, std::function decoder); -} // namespace ffmpeg::tools +} // namespace streamfx::ffmpeg::tools