summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2015-03-09 15:01:19 (GMT)
committerWim Taymans <wtaymans@redhat.com>2015-03-09 15:02:17 (GMT)
commit6ee67a8aa15129fb948d7d042baf17802189b7bf (patch)
tree32599ec25627db75466f5abef2a1ac9ee9e7ff68
parentcf572ae2cb920bc6851749df2b46523fd1e3de93 (diff)
downloadgst-plugins-base-6ee67a8aa15129fb948d7d042baf17802189b7bf.tar.gz
gst-plugins-base-6ee67a8aa15129fb948d7d042baf17802189b7bf.tar.xz
video-converter: detect identity matrix
Do nothing if we have an identity matrix conversion.
-rw-r--r--gst-libs/gst/video/video-converter.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c
index a64c265..dedcfa3 100644
--- a/gst-libs/gst/video/video-converter.c
+++ b/gst-libs/gst/video/video-converter.c
@@ -973,6 +973,34 @@ is_ayuv_to_rgb_matrix (MatrixData * data)
return TRUE;
}
+static gboolean
+is_identity_matrix (MatrixData * data)
+{
+ gint i, j;
+ gint c = data->im[0][0];
+
+ /* not really checking identity because of rounding errors but given
+ * the conversions we do we just check for anything that looks like:
+ *
+ * c 0 0 0
+ * 0 c 0 0
+ * 0 0 c 0
+ * 0 0 0 1
+ */
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ if (i == j) {
+ if (i == 3 && data->im[i][j] != 1)
+ return FALSE;
+ else if (data->im[i][j] != c)
+ return FALSE;
+ } else if (data->im[i][j] != 0)
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
static void
video_converter_matrix16 (MatrixData * data, gpointer pixels)
{
@@ -1004,6 +1032,9 @@ video_converter_matrix16 (MatrixData * data, gpointer pixels)
static void
prepare_matrix (GstVideoConverter * convert, MatrixData * data)
{
+ if (is_identity_matrix (data))
+ return;
+
color_matrix_scale_components (data, SCALE_F, SCALE_F, SCALE_F);
color_matrix_convert (data);