From: Wim Taymans Date: Fri, 1 Feb 2013 15:46:42 +0000 (+0100) Subject: video-format: add method to get palette X-Git-Tag: 1.19.3~511^2~5633 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb7a7cd05cf9dd8d173a3b98016b0e9c2bd24d9f;p=platform%2Fupstream%2Fgstreamer.git video-format: add method to get palette Make a new method to get the default palette for paletted formats. --- diff --git a/gst-libs/gst/video/video-format.c b/gst-libs/gst/video/video-format.c index 083688f..8493a17 100644 --- a/gst-libs/gst/video/video-format.c +++ b/gst-libs/gst/video/video-format.c @@ -1008,6 +1008,52 @@ unpack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags, } } +static guint32 std_palette_RGB8P[] = { + 0xff000000, 0xff000033, 0xff000066, 0xff000099, 0xff0000cc, 0xff0000ff, + 0xff003300, 0xff003333, 0xff003366, 0xff003399, 0xff0033cc, 0xff0033ff, + 0xff006600, 0xff006633, 0xff006666, 0xff006699, 0xff0066cc, 0xff0066ff, + 0xff009900, 0xff009933, 0xff009966, 0xff009999, 0xff0099cc, 0xff0099ff, + 0xff00cc00, 0xff00cc33, 0xff00cc66, 0xff00cc99, 0xff00cccc, 0xff00ccff, + 0xff00ff00, 0xff00ff33, 0xff00ff66, 0xff00ff99, 0xff00ffcc, 0xff00ffff, + 0xff330000, 0xff330033, 0xff330066, 0xff330099, 0xff3300cc, 0xff3300ff, + 0xff333300, 0xff333333, 0xff333366, 0xff333399, 0xff3333cc, 0xff3333ff, + 0xff336600, 0xff336633, 0xff336666, 0xff336699, 0xff3366cc, 0xff3366ff, + 0xff339900, 0xff339933, 0xff339966, 0xff339999, 0xff3399cc, 0xff3399ff, + 0xff33cc00, 0xff33cc33, 0xff33cc66, 0xff33cc99, 0xff33cccc, 0xff33ccff, + 0xff33ff00, 0xff33ff33, 0xff33ff66, 0xff33ff99, 0xff33ffcc, 0xff33ffff, + 0xff660000, 0xff660033, 0xff660066, 0xff660099, 0xff6600cc, 0xff6600ff, + 0xff663300, 0xff663333, 0xff663366, 0xff663399, 0xff6633cc, 0xff6633ff, + 0xff666600, 0xff666633, 0xff666666, 0xff666699, 0xff6666cc, 0xff6666ff, + 0xff669900, 0xff669933, 0xff669966, 0xff669999, 0xff6699cc, 0xff6699ff, + 0xff66cc00, 0xff66cc33, 0xff66cc66, 0xff66cc99, 0xff66cccc, 0xff66ccff, + 0xff66ff00, 0xff66ff33, 0xff66ff66, 0xff66ff99, 0xff66ffcc, 0xff66ffff, + 0xff990000, 0xff990033, 0xff990066, 0xff990099, 0xff9900cc, 0xff9900ff, + 0xff993300, 0xff993333, 0xff993366, 0xff993399, 0xff9933cc, 0xff9933ff, + 0xff996600, 0xff996633, 0xff996666, 0xff996699, 0xff9966cc, 0xff9966ff, + 0xff999900, 0xff999933, 0xff999966, 0xff999999, 0xff9999cc, 0xff9999ff, + 0xff99cc00, 0xff99cc33, 0xff99cc66, 0xff99cc99, 0xff99cccc, 0xff99ccff, + 0xff99ff00, 0xff99ff33, 0xff99ff66, 0xff99ff99, 0xff99ffcc, 0xff99ffff, + 0xffcc0000, 0xffcc0033, 0xffcc0066, 0xffcc0099, 0xffcc00cc, 0xffcc00ff, + 0xffcc3300, 0xffcc3333, 0xffcc3366, 0xffcc3399, 0xffcc33cc, 0xffcc33ff, + 0xffcc6600, 0xffcc6633, 0xffcc6666, 0xffcc6699, 0xffcc66cc, 0xffcc66ff, + 0xffcc9900, 0xffcc9933, 0xffcc9966, 0xffcc9999, 0xffcc99cc, 0xffcc99ff, + 0xffcccc00, 0xffcccc33, 0xffcccc66, 0xffcccc99, 0xffcccccc, 0xffccccff, + 0xffccff00, 0xffccff33, 0xffccff66, 0xffccff99, 0xffccffcc, 0xffccffff, + 0xffff0000, 0xffff0033, 0xffff0066, 0xffff0099, 0xffff00cc, 0xffff00ff, + 0xffff3300, 0xffff3333, 0xffff3366, 0xffff3399, 0xffff33cc, 0xffff33ff, + 0xffff6600, 0xffff6633, 0xffff6666, 0xffff6699, 0xffff66cc, 0xffff66ff, + 0xffff9900, 0xffff9933, 0xffff9966, 0xffff9999, 0xffff99cc, 0xffff99ff, + 0xffffcc00, 0xffffcc33, 0xffffcc66, 0xffffcc99, 0xffffcccc, 0xffffccff, + 0xffffff00, 0xffffff33, 0xffffff66, 0xffffff99, 0xffffffcc, 0xffffffff, + 0x00000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000 +}; + static void pack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags, const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES], @@ -2241,6 +2287,32 @@ gst_video_format_get_info (GstVideoFormat format) return &formats[format].info; } +/** + * gst_video_format_get_palette: + * @format: a #GstVideoFormat + * @size: (out): size of the palette in bytes + * + * Get the default palette of @format. This the palette used in the pack + * function for paletted formats. + * + * Returns: the default palette of @format or %NULL when @format does not have a + * palette. + */ +const gpointer +gst_video_format_get_palette (GstVideoFormat format, gsize * size) +{ + g_return_val_if_fail (format < G_N_ELEMENTS (formats), NULL); + g_return_val_if_fail (size != NULL, NULL); + + switch (format) { + case GST_VIDEO_FORMAT_RGB8P: + *size = sizeof (std_palette_RGB8P); + return std_palette_RGB8P; + default: + return NULL; + } +} + typedef struct { const gchar *name; diff --git a/gst-libs/gst/video/video-format.h b/gst-libs/gst/video/video-format.h index fd22afd..afeda49 100644 --- a/gst-libs/gst/video/video-format.h +++ b/gst-libs/gst/video/video-format.h @@ -436,6 +436,8 @@ const gchar * gst_video_format_to_string (GstVideoFormat format) G_G const GstVideoFormatInfo * gst_video_format_get_info (GstVideoFormat format) G_GNUC_CONST; +const gpointer gst_video_format_get_palette (GstVideoFormat format, gsize *size); + #define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]" #define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]" diff --git a/win32/common/libgstvideo.def b/win32/common/libgstvideo.def index 1f99c75..3a9f630 100644 --- a/win32/common/libgstvideo.def +++ b/win32/common/libgstvideo.def @@ -128,6 +128,7 @@ EXPORTS gst_video_format_from_masks gst_video_format_from_string gst_video_format_get_info + gst_video_format_get_palette gst_video_format_get_type gst_video_format_to_fourcc gst_video_format_to_string