35#define LINE_DATA_SIZE 9
52#define OFFSET(x) offsetof(ReadVitcContext, x)
53#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
56 {
"scan_max",
"maximum line numbers to scan for VITC data",
OFFSET(scan_max),
AV_OPT_TYPE_INT, {.i64 = 45 }, -1, INT_MAX,
FLAGS },
67 crc = 0x01 | (
line[0] << 2);
68 crc ^= (
line[0] >> 6) | 0x04 | (
line[1] << 4);
69 crc ^= (
line[1] >> 4) | 0x10 | (
line[2] << 6);
70 crc ^= (
line[2] >> 2) | 0x40;
72 crc ^= 0x01 | (
line[4] << 2);
73 crc ^= (
line[4] >> 6) | 0x04 | (
line[5] << 4);
74 crc ^= (
line[5] >> 4) | 0x10 | (
line[6] << 6);
75 crc ^= (
line[6] >> 2) | 0x40;
78 crc = (crc >> 2) | (crc << 6);
89 int grp_index, pit_index;
94 if (
ctx->scan_max >= 0)
98 for (y = 0; y <
height; y++) {
103 while ((x <
width) && (grp_index < 9)) {
105 while ((x <
width) && (scan_line[x] <
ctx->threshold_white))
107 while ((x <
width) && (scan_line[x] >
ctx->threshold_black))
109 x =
FFMAX(x - ((
ctx->grp_width+10) / 20), 1);
111 if ((grp_start_pos +
ctx->grp_width) >
width)
114 if (pit_value < ctx->threshold_white)
116 x = grp_start_pos + ((
ctx->grp_width) / 10);
118 if (pit_value >
ctx->threshold_black )
120 for (pit_index = 0; pit_index <= 7; pit_index++) {
121 x = grp_start_pos + (((pit_index+2)*
ctx->grp_width) / 10);
123 if (pit_value >
ctx->threshold_gray)
124 ctx->line_data[grp_index] |= (1 << pit_index);
140 if (
high > 9 || low > 9)
142 return 10*
high + low;
151 unsigned drop = (
line[1] & 0x04);
153 hh, mm,
ss, drop ?
';' :
':', ff);
161 s->threshold_black =
s->thr_b * UINT8_MAX;
162 s->threshold_white =
s->thr_w * UINT8_MAX;
163 if (
s->threshold_black >
s->threshold_white) {
168 s->threshold_gray =
s->threshold_white - ((
s->threshold_white -
s->threshold_black) / 2);
170 s->threshold_black,
s->threshold_white,
s->threshold_gray);
180 s->grp_width = inlink->
w * 5 / 48;
182 inlink->
w, inlink->
h,
s->grp_width,
s->scan_max);
216 av_dict_set(&
frame->metadata,
"lavfi.readvitc.found", (found ?
"1" :
"0"), 0);
233 .p.name =
"readvitc",
234 .p.description =
NULL_IF_CONFIG_SMALL(
"Read vertical interval timecode and write it to frame metadata."),
235 .p.priv_class = &readvitc_class,
static const AVFilterPad inputs[]
const FFFilter ff_vf_readvitc
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
#define ss(width, name, subs,...)
common internal and external API header
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
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 AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static int config_props(AVBitStreamFilterLink *link)
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
char tcbuf[AV_TIMECODE_STR_SIZE]
uint8_t line_data[LINE_DATA_SIZE]
static AVFormatContext * ctx
#define AV_TIMECODE_STR_SIZE
static enum AVPixelFormat pixel_fmts[]
static char * make_vitc_tc_string(char *buf, uint8_t *line)
static int read_vitc_line(ReadVitcContext *ctx, uint8_t *src, int line_size, int width, int height)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static unsigned bcd2uint(uint8_t high, uint8_t low)
static int config_props(AVFilterLink *inlink)
static uint8_t get_vitc_crc(uint8_t *line)
static uint8_t get_pit_avg3(uint8_t *line, int i)
static const AVOption readvitc_options[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.