31 switch (wrapping_type) {
48 switch (payload_sample_coding) {
89#define SMPTE_436M_ANC_ENTRY_HEADER_SIZE ( \
122 uint32_t payload_array_element_size =
AV_RB32(in);
124 if (payload_array_element_size != 1)
127 if (needed_size >
size)
155 if (needed_size >
size)
177 if (anc_packet_count < 0 || anc_packet_count >= (1L << 16) ||
size < 0)
182 if (
size < needed_size)
188 for (
int i = 0;
i < anc_packet_count;
i++) {
203 int final_packet_count = 0;
205 if (
pkt->size >= 2) {
207 write_start =
pkt->size;
208 }
else if (
pkt->size != 0)
210 if (anc_packet_count < 0 || anc_packet_count >= (1L << 16))
212 final_packet_count += anc_packet_count;
213 if (final_packet_count >= (1L << 16))
215 int ret, additional_size = write_start -
pkt->size;
216 for (
int i = 0;
i < anc_packet_count;
i++) {
220 additional_size += ret;
225 for (
int i = 0;
i < anc_packet_count;
i++) {
241 .anc_packets_left =
AV_RB16(buf),
242 .size_left = buf_size - 2,
243 .data_left = buf + 2,
269 switch (sample_coding) {
282 return (sample_count + 3) & -4;
289 return 4 * ((sample_count + 2) / 3);
297 uint16_t sample_count,
298 const uint8_t *payload,
301 switch (sample_coding) {
313 if (sample_count < 3)
315 out->did = *payload++;
316 out->sdid_or_dbn = *payload++;
317 out->data_count = *payload++;
318 if (sample_count < out->data_count + 3)
320 memcpy(
out->payload, payload,
out->data_count);
330 "decoding an ANC packet using the 10-bit SMPTE 436M sample coding isn't implemented.\n");
350 switch (sample_coding) {
368 "encoding an ANC packet using the 10-bit SMPTE 436M sample coding isn't implemented.\n");
376 uint16_t line_number,
382 out->line_number = line_number;
383 out->wrapping_type = wrapping_type;
384 out->payload_sample_coding = sample_coding;
390 out->payload_sample_count = ret;
396 out->payload_array_length = ret;
398 switch (sample_coding) {
412 memset(
out->payload +
out->payload_array_length - 4, 0, 4);
414 out->payload[0] = payload->
did;
426 "encoding an ANC packet using the 10-bit SMPTE 436M sample coding isn't implemented.\n");
441 uint16_t cdp_identifier = bytestream2_get_be16(&gb);
442 if (cdp_identifier != 0x9669) {
446 bytestream2_get_byte(&gb);
447 bytestream2_get_byte(&gb);
448 bytestream2_get_byte(&gb);
449 bytestream2_get_be16(&gb);
450 unsigned section_id = bytestream2_get_byte(&gb);
452 const unsigned TIME_CODE_SECTION_ID = 0x71;
453 if (section_id == TIME_CODE_SECTION_ID) {
455 section_id = bytestream2_get_byte(&gb);
457 const unsigned CC_DATA_SECTION_ID = 0x72;
458 if (section_id == CC_DATA_SECTION_ID) {
462 unsigned cc_count = bytestream2_get_byte(&gb) & 0x1F;
463 unsigned data_length = cc_count * 3;
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define i(width, name, range_min, range_max)
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_smpte_436m_anc_iter_next(AVSmpte436mAncIterator *iter, AVSmpte436mCodedAnc *anc)
Get the next ANC packet from the iterator, advancing the iterator.
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.
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.
static int validate_smpte_436m_anc_payload_sample_coding(AVSmpte436mPayloadSampleCoding payload_sample_coding)
#define SMPTE_436M_ANC_ENTRY_HEADER_SIZE
static int smpte_436m_anc_encode_entry(uint8_t *out, int size, const AVSmpte436mCodedAnc *anc)
Encode an ANC packet.
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.
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.
static int smpte_436m_anc_decode_entry(const uint8_t *in, int size, AVSmpte436mCodedAnc *anc)
Decode an ANC packet.
int av_smpte_436m_coded_anc_validate(const AVSmpte436mCodedAnc *anc)
Validate a AVSmpte436mCodedAnc structure.
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.
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.
static int validate_smpte_436m_anc_wrapping_type(AVSmpte436mWrappingType wrapping_type)
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).
void av_smpte_291m_anc_8bit_fill_checksum(AVSmpte291mAnc8bit *anc)
Fill in the correct checksum for a AVSmpte291mAnc8bit.
int av_smpte_436m_anc_append(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.
AVSmpte436mPayloadSampleCoding
Payload Sample Coding from Table 4 (page 10) and Table 7 (page 13) of: https://pub....
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA_AND_COLOR_DIFF
used for VBI and ANC
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA
only used for VBI
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF
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_1BIT_LUMA_AND_COLOR_DIFF
only used for VBI
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_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_LUMA_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_8BIT_COLOR_DIFF_WITH_PARITY_ERROR
only used for 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
#define AV_SMPTE_291M_ANC_SDID_CTA_708
AVSmpte291mAnc8bit::sdid_or_dbn when carrying CTA-708 data (for AV_CODEC_ID_EIA_608)
#define AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY
max number of samples that can be stored in the payload of AVSmpte436mCodedAnc
AVSmpte436mWrappingType
Wrapping Type from Table 7 (page 13) of: https://pub.smpte.org/latest/st436/s436m-2006....
@ AV_SMPTE_436M_WRAPPING_TYPE_HANC_PROGRESSIVE_FRAME
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2
@ AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_1
@ AV_SMPTE_436M_WRAPPING_TYPE_HANC_FRAME
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_PROGRESSIVE_FRAME
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_1
@ AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_2
#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY
max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc
#define AV_SMPTE_291M_ANC_DID_CTA_708
AVSmpte291mAnc8bit::did when carrying CTA-708 data (for AV_CODEC_ID_EIA_608)
This structure stores compressed data.
An ANC packet with an 8-bit payload.
uint8_t payload[AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY]
Iterator over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
uint16_t anc_packets_left
const uint8_t * data_left
An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
AVSmpte436mWrappingType wrapping_type
uint32_t payload_array_length
AVSmpte436mPayloadSampleCoding payload_sample_coding
uint16_t payload_sample_count
uint8_t payload[AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY]
the payload, has size payload_array_length.