[FFmpeg-devel] [PATCH] lavfi: add xbr filter

Michael Niedermayer michaelni at gmx.at
Sun Oct 26 00:43:56 CEST 2014


On Sat, Oct 25, 2014 at 11:32:43PM +0530, arwa arif wrote:
> Can you please specify what is meant by stand-alone changes? Do I need to
> add the non-default functions in different commit? I am not very sure if I
> understood it right. Apart from that, I have updated the patch.
> 
> On Sat, Oct 25, 2014 at 10:16 PM, Nicolas George <george at nsup.org> wrote:
> 
> > Le quartidi 4 brumaire, an CCXXIII, arwa arif a écrit :
> > > > please post a new patch instead of a patch on top of a previous
> > > > patch
> > >  libavfilter/vf_xbr.c |  303
> > ++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 303 insertions(+)
> > >  create mode 100644 libavfilter/vf_xbr.c
> >
> > This patch does not contain the changes to Makefile and allfilters.c, so I
> > believe you still have a bit of tweaking to do with Git.
> >
> > If you used a branch (that is widely advisable), you should be able to type
> > this:
> >
> > git log --stat master..
> >
> > Then you should see a single commit, yours, with changes to Makefile,
> > allfilters.c and all other common files you needed to changes, and of
> > course
> > the new file(s).
> >
> > (If you have stand-alone changes, such as moving code into a shared
> > function
> > to use in your actual patch, then it should go in a separate commit. But it
> > does not seem to apply here.)
> >
> > Also, I suspect you forgot to add the documentation for the filter in
> > doc/filters.texi. A few words are enough, but at the very least let people
> > know what it does, because xbr looks like just three random letters -- not
> > your fault of course.
> >
> > Regards,
> >
> > --
> >   Nicolas George
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >

>  doc/filters.texi         |    7 +
>  libavfilter/Makefile     |    1 
>  libavfilter/allfilters.c |    1 
>  libavfilter/vf_xbr.c     |  303 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 312 insertions(+)
> a92794344ddf0d5d4ea3205091ee4a19699c5c06  0001-PATCH-lavfi-add-xbr-filter.patch
> From cf3a7a6bcb9735c6f6157f80da208c1c191b3e02 Mon Sep 17 00:00:00 2001
> From: Arwa Arif <arwaarif1994 at gmail.com>
> Date: Sat, 25 Oct 2014 22:04:51 +0530
> Subject: [PATCH] [PATCH]lavfi: add xbr filter
> 
> Makefile
> 
> allfilters.c
> 
> filters.texi
> ---
>  doc/filters.texi         |    7 ++
>  libavfilter/Makefile     |    1 +
>  libavfilter/allfilters.c |    1 +
>  libavfilter/vf_xbr.c     |  303 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 312 insertions(+)
>  create mode 100644 libavfilter/vf_xbr.c

I tried the filter but it segfaults
./ffplay matrixbench_mpeg2.mpg -vf xbr

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffcfff7700 (LWP 14880)]
0x00000000004b40c5 in d (in=0x7fffc85eb000, x1=-1, y1=576, x2=0, y2=577) at libavfilter/vf_xbr.c:49
49          int r2 = *(in->data[0] + y2 * in->linesize[0] + x2*3);
(gdb) bt
#0  0x00000000004b40c5 in d (in=0x7fffc85eb000, x1=-1, y1=576, x2=0, y2=577) at libavfilter/vf_xbr.c:49
#1  0x00000000004b49db in apply_edge_detection_rules (in=0x7fffc85eb000, out=0x7fffc85ead20, x=0, y=575) at libavfilter/vf_xbr.c:159
#2  0x00000000004b5173 in filter_frame (inlink=0x7fffc85a7800, in=0x7fffc85eb000) at libavfilter/vf_xbr.c:270
#3  0x0000000000444270 in ff_filter_frame_framed (link=0x7fffc85a7800, frame=0x7fffc85eb000) at libavfilter/avfilter.c:1103
#4  0x00000000004447c4 in ff_filter_frame (link=0x7fffc85a7800, frame=0x7fffc85eb000) at libavfilter/avfilter.c:1183
#5  0x00000000004a4aff in filter_frame (link=0x7fffc85a70a0, in=0x0) at libavfilter/vf_scale.c:530
#6  0x0000000000444270 in ff_filter_frame_framed (link=0x7fffc85a70a0, frame=0x7fffc85ead20) at libavfilter/avfilter.c:1103
#7  0x00000000004447c4 in ff_filter_frame (link=0x7fffc85a70a0, frame=0x7fffc85ead20) at libavfilter/avfilter.c:1183
#8  0x000000000044b1e3 in request_frame (link=0x7fffc85a70a0) at libavfilter/buffersrc.c:499
#9  0x000000000044212b in ff_request_frame (link=0x7fffc85a70a0) at libavfilter/avfilter.c:351
#10 0x0000000000442159 in ff_request_frame (link=0x7fffc85a7800) at libavfilter/avfilter.c:353
#11 0x0000000000442159 in ff_request_frame (link=0x7fffc85a71e0) at libavfilter/avfilter.c:353
#12 0x0000000000442159 in ff_request_frame (link=0x7fffc85a7680) at libavfilter/avfilter.c:353
#13 0x0000000000442159 in ff_request_frame (link=0x7fffc85a6c00) at libavfilter/avfilter.c:353
#14 0x0000000000448f1e in av_buffersink_get_frame_flags (ctx=0x7fffc85a6220, frame=0x7fffc80008c0, flags=0) at libavfilter/buffersink.c:137
#15 0x000000000041f526 in video_thread (arg=0x7fffeb1a7040) at ffplay.c:2168
#16 0x00007ffff64a6fd5 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
#17 0x00007ffff64ea999 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
#18 0x00007ffff006ae9a in start_thread (arg=0x7fffcfff7700) at pthread_create.c:308
#19 0x00007fffefd9831d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#20 0x0000000000000000 in ?? ()


[...]

> +const int THRESHHOLD_Y = 48;
> +const int THRESHHOLD_U = 7;
> +const int THRESHHOLD_V = 6;

these should be #define


> +
> +/**
> +* Calculates the weight of difference of the pixels, by transforming these
> +* pixels into their Y'UV parts. It then uses the threshold used by HQx filters:
> +* 48*Y + 7*U + 6*V, to give it those smooth looking edges.
> +**/
> +static int d(AVFrame *in,int x1,int y1,int x2,int y2){
> +
> +    int r1 = *(in->data[0] + y1 * in->linesize[0] + x1*3);
> +    int g1 = *(in->data[0] + y1 * in->linesize[0] + x1*3 + 1);
> +    int b1 = *(in->data[0] + y1 * in->linesize[0] + x1*3 + 2);
> +
> +    int r2 = *(in->data[0] + y2 * in->linesize[0] + x2*3);
> +    int g2 = *(in->data[0] + y2 * in->linesize[0] + x2*3 + 1);
> +    int b2 = *(in->data[0] + y2 * in->linesize[0] + x2*3 + 2);
> +
> +    int r = abs(r1 - r2);
> +    int g = abs(g1 - g2);
> +    int b = abs(b1 - b2);	
> +
> +    /*Convert RGB to Y'UV*/
> +    int y = ( (  66 * r + 129 * g +  25 * b + 128) >> 8) +  16; 
> +    int u = ( ( -38 * r -  74 * g + 112 * b + 128) >> 8) + 128;
> +    int v = ( ( 112 * r -  94 * g -  18 * b + 128) >> 8) + 128;
> +
> +    /*Add HQx filters threshold & return*/
> +    return (y * THRESHHOLD_Y) + (u* THRESHHOLD_U) + (v* THRESHHOLD_V);

the position of the abs() looks strange
if this is supposed to be a vector distance in yuv space then the
abs are needed on the yuv terms


[...]

> +    av_frame_copy_props(out, in);
> +    for(i=0;i<inlink->w;i++)
> +	for(j=0;j<inlink->h;j++)
> + 		apply_edge_detection_rules(in,out,i,j);    

tabs and trailing whitespace isnt allowed in ffmpeg git

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141026/99dbeac3/attachment.asc>


More information about the ffmpeg-devel mailing list