On 03.08.2018 19:46, Dan Dennedy wrote:
On Fri, Aug 3, 2018 at 10:23 AM Jean-Baptiste Mardelle <j...@kdenlive.org <mailto:j...@kdenlive.org>> wrote:

    Hi all,

I recently realized that the color producer always creates an alpha
    mask, and uses the rgba24a format by default.


Typically, it will receive a format from the downstream consumer services, and it will only choose this default if movit is used or mlt_image_none is received.


Hi Dan,

Thanks for your answer.


    In fact, unless the color has an alpha value under 255, it is
    unnecessary and we could simply use an rgb24 format, saving some
    memory.

    I am mostly interested in this because the qtblend transition
    checks if
    a producer has an alpha channel before deciding whether a
    compositing is
    required. Having a useless alpha channel on the color producer causes
    unnecessary compositing and slowdowns in this case. Would you be
    ok to
    change the color producer to use rgb24 or rgb24a formats depending on
    the alpha value ?


Only in the truly default case. If qtblend requests mlt_image_rgb24a and the color producer returns mlt_image_rgb24, then the image conversion filter will automatically convert it. That is slightly less efficient than directly returning what is requested.


Ok, I realize I didn't correctly analyze the situation. You are totally right that in most cases, the format will be determined by the consumer services. In fact, the optimization would be to only create the alpha mask if the consumer requests an rgba format or if the alpha is less than 255.

something like:

+       uint8_t *alpha = NULL;
+       if (color.a < 255 || *format == mlt_image_rgb24a) {
+               alpha = mlt_pool_alloc( alpha_size );
+       (...)


If the consumer requests yuv4222 and the color has no transparency, it doesn't make sense to create an alpha mask ?

For frei0r.cairoblend, I check every pixel's alpha until it sees one that is not 255. See transition_frei0r.c:is_opaque().

Sure but it seems to me that simply checking for the presence of an alpha mask would be much faster than checking every pixel of a frame..

Thanks & regards

Jean-Baptiste




    I can provide a patch if you think this is a welcome change.


    Best regards

    Jean-Baptiste


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to