gavl: /tmp/tgz/gavl-1.0.1/include/gavl/gavltime.h Source File

# gavltime.h

    00001 /*****************************************************************
    00002  * gavl - a general purpose audio/video processing library
    00003  *
    00004  * Copyright (c) 2001 - 2008 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
    00035 #define GAVL_TIME_SCALE     1000000
    00040 #define GAVL_TIME_UNDEFINED 0x8000000000000000LL
    00043 #define GAVL_TIME_MAX       0x7fffffffffffffffLL
    00050 typedef int64_t gavl_time_t;
    00051
    00052 /* Utility functions */
    00053
    00059 gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples);
    00060
    00069 int64_t gavl_time_to_samples(int samplerate, gavl_time_t time);
    00070
    00076 gavl_time_t gavl_frames_to_time(int rate_num, int rate_den, int64_t frames);
    00077
    00078
    00088 int64_t gavl_time_to_frames(int rate_num, int rate_den, gavl_time_t time);
    00089
    00098 int64_t gavl_time_scale(int scale, gavl_time_t time);
    00099
    00108 gavl_time_t gavl_time_unscale(int scale, int64_t time);
    00109
    00119 int64_t gavl_time_rescale(int scale1, int scale2, int64_t time);
    00120
    00127 #define gavl_seconds_to_time(s) (gavl_time_t)((s)*(double)(GAVL_TIME_SCALE))
    00128
    00135 #define gavl_time_to_seconds(t) ((double)(t)/(double)(GAVL_TIME_SCALE))
    00136
    00142 void gavl_time_delay(gavl_time_t * time);
    00143
    00148 #define GAVL_TIME_STRING_LEN 11
    00149
    00159 void
    00160 gavl_time_prettyprint(gavl_time_t time, char str[GAVL_TIME_STRING_LEN]);
    00161
    00162
    00163 /* Scan time: format is hhh:mm:ss with hh: hours, mm: minutes, ss: seconds. Seconds can be a fractional
    00164    value (i.e. with decimal point) */
    00165
    00166 int gavl_time_parse(const char * str, gavl_time_t * ret);
    00167
    00168
    00169 /* Simple software timer */
    00170
    00185 typedef struct gavl_timer_s gavl_timer_t;
    00186
    00192 gavl_timer_t * gavl_timer_create();
    00193
    00201 void gavl_timer_destroy(gavl_timer_t * timer);
    00202
    00208 void gavl_timer_start(gavl_timer_t * timer);
    00209
    00215 void gavl_timer_stop(gavl_timer_t * timer);
    00216
    00223 gavl_time_t gavl_timer_get(gavl_timer_t * timer);
    00224
    00231 void gavl_timer_set(gavl_timer_t * timer, gavl_time_t t);
    00232
    00233 #ifdef __cplusplus
    00234 }
    00235 #endif
    00236
    00237 #endif /* GAVLTIME_H_INCLUDED */
    00238