New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -1,11 +1,10 @@
|
|||
#include <obs-module.h>
|
||||
#include <util/darray.h>
|
||||
#include <util/platform.h>
|
||||
#include <libavutil/log.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "obs-ffmpeg-config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dxgi.h>
|
||||
|
|
@ -20,10 +19,10 @@ MODULE_EXPORT const char *obs_module_description(void)
|
|||
return "FFmpeg based sources/outputs/encoders";
|
||||
}
|
||||
|
||||
extern struct obs_source_info ffmpeg_source;
|
||||
extern struct obs_output_info ffmpeg_output;
|
||||
extern struct obs_output_info ffmpeg_muxer;
|
||||
extern struct obs_output_info replay_buffer;
|
||||
extern struct obs_source_info ffmpeg_source;
|
||||
extern struct obs_output_info ffmpeg_output;
|
||||
extern struct obs_output_info ffmpeg_muxer;
|
||||
extern struct obs_output_info replay_buffer;
|
||||
extern struct obs_encoder_info aac_encoder_info;
|
||||
extern struct obs_encoder_info opus_encoder_info;
|
||||
extern struct obs_encoder_info nvenc_encoder_info;
|
||||
|
|
@ -36,134 +35,16 @@ extern struct obs_encoder_info nvenc_encoder_info;
|
|||
extern struct obs_encoder_info vaapi_encoder_info;
|
||||
#endif
|
||||
|
||||
static DARRAY(struct log_context {
|
||||
void *context;
|
||||
char str[4096];
|
||||
int print_prefix;
|
||||
} *) active_log_contexts;
|
||||
static DARRAY(struct log_context *) cached_log_contexts;
|
||||
pthread_mutex_t log_contexts_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct log_context *create_or_fetch_log_context(void *context)
|
||||
{
|
||||
pthread_mutex_lock(&log_contexts_mutex);
|
||||
for (size_t i = 0; i < active_log_contexts.num; i++) {
|
||||
if (context == active_log_contexts.array[i]->context) {
|
||||
pthread_mutex_unlock(&log_contexts_mutex);
|
||||
return active_log_contexts.array[i];
|
||||
}
|
||||
}
|
||||
|
||||
struct log_context *new_log_context = NULL;
|
||||
|
||||
size_t cnt = cached_log_contexts.num;
|
||||
if (!!cnt) {
|
||||
new_log_context = cached_log_contexts.array[cnt - 1];
|
||||
da_pop_back(cached_log_contexts);
|
||||
}
|
||||
|
||||
if (!new_log_context)
|
||||
new_log_context = bzalloc(sizeof(struct log_context));
|
||||
|
||||
new_log_context->context = context;
|
||||
new_log_context->str[0] = '\0';
|
||||
new_log_context->print_prefix = 1;
|
||||
|
||||
da_push_back(active_log_contexts, &new_log_context);
|
||||
|
||||
pthread_mutex_unlock(&log_contexts_mutex);
|
||||
|
||||
return new_log_context;
|
||||
}
|
||||
|
||||
static void destroy_log_context(struct log_context *log_context)
|
||||
{
|
||||
pthread_mutex_lock(&log_contexts_mutex);
|
||||
da_erase_item(active_log_contexts, &log_context);
|
||||
da_push_back(cached_log_contexts, &log_context);
|
||||
pthread_mutex_unlock(&log_contexts_mutex);
|
||||
}
|
||||
|
||||
static void ffmpeg_log_callback(void* context, int level, const char* format,
|
||||
va_list args)
|
||||
{
|
||||
if (format == NULL)
|
||||
return;
|
||||
|
||||
struct log_context *log_context = create_or_fetch_log_context(context);
|
||||
|
||||
char *str = log_context->str;
|
||||
|
||||
av_log_format_line(context, level, format, args, str + strlen(str),
|
||||
(int)(sizeof(log_context->str) - strlen(str)),
|
||||
&log_context->print_prefix);
|
||||
|
||||
int obs_level;
|
||||
switch (level) {
|
||||
case AV_LOG_PANIC:
|
||||
case AV_LOG_FATAL:
|
||||
obs_level = LOG_ERROR;
|
||||
break;
|
||||
case AV_LOG_ERROR:
|
||||
case AV_LOG_WARNING:
|
||||
obs_level = LOG_WARNING;
|
||||
break;
|
||||
case AV_LOG_INFO:
|
||||
case AV_LOG_VERBOSE:
|
||||
obs_level = LOG_INFO;
|
||||
break;
|
||||
case AV_LOG_DEBUG:
|
||||
default:
|
||||
obs_level = LOG_DEBUG;
|
||||
}
|
||||
|
||||
if (!log_context->print_prefix)
|
||||
return;
|
||||
|
||||
char *str_end = str + strlen(str) - 1;
|
||||
while(str < str_end) {
|
||||
if (*str_end != '\n')
|
||||
break;
|
||||
*str_end-- = '\0';
|
||||
}
|
||||
|
||||
if (str_end <= str)
|
||||
goto cleanup;
|
||||
|
||||
blog(obs_level, "[ffmpeg] %s", str);
|
||||
|
||||
cleanup:
|
||||
destroy_log_context(log_context);
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
|
||||
static const char *nvenc_check_name = "nvenc_check";
|
||||
|
||||
#ifdef _WIN32
|
||||
static const wchar_t *blacklisted_adapters[] = {
|
||||
L"720M",
|
||||
L"730M",
|
||||
L"740M",
|
||||
L"745M",
|
||||
L"820M",
|
||||
L"830M",
|
||||
L"840M",
|
||||
L"845M",
|
||||
L"920M",
|
||||
L"930M",
|
||||
L"940M",
|
||||
L"945M",
|
||||
L"1030",
|
||||
L"MX110",
|
||||
L"MX130",
|
||||
L"MX150",
|
||||
L"MX230",
|
||||
L"MX250",
|
||||
L"M520",
|
||||
L"M500",
|
||||
L"P500",
|
||||
L"K620M"
|
||||
L"720M", L"730M", L"740M", L"745M", L"820M", L"830M",
|
||||
L"840M", L"845M", L"920M", L"930M", L"940M", L"945M",
|
||||
L"1030", L"MX110", L"MX130", L"MX150", L"MX230", L"MX250",
|
||||
L"M520", L"M500", L"P500", L"K620M",
|
||||
};
|
||||
|
||||
static const size_t num_blacklisted =
|
||||
|
|
@ -202,7 +83,7 @@ static bool is_blacklisted(const wchar_t *name)
|
|||
return false;
|
||||
}
|
||||
|
||||
typedef HRESULT (WINAPI *create_dxgi_proc)(const IID *, IDXGIFactory1 **);
|
||||
typedef HRESULT(WINAPI *create_dxgi_proc)(const IID *, IDXGIFactory1 **);
|
||||
|
||||
static bool nvenc_device_available(void)
|
||||
{
|
||||
|
|
@ -226,7 +107,7 @@ static bool nvenc_device_available(void)
|
|||
|
||||
if (!create) {
|
||||
create = (create_dxgi_proc)GetProcAddress(dxgi,
|
||||
"CreateDXGIFactory1");
|
||||
"CreateDXGIFactory1");
|
||||
if (!create) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -266,7 +147,9 @@ extern bool load_nvenc_lib(void);
|
|||
|
||||
static bool nvenc_supported(void)
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
|
||||
av_register_all();
|
||||
#endif
|
||||
|
||||
profile_start(nvenc_check_name);
|
||||
|
||||
|
|
@ -319,13 +202,13 @@ extern void jim_nvenc_load(void);
|
|||
extern void jim_nvenc_unload(void);
|
||||
#endif
|
||||
|
||||
#if ENABLE_FFMPEG_LOGGING
|
||||
extern void obs_ffmpeg_load_logging(void);
|
||||
extern void obs_ffmpeg_unload_logging(void);
|
||||
#endif
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
da_init(active_log_contexts);
|
||||
da_init(cached_log_contexts);
|
||||
|
||||
//av_log_set_callback(ffmpeg_log_callback);
|
||||
|
||||
obs_register_source(&ffmpeg_source);
|
||||
obs_register_output(&ffmpeg_output);
|
||||
obs_register_output(&ffmpeg_muxer);
|
||||
|
|
@ -348,28 +231,20 @@ bool obs_module_load(void)
|
|||
obs_register_encoder(&vaapi_encoder_info);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLE_FFMPEG_LOGGING
|
||||
obs_ffmpeg_load_logging();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void obs_module_unload(void)
|
||||
{
|
||||
av_log_set_callback(av_log_default_callback);
|
||||
|
||||
#ifdef _WIN32
|
||||
pthread_mutex_destroy(&log_contexts_mutex);
|
||||
#if ENABLE_FFMPEG_LOGGING
|
||||
obs_ffmpeg_unload_logging();
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < active_log_contexts.num; i++) {
|
||||
bfree(active_log_contexts.array[i]);
|
||||
}
|
||||
for (size_t i = 0; i < cached_log_contexts.num; i++) {
|
||||
bfree(cached_log_contexts.array[i]);
|
||||
}
|
||||
|
||||
da_free(active_log_contexts);
|
||||
da_free(cached_log_contexts);
|
||||
|
||||
#ifdef _WIN32
|
||||
jim_nvenc_unload();
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue