📄 gtkanal.c
字号:
xcord[0] = 1; xcord[1] = n+1; gpk_rectangle_draw(sfbbox[gr],xcord,ycord,xmn,ymn,xmx,ymx,&yellow); }}static void update_progress(void){ char label[80]; int tf = lame_get_totalframes(gfp); if (gtkinfo.totalframes>0) tf=gtkinfo.totalframes; sprintf(label,"Frame:%4i/%4i %6.2fs", pplot->frameNum,(int)tf-1, pplot->frametime); gtk_progress_set_value (GTK_PROGRESS (frameprogress), (gdouble) pplot->frameNum); gtk_label_set_text(GTK_LABEL(framecounter),label);}static void analyze(void){ if ( idle_keepgoing) { idle_count = 0; idle_count_max=0; idle_keepgoing=0; idle_end=0; } plot_frame(); update_progress(); }static void plotclick( GtkWidget *widget, gpointer data ){ analyze(); }static int frameadv1(GtkWidget *widget, gpointer data ){ int i; if (idle_keepgoing ){ if (idle_back) { /* frame displayed is the old frame. to advance, just swap in new frame */ idle_back--; pplot = &Pinfo[READ_AHEAD+idle_back]; }else{ /* advance the frame by reading in a new frame */ pplot = &Pinfo[READ_AHEAD]; if (mp3done) { /* dont try to read any more frames, and quit if "finish MP3" was selected */ /* if (idle_finish) gtk_main_quit(); */ idle_count_max=0; idle_end=0; } else { /* read in the next frame */ for (i=NUMPINFO-1 ; i>0 ; i--) memcpy(&Pinfo[i],&Pinfo[i-1],sizeof(plotting_data)); pinfo = &Pinfo[0]; pinfo->num_samples = gtkmakeframe(); if (pinfo->num_samples==0 && gtkinfo.totalframes==0) /* allow an extra frame to flush decoder buffers */ gtkinfo.totalframes = pinfo->frameNum +2; if (pinfo->sampfreq) pinfo->frametime = (pinfo->frameNum)*1152.0/pinfo->sampfreq; else pinfo->frametime=0; /* eof? if (!pinfo->num_samples) if (idle_finish) gtk_main_quit(); */ pinfo->totbits = 0; { int gr,ch; for (gr = 0 ; gr < 2 ; gr ++) for (ch = 0 ; ch < 2 ; ch ++) { gtkinfo.totshort += (pinfo->mpg123blocktype[gr][ch]==2); gtkinfo.totmix += !(pinfo->mixed[gr][ch]==0); gtkinfo.totpreflag += (pinfo->preflag[gr][ch]==1); pinfo->totbits += pinfo->mainbits[gr][ch]; } } if (pinfo->frameNum > 0) /* start averaging at second frame */ gtkinfo.avebits = (gtkinfo.avebits*((pinfo->frameNum)-1) + pinfo->totbits ) /(pinfo->frameNum); gtkinfo.maxbits=MAX(gtkinfo.maxbits,pinfo->totbits); gtkinfo.totemph += !(pinfo->emph==0); gtkinfo.totms += !(pinfo->ms_stereo==0); gtkinfo.totis += !(pinfo->i_stereo==0); if (gtkinfo.totalframes>0) if (pplot->frameNum >= gtkinfo.totalframes-1) mp3done=1; } } idle_count++; if (gtkinfo.pupdate) plot_frame(); update_progress(); if ((idle_count>=idle_count_max) && (! idle_end)) analyze(); } else { /*no processing to do, sleep in order to not monopolize CPU*/ msleep(10); } return 1;}static void frameadv( GtkWidget *widget, gpointer data ){ int adv; if (!strcmp((char *) data,"-1")) { /* ignore if we've already gone back as far as possible */ if (pplot->frameNum==0 || (idle_back==NUMBACK)) return; idle_back++; pplot = &Pinfo[READ_AHEAD+idle_back]; analyze(); return; } adv = 1; if (!strcmp((char *) data,"1")) adv = 1; if (!strcmp((char *) data,"10")) adv = 10; if (!strcmp((char *) data,"100")) adv = 100; if (!strcmp((char *) data,"finish")) idle_end = 1; if (idle_keepgoing) { /* already running - que up additional frame advance requests */ idle_count_max += adv; } else { /* turn on idleing */ idle_count_max = adv; idle_count = 0; idle_keepgoing = 1; }}/* another callback */static void delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){ /* set MP3 done flag in case the File/Quit menu item has been selected */ mp3done=1; gtk_main_quit ();}static void channel_option (GtkWidget *widget, gpointer data){ long option; option = (long) data; switch (option) { case 1: gtkinfo.msflag=0; gtkinfo.chflag=0; break; case 2: gtkinfo.msflag=0; gtkinfo.chflag=1; break; case 3: gtkinfo.msflag=1; gtkinfo.chflag=0; break; case 4: gtkinfo.msflag=1; gtkinfo.chflag=1; } analyze();}static void spec_option (GtkWidget *widget, gpointer data){ long option; option = (long) data; switch (option) { case 1: gtkinfo.kbflag=0; break; case 2: gtkinfo.kbflag=1; break; case 3: gtkinfo.flag123=0; break; case 4: gtkinfo.flag123=1; break; case 5: gtkinfo.pupdate=1; break; case 6: gtkinfo.pupdate=0; break; case 7: gtkinfo.sfblines = !gtkinfo.sfblines; break; case 8: gtkinfo.difference = !gtkinfo.difference; break; } analyze();}static gint key_press_event (GtkWidget *widget, GdkEventKey *event){ /* is a switch() statement in lame forbidden? */ if (event->keyval == '1') { subblock_draw[0] = 1; subblock_draw[1] = 0; subblock_draw[2] = 0; analyze(); } else if (event->keyval == '2') { subblock_draw[0] = 0; subblock_draw[1] = 1; subblock_draw[2] = 0; analyze(); } else if (event->keyval == '3') { subblock_draw[0] = 0; subblock_draw[1] = 0; subblock_draw[2] = 1; analyze(); } else if (event->keyval == '0') { subblock_draw[0] = 1; subblock_draw[1] = 1; subblock_draw[2] = 1; analyze(); } /* analyze(); */ /* dont redraw entire window for every key! */ return 0;}/*! Get the mp3x version string. *//*! \param void \return a pointer to a string which describes the version of mp3x.*/const char* get_mp3x_version ( void ){#if MP3X_ALPHA_VERSION > 0 static /*@observer@*/ const char *const str = XSTR(MP3X_MAJOR_VERSION) "." XSTR(MP3X_MINOR_VERSION) " (alpha " XSTR(MP3X_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";#elif MP3X_BETA_VERSION > 0 static /*@observer@*/ const char *const str = XSTR(MP3X_MAJOR_VERSION) "." XSTR(MP3X_MINOR_VERSION) " (beta " XSTR(MP3X_BETA_VERSION) ", " __DATE__ ")";#else static /*@observer@*/ const char *const str = XSTR(MP3X_MAJOR_VERSION) "." XSTR(MP3X_MINOR_VERSION);#endif return str;}static void text_window (GtkWidget *widget, gpointer data){ long option; GtkWidget *hbox,*vbox,*button,*box; GtkWidget *textwindow,*vscrollbar; char text[256]; option = (long) data; textwindow = gtk_window_new(GTK_WINDOW_DIALOG); gtk_signal_connect_object (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (textwindow)); gtk_container_set_border_width (GTK_CONTAINER (textwindow), 0); vbox = gtk_vbox_new(FALSE,0); hbox = gtk_hbox_new(FALSE,0); button = gtk_button_new_with_label ("close"); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (textwindow)); box = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (box), FALSE); vscrollbar = gtk_vscrollbar_new (GTK_TEXT(box)->vadj); switch (option) { case 0: gtk_window_set_title (GTK_WINDOW (textwindow), "Documentation"); gtk_widget_set_usize(box,450,500); gtk_text_set_word_wrap(GTK_TEXT(box),TRUE); /* text should be moved outside this function, may be in a separate file */ gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "Frame header information: "\ "First the bitrate, sampling frequency and mono, stereo or jstereo "\ "indicators are displayed . If the bitstream is jstereo, then mid/side "\ "stereo or intensity stereo may be on (indicated in red). If "\ "de-emphasis is used, this is also indicated in red. The mdb value is "\ "main_data_begin. The encoded data starts this many bytes *before* the "\ "frame header. A large value of mdb means the bitstream has saved some "\ "bits into the reservoir, which it may allocate for some future frame. "\ "The two numbers after mdb are the size (in bits) used to encode the "\ "MDCT coefficients for this frame, followed byt the size of the bit "\ "resevoir before encoding this frame. The maximum frame size and a "\ "running average are given in the Stats pull down menu. A large "\ "maximum frame size indicates the bitstream has made use of the bit "\ "reservoir. \n\n",-1); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "PCM data (top graph): "\ "The PCM data is plotted in black. The layer3 frame is divided into 2 "\ "granules of 576 samples (marked with yellow vertical lines). In the "\ "case of normal, start and stop blocks, the MDCT coefficients for each "\ "granule are computed using a 1152 sample window centered over the "\ "granule. In the case of short blocks, the granule is further divided "\ "into 3 blocks of 192 samples (also marked with yellow vertical lines)."\ "The MDCT coefficients for these blocks are computed using 384 sample "\ "windows centered over the 192 sample window. (This info not available "\ "when analyzing .mp3 files.) For the psycho-acoustic model, a windowed "\ "FFT is computed for each granule. The range of these windows "\ "is denoted by the blue and green bars.\n\n",-1); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "PCM re-synthesis data (second graph): "\ "Same as the PCM window described above. The data displayed is the "\ "result of encoding and then decoding the original sample. \n\n",-1); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "MDCT windows: "\ "Shows the energy in the MDCT spectrum for granule 0 (left window) "\ "and granule 1 (right window). The text also shows the blocktype "\ "used, the number of bits used to encode the coefficients and the "\ "number of extra bits allocated from the reservoir. The MDCT pull down "\ "window will toggle between the original unquantized MDCT coefficients "\ "and the compressed (quantized) coefficients.\n\n",-1); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "FFT window: "\ "The gray bars show the energy in the FFT spectrum used by the "\ "psycho-acoustic model. Granule 0 is in the left window, granule 1 in "\ "the right window. The green and blue bars show how much distortion is "\ "allowable, as computed by the psycho-acoustic model. The red bars show "\ "the actual distortion after encoding. There is one FFT for each "\ "granule, computed with a 1024 Hann window centered over the "\ "appropriate granule. (the range of this 1024 sample window is shown "\ "by the blue and green bars in the PCM data window). The Spectrum pull "\ "down window will toggle between showing the energy in equally spaced "\ "frequency domain and the scale factor bands used by layer3. Finally, "\ "the perceptual entropy, total energy and number of scalefactor bands "\ "with audible distortion is shown. (This info not available when "\ "analyzing .mp3 files.)",-1); break; case 1: /* Set the about box information */ gtk_window_set_title (GTK_WINDOW (textwindow), "About"); gtk_widget_set_usize(box,350,260); sprintf(text,"LAME version %s \n%s\n\n",get_lame_version(),get_lame_url()); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL,text,-1); sprintf(text,"psycho-acoustic model: GPSYCHO version %s\n",get_psy_version()); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL,text,-1); sprintf(text,"frame analyzer: MP3x version %s\n\n",get_mp3x_version()); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL,text,-1); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "decoder: mpg123/mpglib .59q \nMichael Hipp (www.mpg123.de)\n\n",-1); gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL, "Encoder, decoder & psy-models based on ISO\ndemonstration source. ",-1); break; case 2: gtk_window_set_title (GTK_WINDOW (textwindow), "Statistics");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -