diff --git a/source/ffmpeg/tools.cpp b/source/ffmpeg/tools.cpp index 9801cd9..7e1cbac 100644 --- a/source/ffmpeg/tools.cpp +++ b/source/ffmpeg/tools.cpp @@ -16,13 +16,62 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "tools.hpp" +#include #include extern "C" { +#include #include #include } +std::string ffmpeg::tools::translate_encoder_capabilities(int capabilities) +{ + // Sorted by relative importance. + std::pair caps[] = { + {AV_CODEC_CAP_EXPERIMENTAL, "Experimental"}, + + // Quality + {AV_CODEC_CAP_LOSSLESS, "Lossless"}, + {AV_CODEC_CAP_INTRA_ONLY, "I-Frames only"}, + + // Threading + {AV_CODEC_CAP_FRAME_THREADS, "Frame-Threading"}, + {AV_CODEC_CAP_SLICE_THREADS, "Slice-Threading"}, + {AV_CODEC_CAP_AUTO_THREADS, "Automatic-Threading"}, + + // Features + {AV_CODEC_CAP_PARAM_CHANGE, "Dynamic Parameter Change"}, + {AV_CODEC_CAP_SUBFRAMES, "Sub-Frames"}, + {AV_CODEC_CAP_VARIABLE_FRAME_SIZE, "Variable Frame Size"}, + {AV_CODEC_CAP_SMALL_LAST_FRAME, "Small Final Frame"}, + //{AV_CODEC_CAP_DR1, "Uses get_buffer"}, + {AV_CODEC_CAP_DELAY, "Requires Flush"}, + + // Other + {AV_CODEC_CAP_TRUNCATED, "Truncated"}, + {AV_CODEC_CAP_CHANNEL_CONF, "AV_CODEC_CAP_CHANNEL_CONF"}, + {AV_CODEC_CAP_DRAW_HORIZ_BAND, "AV_CODEC_CAP_DRAW_HORIZ_BAND"}, + {AV_CODEC_CAP_HWACCEL_VDPAU, "AV_CODEC_CAP_HWACCEL_VDPAU"}, + {AV_CODEC_CAP_AVOID_PROBING, "AV_CODEC_CAP_AVOID_PROBING"}, + }; + + std::stringstream sstr; + for (auto kv : caps) { + if (capabilities & kv.first) { + capabilities &= ~kv.first; + sstr << kv.second; + if (capabilities != 0) { + sstr << ", "; + } else { + break; + } + } + } + + return sstr.str(); +} + const char* ffmpeg::tools::get_pixel_format_name(AVPixelFormat v) { return av_get_pix_fmt_name(v); diff --git a/source/ffmpeg/tools.hpp b/source/ffmpeg/tools.hpp index ad07f48..68352fd 100644 --- a/source/ffmpeg/tools.hpp +++ b/source/ffmpeg/tools.hpp @@ -20,6 +20,7 @@ #pragma once #include +#include extern "C" { #include @@ -27,6 +28,8 @@ extern "C" { namespace ffmpeg { namespace tools { + std::string translate_encoder_capabilities(int capabilities); + const char* get_pixel_format_name(AVPixelFormat v); const char* get_color_space_name(AVColorSpace v); @@ -38,7 +41,7 @@ namespace ffmpeg { AVColorSpace obs_videocolorspace_to_avcolorspace(video_colorspace v); AVColorRange obs_videorangetype_to_avcolorrange(video_range_type v); - } + } // namespace tools } // namespace ffmpeg #endif OBS_FFMPEG_FFMPEG_UTILITY