From 87b404ee4a0e4f23c056b537d0330afff9d310de Mon Sep 17 00:00:00 2001 From: XHY <497633959@qq.com> Date: Tue, 22 May 2018 11:41:10 +0800 Subject: [PATCH] reverse Cosmetic: x264-r2204 style progress indicator --- source/common/param.cpp | 2 -- source/x265.cpp | 76 ++++------------------------------------- source/x265.h | 3 +- source/x265cli.h | 2 -- 4 files changed, 8 insertions(+), 75 deletions(-) diff --git a/source/common/param.cpp b/source/common/param.cpp index f83e14f46..fe949bb81 100644 --- a/source/common/param.cpp +++ b/source/common/param.cpp @@ -118,7 +118,6 @@ void x265_param_default(x265_param* param) param->bLogCuStats = 0; param->decodedPictureHashSEI = 0; param->opts = 3; - param->bStylish = 0; /* Quality Measurement Metrics */ param->bEnablePsnr = 0; @@ -708,7 +707,6 @@ int x265_param_parse(x265_param* p, const char* name, const char* value) } OPT("high-tier") p->bHighTier = atobool(value); OPT("allow-non-conformance") p->bAllowNonConformance = atobool(value); - OPT("stylish") p->bStylish = atobool(value); OPT2("log-level", "log") { p->logLevel = atoi(value); diff --git a/source/x265.cpp b/source/x265.cpp index 348255d78..cbae5c2d4 100644 --- a/source/x265.cpp +++ b/source/x265.cpp @@ -150,61 +150,17 @@ void CLIOptions::printStatus(uint32_t frameNum) int64_t elapsed = time - startTime; double fps = elapsed > 0 ? frameNum * 1000000. / elapsed : 0; float bitrate = 0.008f * totalbytes * (param->fpsNum / param->fpsDenom) / ((float)frameNum); - - int eta, eta_hh = 0, eta_mm = 0, eta_ss = 0, fps_prec, bitrate_prec, file_prec, estsz_prec = 0; - double percentage = 0., estsz = 0., file_num, estsz_num = 0.; - const char *file_unit, *estsz_unit = ""; - fps_prec = fps > 999.5 ? 0 : fps > 99.5 ? 1 : fps > 9.95 ? 2 : 3; - bitrate_prec = bitrate > 9999.5 ? 0 : bitrate > 999.5 ? 1 : 2; - file_prec = totalbytes < 1048576000 ? 2 : totalbytes < 10485760000 ? 1 : 0; - file_num = totalbytes < 1048576 ? (double) totalbytes / 1024. : (double) totalbytes / 1048576.; - file_unit = totalbytes < 1048576 ? "K": "M"; if (framesToBeEncoded) { - eta = (int)(elapsed * (framesToBeEncoded - frameNum) / ((int64_t)frameNum * 1000000)); - percentage = 100. * frameNum / framesToBeEncoded; - eta_hh = eta / 3600; - eta_mm = ( eta / 60 ) % 60; - eta_ss = eta % 60; - estsz = (double) totalbytes * framesToBeEncoded / (frameNum * 1024.); - estsz_prec = estsz < 1024000 ? 2 : estsz < 10240000 ? 1 : 0; - estsz_num = estsz < 1024 ? estsz : estsz / 1024; - estsz_unit = estsz < 1024 ? "K" : "M"; - sprintf(buf, "x265 [%.1f%%] %d/%d frames, %.*f fps, %.*f kb/s, %.*f %sB, eta %d:%02d:%02d, est.size %.*f %sB", - percentage, frameNum, framesToBeEncoded, fps_prec, fps, bitrate_prec, bitrate, - file_prec, file_num, file_unit, - eta_hh, eta_mm, eta_ss, - estsz_prec, estsz_num, estsz_unit); - } - else - sprintf(buf, "x265 %d frames: %.*f fps, %.*f kb/s, %.*f %sB", - frameNum, fps_prec, fps, bitrate_prec, bitrate, - file_prec, file_num, file_unit); - - if( param->bStylish ) - { - char buf_stylish[200]; - int secs = elapsed / 1000000; - if( framesToBeEncoded ) - { - sprintf( buf_stylish, "x265 [%5.1f%%] %6d/%-6d %5.*f %6.*f %3d:%02d:%02d %3d:%02d:%02d %6.*f %1sB %6.*f %1sB", - percentage, frameNum, framesToBeEncoded, fps_prec, fps, bitrate_prec, bitrate, - secs/3600, (secs/60)%60, secs%60, eta_hh, eta_mm, eta_ss, - file_prec, file_num, file_unit, - estsz_prec, estsz_num, estsz_unit); - } - else - { - sprintf( buf_stylish, "x265 %6d %5.*f %6.*f %3d:%02d:%02d %6.*f %1sB", - frameNum, fps_prec, fps, bitrate_prec, bitrate, - secs/3600, (secs/60)%60, secs%60, - file_prec, file_num, file_unit); - } - fprintf( stderr, "%s \r", buf_stylish+5 ); + int eta = (int)(elapsed * (framesToBeEncoded - frameNum) / ((int64_t)frameNum * 1000000)); + sprintf(buf, "x265 [%.1f%%] %d/%d frames, %.2f fps, %.2f kb/s, eta %d:%02d:%02d", + 100. * frameNum / framesToBeEncoded, frameNum, framesToBeEncoded, fps, bitrate, + eta / 3600, (eta / 60) % 60, eta % 60); } else - fprintf( stderr, "%s \r", buf+5 ); + sprintf(buf, "x265 %d frames: %.2f fps, %.2f kb/s", frameNum, fps, bitrate); + fprintf(stderr, "%s \r", buf + 5); SetConsoleTitle(buf); fflush(stderr); // needed in windows prevUpdateTime = time; @@ -693,15 +649,6 @@ int main(int argc, char **argv) cliopt.bDither = false; } - if (cliopt.bProgress && param->bStylish) - { - if (cliopt.framesToBeEncoded) - fprintf(stderr, " %6s %13s %5s %6s %9s %9s %7s %10s\n", - "", "frames ", "fps ", "kb/s ", "elapsed", "remain ", "size", "est.size"); - else - fprintf(stderr, "%6s %5s %6s %9s %7s\n", "frames", "fps ", "kb/s ", "elapsed", "size"); - } - // main encoder loop while (pic_in && !b_ctrl_c) { @@ -809,16 +756,7 @@ int main(int argc, char **argv) /* clear progress report */ if (cliopt.bProgress) - { - if (!param->bStylish) - fprintf(stderr, "%*s\r", 100, " "); - else if (outFrameCount) - { - cliopt.prevUpdateTime = 0; - cliopt.printStatus(outFrameCount); - fprintf(stderr, "\n"); - } - } + fprintf(stderr, "%*s\r", 80, " "); fail: diff --git a/source/x265.h b/source/x265.h index b64a5763c..21361010f 100644 --- a/source/x265.h +++ b/source/x265.h @@ -1163,7 +1163,6 @@ typedef struct x265_param int opts; - bool bStylish; struct { @@ -1619,7 +1618,7 @@ static const char * const x265_preset_names[] = { "ultrafast", "superfast", "ver * 100 times faster than placebo! * * Currently available tunings are: */ -static const char * const x265_tune_names[] = { "psnr", "ssim", "grain", "zerolatency", "fastdecode", "littlepox", "vcb-s", 0 }; +static const char * const x265_tune_names[] = { "psnr", "ssim", "grain", "zerolatency", "fastdecode", "littlepox","littlepox++", "vcb-s","vcb-s++", 0 }; /* returns 0 on success, negative on failure (e.g. invalid preset/tune name). */ int x265_param_default_preset(x265_param *, const char *preset, const char *tune); diff --git a/source/x265cli.h b/source/x265cli.h index 4d1220ed2..d3f8b095b 100644 --- a/source/x265cli.h +++ b/source/x265cli.h @@ -73,7 +73,6 @@ static const struct option long_options[] = { "cu-stats", no_argument, NULL, 0 }, { "y4m", no_argument, NULL, 0 }, { "no-progress", no_argument, NULL, 0 }, - { "stylish", no_argument, NULL, 0 }, { "output", required_argument, NULL, 'o' }, { "output-depth", required_argument, NULL, 'D' }, { "input", required_argument, NULL, 0 }, @@ -350,7 +349,6 @@ static void showHelp(x265_param *param) H1(" --log-file Save log to file\n" ); H1(" --log-file-level Log-file logging level: none error warning info debug full. Default %s\n", x265::logLevelNames[param->logfLevel + 1]); H0(" --no-progress Disable CLI progress reports\n"); - H0(" --stylish Enable x264-r2204 style awesome progress indicator\n"); H0(" --csv Comma separated log file, if csv-log-level > 0 frame level statistics, else one line per run\n"); H0(" --csv-log-level Level of csv logging, if csv-log-level > 0 frame level statistics, else one line per run: 0-2\n"); H0("\nInput Options:\n");