New upstream version 24.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2019-09-22 23:19:10 +02:00
parent b14f9eae6d
commit 5a730d6ec3
842 changed files with 42245 additions and 33385 deletions

View file

@ -40,10 +40,10 @@ struct cached_frame_info {
};
struct video_input {
struct video_scale_info conversion;
video_scaler_t *scaler;
struct video_frame frame[MAX_CONVERT_BUFFERS];
int cur_frame;
struct video_scale_info conversion;
video_scaler_t *scaler;
struct video_frame frame[MAX_CONVERT_BUFFERS];
int cur_frame;
void (*callback)(void *param, struct video_data *frame);
void *param;
@ -57,35 +57,35 @@ static inline void video_input_free(struct video_input *input)
}
struct video_output {
struct video_output_info info;
struct video_output_info info;
pthread_t thread;
pthread_mutex_t data_mutex;
bool stop;
pthread_t thread;
pthread_mutex_t data_mutex;
bool stop;
os_sem_t *update_semaphore;
uint64_t frame_time;
volatile long skipped_frames;
volatile long total_frames;
os_sem_t *update_semaphore;
uint64_t frame_time;
volatile long skipped_frames;
volatile long total_frames;
bool initialized;
bool initialized;
pthread_mutex_t input_mutex;
pthread_mutex_t input_mutex;
DARRAY(struct video_input) inputs;
size_t available_frames;
size_t first_added;
size_t last_added;
struct cached_frame_info cache[MAX_CACHE_SIZE];
size_t available_frames;
size_t first_added;
size_t last_added;
struct cached_frame_info cache[MAX_CACHE_SIZE];
volatile bool raw_active;
volatile long gpu_refs;
volatile bool raw_active;
volatile long gpu_refs;
};
/* ------------------------------------------------------------------------- */
static inline bool scale_video_output(struct video_input *input,
struct video_data *data)
struct video_data *data)
{
bool success = true;
@ -97,14 +97,14 @@ static inline bool scale_video_output(struct video_input *input,
frame = &input->frame[input->cur_frame];
success = video_scaler_scale(input->scaler,
frame->data, frame->linesize,
(const uint8_t * const*)data->data,
data->linesize);
success = video_scaler_scale(input->scaler, frame->data,
frame->linesize,
(const uint8_t *const *)data->data,
data->linesize);
if (success) {
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
data->data[i] = frame->data[i];
data->data[i] = frame->data[i];
data->linesize[i] = frame->linesize[i];
}
} else {
@ -134,7 +134,7 @@ static inline bool video_output_cur_frame(struct video_output *video)
pthread_mutex_lock(&video->input_mutex);
for (size_t i = 0; i < video->inputs.num; i++) {
struct video_input *input = video->inputs.array+i;
struct video_input *input = video->inputs.array + i;
struct video_data frame = frame_info->frame;
if (scale_video_output(input, &frame))
@ -177,7 +177,7 @@ static void *video_thread(void *param)
const char *video_thread_name =
profile_store_name(obs_get_profiler_name_store(),
"video_thread(%s)", video->info.name);
"video_thread(%s)", video->info.name);
while (os_sem_wait(video->update_semaphore) == 0) {
if (video->stop)
@ -212,10 +212,10 @@ static inline void init_cache(struct video_output *video)
for (size_t i = 0; i < video->info.cache_size; i++) {
struct video_frame *frame;
frame = (struct video_frame*)&video->cache[i];
frame = (struct video_frame *)&video->cache[i];
video_frame_init(frame, video->info.format,
video->info.width, video->info.height);
video_frame_init(frame, video->info.format, video->info.width,
video->info.height);
}
video->available_frames = video->info.cache_size;
@ -235,7 +235,7 @@ int video_output_open(video_t **video, struct video_output_info *info)
memcpy(&out->info, info, sizeof(struct video_output_info));
out->frame_time = (uint64_t)(1000000000.0 * (double)info->fps_den /
(double)info->fps_num);
(double)info->fps_num);
out->initialized = false;
if (pthread_mutexattr_init(&attr) != 0)
@ -274,7 +274,7 @@ void video_output_close(video_t *video)
da_free(video->inputs);
for (size_t i = 0; i < video->info.cache_size; i++)
video_frame_free((struct video_frame*)&video->cache[i]);
video_frame_free((struct video_frame *)&video->cache[i]);
os_sem_destroy(video->update_semaphore);
pthread_mutex_destroy(&video->data_mutex);
@ -283,11 +283,12 @@ void video_output_close(video_t *video)
}
static size_t video_get_input_idx(const video_t *video,
void (*callback)(void *param, struct video_data *frame),
void *param)
void (*callback)(void *param,
struct video_data *frame),
void *param)
{
for (size_t i = 0; i < video->inputs.num; i++) {
struct video_input *input = video->inputs.array+i;
struct video_input *input = video->inputs.array + i;
if (input->callback == callback && input->param == param)
return i;
}
@ -296,38 +297,37 @@ static size_t video_get_input_idx(const video_t *video,
}
static inline bool video_input_init(struct video_input *input,
struct video_output *video)
struct video_output *video)
{
if (input->conversion.width != video->info.width ||
if (input->conversion.width != video->info.width ||
input->conversion.height != video->info.height ||
input->conversion.format != video->info.format) {
struct video_scale_info from = {
.format = video->info.format,
.width = video->info.width,
.height = video->info.height,
.range = video->info.range,
.colorspace = video->info.colorspace
};
struct video_scale_info from = {.format = video->info.format,
.width = video->info.width,
.height = video->info.height,
.range = video->info.range,
.colorspace =
video->info.colorspace};
int ret = video_scaler_create(&input->scaler,
&input->conversion, &from,
VIDEO_SCALE_FAST_BILINEAR);
&input->conversion, &from,
VIDEO_SCALE_FAST_BILINEAR);
if (ret != VIDEO_SCALER_SUCCESS) {
if (ret == VIDEO_SCALER_BAD_CONVERSION)
blog(LOG_ERROR, "video_input_init: Bad "
"scale conversion type");
"scale conversion type");
else
blog(LOG_ERROR, "video_input_init: Failed to "
"create scaler");
"create scaler");
return false;
}
for (size_t i = 0; i < MAX_CONVERT_BUFFERS; i++)
video_frame_init(&input->frame[i],
input->conversion.format,
input->conversion.width,
input->conversion.height);
input->conversion.format,
input->conversion.width,
input->conversion.height);
}
return true;
@ -339,10 +339,9 @@ static inline void reset_frames(video_t *video)
os_atomic_set_long(&video->total_frames, 0);
}
bool video_output_connect(video_t *video,
const struct video_scale_info *conversion,
void (*callback)(void *param, struct video_data *frame),
void *param)
bool video_output_connect(
video_t *video, const struct video_scale_info *conversion,
void (*callback)(void *param, struct video_data *frame), void *param)
{
bool success = false;
@ -356,14 +355,14 @@ bool video_output_connect(video_t *video,
memset(&input, 0, sizeof(input));
input.callback = callback;
input.param = param;
input.param = param;
if (conversion) {
input.conversion = *conversion;
} else {
input.conversion.format = video->info.format;
input.conversion.width = video->info.width;
input.conversion.height = video->info.height;
input.conversion.format = video->info.format;
input.conversion.width = video->info.width;
input.conversion.height = video->info.height;
}
if (input.conversion.width == 0)
@ -393,22 +392,22 @@ static void log_skipped(video_t *video)
long skipped = os_atomic_load_long(&video->skipped_frames);
double percentage_skipped =
(double)skipped /
(double)os_atomic_load_long(&video->total_frames) *
100.0;
(double)os_atomic_load_long(&video->total_frames) * 100.0;
if (skipped)
blog(LOG_INFO, "Video stopped, number of "
"skipped frames due "
"to encoding lag: "
"%ld/%ld (%0.1f%%)",
video->skipped_frames,
video->total_frames,
percentage_skipped);
blog(LOG_INFO,
"Video stopped, number of "
"skipped frames due "
"to encoding lag: "
"%ld/%ld (%0.1f%%)",
video->skipped_frames, video->total_frames,
percentage_skipped);
}
void video_output_disconnect(video_t *video,
void (*callback)(void *param, struct video_data *frame),
void *param)
void (*callback)(void *param,
struct video_data *frame),
void *param)
{
if (!video || !callback)
return;
@ -417,7 +416,7 @@ void video_output_disconnect(video_t *video,
size_t idx = video_get_input_idx(video, callback, param);
if (idx != DARRAY_INVALID) {
video_input_free(video->inputs.array+idx);
video_input_free(video->inputs.array + idx);
da_erase(video->inputs, idx);
if (video->inputs.num == 0) {
@ -433,7 +432,8 @@ void video_output_disconnect(video_t *video,
bool video_output_active(const video_t *video)
{
if (!video) return false;
if (!video)
return false;
return os_atomic_load_bool(&video->raw_active);
}
@ -443,12 +443,13 @@ const struct video_output_info *video_output_get_info(const video_t *video)
}
bool video_output_lock_frame(video_t *video, struct video_frame *frame,
int count, uint64_t timestamp)
int count, uint64_t timestamp)
{
struct cached_frame_info *cfi;
bool locked;
if (!video) return false;
if (!video)
return false;
pthread_mutex_lock(&video->data_mutex);
@ -480,7 +481,8 @@ bool video_output_lock_frame(video_t *video, struct video_frame *frame,
void video_output_unlock_frame(video_t *video)
{
if (!video) return;
if (!video)
return;
pthread_mutex_lock(&video->data_mutex);