Skip to content

Commit

Permalink
reverse Cosmetic: x264-r2204 style progress indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
XHY committed May 22, 2018
1 parent e429e15 commit 87b404e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 75 deletions.
2 changes: 0 additions & 2 deletions source/common/param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
76 changes: 7 additions & 69 deletions source/x265.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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:

Expand Down
3 changes: 1 addition & 2 deletions source/x265.h
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,6 @@ typedef struct x265_param

int opts;

bool bStylish;

struct
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions source/x265cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -350,7 +349,6 @@ static void showHelp(x265_param *param)
H1(" --log-file <filename> Save log to file\n" );
H1(" --log-file-level <string> 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 <filename> Comma separated log file, if csv-log-level > 0 frame level statistics, else one line per run\n");
H0(" --csv-log-level <integer> Level of csv logging, if csv-log-level > 0 frame level statistics, else one line per run: 0-2\n");
H0("\nInput Options:\n");
Expand Down

0 comments on commit 87b404e

Please sign in to comment.