Skip to content

Commit c24b797

Browse files
committed
vdec/lavd: check_duration - tolerate only 66% of TFP
Print warning if decompress takes more than 66% of time per frame on average - as the decompress is now written (synchronously), the whole frame time is not available and the drops start earlier. refer to GH-378
1 parent 3aa75ec commit c24b797

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/video_decompress/libavcodec.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -896,20 +896,26 @@ static _Bool check_first_sps_vps(struct state_libavcodec_decompress *s, unsigned
896896
/// print hint to improve performance if not making it
897897
static void check_duration(struct state_libavcodec_decompress *s, double duration_total_sec, double duration_pixfmt_change_sec)
898898
{
899-
enum { REPEAT_INT_SEC = 30 };
899+
enum { REPEAT_INT_SEC = 30, TIME_SLOT_PERC_MAX = 66 };
900900
const int mov_window = 100;
901+
double tpf = 1 / s->desc.fps;
902+
tpf *= TIME_SLOT_PERC_MAX / 100.;
901903
s->mov_avg_comp_duration = (s->mov_avg_comp_duration * (mov_window - 1) + duration_total_sec) / mov_window;
902904
s->mov_avg_frames += 1;
903-
if (s->mov_avg_frames < 2 * mov_window || s->mov_avg_comp_duration < 1 / s->desc.fps) {
905+
if (s->mov_avg_frames < 2 * mov_window ||
906+
s->mov_avg_comp_duration < tpf) {
904907
return;
905908
}
906909
const time_ns_t now = get_time_in_ns();
907910
if (now < s->duration_warn_last_print + NS_IN_SEC * REPEAT_INT_SEC) {
908911
return;
909912
}
910913
s->duration_warn_last_print = now;
911-
log_msg(LOG_LEVEL_WARNING, MOD_NAME "Average decompression time of last %d frames is %f ms but time per frame is only %f ms!\n",
912-
mov_window, s->mov_avg_comp_duration * 1000, 1000 / s->desc.fps);
914+
MSG(WARNING,
915+
"Avg decompress time of last %d frames is %.2f ms which exceeds %.2f "
916+
"ms (%d%% of TPF)!\n",
917+
mov_window, s->mov_avg_comp_duration * MS_IN_SEC, tpf * MS_IN_SEC,
918+
TIME_SLOT_PERC_MAX);
913919
const char *hint = NULL;
914920
if ((s->codec_ctx->thread_type & FF_THREAD_SLICE) == 0 && (s->codec_ctx->codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) != 0) {
915921
hint = "\"--param lavd-thread-count=<n>FS\" option with small <n> or 0 (nr of logical cores)";

0 commit comments

Comments
 (0)