.TH "ltc.h" 3 "Thu Apr 4 2019" "Version 1.3.1" "libltc" \" -*- nroff -*- .ad l .nh .SH NAME ltc.h \- libltc - en+decode linear timecode .SH SYNOPSIS .br .PP \fC#include \fP .br \fC#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBLTCFrame\fP" .br .ti -1c .RI "struct \fBLTCFrameExt\fP" .br .ti -1c .RI "struct \fBSMPTETimecode\fP" .br .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBLTC_FRAME_BIT_COUNT\fP 80" .br .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef unsigned char \fBltcsnd_sample_t\fP" .br .ti -1c .RI "typedef long long int \fBltc_off_t\fP" .br .ti -1c .RI "typedef struct \fBLTCFrame\fP \fBLTCFrame\fP" .br .ti -1c .RI "typedef struct \fBLTCFrameExt\fP \fBLTCFrameExt\fP" .br .ti -1c .RI "typedef struct \fBSMPTETimecode\fP \fBSMPTETimecode\fP" .br .ti -1c .RI "typedef struct \fBLTCDecoder\fP \fBLTCDecoder\fP" .br .ti -1c .RI "typedef struct \fBLTCEncoder\fP \fBLTCEncoder\fP" .br .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBLTC_TV_STANDARD\fP { \fBLTC_TV_525_60\fP, \fBLTC_TV_625_50\fP, \fBLTC_TV_1125_60\fP, \fBLTC_TV_FILM_24\fP }" .br .ti -1c .RI "enum \fBLTC_BG_FLAGS\fP { \fBLTC_USE_DATE\fP = 1, \fBLTC_TC_CLOCK\fP = 2, \fBLTC_BGF_DONT_TOUCH\fP = 4, \fBLTC_NO_PARITY\fP = 8 }" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "void \fBltc_frame_to_time\fP (\fBSMPTETimecode\fP *stime, \fBLTCFrame\fP *frame, int flags)" .br .ti -1c .RI "void \fBltc_time_to_frame\fP (\fBLTCFrame\fP *frame, \fBSMPTETimecode\fP *stime, enum \fBLTC_TV_STANDARD\fP standard, int flags)" .br .ti -1c .RI "void \fBltc_frame_reset\fP (\fBLTCFrame\fP *frame)" .br .ti -1c .RI "int \fBltc_frame_increment\fP (\fBLTCFrame\fP *frame, int fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" .br .ti -1c .RI "int \fBltc_frame_decrement\fP (\fBLTCFrame\fP *frame, int fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" .br .ti -1c .RI "\fBLTCDecoder\fP * \fBltc_decoder_create\fP (int apv, int queue_size)" .br .ti -1c .RI "int \fBltc_decoder_free\fP (\fBLTCDecoder\fP *d)" .br .ti -1c .RI "void \fBltc_decoder_write\fP (\fBLTCDecoder\fP *d, \fBltcsnd_sample_t\fP *buf, size_t size, \fBltc_off_t\fP posinfo)" .br .ti -1c .RI "void \fBltc_decoder_write_float\fP (\fBLTCDecoder\fP *d, float *buf, size_t size, \fBltc_off_t\fP posinfo)" .br .ti -1c .RI "void \fBltc_decoder_write_s16\fP (\fBLTCDecoder\fP *d, short *buf, size_t size, \fBltc_off_t\fP posinfo)" .br .ti -1c .RI "void \fBltc_decoder_write_u16\fP (\fBLTCDecoder\fP *d, unsigned short *buf, size_t size, \fBltc_off_t\fP posinfo)" .br .ti -1c .RI "int \fBltc_decoder_read\fP (\fBLTCDecoder\fP *d, \fBLTCFrameExt\fP *frame)" .br .ti -1c .RI "void \fBltc_decoder_queue_flush\fP (\fBLTCDecoder\fP *d)" .br .ti -1c .RI "int \fBltc_decoder_queue_length\fP (\fBLTCDecoder\fP *d)" .br .ti -1c .RI "\fBLTCEncoder\fP * \fBltc_encoder_create\fP (double sample_rate, double fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" .br .ti -1c .RI "void \fBltc_encoder_free\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "void \fBltc_encoder_set_timecode\fP (\fBLTCEncoder\fP *e, \fBSMPTETimecode\fP *t)" .br .ti -1c .RI "void \fBltc_encoder_get_timecode\fP (\fBLTCEncoder\fP *e, \fBSMPTETimecode\fP *t)" .br .ti -1c .RI "void \fBltc_encoder_set_user_bits\fP (\fBLTCEncoder\fP *e, unsigned long data)" .br .ti -1c .RI "unsigned long \fBltc_frame_get_user_bits\fP (\fBLTCFrame\fP *f)" .br .ti -1c .RI "int \fBltc_encoder_inc_timecode\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "int \fBltc_encoder_dec_timecode\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "void \fBltc_encoder_set_frame\fP (\fBLTCEncoder\fP *e, \fBLTCFrame\fP *f)" .br .ti -1c .RI "void \fBltc_encoder_get_frame\fP (\fBLTCEncoder\fP *e, \fBLTCFrame\fP *f)" .br .ti -1c .RI "int \fBltc_encoder_get_buffer\fP (\fBLTCEncoder\fP *e, \fBltcsnd_sample_t\fP *buf)" .br .ti -1c .RI "\fBltcsnd_sample_t\fP * \fBltc_encoder_get_bufptr\fP (\fBLTCEncoder\fP *e, int *size, int flush)" .br .ti -1c .RI "void \fBltc_encoder_buffer_flush\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "size_t \fBltc_encoder_get_buffersize\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "int \fBltc_encoder_reinit\fP (\fBLTCEncoder\fP *e, double sample_rate, double fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" .br .ti -1c .RI "void \fBltc_encoder_reset\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "int \fBltc_encoder_set_bufsize\fP (\fBLTCEncoder\fP *e, double sample_rate, double fps)" .br .ti -1c .RI "int \fBltc_encoder_set_volume\fP (\fBLTCEncoder\fP *e, double dBFS)" .br .ti -1c .RI "void \fBltc_encoder_set_filter\fP (\fBLTCEncoder\fP *e, double rise_time)" .br .ti -1c .RI "int \fBltc_encoder_encode_byte\fP (\fBLTCEncoder\fP *e, int byte, double speed)" .br .ti -1c .RI "void \fBltc_encoder_encode_frame\fP (\fBLTCEncoder\fP *e)" .br .ti -1c .RI "void \fBltc_frame_set_parity\fP (\fBLTCFrame\fP *frame, enum \fBLTC_TV_STANDARD\fP standard)" .br .ti -1c .RI "int \fBparse_bcg_flags\fP (\fBLTCFrame\fP *f, enum \fBLTC_TV_STANDARD\fP standard)" .br .ti -1c .RI "\fBltc_off_t\fP \fBltc_frame_alignment\fP (double samples_per_frame, enum \fBLTC_TV_STANDARD\fP standard)" .br .in -1c .SH "Detailed Description" .PP 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\&. .PP libltc facilitates decoding and encoding of LTC from/to timecode, including SMPTE date support\&. .PP \fBAuthor:\fP .RS 4 Robin Gareus robin@gareus.org .RE .PP \fBCopyright:\fP .RS 4 .RE .PP Copyright (C) 2006-2014 Robin Gareus robin@gareus.org .PP Copyright (C) 2008-2009 Jan Weiß jan@geheimwerk.de .PP Inspired by SMPTE Decoder - Maarten de Boer mdeboer@iua.upf.es .PP 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\&. .PP 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\&. .PP 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/\&. .SH "Data Structure Documentation" .PP .SH "struct LTCFrame" .PP Raw 80 bit LTC frame .PP The datastream for each video frame of Longitudinal Timecode consists of eighty bit-periods\&. .PP At a frame-rate of 30 fps, the bit-rate corresponds to 30 [fps] * 80 [bits/f] = 2400 bits per second\&. The frequency for a stream of zeros would be 1\&.2 kHz and for a stream of ones it would be 2\&.4 kHz\&. With all commonly used video-frame-rates and audio-sample-rates, LTC timecode can be recorded easily into a audio-track\&. .PP In each frame, 26 of the eighty bits carry the SMPTE time in binary coded decimal (BCD)\&. .PP These Bits are FRAME-UNITS, FRAME-TENS, SECS-UNITS, SECS-TENS, MINS-UNITS, MINS-TENS, HOURS-UNITS and HOURS-TENS\&. The BCD digits are loaded 'least significant bit first' (libltc takes care of the architecture specific alignment)\&. .PP 32 bits are assigned as eight groups of four USER-BITS (also sometimes called the 'Binary Groups')\&. This capacity is generally used to carry extra info such as reel number and/or date\&. The User Bits may be allocated howsoever one wishes as long as both Binary Group Flag Bits are cleared\&. .PP The function \fBltc_frame_to_time\fP can interpret the user-bits as SMPTE Date+Timezone according to SMPTE 309M-1999\&. similarly \fBltc_time_to_frame\fP will do the reverse\&. .PP The last 16 Bits make up the SYNC WORD\&. These bits indicate the frame boundary, the tape direction, and the bit-rate of the sync tone\&. The values of these Bits are fixed as 0011 1111 1111 1101 .PP The 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 of the pulse train in every Sync Word will be the same\&. .PP Bit 10 indicates drop-frame timecode\&. The Colour Frame Flag col\&.frm is Bit 11; if the timecode intentionally synchronized to a colour TV field sequence, this bit is set\&. .PP Bit 58 is not required for the BCD count for HOURS-TENS (which has a maximum value of two) and has not been given any other special purpose so remains unassigned\&. This Bit has been RESERVED for future assignment\&. .PP The Binary Group Flag Bits (bits 43 and 59) are two bits indicate the format of the User Bits data\&. SMPTE 12M-1999 defines the previously reserved bit 58 to signals that the time is locked to wall-clock within a tolerance of ± 0\&.5 seconds\&. .PP SMPTE 12M-1999 also changes the numbering schema of the BGF\&. (BGF1 was renamed to BGF2 and bit 58 becomes BGFB1) .PP To further complicate matters, the BGFB assignment as well as the biphase_mark_phase_correction (aka parity) bit depends on the timecode-format used\&. .PP .PP .nf 25 fps 24, 30 fps BGF0 27 43 BGF1 58 58 BGF2 43 59 Parity 59 27 .fi .PP .PP The variable naming chosen for the \fBLTCFrame\fP struct is based on the 24,30 fps standard\&. .PP The Binary Group Flag Bits should be used only as shown in the truth table below\&. The Unassigned entries in the table should not be used, as they may be allocated specific meanings in the future\&. .PP .PP .nf BGF0 BGF1 BGF2 user-bits timecode Bit 43 Bit 58 Bit 59 (30fps, 24 fps) | | Bit 27 Bit 58 Bit 43 (25fps) No User Bits format specified | ? | 0 0 0 Eight-bit character set (1) | ? | 1 0 0 Date and Timezone set | ? | 0 0 1 Page/Line multiplex (2) | ? | 1 0 1 Character set not specified | clk | 0 1 0 Reserved | ? | 1 1 0 Date and Timezone set | clk | 0 1 1 Page/Line multiplex (2) | clk | 1 1 1 .fi .PP .PP .PP .nf .fi .PP .PP (1) ISO/IEC 646 or ISO/IEC 2022 character set\&. If the seven-bit ISO codes are being used, they shall be converted to eight-bit codes by setting the eighth bit to zero\&. 4 ISO codes can be encoded, user7 and user8 are to be used for the first code with LSB 7 and MSB in 8\&. the remaining ISO codes are to be distributed in the same manner to user5/6 user3/4 and user1/2 accordingly\&. .PP (2) The Page/Line indicates ANSI/SMPTE-262M is used for the user-bits\&. It is multiplex system that can be used to encode large amounts of data in the binary groups through the use of time multiplexing\&. .PP libltc does not use any of the BGF - except for the Parity bit which can be calculated and set with \fBltc_frame_set_parity\fP\&. Setting and interpreting the BGF is left to the application using libltc\&. However libltc provides functionality to parse or set date and timezoe according to SMPTE 309M-1999\&. .PP further information: http://www.philrees.co.uk/articles/timecode.htm and http://www.barney-wol.net/time/timecode.html .PP \fBData Fields:\fP .RS 4 unsigned int \fIbinary_group_flag_bit0:1\fP indicate user-data char encoding, see table above - bit 43 .br .PP unsigned int \fIbinary_group_flag_bit1:1\fP indicate timecode is local time wall-clock, see table above - bit 58 .br .PP unsigned int \fIbinary_group_flag_bit2:1\fP indicate user-data char encoding (or parity with 25fps), see table above - bit 59 .br .PP unsigned int \fIbiphase_mark_phase_correction:1\fP see note on Bit 27 in description and \fBltc_frame_set_parity\fP \&. .br .PP unsigned int \fIcol_frame:1\fP colour-frame: timecode intentionally synchronized to a colour TV field sequence .br .PP unsigned int \fIdfbit:1\fP indicated drop-frame timecode .br .PP unsigned int \fIframe_tens:2\fP SMPTE framenumber BCD tens 0\&.\&.3\&. .br .PP unsigned int \fIframe_units:4\fP SMPTE framenumber BCD unit 0\&.\&.9\&. .br .PP unsigned int \fIhours_tens:2\fP SMPTE hours BCD tens 0\&.\&.2\&. .br .PP unsigned int \fIhours_units:4\fP SMPTE hours BCD unit 0\&.\&.9\&. .br .PP unsigned int \fImins_tens:3\fP SMPTE minutes BCD tens 0\&.\&.6\&. .br .PP unsigned int \fImins_units:4\fP SMPTE minutes BCD unit 0\&.\&.9\&. .br .PP unsigned int \fIsecs_tens:3\fP SMPTE seconds BCD tens 0\&.\&.6\&. .br .PP unsigned int \fIsecs_units:4\fP SMPTE seconds BCD unit 0\&.\&.9\&. .br .PP unsigned int \fIsync_word:16\fP .br .PP unsigned int \fIuser1:4\fP .br .PP unsigned int \fIuser2:4\fP .br .PP unsigned int \fIuser3:4\fP .br .PP unsigned int \fIuser4:4\fP .br .PP unsigned int \fIuser5:4\fP .br .PP unsigned int \fIuser6:4\fP .br .PP unsigned int \fIuser7:4\fP .br .PP unsigned int \fIuser8:4\fP .br .PP .RE .PP .SH "struct LTCFrameExt" .PP Extended LTC frame - includes audio-sample position offsets, volume, etc .PP Note: For TV systems, the sample in the LTC audio data stream where the LTC Frame starts is not necessarily at the same time as the video-frame which is described by the LTC Frame\&. .PP \fBoff_start\fP denotes the time of the first transition of bit 0 in the LTC frame\&. .PP For 525/60 Television systems, the first transition shall occur at the beginning of line 5 of the frame with which it is associated\&. The tolerance is ± 1\&.5 lines\&. .PP For 625/50 systems, the first transition shall occur at the beginning of line 2 ± 1\&.5 lines of the frame with which it is associated\&. .PP Only for 1125/60 systems, the first transition occurs exactly at the vertical sync timing reference of the frame\&. ± 1 line\&. .PP \fBExamples: \fP .in +1c \fBltcdecode\&.c\fP\&. .PP \fBData Fields:\fP .RS 4 float \fIbiphase_tics[\fBLTC_FRAME_BIT_COUNT\fP]\fP detailed timing info: phase of the LTC signal; the time between each bit in the LTC-frame in audio-frames\&. Summing all 80 values in the array will yield audio-frames/LTC-frame = (\fBoff_end\fP - \fBoff_start\fP + 1)\&. .br .PP \fBLTCFrame\fP \fIltc\fP the actual LTC frame\&. see \fBLTCFrame\fP .br .PP \fBltc_off_t\fP \fIoff_end\fP the sample in the stream corresponding to the end of the LTC frame\&. .br .PP \fBltc_off_t\fP \fIoff_start\fP the approximate sample in the stream corresponding to the start of the LTC frame\&. .br .PP int \fIreverse\fP if non-zero, a reverse played LTC frame was detected\&. Since the frame was reversed, it started at off_end and finishes as off_start (off_end > off_start)\&. (Note: in reverse playback the (reversed) sync-word of the next/previous frame is detected, this offset is corrected)\&. .br .PP \fBltcsnd_sample_t\fP \fIsample_max\fP the maximum input sample signal for this frame (0\&.\&.255) .br .PP \fBltcsnd_sample_t\fP \fIsample_min\fP the minimum input sample signal for this frame (0\&.\&.255) .br .PP double \fIvolume\fP the volume of the input signal in dbFS .br .PP .RE .PP .SH "struct SMPTETimecode" .PP Human readable time representation, decimal values\&. .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, \fBltcdecode\&.c\fP, and \fBltcencode\&.c\fP\&. .PP \fBData Fields:\fP .RS 4 unsigned char \fIdays\fP day of month 1\&.\&.31 .br .PP unsigned char \fIframe\fP sub-second frame 0\&.\&.(FPS - 1) .br .PP unsigned char \fIhours\fP hour 0\&.\&.23 .br .PP unsigned char \fImins\fP minute 0\&.\&.60 .br .PP unsigned char \fImonths\fP valid months are 1\&.\&.12 .br .PP unsigned char \fIsecs\fP second 0\&.\&.60 .br .PP char \fItimezone[6]\fP the timezone 6bytes: '+HHMM' textual representation .br .PP unsigned char \fIyears\fP LTC-date uses 2-digit year 00\&.99\&. .br .PP .RE .PP .SH "Macro Definition Documentation" .PP .SS "#define LTC_FRAME_BIT_COUNT 80" .SH "Typedef Documentation" .PP .SS "typedef long long int \fBltc_off_t\fP" sample-count offset - 64bit wide .SS "typedef struct \fBLTCDecoder\fP \fBLTCDecoder\fP" Opaque structure see: \fBltc_decoder_create\fP, \fBltc_decoder_free\fP .SS "typedef struct \fBLTCEncoder\fP \fBLTCEncoder\fP" Opaque structure see: \fBltc_encoder_create\fP, \fBltc_encoder_free\fP .SS "typedef struct \fBLTCFrame\fP \fBLTCFrame\fP" see \fBLTCFrame\fP .SS "typedef struct \fBLTCFrameExt\fP \fBLTCFrameExt\fP" see \fBLTCFrameExt\fP .SS "typedef unsigned char \fBltcsnd_sample_t\fP" default audio sample type: 8bit unsigned (mono) .SS "typedef struct \fBSMPTETimecode\fP \fBSMPTETimecode\fP" see \fBSMPTETimecode\fP .SH "Enumeration Type Documentation" .PP .SS "enum \fBLTC_BG_FLAGS\fP" encoder and LTCframe <> timecode operation flags .PP \fBEnumerator\fP .in +1c .TP \fB\fILTC_USE_DATE \fP\fP \fBLTCFrame\fP <> \fBSMPTETimecode\fP converter and \fBLTCFrame\fP increment/decrement use date, also set BGF2 to '1' when encoder is initialized or re-initialized (unless LTC_BGF_DONT_TOUCH is given) .TP \fB\fILTC_TC_CLOCK \fP\fP the Timecode is wall-clock aka freerun\&. This also sets BGF1 (unless LTC_BGF_DONT_TOUCH is given) .TP \fB\fILTC_BGF_DONT_TOUCH \fP\fP encoder init or re-init does not touch the BGF bits (initial values after initialization is zero) .TP \fB\fILTC_NO_PARITY \fP\fP parity bit is left untouched when setting or in/decrementing the encoder frame-number .SS "enum \fBLTC_TV_STANDARD\fP" 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\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fILTC_TV_525_60 \fP\fP 30fps .TP \fB\fILTC_TV_625_50 \fP\fP 25fps .TP \fB\fILTC_TV_1125_60 \fP\fP 30fps .TP \fB\fILTC_TV_FILM_24 \fP\fP 24fps .SH "Function Documentation" .PP .SS "\fBLTCDecoder\fP* ltc_decoder_create (int apv, int queue_size)" Create a new LTC decoder\&. .PP \fBParameters:\fP .RS 4 \fIapv\fP audio-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\&. .br \fIqueue_size\fP length of the internal queue to store decoded frames to SMPTEDecoderWrite\&. .RE .PP \fBReturns:\fP .RS 4 decoder handle or NULL if out-of-memory .RE .PP .PP \fBExamples: \fP .in +1c \fBltcdecode\&.c\fP\&. .SS "int ltc_decoder_free (\fBLTCDecoder\fP * d)" Release memory of decoder\&. .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .RE .PP .PP \fBExamples: \fP .in +1c \fBltcdecode\&.c\fP\&. .SS "void ltc_decoder_queue_flush (\fBLTCDecoder\fP * d)" Remove all LTC frames from the internal queue\&. .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .RE .PP .SS "int ltc_decoder_queue_length (\fBLTCDecoder\fP * d)" Count number of LTC frames currently in the queue\&. .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .RE .PP \fBReturns:\fP .RS 4 number of queued frames .RE .PP .SS "int ltc_decoder_read (\fBLTCDecoder\fP * d, \fBLTCFrameExt\fP * frame)" Decoded LTC frames are placed in a queue\&. This function retrieves a frame from the queue, and stores it at LTCFrameExt* .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .br \fIframe\fP the decoded LTC frame is copied there .RE .PP \fBReturns:\fP .RS 4 1 on success or 0 when no frames queued\&. .RE .PP .PP \fBExamples: \fP .in +1c \fBltcdecode\&.c\fP\&. .SS "void ltc_decoder_write (\fBLTCDecoder\fP * d, \fBltcsnd_sample_t\fP * buf, size_t size, \fBltc_off_t\fP posinfo)" Feed the LTC decoder with new audio samples\&. .PP Parse raw audio for LTC timestamps\&. Once a complete LTC frame has been decoded it is pushed into a queue (\fBltc_decoder_read\fP) .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .br \fIbuf\fP pointer to ltcsnd_sample_t - unsigned 8 bit mono audio data .br \fIsize\fP .RE .PP .PP \fBExamples: \fP .in +1c \fBltcdecode\&.c\fP\&. .SS "void ltc_decoder_write_float (\fBLTCDecoder\fP * d, float * buf, size_t size, \fBltc_off_t\fP posinfo)" Wrapper around \fBltc_decoder_write\fP that accepts floating point audio samples\&. Note: internally libltc uses 8 bit only\&. .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .br \fIbuf\fP pointer to audio sample data .br \fIsize\fP number of samples to parse .br \fIposinfo\fP (optional, recommended) sample-offset in the audio-stream\&. .RE .PP .SS "void ltc_decoder_write_s16 (\fBLTCDecoder\fP * d, short * buf, size_t size, \fBltc_off_t\fP posinfo)" Wrapper around \fBltc_decoder_write\fP that accepts signed 16 bit audio samples\&. Note: internally libltc uses 8 bit only\&. .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .br \fIbuf\fP pointer to audio sample data .br \fIsize\fP number of samples to parse .br \fIposinfo\fP (optional, recommended) sample-offset in the audio-stream\&. .RE .PP .SS "void ltc_decoder_write_u16 (\fBLTCDecoder\fP * d, unsigned short * buf, size_t size, \fBltc_off_t\fP posinfo)" Wrapper around \fBltc_decoder_write\fP that accepts unsigned 16 bit audio samples\&. Note: internally libltc uses 8 bit only\&. .PP \fBParameters:\fP .RS 4 \fId\fP decoder handle .br \fIbuf\fP pointer to audio sample data .br \fIsize\fP number of samples to parse .br \fIposinfo\fP (optional, recommended) sample-offset in the audio-stream\&. .RE .PP .SS "void ltc_encoder_buffer_flush (\fBLTCEncoder\fP * e)" reset the write-pointer of the encoder-buffer .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .RE .PP .SS "\fBLTCEncoder\fP* ltc_encoder_create (double sample_rate, double fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" Allocate and initialize LTC audio encoder\&. .PP calls \fBltc_encoder_reinit\fP internally see, see notes there\&. .PP \fBParameters:\fP .RS 4 \fIsample_rate\fP audio sample rate (eg\&. 48000) .br \fIfps\fP video-frames per second (e\&.g\&. 25\&.0) .br \fIstandard\fP the TV standard to use for Binary Group Flag bit position .br \fIflags\fP binary combination of \fBLTC_BG_FLAGS\fP .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, and \fBltcencode\&.c\fP\&. .SS "int ltc_encoder_dec_timecode (\fBLTCEncoder\fP * e)" Move the encoder to the previous timecode frame\&. This is useful for encoding reverse LTC\&. uses \fBltc_frame_decrement()\fP internally\&. .SS "int ltc_encoder_encode_byte (\fBLTCEncoder\fP * e, int byte, double speed)" Generate LTC audio for given byte of the LTC-frame and place it into the internal buffer\&. .PP see \fBltc_encoder_get_buffer\fP and \fBltc_encoder_get_bufptr\fP .PP 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\&. .PP The default output signal is @ \-3dBFS (38\&.\&.218 at 8 bit unsigned)\&. see also \fBltc_encoder_set_volume\fP .PP if speed is < 0, the bits are encoded in reverse\&. slowdown > 10\&.0 requires custom buffer sizes; see \fBltc_encoder_set_bufsize\fP .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIbyte\fP byte of the LTC-frame to encode 0\&.\&.9 .br \fIspeed\fP vari-speed, < 1\&.0 faster, > 1\&.0 slower ; must be != 0 .RE .PP \fBReturns:\fP .RS 4 0 on success, \-1 if byte is invalid or buffer overflow (speed > 10\&.0) .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP\&. .SS "void ltc_encoder_encode_frame (\fBLTCEncoder\fP * e)" Encode a full LTC frame at fixed speed\&. This is equivalent to calling \fBltc_encoder_encode_byte\fP 10 times for bytes 0\&.\&.9 with speed 1\&.0\&. .PP 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 \fBltc_encoder_get_buffer\fP after calling this function\&. .PP The default internal buffersize is exactly one full LTC frame at speed 1\&.0\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, and \fBltcencode\&.c\fP\&. .SS "void ltc_encoder_free (\fBLTCEncoder\fP * e)" Release memory of the encoder\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, and \fBltcencode\&.c\fP\&. .SS "int ltc_encoder_get_buffer (\fBLTCEncoder\fP * e, \fBltcsnd_sample_t\fP * buf)" Copy the accumulated encoded audio to the given sample-buffer and flush the internal buffer\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIbuf\fP place to store the audio-samples, needs to be large enough to hold \fBltc_encoder_get_buffersize\fP bytes .RE .PP \fBReturns:\fP .RS 4 the number of bytes written to the memory area pointed to by buf\&. .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP\&. .SS "size_t ltc_encoder_get_buffersize (\fBLTCEncoder\fP * 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 .PP Note this returns the total size of the buffer, not the used/free part\&. See also \fBltc_encoder_get_bufptr\fP .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .RE .PP \fBReturns:\fP .RS 4 size of the allocated internal buffer\&. .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP\&. .SS "\fBltcsnd_sample_t\fP* ltc_encoder_get_bufptr (\fBLTCEncoder\fP * e, int * size, int flush)" Retrieve a pointer to the accumulated encoded audio-data\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIsize\fP if set, the number of valid bytes in the buffer is stored there .br \fIflush\fP call \fBltc_encoder_buffer_flush\fP - reset the buffer write-pointer .RE .PP \fBReturns:\fP .RS 4 pointer to encoder-buffer .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, and \fBltcencode\&.c\fP\&. .SS "void ltc_encoder_get_frame (\fBLTCEncoder\fP * e, \fBLTCFrame\fP * f)" Low-level access to the encoder internal \fBLTCFrame\fP data .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIf\fP return LTC frame data .RE .PP .SS "void ltc_encoder_get_timecode (\fBLTCEncoder\fP * e, \fBSMPTETimecode\fP * t)" Query the current encoder timecode\&. .PP Note: the decoder stores its internal state in an LTC-frame, this function converts that LTC-Frame into \fBSMPTETimecode\fP on demand\&. see also \fBltc_encoder_get_frame\fP\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIt\fP is set to current timecode .RE .PP .SS "int ltc_encoder_inc_timecode (\fBLTCEncoder\fP * e)" Move the encoder to the next timecode frame\&. uses \fBltc_frame_increment()\fP internally\&. .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, and \fBltcencode\&.c\fP\&. .SS "int ltc_encoder_reinit (\fBLTCEncoder\fP * e, double sample_rate, double fps, enum \fBLTC_TV_STANDARD\fP 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\&. .PP This call will fail if the internal buffer is too small to hold one full LTC frame\&. Use \fBltc_encoder_set_bufsize\fP to prepare an internal buffer large enough to accommodate all sample_rate, fps combinations that you would like to re-init to\&. .PP 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 \fBLTCFrame\fP's 'dfbit' bit is set to 1 to indicate drop-frame timecode\&. .PP 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)\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIsample_rate\fP audio sample rate (eg\&. 48000) .br \fIfps\fP video-frames per second (e\&.g\&. 25\&.0) .br \fIstandard\fP the TV standard to use for Binary Group Flag bit position .br \fIflags\fP binary combination of \fBLTC_BG_FLAGS\fP .RE .PP .PP \fBExamples: \fP .in +1c \fBltcencode\&.c\fP\&. .SS "void ltc_encoder_reset (\fBLTCEncoder\fP * e)" reset ecoder state\&. flushes buffer, reset biphase state .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .RE .PP .SS "int ltc_encoder_set_bufsize (\fBLTCEncoder\fP * e, double sample_rate, double fps)" Configure a custom size for the internal buffer\&. .PP This is needed if you are planning to call \fBltc_encoder_reinit()\fP or if you want to keep more than one LTC frame's worth of data in the library's internal buffer\&. .PP The buffer-size is (1 + sample_rate / fps) bytes\&. resizing the internal buffer will flush all existing data in it - alike \fBltc_encoder_buffer_flush\fP\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIsample_rate\fP audio sample rate (eg\&. 48000) .br \fIfps\fP video-frames per second (e\&.g\&. 25\&.0) .RE .PP \fBReturns:\fP .RS 4 0 on success, \-1 if allocation fails (which makes the encoder unusable, call \fBltc_encoder_free\fP or realloc the buffer) .RE .PP .PP \fBExamples: \fP .in +1c \fBltcencode\&.c\fP\&. .SS "void ltc_encoder_set_filter (\fBLTCEncoder\fP * e, double rise_time)" Set encoder signal rise-time / signal filtering .PP 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\&. .PP If you want a perfect square wave, set 'rise_time' to 0\&. .PP Note \fBltc_encoder_reinit\fP resets the filter-time-constant to use the default 40us for the given sample-rate, overriding any value previously set with \fBltc_encoder_set_filter\fP .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIrise_time\fP the signal rise-time in us (10^(\-6) sec), set to 0 for perfect square wave, default 40\&.0 .RE .PP .PP \fBExamples: \fP .in +1c \fBltcencode\&.c\fP\&. .SS "void ltc_encoder_set_frame (\fBLTCEncoder\fP * e, \fBLTCFrame\fP * f)" Low-level access to the internal \fBLTCFrame\fP data\&. .PP Note: be careful to about f->dfbit, the encoder sets this [only] upon initialization\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIf\fP LTC frame data to use .RE .PP .SS "void ltc_encoder_set_timecode (\fBLTCEncoder\fP * e, \fBSMPTETimecode\fP * t)" Set the encoder LTC-frame to the given \fBSMPTETimecode\fP\&. The next call to \fBltc_encoder_encode_byte\fP or \fBltc_encoder_encode_frame\fP will encode this time to LTC audio-samples\&. .PP Internally this call uses \fBltc_time_to_frame\fP because the LTCEncoder operates on LTCframes only\&. see als \fBltc_encoder_set_frame\fP .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIt\fP timecode to set\&. .RE .PP .PP \fBExamples: \fP .in +1c \fBexample_encode\&.c\fP, and \fBltcencode\&.c\fP\&. .SS "void ltc_encoder_set_user_bits (\fBLTCEncoder\fP * e, unsigned long data)" Set the user-bits of the frame to the given data\&. .PP The data should be a 32-bits unsigned integer\&. It is written LSB first continiously int the eight user fields\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIdata\fP the data to write .RE .PP .SS "int ltc_encoder_set_volume (\fBLTCEncoder\fP * e, double dBFS)" Set the volume of the generated LTC signal .PP typically LTC is sent at 0dBu ; in EBU callibrated systems that corresponds to \-18dBFS\&. - by default libltc creates \-3dBFS .PP since libltc generated 8bit audio-data, the minimum dBFS is about \-42dB which corresponds to 1 bit\&. .PP 0dB corresponds to a signal range of 127 1\&.\&.255 with 128 at the center\&. .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .br \fIdBFS\fP the volume in dB full-scale (<= 0\&.0) .RE .PP \fBReturns:\fP .RS 4 0 on success, \-1 if the value was out of range .RE .PP .PP \fBExamples: \fP .in +1c \fBltcencode\&.c\fP\&. .SS "\fBltc_off_t\fP ltc_frame_alignment (double samples_per_frame, enum \fBLTC_TV_STANDARD\fP standard)" \fBLTCFrame\fP sample alignment offset\&. .PP 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\&. .PP For film frames or HDV the offset is zero\&. .PP \fBParameters:\fP .RS 4 \fIsamples_per_frame\fP audio-samples per timecode-frame (eg\&. 1920 = 48000/25) .br \fIstandard\fP the TV standard .RE .PP \fBReturns:\fP .RS 4 offset in samples .RE .PP .SS "int ltc_frame_decrement (\fBLTCFrame\fP * frame, int fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" Decrement the timecode by one Frame (1/framerate seconds) and set the Frame's parity bit accordingly (see \fBltc_frame_set_parity\fP) .PP \fBParameters:\fP .RS 4 \fIframe\fP the LTC-timecode to decrement .br \fIfps\fP integer framerate (for drop-frame-timecode set frame->dfbit and round-up the fps)\&. .br \fIstandard\fP the 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\&. .br \fIflags\fP binary combination of \fBLTC_BG_FLAGS\fP - 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 .RE .PP \fBReturns:\fP .RS 4 1 if timecode was wrapped around at 23:59:59:ff, 0 otherwise .RE .PP .SS "unsigned long ltc_frame_get_user_bits (\fBLTCFrame\fP * f)" Get a 32-bits unsigned integer from the user-data bits\&. The data should be written LSB first in the frame .PP \fBParameters:\fP .RS 4 \fIe\fP encoder handle .RE .PP .SS "int ltc_frame_increment (\fBLTCFrame\fP * frame, int fps, enum \fBLTC_TV_STANDARD\fP standard, int flags)" Increment the timecode by one Frame (1/framerate seconds) and set the Frame's parity bit accordingly (see \fBltc_frame_set_parity\fP) .PP \fBParameters:\fP .RS 4 \fIframe\fP the LTC-timecode to increment .br \fIfps\fP integer framerate (for drop-frame-timecode set frame->dfbit and round-up the fps)\&. .br \fIstandard\fP the 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\&. .br \fIflags\fP binary combination of \fBLTC_BG_FLAGS\fP - 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\&.) .RE .PP \fBReturns:\fP .RS 4 1 if timecode was wrapped around after 23:59:59:ff, 0 otherwise .RE .PP .SS "void ltc_frame_reset (\fBLTCFrame\fP * 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 \fBltc_frame_set_parity\fP) .PP \fBParameters:\fP .RS 4 \fIframe\fP the \fBLTCFrame\fP to reset .RE .PP .SS "void ltc_frame_set_parity (\fBLTCFrame\fP * frame, enum \fBLTC_TV_STANDARD\fP standard)" Set the parity of the LTC frame\&. .PP 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\&. .PP 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\&. .PP There is usually no need to call this function directly\&. The encoder utility functions \fBltc_time_to_frame\fP, \fBltc_frame_increment\fP and \fBltc_frame_decrement\fP include a call to it\&. .PP \fBParameters:\fP .RS 4 \fIframe\fP the LTC to analyze and set or clear the biphase_mark_phase_correction bit\&. .br \fIstandard\fP If 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\&. .RE .PP .SS "void ltc_frame_to_time (\fBSMPTETimecode\fP * stime, \fBLTCFrame\fP * frame, int flags)" Convert binary \fBLTCFrame\fP into \fBSMPTETimecode\fP struct .PP \fBParameters:\fP .RS 4 \fIstime\fP output .br \fIframe\fP input .br \fIflags\fP binary combination of \fBLTC_BG_FLAGS\fP - here only LTC_USE_DATE is relevant\&. if LTC_USE_DATE is set, the user-fields in \fBLTCFrame\fP will be parsed into the date variable of \fBSMPTETimecode\fP\&. otherwise the date information in the \fBSMPTETimecode\fP is set to zero\&. .RE .PP .PP \fBExamples: \fP .in +1c \fBltcdecode\&.c\fP\&. .SS "void ltc_time_to_frame (\fBLTCFrame\fP * frame, \fBSMPTETimecode\fP * stime, enum \fBLTC_TV_STANDARD\fP standard, int flags)" Translate \fBSMPTETimecode\fP struct into its binary LTC representation and set the LTC frame's parity bit accordingly (see \fBltc_frame_set_parity\fP) .PP \fBParameters:\fP .RS 4 \fIframe\fP output - the frame to be set .br \fIstime\fP input - timecode input .br \fIstandard\fP the TV standard to use for parity bit assignment .br \fIflags\fP binary combination of \fBLTC_BG_FLAGS\fP - here only LTC_USE_DATE and LTC_NO_PARITY are relevant\&. if LTC_USE_DATE is given, user-fields in \fBLTCFrame\fP will be set from the date in \fBSMPTETimecode\fP, otherwise the user-bits are not modified\&. All non-timecode fields remain untouched - except for the parity bit unless LTC_NO_PARITY is given\&. .RE .PP .SS "int parse_bcg_flags (\fBLTCFrame\fP * f, enum \fBLTC_TV_STANDARD\fP standard)" Parse Binary Group Flags into standard independent format: bit 0 (1) - BGF 0, bit 1 (2) - BGF 1, bit 2 (4) - BGF 2 .PP \fBParameters:\fP .RS 4 \fIf\fP LTC frame data analyze .br \fIstandard\fP the TV standard to use -- see \fBLTCFrame\fP for BGF assignment .RE .PP \fBReturns:\fP .RS 4 LTC Binary Group Flags .RE .PP .SH "Author" .PP Generated automatically by Doxygen for libltc from the source code\&.