[Cogl] [PATCH 13/13] cogl-gst: video-sink: add special filter for hardware decoded frames

Lionel Landwerlin llandwerlin at gmail.com
Mon Dec 9 03:18:00 PST 2013


Hardware decoded frames are unlikely to be mipmapped. We can't use the
same filters as the ones for CPU decoded/uploaded frames.
---
 cogl-gst/cogl-gst-video-sink.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 7d48824..2615d39 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -159,6 +159,7 @@ typedef struct _CoglGstRenderer
   GstStaticCaps caps;
   int n_layers;
   CoglPipelineFilter layers_filters[2 * MAX_LAYERS];
+  CoglPipelineFilter layers_filters_gl[2 * MAX_LAYERS];
   void (*setup_pipeline) (CoglGstVideoSink *sink,
                           CoglPipeline *pipeline);
   CoglBool (*upload) (CoglGstVideoSink *sink,
@@ -176,6 +177,7 @@ struct _CoglGstVideoSinkPrivate
   CoglBool frame_dirty;
   CoglGstVideoFormat format;
   CoglBool bgr;
+  CoglBool has_gl;
   CoglGstSource *source;
   GSList *renderers;
   GstCaps *caps;
@@ -291,9 +293,14 @@ cogl_gst_video_sink_attach_frame (CoglGstVideoSink *sink,
     if (priv->frame[i] != NULL) {
       cogl_pipeline_set_layer_texture (pln, i + priv->custom_start,
                                        priv->frame[i]);
-      cogl_pipeline_set_layer_filters (pln, i + priv->custom_start,
-                                       priv->renderer->layers_filters[2 * i],
-                                       priv->renderer->layers_filters[2 * i + 1]);
+      if (priv->has_gl)
+        cogl_pipeline_set_layer_filters (pln, i + priv->custom_start,
+                                         priv->renderer->layers_filters_gl[2 * i],
+                                         priv->renderer->layers_filters_gl[2 * i + 1]);
+      else
+        cogl_pipeline_set_layer_filters (pln, i + priv->custom_start,
+                                         priv->renderer->layers_filters[2 * i],
+                                         priv->renderer->layers_filters[2 * i + 1]);
     }
 }
 
@@ -672,6 +679,7 @@ static CoglGstRenderer rgb24_renderer =
   GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:SystemMemory", "{ RGB, BGR }")),
   1, /* n_layers */
   { COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR, },
+  { COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR, },
   cogl_gst_rgb_setup_pipeline,
   cogl_gst_rgb24_upload,
   cogl_gst_dummy_upload_gl,
@@ -769,6 +777,7 @@ static CoglGstRenderer rgb32_renderer =
                    ";" GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "RGBA")),
   1, /* n_layers */
   { COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR, },
+  { COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR, },
   cogl_gst_rgb_setup_pipeline,
   cogl_gst_rgb32_upload,
   cogl_gst_rgb32_upload_gl,
@@ -930,6 +939,11 @@ static CoglGstRenderer yv12_glsl_renderer =
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
   },
+  {
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+  },
   cogl_gst_yv12_glsl_setup_pipeline,
   cogl_gst_yv12_upload,
   cogl_gst_dummy_upload_gl,
@@ -948,6 +962,11 @@ static CoglGstRenderer i420_glsl_renderer =
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
   },
+  {
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+  },
   cogl_gst_yv12_glsl_setup_pipeline,
   cogl_gst_i420_upload,
   cogl_gst_dummy_upload_gl,
@@ -1035,6 +1054,11 @@ static CoglGstRenderer ayuv_glsl_renderer =
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
   },
+  {
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+  },
   cogl_gst_ayuv_glsl_setup_pipeline,
   cogl_gst_ayuv_upload,
   cogl_gst_dummy_upload_gl,
@@ -1141,6 +1165,10 @@ static CoglGstRenderer nv12_glsl_renderer =
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_LINEAR,
     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR, COGL_PIPELINE_FILTER_NEAREST,
   },
+  {
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_LINEAR,
+    COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST,
+  },
   cogl_gst_nv12_glsl_setup_pipeline,
   cogl_gst_nv12_upload,
   cogl_gst_dummy_upload_gl,
@@ -1420,10 +1448,12 @@ cogl_gst_source_dispatch (GSource *source,
   if (buffer)
     {
       if (gst_buffer_get_video_gl_texture_upload_meta (buffer) != NULL) {
+        priv->has_gl = TRUE;
         if (!priv->renderer->upload_gl (gst_source->sink, buffer)) {
           goto fail_upload;
         }
       } else {
+        priv->has_gl = FALSE;
         if (!priv->renderer->upload (gst_source->sink, buffer))
           goto fail_upload;
       }
-- 
1.8.5



More information about the Cogl mailing list