[vlc-commits] transform: inline the inner plane loops in the macro

Rémi Denis-Courmont git at videolan.org
Sat Mar 17 17:29:56 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 17 18:25:07 2012 +0200| [f963a92355f5e0640efafd3bacf6ea0370b28e0d] | committer: Rémi Denis-Courmont

transform: inline the inner plane loops in the macro

This enables GCC to inline the coordinate functions. Without this,
there was one function call per pixel component.

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

 modules/video_filter/transform.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/modules/video_filter/transform.c b/modules/video_filter/transform.c
index 9f6a751..0e887be 100644
--- a/modules/video_filter/transform.c
+++ b/modules/video_filter/transform.c
@@ -100,19 +100,18 @@ static void R270(int *sx, int *sy, int w, int h, int dx, int dy)
 }
 typedef void (*convert_t)(int *, int *, int, int, int, int);
 
-static void Planar(plane_t *dst, const plane_t *src, convert_t f)
-{
-    for (int y = 0; y < dst->i_visible_lines; y++) {
-        for (int x = 0; x < dst->i_visible_pitch; x++) {
-            int sx, sy;
-            f(&sx, &sy, dst->i_visible_pitch, dst->i_visible_lines, x, y);
-            dst->p_pixels[y * dst->i_pitch + x] = src->p_pixels[sy * src->i_pitch + sx];
-        }
-    }
-}
-
 #define PLANAR(f) \
-    static void Planar##f(plane_t *dst, const plane_t *src) { Planar(dst, src, f); }
+static void Planar##f(plane_t *dst, const plane_t *src) \
+{ \
+    for (int y = 0; y < dst->i_visible_lines; y++) { \
+        for (int x = 0; x < dst->i_visible_pitch; x++) { \
+            int sx, sy; \
+            (f)(&sx, &sy, dst->i_visible_pitch, dst->i_visible_lines, x, y); \
+            dst->p_pixels[y * dst->i_pitch + x] = \
+                src->p_pixels[sy * src->i_pitch + sx]; \
+        } \
+    } \
+}
 
 PLANAR(HFlip)
 PLANAR(VFlip)



More information about the vlc-commits mailing list