[Spice-devel] [PATCH spice-server v2] gstreamer: Include only needed fields in SpiceFormatForGStreamer structure

Victor Toso victortoso at redhat.com
Thu Feb 2 11:02:11 UTC 2017


Hi,

On Fri, Jan 27, 2017 at 10:29:22AM +0000, Frediano Ziglio wrote:
> This structure is used to store format information for
> both Gstreamer 0.10 and 1.0 however the two format uses
> different fields from it.
> Use a macro to filter only needed fields.
> This currently also fixes a compile error using Gstreamer 0.10
> (GST_VIDEO_FORMAT_RGB15 not defined as not available).
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

Looks good,
Acked-by: Victor Toso <victortoso at redhat.com>

> ---
>  server/gstreamer-encoder.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> Changes since v1:
> - describe compiler error;
> - use better names for macro arguments.
> 
> diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
> index ba81377..071f859 100644
> --- a/server/gstreamer-encoder.c
> +++ b/server/gstreamer-encoder.c
> @@ -42,16 +42,29 @@
>  
>  typedef struct {
>      SpiceBitmapFmt spice_format;
> +    uint32_t bpp;
> +#ifndef HAVE_GSTREAMER_0_10
>      char format[8];
>      GstVideoFormat gst_format;
> -    uint32_t bpp;
> +#else
>      uint32_t depth;
>      uint32_t endianness;
>      uint32_t blue_mask;
>      uint32_t green_mask;
>      uint32_t red_mask;
> +#endif
>  } SpiceFormatForGStreamer;
>  
> +#ifndef HAVE_GSTREAMER_0_10
> +#define FMT_DESC(spice_format, bpp, format, gst_format, depth, endianness, \
> +                 blue_mask, green_mask, red_mask) \
> +    { spice_format, bpp, format, gst_format }
> +#else
> +#define FMT_DESC(spice_format, bpp, format, gst_format, depth, endianness, \
> +                 blue_mask, green_mask, red_mask) \
> +    { spice_format, bpp, depth, endianness, blue_mask, green_mask, red_mask }
> +#endif
> +
>  typedef struct SpiceGstVideoBuffer {
>      VideoBuffer base;
>      GstBuffer *gst_buffer;
> @@ -758,12 +771,12 @@ static const SpiceFormatForGStreamer format_map[] =  {
>      /* First item is invalid.
>       * It's located first so the loop catch invalid values.
>       */
> -    {SPICE_BITMAP_FMT_INVALID, "", GST_VIDEO_FORMAT_UNKNOWN, 0, 0, 0, 0, 0, 0},
> -    {SPICE_BITMAP_FMT_RGBA, "BGRA", GST_VIDEO_FORMAT_BGRA, 32, 24, 4321, 0xff000000, 0xff0000, 0xff00},
> -    {SPICE_BITMAP_FMT_16BIT, "RGB15", GST_VIDEO_FORMAT_RGB15, 16, 15, 4321, 0x001f, 0x03E0, 0x7C00},
> +    FMT_DESC(SPICE_BITMAP_FMT_INVALID, 0, "", GST_VIDEO_FORMAT_UNKNOWN, 0, 0, 0, 0, 0),
> +    FMT_DESC(SPICE_BITMAP_FMT_RGBA, 32, "BGRA", GST_VIDEO_FORMAT_BGRA, 24, 4321, 0xff000000, 0xff0000, 0xff00),
> +    FMT_DESC(SPICE_BITMAP_FMT_16BIT, 16, "RGB15", GST_VIDEO_FORMAT_RGB15, 15, 4321, 0x001f, 0x03E0, 0x7C00),
>      /* TODO: Test the other formats under GStreamer 0.10*/
> -    {SPICE_BITMAP_FMT_32BIT, "BGRx", GST_VIDEO_FORMAT_BGRx, 32, 24, 4321, 0xff000000, 0xff0000, 0xff00},
> -    {SPICE_BITMAP_FMT_24BIT, "BGR", GST_VIDEO_FORMAT_BGR, 24, 24, 4321, 0xff0000, 0xff00, 0xff},
> +    FMT_DESC(SPICE_BITMAP_FMT_32BIT, 32, "BGRx", GST_VIDEO_FORMAT_BGRx, 24, 4321, 0xff000000, 0xff0000, 0xff00),
> +    FMT_DESC(SPICE_BITMAP_FMT_24BIT, 24, "BGR", GST_VIDEO_FORMAT_BGR, 24, 4321, 0xff0000, 0xff00, 0xff),
>  };
>  #define GSTREAMER_FORMAT_INVALID (&format_map[0])
>  
> -- 
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170202/047f239d/attachment.sig>


More information about the Spice-devel mailing list