clang-format: Apply formatting
Code submissions have continually suffered from formatting inconsistencies that constantly have to be addressed. Using clang-format simplifies this by making code formatting more consistent, and allows automation of the code formatting so that maintainers can focus more on the code itself instead of code formatting.
This commit is contained in:
@@ -7,16 +7,16 @@ static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
NV_ENCODE_API_FUNCTION_LIST nv = {NV_ENCODE_API_FUNCTION_LIST_VER};
|
||||
NV_CREATE_INSTANCE_FUNC nv_create_instance = NULL;
|
||||
|
||||
#define error(format, ...) \
|
||||
blog(LOG_ERROR, "[jim-nvenc] " format, ##__VA_ARGS__)
|
||||
#define error(format, ...) blog(LOG_ERROR, "[jim-nvenc] " format, ##__VA_ARGS__)
|
||||
|
||||
static inline bool nv_failed(NVENCSTATUS err, const char *func, const char *call)
|
||||
static inline bool nv_failed(NVENCSTATUS err, const char *func,
|
||||
const char *call)
|
||||
{
|
||||
if (err == NV_ENC_SUCCESS)
|
||||
return false;
|
||||
|
||||
error("%s: %s failed: %d (%s)", func, call, (int)err,
|
||||
nv_error_name(err));
|
||||
nv_error_name(err));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ static inline bool nv_failed(NVENCSTATUS err, const char *func, const char *call
|
||||
|
||||
bool load_nvenc_lib(void)
|
||||
{
|
||||
if (sizeof(void*) == 8) {
|
||||
if (sizeof(void *) == 8) {
|
||||
nvenc_lib = os_dlopen("nvEncodeAPI64.dll");
|
||||
} else {
|
||||
nvenc_lib = os_dlopen("nvEncodeAPI.dll");
|
||||
@@ -42,40 +42,41 @@ static void *load_nv_func(const char *func)
|
||||
return func_ptr;
|
||||
}
|
||||
|
||||
typedef NVENCSTATUS (NVENCAPI *NV_MAX_VER_FUNC)(uint32_t*);
|
||||
typedef NVENCSTATUS(NVENCAPI *NV_MAX_VER_FUNC)(uint32_t *);
|
||||
|
||||
const char *nv_error_name(NVENCSTATUS err)
|
||||
{
|
||||
#define RETURN_CASE(x) \
|
||||
case x: return #x
|
||||
case x: \
|
||||
return #x
|
||||
|
||||
switch (err) {
|
||||
RETURN_CASE(NV_ENC_SUCCESS);
|
||||
RETURN_CASE(NV_ENC_ERR_NO_ENCODE_DEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_UNSUPPORTED_DEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_ENCODERDEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_DEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_DEVICE_NOT_EXIST);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_PTR);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_EVENT);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_PARAM);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_CALL);
|
||||
RETURN_CASE(NV_ENC_ERR_OUT_OF_MEMORY);
|
||||
RETURN_CASE(NV_ENC_ERR_ENCODER_NOT_INITIALIZED);
|
||||
RETURN_CASE(NV_ENC_ERR_UNSUPPORTED_PARAM);
|
||||
RETURN_CASE(NV_ENC_ERR_LOCK_BUSY);
|
||||
RETURN_CASE(NV_ENC_ERR_NOT_ENOUGH_BUFFER);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_VERSION);
|
||||
RETURN_CASE(NV_ENC_ERR_MAP_FAILED);
|
||||
RETURN_CASE(NV_ENC_ERR_NEED_MORE_INPUT);
|
||||
RETURN_CASE(NV_ENC_ERR_ENCODER_BUSY);
|
||||
RETURN_CASE(NV_ENC_ERR_EVENT_NOT_REGISTERD);
|
||||
RETURN_CASE(NV_ENC_ERR_GENERIC);
|
||||
RETURN_CASE(NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY);
|
||||
RETURN_CASE(NV_ENC_ERR_UNIMPLEMENTED);
|
||||
RETURN_CASE(NV_ENC_ERR_RESOURCE_REGISTER_FAILED);
|
||||
RETURN_CASE(NV_ENC_ERR_RESOURCE_NOT_REGISTERED);
|
||||
RETURN_CASE(NV_ENC_ERR_RESOURCE_NOT_MAPPED);
|
||||
RETURN_CASE(NV_ENC_SUCCESS);
|
||||
RETURN_CASE(NV_ENC_ERR_NO_ENCODE_DEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_UNSUPPORTED_DEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_ENCODERDEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_DEVICE);
|
||||
RETURN_CASE(NV_ENC_ERR_DEVICE_NOT_EXIST);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_PTR);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_EVENT);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_PARAM);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_CALL);
|
||||
RETURN_CASE(NV_ENC_ERR_OUT_OF_MEMORY);
|
||||
RETURN_CASE(NV_ENC_ERR_ENCODER_NOT_INITIALIZED);
|
||||
RETURN_CASE(NV_ENC_ERR_UNSUPPORTED_PARAM);
|
||||
RETURN_CASE(NV_ENC_ERR_LOCK_BUSY);
|
||||
RETURN_CASE(NV_ENC_ERR_NOT_ENOUGH_BUFFER);
|
||||
RETURN_CASE(NV_ENC_ERR_INVALID_VERSION);
|
||||
RETURN_CASE(NV_ENC_ERR_MAP_FAILED);
|
||||
RETURN_CASE(NV_ENC_ERR_NEED_MORE_INPUT);
|
||||
RETURN_CASE(NV_ENC_ERR_ENCODER_BUSY);
|
||||
RETURN_CASE(NV_ENC_ERR_EVENT_NOT_REGISTERD);
|
||||
RETURN_CASE(NV_ENC_ERR_GENERIC);
|
||||
RETURN_CASE(NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY);
|
||||
RETURN_CASE(NV_ENC_ERR_UNIMPLEMENTED);
|
||||
RETURN_CASE(NV_ENC_ERR_RESOURCE_REGISTER_FAILED);
|
||||
RETURN_CASE(NV_ENC_ERR_RESOURCE_NOT_REGISTERED);
|
||||
RETURN_CASE(NV_ENC_ERR_RESOURCE_NOT_MAPPED);
|
||||
}
|
||||
#undef RETURN_CASE
|
||||
|
||||
@@ -91,8 +92,8 @@ static inline bool init_nvenc_internal(void)
|
||||
return success;
|
||||
initialized = true;
|
||||
|
||||
NV_MAX_VER_FUNC nv_max_ver = (NV_MAX_VER_FUNC)
|
||||
load_nv_func("NvEncodeAPIGetMaxSupportedVersion");
|
||||
NV_MAX_VER_FUNC nv_max_ver = (NV_MAX_VER_FUNC)load_nv_func(
|
||||
"NvEncodeAPIGetMaxSupportedVersion");
|
||||
if (!nv_max_ver) {
|
||||
return false;
|
||||
}
|
||||
@@ -102,16 +103,16 @@ static inline bool init_nvenc_internal(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t cur_ver =
|
||||
(NVENCAPI_MAJOR_VERSION << 4) | NVENCAPI_MINOR_VERSION;
|
||||
uint32_t cur_ver = (NVENCAPI_MAJOR_VERSION << 4) |
|
||||
NVENCAPI_MINOR_VERSION;
|
||||
if (cur_ver > ver) {
|
||||
error("Current driver version does not support this NVENC "
|
||||
"version, please upgrade your driver");
|
||||
"version, please upgrade your driver");
|
||||
return false;
|
||||
}
|
||||
|
||||
nv_create_instance = (NV_CREATE_INSTANCE_FUNC)
|
||||
load_nv_func("NvEncodeAPICreateInstance");
|
||||
nv_create_instance = (NV_CREATE_INSTANCE_FUNC)load_nv_func(
|
||||
"NvEncodeAPICreateInstance");
|
||||
if (!nv_create_instance) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user