[FFmpeg-devel] [PATCH] Add negate filter.

Alexander Strange astrange
Fri Dec 3 00:41:29 CET 2010


On Dec 2, 2010, at 6:38 PM, Jason Garrett-Glaser wrote:

> On Thu, Dec 2, 2010 at 3:08 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> On Thu, Dec 02, 2010 at 11:18:44PM +0100, Stefano Sabatini wrote:
>>> On date Thursday 2010-12-02 22:55:24 +0100, Michael Niedermayer encoded:
>>>> On Thu, Dec 02, 2010 at 08:45:24PM +0100, Stefano Sabatini wrote:
>>>>> On date Wednesday 2010-12-01 20:57:19 +0100, Stefano Sabatini encoded:
>>>>>> On date Wednesday 2010-12-01 03:25:47 +0100, Michael Niedermayer encoded:
>>>>>>> On Tue, Nov 30, 2010 at 11:22:43PM +0100, Stefano Sabatini wrote:
>>>>>>>>> From 3c16bf49c0f9f4c3c72d9eea49ae35a47d58d961 Mon Sep 17 00:00:00 2001
>>>>>>>>> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
>>>>>>>>> Date: Fri, 26 Nov 2010 17:31:11 +0100
>>>>>>>>> Subject: [PATCH] Add negate filter.
>>>>>>>>> 
>>>>>>>>> Ported from the libavfilter-soc repo with per-component negation
>>>>>>>>> addition.
>>>>>>>>> ---
>>>>>>>>>  doc/filters.texi         |   22 ++++++
>>>>>>>>>  libavfilter/Makefile     |    1 +
>>>>>>>>>  libavfilter/allfilters.c |    1 +
>>>>>>>>>  libavfilter/vf_negate.c  |  184 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>>  4 files changed, 208 insertions(+), 0 deletions(-)
>>>>>>>>>  create mode 100644 libavfilter/vf_negate.c
>>>>>>>> 
>>>>>>>> I'll apply in three days unless objections.
>>>>>>> 
>>>>>>> is it faster than using a LUT ?
>>>>>> 
>>>>>> 32246490 dezicycles in nolut, 1 runs, 0 skips
>>>>>> 27420150 dezicycles in nolut, 2 runs, 0 skips
>>>>>> 29323650 dezicycles in nolut, 4 runs, 0 skips
>>>>>> 36039801 dezicycles in nolut, 8 runs, 0 skips
>>>>>> 34124634 dezicycles in nolut, 16 runs, 0 skips
>>>>>> 39557091 dezicycles in nolut, 32 runs, 0 skips
>>>>>> 37006964 dezicycles in nolut, 64 runs, 0 skips
>>>>>> 37271243 dezicycles in nolut, 128 runs, 0 skips
>>>>>> 36437873 dezicycles in nolut, 256 runs, 0 skips
>>>>>> 37591370 dezicycles in nolut, 512 runs, 0 skips
>>>>>> 37119779 dezicycles in nolut, 1024 runs, 0 skips
>>>>>> 37390082 dezicycles in nolut, 2048 runs, 0 skips
>>>>>> 
>>>>>> 22483590 dezicycles in lut, 1 runs, 0 skips
>>>>>> 16486965 dezicycles in lut, 2 runs, 0 skips
>>>>>> 14703345 dezicycles in lut, 4 runs, 0 skips
>>>>>> 13340126 dezicycles in lut, 8 runs, 0 skips
>>>>>> 14286336 dezicycles in lut, 16 runs, 0 skips
>>>>>> 17345394 dezicycles in lut, 32 runs, 0 skips
>>>>>> 18178503 dezicycles in lut, 64 runs, 0 skips
>>>>>> 18047690 dezicycles in lut, 128 runs, 0 skips
>>>>>> 18159589 dezicycles in lut, 256 runs, 0 skips
>>>>>> 17833263 dezicycles in lut, 512 runs, 0 skips
>>>>>> 17624724 dezicycles in lut, 1024 runs, 0 skips
>>>>>> 17303343 dezicycles in lut, 2048 runs, 0 skips
>>>>>> 
>>>>>> Updated (with some simplifications).
>>>>> [...]
>>>>> 
>>>>> I'll apply in few days if there are no more comments.
>>>> 
>>>> There should be a vf_lut.c that does generic LUT based filtering and vf_negate
>>>> should use that filter
>>> 
>>> Do you mean apply_lut in libmpcodecs/vf_eq2.c? Why not to implement
>>> some lut in libmpcodecs/vf_geq.c?
>> 
>> We need a generic LUT filter, aka specify LUT entries and filter each pixel
>> 
>> We need a generic expression filter this is not implementable as LUT as the
>> filter can use any pixels from the input frame not just a 8bit sample but
>> like several megabytes. 2^(2^20) is too big for a LUT
> 
> See mt_lut for a good existing implementation (in Avisynth Masktools).
> They have both a 1D and 2D LUT (obviously not a 3D one, for the
> reason you mentioned).
> 
> Though, to be fair, for complex expressions, a 3D LUT might still be
> better than an expression filter.

http://manao4.free.fr/masktools-v2.0a46.zip

Note that, being an AviSynth filter, it's C++/MSVC asm/GPL.




More information about the ffmpeg-devel mailing list