libklvanc
Classes | Macros | Functions
vanc-lines.h File Reference

Routines for managing VANC lines containing one or more VANC packets. More...

#include <stdint.h>
#include <sys/types.h>
#include <sys/errno.h>

Go to the source code of this file.

Classes

struct  klvanc_entry_s
 
struct  klvanc_line_s
 Represents a VANC line prior to serialization. More...
 
struct  klvanc_line_set_s
 Represents a group of VANC lines (e.g. perhaps corresponding to a video frame) More...
 

Macros

#define KLVANC_MAX_VANC_LINES   64
 
#define KLVANC_MAX_VANC_ENTRIES   16
 

Functions

struct klvanc_line_sklvanc_line_create (int line_number)
 Create a VANC line. More...
 
void klvanc_line_free (struct klvanc_line_s *line)
 Free a previously created klvanc_line_s structure. More...
 
int klvanc_line_insert (struct klvanc_context_s *ctx, struct klvanc_line_set_s *vanc_lines, uint16_t *pixels, int pixel_width, int line_number, int horizontal_offset)
 Insert a VANC packet into a VANC frame. More...
 
int klvanc_generate_vanc_line (struct klvanc_context_s *ctx, struct klvanc_line_s *line, uint16_t **out_buf, int *out_len, int line_pixel_width)
 Generate pixel array representing a fully formed VANC line. This function will take in a klvanc_line_s, format the VANC entries to ensure there are no gaps or overlapping packets, and create a final pixel array which can be colorspace converted and output over SDI. More...
 
int klvanc_generate_vanc_line_v210 (struct klvanc_context_s *ctx, struct klvanc_line_s *line, uint8_t *out_buf, int line_pixel_width)
 Generate byte array representing a fully formed VANC line. This function will take in a klvanc_line_s, format the VANC entries to ensure there are no gaps or overlapping packets, and create a final byte array which can be directly output over SDI in packed v210 format. More...
 

Detailed Description

Routines for managing VANC lines containing one or more VANC packets.

Author
Devin Heitmueller dheit.nosp@m.muel.nosp@m.ler@k.nosp@m.erne.nosp@m.llabs.nosp@m..com

Function Documentation

int klvanc_generate_vanc_line ( struct klvanc_context_s ctx,
struct klvanc_line_s line,
uint16_t **  out_buf,
int *  out_len,
int  line_pixel_width 
)

Generate pixel array representing a fully formed VANC line. This function will take in a klvanc_line_s, format the VANC entries to ensure there are no gaps or overlapping packets, and create a final pixel array which can be colorspace converted and output over SDI.

Parameters
[in]structklvanc_context_s *ctx - Context.
[in]structklvanc_line_s *line - the VANC line to operate on
[out]uint16_t**out_buf - a pointer to the buffer the function will output into. The memory for the buffer will be allocated by the function, and the caller will need to call free() to deallocate the resulting buffer. For 10-bit video, the array will contain 10-bit samples in 16-bit values. Bit packing or Colorspace conversion to other formats (such as V210) is the responsibility of the caller.
[out]int*out_len - the size of the resulting out_buf buffer. This parameter allows the caller to know how large out_buf is to avoid buffer overflows. This value may be shorter than the pixel width of the overall line. Measured in number of 16-bit samples (i.e. not bytes).
[in]intline_pixel_width - Size of the line the VANC will ultimately be inserted into, measured in number of samples. The function will not create an out_buf buffer which is larger than this value, nor will it insert VANC packets which exceed the line width specified.
Returns
0 - Success
-ENOMEM - insufficient memory to store the VANC packet
int klvanc_generate_vanc_line_v210 ( struct klvanc_context_s ctx,
struct klvanc_line_s line,
uint8_t *  out_buf,
int  line_pixel_width 
)

Generate byte array representing a fully formed VANC line. This function will take in a klvanc_line_s, format the VANC entries to ensure there are no gaps or overlapping packets, and create a final byte array which can be directly output over SDI in packed v210 format.

Parameters
[in]structklvanc_context_s *ctx - Context.
[in]structklvanc_line_s *line - the VANC line to operate on
[out]uint8_t*out_buf - a pointer to the buffer the function will output into. The memory for the output buffer should be allocated by the caller (or in the case of working with Blackmagic cards, pass the buffer returned from vanc->GetBufferForVerticalBlankingLine(). Note that this function will determine whether to do HD interleaving (inserting into the Y region only) or SD interleaving (using both Y and UV regions) based on the value provided via the line_pixel_width argument.
[in]intline_pixel_width - Size of the output buffer, measured in number of samples. When working with Blackmagic cards, this value will typically be the line width (e.g. 1920 for 1080i video), but there are special exceptions for certain 4K cards so review the Blackmagic SDK documentation for details. This function will it insert VANC packets which exceed the line width specified.
Returns
0 - Success
-ENOMEM - insufficient memory to store the VANC packet
struct klvanc_line_s* klvanc_line_create ( int  line_number)

Create a VANC line.

Parameters
[in]intline_number - line number corresponding to where the line placed within the field
Returns
struct klvanc_line_s containing the line or NULL on error
void klvanc_line_free ( struct klvanc_line_s line)

Free a previously created klvanc_line_s structure.

Parameters
[in]structklvanc_line_s *line - pointer to the line to be deleted. This will also deallocate any VANC packets previously inserted into the line
int klvanc_line_insert ( struct klvanc_context_s ctx,
struct klvanc_line_set_s vanc_lines,
uint16_t *  pixels,
int  pixel_width,
int  line_number,
int  horizontal_offset 
)

Insert a VANC packet into a VANC frame.

Parameters
[in]structklvanc_line_set_s *klvanc_lines - pointer to set of VANC lines to insert into
[in]uint16_t*pixels - Pointer to array of pixels to insert. For 10-bit pixels, these should be 10-bit values inserted into 16-bit padded fields.
[in]intpixel_width - width of [pixels] argument, measured in number of samples
[in]intline_number - line number this VANC packet should appear on in the resulting VANC frame
[in]inthorizontal_offset - offset into active video area the packet should ideally be inserted, measured in pixels
Returns
0 - Success
-ENOMEM - insufficient memory to store the VANC packet