[cogl/cogl-1.16] cogl-gst: video-sink: fix YV12/I420 support
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/cogl-1.16] cogl-gst: video-sink: fix YV12/I420 support
- Date: Tue, 17 Dec 2013 14:25:23 +0000 (UTC)
commit 64dbd2c337de4fabc3bbf95c106dfd0f10993756
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Tue Nov 26 11:11:42 2013 +0000
cogl-gst: video-sink: fix YV12/I420 support
(cherry picked from commit 637728dd89d51bc2809b4f0495c08f6f9eaeb8eb)
cogl-gst/cogl-gst-video-sink.c | 53 +++++++++++++++++++++++++++++++++++++---
1 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 4feb724..30b6114 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -611,8 +611,53 @@ cogl_gst_yv12_upload (CoglGstVideoSink *sink,
GstBuffer *buffer)
{
CoglGstVideoSinkPrivate *priv = sink->priv;
+ CoglPixelFormat format = COGL_PIXEL_FORMAT_A_8;
GstVideoFrame frame;
+
+ 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;
CoglPixelFormat format = COGL_PIXEL_FORMAT_A_8;
+ GstVideoFrame frame;
if (!gst_video_frame_map (&frame, &priv->info, buffer, GST_MAP_READ))
goto map_fail;
@@ -670,9 +715,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"
@@ -711,7 +756,7 @@ static CoglGstRenderer i420_glsl_renderer =
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420")),
3, /* n_layers */
cogl_gst_yv12_glsl_setup_pipeline,
- cogl_gst_yv12_upload,
+ cogl_gst_i420_upload,
};
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]