[FFmpeg-devel] [PATCH 1/2 v2] avfilter: add readvitc filter

Tobias Rapp t.rapp at noa-archive.com
Fri Apr 8 12:10:50 CEST 2016


On 08.04.2016 11:23, Paul B Mahol wrote:
> On 4/8/16, Tobias Rapp <t.rapp at noa-archive.com> wrote:
>> Add a filter to scan the top lines of video frames for vertical interval
>> timecode (VITC) information and attach it as metadata keys.
>>
>> Signed-off-by: Tobias Rapp <t.rapp at noa-archive.com>
>> ---
 >>
>> [...]
 >>
>> +
>> +static int query_formats(AVFilterContext *ctx)
>> +{
>> +    static const enum AVPixelFormat pixel_fmts_eq[] = {
>> +        AV_PIX_FMT_GRAY8,
>> +        AV_PIX_FMT_YUV410P,
>> +        AV_PIX_FMT_YUV411P,
>> +        AV_PIX_FMT_YUV420P,
>> +        AV_PIX_FMT_YUV422P,
>> +        AV_PIX_FMT_YUV444P,
>
> AV_PIX_FMT_YUV440P? Also J variants...

Good catch, I was lazy and just copied the function from vf_eq.c. The 
updated patch should contain all pixel formats with planar 8bit luma 
component.

>> +        AV_PIX_FMT_NONE
>> +    };
>> +    AVFilterFormats *fmts_list = ff_make_format_list(pixel_fmts_eq);
>> +    if (!fmts_list)
>> +        return AVERROR(ENOMEM);
>> +    return ff_set_common_formats(ctx, fmts_list);
>> +}
>> +
>> +static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>> +{
>> +    AVFilterContext *ctx = inlink->dst;
>> +    AVFilterLink *outlink = ctx->outputs[0];
>> +    ReadVitcContext *s = ctx->priv;
>> +    int found;
>> +
>> +    found = read_vitc_line(s, frame->data[0], frame->linesize[0],
>> inlink->w, inlink->h);
>> +    av_dict_set(&frame->metadata, "lavfi.readvitc.found", (found ? "1" :
>> "0"), 0);
>> +    if (found)
>> +        av_dict_set(&frame->metadata, "lavfi.readvitc.tc_str",
>> make_vitc_tc_string(s->tcbuf, s->line_data), 0);
>> +
>> +    return ff_filter_frame(outlink, frame);
>> +}
>> +
>> +#if CONFIG_READVITC_FILTER
>
> Not needed.

Removed.

>> +
>> +static const AVFilterPad inputs[] = {
>> +    {
>> +        .name         = "default",
>> +        .type         = AVMEDIA_TYPE_VIDEO,
>> +        .filter_frame = filter_frame,
>> +        .config_props = config_props,
>> +    },
>> +    { NULL }
>> +};
>> +
>> +static const AVFilterPad outputs[] = {
>> +    {
>> +        .name = "default",
>> +        .type = AVMEDIA_TYPE_VIDEO,
>> +    },
>> +    { NULL }
>> +};
>> +
>> +AVFilter ff_vf_readvitc = {
>> +    .name          = "readvitc",
>> +    .description   = NULL_IF_CONFIG_SMALL("Read vertical interval timecode
>> and write it to frame metadata."),
>> +    .priv_size     = sizeof(ReadVitcContext),
>> +    .priv_class    = &readvitc_class,
>> +    .inputs        = inputs,
>> +    .outputs       = outputs,
>> +    .init          = init,
>> +    .query_formats = query_formats,
>> +};
>> +
>> +#endif /* CONFIG_READVITC_FILTER */
>
> Not needed.

Removed.

Thanks for the review,
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avfilter-add-readvitc-filter.patch
Type: text/x-patch
Size: 13634 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160408/ea0f209e/attachment.bin>


More information about the ffmpeg-devel mailing list