1
0
Эх сурвалжийг харах

Revert "libobs: Fix an int underflow in log_frame_info"

This reverts commit 4e3e67bb8cf6cb508b4d30b85451c0c4f20b7539.

The way this is handled will erroneously report 0 frames encoded when
frames have actually been properly encoded, which is best avoided.
Additionally, and overflow would be generated for drawn frames where
none occurred before.  The encoded value should probably not even be
present in the log for the output due to the way it's handled.
jp9000 8 жил өмнө
parent
commit
ba33bb7745

+ 8 - 15
libobs/obs-output.c

@@ -283,33 +283,26 @@ static void log_frame_info(struct obs_output *output)
 {
 {
 	struct obs_core_video *video = &obs->video;
 	struct obs_core_video *video = &obs->video;
 
 
-	uint32_t encoded_frames  = video_output_get_total_frames(output->video);
+	uint32_t video_frames  = video_output_get_total_frames(output->video);
 
 
-	int64_t encoded_temp = (int64_t)encoded_frames
-		- (int64_t)output->starting_frame_count;
-	uint32_t encoded = encoded_temp > 0 ? (uint32_t)encoded_temp : 0;
+	uint32_t total   = video_frames  - output->starting_frame_count;
 
 
-	int64_t drawn_temp = (int64_t)video->total_frames
-		- (int64_t)output->starting_drawn_count;
-	uint32_t drawn = drawn_temp > 0 ? (uint32_t)drawn_temp : 0;
-
-	int64_t lagged_temp = (int64_t)video->total_frames
-		- (int64_t)output->starting_lagged_count;
-	uint32_t lagged = lagged_temp > 0 ? (uint32_t)lagged_temp : 0;
+	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);
 	int dropped = obs_output_get_frames_dropped(output);
 
 
 	double percentage_lagged = 0.0f;
 	double percentage_lagged = 0.0f;
 	double percentage_dropped = 0.0f;
 	double percentage_dropped = 0.0f;
 
 
-	if (encoded)
-		percentage_dropped = (double)dropped / (double)encoded * 100.0;
+	if (total)
+		percentage_dropped = (double)dropped / (double)total * 100.0;
 	if (drawn)
 	if (drawn)
 		percentage_lagged = (double)lagged  / (double)drawn * 100.0;
 		percentage_lagged = (double)lagged  / (double)drawn * 100.0;
 
 
 	blog(LOG_INFO, "Output '%s': stopping", output->context.name);
 	blog(LOG_INFO, "Output '%s': stopping", output->context.name);
 	blog(LOG_INFO, "Output '%s': Total encoded frames: %"PRIu32,
 	blog(LOG_INFO, "Output '%s': Total encoded frames: %"PRIu32,
-			output->context.name, encoded);
+			output->context.name, total);
 	blog(LOG_INFO, "Output '%s': Total drawn frames: %"PRIu32,
 	blog(LOG_INFO, "Output '%s': Total drawn frames: %"PRIu32,
 			output->context.name, drawn);
 			output->context.name, drawn);
 
 
@@ -318,7 +311,7 @@ static void log_frame_info(struct obs_output *output)
 				"to rendering lag/stalls: %"PRIu32" (%0.1f%%)",
 				"to rendering lag/stalls: %"PRIu32" (%0.1f%%)",
 				output->context.name,
 				output->context.name,
 				lagged, percentage_lagged);
 				lagged, percentage_lagged);
-	if (encoded && dropped)
+	if (total && dropped)
 		blog(LOG_INFO, "Output '%s': Number of dropped frames due "
 		blog(LOG_INFO, "Output '%s': Number of dropped frames due "
 				"to insufficient bandwidth/connection stalls: "
 				"to insufficient bandwidth/connection stalls: "
 				"%d (%0.1f%%)",
 				"%d (%0.1f%%)",