62 if (!memcmp(buf,
"File Format=MacCaption_MCC V", 28))
85#define CCPAD "\xFA\x0\x0"
86#define CCPAD3 CCPAD CCPAD CCPAD
92 { .key = 16, .len = 3, .value =
cc_pad, },
93 { .key = 17, .len = 6, .value =
cc_pad, },
94 { .key = 18, .len = 9, .value =
cc_pad, },
95 { .key = 19, .len = 12, .value =
cc_pad, },
96 { .key = 20, .len = 15, .value =
cc_pad, },
97 { .key = 21, .len = 18, .value =
cc_pad, },
98 { .key = 22, .len = 21, .value =
cc_pad, },
99 { .key = 23, .len = 24, .value =
cc_pad, },
100 { .key = 24, .len = 27, .value =
cc_pad, },
101 { .key = 25, .len = 3, .value =
"\xFB\x80\x80", },
102 { .key = 26, .len = 3, .value =
"\xFC\x80\x80", },
103 { .key = 27, .len = 3, .value =
"\xFD\x80\x80", },
104 { .key = 28, .len = 2, .value =
"\x96\x69", },
105 { .key = 29, .len = 2, .value =
"\x61\x01", },
106 { .key = 30, .len = 3, .value =
"\xFC\x80\x80", },
107 { .key = 31, .len = 3, .value =
"\xFC\x80\x80", },
108 { .key = 32, .len = 4, .value =
"\xE1\x00\x00\x00", },
109 { .key = 33, .len = 0, .value =
NULL, },
110 { .key = 34, .len = 0, .value =
NULL, },
111 { .key = 35, .len = 1, .value =
"\x0", },
163 { .rate = { .num = 24, .den = 1 }, .str =
"24" },
164 { .rate = { .num = 25, .den = 1 }, .str =
"25" },
165 { .rate = { .num = 30000, .den = 1001 }, .str =
"30DF" },
166 { .rate = { .num = 30, .den = 1 }, .str =
"30" },
167 { .rate = { .num = 50, .den = 1 }, .str =
"50" },
168 { .rate = { .num = 60000, .den = 1001 }, .str =
"60DF" },
169 { .rate = { .num = 60, .den = 1 }, .str =
"60" },
177 bool bad_after =
false;
178 for (; *after; after++) {
199 unsigned digit = **line_left -
'0';
205 unsigned char after = **line_left;
206 if (!after || !strchr(after_set, after))
214 *tc = (
MCCTimecode){ .field = 0, .line_number = 9 };
275 if (!strncmp(
line,
"File Format=MacCaption_MCC V", 28))
277 if (!strncmp(
line,
"//", 2))
279 if (!strncmp(
line,
"Time Code Rate=", 15)) {
285 if (strchr(
line,
'='))
287 char *line_left =
line;
312 uint8_t v =
convert(*line_left++);
314 if (v >= 16 && v <= 35) {
324 bytestream2_put_byte(&pb, vv | (v << 4));
338 bytestream2_put_byte(&pb, 0);
354 int len = cc_count * 3;
399#define OFFSET(x) offsetof(MCCContext, x)
400#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
403 {
"eia608_extract",
"extract EIA-608/708 captions from VANC packets",
OFFSET(eia608_extract),
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1,
SD },
409 .class_name =
"mcc demuxer",
419 .p.extensions =
"mcc",
#define attribute_nonstring
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Convenience header that includes libavutil's core.
static av_always_inline int bytestream2_tell_p(const PutByteContext *p)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_CODEC_ID_SMPTE_436M_ANC
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#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.
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
#define LIBAVUTIL_VERSION_INT
static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
Merge two consequent lists of equal size depending on bits read.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
@ AV_CLASS_CATEGORY_DEMUXER
Utility Preprocessor macros.
static const AVClass mcc_class
static attribute_nonstring const char cc_pad[27]
static int mcc_read_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
static int time_tracker_init(TimeTracker *tt, AVStream *st, AVRational rate, void *log_ctx)
static int mcc_read_header(AVFormatContext *s)
static const AVOption mcc_options[]
static int mcc_parse_time_code(char **line_left, MCCTimecode *tc)
static int time_tracker_set_time(TimeTracker *tt, const MCCTimecode *tc, void *log_ctx)
static int convert(uint8_t x)
static const alias aliases[20]
static int mcc_parse_time_code_part(char **line_left, unsigned *value, unsigned max, const char *after_set)
static int mcc_read_close(AVFormatContext *s)
static int mcc_read_packet(AVFormatContext *s, AVPacket *pkt)
static int parse_time_code_rate(AVFormatContext *s, AVStream *st, TimeTracker *tt, const char *time_code_rate)
static int mcc_probe(const AVProbeData *p)
static const struct ValidTimeCodeRate valid_time_code_rates[]
Utilities for rational number calculation.
#define FF_ARRAY_ELEMS(a)
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_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).
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.
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA
used for VBI and ANC
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME
#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY
max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc
Describe the class of an AVClass context structure.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t pos
byte position in stream, -1 if unknown
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
An ANC packet with an 8-bit payload.
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.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
uint32_t flags
flags such as drop frame, +24 hours support, ...
AVRational rate
frame rate in rational form
int start
timecode frame start (first base frame number)
ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size)
Read a line of text.
int64_t ff_text_pos(FFTextReader *r)
Return the byte position of the next byte returned by ff_text_r8().
int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Update current_sub_idx to emulate a seek.
AVPacket * ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, const uint8_t *event, size_t len, int merge)
Insert a new subtitle event.
void ff_text_read(FFTextReader *r, char *buf, size_t size)
Read the given number of bytes (in UTF-8).
int ff_text_eof(FFTextReader *r)
Return non-zero if EOF was reached.
void ff_text_init_buf(FFTextReader *r, const void *buf, size_t size)
Similar to ff_text_init_avio(), but sets it up to read from a bounded buffer.
void ff_text_init_avio(void *s, FFTextReader *r, AVIOContext *pb)
Initialize the FFTextReader from the given AVIOContext.
int ff_text_r8(FFTextReader *r)
Return the next byte.
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
Generic read_packet() callback for subtitles demuxers using this queue system.
int ff_text_peek_r8(FFTextReader *r)
Like ff_text_r8(), but don't remove the byte from the buffer.
void ff_subtitles_queue_finalize(void *log_ctx, FFDemuxSubtitlesQueue *q)
Set missing durations, sort subtitles by PTS (and then byte position), and drop duplicated events.
void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
Remove and destroy all the subtitles packets.
int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx)
Init a timecode struct from the passed timecode components.
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame