Unexpectedly expensive conversion from BGRA to BGR

Nicolas Dufresne nicolas at ndufresne.ca
Sat Oct 17 14:38:05 UTC 2020


Le vendredi 16 octobre 2020 à 16:10 -0700, Tyler Compton a écrit :
> Hi everyone,
> 
> I have a pipeline that, at some point, needs to convert video frames from BGRA to BGR. I was surprised to see about a ~17% increase in CPU usage just from doing this conversion. I wouldn't expect it to be that expensive, considering it's just a matter of stripping off some data for each pixel.
> 
> In my application, I have BGRA frames, but never any actual alpha information. Is there perhaps an optimization opportunity because of that?
> 
> On average I see about 17% CPU usage when running this pipeline:
> 
> videotestsrc is-live=true ! "video/x-raw,format=BGRA,width=1920,height=1080,framerate=30/1" ! fakesink
> 
> However, I see around 38% CPU usage just by adding a videoconvert to go from BGRA to BGR:
> 
> videotestsrc is-live=true ! "video/x-raw,format=BGRA,width=1920,height=1080,framerate=30/1" ! videoconvert ! "video/x-raw,format=BGR" ! fakesink

This conversion will move 32bit aligned pixels to 24bits (unaligned)
pixels. Unaligned writes are 3 time slower. Unless you need the
bandwidth gain (even though yuv formats may give a better compression),
I would not recommending using 24bit packed formats in recent
applications. At least not when doing CPU access.

> 
> I'm running GStreamer 1.18.0 on Ubuntu 20.04.
> 
> Thanks,
> Tyler
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list