1 |
/***************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Some timing functions to profile the library - |
* - Timer functions (used for internal debugging) - |
|
* |
|
|
* NB : not thread safe and only for debug purposes. |
|
5 |
* |
* |
6 |
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
7 |
* |
* |
8 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
* This program is free software ; you can redistribute it and/or modify |
9 |
* |
* it under the terms of the GNU General Public License as published by |
|
* XviD is free software; you can redistribute it and/or modify it |
|
|
* under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
11 |
* (at your option) any later version. |
* (at your option) any later version. |
12 |
* |
* |
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 |
* |
* |
|
* Under section 8 of the GNU General Public License, the copyright |
|
|
* holders of XVID explicitly forbid distribution in the following |
|
|
* countries: |
|
|
* |
|
|
* - Japan |
|
|
* - United States of America |
|
|
* |
|
|
* Linking XviD statically or dynamically with other modules is making a |
|
|
* combined work based on XviD. Thus, the terms and conditions of the |
|
|
* GNU General Public License cover the whole combination. |
|
|
* |
|
|
* As a special exception, the copyright holders of XviD give you |
|
|
* permission to link XviD with independent modules that communicate with |
|
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
* license terms of these independent modules, and to copy and distribute |
|
|
* 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. |
|
|
* |
|
22 |
* $Id$ |
* $Id$ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
27 |
#include <time.h> |
#include <time.h> |
28 |
#include "timer.h" |
#include "timer.h" |
29 |
|
|
30 |
#ifdef _PROFILING_ |
#if defined(_PROFILING_) |
31 |
|
|
32 |
struct ts |
struct ts |
33 |
{ |
{ |
58 |
not very precise but sufficient |
not very precise but sufficient |
59 |
*/ |
*/ |
60 |
double |
double |
61 |
get_freq(void) |
get_freq() |
62 |
{ |
{ |
63 |
int64_t x, y; |
int64_t x, y; |
64 |
int32_t i; |
int32_t i; |
79 |
|
|
80 |
/* set everything to zero */ |
/* set everything to zero */ |
81 |
void |
void |
82 |
init_timer(void) |
init_timer() |
83 |
{ |
{ |
84 |
frequency = get_freq(); |
frequency = get_freq(); |
85 |
|
|
91 |
} |
} |
92 |
|
|
93 |
void |
void |
94 |
start_timer(void) |
start_timer() |
95 |
{ |
{ |
96 |
tim.current = read_counter(); |
tim.current = read_counter(); |
97 |
} |
} |
98 |
|
|
99 |
void |
void |
100 |
start_global_timer(void) |
start_global_timer() |
101 |
{ |
{ |
102 |
tim.global = read_counter(); |
tim.global = read_counter(); |
103 |
} |
} |
104 |
|
|
105 |
void |
void |
106 |
stop_dct_timer(void) |
stop_dct_timer() |
107 |
{ |
{ |
108 |
tim.dct += (read_counter() - tim.current); |
tim.dct += (read_counter() - tim.current); |
109 |
} |
} |
110 |
|
|
111 |
void |
void |
112 |
stop_idct_timer(void) |
stop_idct_timer() |
113 |
{ |
{ |
114 |
tim.idct += (read_counter() - tim.current); |
tim.idct += (read_counter() - tim.current); |
115 |
} |
} |
116 |
|
|
117 |
void |
void |
118 |
stop_quant_timer(void) |
stop_quant_timer() |
119 |
{ |
{ |
120 |
tim.quant += (read_counter() - tim.current); |
tim.quant += (read_counter() - tim.current); |
121 |
} |
} |
122 |
|
|
123 |
void |
void |
124 |
stop_iquant_timer(void) |
stop_iquant_timer() |
125 |
{ |
{ |
126 |
tim.iquant += (read_counter() - tim.current); |
tim.iquant += (read_counter() - tim.current); |
127 |
} |
} |
128 |
|
|
129 |
void |
void |
130 |
stop_motion_timer(void) |
stop_motion_timer() |
131 |
{ |
{ |
132 |
tim.motion += (read_counter() - tim.current); |
tim.motion += (read_counter() - tim.current); |
133 |
} |
} |
134 |
|
|
135 |
void |
void |
136 |
stop_comp_timer(void) |
stop_comp_timer() |
137 |
{ |
{ |
138 |
tim.comp += (read_counter() - tim.current); |
tim.comp += (read_counter() - tim.current); |
139 |
} |
} |
140 |
|
|
141 |
void |
void |
142 |
stop_edges_timer(void) |
stop_edges_timer() |
143 |
{ |
{ |
144 |
tim.edges += (read_counter() - tim.current); |
tim.edges += (read_counter() - tim.current); |
145 |
} |
} |
146 |
|
|
147 |
void |
void |
148 |
stop_inter_timer(void) |
stop_inter_timer() |
149 |
{ |
{ |
150 |
tim.inter += (read_counter() - tim.current); |
tim.inter += (read_counter() - tim.current); |
151 |
} |
} |
152 |
|
|
153 |
void |
void |
154 |
stop_conv_timer(void) |
stop_conv_timer() |
155 |
{ |
{ |
156 |
tim.conv += (read_counter() - tim.current); |
tim.conv += (read_counter() - tim.current); |
157 |
} |
} |
158 |
|
|
159 |
void |
void |
160 |
stop_transfer_timer(void) |
stop_transfer_timer() |
161 |
{ |
{ |
162 |
tim.trans += (read_counter() - tim.current); |
tim.trans += (read_counter() - tim.current); |
163 |
} |
} |
164 |
|
|
165 |
void |
void |
166 |
stop_prediction_timer(void) |
stop_prediction_timer() |
167 |
{ |
{ |
168 |
tim.prediction += (read_counter() - tim.current); |
tim.prediction += (read_counter() - tim.current); |
169 |
} |
} |
170 |
|
|
171 |
void |
void |
172 |
stop_coding_timer(void) |
stop_coding_timer() |
173 |
{ |
{ |
174 |
tim.coding += (read_counter() - tim.current); |
tim.coding += (read_counter() - tim.current); |
175 |
} |
} |
176 |
|
|
177 |
void |
void |
178 |
stop_interlacing_timer(void) |
stop_interlacing_timer() |
179 |
{ |
{ |
180 |
tim.interlacing += (read_counter() - tim.current); |
tim.interlacing += (read_counter() - tim.current); |
181 |
} |
} |
182 |
|
|
183 |
void |
void |
184 |
stop_global_timer(void) |
stop_global_timer() |
185 |
{ |
{ |
186 |
tim.overall += (read_counter() - tim.global); |
tim.overall += (read_counter() - tim.global); |
187 |
} |
} |
190 |
write log file with some timer information |
write log file with some timer information |
191 |
*/ |
*/ |
192 |
void |
void |
193 |
write_timer(void) |
write_timer() |
194 |
{ |
{ |
195 |
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, |
196 |
interlacing_per; |
interlacing_per; |
200 |
|
|
201 |
count_frames++; |
count_frames++; |
202 |
|
|
203 |
/* only write log file every 50 processed frames */ |
// only write log file every 50 processed frames // |
204 |
if (count_frames % 50) { |
if (count_frames % 50) { |
205 |
FILE *fp; |
FILE *fp; |
206 |
|
|