.TH "ltcsmpte.h" 3 "Fri Apr 27 2012" "Version 0.4.4" "libltcsmpte" \" -*- nroff -*- .ad l .nh .SH NAME ltcsmpte.h \- .PP libltcsmpte - en+decode linear SMPTE timecode .SH SYNOPSIS .br .PP \fC#include \fP .br \fC#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBSMPTEFrame\fP" .br .RI "\fIRaw 80 bit SMPTE frame. \fP" .ti -1c .RI "struct \fBSMPTETime\fP" .br .RI "\fIHuman readable time representation. \fP" .ti -1c .RI "struct \fBSMPTEFrameExt\fP" .br .RI "\fIExtended SMPTE frame The maximum error for startpos is 1/80 of a frame. \fP" .in -1c .SS "Defines" .in +1c .ti -1c .RI "#define \fBFPRNT_TIME\fP '%lf'" .br .ti -1c .RI "#define \fBTIME_DELIM\fP '\\t'" .br .ti -1c .RI "#define \fBWRITE_DECODER_BIPHASE_DIAGNOSTICS\fP(A, B, C, D, E)" .br .ti -1c .RI "#define \fBWRITE_DECODER_BITS_DIAGNOSTICS\fP(A, B, C, D, E)" .br .ti -1c .RI "#define \fBUSE8BIT\fP" .br .ti -1c .RI "#define \fBSAMPLE_AND_CURVE_ARE_DIFFERENT_TYPE\fP" .br .ti -1c .RI "#define \fBSAMPLE_CENTER\fP 128" .br .ti -1c .RI "#define \fBCURVE_MIN\fP -127" .br .ti -1c .RI "#define \fBCURVE_MAX\fP 127" .br .ti -1c .RI "#define \fBSAMPLE_IS_UNSIGNED\fP" .br .ti -1c .RI "#define \fBSAMPLE_IS_INTEGER\fP" .br .ti -1c .RI "#define \fBLTC_FRAME_BIT_COUNT\fP 80" .br .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef double \fBtimeu\fP" .br .ti -1c .RI "typedef unsigned char \fBsample_t\fP" .br .ti -1c .RI "typedef short \fBcurve_sample_t\fP" .br .ti -1c .RI "typedef int \fBdiagnostics_t\fP" .br .ti -1c .RI "typedef struct \fBSMPTEFrame\fP \fBSMPTEFrame\fP" .br .RI "\fIRaw 80 bit SMPTE frame. \fP" .ti -1c .RI "typedef struct \fBSMPTETime\fP \fBSMPTETime\fP" .br .RI "\fIHuman readable time representation. \fP" .ti -1c .RI "typedef struct \fBSMPTEFrameExt\fP \fBSMPTEFrameExt\fP" .br .RI "\fIExtended SMPTE frame The maximum error for startpos is 1/80 of a frame. \fP" .ti -1c .RI "typedef struct \fBSMPTEDecoder\fP \fBSMPTEDecoder\fP" .br .RI "\fIopaque structure. \fP" .ti -1c .RI "typedef struct \fBSMPTEEncoder\fP \fBSMPTEEncoder\fP" .br .RI "\fIopaque structure see: SMPTEEncoderCreate, SMPTEFreeEncoder \fP" .in -1c .SS "Functions" .in +1c .ti -1c .RI "int \fBSMPTEFrameToTime\fP (\fBSMPTEFrame\fP *frame, \fBSMPTETime\fP *stime)" .br .RI "\fIconvert binary \fBSMPTEFrame\fP into \fBSMPTETime\fP struct \fP" .ti -1c .RI "int \fBSMPTETimeToFrame\fP (\fBSMPTETime\fP *stime, \fBSMPTEFrame\fP *frame)" .br .RI "\fIconvert \fBSMPTETime\fP struct into it's binary SMPTE representation. \fP" .ti -1c .RI "int \fBSMPTEFrameReset\fP (\fBSMPTEFrame\fP *frame)" .br .RI "\fIset all values of a SMPTE FRAME to zero except for the sync-word (0x3FFD) at the end. \fP" .ti -1c .RI "int \fBSMPTEFrameIncrease\fP (\fBSMPTEFrame\fP *frame, int framesPerSec)" .br .RI "\fIincrements the SMPTE by one SMPTE-Frame (1/framerate seconds) \fP" .ti -1c .RI "\fBSMPTEDecoder\fP * \fBSMPTEDecoderCreate\fP (int sampleRate, \fBFrameRate\fP *fps, int queueSize, int correctJitter)" .br .RI "\fICreate a new decoder. \fP" .ti -1c .RI "int \fBSMPTEFreeDecoder\fP (\fBSMPTEDecoder\fP *d)" .br .RI "\fIrelease memory of Decoder structure. \fP" .ti -1c .RI "int \fBSMPTEDecoderErrorReset\fP (\fBSMPTEDecoder\fP *decoder)" .br .RI "\fIReset the decoder error tracking internals. \fP" .ti -1c .RI "int \fBSMPTEDecoderWrite\fP (\fBSMPTEDecoder\fP *decoder, \fBsample_t\fP *buf, int size, long int posinfo)" .br .RI "\fIFeed the SMPTE decoder with new samples. \fP" .ti -1c .RI "int \fBSMPTEDecoderRead\fP (\fBSMPTEDecoder\fP *decoder, \fBSMPTEFrameExt\fP *frame)" .br .RI "\fIAll decoded SMPTE frames are placed in a queue. \fP" .ti -1c .RI "int \fBSMPTEDecoderReadLast\fP (\fBSMPTEDecoder\fP *decoder, \fBSMPTEFrameExt\fP *frame)" .br .RI "\fIflush unread LTCs in queue and return the last timestamp. \fP" .ti -1c .RI "int \fBSMPTEDecoderFrameToMillisecs\fP (\fBSMPTEDecoder\fP *decoder, \fBSMPTEFrameExt\fP *frame, int *timems)" .br .RI "\fIConvert the frame to time in milliseconds. \fP" .ti -1c .RI "\fBtimeu\fP \fBSMPTEDecoderSamplesToSeconds\fP (\fBSMPTEDecoder\fP *d, long int sampleCount)" .br .RI "\fIConvert the index or position of a sample to its position in time (seconds) relative to the first sample. \fP" .ti -1c .RI "int \fBSMPTEDecoderErrors\fP (\fBSMPTEDecoder\fP *decoder, int *errors)" .br .RI "\fIget accumulated error count since last reset. \fP" .ti -1c .RI "\fBSMPTEEncoder\fP * \fBSMPTEEncoderCreate\fP (int sampleRate, \fBFrameRate\fP *fps)" .br .RI "\fIAllocate and initialize LTC encoder sampleRate: audio sample rate (eg. \fP" .ti -1c .RI "int \fBSMPTEFreeEncoder\fP (\fBSMPTEEncoder\fP *e)" .br .RI "\fIrelease encoder data structure \fP" .ti -1c .RI "int \fBSMPTESetNsamples\fP (\fBSMPTEEncoder\fP *e, int val)" .br .RI "\fIset internal Audio-sample counter. \fP" .ti -1c .RI "int \fBSMPTEGetNsamples\fP (\fBSMPTEEncoder\fP *e)" .br .RI "\fIreturns the current values of the Audio-sample counter. \fP" .ti -1c .RI "int \fBSMPTEEncIncrease\fP (\fBSMPTEEncoder\fP *e)" .br .RI "\fImoves the SMPTE to the next frame. \fP" .ti -1c .RI "int \fBSMPTESetTime\fP (\fBSMPTEEncoder\fP *e, \fBSMPTETime\fP *t)" .br .RI "\fIsets the current encoder SMPTE frame to \fBSMPTETime\fP. \fP" .ti -1c .RI "int \fBSMPTEGetTime\fP (\fBSMPTEEncoder\fP *e, \fBSMPTETime\fP *t)" .br .RI "\fIset t from current Encoder timecode \fP" .ti -1c .RI "long int \fBSMPTEGetVideoFrameNumber\fP (\fBSMPTEEncoder\fP *e)" .br .RI "\fIreturns the current value of the encoder's SMPTE frame converted to video-frames \fP" .ti -1c .RI "int \fBSMPTEGetTimeInMillisecs\fP (\fBSMPTEEncoder\fP *e)" .br .RI "\fIreturns the current value of the encoder's SMPTE frame converted to ms \fP" .ti -1c .RI "int \fBSMPTEGetBuffer\fP (\fBSMPTEEncoder\fP *e, \fBsample_t\fP *buf)" .br .RI "\fIreturns and flushes the accumulated Encoded Audio. \fP" .ti -1c .RI "size_t \fBSMPTEGetBuffersize\fP (\fBSMPTEEncoder\fP *e)" .br .RI "\fIreturns the size of the accumulated encoded Audio in bytes. \fP" .ti -1c .RI "int \fBSMPTEEncode\fP (\fBSMPTEEncoder\fP *e, int byteCnt)" .br .RI "\fIGenerate LTC audio for byte 'byteCnt' of the current frame into the buffer of Encoder e. \fP" .in -1c .SH "Detailed Description" .PP libltcsmpte - en+decode linear SMPTE timecode \fBAuthor:\fP .RS 4 Robin Gareus .RE .PP Copyright (C) 2006 Robin Gareus Copyright (C) 2008-2009 Jan .PP inspired by SMPTE Decoder - Maarten de Boer .PP This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 3, 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 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA .PP Definition in file \fBltcsmpte.h\fP. .SH "Define Documentation" .PP .SS "#define CURVE_MAX 127" .PP Definition at line 90 of file ltcsmpte.h. .SS "#define CURVE_MIN -127" .PP Definition at line 89 of file ltcsmpte.h. .SS "#define FPRNT_TIME '%lf'" .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .PP Definition at line 51 of file ltcsmpte.h. .SS "#define LTC_FRAME_BIT_COUNT 80" .PP Definition at line 98 of file ltcsmpte.h. .SS "#define SAMPLE_AND_CURVE_ARE_DIFFERENT_TYPE" .PP Definition at line 87 of file ltcsmpte.h. .SS "#define SAMPLE_CENTER 128" .PP Definition at line 88 of file ltcsmpte.h. .SS "#define SAMPLE_IS_INTEGER" .PP Definition at line 92 of file ltcsmpte.h. .SS "#define SAMPLE_IS_UNSIGNED" .PP Definition at line 91 of file ltcsmpte.h. .SS "#define TIME_DELIM '\\t'" .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .PP Definition at line 52 of file ltcsmpte.h. .SS "#define USE8BIT" .PP Definition at line 84 of file ltcsmpte.h. .SS "#define WRITE_DECODER_BIPHASE_DIAGNOSTICS(A, B, C, D, E)" .PP Definition at line 58 of file ltcsmpte.h. .SS "#define WRITE_DECODER_BITS_DIAGNOSTICS(A, B, C, D, E)" .PP Definition at line 59 of file ltcsmpte.h. .SH "Typedef Documentation" .PP .SS "typedef short \fBcurve_sample_t\fP" .PP Definition at line 86 of file ltcsmpte.h. .SS "typedef int \fBdiagnostics_t\fP" .PP Definition at line 93 of file ltcsmpte.h. .SS "typedef unsigned char \fBsample_t\fP" .PP Definition at line 85 of file ltcsmpte.h. .SS "typedef struct \fBSMPTEDecoder\fP \fBSMPTEDecoder\fP" .PP opaque structure. see: SMPTEDecoderCreate, SMPTEFreeDecoder .PP Definition at line 211 of file ltcsmpte.h. .SS "typedef struct \fBSMPTEEncoder\fP \fBSMPTEEncoder\fP" .PP opaque structure see: SMPTEEncoderCreate, SMPTEFreeEncoder .PP Definition at line 217 of file ltcsmpte.h. .SS "typedef struct \fBSMPTEFrame\fP \fBSMPTEFrame\fP" .PP Raw 80 bit SMPTE frame. .SS "typedef struct \fBSMPTEFrameExt\fP \fBSMPTEFrameExt\fP" .PP Extended SMPTE frame The maximum error for startpos is 1/80 of a frame. Usually it is 0; .SS "typedef struct \fBSMPTETime\fP \fBSMPTETime\fP" .PP Human readable time representation. .SS "typedef double \fBtimeu\fP" .PP Definition at line 50 of file ltcsmpte.h. .SH "Function Documentation" .PP .SS "\fBSMPTEDecoder\fP* SMPTEDecoderCreate (int sampleRate, \fBFrameRate\fP * fps, int queueSize, int correctJitter)" .PP Create a new decoder. Pass sample rate, number of smpte frames per seconds, and the size of the internal queue where decoded frames are stored. Set correctJitter flag, to correct jitter resulting from audio fragment size when decoding from a realtime audiostream. This works only correctly when buffers of exactly fragment size are passed to SMPTEDecoderWrite. (as discussed on LAD [msgID]) .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEDecoderErrorReset (\fBSMPTEDecoder\fP * decoder)" .PP Reset the decoder error tracking internals. .SS "int SMPTEDecoderErrors (\fBSMPTEDecoder\fP * decoder, int * errors)" .PP get accumulated error count since last reset. .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEDecoderFrameToMillisecs (\fBSMPTEDecoder\fP * decoder, \fBSMPTEFrameExt\fP * frame, int * timems)" .PP Convert the frame to time in milliseconds. This uses the position of the end of the frame related to the sample-time to compensate for jitter. .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEDecoderRead (\fBSMPTEDecoder\fP * decoder, \fBSMPTEFrameExt\fP * frame)" .PP All decoded SMPTE frames are placed in a queue. This function gets a frame from the queue, and stores it in SMPTEFrameExt* frame. Returns 1 on success, 0 when no frames where on the queue, and and errorcode otherwise. .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEDecoderReadLast (\fBSMPTEDecoder\fP * decoder, \fBSMPTEFrameExt\fP * frame)" .PP flush unread LTCs in queue and return the last timestamp. (note that the last timestamp may not be the latest if the queue has overflown!) .SS "\fBtimeu\fP SMPTEDecoderSamplesToSeconds (\fBSMPTEDecoder\fP * d, long int sampleCount)" .PP Convert the index or position of a sample to its position in time (seconds) relative to the first sample. .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEDecoderWrite (\fBSMPTEDecoder\fP * decoder, \fBsample_t\fP * buf, int size, long int posinfo)" .PP Feed the SMPTE decoder with new samples. parse raw audio for LTC timestamps. If found, store them in the Decoder queue (see SMPTEDecoderRead) always returns 1 ;-) d: the decoder buf: pointer to sample_t (defaults to unsigned 8 bit) mono audio data size: number of bytes to parse posinfo: (optional) byte offset in stream to set LTC location offset .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEEncIncrease (\fBSMPTEEncoder\fP * e)" .PP moves the SMPTE to the next frame. it uses \fBSMPTEFrameIncrease()\fP. .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTEEncode (\fBSMPTEEncoder\fP * e, int byteCnt)" .PP Generate LTC audio for byte 'byteCnt' of the current frame into the buffer of Encoder e. 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 \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "\fBSMPTEEncoder\fP* SMPTEEncoderCreate (int sampleRate, \fBFrameRate\fP * fps)" .PP Allocate and initialize LTC encoder sampleRate: audio sample rate (eg. 48000) fps: framerate .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTEFrameIncrease (\fBSMPTEFrame\fP * frame, int framesPerSec)" .PP increments the SMPTE by one SMPTE-Frame (1/framerate seconds) .SS "int SMPTEFrameReset (\fBSMPTEFrame\fP * frame)" .PP set all values of a SMPTE FRAME to zero except for the sync-word (0x3FFD) at the end. This will also clear the dfbit. .SS "int SMPTEFrameToTime (\fBSMPTEFrame\fP * frame, \fBSMPTETime\fP * stime)" .PP convert binary \fBSMPTEFrame\fP into \fBSMPTETime\fP struct .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEFreeDecoder (\fBSMPTEDecoder\fP * d)" .PP release memory of Decoder structure. .PP \fBExamples: \fP .in +1c \fBtests/decoder.c\fP. .SS "int SMPTEFreeEncoder (\fBSMPTEEncoder\fP * e)" .PP release encoder data structure .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTEGetBuffer (\fBSMPTEEncoder\fP * e, \fBsample_t\fP * buf)" .PP returns and flushes the accumulated Encoded Audio. returns the number of bytes written to the memory area pointed to by buf. .PP no overflow check is perfomed! use DTMFGetBuffersize(). .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "size_t SMPTEGetBuffersize (\fBSMPTEEncoder\fP * e)" .PP returns the size of the accumulated encoded Audio in bytes. .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTEGetNsamples (\fBSMPTEEncoder\fP * e)" .PP returns the current values of the Audio-sample counter. ie. the number of encoded samples. .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTEGetTime (\fBSMPTEEncoder\fP * e, \fBSMPTETime\fP * t)" .PP set t from current Encoder timecode .SS "int SMPTEGetTimeInMillisecs (\fBSMPTEEncoder\fP * e)" .PP returns the current value of the encoder's SMPTE frame converted to ms .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "long int SMPTEGetVideoFrameNumber (\fBSMPTEEncoder\fP * e)" .PP returns the current value of the encoder's SMPTE frame converted to video-frames .SS "int SMPTESetNsamples (\fBSMPTEEncoder\fP * e, int val)" .PP set internal Audio-sample counter. \fBSMPTEEncode()\fP increments this counter when it encodes samples. .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTESetTime (\fBSMPTEEncoder\fP * e, \fBSMPTETime\fP * t)" .PP sets the current encoder SMPTE frame to \fBSMPTETime\fP. .PP \fBExamples: \fP .in +1c \fBtests/encoder.c\fP. .SS "int SMPTETimeToFrame (\fBSMPTETime\fP * stime, \fBSMPTEFrame\fP * frame)" .PP convert \fBSMPTETime\fP struct into it's binary SMPTE representation. .SH "Author" .PP Generated automatically by Doxygen for libltcsmpte from the source code.