[Cogl] [PATCH 02/13] cogl-gst: video-sink: fix YV12/I420 support

Robert Bragg robert at sixbynine.org
Tue Dec 10 08:58:44 PST 2013


Splitting out separate _i420_upload and _yv12_upload functions seems
good here, but I don't think we should be switching to use the
COGL_PIXEL_FORMAT_G_8 format. That format was dropped from Cogl master
in favour of _PIXEL_FORMAT_A_8. _G_8 was a bit of an odd
Greyscale/Luminance format that would result in one component being
replicated across the RGB components leaving A as 1.0. _G_8 also
wasn't supported on GL3 since it was based on GL luminance textures
which were removed from GL 3 and we didn't want to add compatibility
via texture swizzling.

If you can revert the format change then this looks good to land on
master to me, and then cherry pick to the 1.18 branch:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

thanks,
Robert

On Mon, Dec 9, 2013 at 11:17 AM, Lionel Landwerlin
<llandwerlin at gmail.com> wrote:
> ---
>  cogl-gst/cogl-gst-video-sink.c | 55 ++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 50 insertions(+), 5 deletions(-)
>
> diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
> index bcbef35..a42841a 100644
> --- a/cogl-gst/cogl-gst-video-sink.c
> +++ b/cogl-gst/cogl-gst-video-sink.c
> @@ -616,7 +616,52 @@ cogl_gst_yv12_upload (CoglGstVideoSink *sink,
>  {
>    CoglGstVideoSinkPrivate *priv = sink->priv;
>    GstVideoFrame frame;
> -  CoglPixelFormat format = COGL_PIXEL_FORMAT_A_8;
> +  CoglPixelFormat format = COGL_PIXEL_FORMAT_G_8;
> +
> +  if (!gst_video_frame_map (&frame, &priv->info, buffer, GST_MAP_READ))
> +    goto map_fail;
> +
> +  clear_frame_textures (sink);
> +
> +  priv->frame[0] =
> +    video_texture_new_from_data (priv->ctx,
> +                                 GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 0),
> +                                 GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 0),
> +                                 format, format,
> +                                 priv->info.stride[0], frame.data[0], NULL);
> +
> +  priv->frame[2] =
> +    video_texture_new_from_data (priv->ctx,
> +                                 GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 1),
> +                                 GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 1),
> +                                 format, format,
> +                                 priv->info.stride[1], frame.data[1], NULL);
> +
> +  priv->frame[1] =
> +    video_texture_new_from_data (priv->ctx,
> +                                 GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 2),
> +                                 GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 2),
> +                                 format, format,
> +                                 priv->info.stride[2], frame.data[2], NULL);
> +
> +  gst_video_frame_unmap (&frame);
> +
> +  return TRUE;
> +
> +map_fail:
> +  {
> +    GST_ERROR_OBJECT (sink, "Could not map incoming video frame");
> +    return FALSE;
> +  }
> +}
> +
> +static CoglBool
> +cogl_gst_i420_upload (CoglGstVideoSink *sink,
> +                      GstBuffer *buffer)
> +{
> +  CoglGstVideoSinkPrivate *priv = sink->priv;
> +  GstVideoFrame frame;
> +  CoglPixelFormat format = COGL_PIXEL_FORMAT_G_8;
>
>    if (!gst_video_frame_map (&frame, &priv->info, buffer, GST_MAP_READ))
>      goto map_fail;
> @@ -674,9 +719,9 @@ cogl_gst_yv12_glsl_setup_pipeline (CoglGstVideoSink *sink,
>                           "cogl_gst_sample_video%i (vec2 UV)\n"
>                           "{\n"
>                           "  float y = 1.1640625 * "
> -                         "(texture2D (cogl_sampler%i, UV).a - 0.0625);\n"
> -                         "  float u = texture2D (cogl_sampler%i, UV).a - 0.5;\n"
> -                         "  float v = texture2D (cogl_sampler%i, UV).a - 0.5;\n"
> +                         "(texture2D (cogl_sampler%i, UV).g - 0.0625);\n"
> +                         "  float u = texture2D (cogl_sampler%i, UV).g - 0.5;\n"
> +                         "  float v = texture2D (cogl_sampler%i, UV).g - 0.5;\n"
>                           "  vec4 color;\n"
>                           "  color.r = y + 1.59765625 * v;\n"
>                           "  color.g = y - 0.390625 * u - 0.8125 * v;\n"
> @@ -715,7 +760,7 @@ static CoglGstRenderer i420_glsl_renderer =
>    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES("memory:SystemMemory", "I420")),
>    3, /* n_layers */
>    cogl_gst_yv12_glsl_setup_pipeline,
> -  cogl_gst_yv12_upload,
> +  cogl_gst_i420_upload,
>  };
>
>  static void
> --
> 1.8.5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list