ffmpeg/tools: Add function to translate encoder capabilities
This commit is contained in:
@@ -16,13 +16,62 @@
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
#include "tools.hpp"
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavutil/error.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
}
|
||||
|
||||
std::string ffmpeg::tools::translate_encoder_capabilities(int capabilities)
|
||||
{
|
||||
// Sorted by relative importance.
|
||||
std::pair<int, std::string> 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);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <obs.h>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/pixfmt.h>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user