diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index 6bb9e7b7ad..496160a0d9 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -615,8 +615,7 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) { GstPngDec *pngdec; GstFlowReturn ret = GST_FLOW_OK; - guint8 *bdata = NULL; - gsize size; + GstMapInfo map = GST_MAP_INFO_INIT; 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_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 */ - 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->framed) { @@ -666,8 +665,8 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) ret = pngdec->ret; beach: - if (G_LIKELY (bdata)) - gst_buffer_unmap (buffer, bdata, -1); + if (G_LIKELY (map.data)) + gst_buffer_unmap (buffer, &map); /* And release the buffer */ gst_buffer_unref (buffer); diff --git a/ext/libpng/gstpngenc.c b/ext/libpng/gstpngenc.c index 18f5eda78e..ebdc36902a 100644 --- a/ext/libpng/gstpngenc.c +++ b/ext/libpng/gstpngenc.c @@ -231,14 +231,13 @@ static void user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length) { GstPngEnc *pngenc; - gsize size; - guint8 *bdata; + GstMapInfo map; pngenc = (GstPngEnc *) png_get_io_ptr (png_ptr); - bdata = gst_buffer_map (pngenc->buffer_out, &size, NULL, GST_MAP_WRITE); - if (pngenc->written + length >= size) { - gst_buffer_unmap (pngenc->buffer_out, data, -1); + gst_buffer_map (pngenc->buffer_out, &map, GST_MAP_WRITE); + if (pngenc->written + length >= map.size) { + gst_buffer_unmap (pngenc->buffer_out, &map); GST_ERROR_OBJECT (pngenc, "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); - memcpy (bdata + pngenc->written, data, length); - gst_buffer_unmap (pngenc->buffer_out, data, -1); + memcpy (map.data + pngenc->written, data, length); + gst_buffer_unmap (pngenc->buffer_out, &map); pngenc->written += length; }