[vlc-commits] blend: compute left shifts from RGB masks

Rémi Denis-Courmont git at videolan.org
Mon Dec 17 18:46:15 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 17 19:30:18 2018 +0200| [8ffc863914708b383b20e05ea5568247645b9d1d] | committer: Rémi Denis-Courmont

blend: compute left shifts from RGB masks

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8ffc863914708b383b20e05ea5568247645b9d1d
---

 modules/video_filter/blend.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules/video_filter/blend.cpp b/modules/video_filter/blend.cpp
index d0df9cee0a..1acc4ad384 100644
--- a/modules/video_filter/blend.cpp
+++ b/modules/video_filter/blend.cpp
@@ -339,17 +339,22 @@ private:
 };
 
 class CPictureRGB16 : public CPicture {
+private:
+    unsigned rshift, gshift, bshift;
 public:
     CPictureRGB16(const CPicture &cfg) : CPicture(cfg)
     {
         data = CPicture::getLine<1>(0);
+        rshift = vlc_ctz(fmt->i_rmask);
+        gshift = vlc_ctz(fmt->i_gmask);
+        bshift = vlc_ctz(fmt->i_bmask);
     }
     void get(CPixel *px, unsigned dx, bool = true) const
     {
         const uint16_t data = *getPointer(dx);
-        px->i = (data & fmt->i_rmask) >> fmt->i_lrshift;
-        px->j = (data & fmt->i_gmask) >> fmt->i_lgshift;
-        px->k = (data & fmt->i_bmask) >> fmt->i_lbshift;
+        px->i = (data & fmt->i_rmask) >> rshift;
+        px->j = (data & fmt->i_gmask) >> gshift;
+        px->k = (data & fmt->i_bmask) >> bshift;
     }
     void merge(unsigned dx, const CPixel &spx, unsigned a, bool full)
     {
@@ -360,9 +365,9 @@ public:
         ::merge(&dpx.j, spx.j, a);
         ::merge(&dpx.k, spx.k, a);
 
-        *getPointer(dx) = (dpx.i << fmt->i_lrshift) |
-                          (dpx.j << fmt->i_lgshift) |
-                          (dpx.k << fmt->i_lbshift);
+        *getPointer(dx) = (dpx.i << rshift) |
+                          (dpx.j << gshift) |
+                          (dpx.k << bshift);
     }
     void nextLine()
     {



More information about the vlc-commits mailing list