1159b3361Sopenharmony_ci/* 2159b3361Sopenharmony_ci * Bitrate histogram source file 3159b3361Sopenharmony_ci * 4159b3361Sopenharmony_ci * Copyright (c) 2000 Mark Taylor 5159b3361Sopenharmony_ci * 6159b3361Sopenharmony_ci * This library is free software; you can redistribute it and/or 7159b3361Sopenharmony_ci * modify it under the terms of the GNU Library General Public 8159b3361Sopenharmony_ci * License as published by the Free Software Foundation; either 9159b3361Sopenharmony_ci * version 2 of the License, or (at your option) any later version. 10159b3361Sopenharmony_ci * 11159b3361Sopenharmony_ci * This library is distributed in the hope that it will be useful, 12159b3361Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 13159b3361Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14159b3361Sopenharmony_ci * Library General Public License for more details. 15159b3361Sopenharmony_ci * 16159b3361Sopenharmony_ci * You should have received a copy of the GNU Library General Public 17159b3361Sopenharmony_ci * License along with this library; if not, write to the 18159b3361Sopenharmony_ci * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19159b3361Sopenharmony_ci * Boston, MA 02111-1307, USA. 20159b3361Sopenharmony_ci */ 21159b3361Sopenharmony_ci 22159b3361Sopenharmony_ci/* $Id$ */ 23159b3361Sopenharmony_ci 24159b3361Sopenharmony_ci#ifdef HAVE_CONFIG_H 25159b3361Sopenharmony_ci#include <config.h> 26159b3361Sopenharmony_ci#endif 27159b3361Sopenharmony_ci 28159b3361Sopenharmony_ci/* basic #define's */ 29159b3361Sopenharmony_ci 30159b3361Sopenharmony_ci#ifndef BRHIST_WIDTH 31159b3361Sopenharmony_ci# define BRHIST_WIDTH 14 32159b3361Sopenharmony_ci#endif 33159b3361Sopenharmony_ci#ifndef BRHIST_RES 34159b3361Sopenharmony_ci# define BRHIST_RES 14 35159b3361Sopenharmony_ci#endif 36159b3361Sopenharmony_ci 37159b3361Sopenharmony_ci 38159b3361Sopenharmony_ci/* #includes */ 39159b3361Sopenharmony_ci 40159b3361Sopenharmony_ci#ifdef STDC_HEADERS 41159b3361Sopenharmony_ci# include <stdio.h> 42159b3361Sopenharmony_ci# include <stdlib.h> 43159b3361Sopenharmony_ci# include <string.h> 44159b3361Sopenharmony_ci#endif 45159b3361Sopenharmony_ci 46159b3361Sopenharmony_ci#include "brhist.h" 47159b3361Sopenharmony_ci#include "console.h" 48159b3361Sopenharmony_ci 49159b3361Sopenharmony_ci#ifdef WITH_DMALLOC 50159b3361Sopenharmony_ci#include <dmalloc.h> 51159b3361Sopenharmony_ci#endif 52159b3361Sopenharmony_ci 53159b3361Sopenharmony_ci 54159b3361Sopenharmony_ci/* Structure holding all data related to the Console I/O 55159b3361Sopenharmony_ci * may be this should be a more global frontend structure. So it 56159b3361Sopenharmony_ci * makes sense to print all files instead with 57159b3361Sopenharmony_ci * printf ( "blah\n") with printf ( "blah%s\n", Console_IO.str_clreoln ); 58159b3361Sopenharmony_ci */ 59159b3361Sopenharmony_ci 60159b3361Sopenharmony_ciextern Console_IO_t Console_IO; 61159b3361Sopenharmony_ci 62159b3361Sopenharmony_cistatic struct brhist_struct { 63159b3361Sopenharmony_ci int vbr_bitrate_min_index; 64159b3361Sopenharmony_ci int vbr_bitrate_max_index; 65159b3361Sopenharmony_ci int kbps[BRHIST_WIDTH]; 66159b3361Sopenharmony_ci int hist_printed_lines; 67159b3361Sopenharmony_ci char bar_asterisk[512 + 1]; /* buffer filled up with a lot of '*' to print a bar */ 68159b3361Sopenharmony_ci char bar_percent[512 + 1]; /* buffer filled up with a lot of '%' to print a bar */ 69159b3361Sopenharmony_ci char bar_coded[512 + 1]; /* buffer filled up with a lot of ' ' to print a bar */ 70159b3361Sopenharmony_ci char bar_space[512 + 1]; /* buffer filled up with a lot of ' ' to print a bar */ 71159b3361Sopenharmony_ci} brhist; 72159b3361Sopenharmony_ci 73159b3361Sopenharmony_cistatic int 74159b3361Sopenharmony_cicalculate_index(const int *const array, const int len, const int value) 75159b3361Sopenharmony_ci{ 76159b3361Sopenharmony_ci int i; 77159b3361Sopenharmony_ci 78159b3361Sopenharmony_ci for (i = 0; i < len; i++) 79159b3361Sopenharmony_ci if (array[i] == value) 80159b3361Sopenharmony_ci return i; 81159b3361Sopenharmony_ci return -1; 82159b3361Sopenharmony_ci} 83159b3361Sopenharmony_ci 84159b3361Sopenharmony_ciint 85159b3361Sopenharmony_cibrhist_init(const lame_global_flags * gf, const int bitrate_kbps_min, const int bitrate_kbps_max) 86159b3361Sopenharmony_ci{ 87159b3361Sopenharmony_ci brhist.hist_printed_lines = 0; 88159b3361Sopenharmony_ci 89159b3361Sopenharmony_ci /* initialize histogramming data structure */ 90159b3361Sopenharmony_ci lame_bitrate_kbps(gf, brhist.kbps); 91159b3361Sopenharmony_ci brhist.vbr_bitrate_min_index = calculate_index(brhist.kbps, BRHIST_WIDTH, bitrate_kbps_min); 92159b3361Sopenharmony_ci brhist.vbr_bitrate_max_index = calculate_index(brhist.kbps, BRHIST_WIDTH, bitrate_kbps_max); 93159b3361Sopenharmony_ci 94159b3361Sopenharmony_ci if (brhist.vbr_bitrate_min_index >= BRHIST_WIDTH || 95159b3361Sopenharmony_ci brhist.vbr_bitrate_max_index >= BRHIST_WIDTH) { 96159b3361Sopenharmony_ci error_printf("lame internal error: VBR min %d kbps or VBR max %d kbps not allowed.\n", 97159b3361Sopenharmony_ci bitrate_kbps_min, bitrate_kbps_max); 98159b3361Sopenharmony_ci return -1; 99159b3361Sopenharmony_ci } 100159b3361Sopenharmony_ci 101159b3361Sopenharmony_ci memset(brhist.bar_asterisk, '*', sizeof(brhist.bar_asterisk) - 1); 102159b3361Sopenharmony_ci memset(brhist.bar_percent, '%', sizeof(brhist.bar_percent) - 1); 103159b3361Sopenharmony_ci memset(brhist.bar_space, '-', sizeof(brhist.bar_space) - 1); 104159b3361Sopenharmony_ci memset(brhist.bar_coded, '-', sizeof(brhist.bar_space) - 1); 105159b3361Sopenharmony_ci 106159b3361Sopenharmony_ci return 0; 107159b3361Sopenharmony_ci} 108159b3361Sopenharmony_ci 109159b3361Sopenharmony_cistatic int 110159b3361Sopenharmony_cidigits(unsigned number) 111159b3361Sopenharmony_ci{ 112159b3361Sopenharmony_ci int ret = 1; 113159b3361Sopenharmony_ci 114159b3361Sopenharmony_ci if (number >= 100000000) { 115159b3361Sopenharmony_ci ret += 8; 116159b3361Sopenharmony_ci number /= 100000000; 117159b3361Sopenharmony_ci } 118159b3361Sopenharmony_ci if (number >= 10000) { 119159b3361Sopenharmony_ci ret += 4; 120159b3361Sopenharmony_ci number /= 10000; 121159b3361Sopenharmony_ci } 122159b3361Sopenharmony_ci if (number >= 100) { 123159b3361Sopenharmony_ci ret += 2; 124159b3361Sopenharmony_ci number /= 100; 125159b3361Sopenharmony_ci } 126159b3361Sopenharmony_ci if (number >= 10) { 127159b3361Sopenharmony_ci ret += 1; 128159b3361Sopenharmony_ci } 129159b3361Sopenharmony_ci 130159b3361Sopenharmony_ci return ret; 131159b3361Sopenharmony_ci} 132159b3361Sopenharmony_ci 133159b3361Sopenharmony_ci 134159b3361Sopenharmony_cistatic void 135159b3361Sopenharmony_cibrhist_disp_line(int i, int br_hist_TOT, int br_hist_LR, int full, int frames) 136159b3361Sopenharmony_ci{ 137159b3361Sopenharmony_ci char brppt[14]; /* [%] and max. 10 characters for kbps */ 138159b3361Sopenharmony_ci int barlen_TOT; 139159b3361Sopenharmony_ci int barlen_LR; 140159b3361Sopenharmony_ci int res = digits(frames) + 3 + 4 + 1; 141159b3361Sopenharmony_ci 142159b3361Sopenharmony_ci if (full != 0) { 143159b3361Sopenharmony_ci /* some problems when br_hist_TOT \approx br_hist_LR: You can't see that there are still MS frames */ 144159b3361Sopenharmony_ci barlen_TOT = (br_hist_TOT * (Console_IO.disp_width - res) + full - 1) / full; /* round up */ 145159b3361Sopenharmony_ci barlen_LR = (br_hist_LR * (Console_IO.disp_width - res) + full - 1) / full; /* round up */ 146159b3361Sopenharmony_ci } 147159b3361Sopenharmony_ci else { 148159b3361Sopenharmony_ci barlen_TOT = barlen_LR = 0; 149159b3361Sopenharmony_ci } 150159b3361Sopenharmony_ci 151159b3361Sopenharmony_ci sprintf(brppt, " [%*i]", digits(frames), br_hist_TOT); 152159b3361Sopenharmony_ci 153159b3361Sopenharmony_ci if (Console_IO.str_clreoln[0]) /* ClearEndOfLine available */ 154159b3361Sopenharmony_ci console_printf("\n%3d%s %.*s%.*s%s", 155159b3361Sopenharmony_ci brhist.kbps[i], brppt, 156159b3361Sopenharmony_ci barlen_LR, brhist.bar_percent, 157159b3361Sopenharmony_ci barlen_TOT - barlen_LR, brhist.bar_asterisk, Console_IO.str_clreoln); 158159b3361Sopenharmony_ci else 159159b3361Sopenharmony_ci console_printf("\n%3d%s %.*s%.*s%*s", 160159b3361Sopenharmony_ci brhist.kbps[i], brppt, 161159b3361Sopenharmony_ci barlen_LR, brhist.bar_percent, 162159b3361Sopenharmony_ci barlen_TOT - barlen_LR, brhist.bar_asterisk, 163159b3361Sopenharmony_ci Console_IO.disp_width - res - barlen_TOT, ""); 164159b3361Sopenharmony_ci 165159b3361Sopenharmony_ci brhist.hist_printed_lines++; 166159b3361Sopenharmony_ci} 167159b3361Sopenharmony_ci 168159b3361Sopenharmony_ci 169159b3361Sopenharmony_ci 170159b3361Sopenharmony_cistatic void 171159b3361Sopenharmony_ciprogress_line(const lame_global_flags * gf, int full, int frames) 172159b3361Sopenharmony_ci{ 173159b3361Sopenharmony_ci char rst[20] = "\0"; 174159b3361Sopenharmony_ci int barlen_TOT = 0, barlen_COD = 0, barlen_RST = 0; 175159b3361Sopenharmony_ci int res = 1; 176159b3361Sopenharmony_ci float time_in_sec = 0; 177159b3361Sopenharmony_ci unsigned int hour, min, sec; 178159b3361Sopenharmony_ci int fsize = lame_get_framesize(gf); 179159b3361Sopenharmony_ci int srate = lame_get_out_samplerate(gf); 180159b3361Sopenharmony_ci 181159b3361Sopenharmony_ci if (full < frames) { 182159b3361Sopenharmony_ci full = frames; 183159b3361Sopenharmony_ci } 184159b3361Sopenharmony_ci if (srate > 0) { 185159b3361Sopenharmony_ci time_in_sec = (float)(full - frames); 186159b3361Sopenharmony_ci time_in_sec *= fsize; 187159b3361Sopenharmony_ci time_in_sec /= srate; 188159b3361Sopenharmony_ci } 189159b3361Sopenharmony_ci hour = (unsigned int)(time_in_sec / 3600); 190159b3361Sopenharmony_ci time_in_sec -= hour * 3600; 191159b3361Sopenharmony_ci min = (unsigned int)(time_in_sec / 60); 192159b3361Sopenharmony_ci time_in_sec -= min * 60; 193159b3361Sopenharmony_ci sec = (unsigned int)time_in_sec; 194159b3361Sopenharmony_ci if (full != 0) { 195159b3361Sopenharmony_ci if (hour > 0) { 196159b3361Sopenharmony_ci sprintf(rst, "%*u:%02u:%02u", digits(hour), hour, min, sec); 197159b3361Sopenharmony_ci res += digits(hour) + 1 + 5; 198159b3361Sopenharmony_ci } 199159b3361Sopenharmony_ci else { 200159b3361Sopenharmony_ci sprintf(rst, "%02u:%02u", min, sec); 201159b3361Sopenharmony_ci res += 5; 202159b3361Sopenharmony_ci } 203159b3361Sopenharmony_ci /* some problems when br_hist_TOT \approx br_hist_LR: You can't see that there are still MS frames */ 204159b3361Sopenharmony_ci barlen_TOT = (full * (Console_IO.disp_width - res) + full - 1) / full; /* round up */ 205159b3361Sopenharmony_ci barlen_COD = (frames * (Console_IO.disp_width - res) + full - 1) / full; /* round up */ 206159b3361Sopenharmony_ci barlen_RST = barlen_TOT - barlen_COD; 207159b3361Sopenharmony_ci if (barlen_RST == 0) { 208159b3361Sopenharmony_ci sprintf(rst, "%.*s", res - 1, brhist.bar_coded); 209159b3361Sopenharmony_ci } 210159b3361Sopenharmony_ci } 211159b3361Sopenharmony_ci else { 212159b3361Sopenharmony_ci barlen_TOT = barlen_COD = barlen_RST = 0; 213159b3361Sopenharmony_ci } 214159b3361Sopenharmony_ci if (Console_IO.str_clreoln[0]) { /* ClearEndOfLine available */ 215159b3361Sopenharmony_ci console_printf("\n%.*s%s%.*s%s", 216159b3361Sopenharmony_ci barlen_COD, brhist.bar_coded, 217159b3361Sopenharmony_ci rst, barlen_RST, brhist.bar_space, Console_IO.str_clreoln); 218159b3361Sopenharmony_ci } 219159b3361Sopenharmony_ci else { 220159b3361Sopenharmony_ci console_printf("\n%.*s%s%.*s%*s", 221159b3361Sopenharmony_ci barlen_COD, brhist.bar_coded, 222159b3361Sopenharmony_ci rst, barlen_RST, brhist.bar_space, Console_IO.disp_width - res - barlen_TOT, 223159b3361Sopenharmony_ci ""); 224159b3361Sopenharmony_ci } 225159b3361Sopenharmony_ci brhist.hist_printed_lines++; 226159b3361Sopenharmony_ci} 227159b3361Sopenharmony_ci 228159b3361Sopenharmony_ci 229159b3361Sopenharmony_cistatic int 230159b3361Sopenharmony_cistats_value(double x) 231159b3361Sopenharmony_ci{ 232159b3361Sopenharmony_ci if (x > 0.0) { 233159b3361Sopenharmony_ci console_printf(" %5.1f", x); 234159b3361Sopenharmony_ci return 6; 235159b3361Sopenharmony_ci } 236159b3361Sopenharmony_ci return 0; 237159b3361Sopenharmony_ci} 238159b3361Sopenharmony_ci 239159b3361Sopenharmony_cistatic int 240159b3361Sopenharmony_cistats_head(double x, const char *txt) 241159b3361Sopenharmony_ci{ 242159b3361Sopenharmony_ci if (x > 0.0) { 243159b3361Sopenharmony_ci console_printf(txt); 244159b3361Sopenharmony_ci return 6; 245159b3361Sopenharmony_ci } 246159b3361Sopenharmony_ci return 0; 247159b3361Sopenharmony_ci} 248159b3361Sopenharmony_ci 249159b3361Sopenharmony_ci 250159b3361Sopenharmony_cistatic void 251159b3361Sopenharmony_cistats_line(double *stat) 252159b3361Sopenharmony_ci{ 253159b3361Sopenharmony_ci int n = 1; 254159b3361Sopenharmony_ci console_printf("\n kbps "); 255159b3361Sopenharmony_ci n += 12; 256159b3361Sopenharmony_ci n += stats_head(stat[1], " mono"); 257159b3361Sopenharmony_ci n += stats_head(stat[2], " IS "); 258159b3361Sopenharmony_ci n += stats_head(stat[3], " LR "); 259159b3361Sopenharmony_ci n += stats_head(stat[4], " MS "); 260159b3361Sopenharmony_ci console_printf(" %% "); 261159b3361Sopenharmony_ci n += 6; 262159b3361Sopenharmony_ci n += stats_head(stat[5], " long "); 263159b3361Sopenharmony_ci n += stats_head(stat[6], "switch"); 264159b3361Sopenharmony_ci n += stats_head(stat[7], " short"); 265159b3361Sopenharmony_ci n += stats_head(stat[8], " mixed"); 266159b3361Sopenharmony_ci n += console_printf(" %%"); 267159b3361Sopenharmony_ci if (Console_IO.str_clreoln[0]) { /* ClearEndOfLine available */ 268159b3361Sopenharmony_ci console_printf("%s", Console_IO.str_clreoln); 269159b3361Sopenharmony_ci } 270159b3361Sopenharmony_ci else { 271159b3361Sopenharmony_ci console_printf("%*s", Console_IO.disp_width - n, ""); 272159b3361Sopenharmony_ci } 273159b3361Sopenharmony_ci brhist.hist_printed_lines++; 274159b3361Sopenharmony_ci 275159b3361Sopenharmony_ci n = 1; 276159b3361Sopenharmony_ci console_printf("\n %5.1f ", stat[0]); 277159b3361Sopenharmony_ci n += 12; 278159b3361Sopenharmony_ci n += stats_value(stat[1]); 279159b3361Sopenharmony_ci n += stats_value(stat[2]); 280159b3361Sopenharmony_ci n += stats_value(stat[3]); 281159b3361Sopenharmony_ci n += stats_value(stat[4]); 282159b3361Sopenharmony_ci console_printf(" "); 283159b3361Sopenharmony_ci n += 6; 284159b3361Sopenharmony_ci n += stats_value(stat[5]); 285159b3361Sopenharmony_ci n += stats_value(stat[6]); 286159b3361Sopenharmony_ci n += stats_value(stat[7]); 287159b3361Sopenharmony_ci n += stats_value(stat[8]); 288159b3361Sopenharmony_ci if (Console_IO.str_clreoln[0]) { /* ClearEndOfLine available */ 289159b3361Sopenharmony_ci console_printf("%s", Console_IO.str_clreoln); 290159b3361Sopenharmony_ci } 291159b3361Sopenharmony_ci else { 292159b3361Sopenharmony_ci console_printf("%*s", Console_IO.disp_width - n, ""); 293159b3361Sopenharmony_ci } 294159b3361Sopenharmony_ci brhist.hist_printed_lines++; 295159b3361Sopenharmony_ci} 296159b3361Sopenharmony_ci 297159b3361Sopenharmony_ci 298159b3361Sopenharmony_ci/* Yes, not very good */ 299159b3361Sopenharmony_ci#define LR 0 300159b3361Sopenharmony_ci#define MS 2 301159b3361Sopenharmony_ci 302159b3361Sopenharmony_civoid 303159b3361Sopenharmony_cibrhist_disp(const lame_global_flags * gf) 304159b3361Sopenharmony_ci{ 305159b3361Sopenharmony_ci int i, lines_used = 0; 306159b3361Sopenharmony_ci int br_hist[BRHIST_WIDTH]; /* how often a frame size was used */ 307159b3361Sopenharmony_ci int br_sm_hist[BRHIST_WIDTH][4]; /* how often a special frame size/stereo mode commbination was used */ 308159b3361Sopenharmony_ci int st_mode[4]; 309159b3361Sopenharmony_ci int bl_type[6]; 310159b3361Sopenharmony_ci int frames; /* total number of encoded frames */ 311159b3361Sopenharmony_ci 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 */ 312159b3361Sopenharmony_ci double sum = 0.; 313159b3361Sopenharmony_ci 314159b3361Sopenharmony_ci double stat[9] = { 0 }; 315159b3361Sopenharmony_ci int st_frames = 0; 316159b3361Sopenharmony_ci 317159b3361Sopenharmony_ci 318159b3361Sopenharmony_ci brhist.hist_printed_lines = 0; /* printed number of lines for the brhist functionality, used to skip back the right number of lines */ 319159b3361Sopenharmony_ci 320159b3361Sopenharmony_ci lame_bitrate_stereo_mode_hist(gf, br_sm_hist); 321159b3361Sopenharmony_ci lame_bitrate_hist(gf, br_hist); 322159b3361Sopenharmony_ci lame_stereo_mode_hist(gf, st_mode); 323159b3361Sopenharmony_ci lame_block_type_hist(gf, bl_type); 324159b3361Sopenharmony_ci 325159b3361Sopenharmony_ci frames = most_often = 0; 326159b3361Sopenharmony_ci for (i = 0; i < BRHIST_WIDTH; i++) { 327159b3361Sopenharmony_ci frames += br_hist[i]; 328159b3361Sopenharmony_ci sum += br_hist[i] * brhist.kbps[i]; 329159b3361Sopenharmony_ci if (most_often < br_hist[i]) 330159b3361Sopenharmony_ci most_often = br_hist[i]; 331159b3361Sopenharmony_ci if (br_hist[i]) 332159b3361Sopenharmony_ci ++lines_used; 333159b3361Sopenharmony_ci } 334159b3361Sopenharmony_ci 335159b3361Sopenharmony_ci for (i = 0; i < BRHIST_WIDTH; i++) { 336159b3361Sopenharmony_ci int show = br_hist[i]; 337159b3361Sopenharmony_ci show = show && (lines_used > 1); 338159b3361Sopenharmony_ci if (show || (i >= brhist.vbr_bitrate_min_index && i <= brhist.vbr_bitrate_max_index)) 339159b3361Sopenharmony_ci brhist_disp_line(i, br_hist[i], br_sm_hist[i][LR], most_often, frames); 340159b3361Sopenharmony_ci } 341159b3361Sopenharmony_ci for (i = 0; i < 4; i++) { 342159b3361Sopenharmony_ci st_frames += st_mode[i]; 343159b3361Sopenharmony_ci } 344159b3361Sopenharmony_ci if (frames > 0) { 345159b3361Sopenharmony_ci stat[0] = sum / frames; 346159b3361Sopenharmony_ci stat[1] = 100. * (frames - st_frames) / frames; 347159b3361Sopenharmony_ci } 348159b3361Sopenharmony_ci if (st_frames > 0) { 349159b3361Sopenharmony_ci stat[2] = 0.0; 350159b3361Sopenharmony_ci stat[3] = 100. * st_mode[LR] / st_frames; 351159b3361Sopenharmony_ci stat[4] = 100. * st_mode[MS] / st_frames; 352159b3361Sopenharmony_ci } 353159b3361Sopenharmony_ci if (bl_type[5] > 0) { 354159b3361Sopenharmony_ci stat[5] = 100. * bl_type[0] / bl_type[5]; 355159b3361Sopenharmony_ci stat[6] = 100. * (bl_type[1] + bl_type[3]) / bl_type[5]; 356159b3361Sopenharmony_ci stat[7] = 100. * bl_type[2] / bl_type[5]; 357159b3361Sopenharmony_ci stat[8] = 100. * bl_type[4] / bl_type[5]; 358159b3361Sopenharmony_ci } 359159b3361Sopenharmony_ci progress_line(gf, lame_get_totalframes(gf), frames); 360159b3361Sopenharmony_ci stats_line(stat); 361159b3361Sopenharmony_ci} 362159b3361Sopenharmony_ci 363159b3361Sopenharmony_civoid 364159b3361Sopenharmony_cibrhist_jump_back(void) 365159b3361Sopenharmony_ci{ 366159b3361Sopenharmony_ci console_up(brhist.hist_printed_lines); 367159b3361Sopenharmony_ci brhist.hist_printed_lines = 0; 368159b3361Sopenharmony_ci} 369159b3361Sopenharmony_ci 370159b3361Sopenharmony_ci/* 371159b3361Sopenharmony_ci * 1) 372159b3361Sopenharmony_ci * 373159b3361Sopenharmony_ci * Taken from Termcap_Manual.html: 374159b3361Sopenharmony_ci * 375159b3361Sopenharmony_ci * With the Unix version of termcap, you must allocate space for the description yourself and pass 376159b3361Sopenharmony_ci * the address of the space as the argument buffer. There is no way you can tell how much space is 377159b3361Sopenharmony_ci * needed, so the convention is to allocate a buffer 2048 characters long and assume that is 378159b3361Sopenharmony_ci * enough. (Formerly the convention was to allocate 1024 characters and assume that was enough. 379159b3361Sopenharmony_ci * But one day, for one kind of terminal, that was not enough.) 380159b3361Sopenharmony_ci */ 381159b3361Sopenharmony_ci 382159b3361Sopenharmony_ci 383