videomixer: Update videoconvert code from -base
authorSebastian Dröge <sebastian@centricular.com>
Sat, 28 Jun 2014 14:48:13 +0000 (16:48 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 28 Jun 2014 14:56:18 +0000 (16:56 +0200)
And also rename the remaining symbols to prevent conflicts
during static linking.

https://bugzilla.gnome.org/show_bug.cgi?id=728443

gst/videomixer/gstcms.c
gst/videomixer/gstcms.h
gst/videomixer/videoconvert.c
gst/videomixer/videoconvert.h
gst/videomixer/videomixerorc.orc

index 96a9f70..c46bd56 100644 (file)
@@ -33,7 +33,7 @@
 /* our simple CMS */
 
 void
-color_xyY_to_XYZ (Color * c)
+videomixer_color_xyY_to_XYZ (Color * c)
 {
   if (c->v[1] == 0) {
     c->v[0] = 0;
@@ -51,7 +51,7 @@ color_xyY_to_XYZ (Color * c)
 }
 
 void
-color_XYZ_to_xyY (Color * c)
+videomixer_color_XYZ_to_xyY (Color * c)
 {
   double d;
   d = c->v[0] + c->v[1] + c->v[2];
@@ -71,7 +71,7 @@ color_XYZ_to_xyY (Color * c)
 }
 
 void
-color_set (Color * c, double x, double y, double z)
+videomixer_color_set (Color * c, double x, double y, double z)
 {
   c->v[0] = x;
   c->v[1] = y;
@@ -79,7 +79,7 @@ color_set (Color * c, double x, double y, double z)
 }
 
 void
-color_matrix_set_identity (ColorMatrix * m)
+videomixer_color_matrix_set_identity (ColorMatrix * m)
 {
   int i, j;
 
@@ -92,7 +92,7 @@ color_matrix_set_identity (ColorMatrix * m)
 
 /* Prettyprint a 4x4 matrix @m@ */
 void
-color_matrix_dump (ColorMatrix * m)
+videomixer_color_matrix_dump (ColorMatrix * m)
 {
   int i, j;
 
@@ -112,7 +112,8 @@ color_matrix_dump (ColorMatrix * m)
  *  - @dst@ may be a pointer to @a@ andor @b@
  */
 void
-color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b)
+videomixer_color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a,
+    ColorMatrix * b)
 {
   ColorMatrix tmp;
   int i, j, k;
@@ -131,7 +132,7 @@ color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b)
 }
 
 void
-color_matrix_apply (ColorMatrix * m, Color * dest, Color * src)
+videomixer_color_matrix_apply (ColorMatrix * m, Color * dest, Color * src)
 {
   int i;
   Color tmp;
@@ -148,32 +149,33 @@ color_matrix_apply (ColorMatrix * m, Color * dest, Color * src)
 }
 
 void
-color_matrix_offset_components (ColorMatrix * m, double a1, double a2,
-    double a3)
+videomixer_color_matrix_offset_components (ColorMatrix * m, double a1,
+    double a2, double a3)
 {
   ColorMatrix a;
 
-  color_matrix_set_identity (&a);
+  videomixer_color_matrix_set_identity (&a);
   a.m[0][3] = a1;
   a.m[1][3] = a2;
   a.m[2][3] = a3;
-  color_matrix_multiply (m, &a, m);
+  videomixer_color_matrix_multiply (m, &a, m);
 }
 
 void
-color_matrix_scale_components (ColorMatrix * m, double a1, double a2, double a3)
+videomixer_color_matrix_scale_components (ColorMatrix * m, double a1, double a2,
+    double a3)
 {
   ColorMatrix a;
 
-  color_matrix_set_identity (&a);
+  videomixer_color_matrix_set_identity (&a);
   a.m[0][0] = a1;
   a.m[1][1] = a2;
   a.m[2][2] = a3;
-  color_matrix_multiply (m, &a, m);
+  videomixer_color_matrix_multiply (m, &a, m);
 }
 
 void
-color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb)
+videomixer_color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb)
 {
   double Kg = 1.0 - Kr - Kb;
   ColorMatrix k = {
@@ -185,11 +187,11 @@ color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb)
         }
   };
 
-  color_matrix_multiply (m, &k, m);
+  videomixer_color_matrix_multiply (m, &k, m);
 }
 
 void
-color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb)
+videomixer_color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb)
 {
   double Kg = 1.0 - Kr - Kb;
   ColorMatrix k;
@@ -217,27 +219,28 @@ color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb)
   k.m[3][2] = 0;
   k.m[3][3] = 1;
 
-  color_matrix_multiply (m, &k, m);
+  videomixer_color_matrix_multiply (m, &k, m);
 }
 
 void
-color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst)
+videomixer_color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst)
 {
   /*
    * At this point, everything is in YCbCr
    * All components are in the range [0,255]
    */
-  color_matrix_set_identity (dst);
+  videomixer_color_matrix_set_identity (dst);
 
   /* offset required to get input video black to (0.,0.,0.) */
-  color_matrix_offset_components (dst, -16, -128, -128);
+  videomixer_color_matrix_offset_components (dst, -16, -128, -128);
 
   /* scale required to get input video black to (0.,0.,0.) */
-  color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0), (1 / 224.0));
+  videomixer_color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0),
+      (1 / 224.0));
 
   /* colour matrix, YCbCr -> RGB */
   /* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */
-  color_matrix_YCbCr_to_RGB (dst, 0.2990, 0.1140);      /* SD */
+  videomixer_color_matrix_YCbCr_to_RGB (dst, 0.2990, 0.1140);   /* SD */
 
   /*
    * We are now in RGB space
@@ -245,72 +248,73 @@ color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst)
 
 #if 0
   /* scale to output range. */
-  color_matrix_scale_components (dst, 255.0, 255.0, 255.0);
+  videomixer_color_matrix_scale_components (dst, 255.0, 255.0, 255.0);
 #endif
 }
 
 void
-color_matrix_build_bt709_to_bt601 (ColorMatrix * dst)
+videomixer_color_matrix_build_bt709_to_bt601 (ColorMatrix * dst)
 {
-  color_matrix_set_identity (dst);
+  videomixer_color_matrix_set_identity (dst);
 
   /* offset required to get input video black to (0.,0.,0.) */
-  color_matrix_offset_components (dst, -16, -128, -128);
+  videomixer_color_matrix_offset_components (dst, -16, -128, -128);
 
   /* scale required to get input video black to (0.,0.,0.) */
-  color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0), (1 / 224.0));
+  videomixer_color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0),
+      (1 / 224.0));
 
   /* colour matrix, YCbCr -> RGB */
   /* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */
-  color_matrix_YCbCr_to_RGB (dst, 0.2126, 0.0722);      /* HD */
+  videomixer_color_matrix_YCbCr_to_RGB (dst, 0.2126, 0.0722);   /* HD */
 
-  color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140);      /* SD */
+  videomixer_color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140);   /* SD */
 
-  color_matrix_scale_components (dst, 219.0, 224.0, 224.0);
+  videomixer_color_matrix_scale_components (dst, 219.0, 224.0, 224.0);
 
-  color_matrix_offset_components (dst, 16, 128, 128);
+  videomixer_color_matrix_offset_components (dst, 16, 128, 128);
 }
 
 void
-color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst)
+videomixer_color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst)
 {
-  color_matrix_set_identity (dst);
+  videomixer_color_matrix_set_identity (dst);
 
-  color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140);      /* SD */
+  videomixer_color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140);   /* SD */
 
-  color_matrix_scale_components (dst, 219.0, 224.0, 224.0);
+  videomixer_color_matrix_scale_components (dst, 219.0, 224.0, 224.0);
 
-  color_matrix_offset_components (dst, 16, 128, 128);
+  videomixer_color_matrix_offset_components (dst, 16, 128, 128);
 
   {
     Color c;
     int i;
     for (i = 7; i >= 0; i--) {
-      color_set (&c, (i & 2) ? 0.75 : 0.0, (i & 4) ? 0.75 : 0.0,
+      videomixer_color_set (&c, (i & 2) ? 0.75 : 0.0, (i & 4) ? 0.75 : 0.0,
           (i & 1) ? 0.75 : 0.0);
-      color_matrix_apply (dst, &c, &c);
+      videomixer_color_matrix_apply (dst, &c, &c);
       g_print ("  { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]),
           rint (c.v[2]));
     }
-    color_set (&c, -0.075, -0.075, -0.075);
-    color_matrix_apply (dst, &c, &c);
+    videomixer_color_set (&c, -0.075, -0.075, -0.075);
+    videomixer_color_matrix_apply (dst, &c, &c);
     g_print ("  { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]),
         rint (c.v[2]));
-    color_set (&c, 0.075, 0.075, 0.075);
-    color_matrix_apply (dst, &c, &c);
+    videomixer_color_set (&c, 0.075, 0.075, 0.075);
+    videomixer_color_matrix_apply (dst, &c, &c);
     g_print ("  { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]),
         rint (c.v[2]));
   }
 }
 
 void
-color_matrix_invert (ColorMatrix * m)
+videomixer_color_matrix_invert (ColorMatrix * m)
 {
   ColorMatrix tmp;
   int i, j;
   double det;
 
-  color_matrix_set_identity (&tmp);
+  videomixer_color_matrix_set_identity (&tmp);
   for (j = 0; j < 3; j++) {
     for (i = 0; i < 3; i++) {
       tmp.m[j][i] =
@@ -330,18 +334,18 @@ color_matrix_invert (ColorMatrix * m)
 }
 
 void
-color_matrix_copy (ColorMatrix * dest, ColorMatrix * src)
+videomixer_color_matrix_copy (ColorMatrix * dest, ColorMatrix * src)
 {
   memcpy (dest, src, sizeof (ColorMatrix));
 }
 
 void
-color_matrix_transpose (ColorMatrix * m)
+videomixer_color_matrix_transpose (ColorMatrix * m)
 {
   int i, j;
   ColorMatrix tmp;
 
-  color_matrix_set_identity (&tmp);
+  videomixer_color_matrix_set_identity (&tmp);
   for (i = 0; i < 3; i++) {
     for (j = 0; j < 3; j++) {
       tmp.m[i][j] = m->m[j][i];
@@ -351,23 +355,23 @@ color_matrix_transpose (ColorMatrix * m)
 }
 
 void
-color_matrix_build_XYZ (ColorMatrix * dst,
+videomixer_color_matrix_build_XYZ (ColorMatrix * dst,
     double rx, double ry,
     double gx, double gy, double bx, double by, double wx, double wy)
 {
   Color r, g, b, w, scale;
   ColorMatrix m;
 
-  color_set (&r, rx, ry, 1.0);
-  color_xyY_to_XYZ (&r);
-  color_set (&g, gx, gy, 1.0);
-  color_xyY_to_XYZ (&g);
-  color_set (&b, bx, by, 1.0);
-  color_xyY_to_XYZ (&b);
-  color_set (&w, wx, wy, 1.0);
-  color_xyY_to_XYZ (&w);
+  videomixer_color_set (&r, rx, ry, 1.0);
+  videomixer_color_xyY_to_XYZ (&r);
+  videomixer_color_set (&g, gx, gy, 1.0);
+  videomixer_color_xyY_to_XYZ (&g);
+  videomixer_color_set (&b, bx, by, 1.0);
+  videomixer_color_xyY_to_XYZ (&b);
+  videomixer_color_set (&w, wx, wy, 1.0);
+  videomixer_color_xyY_to_XYZ (&w);
 
-  color_matrix_set_identity (dst);
+  videomixer_color_matrix_set_identity (dst);
 
   dst->m[0][0] = r.v[0];
   dst->m[0][1] = r.v[1];
@@ -379,13 +383,13 @@ color_matrix_build_XYZ (ColorMatrix * dst,
   dst->m[2][1] = b.v[1];
   dst->m[2][2] = b.v[2];
 
-  color_matrix_dump (dst);
-  color_matrix_copy (&m, dst);
-  color_matrix_invert (&m);
-  color_matrix_dump (&m);
+  videomixer_color_matrix_dump (dst);
+  videomixer_color_matrix_copy (&m, dst);
+  videomixer_color_matrix_invert (&m);
+  videomixer_color_matrix_dump (&m);
 
-  color_matrix_transpose (&m);
-  color_matrix_apply (&m, &scale, &w);
+  videomixer_color_matrix_transpose (&m);
+  videomixer_color_matrix_apply (&m, &scale, &w);
   g_print ("%g %g %g\n", scale.v[0], scale.v[1], scale.v[2]);
 
   dst->m[0][0] = r.v[0] * scale.v[0];
@@ -398,54 +402,54 @@ color_matrix_build_XYZ (ColorMatrix * dst,
   dst->m[2][1] = b.v[1] * scale.v[2];
   dst->m[2][2] = b.v[2] * scale.v[2];
 
-  color_matrix_transpose (dst);
-  color_matrix_dump (dst);
+  videomixer_color_matrix_transpose (dst);
+  videomixer_color_matrix_dump (dst);
 
-  color_set (&scale, 1, 1, 1);
-  color_matrix_apply (dst, &scale, &scale);
-  color_XYZ_to_xyY (&scale);
+  videomixer_color_set (&scale, 1, 1, 1);
+  videomixer_color_matrix_apply (dst, &scale, &scale);
+  videomixer_color_XYZ_to_xyY (&scale);
   g_print ("white %g %g %g\n", scale.v[0], scale.v[1], scale.v[2]);
 
 }
 
 void
-color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst)
+videomixer_color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst)
 {
   /* SMPTE C primaries, SMPTE 170M-2004 */
-  color_matrix_build_XYZ (dst,
+  videomixer_color_matrix_build_XYZ (dst,
       0.630, 0.340, 0.310, 0.595, 0.155, 0.070, 0.3127, 0.3290);
 #if 0
   /* NTSC 1953 primaries, SMPTE 170M-2004 */
-  color_matrix_build_XYZ (dst,
+  videomixer_color_matrix_build_XYZ (dst,
       0.67, 0.33, 0.21, 0.71, 0.14, 0.08, 0.3127, 0.3290);
 #endif
 }
 
 void
-color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst)
+videomixer_color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst)
 {
   /* Rec. ITU-R BT.709-5 */
-  color_matrix_build_XYZ (dst,
+  videomixer_color_matrix_build_XYZ (dst,
       0.640, 0.330, 0.300, 0.600, 0.150, 0.060, 0.3127, 0.3290);
 }
 
 void
-color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst)
+videomixer_color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst)
 {
   /* Dell monitor */
 #if 1
-  color_matrix_build_XYZ (dst,
+  videomixer_color_matrix_build_XYZ (dst,
       0.662, 0.329, 0.205, 0.683, 0.146, 0.077, 0.3135, 0.3290);
 #endif
 #if 0
-  color_matrix_build_XYZ (dst,
+  videomixer_color_matrix_build_XYZ (dst,
       0.630, 0.340, 0.310, 0.595, 0.155, 0.070, 0.3127, 0.3290);
 #endif
-  color_matrix_invert (dst);
+  videomixer_color_matrix_invert (dst);
 }
 
 void
-color_transfer_function_apply (Color * dest, Color * src)
+videomixer_color_transfer_function_apply (Color * dest, Color * src)
 {
   int i;
 
@@ -459,7 +463,7 @@ color_transfer_function_apply (Color * dest, Color * src)
 }
 
 void
-color_transfer_function_unapply (Color * dest, Color * src)
+videomixer_color_transfer_function_unapply (Color * dest, Color * src)
 {
   int i;
 
@@ -473,7 +477,7 @@ color_transfer_function_unapply (Color * dest, Color * src)
 }
 
 void
-color_gamut_clamp (Color * dest, Color * src)
+videomixer_color_gamut_clamp (Color * dest, Color * src)
 {
   dest->v[0] = CLAMP (src->v[0], 0.0, 1.0);
   dest->v[1] = CLAMP (src->v[1], 0.0, 1.0);
@@ -497,10 +501,10 @@ get_color_transform_table (void)
     guint8 *table_v;
     int y, u, v;
 
-    color_matrix_build_yuv_to_rgb_601 (&bt601_to_rgb);
-    color_matrix_build_rgb_to_yuv_601 (&bt601_to_yuv);
-    color_matrix_build_rgb_to_XYZ_601 (&bt601_rgb_to_XYZ);
-    color_matrix_build_XYZ_to_rgb_dell (&dell_XYZ_to_rgb);
+    videomixer_color_matrix_build_yuv_to_rgb_601 (&bt601_to_rgb);
+    videomixer_color_matrix_build_rgb_to_yuv_601 (&bt601_to_yuv);
+    videomixer_color_matrix_build_rgb_to_XYZ_601 (&bt601_rgb_to_XYZ);
+    videomixer_color_matrix_build_XYZ_to_rgb_dell (&dell_XYZ_to_rgb);
 
     color_transform_table = g_malloc (0x1000000 * 3);
 
@@ -516,14 +520,14 @@ get_color_transform_table (void)
           c.v[0] = y;
           c.v[1] = u;
           c.v[2] = v;
-          color_matrix_apply (&bt601_to_rgb, &c, &c);
+          videomixer_color_matrix_apply (&bt601_to_rgb, &c, &c);
           color_gamut_clamp (&c, &c);
           color_transfer_function_apply (&c, &c);
-          color_matrix_apply (&bt601_rgb_to_XYZ, &c, &c);
-          color_matrix_apply (&dell_XYZ_to_rgb, &c, &c);
+          videomixer_color_matrix_apply (&bt601_rgb_to_XYZ, &c, &c);
+          videomixer_color_matrix_apply (&dell_XYZ_to_rgb, &c, &c);
           color_transfer_function_unapply (&c, &c);
           color_gamut_clamp (&c, &c);
-          color_matrix_apply (&bt601_to_yuv, &c, &c);
+          videomixer_color_matrix_apply (&bt601_to_yuv, &c, &c);
 
           table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]);
           table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]);
@@ -541,7 +545,7 @@ get_color_transform_table (void)
     guint8 *table_v;
     int y, u, v;
 
-    color_matrix_build_bt709_to_bt601 (&bt709_to_bt601);
+    videomixer_color_matrix_build_bt709_to_bt601 (&bt709_to_bt601);
 
     color_transform_table = g_malloc (0x1000000 * 3);
 
@@ -557,7 +561,7 @@ get_color_transform_table (void)
           c.v[0] = y;
           c.v[1] = u;
           c.v[2] = v;
-          color_matrix_apply (&bt709_to_bt601, &c, &c);
+          videomixer_color_matrix_apply (&bt709_to_bt601, &c, &c);
 
           table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]);
           table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]);
index f926a44..7cc5d5a 100644 (file)
@@ -37,33 +37,33 @@ struct _ColorMatrix
   double m[4][4];
 };
 
-void color_xyY_to_XYZ (Color * c);
-void color_XYZ_to_xyY (Color * c);
-void color_set (Color * c, double x, double y, double z);
-void color_matrix_set_identity (ColorMatrix * m);
-void color_matrix_dump (ColorMatrix * m);
-void color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b);
-void color_matrix_apply (ColorMatrix * m, Color * dest, Color * src);
-void color_matrix_offset_components (ColorMatrix * m, double a1, double a2,
+void videomixer_color_xyY_to_XYZ (Color * c);
+void videomixer_color_XYZ_to_xyY (Color * c);
+void videomixer_color_set (Color * c, double x, double y, double z);
+void videomixer_color_matrix_set_identity (ColorMatrix * m);
+void videomixer_color_matrix_dump (ColorMatrix * m);
+void videomixer_color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b);
+void videomixer_color_matrix_apply (ColorMatrix * m, Color * dest, Color * src);
+void videomixer_color_matrix_offset_components (ColorMatrix * m, double a1, double a2,
     double a3);
-void color_matrix_scale_components (ColorMatrix * m, double a1, double a2, double a3);
-void color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb);
-void color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb);
-void color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst);
-void color_matrix_build_bt709_to_bt601 (ColorMatrix * dst);
-void color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst);
-void color_matrix_invert (ColorMatrix * m);
-void color_matrix_copy (ColorMatrix * dest, ColorMatrix * src);
-void color_matrix_transpose (ColorMatrix * m);
-void color_matrix_build_XYZ (ColorMatrix * dst,
+void videomixer_color_matrix_scale_components (ColorMatrix * m, double a1, double a2, double a3);
+void videomixer_color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb);
+void videomixer_color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb);
+void videomixer_color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst);
+void videomixer_color_matrix_build_bt709_to_bt601 (ColorMatrix * dst);
+void videomixer_color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst);
+void videomixer_color_matrix_invert (ColorMatrix * m);
+void videomixer_color_matrix_copy (ColorMatrix * dest, ColorMatrix * src);
+void videomixer_color_matrix_transpose (ColorMatrix * m);
+void videomixer_color_matrix_build_XYZ (ColorMatrix * dst,
     double rx, double ry,
     double gx, double gy, double bx, double by, double wx, double wy);
-void color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst);
-void color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst);
-void color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst);
-void color_transfer_function_apply (Color * dest, Color * src);
-void color_transfer_function_unapply (Color * dest, Color * src);
-void color_gamut_clamp (Color * dest, Color * src);
+void videomixer_color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst);
+void videomixer_color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst);
+void videomixer_color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst);
+void videomixer_color_transfer_function_apply (Color * dest, Color * src);
+void videomixer_color_transfer_function_unapply (Color * dest, Color * src);
+void videomixer_color_gamut_clamp (Color * dest, Color * src);
 
 G_END_DECLS
 
index 53e192d..05565d7 100644 (file)
 #include "videomixerorc.h"
 
 
-static void videomixer_videoconvert_convert_generic (VideoConvert * convert,
+static void videoconvert_convert_generic (VideoConvert * convert,
     GstVideoFrame * dest, const GstVideoFrame * src);
-static void videomixer_videoconvert_convert_matrix8 (VideoConvert * convert,
+static void videoconvert_convert_matrix8 (VideoConvert * convert,
     gpointer pixels);
-static void videomixer_videoconvert_convert_matrix16 (VideoConvert * convert,
+static void videoconvert_convert_matrix16 (VideoConvert * convert,
     gpointer pixels);
-static gboolean videomixer_videoconvert_convert_lookup_fastpath (VideoConvert *
-    convert);
-static gboolean videomixer_videoconvert_convert_compute_matrix (VideoConvert *
-    convert);
-static gboolean videomixer_videoconvert_convert_compute_resample (VideoConvert *
-    convert);
-static void videomixer_videoconvert_dither_verterr (VideoConvert * convert,
+static gboolean videoconvert_convert_lookup_fastpath (VideoConvert * convert);
+static gboolean videoconvert_convert_compute_matrix (VideoConvert * convert);
+static gboolean videoconvert_convert_compute_resample (VideoConvert * convert);
+static void videoconvert_dither_verterr (VideoConvert * convert,
     guint16 * pixels, int j);
-static void videomixer_videoconvert_dither_halftone (VideoConvert * convert,
+static void videoconvert_dither_halftone (VideoConvert * convert,
     guint16 * pixels, int j);
 
 
@@ -65,12 +62,12 @@ videomixer_videoconvert_convert_new (GstVideoInfo * in_info,
   convert->width = GST_VIDEO_INFO_WIDTH (in_info);
   convert->height = GST_VIDEO_INFO_HEIGHT (in_info);
 
-  if (!videomixer_videoconvert_convert_lookup_fastpath (convert)) {
-    convert->convert = videomixer_videoconvert_convert_generic;
-    if (!videomixer_videoconvert_convert_compute_matrix (convert))
+  if (!videoconvert_convert_lookup_fastpath (convert)) {
+    convert->convert = videoconvert_convert_generic;
+    if (!videoconvert_convert_compute_matrix (convert))
       goto no_convert;
 
-    if (!videomixer_videoconvert_convert_compute_resample (convert))
+    if (!videoconvert_convert_compute_resample (convert))
       goto no_convert;
   }
 
@@ -116,10 +113,10 @@ videomixer_videoconvert_convert_set_dither (VideoConvert * convert, int type)
       convert->dither16 = NULL;
       break;
     case 1:
-      convert->dither16 = videomixer_videoconvert_dither_verterr;
+      convert->dither16 = videoconvert_dither_verterr;
       break;
     case 2:
-      convert->dither16 = videomixer_videoconvert_dither_halftone;
+      convert->dither16 = videoconvert_dither_halftone;
       break;
   }
 }
@@ -135,8 +132,7 @@ videomixer_videoconvert_convert_convert (VideoConvert * convert,
 #define SCALE_F  ((float) (1 << SCALE))
 
 static void
-videomixer_videoconvert_convert_matrix8 (VideoConvert * convert,
-    gpointer pixels)
+videoconvert_convert_matrix8 (VideoConvert * convert, gpointer pixels)
 {
   int i;
   int r, g, b;
@@ -162,8 +158,7 @@ videomixer_videoconvert_convert_matrix8 (VideoConvert * convert,
 }
 
 static void
-videomixer_videoconvert_convert_matrix16 (VideoConvert * convert,
-    gpointer pixels)
+videoconvert_convert_matrix16 (VideoConvert * convert, gpointer pixels)
 {
   int i;
   int r, g, b;
@@ -222,7 +217,7 @@ get_Kr_Kb (GstVideoColorMatrix matrix, gdouble * Kr, gdouble * Kb)
 }
 
 static gboolean
-videomixer_videoconvert_convert_compute_matrix (VideoConvert * convert)
+videoconvert_convert_compute_matrix (VideoConvert * convert)
 {
   GstVideoInfo *in_info, *out_info;
   ColorMatrix dst;
@@ -262,7 +257,7 @@ videomixer_videoconvert_convert_compute_matrix (VideoConvert * convert)
   /* calculate intermediate format for the matrix. When unpacking, we expand
    * input to 16 when one of the inputs is 16 bits */
   if (convert->in_bits == 16 || convert->out_bits == 16) {
-    convert->matrix = videomixer_videoconvert_convert_matrix16;
+    convert->matrix = videoconvert_convert_matrix16;
 
     if (GST_VIDEO_FORMAT_INFO_IS_RGB (suinfo))
       suinfo = gst_video_format_get_info (GST_VIDEO_FORMAT_ARGB64);
@@ -274,22 +269,24 @@ videomixer_videoconvert_convert_compute_matrix (VideoConvert * convert)
     else
       duinfo = gst_video_format_get_info (GST_VIDEO_FORMAT_AYUV64);
   } else {
-    convert->matrix = videomixer_videoconvert_convert_matrix8;
+    convert->matrix = videoconvert_convert_matrix8;
   }
 
-  color_matrix_set_identity (&dst);
+  videomixer_color_matrix_set_identity (&dst);
 
   /* 1, bring color components to [0..1.0] range */
   gst_video_color_range_offsets (in_info->colorimetry.range, suinfo, offset,
       scale);
-  color_matrix_offset_components (&dst, -offset[0], -offset[1], -offset[2]);
 
-  color_matrix_scale_components (&dst, 1 / ((float) scale[0]),
+  videomixer_color_matrix_offset_components (&dst, -offset[0], -offset[1],
+      -offset[2]);
+
+  videomixer_color_matrix_scale_components (&dst, 1 / ((float) scale[0]),
       1 / ((float) scale[1]), 1 / ((float) scale[2]));
 
   /* 2. bring components to R'G'B' space */
   if (get_Kr_Kb (in_info->colorimetry.matrix, &Kr, &Kb))
-    color_matrix_YCbCr_to_RGB (&dst, Kr, Kb);
+    videomixer_color_matrix_YCbCr_to_RGB (&dst, Kr, Kb);
 
   /* 3. inverse transfer function. R'G'B' to linear RGB */
 
@@ -301,18 +298,20 @@ videomixer_videoconvert_convert_compute_matrix (VideoConvert * convert)
 
   /* 7. bring components to YCbCr space */
   if (get_Kr_Kb (out_info->colorimetry.matrix, &Kr, &Kb))
-    color_matrix_RGB_to_YCbCr (&dst, Kr, Kb);
+    videomixer_color_matrix_RGB_to_YCbCr (&dst, Kr, Kb);
 
   /* 8, bring color components to nominal range */
   gst_video_color_range_offsets (out_info->colorimetry.range, duinfo, offset,
       scale);
-  color_matrix_scale_components (&dst, (float) scale[0], (float) scale[1],
-      (float) scale[2]);
 
-  color_matrix_offset_components (&dst, offset[0], offset[1], offset[2]);
+  videomixer_color_matrix_scale_components (&dst, (float) scale[0],
+      (float) scale[1], (float) scale[2]);
+
+  videomixer_color_matrix_offset_components (&dst, offset[0], offset[1],
+      offset[2]);
 
   /* because we're doing fixed point matrix coefficients */
-  color_matrix_scale_components (&dst, SCALE_F, SCALE_F, SCALE_F);
+  videomixer_color_matrix_scale_components (&dst, SCALE_F, SCALE_F, SCALE_F);
 
   for (i = 0; i < 4; i++)
     for (j = 0; j < 4; j++)
@@ -345,8 +344,7 @@ no_pack_func:
 }
 
 static void
-videomixer_videoconvert_dither_verterr (VideoConvert * convert,
-    guint16 * pixels, int j)
+videoconvert_dither_verterr (VideoConvert * convert, guint16 * pixels, int j)
 {
   int i;
   guint16 *errline = convert->errline;
@@ -362,8 +360,7 @@ videomixer_videoconvert_dither_verterr (VideoConvert * convert,
 }
 
 static void
-videomixer_videoconvert_dither_halftone (VideoConvert * convert,
-    guint16 * pixels, int j)
+videoconvert_dither_halftone (VideoConvert * convert, guint16 * pixels, int j)
 {
   int i;
   static guint16 halftone[8][8] = {
@@ -398,7 +395,7 @@ alloc_tmplines (VideoConvert * convert, guint lines, gint width)
 }
 
 static gboolean
-videomixer_videoconvert_convert_compute_resample (VideoConvert * convert)
+videoconvert_convert_compute_resample (VideoConvert * convert)
 {
   GstVideoInfo *in_info, *out_info;
   const GstVideoFormatInfo *sfinfo, *dfinfo;
@@ -494,8 +491,8 @@ convert_to8 (gpointer line, gint width)
       frame->info.chroma_site, line, width);
 
 static void
-videomixer_videoconvert_convert_generic (VideoConvert * convert,
-    GstVideoFrame * dest, const GstVideoFrame * src)
+videoconvert_convert_generic (VideoConvert * convert, GstVideoFrame * dest,
+    const GstVideoFrame * src)
 {
   int j, k;
   gint width, height, lines, max_lines;
@@ -1210,7 +1207,9 @@ convert_AYUV_ARGB (VideoConvert * convert, GstVideoFrame * dest,
 
   videomixer_video_convert_orc_convert_AYUV_ARGB (FRAME_GET_LINE (dest, 0),
       FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0),
-      FRAME_GET_STRIDE (src), width, height);
+      FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2],
+      convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2],
+      width, height);
 }
 
 static void
@@ -1222,7 +1221,9 @@ convert_AYUV_BGRA (VideoConvert * convert, GstVideoFrame * dest,
 
   videomixer_video_convert_orc_convert_AYUV_BGRA (FRAME_GET_LINE (dest, 0),
       FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0),
-      FRAME_GET_STRIDE (src), width, height);
+      FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2],
+      convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2],
+      width, height);
 }
 
 static void
@@ -1234,7 +1235,9 @@ convert_AYUV_ABGR (VideoConvert * convert, GstVideoFrame * dest,
 
   videomixer_video_convert_orc_convert_AYUV_ABGR (FRAME_GET_LINE (dest, 0),
       FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0),
-      FRAME_GET_STRIDE (src), width, height);
+      FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2],
+      convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2],
+      width, height);
 }
 
 static void
@@ -1246,7 +1249,9 @@ convert_AYUV_RGBA (VideoConvert * convert, GstVideoFrame * dest,
 
   videomixer_video_convert_orc_convert_AYUV_RGBA (FRAME_GET_LINE (dest, 0),
       FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0),
-      FRAME_GET_STRIDE (src), width, height);
+      FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2],
+      convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2],
+      width, height);
 }
 
 static void
@@ -1260,7 +1265,10 @@ convert_I420_BGRA (VideoConvert * convert, GstVideoFrame * dest,
   for (i = 0; i < height; i++) {
     videomixer_video_convert_orc_convert_I420_BGRA (FRAME_GET_LINE (dest, i),
         FRAME_GET_Y_LINE (src, i),
-        FRAME_GET_U_LINE (src, i >> 1), FRAME_GET_V_LINE (src, i >> 1), width);
+        FRAME_GET_U_LINE (src, i >> 1), FRAME_GET_V_LINE (src, i >> 1),
+        convert->cmatrix[0][0], convert->cmatrix[0][2],
+        convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2],
+        width);
   }
 }
 #endif
@@ -1277,6 +1285,7 @@ typedef struct
   GstVideoColorMatrix out_matrix;
   gboolean keeps_color_matrix;
   gboolean keeps_interlaced;
+  gboolean needs_color_matrix;
   gint width_align, height_align;
   void (*convert) (VideoConvert * convert, GstVideoFrame * dest,
       const GstVideoFrame * src);
@@ -1284,123 +1293,170 @@ typedef struct
 
 static const VideoTransform transforms[] = {
   {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_I420_YUY2},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_I420_YUY2},
   {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_I420_UYVY},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_I420_UYVY},
   {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_I420_AYUV},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_I420_AYUV},
   {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 0, 0, convert_I420_Y42B},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0,
+      convert_I420_Y42B},
   {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 0, 0, convert_I420_Y444},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0,
+      convert_I420_Y444},
 
   {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_I420_YUY2},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_I420_YUY2},
   {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_I420_UYVY},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_I420_UYVY},
   {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_I420_AYUV},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_I420_AYUV},
   {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 0, 0, convert_I420_Y42B},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0,
+      convert_I420_Y42B},
   {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 0, 0, convert_I420_Y444},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0,
+      convert_I420_Y444},
 
   {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_YUY2_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_YUY2_I420},
   {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_YUY2_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_YUY2_I420},
   {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_YUY2},     /* alias */
+      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, convert_UYVY_YUY2},      /* alias */
   {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_YUY2_AYUV},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_YUY2_AYUV},
   {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_YUY2_Y42B},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_YUY2_Y42B},
   {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_YUY2_Y444},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_YUY2_Y444},
 
   {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_UYVY_I420},
   {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_UYVY_I420},
   {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_YUY2},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_UYVY_YUY2},
   {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_AYUV},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_UYVY_AYUV},
   {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_Y42B},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_UYVY_Y42B},
   {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_UYVY_Y444},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_UYVY_Y444},
 
   {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 1, 1, convert_AYUV_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 1,
+      convert_AYUV_I420},
   {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 1, 1, convert_AYUV_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 1,
+      convert_AYUV_I420},
   {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_AYUV_YUY2},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_AYUV_YUY2},
   {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_AYUV_UYVY},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_AYUV_UYVY},
   {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_AYUV_Y42B},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_AYUV_Y42B},
   {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_AYUV_Y444},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_AYUV_Y444},
 
   {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 0, 0, convert_Y42B_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0,
+      convert_Y42B_I420},
   {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 0, 0, convert_Y42B_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0,
+      convert_Y42B_I420},
   {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_Y42B_YUY2},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_Y42B_YUY2},
   {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_Y42B_UYVY},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_Y42B_UYVY},
   {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_Y42B_AYUV},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_Y42B_AYUV},
   {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_Y42B_Y444},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_Y42B_Y444},
 
   {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 1, 0, convert_Y444_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 0,
+      convert_Y444_I420},
   {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, 1, 0, convert_Y444_I420},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 0,
+      convert_Y444_I420},
   {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_Y444_YUY2},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_Y444_YUY2},
   {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_Y444_UYVY},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_Y444_UYVY},
   {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 0, 0, convert_Y444_AYUV},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0,
+      convert_Y444_AYUV},
   {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B,
-      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, 1, 0, convert_Y444_Y42B},
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0,
+      convert_Y444_Y42B},
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_ARGB,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_ARGB},
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_BGRA,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_BGRA},
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_xRGB,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_ARGB},        /* alias */
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_BGRx,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_BGRA},        /* alias */
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_ABGR,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_ABGR},
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_RGBA,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_RGBA},
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_xBGR,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_ABGR},        /* alias */
-  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_RGBx,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, TRUE, 0, 0, convert_AYUV_RGBA},        /* alias */
-
-  {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_BGRA,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, FALSE, 0, 0, convert_I420_BGRA},
-  {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_BGRx,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, FALSE, 0, 0, convert_I420_BGRA},
-  {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_BGRA,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, FALSE, 0, 0, convert_I420_BGRA},
-  {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_BT601, GST_VIDEO_FORMAT_BGRx,
-      GST_VIDEO_COLOR_MATRIX_RGB, FALSE, FALSE, 0, 0, convert_I420_BGRA},
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_ARGB,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0,
+      convert_AYUV_ARGB},
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRA,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0,
+      convert_AYUV_BGRA},
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_xRGB,
+      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_ARGB},       /* alias */
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRx,
+      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_BGRA},       /* alias */
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_ABGR,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0,
+      convert_AYUV_ABGR},
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_RGBA,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0,
+      convert_AYUV_RGBA},
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_xBGR,
+      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_ABGR},       /* alias */
+  {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_RGBx,
+      GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_RGBA},       /* alias */
+
+  {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRA,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0,
+      convert_I420_BGRA},
+  {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRx,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0,
+      convert_I420_BGRA},
+  {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRA,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0,
+      convert_I420_BGRA},
+  {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRx,
+        GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0,
+      convert_I420_BGRA},
 #endif
 };
 
 static gboolean
-videomixer_videoconvert_convert_lookup_fastpath (VideoConvert * convert)
+videoconvert_convert_lookup_fastpath (VideoConvert * convert)
 {
   int i;
   GstVideoFormat in_format, out_format;
@@ -1430,10 +1486,20 @@ videomixer_videoconvert_convert_lookup_fastpath (VideoConvert * convert)
         (transforms[i].width_align & width) == 0 &&
         (transforms[i].height_align & height) == 0) {
       GST_DEBUG ("using fastpath");
+      if (transforms[i].needs_color_matrix)
+        if (!videoconvert_convert_compute_matrix (convert))
+          goto no_convert;
       convert->convert = transforms[i].convert;
       alloc_tmplines (convert, 1, GST_VIDEO_INFO_WIDTH (&convert->in_info));
       return TRUE;
     }
   }
+  GST_DEBUG ("no fastpath found");
   return FALSE;
+
+no_convert:
+  {
+    GST_DEBUG ("can't create matrix");
+    return FALSE;
+  }
 }
index b83b28b..e27bc0a 100644 (file)
@@ -66,13 +66,13 @@ struct _VideoConvert {
 };
 
 VideoConvert *   videomixer_videoconvert_convert_new            (GstVideoInfo *in_info,
-                                                      GstVideoInfo *out_info);
+                                                                 GstVideoInfo *out_info);
 void             videomixer_videoconvert_convert_free           (VideoConvert * convert);
 
 void             videomixer_videoconvert_convert_set_dither     (VideoConvert * convert, int type);
 
 void             videomixer_videoconvert_convert_convert        (VideoConvert * convert,
-                                                      GstVideoFrame *dest, const GstVideoFrame *src);
+                                                                 GstVideoFrame *dest, const GstVideoFrame *src);
 
 
 G_END_DECLS
index 7ee7fef..45e0f56 100644 (file)
@@ -674,8 +674,11 @@ mergewl ayuv, ay, uv
 .flags 2d
 .dest 4 argb guint8
 .source 4 ayuv guint8
-.temp 2 t1
-.temp 2 t2
+.param 2 p1
+.param 2 p2
+.param 2 p3
+.param 2 p4
+.param 2 p5
 .temp 1 a
 .temp 1 y
 .temp 1 u
@@ -690,57 +693,48 @@ mergewl ayuv, ay, uv
 .temp 1 g
 .temp 1 b
 .temp 4 x
-.const 1 c8
+.const 1 c128 128
 
-x4 subb x, ayuv, 128
-splitlw t1, t2, x
-splitwb y, a, t2
-splitwb v, u, t1
-convsbw wy, y
-convsbw wu, u
-convsbw wv, v
-
-mullw t1, wy, 42
-shrsw t1, t1, c8
-addssw wy, wy, t1
-
-addssw wr, wy, wv
-mullw t1, wv, 103
-shrsw t1, t1, c8
-subssw wr, wr, t1
-addssw wr, wr, wv
-
-addssw wb, wy, wu
-addssw wb, wb, wu
-mullw t1, wu, 4
-shrsw t1, t1, c8
-addssw wb, wb, t1
-
-mullw t1, wu, 100
-shrsw t1, t1, c8
-subssw wg, wy, t1
-mullw t1, wv, 104
-shrsw t1, t1, c8
-subssw wg, wg, t1
-subssw wg, wg, t1
+x4 subb x, ayuv, c128 
+splitlw wv, wy, x
+splitwb y, a, wy
+splitwb v, u, wv
+
+splatbw wy, y
+splatbw wu, u
+splatbw wv, v
+
+mulhsw wy, wy, p1
+
+mulhsw wr, wv, p2
+addssw wr, wy, wr
+
+mulhsw wb, wu, p3
+addssw wb, wy, wb
+
+mulhsw wg, wu, p4
+addssw wg, wy, wg
+mulhsw wy, wv, p5
+addssw wg, wg, wy
 
 convssswb r, wr
 convssswb g, wg
 convssswb b, wb
 
-mergebw t1, a, r
-mergebw t2, g, b
-mergewl x, t1, t2
-x4 addb argb, x, 128
-
-
+mergebw wr, a, r
+mergebw wb, g, b
+mergewl x, wr, wb
+x4 addb argb, x, c128
 
 .function videomixer_video_convert_orc_convert_AYUV_BGRA
 .flags 2d
-.dest 4 argb guint8
+.dest 4 bgra guint8
 .source 4 ayuv guint8
-.temp 2 t1
-.temp 2 t2
+.param 2 p1
+.param 2 p2
+.param 2 p3
+.param 2 p4
+.param 2 p5
 .temp 1 a
 .temp 1 y
 .temp 1 u
@@ -755,58 +749,49 @@ x4 addb argb, x, 128
 .temp 1 g
 .temp 1 b
 .temp 4 x
-.const 1 c8
+.const 1 c128 128
 
-x4 subb x, ayuv, 128
-splitlw t1, t2, x
-splitwb y, a, t2
-splitwb v, u, t1
-convsbw wy, y
-convsbw wu, u
-convsbw wv, v
-
-mullw t1, wy, 42
-shrsw t1, t1, c8
-addssw wy, wy, t1
-
-addssw wr, wy, wv
-mullw t1, wv, 103
-shrsw t1, t1, c8
-subssw wr, wr, t1
-addssw wr, wr, wv
-
-addssw wb, wy, wu
-addssw wb, wb, wu
-mullw t1, wu, 4
-shrsw t1, t1, c8
-addssw wb, wb, t1
-
-mullw t1, wu, 100
-shrsw t1, t1, c8
-subssw wg, wy, t1
-mullw t1, wv, 104
-shrsw t1, t1, c8
-subssw wg, wg, t1
-subssw wg, wg, t1
+x4 subb x, ayuv, c128 
+splitlw wv, wy, x
+splitwb y, a, wy
+splitwb v, u, wv
+
+splatbw wy, y
+splatbw wu, u
+splatbw wv, v
+
+mulhsw wy, wy, p1
+
+mulhsw wr, wv, p2
+addssw wr, wy, wr
+
+mulhsw wb, wu, p3
+addssw wb, wy, wb
+
+mulhsw wg, wu, p4
+addssw wg, wy, wg
+mulhsw wy, wv, p5
+addssw wg, wg, wy
 
 convssswb r, wr
 convssswb g, wg
 convssswb b, wb
 
-mergebw t1, b, g
-mergebw t2, r, a
-mergewl x, t1, t2
-x4 addb argb, x, 128
-
-
+mergebw wb, b, g
+mergebw wr, r, a
+mergewl x, wb, wr
+x4 addb bgra, x, c128
 
 
 .function videomixer_video_convert_orc_convert_AYUV_ABGR
 .flags 2d
 .dest 4 argb guint8
 .source 4 ayuv guint8
-.temp 2 t1
-.temp 2 t2
+.param 2 p1
+.param 2 p2
+.param 2 p3
+.param 2 p4
+.param 2 p5
 .temp 1 a
 .temp 1 y
 .temp 1 u
@@ -821,57 +806,48 @@ x4 addb argb, x, 128
 .temp 1 g
 .temp 1 b
 .temp 4 x
-.const 1 c8
+.const 1 c128 128
 
-x4 subb x, ayuv, 128
-splitlw t1, t2, x
-splitwb y, a, t2
-splitwb v, u, t1
-convsbw wy, y
-convsbw wu, u
-convsbw wv, v
-
-mullw t1, wy, 42
-shrsw t1, t1, c8
-addssw wy, wy, t1
-
-addssw wr, wy, wv
-mullw t1, wv, 103
-shrsw t1, t1, c8
-subssw wr, wr, t1
-addssw wr, wr, wv
-
-addssw wb, wy, wu
-addssw wb, wb, wu
-mullw t1, wu, 4
-shrsw t1, t1, c8
-addssw wb, wb, t1
-
-mullw t1, wu, 100
-shrsw t1, t1, c8
-subssw wg, wy, t1
-mullw t1, wv, 104
-shrsw t1, t1, c8
-subssw wg, wg, t1
-subssw wg, wg, t1
+x4 subb x, ayuv, c128 
+splitlw wv, wy, x
+splitwb y, a, wy
+splitwb v, u, wv
+
+splatbw wy, y
+splatbw wu, u
+splatbw wv, v
+
+mulhsw wy, wy, p1
+
+mulhsw wr, wv, p2
+addssw wr, wy, wr
+
+mulhsw wb, wu, p3
+addssw wb, wy, wb
+
+mulhsw wg, wu, p4
+addssw wg, wy, wg
+mulhsw wy, wv, p5
+addssw wg, wg, wy
 
 convssswb r, wr
 convssswb g, wg
 convssswb b, wb
 
-mergebw t1, a, b
-mergebw t2, g, r
-mergewl x, t1, t2
-x4 addb argb, x, 128
-
-
+mergebw wb, a, b
+mergebw wr, g, r
+mergewl x, wb, wr
+x4 addb argb, x, c128
 
 .function videomixer_video_convert_orc_convert_AYUV_RGBA
 .flags 2d
 .dest 4 argb guint8
 .source 4 ayuv guint8
-.temp 2 t1
-.temp 2 t2
+.param 2 p1
+.param 2 p2
+.param 2 p3
+.param 2 p4
+.param 2 p5
 .temp 1 a
 .temp 1 y
 .temp 1 u
@@ -886,48 +862,38 @@ x4 addb argb, x, 128
 .temp 1 g
 .temp 1 b
 .temp 4 x
-.const 1 c8
+.const 1 c128 128
 
-x4 subb x, ayuv, 128
-splitlw t1, t2, x
-splitwb y, a, t2
-splitwb v, u, t1
-convsbw wy, y
-convsbw wu, u
-convsbw wv, v
-
-mullw t1, wy, 42
-shrsw t1, t1, c8
-addssw wy, wy, t1
-
-addssw wr, wy, wv
-mullw t1, wv, 103
-shrsw t1, t1, c8
-subssw wr, wr, t1
-addssw wr, wr, wv
-
-addssw wb, wy, wu
-addssw wb, wb, wu
-mullw t1, wu, 4
-shrsw t1, t1, c8
-addssw wb, wb, t1
-
-mullw t1, wu, 100
-shrsw t1, t1, c8
-subssw wg, wy, t1
-mullw t1, wv, 104
-shrsw t1, t1, c8
-subssw wg, wg, t1
-subssw wg, wg, t1
+x4 subb x, ayuv, c128 
+splitlw wv, wy, x
+splitwb y, a, wy
+splitwb v, u, wv
+
+splatbw wy, y
+splatbw wu, u
+splatbw wv, v
+
+mulhsw wy, wy, p1
+
+mulhsw wr, wv, p2
+addssw wr, wy, wr
+
+mulhsw wb, wu, p3
+addssw wb, wy, wb
+
+mulhsw wg, wu, p4
+addssw wg, wy, wg
+mulhsw wy, wv, p5
+addssw wg, wg, wy
 
 convssswb r, wr
 convssswb g, wg
 convssswb b, wb
 
-mergebw t1, r, g
-mergebw t2, b, a
-mergewl x, t1, t2
-x4 addb argb, x, 128
+mergebw wr, r, g
+mergebw wb, b, a
+mergewl x, wr, wb
+x4 addb argb, x, c128
 
 
 
@@ -936,9 +902,11 @@ x4 addb argb, x, 128
 .source 1 y guint8
 .source 1 u guint8
 .source 1 v guint8
-.temp 2 t1
-.temp 2 t2
-.temp 1 t3
+.param 2 p1
+.param 2 p2
+.param 2 p3
+.param 2 p4
+.param 2 p5
 .temp 2 wy
 .temp 2 wu
 .temp 2 wv
@@ -949,568 +917,36 @@ x4 addb argb, x, 128
 .temp 1 g
 .temp 1 b
 .temp 4 x
-.const 1 c8 8
 .const 1 c128 128
 
-subb t3, y, c128
-convsbw wy, t3
-loadupib t3, u
-subb t3, t3, c128
-convsbw wu, t3
-loadupib t3, v
-subb t3, t3, c128
-convsbw wv, t3
-
-mullw t1, wy, 42
-shrsw t1, t1, c8
-addssw wy, wy, t1
-
-addssw wr, wy, wv
-mullw t1, wv, 103
-shrsw t1, t1, c8
-subssw wr, wr, t1
-addssw wr, wr, wv
-
-addssw wb, wy, wu
-addssw wb, wb, wu
-mullw t1, wu, 4
-shrsw t1, t1, c8
-addssw wb, wb, t1
-
-mullw t1, wu, 100
-shrsw t1, t1, c8
-subssw wg, wy, t1
-mullw t1, wv, 104
-shrsw t1, t1, c8
-subssw wg, wg, t1
-subssw wg, wg, t1
+subb r, y, c128
+splatbw wy, r
+loadupdb r, u
+subb r, r, c128
+splatbw wu, r
+loadupdb r, v
+subb r, r, c128
+splatbw wv, r
 
-convssswb r, wr
-convssswb g, wg
-convssswb b, wb
-
-mergebw t1, b, g
-mergebw t2, r, 255
-mergewl x, t1, t2
-x4 addb argb, x, c128
+mulhsw wy, wy, p1
 
+mulhsw wr, wv, p2
+addssw wr, wy, wr
 
+mulhsw wb, wu, p3
+addssw wb, wy, wb
 
-.function videomixer_video_convert_orc_convert_I420_BGRA_avg
-.dest 4 argb guint8
-.source 1 y guint8
-.source 1 u1 guint8
-.source 1 u2 guint8
-.source 1 v1 guint8
-.source 1 v2 guint8
-.temp 2 t1
-.temp 2 t2
-.temp 1 t3
-.temp 1 t4
-.temp 2 wy
-.temp 2 wu
-.temp 2 wv
-.temp 2 wr
-.temp 2 wg
-.temp 2 wb
-.temp 1 r
-.temp 1 g
-.temp 1 b
-.temp 4 x
-.const 1 c8 8
-.const 1 c128 128
-
-subb t3, y, c128
-convsbw wy, t3
-loadupib t3, u1
-loadupib t4, u2
-avgub t3, t3, t4
-subb t3, t3, c128
-convsbw wu, t3
-loadupib t3, v1
-loadupib t4, v2
-avgub t3, t3, t4
-subb t3, t3, c128
-convsbw wv, t3
-
-mullw t1, wy, 42
-shrsw t1, t1, c8
-addssw wy, wy, t1
-
-addssw wr, wy, wv
-mullw t1, wv, 103
-shrsw t1, t1, c8
-subssw wr, wr, t1
-addssw wr, wr, wv
-
-addssw wb, wy, wu
-addssw wb, wb, wu
-mullw t1, wu, 4
-shrsw t1, t1, c8
-addssw wb, wb, t1
-
-mullw t1, wu, 100
-shrsw t1, t1, c8
-subssw wg, wy, t1
-mullw t1, wv, 104
-shrsw t1, t1, c8
-subssw wg, wg, t1
-subssw wg, wg, t1
+mulhsw wg, wu, p4
+addssw wg, wy, wg
+mulhsw wy, wv, p5
+addssw wg, wg, wy
 
 convssswb r, wr
 convssswb g, wg
 convssswb b, wb
 
-mergebw t1, b, g
-mergebw t2, r, 255
-mergewl x, t1, t2
+mergebw wb, b, g
+mergebw wr, r, 127
+mergewl x, wb, wr
 x4 addb argb, x, c128
 
-
-
-.function videomixer_video_convert_orc_getline_I420
-.dest 4 d guint8
-.source 1 y guint8
-.source 1 u guint8
-.source 1 v guint8
-.const 1 c255 255
-.temp 2 uv
-.temp 2 ay
-.temp 1 tu
-.temp 1 tv
-
-loadupdb tu, u
-loadupdb tv, v
-mergebw uv, tu, tv
-mergebw ay, c255, y
-mergewl d, ay, uv
-
-.function videomixer_video_convert_orc_getline_YUV9
-.dest 8 d guint8
-.source 2 y guint8
-.source 1 u guint8
-.source 1 v guint8
-.const 1 c255 255
-.temp 2 tuv
-.temp 4 ay
-.temp 4 uv
-.temp 1 tu
-.temp 1 tv
-
-loadupdb tu, u
-loadupdb tv, v
-mergebw tuv, tu, tv
-mergewl uv, tuv, tuv
-x2 mergebw ay, c255, y
-x2 mergewl d, ay, uv
-
-.function videomixer_video_convert_orc_getline_YUY2
-.dest 8 ayuv guint8
-.source 4 yuy2 guint8
-.const 2 c255 0xff
-.temp 2 yy
-.temp 2 uv
-.temp 4 ayay
-.temp 4 uvuv
-
-x2 splitwb uv, yy, yuy2
-x2 mergebw ayay, c255, yy
-mergewl uvuv, uv, uv
-x2 mergewl ayuv, ayay, uvuv
-
-
-.function videomixer_video_convert_orc_getline_UYVY
-.dest 8 ayuv guint8
-.source 4 uyvy guint8
-.const 2 c255 0xff
-.temp 2 yy
-.temp 2 uv
-.temp 4 ayay
-.temp 4 uvuv
-
-x2 splitwb yy, uv, uyvy
-x2 mergebw ayay, c255, yy
-mergewl uvuv, uv, uv
-x2 mergewl ayuv, ayay, uvuv
-
-
-.function videomixer_video_convert_orc_getline_YVYU
-.dest 8 ayuv guint8
-.source 4 uyvy guint8
-.const 2 c255 0xff
-.temp 2 yy
-.temp 2 uv
-.temp 4 ayay
-.temp 4 uvuv
-
-x2 splitwb uv, yy, uyvy
-swapw uv, uv
-x2 mergebw ayay, c255, yy
-mergewl uvuv, uv, uv
-x2 mergewl ayuv, ayay, uvuv
-
-
-.function videomixer_video_convert_orc_getline_Y42B
-.dest 8 ayuv guint8
-.source 2 yy guint8
-.source 1 u guint8
-.source 1 v guint8
-.const 1 c255 255
-.temp 2 uv
-.temp 2 ay
-.temp 4 uvuv
-.temp 4 ayay
-
-mergebw uv, u, v
-x2 mergebw ayay, c255, yy
-mergewl uvuv, uv, uv
-x2 mergewl ayuv, ayay, uvuv
-
-
-.function videomixer_video_convert_orc_getline_Y444
-.dest 4 ayuv guint8
-.source 1 y guint8
-.source 1 u guint8
-.source 1 v guint8
-.const 1 c255 255
-.temp 2 uv
-.temp 2 ay
-
-mergebw uv, u, v
-mergebw ay, c255, y
-mergewl ayuv, ay, uv
-
-
-.function videomixer_video_convert_orc_getline_Y800
-.dest 4 ayuv guint8
-.source 1 y guint8
-.const 1 c255 255
-.const 2 c0x8080 0x8080
-.temp 2 ay
-
-mergebw ay, c255, y
-mergewl ayuv, ay, c0x8080
-
-.function videomixer_video_convert_orc_getline_Y16
-.dest 4 ayuv guint8
-.source 2 y guint8
-.const 1 c255 255
-.const 2 c0x8080 0x8080
-.temp 2 ay
-.temp 1 yb
-
-convhwb yb, y
-mergebw ay, c255, yb
-mergewl ayuv, ay, c0x8080
-
-.function videomixer_video_convert_orc_getline_BGRA
-.dest 4 argb guint8
-.source 4 bgra guint8
-
-swapl argb, bgra
-
-
-.function videomixer_video_convert_orc_getline_ABGR
-.dest 4 argb guint8
-.source 4 abgr guint8
-.temp 1 a
-.temp 1 r
-.temp 1 g
-.temp 1 b
-.temp 2 gr
-.temp 2 ab
-.temp 2 ar
-.temp 2 gb
-
-splitlw gr, ab, abgr
-splitwb r, g, gr
-splitwb b, a, ab
-mergebw ar, a, r
-mergebw gb, g, b
-mergewl argb, ar, gb
-
-
-.function videomixer_video_convert_orc_getline_RGBA
-.dest 4 argb guint8
-.source 4 rgba guint8
-.temp 1 a
-.temp 1 r
-.temp 1 g
-.temp 1 b
-.temp 2 rg
-.temp 2 ba
-.temp 2 ar
-.temp 2 gb
-
-splitlw ba, rg, rgba
-splitwb g, r, rg
-splitwb a, b, ba
-mergebw ar, a, r
-mergebw gb, g, b
-mergewl argb, ar, gb
-
-
-.function videomixer_video_convert_orc_getline_NV12
-.dest 8 d guint8
-.source 2 y guint8
-.source 2 uv guint8
-.const 1 c255 255
-.temp 4 ay
-.temp 4 uvuv
-
-mergewl uvuv, uv, uv
-x2 mergebw ay, c255, y
-x2 mergewl d, ay, uvuv
-
-
-.function videomixer_video_convert_orc_getline_NV21
-.dest 8 d guint8
-.source 2 y guint8
-.source 2 vu guint8
-.const 1 c255 255
-.temp 2 uv
-.temp 4 ay
-.temp 4 uvuv
-
-swapw uv, vu
-mergewl uvuv, uv, uv
-x2 mergebw ay, c255, y
-x2 mergewl d, ay, uvuv
-
-.function videomixer_video_convert_orc_getline_A420
-.dest 4 d guint8
-.source 1 y guint8
-.source 1 u guint8
-.source 1 v guint8
-.source 1 a guint8
-.temp 2 uv
-.temp 2 ay
-.temp 1 tu
-.temp 1 tv
-
-loadupdb tu, u
-loadupdb tv, v
-mergebw uv, tu, tv
-mergebw ay, a, y
-mergewl d, ay, uv
-
-.function videomixer_video_convert_orc_putline_I420
-.dest 2 y guint8
-.dest 1 u guint8
-.dest 1 v guint8
-.source 8 ayuv guint8
-.temp 4 ay
-.temp 4 uv
-.temp 2 uu
-.temp 2 vv
-.temp 1 t1
-.temp 1 t2
-
-x2 splitlw uv, ay, ayuv
-x2 select1wb y, ay
-x2 splitwb vv, uu, uv
-splitwb t1, t2, uu
-avgub u, t1, t2
-splitwb t1, t2, vv
-avgub v, t1, t2
-
-
-
-.function videomixer_video_convert_orc_putline_YUY2
-.dest 4 yuy2 guint8
-.source 8 ayuv guint8
-.temp 2 yy
-.temp 2 uv1
-.temp 2 uv2
-.temp 4 ayay
-.temp 4 uvuv
-
-x2 splitlw uvuv, ayay, ayuv
-splitlw uv1, uv2, uvuv
-x2 avgub uv1, uv1, uv2
-x2 select1wb yy, ayay
-x2 mergebw yuy2, yy, uv1
-
-
-.function videomixer_video_convert_orc_putline_YVYU
-.dest 4 yuy2 guint8
-.source 8 ayuv guint8
-.temp 2 yy
-.temp 2 uv1
-.temp 2 uv2
-.temp 4 ayay
-.temp 4 uvuv
-
-x2 splitlw uvuv, ayay, ayuv
-splitlw uv1, uv2, uvuv
-x2 avgub uv1, uv1, uv2
-x2 select1wb yy, ayay
-swapw uv1, uv1
-x2 mergebw yuy2, yy, uv1
-
-
-.function videomixer_video_convert_orc_putline_UYVY
-.dest 4 yuy2 guint8
-.source 8 ayuv guint8
-.temp 2 yy
-.temp 2 uv1
-.temp 2 uv2
-.temp 4 ayay
-.temp 4 uvuv
-
-x2 splitlw uvuv, ayay, ayuv
-splitlw uv1, uv2, uvuv
-x2 avgub uv1, uv1, uv2
-x2 select1wb yy, ayay
-x2 mergebw yuy2, uv1, yy
-
-
-
-.function videomixer_video_convert_orc_putline_Y42B
-.dest 2 y guint8
-.dest 1 u guint8
-.dest 1 v guint8
-.source 8 ayuv guint8
-.temp 4 ayay
-.temp 4 uvuv
-.temp 2 uv1
-.temp 2 uv2
-
-x2 splitlw uvuv, ayay, ayuv
-splitlw uv1, uv2, uvuv
-x2 avgub uv1, uv1, uv2
-splitwb v, u, uv1
-x2 select1wb y, ayay
-
-
-.function videomixer_video_convert_orc_putline_Y444
-.dest 1 y guint8
-.dest 1 u guint8
-.dest 1 v guint8
-.source 4 ayuv guint8
-.temp 2 ay
-.temp 2 uv
-
-splitlw uv, ay, ayuv
-splitwb v, u, uv
-select1wb y, ay
-
-
-.function videomixer_video_convert_orc_putline_Y800
-.dest 1 y guint8
-.source 4 ayuv guint8
-.temp 2 ay
-
-select0lw ay, ayuv
-select1wb y, ay
-
-.function videomixer_video_convert_orc_putline_Y16
-.dest 2 y guint8
-.source 4 ayuv guint8
-.temp 2 ay
-.temp 1 yb
-
-select0lw ay, ayuv
-select1wb yb, ay
-convubw ay, yb
-shlw y, ay, 8
-
-.function videomixer_video_convert_orc_putline_BGRA
-.dest 4 bgra guint8
-.source 4 argb guint8
-
-swapl bgra, argb
-
-
-.function videomixer_video_convert_orc_putline_ABGR
-.dest 4 abgr guint8
-.source 4 argb guint8
-.temp 1 a
-.temp 1 r
-.temp 1 g
-.temp 1 b
-.temp 2 gr
-.temp 2 ab
-.temp 2 ar
-.temp 2 gb
-
-splitlw gb, ar, argb
-splitwb b, g, gb
-splitwb r, a, ar
-mergebw ab, a, b
-mergebw gr, g, r
-mergewl abgr, ab, gr
-
-
-.function videomixer_video_convert_orc_putline_RGBA
-.dest 4 rgba guint8
-.source 4 argb guint8
-.temp 1 a
-.temp 1 r
-.temp 1 g
-.temp 1 b
-.temp 2 rg
-.temp 2 ba
-.temp 2 ar
-.temp 2 gb
-
-splitlw gb, ar, argb
-splitwb b, g, gb
-splitwb r, a, ar
-mergebw ba, b, a
-mergebw rg, r, g
-mergewl rgba, rg, ba
-
-
-.function videomixer_video_convert_orc_putline_NV12
-.dest 2 y guint8
-.dest 2 uv guint8
-.source 8 ayuv guint8
-.temp 4 ay
-.temp 4 uvuv
-.temp 2 uv1
-.temp 2 uv2
-
-x2 splitlw uvuv, ay, ayuv
-x2 select1wb y, ay
-splitlw uv1, uv2, uvuv
-x2 avgub uv, uv1, uv2
-
-
-.function videomixer_video_convert_orc_putline_NV21
-.dest 2 y guint8
-.dest 2 vu guint8
-.source 8 ayuv guint8
-.temp 4 ay
-.temp 4 uvuv
-.temp 2 uv1
-.temp 2 uv2
-.temp 2 uv
-
-x2 splitlw uvuv, ay, ayuv
-x2 select1wb y, ay
-splitlw uv1, uv2, uvuv
-x2 avgub uv, uv1, uv2
-swapw vu, uv
-
-.function videomixer_video_convert_orc_putline_A420
-.dest 2 y guint8
-.dest 1 u guint8
-.dest 1 v guint8
-.dest 2 a guint8
-.source 8 ayuv guint8
-.temp 4 ay
-.temp 4 uv
-.temp 2 uu
-.temp 2 vv
-.temp 1 t1
-.temp 1 t2
-
-x2 splitlw uv, ay, ayuv
-x2 select1wb y, ay
-x2 select0wb a, ay
-x2 splitwb vv, uu, uv
-splitwb t1, t2, uu
-avgub u, t1, t2
-splitwb t1, t2, vv
-avgub v, t1, t2