Ardour  9.0-pre0-582-g084a23a80d
ltc.h File Reference

libltc - en+decode linear timecode More...

#include <endian.h>
#include <stddef.h>
Include dependency graph for ltc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LTCFrame
 
struct  LTCFrameExt
 
struct  SMPTETimecode
 

Macros

#define LIBLTC_VERSION   "1.3.0"
 
#define LIBLTC_VERSION_MAJOR   1
 
#define LIBLTC_VERSION_MINOR   3
 
#define LIBLTC_VERSION_MICRO   0
 
#define LIBLTC_CUR   11
 
#define LIBLTC_REV   5
 
#define LIBLTC_AGE   0
 
#define LTC_FRAME_BIT_COUNT   80
 

Typedefs

typedef unsigned char ltcsnd_sample_t
 
typedef long long int ltc_off_t
 
typedef struct LTCFrame LTCFrame
 
typedef struct LTCFrameExt LTCFrameExt
 
typedef struct SMPTETimecode SMPTETimecode
 
typedef struct LTCDecoder LTCDecoder
 
typedef struct LTCEncoder LTCEncoder
 

Enumerations

enum  LTC_TV_STANDARD { LTC_TV_525_60 , LTC_TV_625_50 , LTC_TV_1125_60 , LTC_TV_FILM_24 }
 
enum  LTC_BG_FLAGS { LTC_USE_DATE = 1 , LTC_TC_CLOCK = 2 , LTC_BGF_DONT_TOUCH = 4 , LTC_NO_PARITY = 8 }
 

Functions

void ltc_frame_to_time (SMPTETimecode *stime, LTCFrame *frame, int flags)
 
void ltc_time_to_frame (LTCFrame *frame, SMPTETimecode *stime, enum LTC_TV_STANDARD standard, int flags)
 
void ltc_frame_reset (LTCFrame *frame)
 
int ltc_frame_increment (LTCFrame *frame, int fps, enum LTC_TV_STANDARD standard, int flags)
 
int ltc_frame_decrement (LTCFrame *frame, int fps, enum LTC_TV_STANDARD standard, int flags)
 
LTCDecoderltc_decoder_create (int apv, int queue_size)
 
int ltc_decoder_free (LTCDecoder *d)
 
void ltc_decoder_write (LTCDecoder *d, ltcsnd_sample_t *buf, size_t size, ltc_off_t posinfo)
 
void ltc_decoder_write_float (LTCDecoder *d, float *buf, size_t size, ltc_off_t posinfo)
 
void ltc_decoder_write_s16 (LTCDecoder *d, short *buf, size_t size, ltc_off_t posinfo)
 
void ltc_decoder_write_u16 (LTCDecoder *d, unsigned short *buf, size_t size, ltc_off_t posinfo)
 
int ltc_decoder_read (LTCDecoder *d, LTCFrameExt *frame)
 
void ltc_decoder_queue_flush (LTCDecoder *d)
 
int ltc_decoder_queue_length (LTCDecoder *d)
 
LTCEncoderltc_encoder_create (double sample_rate, double fps, enum LTC_TV_STANDARD standard, int flags)
 
void ltc_encoder_free (LTCEncoder *e)
 
void ltc_encoder_set_timecode (LTCEncoder *e, SMPTETimecode *t)
 
void ltc_encoder_get_timecode (LTCEncoder *e, SMPTETimecode *t)
 
int ltc_encoder_inc_timecode (LTCEncoder *e)
 
int ltc_encoder_dec_timecode (LTCEncoder *e)
 
void ltc_encoder_set_frame (LTCEncoder *e, LTCFrame *f)
 
void ltc_encoder_get_frame (LTCEncoder *e, LTCFrame *f)
 
int ltc_encoder_get_buffer (LTCEncoder *e, ltcsnd_sample_t *buf)
 
ltcsnd_sample_tltc_encoder_get_bufptr (LTCEncoder *e, int *size, int flush)
 
void ltc_encoder_buffer_flush (LTCEncoder *e)
 
size_t ltc_encoder_get_buffersize (LTCEncoder *e)
 
int ltc_encoder_reinit (LTCEncoder *e, double sample_rate, double fps, enum LTC_TV_STANDARD standard, int flags)
 
void ltc_encoder_reset (LTCEncoder *e)
 
int ltc_encoder_set_bufsize (LTCEncoder *e, double sample_rate, double fps)
 
int ltc_encoder_set_volume (LTCEncoder *e, double dBFS)
 
void ltc_encoder_set_filter (LTCEncoder *e, double rise_time)
 
int ltc_encoder_encode_byte (LTCEncoder *e, int byte, double speed)
 
void ltc_encoder_encode_frame (LTCEncoder *e)
 
void ltc_frame_set_parity (LTCFrame *frame, enum LTC_TV_STANDARD standard)
 
int parse_bcg_flags (LTCFrame *f, enum LTC_TV_STANDARD standard)
 
ltc_off_t ltc_frame_alignment (double samples_per_frame, enum LTC_TV_STANDARD standard)
 

Detailed Description

libltc - en+decode linear timecode

Linear (or Longitudinal) Timecode (LTC) is an encoding of timecode data as a Manchester-Biphase encoded audio signal. The audio signal is commonly recorded on a VTR track or other storage media.

libltc facilitates decoding and encoding of LTC from/to timecode, including SMPTE date support.

Author
Robin Gareus robin.nosp@m.@gar.nosp@m.eus.o.nosp@m.rg

Copyright (C) 2006-2014 Robin Gareus robin.nosp@m.@gar.nosp@m.eus.o.nosp@m.rg

Copyright (C) 2008-2009 Jan Weiß jan@g.nosp@m.ehei.nosp@m.mwerk.nosp@m..de

Inspired by SMPTE Decoder - Maarten de Boer mdebo.nosp@m.er@i.nosp@m.ua.up.nosp@m.f.es

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.

Definition in file ltc.h.

Macro Definition Documentation

◆ LIBLTC_AGE

#define LIBLTC_AGE   0

Definition at line 76 of file ltc.h.

◆ LIBLTC_CUR

#define LIBLTC_CUR   11

Definition at line 74 of file ltc.h.

◆ LIBLTC_REV

#define LIBLTC_REV   5

Definition at line 75 of file ltc.h.

◆ LIBLTC_VERSION

#define LIBLTC_VERSION   "1.3.0"

Definition at line 66 of file ltc.h.

◆ LIBLTC_VERSION_MAJOR

#define LIBLTC_VERSION_MAJOR   1

Definition at line 67 of file ltc.h.

◆ LIBLTC_VERSION_MICRO

#define LIBLTC_VERSION_MICRO   0

Definition at line 69 of file ltc.h.

◆ LIBLTC_VERSION_MINOR

#define LIBLTC_VERSION_MINOR   3

Definition at line 68 of file ltc.h.

◆ LTC_FRAME_BIT_COUNT

#define LTC_FRAME_BIT_COUNT   80

Definition at line 89 of file ltc.h.

Typedef Documentation

◆ ltc_off_t

typedef long long int ltc_off_t

sample-count offset - 64bit wide

Definition at line 87 of file ltc.h.

◆ LTCDecoder

typedef struct LTCDecoder LTCDecoder

Opaque structure see: ltc_decoder_create, ltc_decoder_free

Definition at line 87 of file ltc.h.

◆ LTCEncoder

typedef struct LTCEncoder LTCEncoder

Opaque structure see: ltc_encoder_create, ltc_encoder_free

Definition at line 87 of file ltc.h.

◆ LTCFrame

typedef struct LTCFrame LTCFrame

see LTCFrame

Definition at line 87 of file ltc.h.

◆ LTCFrameExt

typedef struct LTCFrameExt LTCFrameExt

see LTCFrameExt

Definition at line 87 of file ltc.h.

◆ ltcsnd_sample_t

typedef unsigned char ltcsnd_sample_t

default audio sample type: 8bit unsigned (mono)

Definition at line 82 of file ltc.h.

◆ SMPTETimecode

typedef struct SMPTETimecode SMPTETimecode

see SMPTETimecode

Definition at line 87 of file ltc.h.

Enumeration Type Documentation

◆ LTC_BG_FLAGS

encoder and LTCframe <> timecode operation flags

Enumerator
LTC_USE_DATE 

LTCFrame <> SMPTETimecode converter and LTCFrame increment/decrement use date, also set BGF2 to '1' when encoder is initialized or re-initialized (unless LTC_BGF_DONT_TOUCH is given)

LTC_TC_CLOCK 

the Timecode is wall-clock aka freerun. This also sets BGF1 (unless LTC_BGF_DONT_TOUCH is given)

LTC_BGF_DONT_TOUCH 

encoder init or re-init does not touch the BGF bits (initial values after initialization is zero)

LTC_NO_PARITY 

parity bit is left untouched when setting or in/decrementing the encoder frame-number

Definition at line 265 of file ltc.h.

◆ LTC_TV_STANDARD

the standard defines the assignment of the binary-group-flag bits basically only 25fps is different, but other standards defined in the SMPTE spec have been included for completeness.

Enumerator
LTC_TV_525_60 

30fps

LTC_TV_625_50 

25fps

LTC_TV_1125_60 

30fps

LTC_TV_FILM_24 

24fps

Definition at line 257 of file ltc.h.

Function Documentation

◆ ltc_decoder_create()

LTCDecoder* ltc_decoder_create ( int  apv,
int  queue_size 
)

Create a new LTC decoder.

Parameters
apvaudio-frames per video frame. This is just used for initial settings, the speed is tracked dynamically. setting this in the right ballpark is needed to properly decode the first LTC frame in a sequence.
queue_sizelength of the internal queue to store decoded frames to SMPTEDecoderWrite.
Returns
decoder handle or NULL if out-of-memory

◆ ltc_decoder_free()

int ltc_decoder_free ( LTCDecoder d)

Release memory of decoder.

Parameters
ddecoder handle

◆ ltc_decoder_queue_flush()

void ltc_decoder_queue_flush ( LTCDecoder d)

Remove all LTC frames from the internal queue.

Parameters
ddecoder handle

◆ ltc_decoder_queue_length()

int ltc_decoder_queue_length ( LTCDecoder d)

Count number of LTC frames currently in the queue.

Parameters
ddecoder handle
Returns
number of queued frames

◆ ltc_decoder_read()

int ltc_decoder_read ( LTCDecoder d,
LTCFrameExt frame 
)

Decoded LTC frames are placed in a queue. This function retrieves a frame from the queue, and stores it at LTCFrameExt*

Parameters
ddecoder handle
framethe decoded LTC frame is copied there
Returns
1 on success or 0 when no frames queued.

◆ ltc_decoder_write()

void ltc_decoder_write ( LTCDecoder d,
ltcsnd_sample_t buf,
size_t  size,
ltc_off_t  posinfo 
)

Feed the LTC decoder with new audio samples.

Parse raw audio for LTC timestamps. Once a complete LTC frame has been decoded it is pushed into a queue (ltc_decoder_read)

Parameters
ddecoder handle
bufpointer to ltcsnd_sample_t - unsigned 8 bit mono audio data
sizesize number of samples to parse
posinfo(optional, recommended) sample-offset in the audio-stream. It is added to off_start, off_end in LTCFrameExt and should be monotonic (ie incremented by size for every call to ltc_decoder_write)

◆ ltc_decoder_write_float()

void ltc_decoder_write_float ( LTCDecoder d,
float *  buf,
size_t  size,
ltc_off_t  posinfo 
)

Wrapper around ltc_decoder_write that accepts floating point audio samples. Note: internally libltc uses 8 bit only.

Parameters
ddecoder handle
bufpointer to audio sample data
sizenumber of samples to parse
posinfo(optional, recommended) sample-offset in the audio-stream.

◆ ltc_decoder_write_s16()

void ltc_decoder_write_s16 ( LTCDecoder d,
short *  buf,
size_t  size,
ltc_off_t  posinfo 
)

Wrapper around ltc_decoder_write that accepts signed 16 bit audio samples. Note: internally libltc uses 8 bit only.

Parameters
ddecoder handle
bufpointer to audio sample data
sizenumber of samples to parse
posinfo(optional, recommended) sample-offset in the audio-stream.

◆ ltc_decoder_write_u16()

void ltc_decoder_write_u16 ( LTCDecoder d,
unsigned short *  buf,
size_t  size,
ltc_off_t  posinfo 
)

Wrapper around ltc_decoder_write that accepts unsigned 16 bit audio samples. Note: internally libltc uses 8 bit only.

Parameters
ddecoder handle
bufpointer to audio sample data
sizenumber of samples to parse
posinfo(optional, recommended) sample-offset in the audio-stream.

◆ ltc_encoder_buffer_flush()

void ltc_encoder_buffer_flush ( LTCEncoder e)

reset the write-pointer of the encoder-buffer

Parameters
eencoder handle

◆ ltc_encoder_create()

LTCEncoder* ltc_encoder_create ( double  sample_rate,
double  fps,
enum LTC_TV_STANDARD  standard,
int  flags 
)

Allocate and initialize LTC audio encoder.

calls ltc_encoder_reinit internally see, see notes there.

Parameters
sample_rateaudio sample rate (eg. 48000)
fpsvideo-frames per second (e.g. 25.0)
standardthe TV standard to use for Binary Group Flag bit position
flagsbinary combination of LTC_BG_FLAGS

◆ ltc_encoder_dec_timecode()

int ltc_encoder_dec_timecode ( LTCEncoder e)

Move the encoder to the previous timecode frame. This is useful for encoding reverse LTC. uses ltc_frame_decrement() internally.

◆ ltc_encoder_encode_byte()

int ltc_encoder_encode_byte ( LTCEncoder e,
int  byte,
double  speed 
)

Generate LTC audio for given byte of the LTC-frame and place it into the internal buffer.

see ltc_encoder_get_buffer and ltc_encoder_get_bufptr

LTC has 10 bytes per frame: 0 <= bytecnt < 10 use SMPTESetTime(..) to set the current frame before Encoding. see tests/encoder.c for an example.

The default output signal is @ -3dBFS (38..218 at 8 bit unsigned). see also ltc_encoder_set_volume

if speed is < 0, the bits are encoded in reverse. slowdown > 10.0 requires custom buffer sizes; see ltc_encoder_set_bufsize

Parameters
eencoder handle
bytebyte of the LTC-frame to encode 0..9
speedvari-speed, < 1.0 faster, > 1.0 slower ; must be != 0
Returns
0 on success, -1 if byte is invalid or buffer overflow (speed > 10.0)

◆ ltc_encoder_encode_frame()

void ltc_encoder_encode_frame ( LTCEncoder e)

Encode a full LTC frame at fixed speed. This is equivalent to calling ltc_encoder_encode_byte 10 times for bytes 0..9 with speed 1.0.

Note: The internal buffer must be empty before calling this function. Otherwise it may overflow. This is usually the case if it is read with ltc_encoder_get_buffer after calling this function.

The default internal buffersize is exactly one full LTC frame at speed 1.0.

Parameters
eencoder handle

◆ ltc_encoder_free()

void ltc_encoder_free ( LTCEncoder e)

Release memory of the encoder.

Parameters
eencoder handle

◆ ltc_encoder_get_buffer()

int ltc_encoder_get_buffer ( LTCEncoder e,
ltcsnd_sample_t buf 
)

Copy the accumulated encoded audio to the given sample-buffer and flush the internal buffer.

Parameters
eencoder handle
bufplace to store the audio-samples, needs to be large enough to hold ltc_encoder_get_buffersize bytes
Returns
the number of bytes written to the memory area pointed to by buf.

◆ ltc_encoder_get_buffersize()

size_t ltc_encoder_get_buffersize ( LTCEncoder e)

Query the length of the internal buffer. It is allocated to hold audio-frames for exactly one LTC frame for the given sample-rate and frame-rate. ie. (1 + sample-rate / fps) bytes

Note this returns the total size of the buffer, not the used/free part. See also ltc_encoder_get_bufptr

Parameters
eencoder handle
Returns
size of the allocated internal buffer.

◆ ltc_encoder_get_bufptr()

ltcsnd_sample_t* ltc_encoder_get_bufptr ( LTCEncoder e,
int *  size,
int  flush 
)

Retrieve a pointer to the accumulated encoded audio-data.

Parameters
eencoder handle
sizeif set, the number of valid bytes in the buffer is stored there
flushcall ltc_encoder_buffer_flush - reset the buffer write-pointer
Returns
pointer to encoder-buffer

◆ ltc_encoder_get_frame()

void ltc_encoder_get_frame ( LTCEncoder e,
LTCFrame f 
)

Low-level access to the encoder internal LTCFrame data

Parameters
eencoder handle
freturn LTC frame data

◆ ltc_encoder_get_timecode()

void ltc_encoder_get_timecode ( LTCEncoder e,
SMPTETimecode t 
)

Query the current encoder timecode.

Note: the decoder stores its internal state in an LTC-frame, this function converts that LTC-Frame into SMPTETimecode on demand. see also ltc_encoder_get_frame.

Parameters
eencoder handle
tis set to current timecode

◆ ltc_encoder_inc_timecode()

int ltc_encoder_inc_timecode ( LTCEncoder e)

Move the encoder to the next timecode frame. uses ltc_frame_increment() internally.

◆ ltc_encoder_reinit()

int ltc_encoder_reinit ( LTCEncoder e,
double  sample_rate,
double  fps,
enum LTC_TV_STANDARD  standard,
int  flags 
)

Change the encoder settings without re-allocating any library internal data structure (realtime safe). changing the fps and or sample-rate implies a buffer flush, and biphase state reset.

This call will fail if the internal buffer is too small to hold one full LTC frame. Use ltc_encoder_set_bufsize to prepare an internal buffer large enough to accommodate all sample_rate, fps combinations that you would like to re-init to.

The LTC frame payload data is not modified by this call, however, the flag-bits of the LTC-Frame are updated: If fps equals to 29.97 or 30000.0/1001.0, the LTCFrame's 'dfbit' bit is set to 1 to indicate drop-frame timecode.

Unless the LTC_BGF_DONT_TOUCH flag is set the BGF1 is set or cleared depending on LTC_TC_CLOCK and BGF0,2 according to LTC_USE_DATE and the given standard. col_frame is cleared and the parity recomputed (unless LTC_NO_PARITY is given).

Parameters
eencoder handle
sample_rateaudio sample rate (eg. 48000)
fpsvideo-frames per second (e.g. 25.0)
standardthe TV standard to use for Binary Group Flag bit position
flagsbinary combination of LTC_BG_FLAGS

◆ ltc_encoder_reset()

void ltc_encoder_reset ( LTCEncoder e)

reset ecoder state. flushes buffer, reset biphase state

Parameters
eencoder handle

◆ ltc_encoder_set_bufsize()

int ltc_encoder_set_bufsize ( LTCEncoder e,
double  sample_rate,
double  fps 
)

Configure a custom size for the internal buffer.

This is needed if you are planning to call ltc_encoder_reinit() or if you want to keep more than one LTC frame's worth of data in the library's internal buffer.

The buffer-size is (1 + sample_rate / fps) bytes. resizing the internal buffer will flush all existing data in it - alike ltc_encoder_buffer_flush.

Parameters
eencoder handle
sample_rateaudio sample rate (eg. 48000)
fpsvideo-frames per second (e.g. 25.0)
Returns
0 on success, -1 if allocation fails (which makes the encoder unusable, call ltc_encoder_free or realloc the buffer)

◆ ltc_encoder_set_filter()

void ltc_encoder_set_filter ( LTCEncoder e,
double  rise_time 
)

Set encoder signal rise-time / signal filtering

LTC signal should have a rise time of 40us +/- 10 us. by default the encoder honors this and low-pass filters the output depending on the sample-rate.

If you want a perfect square wave, set 'rise_time' to 0.

Note ltc_encoder_reinit resets the filter-time-constant to use the default 40us for the given sample-rate, overriding any value previously set with ltc_encoder_set_filter

Parameters
eencoder handle
rise_timethe signal rise-time in us (10^(-6) sec), set to 0 for perfect square wave, default 40.0

◆ ltc_encoder_set_frame()

void ltc_encoder_set_frame ( LTCEncoder e,
LTCFrame f 
)

Low-level access to the internal LTCFrame data.

Note: be careful to about f->dfbit, the encoder sets this [only] upon initialization.

Parameters
eencoder handle
fLTC frame data to use

◆ ltc_encoder_set_timecode()

void ltc_encoder_set_timecode ( LTCEncoder e,
SMPTETimecode t 
)

Set the encoder LTC-frame to the given SMPTETimecode. The next call to ltc_encoder_encode_byte or ltc_encoder_encode_frame will encode this time to LTC audio-samples.

Internally this call uses ltc_time_to_frame because the LTCEncoder operates on LTCframes only. see als ltc_encoder_set_frame

Parameters
eencoder handle
ttimecode to set.

◆ ltc_encoder_set_volume()

int ltc_encoder_set_volume ( LTCEncoder e,
double  dBFS 
)

Set the volume of the generated LTC signal

typically LTC is sent at 0dBu ; in EBU calibrated systems that corresponds to -18dBFS. - by default libltc creates -3dBFS

since libltc generated 8bit audio-data, the minimum dBFS is about -42dB which corresponds to 1 bit.

0dB corresponds to a signal range of 127 1..255 with 128 at the center.

Parameters
eencoder handle
dBFSthe volume in dB full-scale (<= 0.0)
Returns
0 on success, -1 if the value was out of range

◆ ltc_frame_alignment()

ltc_off_t ltc_frame_alignment ( double  samples_per_frame,
enum LTC_TV_STANDARD  standard 
)

LTCFrame sample alignment offset.

There is a relative offset of the LTC-Frame start and the TV-frame. The first bit of a LTC frame corresponds to a specific line in the actual video frame. When decoding this offset needs to be subtracted from the LTC-frame's audio-sample-time to match the TV-frame's start position.

For film frames or HDV the offset is zero.

Parameters
samples_per_frameaudio-samples per timecode-frame (eg. 1920 = 48000/25)
standardthe TV standard
Returns
offset in samples

◆ ltc_frame_decrement()

int ltc_frame_decrement ( LTCFrame frame,
int  fps,
enum LTC_TV_STANDARD  standard,
int  flags 
)

Decrement the timecode by one Frame (1/framerate seconds) and set the Frame's parity bit accordingly (see ltc_frame_set_parity)

Parameters
framethe LTC-timecode to decrement
fpsinteger framerate (for drop-frame-timecode set frame->dfbit and round-up the fps).
standardthe TV standard to use for parity bit assignment if set to 1 the 25fps standard is enabled and LTC Frame bit 59 instead of 27 is used for the parity. It only has only has effect flag bit 4 (LTC_NO_PARITY) is cleared.
flagsbinary combination of LTC_BG_FLAGS - here only LTC_USE_DATE and LTC_NO_PARITY are relevant. if the bit 0 is set (1) interpret user-data as date and decrement date if timecode wraps at 24h. (Note: leap-years are taken into account, but since the year is two-digit only, the 100,400yr rules are ignored. "00" is assumed to be year 2000 which was a leap year.) bit 3 (8) indicates that the parity bit should not be touched
Returns
1 if timecode was wrapped around at 23:59:59:ff, 0 otherwise

◆ ltc_frame_increment()

int ltc_frame_increment ( LTCFrame frame,
int  fps,
enum LTC_TV_STANDARD  standard,
int  flags 
)

Increment the timecode by one Frame (1/framerate seconds) and set the Frame's parity bit accordingly (see ltc_frame_set_parity)

Parameters
framethe LTC-timecode to increment
fpsinteger framerate (for drop-frame-timecode set frame->dfbit and round-up the fps).
standardthe TV standard to use for parity bit assignment if set to 1 the 25fps standard is enabled and LTC Frame bit 59 instead of 27 is used for the parity. It only has only has effect flag bit 4 (LTC_NO_PARITY) is cleared.
flagsbinary combination of LTC_BG_FLAGS - here only LTC_USE_DATE and LTC_NO_PARITY are relevant. If the bit 0 (1) is set (1) interpret user-data as date and increment date if timecode wraps after 24h. (Note: leap-years are taken into account, but since the year is two-digit only, the 100,400yr rules are ignored. "00" is assumed to be year 2000 which was a leap year.)
Returns
1 if timecode was wrapped around after 23:59:59:ff, 0 otherwise

◆ ltc_frame_reset()

void ltc_frame_reset ( LTCFrame frame)

Reset all values of a LTC FRAME to zero, except for the sync-word (0x3FFD) at the end. The sync word is set according to architecture (big/little endian). Also set the Frame's parity bit accordingly (see ltc_frame_set_parity)

Parameters
framethe LTCFrame to reset

◆ ltc_frame_set_parity()

void ltc_frame_set_parity ( LTCFrame frame,
enum LTC_TV_STANDARD  standard 
)

Set the parity of the LTC frame.

Bi-Phase Mark Phase Correction bit (bit 27 - or 59) may be set or cleared so that that every 80-bit word contains an even number of zeroes. This means that the phase in every Sync Word will be the same.

This is merely cosmetic; the motivation to keep the polarity of the waveform constant is to make finding the Sync Word visibly (on a scope) easier.

There is usually no need to call this function directly. The encoder utility functions ltc_time_to_frame, ltc_frame_increment and ltc_frame_decrement include a call to it.

Parameters
framethe LTC to analyze and set or clear the biphase_mark_phase_correction bit.
standardIf 1 (aka LTC_TV_625_50) , the 25fps mode (bit 59 - aka binary_group_flag_bit2) is used, otherwise the 30fps, 24fps mode (bit 27 – biphase_mark_phase_correction) is set or cleared.

◆ ltc_frame_to_time()

void ltc_frame_to_time ( SMPTETimecode stime,
LTCFrame frame,
int  flags 
)

Convert binary LTCFrame into SMPTETimecode struct

Parameters
stimeoutput
frameinput
flagsbinary combination of LTC_BG_FLAGS - here only LTC_USE_DATE is relevant. if LTC_USE_DATE is set, the user-fields in LTCFrame will be parsed into the date variable of SMPTETimecode. otherwise the date information in the SMPTETimecode is set to zero.

◆ ltc_time_to_frame()

void ltc_time_to_frame ( LTCFrame frame,
SMPTETimecode stime,
enum LTC_TV_STANDARD  standard,
int  flags 
)

Translate SMPTETimecode struct into its binary LTC representation and set the LTC frame's parity bit accordingly (see ltc_frame_set_parity)

Parameters
frameoutput - the frame to be set
stimeinput - timecode input
standardthe TV standard to use for parity bit assignment
flagsbinary combination of LTC_BG_FLAGS - here only LTC_USE_DATE and LTC_NO_PARITY are relevant. if LTC_USE_DATE is given, user-fields in LTCFrame will be set from the date in SMPTETimecode, otherwise the user-bits are not modified. All non-timecode fields remain untouched - except for the parity bit unless LTC_NO_PARITY is given.

◆ parse_bcg_flags()

int parse_bcg_flags ( LTCFrame f,
enum LTC_TV_STANDARD  standard 
)

Parse Binary Group Flags into standard independent format: bit 0 (1) - BGF 0, bit 1 (2) - BGF 1, bit 2 (4) - BGF 2

Parameters
fLTC frame data analyze
standardthe TV standard to use – see LTCFrame for BGF assignment
Returns
LTC Binary Group Flags