FFmpeg
Data Structures | Macros | Enumerations | Functions
smpte_436m.h File Reference
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  AVSmpte436mAncIterator
 Iterator over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. More...
 
struct  AVSmpte291mAnc8bit
 An ANC packet with an 8-bit payload. More...
 
struct  AVSmpte436mCodedAnc
 An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. More...
 

Macros

#define AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY   0xFF
 the payload capacity of AVSmpte291mAnc8bit (and of AVSmpte291mAnc10bit when that gets added) More...
 
#define AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY   (AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY + 4) /* 4 for did, sdid_or_dbn, data_count, and checksum */
 max number of samples that can be stored in the payload of AVSmpte436mCodedAnc More...
 
#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY   (((AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY + 2) / 3) * 4)
 max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc More...
 
#define AV_SMPTE_291M_ANC_DID_CTA_708   0x61
 AVSmpte291mAnc8bit::did when carrying CTA-708 data (for AV_CODEC_ID_EIA_608) More...
 
#define AV_SMPTE_291M_ANC_SDID_CTA_708   0x1
 AVSmpte291mAnc8bit::sdid_or_dbn when carrying CTA-708 data (for AV_CODEC_ID_EIA_608) More...
 

Enumerations

enum  AVSmpte436mWrappingType {
  AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME = 1, AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_1 = 2, AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2 = 3, AV_SMPTE_436M_WRAPPING_TYPE_VANC_PROGRESSIVE_FRAME = 4,
  AV_SMPTE_436M_WRAPPING_TYPE_HANC_FRAME = 0x11, AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_1 = 0x12, AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_2 = 0x13, AV_SMPTE_436M_WRAPPING_TYPE_HANC_PROGRESSIVE_FRAME = 0x14,
  AV_SMPTE_436M_WRAPPING_TYPE_MAX = 0xFF
}
 Wrapping Type from Table 7 (page 13) of: https://pub.smpte.org/latest/st436/s436m-2006.pdf. More...
 
enum  AVSmpte436mPayloadSampleCoding {
  AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA = 1, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_COLOR_DIFF = 2, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA_AND_COLOR_DIFF = 3, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA = 4,
  AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF = 5, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF = 6, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA = 7, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_COLOR_DIFF = 8,
  AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA_AND_COLOR_DIFF = 9, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_WITH_PARITY_ERROR = 10, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF_WITH_PARITY_ERROR = 11, AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF_WITH_PARITY_ERROR = 12,
  AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_MAX = 0xFF
}
 Payload Sample Coding from Table 4 (page 10) and Table 7 (page 13) of: https://pub.smpte.org/latest/st436/s436m-2006.pdf. More...
 

Functions

int av_smpte_436m_coded_anc_validate (const AVSmpte436mCodedAnc *anc)
 Validate a AVSmpte436mCodedAnc structure. More...
 
int av_smpte_436m_anc_encode (uint8_t *out, int size, int anc_packet_count, const AVSmpte436mCodedAnc *anc_packets)
 Encode ANC packets into a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. More...
 
int av_smpte_436m_anc_append (struct AVPacket *pkt, int anc_packet_count, const AVSmpte436mCodedAnc *anc_packets)
 Append more ANC packets to a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. More...
 
int av_smpte_436m_anc_iter_init (AVSmpte436mAncIterator *iter, const uint8_t *buf, int buf_size)
 Set up iteration over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. More...
 
int av_smpte_436m_anc_iter_next (AVSmpte436mAncIterator *iter, AVSmpte436mCodedAnc *anc)
 Get the next ANC packet from the iterator, advancing the iterator. More...
 
int av_smpte_436m_coded_anc_payload_size (AVSmpte436mPayloadSampleCoding sample_coding, uint16_t sample_count)
 Get the minimum number of bytes needed to store a AVSmpte436mCodedAnc payload. More...
 
int av_smpte_291m_anc_8bit_decode (AVSmpte291mAnc8bit *out, AVSmpte436mPayloadSampleCoding sample_coding, uint16_t sample_count, const uint8_t *payload, void *log_ctx)
 Decode a AVSmpte436mCodedAnc payload into AVSmpte291mAnc8bit. More...
 
void av_smpte_291m_anc_8bit_fill_checksum (AVSmpte291mAnc8bit *anc)
 Fill in the correct checksum for a AVSmpte291mAnc8bit. More...
 
int av_smpte_291m_anc_8bit_get_sample_count (const AVSmpte291mAnc8bit *anc, AVSmpte436mPayloadSampleCoding sample_coding, void *log_ctx)
 Compute the sample count needed to encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc payload. More...
 
int av_smpte_291m_anc_8bit_encode (AVSmpte436mCodedAnc *out, uint16_t line_number, AVSmpte436mWrappingType wrapping_type, AVSmpte436mPayloadSampleCoding sample_coding, const AVSmpte291mAnc8bit *payload, void *log_ctx)
 Encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc. More...
 
int av_smpte_291m_anc_8bit_extract_cta_708 (const AVSmpte291mAnc8bit *anc, uint8_t *cc_data, void *log_ctx)
 Try to decode an ANC packet into EIA-608/CTA-708 data (AV_CODEC_ID_EIA_608). More...
 

Macro Definition Documentation

◆ AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY

#define AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY   0xFF

the payload capacity of AVSmpte291mAnc8bit (and of AVSmpte291mAnc10bit when that gets added)

Definition at line 89 of file smpte_436m.h.

◆ AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY

#define AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY   (AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY + 4) /* 4 for did, sdid_or_dbn, data_count, and checksum */

max number of samples that can be stored in the payload of AVSmpte436mCodedAnc

Definition at line 107 of file smpte_436m.h.

◆ AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY

#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY   (((AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY + 2) / 3) * 4)

max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc

Definition at line 110 of file smpte_436m.h.

◆ AV_SMPTE_291M_ANC_DID_CTA_708

#define AV_SMPTE_291M_ANC_DID_CTA_708   0x61

AVSmpte291mAnc8bit::did when carrying CTA-708 data (for AV_CODEC_ID_EIA_608)

Definition at line 237 of file smpte_436m.h.

◆ AV_SMPTE_291M_ANC_SDID_CTA_708

#define AV_SMPTE_291M_ANC_SDID_CTA_708   0x1

AVSmpte291mAnc8bit::sdid_or_dbn when carrying CTA-708 data (for AV_CODEC_ID_EIA_608)

Definition at line 240 of file smpte_436m.h.

Enumeration Type Documentation

◆ AVSmpte436mWrappingType

Wrapping Type from Table 7 (page 13) of: https://pub.smpte.org/latest/st436/s436m-2006.pdf.

Enumerator
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME 
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_1 
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2 
AV_SMPTE_436M_WRAPPING_TYPE_VANC_PROGRESSIVE_FRAME 
AV_SMPTE_436M_WRAPPING_TYPE_HANC_FRAME 
AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_1 
AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_2 
AV_SMPTE_436M_WRAPPING_TYPE_HANC_PROGRESSIVE_FRAME 
AV_SMPTE_436M_WRAPPING_TYPE_MAX 

not a real wrapping type, just here to guarantee the enum is big enough

Definition at line 40 of file smpte_436m.h.

◆ AVSmpte436mPayloadSampleCoding

Payload Sample Coding from Table 4 (page 10) and Table 7 (page 13) of: https://pub.smpte.org/latest/st436/s436m-2006.pdf.

Enumerator
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA 

only used for VBI

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_COLOR_DIFF 

only used for VBI

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA_AND_COLOR_DIFF 

only used for VBI

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA 

used for VBI and ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF 

used for VBI and ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF 

used for VBI and ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA 

used for VBI and ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_COLOR_DIFF 

used for VBI and ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA_AND_COLOR_DIFF 

used for VBI and ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_WITH_PARITY_ERROR 

only used for ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF_WITH_PARITY_ERROR 

only used for ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF_WITH_PARITY_ERROR 

only used for ANC

AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_MAX 

not a real sample coding, just here to guarantee the enum is big enough

Definition at line 58 of file smpte_436m.h.

Function Documentation

◆ av_smpte_436m_coded_anc_validate()

int av_smpte_436m_coded_anc_validate ( const AVSmpte436mCodedAnc anc)

Validate a AVSmpte436mCodedAnc structure.

Doesn't check if the payload is valid.

Parameters
[in]ancANC packet to validate
Returns
0 on success, AVERROR codes otherwise.

Definition at line 69 of file smpte_436m.c.

Referenced by smpte_436m_anc_decode_entry().

◆ av_smpte_436m_anc_encode()

int av_smpte_436m_anc_encode ( uint8_t *  out,
int  size,
int  anc_packet_count,
const AVSmpte436mCodedAnc anc_packets 
)

Encode ANC packets into a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.

Parameters
[in]anc_packet_countnumber of ANC packets to encode
[in]anc_packetsthe ANC packets to encode
[in]sizethe size of out. ignored if out is NULL.
[out]outOutput bytes. Doesn't write anything if out is NULL.
Returns
the number of bytes written on success, AVERROR codes otherwise. If out is NULL, returns the number of bytes it would have written.

Definition at line 173 of file smpte_436m.c.

Referenced by ff_eia608_to_smpte436m_filter().

◆ av_smpte_436m_anc_append()

int av_smpte_436m_anc_append ( struct AVPacket pkt,
int  anc_packet_count,
const AVSmpte436mCodedAnc anc_packets 
)

Append more ANC packets to a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.

Parameters
[in]anc_packet_countnumber of ANC packets to encode
[in]anc_packetsthe ANC packets to encode
pktthe AVPacket to append to. it must either be size 0 or contain valid SMPTE_436M_ANC data.
Returns
0 on success, AVERROR codes otherwise.

Definition at line 201 of file smpte_436m.c.

Referenced by mcc_read_header().

◆ av_smpte_436m_anc_iter_init()

int av_smpte_436m_anc_iter_init ( AVSmpte436mAncIterator iter,
const uint8_t *  buf,
int  buf_size 
)

Set up iteration over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.

Parameters
[in]bufPointer to the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket.
[in]buf_sizeSize of the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket.
[out]iterPointer to the iterator.
Returns
0 on success, AVERROR codes otherwise.

Definition at line 234 of file smpte_436m.c.

Referenced by ff_smpte436m_to_eia608_filter(), and mcc_write_packet().

◆ av_smpte_436m_anc_iter_next()

int av_smpte_436m_anc_iter_next ( AVSmpte436mAncIterator iter,
AVSmpte436mCodedAnc anc 
)

Get the next ANC packet from the iterator, advancing the iterator.

Parameters
[in,out]iterPointer to the iterator.
[out]ancThe returned ANC packet.
Returns
0 on success, AVERROR_EOF when the iterator has reached the end, AVERROR codes otherwise.

Definition at line 250 of file smpte_436m.c.

Referenced by ff_smpte436m_to_eia608_filter(), and mcc_write_packet().

◆ av_smpte_436m_coded_anc_payload_size()

int av_smpte_436m_coded_anc_payload_size ( AVSmpte436mPayloadSampleCoding  sample_coding,
uint16_t  sample_count 
)

Get the minimum number of bytes needed to store a AVSmpte436mCodedAnc payload.

Parameters
sample_codingthe payload sample coding
sample_countthe number of samples stored in the payload
Returns
returns the minimum number of bytes needed, on error returns < 0. always <= SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY

Definition at line 265 of file smpte_436m.c.

Referenced by av_smpte_291m_anc_8bit_encode(), and av_smpte_436m_coded_anc_validate().

◆ av_smpte_291m_anc_8bit_decode()

int av_smpte_291m_anc_8bit_decode ( AVSmpte291mAnc8bit out,
AVSmpte436mPayloadSampleCoding  sample_coding,
uint16_t  sample_count,
const uint8_t *  payload,
void *  log_ctx 
)

Decode a AVSmpte436mCodedAnc payload into AVSmpte291mAnc8bit.

Parameters
[in]sample_codingthe payload sample coding
[in]sample_countthe number of samples stored in the payload
[in]payloadthe bytes storing the payload, the needed size can be obtained from avpriv_smpte_436m_coded_anc_payload_size
[in]log_ctxcontext pointer for av_log
[out]outThe decoded ANC packet.
Returns
returns 0 on success, otherwise < 0.

Definition at line 295 of file smpte_436m.c.

Referenced by ff_smpte436m_to_eia608_filter(), mcc_read_header(), and mcc_write_packet().

◆ av_smpte_291m_anc_8bit_fill_checksum()

void av_smpte_291m_anc_8bit_fill_checksum ( AVSmpte291mAnc8bit anc)

Fill in the correct checksum for a AVSmpte291mAnc8bit.

Parameters
[in,out]ancThe ANC packet.

Definition at line 337 of file smpte_436m.c.

Referenced by av_smpte_291m_anc_8bit_decode(), and ff_eia608_to_smpte436m_filter().

◆ av_smpte_291m_anc_8bit_get_sample_count()

int av_smpte_291m_anc_8bit_get_sample_count ( const AVSmpte291mAnc8bit anc,
AVSmpte436mPayloadSampleCoding  sample_coding,
void *  log_ctx 
)

Compute the sample count needed to encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc payload.

Parameters
[in]ancThe ANC packet.
[in]sample_codingThe sample coding.
[in]log_ctxcontext pointer for av_log
Returns
returns the sample count on success, otherwise < 0.

Definition at line 346 of file smpte_436m.c.

Referenced by av_smpte_291m_anc_8bit_encode().

◆ av_smpte_291m_anc_8bit_encode()

int av_smpte_291m_anc_8bit_encode ( AVSmpte436mCodedAnc out,
uint16_t  line_number,
AVSmpte436mWrappingType  wrapping_type,
AVSmpte436mPayloadSampleCoding  sample_coding,
const AVSmpte291mAnc8bit payload,
void *  log_ctx 
)

Encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc.

Parameters
[in]line_numberthe line number the ANC packet is on
[in]wrapping_typethe wrapping type
[in]sample_codingthe payload sample coding
[in]payloadthe ANC packet to encode.
[in]log_ctxcontext pointer for av_log
[out]outThe encoded ANC packet.
Returns
returns 0 on success, otherwise < 0.

Definition at line 375 of file smpte_436m.c.

Referenced by ff_eia608_to_smpte436m_filter(), and ff_eia608_to_smpte436m_init().

◆ av_smpte_291m_anc_8bit_extract_cta_708()

int av_smpte_291m_anc_8bit_extract_cta_708 ( const AVSmpte291mAnc8bit anc,
uint8_t *  cc_data,
void *  log_ctx 
)

Try to decode an ANC packet into EIA-608/CTA-708 data (AV_CODEC_ID_EIA_608).

This

Parameters
[in]ancThe ANC packet.
[in]log_ctxContext pointer for av_log
[out]cc_datathe buffer to store the extracted EIA-608/CTA-708 data, you can pass NULL to not store the data. the required size is 3 * cc_count bytes. SMPTE_291M_ANC_PAYLOAD_CAPACITY is always enough size.
Returns
returns cc_count (>= 0) on success, AVERROR(EAGAIN) if it wasn't a CTA-708 ANC packet, < 0 on error.

Definition at line 433 of file smpte_436m.c.

Referenced by ff_smpte436m_to_eia608_filter(), and mcc_read_header().