---
name: "framerate.h"
section: "3"
platform: "linux"
package: "libltcsmpte-doc"
version: "0.4.4-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/framerate.h"
---

# framerate.h(3)

libltcsmpte - framerate conversion

## NAME

framerate.h -

libltcsmpte - framerate conversion

## SYNOPSIS

### Data Structures

struct **FrameRate**\
 *Frame rate data structure.*

### Enumerations

enum **FRFlags** { **FRF\_NONE** =  0, **FRF\_DROP\_FRAMES** =  1, **FRF\_UNUSED** =  2, **FRF\_SAMPLERATE** =  4, **FRF\_OFFA** =  8, **FRF\_OFFV** =  16, **FRF\_LAST** =  32 }\
 *Frame-Rate-Flags and options: multiple flags/options can be added (binary OR).*  enum **FRSMPTE** { **SMPTE\_FRAME** =  0, **SMPTE\_SEC**, **SMPTE\_MIN**, **SMPTE\_HOUR**, **SMPTE\_OVERFLOW**, **SMPTE\_LAST** }\

### Functions

int **FR\_toint** (**FrameRate** \*fr)\
 *round framerate to the nearest integer*  double **FR\_todbl** (**FrameRate** \*fr)\
 *return (double) floating point representation of framerate*  **FrameRate** \* **FR\_create** (int num, int den, int flags)\
 *allocate memory for* **FrameRate** *struct and initialize with given values.*  void **FR\_free** (**FrameRate** \*f)\
 *free memory allocated for* **FrameRate** *data structure*  void **FR\_setsamplerate** (**FrameRate** \*f, int samplerate)\
 *set audio sample rate (sps) for av,vf conversion*  long long int **FR\_vf2af** (**FrameRate** \*f, long int vf)\
 *convert integer video-frames to audio frame.*  long int **FR\_af2vfi** (**FrameRate** \*f, long long int af)\
 *convert audio-frame to integer video-frames round down to the prev.*  double **FR\_af2vf** (**FrameRate** \*f, long long int af)\
 *convert audio-frame to fractional video-frames*  long int **FR\_insert\_drop\_frames** (long int frames)\
 *private function - no need to call it when using the FR-API for smpte/bcd conversion*  long int **FR\_drop\_frames** (**FrameRate** \*fr, int f, int s, int m, int h)\
 *private function - no need to call it when using the FR-API for smpte/bcd conversion*  void **FR\_frame\_to\_bcd** (**FrameRate** \*f, long int \*bcd, long int frame)\
 *converts video-frame number into binary coded decimal timecode sets: bcd\[SMPTE\_FRAME\] .*  void **FR\_vf2smpte** (**FrameRate** \*fr, char \*smptestring, long int frame)\
 *converts video-frame into 13char SMPTE string.*  long int **FR\_smpte2vf** (**FrameRate** \*fr, int f, int s, int m, int h, int overflow)\
 *convert smpte into video-frame number expects smpte in decimal representation as separate arguments:*  long int **FR\_bcd2vf** (**FrameRate** \*fr, int bcd\[SMPTE\_LAST\])\
 *wrapper around FR\_smpte2vf reads SMPTE as bcd array argument and returns video frame number, starting at zero*  void **FR\_setflags** (**FrameRate** \*fr, int flags)\
 *directly change framerate flags*  void **FR\_setratio** (**FrameRate** \*fr, int num, int den)\
 *set the framerate*  void **FR\_setdbl** (**FrameRate** \*fr, double fps, int mode)\
 *convert double value into ratio and set framerate.*

## Detailed Description

libltcsmpte - framerate conversion

**Author:**

Robin Gareus \<robin@gareus.org\>

Copyright (C) 2006, 2007, 2008 Robin Gareus \<robin@gareus.org\>

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.

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.

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

Definition in file **framerate.h**.

## Enumeration Type Documentation

### enum FRFlags

Frame-Rate-Flags and options: multiple flags/options can be added (binary OR).

**Enumerator:**

- *FRF\_NONE*

  - *FRF\_DROP\_FRAMES*

  *use drop frame timecode*

- *FRF\_UNUSED*

  - *FRF\_SAMPLERATE*

  *has sample-rate info*

- *FRF\_OFFA*

  *has audio frame offset*

- *FRF\_OFFV*

  *has video frame offset*

- *FRF\_LAST*

  *Definition at line 31 of file framerate.h.*

### enum FRSMPTE

**Enumerator:**

- *SMPTE\_FRAME*

  - *SMPTE\_SEC*

  - *SMPTE\_MIN*

  - *SMPTE\_HOUR*

  - *SMPTE\_OVERFLOW*

  - *SMPTE\_LAST*

  *Definition at line 42 of file framerate.h.*

## Function Documentation

### double FR\_af2vf (FrameRate \* f, long long int af)

*convert audio-frame to fractional video-frames*

### long int FR\_af2vfi (FrameRate \* f, long long int af)

*convert audio-frame to integer video-frames round down to the prev. video frame.*

### long int FR\_bcd2vf (FrameRate \* fr, int bcd\[SMPTE\_LAST\])

*wrapper around FR\_smpte2vf reads SMPTE as bcd array argument and returns video frame number, starting at zero*

### FrameRate\* FR\_create (int num, int den, int flags)

*allocate memory for* **FrameRate** *struct and initialize with given values.*

**Examples:**  **tests/decoder.c***, and* **tests/encoder.c***.*

### long int FR\_drop\_frames (FrameRate \* fr, int f, int s, int m, int h)

*private function - no need to call it when using the FR-API for smpte/bcd conversion Drop frame numbers (not frames) 00:00 and 00:01 at the start of every minute except the tenth. returns video frame number staring at zero for 29.97fps*

*dropframes are not required or permitted when operating at 24, 25, or 30 frames per second.*

### void FR\_frame\_to\_bcd (FrameRate \* f, long int \* bcd, long int frame)

*converts video-frame number into binary coded decimal timecode sets: bcd\[SMPTE\_FRAME\] . . bcd\[SMPTE\_LAST\] accoding to video-frame. Note: this supports only integer framerates! use FR\_vf2smpte instead.*

### void FR\_free (FrameRate \* f)

*free memory allocated for* **FrameRate** *data structure*

**Examples:**  **tests/decoder.c***, and* **tests/encoder.c***.*

### long int FR\_insert\_drop\_frames (long int frames)

*private function - no need to call it when using the FR-API for smpte/bcd conversion Insert two frame numbers at the start of every minute except the tenth. unit: video-frames!*

### void FR\_setdbl (FrameRate \* fr, double fps, int mode)

*convert double value into ratio and set framerate. if mode == 1: autodetect drop-frame timecode (set flag\|=FRF\_DROP\_FRAMES if fps==29.97 )*

**Examples:**  **tests/decoder.c***, and* **tests/encoder.c***.*

### void FR\_setflags (FrameRate \* fr, int flags)

*directly change framerate flags*

### void FR\_setratio (FrameRate \* fr, int num, int den)

*set the framerate*

### void FR\_setsamplerate (FrameRate \* f, int samplerate)

*set audio sample rate (sps) for av,vf conversion*

### long int FR\_smpte2vf (FrameRate \* fr, int f, int s, int m, int h, int overflow)

*convert smpte into video-frame number expects smpte in decimal representation as separate arguments: f: frame, s: second, m: minute, h: hour overflow should be set to zero (days); returns: video frame number, starting at zero*

### double FR\_todbl (FrameRate \* fr)

*return (double) floating point representation of framerate*

### int FR\_toint (FrameRate \* fr)

*round framerate to the nearest integer*

### long long int FR\_vf2af (FrameRate \* f, long int vf)

*convert integer video-frames to audio frame.*

### void FR\_vf2smpte (FrameRate \* fr, char \* smptestring, long int frame)

*converts video-frame into 13char SMPTE string. smptestring needs to point to a allocated (char\*) memory!*

*it does handle drop-frame formats correctly.*

## Author

*Generated automatically by Doxygen for libltcsmpte from the source code.*
