Commit Graph

31 Commits

Author SHA1 Message Date
Neil Roberts
b898333181 cogl-gst: Fix get_caps implementation when no context is set
If no context is set on the CoglGstVideoSink then it would previously
call gst_caps_ref with a NULL pointer. This patch makes it just return
NULL instead. I think that is a valid thing to do because that is what
gst_base_sink_default_get_caps does. If we don't do this then it's not
possible to use CoglGstVideoSink with GstParse because that tries to
link the pipeline after parsing the string. That was previously
causing a critical error because the freshly parsed sink doesn't have
a CoglContext.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Lionel Landwerlin <llandwerlin@gmail.com>
(cherry picked from commit cf26da2964e372c9fe5bd6da060a57006a83af38)
2014-01-31 12:42:03 +00:00
Neil Roberts
23044a1047 cogl-gst: video-sink: add NV12 support
This adds a cogl-gst renderer to decode NV12 data. NV12 is split into
two buffers, one for the luma component and another for the two
chrominance components at a quarter of the resolution. The second
buffer is uploaded to a two-component RG texture. RG-component
textures are only supported if COGL_FEATURE_ID_TEXTURE_RG is
advertised by Cogl so the NV12 cap is also only advertised when that
is available.

Based on a patch by Lionel Landwerlin which was in turn based on a
patch from Edward Hervey and Matthieu Bouron for Clutter-Gst:

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Lionel Landwerlin <llandwerlin@gmail.com>
(cherry picked from commit 2c619216964b46aab313be3ef1c405dfc720d258)
2014-01-31 12:42:03 +00:00
Neil Roberts
2543a86ba1 cogl-gst-video-sink: Premultiply the colors coming from the video
Commit 99a53c82e9ab0a1e5 removed the internal format argument when
uploading a video frame to a texture so that the format will just be
determined automatically from the image format. However this also
leaves the premultiplied state at the default and the default is TRUE.
That means that when we upload RGBA data Cogl will do a premultiplied
conversion on the CPU. We probably don't want to be putting a CPU
conversion in the way of video frames so this patch changes it to set
the premultiplied state to FALSE on the textures and then do the
premultiplied conversion in the shader.

This is particularly important for AYUV which uses the alpha channel
for the V component so doing a premultiplied conversion on the CPU
just creates garbage and messes up the image.

The RGB and RGBA renderers have each been split into two; one that
uses GLSL and one that uses a regular pipeline. The RGBA pipeline
without GLSL is then changed to use 2 layers so we that we can do the
premultiplied conversion in the second layer with a special layer
combine string.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 07a57f26596c72507035369c90ed6d62568330b5)
2014-01-31 12:42:03 +00:00
Lionel Landwerlin
5227853e10 cogl-gst: video-sink: fix not installed rgb shader
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 07114acc40406e3e0fa79ae6195836d56397fdfa)
2014-01-22 13:05:50 +00:00
Robert Bragg
c2130e9556 Consistently name cogl-gst pkg-config files
This makes sure we install a cogl-gst-1.0.pc and
cogl-gst-2.0-experimental.pc file consistent with other sub-libraries
such that cogl-1.x packages can be parallel installed with cogl master.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 16:03:17 +00:00
Robert Bragg
af7398788a remove internal_format and redundant error arguments
Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 99a53c82e9ab0a1e5ee35941bf83dc334b1fbe87)

Note: there are numerous API changes for functions currently marked
as 'unstable' which we don't think are in use by anyone depending on
a stable 1.x api. Compared to the original patch though this avoids
changing the cogl_texture_rectangle_new_with_size() api which we know
is used by Mutter.
2014-01-09 15:49:47 +00:00
Robert Bragg
9a879a7616 cogl-gst: video-sink: fix YV12/I420 support
This fixes a mistake in commit 637728dd89d51bc28 that was meant to fix
yv12/i420 support but when the patch was updated based on review to use
COGL_PIXEL_FORMAT_A instead of COGL_PIXEL_FORMAT_G the corresponding
glsl code wasn't also updated to sample the .a component.

(cherry picked from commit a02c55105c705471866df2d306879d8616289f2a)
2014-01-01 17:56:46 +00:00
Lionel Landwerlin
7dcdf4dfd6 cogl-gst: video-sink: fix ayuv pipeline setup 2013-12-11 10:49:36 +00:00
Lionel Landwerlin
6101360304 cogl-gst: video-sink: fix YV12/I420 support 2013-12-11 10:47:38 +00:00
Robert Bragg
6436cd073d Declare interface types as void and remove cast macros
This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.

(cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7)

Since we can't break the 1.x api this version of the patch actually
defines compatible NOP macros within deprecated/cogl-type-casts.h
2013-11-27 19:33:44 +00:00
Lionel Landwerlin
447488dd5b cogl-gst: add missing annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:32 +01:00
Lionel Landwerlin
69247c10f3 cogl-gst: emit ready signal on sink only after the first frame is uploaded
Developers listening to the 'ready' signal on CoglGstVideoSink might
call process the current frame once the signal is triggered. We need
to ensure the first frame has been uploaded before letting people know
that the sink is ready.

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

(cherry picked from commit 53882aa0728c5540d8452045006a763e29d4306d)
2013-08-19 22:44:45 +01:00
Robert Bragg
1255d178e0 gst: don't use cogl_texture_new_with_data
This updates cogl-gst to use cogl_texture_2d_new_with_data instead of
cogl_texture_new_with_data in preparation for removing the automagic
apis in cogl-auto-texture.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit d3af8dc9bf6c4c1b09a4f7559b0375f848368c10)

Conflicts:
	cogl-gst/cogl-gst-video-sink.c
2013-07-29 16:59:15 +01:00
Robert Bragg
4d5af45d99 cogl-gst: adds _sink_is_ready() api
This adds a cogl_gst_video_sink_is_ready() for code to be able to
check if it's safe to call cogl_gst_video_sink_get_pipeline() or
cogl_gst_video_sink_setup_pipeline() without causing an error.
Normally an application can listen for the pipeline-ready signal but
sometimes a sink can be passed between components that didn't have an
opportunity to connect a signal handler, so they need a way to
directly check the status.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 9e7db391a87beee7c448f2a67b3e7202779ce9b2)
2013-07-25 16:46:18 +01:00
Lionel Landwerlin
6cc9074cfb cogl-gst: move initialization code so CoglGstVideoSink can be subclassed
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 2f6068cb6783edf6e05d6e55e9700e22f31cb233)
2013-07-09 22:52:49 +01:00
Lionel Landwerlin
86cd26b67c cogl-gst: protect public API using type checks
(cherry picked from commit 9a8c6536088368060a85f74d082c3dd8487b877c)
2013-07-09 13:32:16 +01:00
Robert Bragg
5faed43f29 cogl-gst: expose aspect ratio apis
This adds several utility apis that aim to make it as easy as possible
for an application to determine what size a video should be drawn at.

The important detail here is that these apis take into account the
pixel-aspect-ratio in addition to the video's own aspect ratio.

This patch updates the cogl-basic-video-player example to use the
cogl_gst_video_sink_fit_size() api to perform letterboxing.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit d26f17c97ff6b9f6d6211e0527d5965a85305a56)
2013-06-21 19:06:59 +01:00
Neil Roberts
ee559d4e93 cogl-gst: Remove the return value from attach_frame()
Previously cogl_gst_video_sink_attach_frame returned the last layer
used by the sink. This can also be retrieved via
cogl_gst_video_sink_get_free_layer so I don't think it's necessary to
return it here and it seems kind of out of place.

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

(cherry picked from commit 0805f3e9db715fc2c97b7e60d4f3a25e7fa598fc)
2013-06-21 19:05:36 +01:00
Neil Roberts
735bf63063 cogl-gst: Move the PARAM macros into the C file
These are just internal convenience macros to define the GObject
properties so they shouldn't be in the public headers.

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

(cherry picked from commit b7b861aa87ad05a2c253afdd87323acd82fd988f)
2013-06-21 19:05:16 +01:00
Neil Roberts
5f86563c86 cogl-gst: Add some documentation
Adds documentation comments to CoglGstVideoSink and makes it generate
a separate manual to contain it.

One thing that I wasn't able to figure out with this was how to get
the documentation to have correct references to the main Cogl docs.
You can pass arguments to gtkdoc-fixxref to point to other manuals,
but presumably this needs the installed locations and when the
Cogl-Gst documentation is generated the Cogl docs may not have been
installed yet.

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

(cherry picked from commit 5acdf8db47311893a9cf9ea04a66a287b657b8b0)
2013-06-21 19:04:52 +01:00
Neil Roberts
c50b302fc4 cogl-gst: Remove the unused cogl_gst_video_sink_get_main_loop
This declaration was a leftover from a previous iteration of the
CoglGST patches.

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

(cherry picked from commit 53ae6d39efa113e28f5d1177ccb8613ddf28ee43)
2013-06-21 19:03:24 +01:00
Plamena Manolova
282505ba99 cogl-gst: Add a functions to facilitate layering
These functions are used when attaching frames at a start point other
than layer 0 is required. This could potentially be used to "layer"
videos and textures on top of each other in the CoglPipeline. This
layering could come handy if videos are used as alpha masks or normal
maps, or when arranging layers in a perticular order, so Cogl could
blend them nicely without extra hassle.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f98b437c9ea79f04ef1ebbb6ff547f58b49b0008)
2013-06-21 19:03:04 +01:00
Neil Roberts
4eb9987699 cogl-gst: Don't replace previous layers in default shader
Previously, when CoglGST generated the default sampling snippet it
would set the replace string so that Cogl wouldn't generate any
redundant code for the other layers. However this also meant that it
wouldn't modulate with the default colour. This patch changes it to
set the combine mode on all of the layers to REPLACE(PREVIOUS) so that
it just copies the previous layer without generating any texture
sampling. That way the fragment snippet for the final layer can just
modulate the previous value with the video sampling function. This
makes it possible to set a color on the pipeline and have it modulate
the video. Also if we eventually add a way to insert layers before the
GST sampling layer then it can modulate with those.

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

(cherry picked from commit f5da8d2caf4b2fbaf6941642a5d5ea7b93d0dd0f)
2013-06-21 19:02:35 +01:00
Neil Roberts
e85a681788 cogl-gst: Remove ‘FLOP’
This is an inappropriately pessimistic remark for the header of
CoglGstVideoSink.

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

(cherry picked from commit ce2a70165054fea3e9d992c14650ba8cccf60e97)
2013-06-21 19:02:15 +01:00
Neil Roberts
e46ad9a91e cogl-gst: Use alpha textures instead of luminance textures
Luminance textures are not supported on GL3 and as the textures are
accessed via a shader anyway it doesn't seem like it should make much
difference which component the single-component textures are in. Cogl
already has code to fake alpha textures via the texture swizzle
extension on GL3.

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

(cherry picked from commit ca1666860a325fa4d2362cdd38297d6281e997d8)
2013-06-21 19:01:56 +01:00
Neil Roberts
52b0e91537 cogl-gst-plugin: Use a real version number and web address
Instead of hardcoding the version number “0.0” it now uses the version
number from the Cogl source. The web address has been changed to
cogl3d.org.

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

(cherry picked from commit 5363e4a68da9811fb136a01b278846ce15913287)
2013-06-21 19:01:35 +01:00
Neil Roberts
7acdf0114e cogl-gst: More pedantic style fixes
• Fixes some overly long lines, hugging asterisks in the pointer type
  declarations and indentation issues.

• Tidies up the GLSL source so that it will look nicer in the
  debug output.

• Removes the backwards ‘parent_class’ define which hacks the
  implementation of the G_DEFINE_TYPE macro and just uses the full
  type name instead.

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

(cherry picked from commit 3ffe8979da4d4dc7deb221e5653b6f24f41b412c)
2013-06-21 19:00:15 +01:00
Chris Cummins
30001939ad cogl-gst: pedantic typo fix in pkg-config description
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f723ad34cbdd99385ee5fbfc71423ab3c9bfdae2)
2013-06-21 18:59:49 +01:00
Robert Bragg
adcaf27106 cogl-gst: pedantic style fixes in cogl-gst-video-sink.h
There were a few hugging pointer asterisks and inconsistent newlines for
a prototype which this patch tweaks.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 488c074316b270b17d1000c68f26210108b1b0ca)
2013-06-21 18:59:14 +01:00
Robert Bragg
595a06e415 cogl-gst: remove experimental "HW Decode" code
The experimental HW decode path was adapted from clutter-gst based on
some experimental gstreamer api. This path was disabled by upstream
gstreamer developers back in september last year due to instabilities.
Without understanding how the experimental api is implemented it seems
rather strange to be plucking out the GL handle of a cogl texture and
passing that to some unknown gstreamer code which would presumably
somehow have to use the same GL context as Cogl to be able to do
something with that texture. For now we can strip all of this unused
code and it would be easy enough to re-instate later if it's useful.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2a24cb9f2a283af87bb685b3e9c7e3af1ffeab6e)
2013-06-21 18:59:09 +01:00
Plamena Manolova
1eca1631a7 Include CoglGst
CoglGst is a GStreamer integration library that facilitates
video playback using the Cogl API. It works by retrieving
each video frame from the GStreamer pipeline and attaching
it to a Cogl pipeline in the form of a Cogl texture along
with possible color model conversion shaders. The pipeline
is then retrieved by the user during each draw. An example
use of the CoglGst API is included in the examples directory.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit dfb94cf4b0b6b42d6465df362a0c0af780596890)
2013-06-21 18:57:24 +01:00