[FFmpeg-devel] Optimised math functions in FFMPEG?

Paul B Mahol onemda at gmail.com
Sun Aug 15 19:15:23 EEST 2021


On Sun, Aug 15, 2021 at 6:05 PM Paul Buxton <paulbuxton.mail at googlemail.com>
wrote:

> So construct filtergraph with
>
>    1. zscale with a linear transfer function
>    2. color correction filter (I am calling it underwater correction, but
>    nothing it does is actually specific to underwater images, it is simply
> a
>    grey world based algorithm for whitebalance).
>    3. zscale with desired output transfer function (probably BT709).
>
> Is it normal that someone needs to know the characteristics of the filter
> to such a degree that they know to apply the pre/post
> linearisation/de-linearisation to use it?
>
> Agree filter cannot recover red where none is present, but at recreational
> dive depths there is still some red present, and this does get the image
> closer to what you 'see' as a diver. I think the bigger problem with this
> approach is that for scenes where there is not much other color, it can
> wash out the color that is there.
> Compared to other algorithms, such as histogram equalisation it seems to
> perform pretty well and  without temporal instability which requires
> smoothing to correct.
>
> I can throw some comparison videos up on youtube if anyone is
> interested (when it finally finishes converting).
>
>
Better provide real unprocessed underwater videos.

I see no point in using different color space or floats if unprocessed
video source in need for filtering is 8bit depth YUV.


> I need to look into how the FATE testing stuff works and put together a
> test, and make sure everything else fits with coding guidelines before
> submittinga patch. But I think I would prefer to send the working floating
> point version before working on a performance optimised int varient, unless
> that would be against contribution guidelines..
>

Any patches are welcomed.


>
> Paul
>
>
> On Sun, Aug 15, 2021 at 4:09 PM Paul B Mahol <onemda at gmail.com> wrote:
>
> > On Sun, Aug 15, 2021 at 3:43 PM Paul Buxton <
> > paulbuxton.mail at googlemail.com>
> > wrote:
> >
> > > Thanks both.
> > >
> > > I have implemented the algorithm in this paper
> > >
> > >
> >
> https://www.researchgate.net/publication/275213614_A_New_Color_Correction_Method_for_Underwater_Imaging
> > >
> > > Which basically converts to an L A B (not CIELAB) colorspace, subtracts
> > the
> > > average value of the frame from each pixel and converts back.
> > >
> > > Yes I did put the linearisation /de-linearisation into the filter. Not
> > > applying it produces noticeably incorrect results. Is there instead a
> way
> > > to tell the filtergraph that the filter expects and outputs linear
> data?
> > >
> >
> > There is no automated thing yet, but for converting to/from linear use
> > zscale filter.
> >
> > Also if input is 8bit depth I doubt there can be recovered much if there
> is
> > no red component in video.
> > If input is in float that is completely different story....
> >
> >
> > >
> > > I can investigate an integer version.
> > >
> > >
> > > On Sun, Aug 15, 2021 at 2:31 PM Paul B Mahol <onemda at gmail.com> wrote:
> > >
> > > > On Sun, Aug 15, 2021 at 3:27 PM Nicolas George <george at nsup.org>
> > wrote:
> > > >
> > > > > Paul Buxton (12021-08-15):
> > > > > > I have my filter working nicely but it is a little slow. I have
> > > > > > parallelised it where possible, but it is still a bit heavy. I am
> > > > > wondering
> > > > > > if there are any optimised implementations/approximations of some
> > > math
> > > > > > functions built in that I should use instead of the standard
> > library
> > > > > > implementations.
> > > > > > Specifically any of
> > > > > > pow()
> > > > > > exp()
> > > > > > log()
> > > > > >
> > > > > > I have done a quick grep of the code but can't see any likely
> > > > contenders.
> > > > >
> > > > > I am not aware we have those. The kind of optimization you can do
> > > > > depends a lot on your use case. Please give a little details.
> > > > >
> > > > > If you want to speed your filter up, the best would be to make it
> > work
> > > > > with integers. It would also allow to make reliable unit tests.
> > > > >
> > > >
> > > >
> > > > If you convert to/from linear light inside filter, that is wrong
> thing
> > to
> > > > do.
> > > >
> > > >
> > > > >
> > > > > Regards,
> > > > >
> > > > > --
> > > > >   Nicolas George
> > > > > _______________________________________________
> > > > > ffmpeg-devel mailing list
> > > > > ffmpeg-devel at ffmpeg.org
> > > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > >
> > > > > To unsubscribe, visit link above, or email
> > > > > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> > > > >
> > > > _______________________________________________
> > > > ffmpeg-devel mailing list
> > > > ffmpeg-devel at ffmpeg.org
> > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > >
> > > > To unsubscribe, visit link above, or email
> > > > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> > > >
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel at ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> > >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list