1 |
/***************************************************************************** |
/****************************************************************************** |
2 |
* |
* * |
3 |
* XVID MPEG-4 VIDEO CODEC |
* This file is part of XviD, a free MPEG-4 video encoder/decoder * |
4 |
* - Some timing functions to profile the library - |
* * |
5 |
* |
* XviD is free software; you can redistribute it and/or modify it * |
6 |
* NB : not thread safe and only for debug purposes. |
* under the terms of the GNU General Public License as published by * |
7 |
* |
* the Free Software Foundation; either version 2 of the License, or * |
8 |
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
* (at your option) any later version. * |
9 |
* |
* * |
10 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
* XviD is distributed in the hope that it will be useful, but * |
11 |
* |
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
* XviD is free software; you can redistribute it and/or modify it |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
* under the terms of the GNU General Public License as published by |
* GNU General Public License for more details. * |
14 |
* the Free Software Foundation; either version 2 of the License, or |
* * |
15 |
* (at your option) any later version. |
* You should have received a copy of the GNU General Public License * |
16 |
* |
* along with this program; if not, write to the Free Software * |
17 |
* This program is distributed in the hope that it will be useful, |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* * |
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
******************************************************************************/ |
20 |
* GNU General Public License for more details. |
|
21 |
* |
/****************************************************************************** |
22 |
* You should have received a copy of the GNU General Public License |
* * |
23 |
* along with this program; if not, write to the Free Software |
* timer.c, some timing functions * |
24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* * |
25 |
* |
* Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org> * |
26 |
* Under section 8 of the GNU General Public License, the copyright |
* * |
27 |
* holders of XVID explicitly forbid distribution in the following |
* For more information visit the XviD homepage: http://www.xvid.org * |
28 |
* countries: |
* * |
29 |
* |
******************************************************************************/ |
30 |
* - Japan |
|
31 |
* - United States of America |
/****************************************************************************** |
32 |
* |
* * |
33 |
* Linking XviD statically or dynamically with other modules is making a |
* Revision history: * |
34 |
* combined work based on XviD. Thus, the terms and conditions of the |
* |
35 |
* GNU General Public License cover the whole combination. |
* 26.03.2002 interlacing timer added |
36 |
* |
* 21.12.2001 edges error fixed |
37 |
* As a special exception, the copyright holders of XviD give you |
* 17.11.2001 small clean up (Isibaar) * |
38 |
* permission to link XviD with independent modules that communicate with |
* 13.11.2001 inlined rdtsc call and moved to portab.h (Isibaar) * |
39 |
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
* 02.11.2001 initial version (Isibaar) * |
40 |
* license terms of these independent modules, and to copy and distribute |
* * |
41 |
* the resulting combined work under terms of your choice, provided that |
******************************************************************************/ |
|
* every copy of the combined work is accompanied by a complete copy of |
|
|
* the source code of XviD (the version of XviD used to produce the |
|
|
* combined work), being distributed under the terms of the GNU General |
|
|
* Public License plus this exception. An independent module is a module |
|
|
* which is not derived from or based on XviD. |
|
|
* |
|
|
* Note that people who make modified versions of XviD are not obligated |
|
|
* to grant this special exception for their modified versions; it is |
|
|
* their choice whether to do so. The GNU General Public License gives |
|
|
* permission to release a modified version without this exception; this |
|
|
* exception also makes it possible to release a modified version which |
|
|
* carries forward this exception. |
|
|
* |
|
|
* $Id$ |
|
|
* |
|
|
****************************************************************************/ |
|
42 |
|
|
43 |
#include <stdio.h> |
#include <stdio.h> |
44 |
#include <time.h> |
#include <time.h> |
45 |
#include "timer.h" |
#include "timer.h" |
46 |
|
|
47 |
#ifdef _PROFILING_ |
#if defined(_PROFILING_) |
48 |
|
|
49 |
struct ts |
struct ts |
50 |
{ |
{ |
75 |
not very precise but sufficient |
not very precise but sufficient |
76 |
*/ |
*/ |
77 |
double |
double |
78 |
get_freq(void) |
get_freq() |
79 |
{ |
{ |
80 |
int64_t x, y; |
int64_t x, y; |
81 |
int32_t i; |
int32_t i; |
94 |
return (double) (y - x) / 1000.; |
return (double) (y - x) / 1000.; |
95 |
} |
} |
96 |
|
|
97 |
/* set everything to zero */ |
// set everything to zero // |
98 |
void |
void |
99 |
init_timer(void) |
init_timer() |
100 |
{ |
{ |
101 |
frequency = get_freq(); |
frequency = get_freq(); |
102 |
|
|
108 |
} |
} |
109 |
|
|
110 |
void |
void |
111 |
start_timer(void) |
start_timer() |
112 |
{ |
{ |
113 |
tim.current = read_counter(); |
tim.current = read_counter(); |
114 |
} |
} |
115 |
|
|
116 |
void |
void |
117 |
start_global_timer(void) |
start_global_timer() |
118 |
{ |
{ |
119 |
tim.global = read_counter(); |
tim.global = read_counter(); |
120 |
} |
} |
121 |
|
|
122 |
void |
void |
123 |
stop_dct_timer(void) |
stop_dct_timer() |
124 |
{ |
{ |
125 |
tim.dct += (read_counter() - tim.current); |
tim.dct += (read_counter() - tim.current); |
126 |
} |
} |
127 |
|
|
128 |
void |
void |
129 |
stop_idct_timer(void) |
stop_idct_timer() |
130 |
{ |
{ |
131 |
tim.idct += (read_counter() - tim.current); |
tim.idct += (read_counter() - tim.current); |
132 |
} |
} |
133 |
|
|
134 |
void |
void |
135 |
stop_quant_timer(void) |
stop_quant_timer() |
136 |
{ |
{ |
137 |
tim.quant += (read_counter() - tim.current); |
tim.quant += (read_counter() - tim.current); |
138 |
} |
} |
139 |
|
|
140 |
void |
void |
141 |
stop_iquant_timer(void) |
stop_iquant_timer() |
142 |
{ |
{ |
143 |
tim.iquant += (read_counter() - tim.current); |
tim.iquant += (read_counter() - tim.current); |
144 |
} |
} |
145 |
|
|
146 |
void |
void |
147 |
stop_motion_timer(void) |
stop_motion_timer() |
148 |
{ |
{ |
149 |
tim.motion += (read_counter() - tim.current); |
tim.motion += (read_counter() - tim.current); |
150 |
} |
} |
151 |
|
|
152 |
void |
void |
153 |
stop_comp_timer(void) |
stop_comp_timer() |
154 |
{ |
{ |
155 |
tim.comp += (read_counter() - tim.current); |
tim.comp += (read_counter() - tim.current); |
156 |
} |
} |
157 |
|
|
158 |
void |
void |
159 |
stop_edges_timer(void) |
stop_edges_timer() |
160 |
{ |
{ |
161 |
tim.edges += (read_counter() - tim.current); |
tim.edges += (read_counter() - tim.current); |
162 |
} |
} |
163 |
|
|
164 |
void |
void |
165 |
stop_inter_timer(void) |
stop_inter_timer() |
166 |
{ |
{ |
167 |
tim.inter += (read_counter() - tim.current); |
tim.inter += (read_counter() - tim.current); |
168 |
} |
} |
169 |
|
|
170 |
void |
void |
171 |
stop_conv_timer(void) |
stop_conv_timer() |
172 |
{ |
{ |
173 |
tim.conv += (read_counter() - tim.current); |
tim.conv += (read_counter() - tim.current); |
174 |
} |
} |
175 |
|
|
176 |
void |
void |
177 |
stop_transfer_timer(void) |
stop_transfer_timer() |
178 |
{ |
{ |
179 |
tim.trans += (read_counter() - tim.current); |
tim.trans += (read_counter() - tim.current); |
180 |
} |
} |
181 |
|
|
182 |
void |
void |
183 |
stop_prediction_timer(void) |
stop_prediction_timer() |
184 |
{ |
{ |
185 |
tim.prediction += (read_counter() - tim.current); |
tim.prediction += (read_counter() - tim.current); |
186 |
} |
} |
187 |
|
|
188 |
void |
void |
189 |
stop_coding_timer(void) |
stop_coding_timer() |
190 |
{ |
{ |
191 |
tim.coding += (read_counter() - tim.current); |
tim.coding += (read_counter() - tim.current); |
192 |
} |
} |
193 |
|
|
194 |
void |
void |
195 |
stop_interlacing_timer(void) |
stop_interlacing_timer() |
196 |
{ |
{ |
197 |
tim.interlacing += (read_counter() - tim.current); |
tim.interlacing += (read_counter() - tim.current); |
198 |
} |
} |
199 |
|
|
200 |
void |
void |
201 |
stop_global_timer(void) |
stop_global_timer() |
202 |
{ |
{ |
203 |
tim.overall += (read_counter() - tim.global); |
tim.overall += (read_counter() - tim.global); |
204 |
} |
} |
207 |
write log file with some timer information |
write log file with some timer information |
208 |
*/ |
*/ |
209 |
void |
void |
210 |
write_timer(void) |
write_timer() |
211 |
{ |
{ |
212 |
float dct_per, quant_per, idct_per, iquant_per, mot_per, comp_per, |
float dct_per, quant_per, idct_per, iquant_per, mot_per, comp_per, |
213 |
interlacing_per; |
interlacing_per; |
217 |
|
|
218 |
count_frames++; |
count_frames++; |
219 |
|
|
220 |
/* only write log file every 50 processed frames */ |
// only write log file every 50 processed frames // |
221 |
if (count_frames % 50) { |
if (count_frames % 50) { |
222 |
FILE *fp; |
FILE *fp; |
223 |
|
|