FFmpeg
mccdec.c
Go to the documentation of this file.
1 /*
2  * MCC subtitle demuxer
3  * Copyright (c) 2020 Paul B Mahol
4  * Copyright (c) 2025 Jacob Lifshay
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "avformat.h"
24 #include "demux.h"
25 #include "internal.h"
26 #include "libavcodec/bytestream.h"
27 #include "libavcodec/codec_id.h"
28 #include "libavcodec/smpte_436m.h"
29 #include "libavutil/avstring.h"
30 #include "libavutil/avutil.h"
31 #include "libavutil/error.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/log.h"
34 #include "libavutil/macros.h"
35 #include "libavutil/opt.h"
36 #include "libavutil/rational.h"
37 #include "libavutil/timecode.h"
38 #include "subtitles.h"
39 #include <inttypes.h>
40 #include <stdbool.h>
41 #include <string.h>
42 
43 typedef struct MCCContext {
44  const AVClass *class;
47 } MCCContext;
48 
49 static int mcc_probe(const AVProbeData *p)
50 {
51  char buf[28];
52  FFTextReader tr;
53 
54  ff_text_init_buf(&tr, p->buf, p->buf_size);
55 
56  while (ff_text_peek_r8(&tr) == '\r' || ff_text_peek_r8(&tr) == '\n')
57  ff_text_r8(&tr);
58 
59  ff_text_read(&tr, buf, sizeof(buf));
60 
61  if (!memcmp(buf, "File Format=MacCaption_MCC V", 28))
62  return AVPROBE_SCORE_MAX;
63 
64  return 0;
65 }
66 
67 static int convert(uint8_t x)
68 {
69  if (x >= 'a')
70  x -= 87;
71  else if (x >= 'A')
72  x -= 55;
73  else
74  x -= '0';
75  return x;
76 }
77 
78 typedef struct alias {
79  uint8_t key;
80  int len;
81  const char *value;
82 } alias;
83 
84 #define CCPAD "\xFA\x0\x0"
85 #define CCPAD3 CCPAD CCPAD CCPAD
86 
87 static const char cc_pad[27] = CCPAD3 CCPAD3 CCPAD3;
88 
89 static const alias aliases[20] = {
90  // clang-format off
91  { .key = 16, .len = 3, .value = cc_pad, },
92  { .key = 17, .len = 6, .value = cc_pad, },
93  { .key = 18, .len = 9, .value = cc_pad, },
94  { .key = 19, .len = 12, .value = cc_pad, },
95  { .key = 20, .len = 15, .value = cc_pad, },
96  { .key = 21, .len = 18, .value = cc_pad, },
97  { .key = 22, .len = 21, .value = cc_pad, },
98  { .key = 23, .len = 24, .value = cc_pad, },
99  { .key = 24, .len = 27, .value = cc_pad, },
100  { .key = 25, .len = 3, .value = "\xFB\x80\x80", },
101  { .key = 26, .len = 3, .value = "\xFC\x80\x80", },
102  { .key = 27, .len = 3, .value = "\xFD\x80\x80", },
103  { .key = 28, .len = 2, .value = "\x96\x69", },
104  { .key = 29, .len = 2, .value = "\x61\x01", },
105  { .key = 30, .len = 3, .value = "\xFC\x80\x80", },
106  { .key = 31, .len = 3, .value = "\xFC\x80\x80", },
107  { .key = 32, .len = 4, .value = "\xE1\x00\x00\x00", },
108  { .key = 33, .len = 0, .value = NULL, },
109  { .key = 34, .len = 0, .value = NULL, },
110  { .key = 35, .len = 1, .value = "\x0", },
111  // clang-format on
112 };
113 
114 typedef struct TimeTracker {
118 } TimeTracker;
119 
120 static int time_tracker_init(TimeTracker *tt, AVStream *st, AVRational rate, void *log_ctx)
121 {
122  *tt = (TimeTracker){ .last_ts = 0 };
123  int ret = av_timecode_init(&tt->timecode, rate, rate.den == 1001 ? AV_TIMECODE_FLAG_DROPFRAME : 0, 0, log_ctx);
124  if (ret < 0)
125  return ret;
126  // wrap pts values at 24hr ourselves since they can be bigger than fits in an int
127  AVTimecode twenty_four_hr;
128  ret = av_timecode_init_from_components(&twenty_four_hr, rate, tt->timecode.flags, 24, 0, 0, 0, log_ctx);
129  if (ret < 0)
130  return ret;
131  tt->twenty_four_hr = twenty_four_hr.start;
132  // timecode uses reciprocal of timebase
133  avpriv_set_pts_info(st, 64, rate.den, rate.num);
134  return 0;
135 }
136 
137 typedef struct MCCTimecode {
138  unsigned hh, mm, ss, ff, field, line_number;
139 } MCCTimecode;
140 
141 static int time_tracker_set_time(TimeTracker *tt, const MCCTimecode *tc, void *log_ctx)
142 {
143  AVTimecode last = tt->timecode;
144  int ret = av_timecode_init_from_components(&tt->timecode, last.rate, last.flags, tc->hh, tc->mm, tc->ss, tc->ff, log_ctx);
145  if (ret < 0) {
146  tt->timecode = last;
147  return ret;
148  }
149  tt->last_ts -= last.start;
150  tt->last_ts += tt->timecode.start;
151  if (tt->timecode.start < last.start)
152  tt->last_ts += tt->twenty_four_hr;
153  return 0;
154 }
155 
158  const char *str;
159 };
160 
162  { .rate = { .num = 24, .den = 1 }, .str = "24" },
163  { .rate = { .num = 25, .den = 1 }, .str = "25" },
164  { .rate = { .num = 30000, .den = 1001 }, .str = "30DF" },
165  { .rate = { .num = 30, .den = 1 }, .str = "30" },
166  { .rate = { .num = 50, .den = 1 }, .str = "50" },
167  { .rate = { .num = 60000, .den = 1001 }, .str = "60DF" },
168  { .rate = { .num = 60, .den = 1 }, .str = "60" },
169 };
170 
171 static int parse_time_code_rate(AVFormatContext *s, AVStream *st, TimeTracker *tt, const char *time_code_rate)
172 {
173  for (size_t i = 0; i < FF_ARRAY_ELEMS(valid_time_code_rates); i++) {
174  const char *after;
175  if (av_stristart(time_code_rate, valid_time_code_rates[i].str, &after) != 0) {
176  bool bad_after = false;
177  for (; *after; after++) {
178  if (!av_isspace(*after)) {
179  bad_after = true;
180  break;
181  }
182  }
183  if (bad_after)
184  continue;
185  return time_tracker_init(tt, st, valid_time_code_rates[i].rate, s);
186  }
187  }
188  av_log(s, AV_LOG_FATAL, "invalid mcc time code rate: %s", time_code_rate);
189  return AVERROR_INVALIDDATA;
190 }
191 
192 static int mcc_parse_time_code_part(char **line_left, unsigned *value, unsigned max, const char *after_set)
193 {
194  *value = 0;
195  if (!av_isdigit(**line_left))
196  return AVERROR_INVALIDDATA;
197  while (av_isdigit(**line_left)) {
198  unsigned digit = **line_left - '0';
199  *value = *value * 10 + digit;
200  ++*line_left;
201  if (*value > max)
202  return AVERROR_INVALIDDATA;
203  }
204  unsigned char after = **line_left;
205  if (!after || !strchr(after_set, after))
206  return AVERROR_INVALIDDATA;
207  ++*line_left;
208  return after;
209 }
210 
211 static int mcc_parse_time_code(char **line_left, MCCTimecode *tc)
212 {
213  *tc = (MCCTimecode){ .field = 0, .line_number = 9 };
214  int ret = mcc_parse_time_code_part(line_left, &tc->hh, 23, ":");
215  if (ret < 0)
216  return ret;
217  ret = mcc_parse_time_code_part(line_left, &tc->mm, 59, ":");
218  if (ret < 0)
219  return ret;
220  ret = mcc_parse_time_code_part(line_left, &tc->ss, 59, ":;");
221  if (ret < 0)
222  return ret;
223  ret = mcc_parse_time_code_part(line_left, &tc->ff, 59, ".\t");
224  if (ret < 0)
225  return ret;
226  if (ret == '.') {
227  ret = mcc_parse_time_code_part(line_left, &tc->field, 1, ",\t");
228  if (ret < 0)
229  return ret;
230  if (ret == ',') {
231  ret = mcc_parse_time_code_part(line_left, &tc->line_number, 0xFFFF, "\t");
232  if (ret < 0)
233  return ret;
234  }
235  }
236  if (ret != '\t')
237  return AVERROR_INVALIDDATA;
238  return 0;
239 }
240 
242 {
243  MCCContext *mcc = s->priv_data;
245  int64_t pos;
246  AVSmpte436mCodedAnc coded_anc = {
248  };
249  char line[4096];
250  FFTextReader tr;
251  int ret = 0;
252 
253  ff_text_init_avio(s, &tr, s->pb);
254 
255  if (!st)
256  return AVERROR(ENOMEM);
257  if (mcc->eia608_extract) {
260  } else {
263  av_dict_set(&st->metadata, "data_type", "vbi_vanc_smpte_436M", 0);
264  }
265 
266  TimeTracker tt;
267  ret = time_tracker_init(&tt, st, (AVRational){ .num = 30, .den = 1 }, s);
268  if (ret < 0)
269  return ret;
270 
271  while (!ff_text_eof(&tr)) {
272  pos = ff_text_pos(&tr);
273  ff_subtitles_read_line(&tr, line, sizeof(line));
274  if (!strncmp(line, "File Format=MacCaption_MCC V", 28))
275  continue;
276  if (!strncmp(line, "//", 2))
277  continue;
278  if (!strncmp(line, "Time Code Rate=", 15)) {
279  ret = parse_time_code_rate(s, st, &tt, line + 15);
280  if (ret < 0)
281  return ret;
282  continue;
283  }
284  if (strchr(line, '='))
285  continue; // skip attributes
286  char *line_left = line;
287  while (av_isspace(*line_left))
288  line_left++;
289  if (!*line_left) // skip empty lines
290  continue;
291  MCCTimecode tc;
292  ret = mcc_parse_time_code(&line_left, &tc);
293  if (ret < 0) {
294  av_log(s, AV_LOG_ERROR, "can't parse mcc time code");
295  continue;
296  }
297 
298  int64_t last_pts = tt.last_ts;
299  ret = time_tracker_set_time(&tt, &tc, s);
300  if (ret < 0)
301  continue;
302  bool merge = last_pts == tt.last_ts;
303 
304  coded_anc.line_number = tc.line_number;
306 
307  PutByteContext pb;
309 
310  while (*line_left) {
311  uint8_t v = convert(*line_left++);
312 
313  if (v >= 16 && v <= 35) {
314  int idx = v - 16;
316  } else {
317  uint8_t vv;
318 
319  if (!*line_left)
320  break;
321  vv = convert(*line_left++);
322  bytestream2_put_byte(&pb, vv | (v << 4));
323  }
324  }
325  if (pb.eof)
326  continue;
327  // remove trailing ANC checksum byte (not to be confused with the CDP checksum byte),
328  // it's not included in 8-bit sample encodings. see section 6.2 (page 14) of:
329  // https://pub.smpte.org/latest/st436/s436m-2006.pdf
330  bytestream2_seek_p(&pb, -1, SEEK_CUR);
331  coded_anc.payload_sample_count = bytestream2_tell_p(&pb);
332  if (coded_anc.payload_sample_count == 0)
333  continue; // ignore if too small
334  // add padding to align to 4 bytes
335  while (!pb.eof && bytestream2_tell_p(&pb) % 4)
336  bytestream2_put_byte(&pb, 0);
337  if (pb.eof)
338  continue;
339  coded_anc.payload_array_length = bytestream2_tell_p(&pb);
340 
341  AVPacket *sub;
342  if (mcc->eia608_extract) {
343  AVSmpte291mAnc8bit anc;
345  &anc, coded_anc.payload_sample_coding, coded_anc.payload_sample_count, coded_anc.payload, s)
346  < 0)
347  continue;
348  // reuse line
349  int cc_count = av_smpte_291m_anc_8bit_extract_cta_708(&anc, line, s);
350  if (cc_count < 0) // continue if error or if it's not a closed captions packet
351  continue;
352  int len = cc_count * 3;
353 
354  sub = ff_subtitles_queue_insert(&mcc->q, line, len, merge);
355  if (!sub)
356  return AVERROR(ENOMEM);
357  } else {
358  sub = ff_subtitles_queue_insert(&mcc->q, NULL, 0, merge);
359  if (!sub)
360  return AVERROR(ENOMEM);
361 
362  ret = av_smpte_436m_anc_append(sub, 1, &coded_anc);
363  if (ret < 0)
364  return ret;
365  }
366 
367  sub->pos = pos;
368  sub->pts = tt.last_ts;
369  sub->duration = 1;
370  continue;
371  }
372 
374 
375  return ret;
376 }
377 
379 {
380  MCCContext *mcc = s->priv_data;
381  return ff_subtitles_queue_read_packet(&mcc->q, pkt);
382 }
383 
384 static int mcc_read_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
385 {
386  MCCContext *mcc = s->priv_data;
387  return ff_subtitles_queue_seek(&mcc->q, s, stream_index, min_ts, ts, max_ts, flags);
388 }
389 
391 {
392  MCCContext *mcc = s->priv_data;
394  return 0;
395 }
396 
397 #define OFFSET(x) offsetof(MCCContext, x)
398 #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
399 // clang-format off
400 static const AVOption mcc_options[] = {
401  { "eia608_extract", "extract EIA-608/708 captions from VANC packets", OFFSET(eia608_extract), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, SD },
402  { NULL },
403 };
404 // clang-format on
405 
406 static const AVClass mcc_class = {
407  .class_name = "mcc demuxer",
408  .item_name = av_default_item_name,
409  .option = mcc_options,
410  .version = LIBAVUTIL_VERSION_INT,
411  .category = AV_CLASS_CATEGORY_DEMUXER,
412 };
413 
415  .p.name = "mcc",
416  .p.long_name = NULL_IF_CONFIG_SMALL("MacCaption"),
417  .p.extensions = "mcc",
418  .p.priv_class = &mcc_class,
419  .priv_data_size = sizeof(MCCContext),
420  .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
424  .read_seek2 = mcc_read_seek,
426 };
flags
const SwsFlags flags[]
Definition: swscale.c:61
AV_CODEC_ID_EIA_608
@ AV_CODEC_ID_EIA_608
Definition: codec_id.h:572
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:203
ff_text_r8
int ff_text_r8(FFTextReader *r)
Return the next byte.
Definition: subtitles.c:65
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
TimeTracker::last_ts
int64_t last_ts
Definition: mccdec.c:115
rational.h
int64_t
long long int64_t
Definition: coverity.c:34
convert
static int convert(uint8_t x)
Definition: mccdec.c:67
av_isspace
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
Definition: avstring.h:218
merge
static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
Merge two consequent lists of equal size depending on bits read.
Definition: bink.c:221
MCCTimecode
Definition: mccdec.c:137
AVOption
AVOption.
Definition: opt.h:429
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA
@ AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA
used for VBI and ANC
Definition: smpte_436m.h:67
AVTimecode::flags
uint32_t flags
flags such as drop frame, +24 hours support, ...
Definition: timecode.h:43
AVSmpte436mCodedAnc::payload_sample_count
uint16_t payload_sample_count
Definition: smpte_436m.h:121
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:570
max
#define max(a, b)
Definition: cuda_runtime.h:33
FFTextReader
Definition: subtitles.h:41
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:454
mcc_parse_time_code_part
static int mcc_parse_time_code_part(char **line_left, unsigned *value, unsigned max, const char *after_set)
Definition: mccdec.c:192
parse_time_code_rate
static int parse_time_code_rate(AVFormatContext *s, AVStream *st, TimeTracker *tt, const char *time_code_rate)
Definition: mccdec.c:171
AVSmpte436mCodedAnc::wrapping_type
AVSmpte436mWrappingType wrapping_type
Definition: smpte_436m.h:119
ff_subtitles_read_line
ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size)
Read a line of text.
Definition: subtitles.c:454
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:463
av_smpte_436m_anc_append
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.
Definition: smpte_436m.c:201
MCCTimecode::line_number
unsigned line_number
Definition: mccdec.c:138
MCCContext
Definition: mccdec.c:43
mcc_read_close
static int mcc_read_close(AVFormatContext *s)
Definition: mccdec.c:390
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:777
alias::len
int len
Definition: mccdec.c:80
macros.h
timecode.h
AVTimecode::start
int start
timecode frame start (first base frame number)
Definition: timecode.h:42
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:143
MCCTimecode::ff
unsigned ff
Definition: mccdec.c:138
AVRational::num
int num
Numerator.
Definition: rational.h:59
mcc_options
static const AVOption mcc_options[]
Definition: mccdec.c:400
ff_subtitles_queue_seek
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.
Definition: subtitles.c:269
MCCContext::q
FFDemuxSubtitlesQueue q
Definition: mccdec.c:46
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
codec_id.h
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:42
bytestream2_init_writer
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
av_timecode_init
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
Definition: timecode.c:201
s
#define s(width, name)
Definition: cbs_vp9.c:198
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.
Definition: smpte_436m.c:295
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:549
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:453
bytestream2_tell_p
static av_always_inline int bytestream2_tell_p(const PutByteContext *p)
Definition: bytestream.h:197
bytestream2_put_buffer
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
Definition: bytestream.h:286
mcc_parse_time_code
static int mcc_parse_time_code(char **line_left, MCCTimecode *tc)
Definition: mccdec.c:211
av_stristart
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.
Definition: avstring.c:47
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:202
ff_subtitles_queue_read_packet
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
Generic read_packet() callback for subtitles demuxers using this queue system.
Definition: subtitles.c:230
smpte_436m.h
CCPAD3
#define CCPAD3
Definition: mccdec.c:85
AV_CLASS_CATEGORY_DEMUXER
@ AV_CLASS_CATEGORY_DEMUXER
Definition: log.h:33
FF_INFMT_FLAG_INIT_CLEANUP
#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...
Definition: demux.h:35
AVFormatContext
Format I/O context.
Definition: avformat.h:1264
AVSmpte436mCodedAnc::line_number
uint16_t line_number
Definition: smpte_436m.h:118
internal.h
ff_text_read
void ff_text_read(FFTextReader *r, char *buf, size_t size)
Read the given number of bytes (in UTF-8).
Definition: subtitles.c:86
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:767
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
MCCTimecode::field
unsigned field
Definition: mccdec.c:138
MCCTimecode::hh
unsigned hh
Definition: mccdec.c:138
alias::key
uint8_t key
Definition: mccdec.c:79
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
NULL
#define NULL
Definition: coverity.c:32
PutByteContext::eof
int eof
Definition: bytestream.h:39
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
MCCContext::eia608_extract
int eia608_extract
Definition: mccdec.c:45
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:824
ValidTimeCodeRate
Definition: mccdec.c:156
ff_subtitles_queue_insert
AVPacket * ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, const uint8_t *event, size_t len, int merge)
Insert a new subtitle event.
Definition: subtitles.c:111
ValidTimeCodeRate::str
const char * str
Definition: mccdec.c:158
AVTimecode::rate
AVRational rate
frame rate in rational form
Definition: timecode.h:44
error.h
ff_text_init_avio
void ff_text_init_avio(void *s, FFTextReader *r, AVIOContext *pb)
Initialize the FFTextReader from the given AVIOContext.
Definition: subtitles.c:28
av_timecode_init_from_components
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.
Definition: timecode.c:211
PutByteContext
Definition: bytestream.h:37
time_tracker_set_time
static int time_tracker_set_time(TimeTracker *tt, const MCCTimecode *tc, void *log_ctx)
Definition: mccdec.c:141
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2
Definition: smpte_436m.h:44
ff_subtitles_queue_finalize
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.
Definition: subtitles.c:212
aliases
static const alias aliases[20]
Definition: mccdec.c:89
SD
#define SD
Definition: mccdec.c:398
FFDemuxSubtitlesQueue
Definition: subtitles.h:103
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:46
av_isdigit
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
Definition: avstring.h:202
ff_subtitles_queue_clean
void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
Remove and destroy all the subtitles packets.
Definition: subtitles.c:321
line
Definition: graph2dot.c:48
OFFSET
#define OFFSET(x)
Definition: mccdec.c:397
read_header
static int read_header(FFV1Context *f, RangeCoder *c)
Definition: ffv1dec.c:498
MCCTimecode::ss
unsigned ss
Definition: mccdec.c:138
AVSmpte436mCodedAnc
An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
Definition: smpte_436m.h:117
mcc_probe
static int mcc_probe(const AVProbeData *p)
Definition: mccdec.c:49
AVSmpte291mAnc8bit
An ANC packet with an 8-bit payload.
Definition: smpte_436m.h:98
AVSmpte436mCodedAnc::payload_array_length
uint32_t payload_array_length
Definition: smpte_436m.h:122
mcc_read_packet
static int mcc_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mccdec.c:378
mcc_class
static const AVClass mcc_class
Definition: mccdec.c:406
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:545
mcc_read_seek
static int mcc_read_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Definition: mccdec.c:384
ff_text_pos
int64_t ff_text_pos(FFTextReader *r)
Return the byte position of the next byte returned by ff_text_r8().
Definition: subtitles.c:60
internal.h
TimeTracker::twenty_four_hr
int64_t twenty_four_hr
Definition: mccdec.c:116
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
AV_CODEC_ID_SMPTE_436M_ANC
@ AV_CODEC_ID_SMPTE_436M_ANC
Definition: codec_id.h:606
ff_mcc_demuxer
const FFInputFormat ff_mcc_demuxer
Definition: mccdec.c:414
demux.h
len
int len
Definition: vorbis_enc_data.h:426
last_pts
static int64_t last_pts
Definition: decode_filter_video.c:52
cc_pad
static const char cc_pad[27]
Definition: mccdec.c:87
AV_TIMECODE_FLAG_DROPFRAME
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
Definition: timecode.h:36
AVSmpte436mCodedAnc::payload
uint8_t payload[AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY]
the payload, has size payload_array_length.
Definition: smpte_436m.h:126
MCCTimecode::mm
unsigned mm
Definition: mccdec.c:138
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:744
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:204
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:81
pos
unsigned int pos
Definition: spdifenc.c:414
avformat.h
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).
Definition: smpte_436m.c:433
ff_text_peek_r8
int ff_text_peek_r8(FFTextReader *r)
Like ff_text_r8(), but don't remove the byte from the buffer.
Definition: subtitles.c:97
TimeTracker::timecode
AVTimecode timecode
Definition: mccdec.c:117
subtitles.h
valid_time_code_rates
static struct ValidTimeCodeRate valid_time_code_rates[]
Definition: mccdec.c:161
AVRational::den
int den
Denominator.
Definition: rational.h:60
bytestream2_seek_p
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
Definition: bytestream.h:236
ff_text_init_buf
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.
Definition: subtitles.c:54
time_tracker_init
static int time_tracker_init(TimeTracker *tt, AVStream *st, AVRational rate, void *log_ctx)
Definition: mccdec.c:120
read_probe
static int read_probe(const AVProbeData *p)
Definition: cdg.c:30
avutil.h
ff_text_eof
int ff_text_eof(FFTextReader *r)
Return non-zero if EOF was reached.
Definition: subtitles.c:92
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME
Definition: smpte_436m.h:42
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:529
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:86
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:572
FFInputFormat
Definition: demux.h:42
bytestream.h
AVSmpte436mCodedAnc::payload_sample_coding
AVSmpte436mPayloadSampleCoding payload_sample_coding
Definition: smpte_436m.h:120
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
alias
Definition: mccdec.c:78
AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY
#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY
max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc
Definition: smpte_436m.h:110
avstring.h
AVTimecode
Definition: timecode.h:41
alias::value
const char * value
Definition: mccdec.c:81
mcc_read_header
static int mcc_read_header(AVFormatContext *s)
Definition: mccdec.c:241
line
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
Definition: swscale.txt:40
ValidTimeCodeRate::rate
AVRational rate
Definition: mccdec.c:157
TimeTracker
Definition: mccdec.c:114