[svn] / branches / dev-api-4 / xvidcore / vfw / src / status.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/vfw/src/status.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1319, Thu Jan 22 14:43:39 2004 UTC revision 1328, Fri Jan 23 13:27:59 2004 UTC
# Line 19  Line 19 
19   * along with this program; if not, write to the Free Software   * along with this program; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21   *   *
22   * $Id: status.c,v 1.1.2.3 2004-01-22 14:43:39 syskin Exp $   * $Id: status.c,v 1.1.2.5 2004-01-23 13:27:59 edgomez Exp $
23   *   *
24   *****************************************************************************/   *****************************************************************************/
25    
26    
27  #include <windows.h>  #include <windows.h>
28    #include <stdio.h>
29    
30  #include "resource.h"  #include "resource.h"
31  #include "codec.h"  #include "codec.h"
32  #include "status.h"  #include "status.h"
# Line 62  Line 64 
64                  for (i=0; i<31; i++) {                  for (i=0; i<31; i++) {
65                          /* i-vops */                          /* i-vops */
66                          unsigned int j_height = (s->height-s->tm.tmHeight)*s->quant[0][i]/s->max_quant_frames;                          unsigned int j_height = (s->height-s->tm.tmHeight)*s->quant[0][i]/s->max_quant_frames;
67                          if (j_height==0 && s->quant[1][i]>0) j_height=1;                          if (j_height==0 && s->quant[0][i]>0) j_height=1;
68    
69                          for(j=0; j < j_height; j++) {                          for(j=0; j < j_height; j++) {
70                                  memset(s->buffer + (s->tm.tmHeight+j)*s->stride + i*s->width31 + 1,                                  memset(s->buffer + (s->tm.tmHeight+j)*s->stride + i*s->width31 + 1,
# Line 91  Line 93 
93    
94  static const char * number[31] = {  static const char * number[31] = {
95          "1", "2", "3", "4", "5", "6", "7", "8", "9",          "1", "2", "3", "4", "5", "6", "7", "8", "9",
96          "10","11","12","13","14","15","16","17","18","19",          "0","1","2","3","4","5","6","7","8","9",
97          "20","21","22","23","24","25","26","27","28","29",          "0","1","2","3","4","5","6","7","8","9",
98          "30","31"          "0","1"
99  };  };
100    
101    static double
102    avg_quant(int quants[31], int min, int max, char* buf)
103    {
104            int i, sum = 0, count = 0;
105            for (i = min; i <= max && i > 0; i++) {
106                    sum += i*quants[i-1];
107                    count += quants[i-1];
108            }
109    
110            if (count != 0) {
111                    double avg = (double)sum/(double)count;
112                    sprintf(buf, "%.2f", avg);
113                    return avg;
114            } else {
115                    buf[0] = 0;
116                    return 0.0;
117            }
118    }
119    
120  /* status window proc handlder */  /* status window proc handlder */
121    
# Line 138  Line 158 
158                  set_bic(s->bi->bmiColors, CLR_QUANT_P,  0, 0,   255);                  set_bic(s->bi->bmiColors, CLR_QUANT_P,  0, 0,   255);
159                  set_bic(s->bi->bmiColors, CLR_QUANT_B,  0, 192,   0);                  set_bic(s->bi->bmiColors, CLR_QUANT_B,  0, 192,   0);
160    
161                  SelectObject(s->hDc, GetStockObject(SYSTEM_FONT));                  SelectObject(s->hDc, GetStockObject(DEFAULT_GUI_FONT));
162                  SetBkColor(s->hDc, *(DWORD*)&s->bi->bmiColors[CLR_BG]);                  SetBkColor(s->hDc, *(DWORD*)&s->bi->bmiColors[CLR_BG]);
163                  SetTextColor(s->hDc, *(DWORD*)&s->bi->bmiColors[CLR_FG]);                  SetTextColor(s->hDc, *(DWORD*)&s->bi->bmiColors[CLR_FG]);
164                  GetTextMetrics(s->hDc, &s->tm);                  GetTextMetrics(s->hDc, &s->tm);
# Line 175  Line 195 
195    
196          case WM_TIMER :          case WM_TIMER :
197                  if (wParam==IDC_STATUS_GRAPH) {                  if (wParam==IDC_STATUS_GRAPH) {
198                            double avg_q; char buf[16];
199    
200                          SetDlgItemInt(hDlg, IDC_STATUS_I_NUM, s->count[1], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_I_NUM, (unsigned int)s->count[1], FALSE);
201                          SetDlgItemInt(hDlg, IDC_STATUS_P_NUM, s->count[2], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_P_NUM, (unsigned int)s->count[2], FALSE);
202                          SetDlgItemInt(hDlg, IDC_STATUS_B_NUM, s->count[3], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_B_NUM, (unsigned int)s->count[3], FALSE);
203                          SetDlgItemInt(hDlg, IDC_STATUS_NUM, s->count[0], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_NUM, (unsigned int)s->count[0], FALSE);
204    
205                          SetDlgItemInt(hDlg, IDC_STATUS_IQ_MIN, s->min_quant[1], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_IQ_MIN, s->min_quant[1], FALSE);
206                          SetDlgItemInt(hDlg, IDC_STATUS_IQ_MAX, s->max_quant[1], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_IQ_MAX, s->max_quant[1], FALSE);
# Line 193  Line 214 
214                          SetDlgItemInt(hDlg, IDC_STATUS_IL_MIN, s->min_length[1], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_IL_MIN, s->min_length[1], FALSE);
215                          SetDlgItemInt(hDlg, IDC_STATUS_IL_MAX, s->max_length[1], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_IL_MAX, s->max_length[1], FALSE);
216                          if (s->count[1]>0)                          if (s->count[1]>0)
217                                  SetDlgItemInt(hDlg, IDC_STATUS_IL_AVG, s->tot_length[1]/s->count[1], FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_IL_AVG, (unsigned int)(s->tot_length[1]/s->count[1]), FALSE);
218                          else                          else
219                                  SetDlgItemInt(hDlg, IDC_STATUS_IL_AVG, 0, FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_IL_AVG, 0, FALSE);
220                          SetDlgItemInt(hDlg, IDC_STATUS_IL_TOT, s->tot_length[1]/1024, FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_IL_TOT, (unsigned int)(s->tot_length[1]/1024), FALSE);
221                          SetDlgItemInt(hDlg, IDC_STATUS_PL_MIN, s->min_length[2], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_PL_MIN, s->min_length[2], FALSE);
222                          SetDlgItemInt(hDlg, IDC_STATUS_PL_MAX, s->max_length[2], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_PL_MAX, s->max_length[2], FALSE);
223                          if (s->count[2]>0)                          if (s->count[2]>0)
224                                  SetDlgItemInt(hDlg, IDC_STATUS_PL_AVG, s->tot_length[2]/s->count[2], FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_PL_AVG, (unsigned int)(s->tot_length[2]/s->count[2]), FALSE);
225                          else                          else
226                                  SetDlgItemInt(hDlg, IDC_STATUS_PL_AVG, 0, FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_PL_AVG, 0, FALSE);
227                          SetDlgItemInt(hDlg, IDC_STATUS_PL_TOT, s->tot_length[2]/1024, FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_PL_TOT, (unsigned int)(s->tot_length[2]/1024), FALSE);
228                          SetDlgItemInt(hDlg, IDC_STATUS_BL_MIN, s->min_length[3], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_BL_MIN, s->min_length[3], FALSE);
229                          SetDlgItemInt(hDlg, IDC_STATUS_BL_MAX, s->max_length[3], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_BL_MAX, s->max_length[3], FALSE);
230                          if (s->count[3]>0)                          if (s->count[3]>0)
231                                  SetDlgItemInt(hDlg, IDC_STATUS_BL_AVG, s->tot_length[3]/s->count[3], FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_BL_AVG, (unsigned int)(s->tot_length[3]/s->count[3]), FALSE);
232                          else                          else
233                                  SetDlgItemInt(hDlg, IDC_STATUS_BL_AVG, 0, FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_BL_AVG, 0, FALSE);
234                          SetDlgItemInt(hDlg, IDC_STATUS_BL_TOT, s->tot_length[3]/1024, FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_BL_TOT, (unsigned int)(s->tot_length[3]/1024), FALSE);
235                          SetDlgItemInt(hDlg, IDC_STATUS_L_MIN, s->min_length[0], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_L_MIN, s->min_length[0], FALSE);
236                          SetDlgItemInt(hDlg, IDC_STATUS_L_MAX, s->max_length[0], FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_L_MAX, s->max_length[0], FALSE);
237                          if (s->count[0]>0)                          if (s->count[0]>0)
238                                  SetDlgItemInt(hDlg, IDC_STATUS_L_AVG, s->tot_length[0]/s->count[0], FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_L_AVG, (int)(s->tot_length[0]/s->count[0]), FALSE);
239                          else                          else
240                                  SetDlgItemInt(hDlg, IDC_STATUS_L_AVG, 0, FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_L_AVG, 0, FALSE);
241                          SetDlgItemInt(hDlg, IDC_STATUS_L_TOT, s->tot_length[0]/1024, FALSE);                          SetDlgItemInt(hDlg, IDC_STATUS_L_TOT, (unsigned int)(s->tot_length[0]/1024), FALSE);
242    
243                          if (s->count[0]>0) {                          if (s->count[0]>0) {
244                                  uint64_t kbits = 8*s->tot_length[0]/1000;                                  uint64_t kbits = 8*s->tot_length[0]/1000;
# Line 227  Line 248 
248                                  SetDlgItemInt(hDlg, IDC_STATUS_KBPS, 0, FALSE);                                  SetDlgItemInt(hDlg, IDC_STATUS_KBPS, 0, FALSE);
249                          }                          }
250    
251                            avg_q = avg_quant(s->quant[0], s->min_quant[1], s->max_quant[1], buf) * s->count[1];
252                            SetDlgItemText(hDlg, IDC_STATUS_IQ_AVG, buf);
253    
254                            avg_q += avg_quant(s->quant[1], s->min_quant[2], s->max_quant[2], buf) * s->count[2];
255                            SetDlgItemText(hDlg, IDC_STATUS_PQ_AVG, buf);
256    
257                            avg_q += avg_quant(s->quant[2], s->min_quant[3], s->max_quant[3], buf) * s->count[3];
258                            SetDlgItemText(hDlg, IDC_STATUS_BQ_AVG, buf);
259    
260                            if (s->count[0] != 0) avg_q /= (double)s->count[0];
261                            sprintf(buf, "%.2f", avg_q);
262                            SetDlgItemText(hDlg, IDC_STATUS_Q_AVG, buf);
263    
264                          draw_graph(s);                          draw_graph(s);
265                          InvalidateRect(s->hGraph, NULL, FALSE);                          InvalidateRect(s->hGraph, NULL, FALSE);
266                  }                  }
# Line 274  Line 308 
308    
309          s->fps = fps_base/fps_inc;          s->fps = fps_base/fps_inc;
310    
311          memset(s->quant, 0, 31*sizeof(int));          memset(s->quant[0], 0, 31*sizeof(int));
312            memset(s->quant[1], 0, 31*sizeof(int));
313            memset(s->quant[2], 0, 31*sizeof(int));
314          s->max_quant_frames = 0;          s->max_quant_frames = 0;
315          for (i=0; i<4; i++) {          for (i=0; i<4; i++) {
316                  s->count[i] = 0;                  s->count[i] = 0;
# Line 291  Line 327 
327          ShowWindow(s->hDlg, SW_SHOW);          ShowWindow(s->hDlg, SW_SHOW);
328  }  }
329    
330    static char
331    type2char(int type)
332    {
333            if (type==XVID_TYPE_IVOP)
334                    return 'I';
335            if (type==XVID_TYPE_PVOP)
336                    return 'P';
337            if (type==XVID_TYPE_BVOP)
338                    return 'B';
339            return 'S';
340    }
341    
342    static void
343    status_debugoutput(status_t *s, int type, int length, int quant)
344    {
345            if (s->hDlg && IsDlgButtonChecked(s->hDlg,IDC_SHOWINTERNALS)==BST_CHECKED) {
346                    LRESULT litem;
347                    char buf[128];
348                    sprintf(buf, "[%6d] ->%c  q:%2d (%6d b)",
349                                    (unsigned int)(s->count[0]), type2char(type), quant, length);
350    
351                    SendDlgItemMessage (s->hDlg,IDC_DEBUGOUTPUT, LB_ADDSTRING, 0, (LPARAM)(LPSTR)buf);
352    
353                    litem = SendDlgItemMessage (s->hDlg, IDC_DEBUGOUTPUT, LB_GETCOUNT, 0, 0L);
354    
355                    if (litem > 12)
356                            litem = SendDlgItemMessage (s->hDlg,IDC_DEBUGOUTPUT, LB_DELETESTRING, 0, 0L);
357    
358                    SendDlgItemMessage(s->hDlg,IDC_DEBUGOUTPUT, LB_SETCURSEL, (WORD)(litem-1), 0L);
359            }
360    }
361    
362  /* feed stats info into the window */  /* feed stats info into the window */
363  void status_update(status_t *s, int type, int length, int quant)  void status_update(status_t *s, int type, int length, int quant)
364  {  {
         if (type == 4) type = 2; /* XVID_TYPE_SVOP to XVID_TYPE_PVOP */  
365          s->count[0]++;          s->count[0]++;
366          s->count[type]++;          s->count[type]++;
367    
368            status_debugoutput(s, type, length, quant);
369    
370            if (type == 4) type = 2; /* XVID_TYPE_SVOP to XVID_TYPE_PVOP */
371    
372          if (s->min_quant[0]==0 || quant<s->min_quant[0]) s->min_quant[0] = quant;          if (s->min_quant[0]==0 || quant<s->min_quant[0]) s->min_quant[0] = quant;
373          if (s->max_quant[0]==0 || quant>s->max_quant[0]) s->max_quant[0] = quant;          if (s->max_quant[0]==0 || quant>s->max_quant[0]) s->max_quant[0] = quant;
374          if (s->min_quant[type]==0 || quant<s->min_quant[type]) s->min_quant[type] = quant;          if (s->min_quant[type]==0 || quant<s->min_quant[type]) s->min_quant[type] = quant;

Legend:
Removed from v.1319  
changed lines
  Added in v.1328

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4