png: port to new memory API

This commit is contained in:
Wim Taymans 2012-01-25 12:41:42 +01:00
parent 684f504336
commit f87ab74add
2 changed files with 12 additions and 14 deletions

View file

@ -615,8 +615,7 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{ {
GstPngDec *pngdec; GstPngDec *pngdec;
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
guint8 *bdata = NULL; GstMapInfo map = GST_MAP_INFO_INIT;
gsize size;
pngdec = GST_PNGDEC (parent); pngdec = GST_PNGDEC (parent);
@ -640,12 +639,12 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
pngdec->in_timestamp = GST_BUFFER_TIMESTAMP (buffer); pngdec->in_timestamp = GST_BUFFER_TIMESTAMP (buffer);
pngdec->in_duration = GST_BUFFER_DURATION (buffer); pngdec->in_duration = GST_BUFFER_DURATION (buffer);
bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
GST_LOG_OBJECT (pngdec, "Got buffer, size=%d", (gint) size); GST_LOG_OBJECT (pngdec, "Got buffer, size=%d", (gint) map.size);
/* Progressive loading of the PNG image */ /* Progressive loading of the PNG image */
png_process_data (pngdec->png, pngdec->info, bdata, size); png_process_data (pngdec->png, pngdec->info, map.data, map.size);
if (pngdec->image_ready) { if (pngdec->image_ready) {
if (pngdec->framed) { if (pngdec->framed) {
@ -666,8 +665,8 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
ret = pngdec->ret; ret = pngdec->ret;
beach: beach:
if (G_LIKELY (bdata)) if (G_LIKELY (map.data))
gst_buffer_unmap (buffer, bdata, -1); gst_buffer_unmap (buffer, &map);
/* And release the buffer */ /* And release the buffer */
gst_buffer_unref (buffer); gst_buffer_unref (buffer);

View file

@ -231,14 +231,13 @@ static void
user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length) user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length)
{ {
GstPngEnc *pngenc; GstPngEnc *pngenc;
gsize size; GstMapInfo map;
guint8 *bdata;
pngenc = (GstPngEnc *) png_get_io_ptr (png_ptr); pngenc = (GstPngEnc *) png_get_io_ptr (png_ptr);
bdata = gst_buffer_map (pngenc->buffer_out, &size, NULL, GST_MAP_WRITE); gst_buffer_map (pngenc->buffer_out, &map, GST_MAP_WRITE);
if (pngenc->written + length >= size) { if (pngenc->written + length >= map.size) {
gst_buffer_unmap (pngenc->buffer_out, data, -1); gst_buffer_unmap (pngenc->buffer_out, &map);
GST_ERROR_OBJECT (pngenc, "output buffer bigger than the input buffer!?"); GST_ERROR_OBJECT (pngenc, "output buffer bigger than the input buffer!?");
png_error (png_ptr, "output buffer bigger than the input buffer!?"); png_error (png_ptr, "output buffer bigger than the input buffer!?");
@ -248,8 +247,8 @@ user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length)
GST_DEBUG_OBJECT (pngenc, "writing %u bytes", (guint) length); GST_DEBUG_OBJECT (pngenc, "writing %u bytes", (guint) length);
memcpy (bdata + pngenc->written, data, length); memcpy (map.data + pngenc->written, data, length);
gst_buffer_unmap (pngenc->buffer_out, data, -1); gst_buffer_unmap (pngenc->buffer_out, &map);
pngenc->written += length; pngenc->written += length;
} }