fftools/ffmpeg_enc: move nb_frames{dup,drop} globals into OutputStream

This commit is contained in:
Anton Khirnov 2023-05-28 16:51:57 +02:00
parent 09af34dc91
commit ba1141d8a9
3 changed files with 11 additions and 9 deletions

View File

@ -119,8 +119,6 @@ typedef struct BenchmarkTimeStamps {
static BenchmarkTimeStamps get_benchmark_time_stamps(void); static BenchmarkTimeStamps get_benchmark_time_stamps(void);
static int64_t getmaxrss(void); static int64_t getmaxrss(void);
int64_t nb_frames_dup = 0;
int64_t nb_frames_drop = 0;
unsigned nb_output_dumped = 0; unsigned nb_output_dumped = 0;
static BenchmarkTimeStamps current_time; static BenchmarkTimeStamps current_time;
@ -491,6 +489,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
int64_t pts = INT64_MIN + 1; int64_t pts = INT64_MIN + 1;
static int64_t last_time = -1; static int64_t last_time = -1;
static int first_report = 1; static int first_report = 1;
uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
int hours, mins, secs, us; int hours, mins, secs, us;
const char *hours_sign; const char *hours_sign;
int ret; int ret;
@ -536,6 +535,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
if (is_last_report) if (is_last_report)
av_bprintf(&buf, "L"); av_bprintf(&buf, "L");
nb_frames_dup = ost->nb_frames_dup;
nb_frames_drop = ost->nb_frames_drop;
vid = 1; vid = 1;
} }
/* compute min output value */ /* compute min output value */

View File

@ -553,6 +553,9 @@ typedef struct OutputStream {
Encoder *enc; Encoder *enc;
AVCodecContext *enc_ctx; AVCodecContext *enc_ctx;
AVPacket *pkt; AVPacket *pkt;
uint64_t nb_frames_dup;
uint64_t nb_frames_drop;
int64_t last_dropped; int64_t last_dropped;
/* video only */ /* video only */
@ -707,9 +710,6 @@ extern int recast_media;
extern FILE *vstats_file; extern FILE *vstats_file;
extern int64_t nb_frames_dup;
extern int64_t nb_frames_drop;
#if FFMPEG_OPT_PSNR #if FFMPEG_OPT_PSNR
extern int do_psnr; extern int do_psnr;
#endif #endif

View File

@ -1078,7 +1078,7 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
&nb_frames, &nb_frames_prev); &nb_frames, &nb_frames_prev);
if (nb_frames_prev == 0 && ost->last_dropped) { if (nb_frames_prev == 0 && ost->last_dropped) {
nb_frames_drop++; ost->nb_frames_drop++;
av_log(ost, AV_LOG_VERBOSE, av_log(ost, AV_LOG_VERBOSE,
"*** dropping frame %"PRId64" at ts %"PRId64"\n", "*** dropping frame %"PRId64" at ts %"PRId64"\n",
e->vsync_frame_number, e->last_frame->pts); e->vsync_frame_number, e->last_frame->pts);
@ -1086,12 +1086,12 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) { if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) {
if (nb_frames > dts_error_threshold * 30) { if (nb_frames > dts_error_threshold * 30) {
av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1); av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1);
nb_frames_drop++; ost->nb_frames_drop++;
return; return;
} }
nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev); ost->nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev);
av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1); av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1);
if (nb_frames_dup > dup_warning) { if (ost->nb_frames_dup > dup_warning) {
av_log(ost, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning); av_log(ost, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning);
dup_warning *= 10; dup_warning *= 10;
} }