Files
One-KVM/libs/hwcodec/cpp/common/util.h
mofeng-git bc85810849 fix(video): 修正默认码率配置并优化软件编码器
- 将默认码率从 8 Mbps 降至 1 Mbps,更适合嵌入式设备
- 修复 WebRtcConfig 中 max_bitrate < target_bitrate 的逻辑错误
- 优化 libx264/libx265 软件编码器的低延迟配置
- 优化 libvpx (VP8/VP9) 的实时编码参数
2025-12-31 22:04:58 +08:00

53 lines
1.6 KiB
C++

#ifndef UTIL_H
#define UTIL_H
#include <string>
#include <chrono>
extern "C" {
#include <libavcodec/avcodec.h>
}
namespace util_encode {
void set_av_codec_ctx(AVCodecContext *c, const std::string &name, int kbs,
int gop, int fps, int thread_count);
bool set_lantency_free(void *priv_data, const std::string &name);
bool set_quality(void *priv_data, const std::string &name, int quality);
bool set_rate_control(AVCodecContext *c, const std::string &name, int rc,
int q);
bool set_gpu(void *priv_data, const std::string &name, int gpu);
bool force_hw(void *priv_data, const std::string &name);
bool set_others(void *priv_data, const std::string &name);
bool change_bit_rate(AVCodecContext *c, const std::string &name, int kbs);
void vram_encode_test_callback(const uint8_t *data, int32_t len, int32_t key, const void *obj, int64_t pts);
} // namespace util
namespace util_decode {
bool has_flag_could_not_find_ref_with_poc();
}
namespace util {
inline std::chrono::steady_clock::time_point now() {
return std::chrono::steady_clock::now();
}
inline int64_t elapsed_ms(std::chrono::steady_clock::time_point start) {
return std::chrono::duration_cast<std::chrono::milliseconds>(now() - start).count();
}
inline bool skip_test(const int64_t *excludedLuids, const int32_t *excludeFormats, int32_t excludeCount, int64_t currentLuid, int32_t dataFormat) {
for (int32_t i = 0; i < excludeCount; i++) {
if (excludedLuids[i] == currentLuid && excludeFormats[i] == dataFormat) {
return true;
}
}
return false;
}
}
#endif