slippyr4 wrote:
Hi all,
My libav-using app captures select frames from a video source and packages
them in a propriatary format.
When the source video is interlaced, I have to deinterlace the video by
throwing away lines from the field I don't want, thus resulting in an image
one half of the vertical resolution. Whether I need the odd or the even
field varies. Currently, I implement this at the very last stage by
performing memcpy operation on the rgb colorspace frame data, after
sws_scale has converted from yuv422 -> rgb.
I now have a need to have the facility to crop, hflip and vflip frames.
Initially, libavfilter seems like a great tool to facilitate this. However,
it's hard to establish programatically which field of the picture i'd need
to keep after a chain of filters has worked on the frame.
The obvious solution to this problem is to implement a new filter which
deinterlaces in the way I want (ie by throwing away one field). This filter
could then be added at the front of the chain, and other filters added as
necessary.
Indeed.
However, having looked more at the nuts-and-bolts of the filter system, it
seems that the filters want to run on data in the same pix_fmt as the video
Only if you use avfilter_set_common_formats().
But, because of the chroma subsampling, this kind
of deinterlace is hard to do in this colorspace.
Try
static int query_formats(AVFilterContext *ctx)
{
if(ctx->inputs[0]) {
avfilter_formats_ref(avfilter_make_format_list(1,
PIX_FMT_YUV422P), &ctx->inputs[0]->out_formats);
}
if(ctx->outputs[0]) {
avfilter_formats_ref(avfilter_make_format_list(1,
PIX_FMT_YUV420P), &ctx->outputs[0]->in_formats);
}
return 0;
}
For example if you want your input as yuv422p and your output as
yuv422p. Note that if libavfilter always wanted
input_format==output_format, it would be impossible to implement, for
example, vf_scale (that actually does colorspace conversion).
-Vitor
PS: if you want to contribute after your filter to the ffmpeg project,
you can ask such questions at ffmpeg-soc mailing list (or even
ffmpeg-devel), where it will get more attention.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user