[FFmpeg-devel] [PATCH] lavfi: port mcdeint filter from libmpcodecs

Stefano Sabatini stefasab at gmail.com
Thu May 30 15:36:09 CEST 2013


On date Tuesday 2013-05-28 15:40:43 +0200, Stefano Sabatini encoded:
[...]
> From b9f77bf3e9b51a3bdc093eca363e56a817bdfa75 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Tue, 28 May 2013 13:40:39 +0200
> Subject: [PATCH] lavfi: port mcdeint filter from libmpcodecs
> 
> TODO: bump minor, update changelog
> ---
>  LICENSE                  |    1 +
>  configure                |    1 +
>  doc/filters.texi         |   44 +++++++
>  libavfilter/Makefile     |    2 +
>  libavfilter/allfilters.c |    1 +
>  libavfilter/vf_mcdeint.c |  298 ++++++++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 347 insertions(+)
>  create mode 100644 libavfilter/vf_mcdeint.c

Updated mcdeint patch. I tracked the inconsistent output to
uninitialiazed buffer reading which happens in the CHECK(j) macro:

#define CHECK(j)\
    {   int score = FFABS(srcp[-srcs-1+(j)] - srcp[+srcs-1-(j)]) +\
                    FFABS(srcp[-srcs  +(j)] - srcp[+srcs  -(j)]) +\
                    FFABS(srcp[-srcs+1+(j)] - srcp[+srcs+1-(j)]);\
        if (score < spatial_score) {\
            spatial_score = score;\
            diff0 = filp[-fils+(j)] - srcp[-srcs+(j)];\
            diff1 = filp[+fils-(j)] - srcp[+srcs-(j)];

which is reading padded data if x<2 && x>=w-2, and out-of-buffer data
in case x=2 and y=1 or x=w-3 and y=h-1.

A possible way to fix it would be to change:
-                    if((x-2)+(y-1)*w>=0 && (x+2)+(y+1)*w<w*h){ //FIXME either alloc larger images or optimize this
+                    if(y>0 && y<h-1 && x>2 && x<w-3){

but Michael suggested to adopt the same logic used in yadif. I suspend
my port of mcdeint until the problem is fixed in libmpcodecs.

Note: CHECK(j) macro restored to initial form for consistency with
yadif code.
-- 
FFmpeg = Fundamental and Fantastic Mastodontic Perennial EnGine
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavfi-port-mcdeint-filter-from-libmpcodecs.patch
Type: text/x-diff
Size: 14545 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130530/c4753cde/attachment.bin>


More information about the ffmpeg-devel mailing list