[0.11] gst-plugins-good: png: port to new memory API

Wim Taymans wtay at kemper.freedesktop.org
Wed Jan 25 03:42:36 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: f87ab74addc898e35b64729bbf435899de4ccab4
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=f87ab74addc898e35b64729bbf435899de4ccab4

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Wed Jan 25 12:41:42 2012 +0100

png: port to new memory API

---

 ext/libpng/gstpngdec.c |   13 ++++++-------
 ext/libpng/gstpngenc.c |   13 ++++++-------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c
index 6bb9e7b..496160a 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 18f5eda..ebdc369 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;
 }
 



More information about the gstreamer-commits mailing list