home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Misc / Graph.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-06  |  3.5 KB  |  130 lines

  1. /* 
  2.  *  Graph.cpp 
  3.  *
  4.  *    Copyright (C) Alberto Vigata - January 2000 - ultraflask@yahoo.com
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23. #include "..\flaskmpeg.h"
  24. #include "..\auxiliary.h"
  25. #include "..\resource.h"
  26. #include "graph.h"
  27.  
  28. extern TConfig   o ;
  29. extern i64 myClock;
  30.  
  31. void GraphStart(TGraph *gr){
  32.     gr->posw       = 0;
  33.     gr->last55[55];
  34.     gr->br_actual  = 0;
  35.     gr->br_max     = 0;
  36.     gr->br_min     = 2000000000;
  37.     gr->br_fr      = 0;
  38.     gr->posw_input = 0;
  39.     gr->br_avr     = 0;
  40. }
  41.  
  42. void DrawGraph(HWND hDlg, TGraph *gr){
  43.     //Agrabber start
  44.             
  45.             if(o.options.displayVideo)
  46.             {
  47.                 DlgSetText(hDlg, IDC_BR_A,   (gr->br_actual*5*25*8)/1024.0);
  48.                 DlgSetText(hDlg, IDC_BR_MAX, (gr->br_max*5*25*8)/1024.0);
  49.                 DlgSetText(hDlg, IDC_BR_MIN, (gr->br_min*5*25*8)/1024.0);
  50.                 if(myClock)
  51.                     DlgSetText(hDlg, IDC_BR_AVR, ((gr->br_avr*5*8)/1024.0)/((float)myClock/(float)27000000));
  52.                 HDC hDC;
  53.                 HWND m_hwnd = GetDlgItem (hDlg, IDC_BITRATEHIST);
  54.                 hDC = GetWindowDC (m_hwnd);
  55.  
  56.                 PatBlt(hDC,0,0,545,61,BLACKNESS);
  57.                 HPEN Fpen, oldpen;
  58.                 Fpen = CreatePen(PS_SOLID, 1, RGB(0,160,0));
  59.                 oldpen = (HPEN)SelectObject(hDC, Fpen);
  60.                  for (int i=0;i<54;i++)
  61.                 {
  62.                     MoveToEx(hDC,i*10,0,NULL);
  63.                     LineTo(hDC,i*10,60);
  64.                 }
  65.                 for (i=0;i<7;i++)
  66.                 {
  67.                     MoveToEx(hDC,0,i*10,NULL);
  68.                     LineTo(hDC,544,i*10);
  69.                 }
  70.                 Fpen = (HPEN)SelectObject(hDC, oldpen);
  71.                 DeleteObject(Fpen);
  72.  
  73.                 Fpen = CreatePen(PS_SOLID, 1, RGB(255,255,0));
  74.                 oldpen = (HPEN)SelectObject(hDC, Fpen);
  75.                 for (i=1;i<55;i++)
  76.                 {
  77.                     int y1,y2,x1,x2;
  78.                     x1 = i*10-10;
  79.                     x2 = i*10;
  80.                     y1 = gr->last55[i-1];
  81.                     y2 = gr->last55[i];
  82.                     MoveToEx(hDC,x1,y1,NULL);
  83.                     LineTo(hDC,x2,y2);
  84.  
  85.                 }
  86.                 Fpen = (HPEN)SelectObject(hDC, oldpen);
  87.                 DeleteObject(Fpen);
  88.  
  89. /*                Fpen = CreatePen(PS_SOLID, 1, RGB(0,255,0));
  90.                 oldpen = (HPEN)SelectObject(hDC, Fpen);
  91.                 for (i=1;i<55;i++)
  92.                 {
  93.                     int y1,y2,x1,x2;
  94.                     x1 = i*10-10;
  95.                     x2 = i*10;
  96.                     y1 = last55_input[i-1];
  97.                     y2 = last55_input[i];
  98.                     MoveToEx(hDC,x1,y1,NULL);
  99.                     LineTo(hDC,x2,y2);
  100.  
  101.                 }
  102.                 Fpen = (HPEN)SelectObject(hDC, oldpen);
  103.                 DeleteObject(Fpen);*/
  104.  
  105. //                SetPixel(hDC,posw*10,60-(bytesw/250),RGB(255,255,0));
  106.                 ReleaseDC (m_hwnd, hDC);
  107.             }
  108. //Agrabber end    
  109. }
  110.  
  111. void UpdateGraph(TGraph *gr, TAVIPlugGraphInfo *info){
  112.     int i;
  113.     int frame_size;
  114.     frame_size = info->Video;
  115.  
  116.     gr->br_actual = (frame_size*8*25)/1000;
  117.     gr->br_avr = gr->br_avr+gr->br_actual;
  118.     gr->br_fr++;
  119.     if (gr->br_actual>gr->br_max)
  120.         gr->br_max = gr->br_actual;
  121.     if (gr->br_actual<gr->br_min)
  122.         gr->br_min = gr->br_actual;
  123.  
  124.     gr->last55[gr->posw]=60-( (frame_size/250)>=60 ? 0:(frame_size/250));
  125.     if (gr->posw<54)
  126.         gr->posw++;
  127.     else
  128.         for (i=1;i<55;i++)
  129.             gr->last55[i-1]=gr->last55[i];
  130. }