gavltime.h

00001 /*****************************************************************
00002  * gavl - a general purpose audio/video processing library
00003  *
00004  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
00005  * gmerlin-general@lists.sourceforge.net
00006  * http://gmerlin.sourceforge.net
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  * *****************************************************************/
00021  
00022 #ifndef GAVLTIME_H_INCLUDED
00023 #define GAVLTIME_H_INCLUDED
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 #include <inttypes.h>
00030 #include <gavl/gavldefs.h>
00031 
00038 #define GAVL_TIME_SCALE     1000000 
00043 #define GAVL_TIME_UNDEFINED 0x8000000000000000LL 
00046 #define GAVL_TIME_MAX       0x7fffffffffffffffLL 
00053 typedef int64_t gavl_time_t;
00054 
00055 /* Utility functions */
00056 
00061 GAVL_PUBLIC
00062 gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples);
00063 
00071 GAVL_PUBLIC
00072 int64_t gavl_time_to_samples(int samplerate, gavl_time_t time);
00073 
00078 GAVL_PUBLIC
00079 gavl_time_t gavl_frames_to_time(int rate_num, int rate_den, int64_t frames);
00080 
00081 
00090 GAVL_PUBLIC
00091 int64_t gavl_time_to_frames(int rate_num, int rate_den, gavl_time_t time); 
00092 
00100 GAVL_PUBLIC
00101 int64_t gavl_time_scale(int scale, gavl_time_t time);
00102 
00110 GAVL_PUBLIC
00111 gavl_time_t gavl_time_unscale(int scale, int64_t time);
00112 
00121 GAVL_PUBLIC
00122 int64_t gavl_time_rescale(int scale1, int scale2, int64_t time);
00123 
00130 #define gavl_seconds_to_time(s) (gavl_time_t)((s)*(double)(GAVL_TIME_SCALE))
00131 
00138 #define gavl_time_to_seconds(t) ((double)(t)/(double)(GAVL_TIME_SCALE))
00139 
00145 GAVL_PUBLIC
00146 void gavl_time_delay(gavl_time_t * time);
00147 
00152 #define GAVL_TIME_STRING_LEN 11
00153 
00163 GAVL_PUBLIC void
00164 gavl_time_prettyprint(gavl_time_t time, char str[GAVL_TIME_STRING_LEN]);
00165 
00170 #define GAVL_TIME_STRING_LEN_MS 15
00171 
00183 GAVL_PUBLIC void
00184 gavl_time_prettyprint_ms(gavl_time_t time, char str[GAVL_TIME_STRING_LEN_MS]);
00185   
00186 
00187 /* Scan time: format is hhh:mm:ss with hh: hours, mm: minutes, ss: seconds. Seconds can be a fractional
00188    value (i.e. with decimal point) */
00189 
00190 GAVL_PUBLIC
00191 int gavl_time_parse(const char * str, gavl_time_t * ret);
00192 
00193 
00194 /* Simple software timer */
00195 
00210 typedef struct gavl_timer_s gavl_timer_t;
00211 
00217 GAVL_PUBLIC
00218 gavl_timer_t * gavl_timer_create();
00219 
00227 GAVL_PUBLIC
00228 void gavl_timer_destroy(gavl_timer_t * timer);
00229 
00235 GAVL_PUBLIC
00236 void gavl_timer_start(gavl_timer_t * timer);
00237 
00243 GAVL_PUBLIC
00244 void gavl_timer_stop(gavl_timer_t * timer);
00245 
00252 GAVL_PUBLIC
00253 gavl_time_t gavl_timer_get(gavl_timer_t * timer);
00254 
00261 GAVL_PUBLIC
00262 void gavl_timer_set(gavl_timer_t * timer, gavl_time_t t);
00263 
00275 GAVL_PUBLIC
00276 uint64_t gavl_benchmark_get_time(int flags);
00277 
00286 GAVL_PUBLIC
00287 const char * gavl_benchmark_get_desc(int flags);
00288   
00289   
00290 #ifdef __cplusplus
00291 }
00292 #endif
00293 
00294 #endif /* GAVLTIME_H_INCLUDED */
00295 
Generated on Fri Jun 8 17:27:53 2012 for gavl by  doxygen 1.6.3