54 0x96, 0x69, 0x49, 0x7F, 0x43, 0xFA, 0x8D, 0x72, 0xF4,
57 0xFC, 0x80, 0x80, 0xFD, 0x80, 0x80,
60 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00,
61 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00,
62 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00,
63 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00,
64 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00,
65 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00, 0xFA, 0x00, 0x00,
68 0x74, 0xFA, 0x8D, 0x81,
95 uint8_t cdp_frame_rate;
96 } known_frame_rates[] = {
97 { .frame_rate = { .num = 24000, .den = 1001 }, .cdp_frame_rate = 0x1F },
98 { .frame_rate = { .num = 24, .den = 1 }, .cdp_frame_rate = 0x2F },
99 { .frame_rate = { .num = 25, .den = 1 }, .cdp_frame_rate = 0x3F },
100 { .frame_rate = { .num = 30000, .den = 1001 }, .cdp_frame_rate = 0x4F },
101 { .frame_rate = { .num = 30, .den = 1 }, .cdp_frame_rate = 0x5F },
102 { .frame_rate = { .num = 50, .den = 1 }, .cdp_frame_rate = 0x6F },
103 { .frame_rate = { .num = 60000, .den = 1001 }, .cdp_frame_rate = 0x7F },
104 { .frame_rate = { .num = 60, .den = 1 }, .cdp_frame_rate = 0x8F },
119 "cdp_frame_rate not supported: %d/%d\n",
146 uint8_t *cdp_length_p = p++;
150 const uint8_t FLAG_CC_DATA_PRESENT = 0x40;
151 const uint8_t FLAG_CAPTION_SERVICE_ACTIVE = 0x2;
154 *p++ = FLAG_CC_DATA_PRESENT | FLAG_CAPTION_SERVICE_ACTIVE |
FLAG_RESERVED;
159 const uint8_t CC_DATA_SECTION_ID = 0x72;
161 *p++ = CC_DATA_SECTION_ID;
163 uint8_t *cc_count_p = p++;
165 const uint8_t CC_COUNT_MASK = 0x1F;
166 const int CDP_FOOTER_SIZE = 4;
168 int cc_count = in->
size / 3;
170 int cc_data_space_left = space_left - CDP_FOOTER_SIZE;
171 int max_cc_count =
FFMAX(cc_data_space_left / 3, CC_COUNT_MASK);
173 if (cc_count > max_cc_count) {
176 "cc_count (%d) is bigger than the maximum supported (%d), truncating captions packet\n",
179 cc_count = max_cc_count;
182 *cc_count_p = cc_count | ~CC_COUNT_MASK;
184 for (
size_t i = 0;
i < cc_count;
i++) {
185 size_t start =
i * 3;
186 *p++ = in->
data[start] | 0xF8;
187 *p++ = in->
data[start + 1];
188 *p++ = in->
data[start + 2];
191 const uint8_t CDP_FOOTER_ID = 0x74;
193 *p++ = CDP_FOOTER_ID;
198 uint8_t *packet_checksum_p = p;
209 *packet_checksum_p = -sum;
248#define OFFSET(x) offsetof(EIA608ToSMPTE436MContext, x)
249#define FLAGS AV_OPT_FLAG_BSF_PARAM
252 {
"line_number",
"line number -- you probably want 9 or 11",
OFFSET(line_number),
AV_OPT_TYPE_UINT, { .i64 = 9 }, 0, 0xFFFF,
FLAGS },
257 {
"initial_cdp_sequence_cntr",
"initial cdp_*_sequence_cntr value",
OFFSET(cdp_sequence_cntr),
AV_OPT_TYPE_UINT, { .i64 = 0 }, 0, 0xFFFF,
FLAGS },
264 .class_name =
"eia608_to_smpte436m bitstream filter",
271 .p.name =
"eia608_to_smpte436m",
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
Convenience header that includes libavutil's core.
const FFBitStreamFilter ff_eia608_to_smpte436m_bsf
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
Called by the bitstream filters to get the next packet for filtering.
#define i(width, name, range_min, range_max)
int(* init)(AVBSFContext *ctx)
static const AVClass eia608_to_smpte436m_class
static int ff_eia608_to_smpte436m_filter(AVBSFContext *ctx, AVPacket *out)
static av_cold int ff_eia608_to_smpte436m_init(AVBSFContext *ctx)
static const AVSmpte291mAnc8bit test_anc
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_SMPTE_436M_ANC
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define LIBAVUTIL_VERSION_INT
Utility Preprocessor macros.
Utilities for rational number calculation.
#define FF_ARRAY_ELEMS(a)
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_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.
void av_smpte_291m_anc_8bit_fill_checksum(AVSmpte291mAnc8bit *anc)
Fill in the correct checksum for a AVSmpte291mAnc8bit.
AVSmpte436mPayloadSampleCoding
Payload Sample Coding from Table 4 (page 10) and Table 7 (page 13) of: https://pub....
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA
used for VBI and ANC
#define AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY
the payload capacity of AVSmpte291mAnc8bit (and of AVSmpte291mAnc10bit when that gets added)
AVSmpte436mWrappingType
Wrapping Type from Table 7 (page 13) of: https://pub.smpte.org/latest/st436/s436m-2006....
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME
#define FF_SMPTE_436M_PAYLOAD_SAMPLE_CODING_ANC_AVOPTIONS(flags, unit_name)
#define FF_SMPTE_436M_WRAPPING_TYPE_VANC_AVOPTIONS(flags, unit_name)
The bitstream filter state.
Describe the class of an AVClass context structure.
This structure stores compressed data.
Rational number (pair of numerator and denominator).
An ANC packet with an 8-bit payload.
uint8_t payload[AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY]
An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
AVSmpte436mPayloadSampleCoding sample_coding
unsigned sample_coding_opt
AVSmpte436mWrappingType wrapping_type
uint8_t cdp_frame_rate_byte
AVRational cdp_frame_rate
unsigned cdp_sequence_cntr
unsigned wrapping_type_opt
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)