home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / Misc / Graph.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  3.5 KB  |  131 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 "..\runstate.h"
  27. #include "graph.h"
  28.  
  29. extern TRunState   rs;
  30. extern i64 myClock;
  31.  
  32. void GraphStart(TGraph *gr){
  33.     gr->posw       = 0;
  34.     gr->last55[55];
  35.     gr->br_actual  = 0;
  36.     gr->br_max     = 0;
  37.     gr->br_min     = 2000000000;
  38.     gr->br_fr      = 0;
  39.     gr->posw_input = 0;
  40.     gr->br_avr     = 0;
  41. }
  42.  
  43. void DrawGraph(HWND hDlg, TGraph *gr){
  44.     //Agrabber start
  45.             DlgSetText(hDlg, IDC_BR_A,   (gr->br_actual*5*25*8)/1024.0);
  46.             DlgSetText(hDlg, IDC_BR_MAX, (gr->br_max*5*25*8)/1024.0);
  47.             DlgSetText(hDlg, IDC_BR_MIN, (gr->br_min*5*25*8)/1024.0);
  48.             if(myClock)
  49.                 DlgSetText(hDlg, IDC_BR_AVR, ((gr->br_avr*5*8)/1024.0)/((float)myClock/(float)27000000));
  50.             
  51.             if(rs.conf.displayVideo)
  52.             {
  53.                 HDC hDC;
  54.                 HWND m_hwnd = GetDlgItem (hDlg, IDC_BITRATEHIST);
  55.                 hDC = GetWindowDC (m_hwnd);
  56.  
  57.                 PatBlt(hDC,0,0,545,61,BLACKNESS);
  58.                 HPEN Fpen, oldpen;
  59.                 Fpen = CreatePen(PS_SOLID, 1, RGB(0,160,0));
  60.                 oldpen = (HPEN)SelectObject(hDC, Fpen);
  61.                  for (int i=0;i<54;i++)
  62.                 {
  63.                     MoveToEx(hDC,i*10,0,NULL);
  64.                     LineTo(hDC,i*10,60);
  65.                 }
  66.                 for (i=0;i<7;i++)
  67.                 {
  68.                     MoveToEx(hDC,0,i*10,NULL);
  69.                     LineTo(hDC,544,i*10);
  70.                 }
  71.                 Fpen = (HPEN)SelectObject(hDC, oldpen);
  72.                 DeleteObject(Fpen);
  73.  
  74.                 Fpen = CreatePen(PS_SOLID, 1, RGB(255,255,0));
  75.                 oldpen = (HPEN)SelectObject(hDC, Fpen);
  76.                 for (i=1;i<55;i++)
  77.                 {
  78.                     int y1,y2,x1,x2;
  79.                     x1 = i*10-10;
  80.                     x2 = i*10;
  81.                     y1 = gr->last55[i-1];
  82.                     y2 = gr->last55[i];
  83.                     MoveToEx(hDC,x1,y1,NULL);
  84.                     LineTo(hDC,x2,y2);
  85.  
  86.                 }
  87.                 Fpen = (HPEN)SelectObject(hDC, oldpen);
  88.                 DeleteObject(Fpen);
  89.  
  90. /*                Fpen = CreatePen(PS_SOLID, 1, RGB(0,255,0));
  91.                 oldpen = (HPEN)SelectObject(hDC, Fpen);
  92.                 for (i=1;i<55;i++)
  93.                 {
  94.                     int y1,y2,x1,x2;
  95.                     x1 = i*10-10;
  96.                     x2 = i*10;
  97.                     y1 = last55_input[i-1];
  98.                     y2 = last55_input[i];
  99.                     MoveToEx(hDC,x1,y1,NULL);
  100.                     LineTo(hDC,x2,y2);
  101.  
  102.                 }
  103.                 Fpen = (HPEN)SelectObject(hDC, oldpen);
  104.                 DeleteObject(Fpen);*/
  105.  
  106. //                SetPixel(hDC,posw*10,60-(bytesw/250),RGB(255,255,0));
  107.                 ReleaseDC (m_hwnd, hDC);
  108.             }
  109. //Agrabber end    
  110. }
  111.  
  112. void UpdateGraph(TGraph *gr, TAVIPlugGraphInfo *info){
  113.     int i;
  114.     int frame_size;
  115.     frame_size = info->Video;
  116.  
  117.     gr->br_actual = (frame_size*8*25)/1000;
  118.     gr->br_avr = gr->br_avr+gr->br_actual;
  119.     gr->br_fr++;
  120.     if (gr->br_actual>gr->br_max)
  121.         gr->br_max = gr->br_actual;
  122.     if (gr->br_actual<gr->br_min)
  123.         gr->br_min = gr->br_actual;
  124.  
  125.     gr->last55[gr->posw]=60-( (frame_size/250)>=60 ? 0:(frame_size/250));
  126.     if (gr->posw<54)
  127.         gr->posw++;
  128.     else
  129.         for (i=1;i<55;i++)
  130.             gr->last55[i-1]=gr->last55[i];
  131. }