ext/libpng/gstpngenc.*: Fix strides. Fixes #364856.

Original commit message from CVS:
* ext/libpng/gstpngenc.c: (gst_pngenc_setcaps), (gst_pngenc_chain):
* ext/libpng/gstpngenc.h:
Fix strides. Fixes #364856.
Cleanup capsnego.
Set caps on outgoing buffers.
This commit is contained in:
Wim Taymans 2006-10-27 17:10:42 +00:00
parent 69ce71927e
commit 82ad65b262
4 changed files with 26 additions and 26 deletions

View file

@ -1,3 +1,11 @@
2006-10-27 Wim Taymans <wim@fluendo.com>
* ext/libpng/gstpngenc.c: (gst_pngenc_setcaps), (gst_pngenc_chain):
* ext/libpng/gstpngenc.h:
Fix strides. Fixes #364856.
Cleanup capsnego.
Set caps on outgoing buffers.
2006-10-18 Wim Taymans <wim@fluendo.com> 2006-10-18 Wim Taymans <wim@fluendo.com>
Patch by: Ville Syrjala <ville dot syrjala at movial dot fi> Patch by: Ville Syrjala <ville dot syrjala at movial dot fi>

2
common

@ -1 +1 @@
Subproject commit efcacf2625da231fbee99b68e0f5db6816cf6fad Subproject commit ee0bb43e2b66781d04078e2210404da48f6c68f0

View file

@ -150,7 +150,6 @@ gst_pngenc_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure; GstStructure *structure;
GstCaps *pcaps; GstCaps *pcaps;
gboolean ret = TRUE; gboolean ret = TRUE;
GstPad *opeer;
pngenc = GST_PNGENC (gst_pad_get_parent (pad)); pngenc = GST_PNGENC (gst_pad_get_parent (pad));
@ -160,22 +159,20 @@ gst_pngenc_setcaps (GstPad * pad, GstCaps * caps)
fps = gst_structure_get_value (structure, "framerate"); fps = gst_structure_get_value (structure, "framerate");
gst_structure_get_int (structure, "bpp", &pngenc->bpp); gst_structure_get_int (structure, "bpp", &pngenc->bpp);
opeer = gst_pad_get_peer (pngenc->srcpad); if (pngenc->bpp == 32)
if (opeer) { pngenc->stride = pngenc->width * 4;
pcaps = gst_caps_new_simple ("image/png", else
"width", G_TYPE_INT, pngenc->width, pngenc->stride = GST_ROUND_UP_4 (pngenc->width * 3);
"height", G_TYPE_INT, pngenc->height, NULL);
structure = gst_caps_get_structure (pcaps, 0);
gst_structure_set_value (structure, "framerate", fps);
if (gst_pad_accept_caps (opeer, pcaps)) { pcaps = gst_caps_new_simple ("image/png",
gst_pad_set_caps (pngenc->srcpad, pcaps); "width", G_TYPE_INT, pngenc->width,
} else "height", G_TYPE_INT, pngenc->height, NULL);
ret = FALSE; structure = gst_caps_get_structure (pcaps, 0);
gst_caps_unref (pcaps); gst_structure_set_value (structure, "framerate", fps);
gst_object_unref (opeer);
}
ret = gst_pad_set_caps (pngenc->srcpad, pcaps);
gst_caps_unref (pcaps);
gst_object_unref (pngenc); gst_object_unref (pngenc);
return ret; return ret;
@ -306,9 +303,10 @@ gst_pngenc_chain (GstPad * pad, GstBuffer * buf)
png_set_write_fn (pngenc->png_struct_ptr, pngenc, png_set_write_fn (pngenc->png_struct_ptr, pngenc,
(png_rw_ptr) user_write_data, user_flush_data); (png_rw_ptr) user_write_data, user_flush_data);
for (row_index = 0; row_index < pngenc->height; row_index++) for (row_index = 0; row_index < pngenc->height; row_index++) {
row_pointers[row_index] = GST_BUFFER_DATA (buf) + row_pointers[row_index] = GST_BUFFER_DATA (buf) +
(row_index * pngenc->png_info_ptr->rowbytes); (row_index * pngenc->stride);
}
png_write_info (pngenc->png_struct_ptr, pngenc->png_info_ptr); png_write_info (pngenc->png_struct_ptr, pngenc->png_info_ptr);
png_write_image (pngenc->png_struct_ptr, row_pointers); png_write_image (pngenc->png_struct_ptr, row_pointers);
@ -320,6 +318,7 @@ gst_pngenc_chain (GstPad * pad, GstBuffer * buf)
png_destroy_write_struct (&pngenc->png_struct_ptr, (png_infopp) NULL); png_destroy_write_struct (&pngenc->png_struct_ptr, (png_infopp) NULL);
gst_buffer_stamp (pngenc->buffer_out, buf); gst_buffer_stamp (pngenc->buffer_out, buf);
gst_buffer_unref (buf); gst_buffer_unref (buf);
gst_buffer_set_caps (pngenc->buffer_out, GST_PAD_CAPS (pngenc->srcpad));
if ((ret = gst_pad_push (pngenc->srcpad, pngenc->buffer_out)) != GST_FLOW_OK) if ((ret = gst_pad_push (pngenc->srcpad, pngenc->buffer_out)) != GST_FLOW_OK)
goto done; goto done;
@ -334,15 +333,7 @@ gst_pngenc_chain (GstPad * pad, GstBuffer * buf)
gst_pad_push_event (pngenc->srcpad, event); gst_pad_push_event (pngenc->srcpad, event);
ret = GST_FLOW_UNEXPECTED; ret = GST_FLOW_UNEXPECTED;
} }
/* else if (pngenc->newmedia) { */
/* /\* send new media discont *\/ */
/* GstEvent *newmedia_event; */
/* newmedia_event = */
/* gst_event_new_discontinuous (TRUE, GST_FORMAT_TIME, (gint64) 0, */
/* GST_FORMAT_UNDEFINED); */
/* ret = gst_pad_push (pngenc->srcpad, GST_DATA (newmedia_event)); */
/* } */
done: done:
GST_DEBUG_OBJECT (pngenc, "END, ret:%d", ret); GST_DEBUG_OBJECT (pngenc, "END, ret:%d", ret);

View file

@ -51,6 +51,7 @@ struct _GstPngEnc
gint width; gint width;
gint height; gint height;
gint bpp; gint bpp;
gint stride;
guint compression_level; guint compression_level;
gboolean snapshot; gboolean snapshot;