浏览代码

libobs: Don't allow lagged frames to be counted as skipped

Prevents lagged frames (frames that took too long to render) to be
counted as skipped frames (frames that are skipped due to encoding
taking too long to process)
jp9000 8 年之前
父节点
当前提交
a81646ed9c
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      libobs/media-io/video-io.c

+ 7 - 1
libobs/media-io/video-io.c

@@ -35,6 +35,7 @@ extern profiler_name_store_t *obs_get_profiler_name_store(void);
 
 
 struct cached_frame_info {
 struct cached_frame_info {
 	struct video_data frame;
 	struct video_data frame;
+	int skipped;
 	int count;
 	int count;
 };
 };
 
 
@@ -115,6 +116,7 @@ static inline bool video_output_cur_frame(struct video_output *video)
 {
 {
 	struct cached_frame_info *frame_info;
 	struct cached_frame_info *frame_info;
 	bool complete;
 	bool complete;
+	bool skipped;
 
 
 	/* -------------------------------- */
 	/* -------------------------------- */
 
 
@@ -144,6 +146,7 @@ static inline bool video_output_cur_frame(struct video_output *video)
 
 
 	frame_info->frame.timestamp += video->frame_time;
 	frame_info->frame.timestamp += video->frame_time;
 	complete = --frame_info->count == 0;
 	complete = --frame_info->count == 0;
+	skipped = frame_info->skipped > 0;
 
 
 	if (complete) {
 	if (complete) {
 		if (++video->first_added == video->info.cache_size)
 		if (++video->first_added == video->info.cache_size)
@@ -151,7 +154,8 @@ static inline bool video_output_cur_frame(struct video_output *video)
 
 
 		if (++video->available_frames == video->info.cache_size)
 		if (++video->available_frames == video->info.cache_size)
 			video->last_added = video->first_added;
 			video->last_added = video->first_added;
-	} else {
+	} else if (skipped) {
+		--frame_info->skipped;
 		++video->skipped_frames;
 		++video->skipped_frames;
 	}
 	}
 
 
@@ -426,6 +430,7 @@ bool video_output_lock_frame(video_t *video, struct video_frame *frame,
 
 
 	if (video->available_frames == 0) {
 	if (video->available_frames == 0) {
 		video->cache[video->last_added].count += count;
 		video->cache[video->last_added].count += count;
+		video->cache[video->last_added].skipped += count;
 		locked = false;
 		locked = false;
 
 
 	} else {
 	} else {
@@ -437,6 +442,7 @@ bool video_output_lock_frame(video_t *video, struct video_frame *frame,
 		cfi = &video->cache[video->last_added];
 		cfi = &video->cache[video->last_added];
 		cfi->frame.timestamp = timestamp;
 		cfi->frame.timestamp = timestamp;
 		cfi->count = count;
 		cfi->count = count;
+		cfi->skipped = 0;
 
 
 		memcpy(frame, &cfi->frame, sizeof(*frame));
 		memcpy(frame, &cfi->frame, sizeof(*frame));