fix: use 120sec window in the middle of the file, not from the start

when not using -F; further alg. bugfixes
This commit is contained in:
Armin 2026-07-03 23:24:25 +02:00
commit 68f05d2313

24
tcd.c
View file

@ -23,7 +23,7 @@
#define FFT_SIZE_DEFAULT 4096
#define THRESHOLD_DEFAULT 50
#define MAX_ANALYSIS_SECS 60
#define MAX_ANALYSIS_SECS 120
#define OVERLAP_FACTOR 2
#define ANSI_RESET "\033[0m"
@ -1082,6 +1082,12 @@ static int process_file(const char *filename, const Options *opts)
int max_frames = opts->full ? INT_MAX : sample_rate * opts->max_secs;
int total_frames = 0;
if (!opts->full && fmt_ctx->duration > 0 && fmt_ctx->duration != AV_NOPTS_VALUE) {
int64_t seek_ts = fmt_ctx->duration / 2;
if (av_seek_frame(fmt_ctx, -1, seek_ts, AVSEEK_FLAG_BACKWARD) >= 0)
avcodec_flush_buffers(codec_ctx);
}
float *ring = calloc(opts->fft_size * channels, sizeof(float));
int ring_pos = 0;
@ -1183,8 +1189,12 @@ static int process_file(const char *filename, const Options *opts)
double expected_min = 0.90;
if (bitrate > 0 && bitrate < 192000) expected_min = 0.75;
else if (bitrate > 0 && bitrate < 256000) expected_min = 0.85;
if (cutoff_ratio > 0 && cutoff_ratio < expected_min - 0.08)
upscaled = 1;
if (cutoff_ratio > 0 && cutoff_ratio < expected_min - 0.08) {
if (effective_cutoff > 0 && steepness / effective_cutoff > 0.30)
upscaled = 0;
else
upscaled = 1;
}
}
render_visual_spectrum(
@ -1244,8 +1254,12 @@ static int process_file(const char *filename, const Options *opts)
if (bitrate > 0 && bitrate < 192000) expected_min = 0.75;
else if (bitrate > 0 && bitrate < 256000) expected_min = 0.85;
if (cutoff_ratio > 0 && cutoff_ratio < expected_min - 0.08)
upscaled = 1;
if (cutoff_ratio > 0 && cutoff_ratio < expected_min - 0.08) {
if (effective_cutoff > 0 && steepness / effective_cutoff > 0.30)
upscaled = 0;
else
upscaled = 1;
}
if (upscaled) {
printf(ANSI_YELLOW "UPSCALED" ANSI_RESET " (re-encoded from a lower-bitrate source)\n");