36 #define LINE_DATA_SIZE 9
53 #define OFFSET(x) offsetof(ReadVitcContext, x)
54 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
57 {
"scan_max",
"maximum line numbers to scan for VITC data",
OFFSET(scan_max),
AV_OPT_TYPE_INT, {.i64 = 45 }, -1, INT_MAX,
FLAGS },
68 crc = 0x01 | (line[0] << 2);
69 crc ^= (line[0] >> 6) | 0x04 | (line[1] << 4);
70 crc ^= (line[1] >> 4) | 0x10 | (line[2] << 6);
71 crc ^= (line[2] >> 2) | 0x40;
73 crc ^= 0x01 | (line[4] << 2);
74 crc ^= (line[4] >> 6) | 0x04 | (line[5] << 4);
75 crc ^= (line[5] >> 4) | 0x10 | (line[6] << 6);
76 crc ^= (line[6] >> 2) | 0x40;
79 crc = (crc >> 2) | (crc << 6);
84 return ((line[i-1] + line[i] + line[i+1]) / 3);
90 int grp_index, pit_index;
99 for (y = 0; y <
height; y++) {
104 while ((x < width) && (grp_index < 9)) {
112 if ((grp_start_pos + ctx->
grp_width) > width)
115 if (pit_value < ctx->threshold_white)
117 x = grp_start_pos + ((ctx->
grp_width) / 10);
121 for (pit_index = 0; pit_index <= 7; pit_index++) {
122 x = grp_start_pos + (((pit_index+2)*ctx->
grp_width) / 10);
125 ctx->
line_data[grp_index] |= (1 << pit_index);
141 if (high > 9 || low > 9)
143 return 10*high + low;
148 unsigned hh =
bcd2uint(line[7] & 0x03, line[6] & 0x0f);
149 unsigned mm =
bcd2uint(line[5] & 0x07, line[4] & 0x0f);
150 unsigned ss =
bcd2uint(line[3] & 0x07, line[2] & 0x0f);
151 unsigned ff =
bcd2uint(line[1] & 0x03, line[0] & 0x0f);
152 unsigned drop = (line[1] & 0x04);
154 hh, mm, ss, drop ?
';' :
':', ff);
165 av_log(ctx,
AV_LOG_WARNING,
"Black color threshold is higher than white color threshold (%g > %g)\n",
170 av_log(ctx,
AV_LOG_DEBUG,
"threshold_black:%d threshold_white:%d threshold_gray:%d\n",
251 .description =
NULL_IF_CONFIG_SMALL(
"Read vertical interval timecode and write it to frame metadata."),
253 .priv_class = &readvitc_class,
This structure describes decoded (raw) audio or video data.
static int query_formats(AVFilterContext *ctx)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
static unsigned bcd2uint(uint8_t high, uint8_t low)
int h
agreed upon image height
static uint8_t get_pit_avg3(uint8_t *line, int i)
static uint8_t get_vitc_crc(uint8_t *line)
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
AVDictionary * metadata
metadata.
static char * make_vitc_tc_string(char *buf, uint8_t *line)
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
static const AVOption readvitc_options[]
AVFILTER_DEFINE_CLASS(readvitc)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
common internal API header
as above, but U and V bytes are swapped
#define ss(width, name, subs,...)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
char tcbuf[AV_TIMECODE_STR_SIZE]
uint8_t line_data[LINE_DATA_SIZE]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
static const AVFilterPad inputs[]
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int init(AVFilterContext *ctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int read_vitc_line(ReadVitcContext *ctx, uint8_t *src, int line_size, int width, int height)
static int config_props(AVFilterLink *inlink)
AVFilterContext * dst
dest filter
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static const AVFilterPad outputs[]
AVPixelFormat
Pixel format.
#define AV_TIMECODE_STR_SIZE