pngenc: add support for 8- and 16-bit gray images

Add support for direct encoding of 8- and 16-bit big endian gray images.

https://bugzilla.gnome.org/show_bug.cgi?id=672025
This commit is contained in:
Andrej Gelenberg 2012-03-13 23:08:38 +01:00 committed by Tim-Philipp Müller
parent 265a5bfa9b
commit 9fb6766870
2 changed files with 13 additions and 2 deletions

View file

@ -66,7 +66,7 @@ static GstStaticPadTemplate pngenc_sink_template =
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB ";" GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB ";"
GST_VIDEO_CAPS_GRAY8) GST_VIDEO_CAPS_GRAY8 ";" GST_VIDEO_CAPS_GRAY16 ("BIG_ENDIAN"))
); );
/* static GstElementClass *parent_class = NULL; */ /* static GstElementClass *parent_class = NULL; */
@ -167,6 +167,7 @@ gst_pngenc_setcaps (GstPad * pad, GstCaps * caps)
pngenc->png_color_type = PNG_COLOR_TYPE_RGB; pngenc->png_color_type = PNG_COLOR_TYPE_RGB;
break; break;
case GST_VIDEO_FORMAT_GRAY8: case GST_VIDEO_FORMAT_GRAY8:
case GST_VIDEO_FORMAT_GRAY16_BE:
pngenc->png_color_type = PNG_COLOR_TYPE_GRAY; pngenc->png_color_type = PNG_COLOR_TYPE_GRAY;
break; break;
default: default:
@ -174,6 +175,15 @@ gst_pngenc_setcaps (GstPad * pad, GstCaps * caps)
goto done; goto done;
} }
switch (format) {
case GST_VIDEO_FORMAT_GRAY16_BE:
pngenc->depth = 16;
break;
default: /* GST_VIDEO_FORMAT_RGB and GST_VIDEO_FORMAT_GRAY8 */
pngenc->depth = 8;
break;
}
if (G_UNLIKELY (pngenc->width < 16 || pngenc->width > 1000000 || if (G_UNLIKELY (pngenc->width < 16 || pngenc->width > 1000000 ||
pngenc->height < 16 || pngenc->height > 1000000)) { pngenc->height < 16 || pngenc->height > 1000000)) {
ret = FALSE; ret = FALSE;
@ -321,7 +331,7 @@ gst_pngenc_chain (GstPad * pad, GstBuffer * buf)
pngenc->png_info_ptr, pngenc->png_info_ptr,
pngenc->width, pngenc->width,
pngenc->height, pngenc->height,
8, pngenc->depth,
pngenc->png_color_type, pngenc->png_color_type,
PNG_INTERLACE_NONE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);

View file

@ -50,6 +50,7 @@ struct _GstPngEnc
png_infop png_info_ptr; png_infop png_info_ptr;
gint png_color_type; gint png_color_type;
gint depth;
gint width; gint width;
gint height; gint height;
gint stride; gint stride;