⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brhist.c

📁 音频编码
💻 C
📖 第 1 页 / 共 2 页
字号:
    min = df / 60;    df -= min * 60;    sec = df;    if (full != 0) {        if (hour > 0) {            sprintf(rst, "%*d:%02d:%02d", digits(hour), hour, min, sec);            res += digits(hour) + 1 + 5;        }        else {            sprintf(rst, "%02d:%02d", min, sec);            res += 5;        }        /* some problems when br_hist_TOT \approx br_hist_LR: You can't see that there are still MS frames */        barlen_TOT = (full * (Console_IO.disp_width - res) + full - 1) / full; /* round up */        barlen_COD = (frames * (Console_IO.disp_width - res) + full - 1) / full; /* round up */        barlen_RST = barlen_TOT - barlen_COD;        if (barlen_RST == 0) {            sprintf(rst, "%.*s", res - 1, brhist.bar_coded);        }    }    else {        barlen_TOT = barlen_COD = barlen_RST = 0;    }    if (Console_IO.str_clreoln[0]) { /* ClearEndOfLine available */        fprintf(Console_IO.Console_fp, "\n%.*s%s%.*s%s",                barlen_COD, brhist.bar_coded,                rst, barlen_RST, brhist.bar_space, Console_IO.str_clreoln);    }    else {        fprintf(Console_IO.Console_fp, "\n%.*s%s%.*s%*s",                barlen_COD, brhist.bar_coded,                rst, barlen_RST, brhist.bar_space, Console_IO.disp_width - res - barlen_TOT, "");    }    brhist.hist_printed_lines++;}static intstats_value(double x){    if (x > 0.0) {        fprintf(Console_IO.Console_fp, " %5.1f", x);        return 6;    }    /*       else {       fprintf( Console_IO.Console_fp, "      " );       return 6;       }     */    return 0;}static intstats_head(double x, const char *txt){    if (x > 0.0) {        fprintf(Console_IO.Console_fp, txt);        return 6;    }    /*       else {       fprintf( Console_IO.Console_fp, "      " );       return 6;       }     */    return 0;}static voidstats_line(const lame_global_flags * gf, double *stat){    int     n = 1;    fprintf(Console_IO.Console_fp, "\n   kbps     ");    n += 12;    n += stats_head(stat[1], "  mono");    n += stats_head(stat[2], "   IS ");    n += stats_head(stat[3], "   LR ");    n += stats_head(stat[4], "   MS ");    fprintf(Console_IO.Console_fp, " %%    ");    n += 6;    n += stats_head(stat[5], " long ");    n += stats_head(stat[6], "switch");    n += stats_head(stat[7], " short");    n += stats_head(stat[8], " mixed");    n += fprintf(Console_IO.Console_fp, " %%");    if (Console_IO.str_clreoln[0]) { /* ClearEndOfLine available */        fprintf(Console_IO.Console_fp, "%s", Console_IO.str_clreoln);    }    else {        fprintf(Console_IO.Console_fp, "%*s", Console_IO.disp_width - n, "");    }    brhist.hist_printed_lines++;    n = 1;    fprintf(Console_IO.Console_fp, "\n  %5.1f     ", stat[0]);    n += 12;    n += stats_value(stat[1]);    n += stats_value(stat[2]);    n += stats_value(stat[3]);    n += stats_value(stat[4]);    fprintf(Console_IO.Console_fp, "      ");    n += 6;    n += stats_value(stat[5]);    n += stats_value(stat[6]);    n += stats_value(stat[7]);    n += stats_value(stat[8]);    if (Console_IO.str_clreoln[0]) { /* ClearEndOfLine available */        fprintf(Console_IO.Console_fp, "%s", Console_IO.str_clreoln);    }    else {        fprintf(Console_IO.Console_fp, "%*s", Console_IO.disp_width - n, "");    }    brhist.hist_printed_lines++;}#endif/* Yes, not very good */#define LR  0#define MS  2voidbrhist_disp(const lame_global_flags * gf){    int     i, lines = 0;    int     br_hist[BRHIST_WIDTH]; /* how often a frame size was used */    int     br_sm_hist[BRHIST_WIDTH][4]; /* how often a special frame size/stereo mode commbination was used */    int     st_mode[4];    int     bl_type[6];    int     frames;          /* total number of encoded frames */    int     most_often;      /* usage count of the most often used frame size, but not smaller than Console_IO.disp_width-BRHIST_RES (makes this sense?) and 1 */    double  sum = 0.;#ifdef RH_HIST    double  stat[9] = { 0 };    int     st_frames = 0;#endif    brhist.hist_printed_lines = 0; /* printed number of lines for the brhist functionality, used to skip back the right number of lines */    lame_bitrate_stereo_mode_hist(gf, br_sm_hist);    lame_bitrate_hist(gf, br_hist);    lame_stereo_mode_hist(gf, st_mode);    lame_block_type_hist(gf, bl_type);    frames = most_often = 0;    for (i = 0; i < BRHIST_WIDTH; i++) {        frames += br_hist[i];        sum += br_hist[i] * brhist.kbps[i];        if (most_often < br_hist[i])            most_often = br_hist[i];        if (br_hist[i])            ++lines;    }    for (i = 0; i < BRHIST_WIDTH; i++) {        int     show = br_hist[i];#ifdef RH_HIST        show = show && (lines > 1);#endif        if (show || (i >= brhist.vbr_bitrate_min_index && i <= brhist.vbr_bitrate_max_index))            brhist_disp_line(gf, i, br_hist[i], br_sm_hist[i][LR], most_often, frames);    }#ifdef RH_HIST    for (i = 0; i < 4; i++) {        st_frames += st_mode[i];    }    if (frames > 0) {        stat[0] = sum / frames;        stat[1] = 100. * (frames - st_frames) / frames;    }    if (st_frames > 0) {        stat[2] = 0.0;        stat[3] = 100. * st_mode[LR] / st_frames;        stat[4] = 100. * st_mode[MS] / st_frames;    }    if (bl_type[5] > 0) {        stat[5] = 100. * bl_type[0] / bl_type[5];        stat[6] = 100. * (bl_type[1] + bl_type[3]) / bl_type[5];        stat[7] = 100. * bl_type[2] / bl_type[5];        stat[8] = 100. * bl_type[4] / bl_type[5];    }    progress_line(gf, lame_get_totalframes(gf), frames);    stats_line(gf, stat);#endif    fputs("\r", Console_IO.Console_fp);    fflush(Console_IO.Console_fp); /* fflush is ALSO needed for Windows! */}voidbrhist_jump_back(void){#if defined(_WIN32)  &&  !defined(__CYGWIN__)    if (GetFileType(Console_IO.Console_Handle) != FILE_TYPE_PIPE) {        COORD   Pos;        CONSOLE_SCREEN_BUFFER_INFO CSBI;        GetConsoleScreenBufferInfo(Console_IO.Console_Handle, &CSBI);        Pos.Y = CSBI.dwCursorPosition.Y - brhist.hist_printed_lines;        Pos.X = 0;        SetConsoleCursorPosition(Console_IO.Console_Handle, Pos);    }#else    while (brhist.hist_printed_lines-- > 0)        fputs(Console_IO.str_up, Console_IO.Console_fp);#endif}voidbrhist_disp_total(const lame_global_flags * gf){#ifndef RH_HIST    int     i;    int     br_hist[BRHIST_WIDTH];    int     st_mode[4];    int     bl_type[6];    int     st_frames = 0;    int     br_frames = 0;    double  sum = 0.;    lame_stereo_mode_hist(gf, st_mode);    lame_bitrate_hist(gf, br_hist);    lame_block_type_hist(gf, bl_type);    for (i = 0; i < BRHIST_WIDTH; i++) {        br_frames += br_hist[i];        sum += br_hist[i] * brhist.kbps[i];    }    for (i = 0; i < 4; i++) {        st_frames += st_mode[i];    }    if (0 == br_frames)        return;    fprintf(Console_IO.Console_fp, "\naverage: %5.1f kbps", sum / br_frames);    /* I'm very unhappy because this is only printed out in VBR modes */    if (st_frames > 0) {        if (st_mode[LR] > 0)            fprintf(Console_IO.Console_fp, "   LR: %d (%#5.4g%%)", st_mode[LR],                    100. * st_mode[LR] / st_frames);        else            fprintf(Console_IO.Console_fp, "                 ");        if (st_mode[MS] > 0)            fprintf(Console_IO.Console_fp, "   MS: %d (%#5.4g%%)", st_mode[MS],                    100. * st_mode[MS] / st_frames);    }    fprintf(Console_IO.Console_fp, "\n");    if (bl_type[5] > 0) {        extern int silent;        if (silent <= -5 && silent > -10) {            fprintf(Console_IO.Console_fp, "block type");            fprintf(Console_IO.Console_fp, " long: %#4.3f", 100. * bl_type[0] / bl_type[5]);            fprintf(Console_IO.Console_fp, " start: %#4.3f", 100. * bl_type[1] / bl_type[5]);            fprintf(Console_IO.Console_fp, " short: %#4.3f", 100. * bl_type[2] / bl_type[5]);            fprintf(Console_IO.Console_fp, " stop: %#4.3f", 100. * bl_type[3] / bl_type[5]);            fprintf(Console_IO.Console_fp, " mixed: %#4.3f", 100. * bl_type[4] / bl_type[5]);            fprintf(Console_IO.Console_fp, " (%%)\n");        }        else if (silent <= -10) {            fprintf(Console_IO.Console_fp, "block types   granules   percent\n");            fprintf(Console_IO.Console_fp, "      long: % 10d  % 8.3f%%\n",                    bl_type[0], 100. * bl_type[0] / bl_type[5]);            fprintf(Console_IO.Console_fp, "     start: % 10d  % 8.3f%%\n",                    bl_type[1], 100. * bl_type[1] / bl_type[5]);            fprintf(Console_IO.Console_fp, "     short: % 10d  % 8.3f%%\n",                    bl_type[2], 100. * bl_type[2] / bl_type[5]);            fprintf(Console_IO.Console_fp, "      stop: % 10d  % 8.3f%%\n",                    bl_type[3], 100. * bl_type[3] / bl_type[5]);            fprintf(Console_IO.Console_fp, "     mixed: % 10d  % 8.3f%%\n",                    bl_type[4], 100. * bl_type[4] / bl_type[5]);        }    }#endif    fflush(Console_IO.Console_fp);}/* * 1) * * Taken from Termcap_Manual.html: * * With the Unix version of termcap, you must allocate space for the description yourself and pass * the address of the space as the argument buffer. There is no way you can tell how much space is * needed, so the convention is to allocate a buffer 2048 characters long and assume that is * enough.  (Formerly the convention was to allocate 1024 characters and assume that was enough. * But one day, for one kind of terminal, that was not enough.) */#endif /* ifdef BRHIST */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -