ext/libpng/: Fix byte-order, use proper fixed caps. Fixes #164197.

Original commit message from CVS:
Reviewed by:  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_init), (gst_pngdec_chain):
* ext/libpng/gstpngenc.c:
Fix byte-order, use proper fixed caps. Fixes #164197.
This commit is contained in:
Ronald S. Bultje 2005-02-08 11:11:21 +00:00
parent 5ab3df2846
commit 840c55ebd1
3 changed files with 52 additions and 73 deletions

View file

@ -1,3 +1,11 @@
2005-02-08 Gergely Nagy <algernon@bonehunter.rulez.org>
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_init), (gst_pngdec_chain):
* ext/libpng/gstpngenc.c:
Fix byte-order, use proper fixed caps. Fixes #164197.
2005-02-08 Jan Schmidt <thaytan@mad.scientist.com> 2005-02-08 Jan Schmidt <thaytan@mad.scientist.com>
* configure.ac: * configure.ac:
@ -37,7 +45,7 @@
(gst_mpeg_parse_get_rate), (gst_mpeg_parse_convert_src), (gst_mpeg_parse_get_rate), (gst_mpeg_parse_convert_src),
(gst_mpeg_parse_handle_src_query), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event): (gst_mpeg_parse_handle_src_event):
Use audio/x-dvd-lpcm for LPCM output. Use audio/x-dvd-lpcm for LPCM output.
Add DTS output. Add DTS output.
2005-02-08 Gergely Nagy <algernon@bonehunter.rulez.org> 2005-02-08 Gergely Nagy <algernon@bonehunter.rulez.org>

View file

@ -47,8 +47,6 @@ static void gst_pngdec_init (GstPngDec * pngdec);
static void gst_pngdec_chain (GstPad * pad, GstData * _data); static void gst_pngdec_chain (GstPad * pad, GstData * _data);
static GstCaps *gst_pngdec_src_getcaps (GstPad * pad);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
@ -93,7 +91,7 @@ static GstStaticPadTemplate gst_pngdec_src_pad_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB) GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_BGR)
); );
static GstStaticPadTemplate gst_pngdec_sink_pad_template = static GstStaticPadTemplate gst_pngdec_sink_pad_template =
@ -129,7 +127,6 @@ gst_pngdec_class_init (GstPngDecClass * klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
} }
static GstPadLinkReturn static GstPadLinkReturn
gst_pngdec_sinklink (GstPad * pad, const GstCaps * caps) gst_pngdec_sinklink (GstPad * pad, const GstCaps * caps)
{ {
@ -158,7 +155,7 @@ gst_pngdec_init (GstPngDec * pngdec)
gst_pad_set_chain_function (pngdec->sinkpad, gst_pngdec_chain); gst_pad_set_chain_function (pngdec->sinkpad, gst_pngdec_chain);
gst_pad_set_link_function (pngdec->sinkpad, gst_pngdec_sinklink); gst_pad_set_link_function (pngdec->sinkpad, gst_pngdec_sinklink);
gst_pad_set_getcaps_function (pngdec->srcpad, gst_pngdec_src_getcaps); gst_pad_use_explicit_caps (pngdec->srcpad);
pngdec->png = NULL; pngdec->png = NULL;
pngdec->info = NULL; pngdec->info = NULL;
@ -169,71 +166,6 @@ gst_pngdec_init (GstPngDec * pngdec)
pngdec->fps = -1; pngdec->fps = -1;
} }
static GstCaps *
gst_pngdec_src_getcaps (GstPad * pad)
{
GstPngDec *pngdec;
GstCaps *caps;
gint i;
GstPadTemplate *templ;
GstCaps *inter;
pngdec = GST_PNGDEC (gst_pad_get_parent (pad));
templ = gst_static_pad_template_get (&gst_pngdec_src_pad_template);
caps = gst_caps_copy (gst_pad_template_get_caps (templ));
if (pngdec->color_type != -1) {
GstCaps *to_inter = NULL;
if (pngdec->info && pngdec->info->bit_depth != 8) {
GST_ELEMENT_ERROR (pngdec, STREAM, NOT_IMPLEMENTED, (NULL),
("pngdec only supports 8 bit images for now"));
return NULL;
}
switch (pngdec->color_type) {
case PNG_COLOR_TYPE_RGB:
to_inter = gst_caps_new_simple ("video/x-raw-rgb",
"bpp", G_TYPE_INT, 24, NULL);
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
to_inter = gst_caps_new_simple ("video/x-raw-rgb",
"bpp", G_TYPE_INT, 32, NULL);
break;
case PNG_COLOR_TYPE_GRAY:
case PNG_COLOR_TYPE_PALETTE:
case PNG_COLOR_TYPE_GRAY_ALPHA:
default:
GST_ELEMENT_ERROR (pngdec, STREAM, NOT_IMPLEMENTED, (NULL),
("pngdec does not support grayscale or paletted data yet"));
break;
}
inter = gst_caps_intersect (caps, to_inter);
gst_caps_free (caps);
gst_caps_free (to_inter);
caps = inter;
}
for (i = 0; i < gst_caps_get_size (caps); i++) {
GstStructure *structure = gst_caps_get_structure (caps, i);
if (pngdec->width != -1) {
gst_structure_set (structure, "width", G_TYPE_INT, pngdec->width, NULL);
}
if (pngdec->height != -1) {
gst_structure_set (structure, "height", G_TYPE_INT, pngdec->height, NULL);
}
if (pngdec->fps != -1) {
gst_structure_set (structure,
"framerate", G_TYPE_DOUBLE, pngdec->fps, NULL);
}
}
return caps;
}
static void static void
user_read_data (png_structp png_ptr, png_bytep data, png_size_t length) user_read_data (png_structp png_ptr, png_bytep data, png_size_t length)
{ {
@ -316,14 +248,53 @@ gst_pngdec_chain (GstPad * pad, GstData * _data)
png_get_IHDR (pngdec->png, pngdec->info, &width, &height, png_get_IHDR (pngdec->png, pngdec->info, &width, &height,
&depth, &color, NULL, NULL, NULL); &depth, &color, NULL, NULL, NULL);
if (pngdec->info->bit_depth != 8) {
gst_buffer_unref (buf);
png_destroy_read_struct (&pngdec->png, &pngdec->info, &pngdec->endinfo);
GST_ELEMENT_ERROR (pngdec, STREAM, NOT_IMPLEMENTED, (NULL),
("pngdec only supports 8 bit images for now"));
return;
}
if (pngdec->width != width || if (pngdec->width != width ||
pngdec->height != height || pngdec->height != height ||
pngdec->color_type != pngdec->info->color_type) { pngdec->color_type != pngdec->info->color_type) {
GstCaps *caps, *templ, *res;
gboolean ret;
gint bpp;
pngdec->width = width; pngdec->width = width;
pngdec->height = height; pngdec->height = height;
pngdec->color_type = pngdec->info->color_type; pngdec->color_type = pngdec->info->color_type;
if (GST_PAD_LINK_FAILED (gst_pad_renegotiate (pngdec->srcpad))) { templ = gst_caps_copy (gst_pad_template_get_caps
(gst_static_pad_template_get (&gst_pngdec_src_pad_template)));
switch (pngdec->color_type) {
case PNG_COLOR_TYPE_RGB:
bpp = 24;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
bpp = 32;
break;
default:
GST_ELEMENT_ERROR (pngdec, STREAM, NOT_IMPLEMENTED, (NULL),
("pngdec does not support grayscale or paletted data yet"));
return;
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
"bpp", G_TYPE_INT, bpp, "framerate", G_TYPE_DOUBLE, pngdec->fps, NULL);
res = gst_caps_intersect (templ, caps);
gst_caps_free (caps);
gst_caps_free (templ);
ret = gst_pad_set_explicit_caps (pngdec->srcpad, res);
gst_caps_free (res);
if (!ret) {
gst_buffer_unref (buf); gst_buffer_unref (buf);
png_destroy_read_struct (&pngdec->png, &pngdec->info, &pngdec->endinfo); png_destroy_read_struct (&pngdec->png, &pngdec->info, &pngdec->endinfo);
GST_ELEMENT_ERROR (pngdec, CORE, NEGOTIATION, (NULL), (NULL)); GST_ELEMENT_ERROR (pngdec, CORE, NEGOTIATION, (NULL), (NULL));

View file

@ -76,7 +76,7 @@ static GstStaticPadTemplate pngenc_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
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_BGRA ";" GST_VIDEO_CAPS_BGR)
); );
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;