Hello,

I would like that the delogo filter is improved by an alternative way of removing the logo. It's the "UGLARM" mode known from Virtual Dub's DeLogo filter and ffdshow. I used it many years (under Windows), but now moving to Linux miss it using ffmpeg as encoding tool.

Since an ffmpeg developer can probably add the code in a fragment of the time and more consistently than it would take me to add it, I'd like to hire someone to do so.

The code is just ~50 lines, and already available in c for ffdshow. I'd donate 50 EUR (PayPal) for someone adding it - hopefully into the normal production code for everyone to use. :) So if someone knows the delogo code / filter code and volunteers, let me know. :) I would be really glad if this could be done.


++ How does it work:

The algorith is called "UGLARM mode" and takes all pixels of the 1-pixel border of the box covering the logo into account to interpolate the inner pixels. Each pixel is taken into account according to an exponential value of the distance. The result is a more blurred and I find much more pleasing effect than the current xy-algorithm in ffmpgeg's delogo filter, which tends to show vertical and horizontal lines / crosses. Although the calculation takes more time than the xy-interpolation, this is absolutely not relevant compared to the video encoding time.

The code was impemented by myself ~15 years ago for the VirtualDub filter "LogoAway" by Chris Wojdon. It was taken over in the ffdshow Codec package for Windows.

"UGLARM" stands for "Uwe's Great LogoAway Remove Mode". :-) It was my not-so-serious answer to Chris about how we could name it. But the name was taken over in his filter and later ffdshow, where it's available until now.

++ How does it look:

See these examples:
http://www.fixya.com/support/r3995122-remove_logo_from_avi_mpg4_file_using
https://forum.videohelp.com/threads/260207-Remove-Spoilers-Logos-etc (search for "UGLARM" for the image).

++ Code to add:

I alreday took a look at the ffmpeg code and ffdshow code.
In ffdshow, you can find the functions in TimgFilterLogoaway.cpp:
https://sourceforge.net/p/ffdshow-tryout/code/HEAD/tree/trunk/src/imgFilters/TimgFilterLogoaway.cpp

In ffmpeg, it has to be added in libavfilter/vf_delogo.c, function apply_delogo.

Here's the relevant code to add (+ some config variable to set the mode I guess):

// Precalculate weights once.
void TimgFilterLogoaway::Tplane::calcUweWeightTable(int w, int h, int power)
{
    double e = 1.0 + (0.3 * power);
    int x;
    for (x = 0; x < w; x++)
        for (int y = 0; y < h; y++)
            if (x + y != 0) {
                double d = pow(sqrt(double(x * x + y * y)), e);
                uwetable[x + y * w] = 1.0 / d;
            } else {
                uwetable[x + y * w] = 1.0;
            }

    for (x = 1; x < w - 1; x++)
        for (int y = 1; y < h - 1; y++) {
            double weightsum = 0;
            for (int bx = 0; bx < w; bx++) {
                weightsum += uwetable[abs(bx - x) + y * w];
                weightsum += uwetable[abs(bx - x) + abs(h - 1 - y) * w];
            }
            for (int by = 1; by < h - 1; by++) {
                weightsum += uwetable[x + abs(by - y) * w];
                weightsum += uwetable[abs(w - 1 - x) + abs(by - y) * w];
            }
            uweweightsum[y * w + x] = weightsum;
        }
}

// apply filter
void TimgFilterLogoaway::Tplane::uwe(const TlogoawaySettings *cfg)
{
    if (!uwetable) {
        uwetable = (double*)aligned_malloc(w * h * sizeof(double));
        uweweightsum = (double*)aligned_malloc(w * h * sizeof(double));
        calcUweWeightTable(w, h, cfg->blur);
    }

    for (int x = 1; x < w - 1; x++)
        for (int y = 1; y < h - 1; y++) {
            double r = 0;
            const unsigned char *lineN = bordn, *lineS = bords;
            for (int bx = 0; bx < w; bx++) {
                r += lineN[bx] * uwetable[abs(bx - x) + y * w];
                r += lineS[bx] * uwetable[abs(bx - x) + abs(h - 1 - y) * w];
            }
            const unsigned char *lineW = bordw, *lineE = borde;
            for (int by = 1; by < h - 1; by++) {
                r += lineW[by] * uwetable[x + abs(by - y) * w];
                r += lineE[by] * uwetable[abs(w - 1 - x) + abs(by - y) * w];
            }
            logotempdata[y * logotempstride + x] = uint8_t(r / uweweightsum[y * w + x]);
        }

}


Regards,
Uwe

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to