Skip to content

Commit

Permalink
lavc video: small updates
Browse files Browse the repository at this point in the history
- moved constexpr definitions to the (anonymous) namespace (allows
eg. detection of unused vars)
- do not import the whole std namespace
  • Loading branch information
MartinPulec committed Aug 14, 2023
1 parent 7e2d50a commit 4f0fa9f
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions src/video_compress/libavcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,24 @@ extern "C"{

#define MOD_NAME "[lavc] "

using namespace std;
using std::array;
using std::clamp;
using std::cout;
using std::function;
using std::list;
using std::invalid_argument;
using std::map;
using std::min;
using std::regex;
using std::set;
using std::shared_ptr;
using std::stof;
using std::stoi;
using std::string;
using std::thread;
using std::to_string;
using namespace std::string_literals;

static constexpr const codec_t DEFAULT_CODEC = MJPG;
static constexpr double DEFAULT_X264_X265_CRF = 22.0;
static constexpr int DEFAULT_CQP = 21;
static constexpr int DEFAULT_CQP_MPJEG = 7;
static constexpr int DEFAULT_CQP_MJPEG_QSV = 80;
static constexpr int DEFAULT_CQP_QSV = 5000;
static constexpr const int DEFAULT_GOP_SIZE = 20;
static constexpr int DEFAULT_SLICE_COUNT = 32;

// NOLINTNEXTLINE(*-macro-usage): for correct TOSTRING expansion
#define DEFAULT_X26X_RC_BUF_SIZE_FACTOR 2.5
#define DEFAULT_NVENC_RC_BUF_SIZE_FACTOR 1.5 // NOLINT: ditto
Expand All @@ -111,6 +117,23 @@ enum {
FLW_THRESH = 1920 * 1080 * 30, //< in px/sec
};

constexpr const codec_t DEFAULT_CODEC = MJPG;
constexpr const int DEFAULT_GOP_SIZE = 20;
constexpr int DEFAULT_SLICE_COUNT = 32;

constexpr const char *DEFAULT_AMF_USAGE = "lowlatency";
constexpr int DEFAULT_CQP = 21;
constexpr int DEFAULT_CQP_MPJEG = 7;
constexpr int DEFAULT_CQP_MJPEG_QSV = 80;
constexpr int DEFAULT_CQP_QSV = 5000;
constexpr const char *DEFAULT_NVENC_PRESET = "p4";
constexpr const char *DEFAULT_NVENC_RC = "cbr";
constexpr const char *DEFAULT_NVENC_TUNE = "ull";
constexpr const char *DEFAULT_QSV_PRESET = "medium";
constexpr const char *DEFAULT_QSV_RC = "vbr";
constexpr double DEFAULT_X264_X265_CRF = 22.0;
constexpr const char *FALLBACK_NVENC_PRESET = "llhq";

struct setparam_param {
setparam_param(map<string, string> &lo, set<string> &bo) : lavc_opts(lo), blacklist_opts(bo) {}
struct video_desc desc {};
Expand All @@ -123,15 +146,6 @@ struct setparam_param {
set<string> &blacklist_opts; ///< options that should be blacklisted
};

constexpr const char *DEFAULT_AMF_USAGE = "lowlatency";
constexpr const char *DEFAULT_NVENC_PRESET = "p4";
constexpr const char *DEFAULT_NVENC_RC = "cbr";
constexpr const char *DEFAULT_NVENC_TUNE = "ull";
constexpr const char *FALLBACK_NVENC_PRESET = "llhq";

static constexpr const char *DEFAULT_QSV_RC = "vbr";
static constexpr const char *DEFAULT_QSV_PRESET = "medium";

typedef struct {
function<const char*(bool)> get_prefered_encoder; ///< can be nullptr
double avg_bpp;
Expand Down

0 comments on commit 4f0fa9f

Please sign in to comment.