libobs: Fix skipped frames reporting
When frames are skipped the skipped frame count would increment, but the total frame count would not increment, causing the percentage calculation to fail. Additionally, the skipped frames log reporting has been moved to media-io/video-io.c instead of each output.
This commit is contained in:
parent
7c6c7bc4c0
commit
829ec5be2d
@ -16,6 +16,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include "../util/bmem.h"
|
||||
#include "../util/platform.h"
|
||||
#include "../util/profiler.h"
|
||||
@ -150,6 +151,8 @@ static inline bool video_output_cur_frame(struct video_output *video)
|
||||
|
||||
if (++video->available_frames == video->info.cache_size)
|
||||
video->last_added = video->first_added;
|
||||
} else {
|
||||
++video->skipped_frames;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&video->data_mutex);
|
||||
@ -333,6 +336,11 @@ bool video_output_connect(video_t *video,
|
||||
|
||||
pthread_mutex_lock(&video->input_mutex);
|
||||
|
||||
if (video->inputs.num == 0) {
|
||||
video->skipped_frames = 0;
|
||||
video->total_frames = 0;
|
||||
}
|
||||
|
||||
if (video_get_input_idx(video, callback, param) == DARRAY_INVALID) {
|
||||
struct video_input input;
|
||||
memset(&input, 0, sizeof(input));
|
||||
@ -378,6 +386,20 @@ void video_output_disconnect(video_t *video,
|
||||
da_erase(video->inputs, idx);
|
||||
}
|
||||
|
||||
if (video->inputs.num == 0) {
|
||||
double percentage_skipped = (double)video->skipped_frames /
|
||||
(double)video->total_frames * 100.0;
|
||||
|
||||
if (video->skipped_frames)
|
||||
blog(LOG_INFO, "Video stopped, number of "
|
||||
"skipped frames due "
|
||||
"to encoding lag: "
|
||||
"%"PRIu32"/%"PRIu32" (%0.1f%%)",
|
||||
video->skipped_frames,
|
||||
video->total_frames,
|
||||
percentage_skipped);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&video->input_mutex);
|
||||
}
|
||||
|
||||
@ -403,7 +425,6 @@ bool video_output_lock_frame(video_t *video, struct video_frame *frame,
|
||||
pthread_mutex_lock(&video->data_mutex);
|
||||
|
||||
if (video->available_frames == 0) {
|
||||
video->skipped_frames += count;
|
||||
video->cache[video->last_added].count += count;
|
||||
locked = false;
|
||||
|
||||
|
@ -830,7 +830,6 @@ struct obs_output {
|
||||
uint32_t starting_drawn_count;
|
||||
uint32_t starting_lagged_count;
|
||||
uint32_t starting_frame_count;
|
||||
uint32_t starting_skipped_frame_count;
|
||||
|
||||
int total_frames;
|
||||
|
||||
|
@ -235,8 +235,6 @@ bool obs_output_actual_start(obs_output_t *output)
|
||||
if (success && output->video) {
|
||||
output->starting_frame_count =
|
||||
video_output_get_total_frames(output->video);
|
||||
output->starting_skipped_frame_count =
|
||||
video_output_get_skipped_frames(output->video);
|
||||
output->starting_drawn_count = obs->video.total_frames;
|
||||
output->starting_lagged_count = obs->video.lagged_frames;
|
||||
}
|
||||
@ -280,24 +278,19 @@ static void log_frame_info(struct obs_output *output)
|
||||
struct obs_core_video *video = &obs->video;
|
||||
|
||||
uint32_t video_frames = video_output_get_total_frames(output->video);
|
||||
uint32_t video_skipped = video_output_get_skipped_frames(output->video);
|
||||
|
||||
uint32_t total = video_frames - output->starting_frame_count;
|
||||
uint32_t skipped = video_skipped - output->starting_skipped_frame_count;
|
||||
|
||||
uint32_t drawn = video->total_frames - output->starting_drawn_count;
|
||||
uint32_t lagged = video->lagged_frames - output->starting_lagged_count;
|
||||
|
||||
int dropped = obs_output_get_frames_dropped(output);
|
||||
|
||||
double percentage_skipped = 0.0f;
|
||||
double percentage_lagged = 0.0f;
|
||||
double percentage_dropped = 0.0f;
|
||||
|
||||
if (total) {
|
||||
percentage_skipped = (double)skipped / (double)total * 100.0;
|
||||
if (total)
|
||||
percentage_dropped = (double)dropped / (double)total * 100.0;
|
||||
}
|
||||
if (drawn)
|
||||
percentage_lagged = (double)lagged / (double)drawn * 100.0;
|
||||
|
||||
@ -307,11 +300,6 @@ static void log_frame_info(struct obs_output *output)
|
||||
blog(LOG_INFO, "Output '%s': Total drawn frames: %"PRIu32,
|
||||
output->context.name, drawn);
|
||||
|
||||
if (total && skipped)
|
||||
blog(LOG_INFO, "Output '%s': Number of skipped frames due "
|
||||
"to encoding lag: %"PRIu32" (%0.1f%%)",
|
||||
output->context.name,
|
||||
skipped, percentage_skipped);
|
||||
if (drawn && lagged)
|
||||
blog(LOG_INFO, "Output '%s': Number of lagged frames due "
|
||||
"to rendering lag/stalls: %"PRIu32" (%0.1f%%)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user