void
brhist_disp(const lame_global_flags * gf)
{
    int     i, lines_used = 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.;

    double  stat[9] = { 0 };
    int     st_frames = 0;


    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_used;
    }

    for (i = 0; i < BRHIST_WIDTH; i++) {
        int     show = br_hist[i];
        show = show && (lines_used > 1);
        if (show || (i >= brhist.vbr_bitrate_min_index && i <= brhist.vbr_bitrate_max_index))
            brhist_disp_line(i, br_hist[i], br_sm_hist[i][LR], most_often, frames);
    }
    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(stat);
}
Example #2
0
void
brhist_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]);
        }
    }
#else
    (void) gf;
#endif

    fflush(Console_IO.Console_fp);
}