timecode.h
/*****************************************************************
* gavl - a general purpose audio/video processing library
*
* Copyright (c) 2001 - 2011 Members of the Gmerlin project
* gmerlin-general@lists.sourceforge.net
* http://gmerlin.sourceforge.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *****************************************************************/
#ifndef TIMECODE_H_INCLUDED
#define TIMECODE_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
#include <gavl/gavldefs.h>
typedef uint64_t gavl_timecode_t;
#define GAVL_TIMECODE_SIGN_MASK (0x1LL<<62)
#define GAVL_TIMECODE_INVALID_MASK (0x1LL<<63)
#define GAVL_TIMECODE_DROP_FRAME (1<<0)
#define GAVL_TIMECODE_UNDEFINED GAVL_TIMECODE_INVALID_MASK
typedef struct
{
int int_framerate;
int flags;
} gavl_timecode_format_t;
GAVL_PUBLIC
void gavl_timecode_format_copy(gavl_timecode_format_t * dst,
const gavl_timecode_format_t * src);
GAVL_PUBLIC
void gavl_timecode_to_hmsf(gavl_timecode_t tc,
int * hours,
int * minutes,
int * seconds,
int * frames);
GAVL_PUBLIC
void gavl_timecode_to_ymd(gavl_timecode_t tc,
int * year,
int * month,
int * day);
GAVL_PUBLIC
void gavl_timecode_from_hmsf(gavl_timecode_t * tc,
int hours,
int minutes,
int seconds,
int frames);
GAVL_PUBLIC
void gavl_timecode_from_ymd(gavl_timecode_t * tc,
int year,
int month,
int day);
GAVL_PUBLIC
int64_t gavl_timecode_to_framecount(const gavl_timecode_format_t * tf,
gavl_timecode_t tc);
GAVL_PUBLIC
gavl_timecode_t gavl_timecode_from_framecount(const gavl_timecode_format_t * tf,
int64_t fc);
GAVL_PUBLIC
void gavl_timecode_dump(const gavl_timecode_format_t * tf,
gavl_timecode_t tc);
/* -YYYY-MM-DD-HH:MM:SS.FFFF */
#define GAVL_TIMECODE_STRING_LEN 26
GAVL_PUBLIC
void gavl_timecode_prettyprint(const gavl_timecode_format_t * tf,
gavl_timecode_t tc,
char str[GAVL_TIMECODE_STRING_LEN]);
/* -HH:MM:SS:FF */
#define GAVL_TIMECODE_STRING_LEN_SHORT 13
GAVL_PUBLIC
void gavl_timecode_prettyprint_short(gavl_timecode_t tc,
char str[GAVL_TIMECODE_STRING_LEN_SHORT]);
#ifdef __cplusplus
}
#endif
#endif /* TIMECODE_H_INCLUDED */
gavl_timecode_prettyprint_short
GAVL_PUBLIC void gavl_timecode_prettyprint_short(gavl_timecode_t tc, char str[GAVL_TIMECODE_STRING_LEN_SHORT])
Print a short timecode into a string.
gavl_timecode_from_framecount
GAVL_PUBLIC gavl_timecode_t gavl_timecode_from_framecount(const gavl_timecode_format_t *tf, int64_t fc)
Get a timecode from the frame count.
gavl_timecode_format_copy
GAVL_PUBLIC void gavl_timecode_format_copy(gavl_timecode_format_t *dst, const gavl_timecode_format_t *src)
Copy one timecode format to another.
gavl_timecode_t
uint64_t gavl_timecode_t
Typedef for timecodes.
Definition: timecode.h:43
gavl_timecode_to_hmsf
GAVL_PUBLIC void gavl_timecode_to_hmsf(gavl_timecode_t tc, int *hours, int *minutes, int *seconds, int *frames)
Extract the time part of the timecode.
gavl_timecode_from_hmsf
GAVL_PUBLIC void gavl_timecode_from_hmsf(gavl_timecode_t *tc, int hours, int minutes, int seconds, int frames)
Set the time part of the timecode.
gavl_timecode_from_ymd
GAVL_PUBLIC void gavl_timecode_from_ymd(gavl_timecode_t *tc, int year, int month, int day)
Set the date part of the timecode.
gavl_timecode_to_framecount
GAVL_PUBLIC int64_t gavl_timecode_to_framecount(const gavl_timecode_format_t *tf, gavl_timecode_t tc)
Get the frame count from the timecode.
gavl_timecode_dump
GAVL_PUBLIC void gavl_timecode_dump(const gavl_timecode_format_t *tf, gavl_timecode_t tc)
Dump a timecode to stderr.
gavl_timecode_prettyprint
GAVL_PUBLIC void gavl_timecode_prettyprint(const gavl_timecode_format_t *tf, gavl_timecode_t tc, char str[GAVL_TIMECODE_STRING_LEN])
Print a full timecode into a string.
GAVL_TIMECODE_STRING_LEN_SHORT
#define GAVL_TIMECODE_STRING_LEN_SHORT
Definition: timecode.h:192
gavl_timecode_to_ymd
GAVL_PUBLIC void gavl_timecode_to_ymd(gavl_timecode_t tc, int *year, int *month, int *day)
Extract the date part of the timecode.
GAVL_TIMECODE_STRING_LEN
#define GAVL_TIMECODE_STRING_LEN
Definition: timecode.h:172
gavl_timecode_format_t
Timecode format.
Definition: timecode.h:60
gavl_timecode_format_t::int_framerate
int int_framerate
Integer framerate. A value of zero signals, that no timecodes are available.
Definition: timecode.h:61
gavl_timecode_format_t::flags
int flags
Zero or more of the flags defined above.
Definition: timecode.h:62