pngdec: enable libpng interlaced picture handling

Makes libpng deinterlace Adam7 interlaced pictures
by default. It is the only interlaced format available
and if the picture isn't interlaced the code should behave
as before.

https://bugzilla.gnome.org/show_bug.cgi?id=726161
diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c
index 0608449..d4b8ef1 100644
--- a/ext/libpng/gstpngdec.c
+++ b/ext/libpng/gstpngdec.c
@@ -179,15 +179,12 @@
 
   pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));
 
-  /* FIXME: implement interlaced pictures */
-
   /* If buffer_out doesn't exist, it means buffer_alloc failed, which 
    * will already have set the return code */
-  if (GST_IS_BUFFER (pngdec->current_frame->output_buffer)) {
+  if (new_row && GST_IS_BUFFER (pngdec->current_frame->output_buffer)) {
     GstVideoFrame frame;
     GstBuffer *buffer = pngdec->current_frame->output_buffer;
     size_t offset;
-    gint width;
     guint8 *data;
 
     if (!gst_video_frame_map (&frame, &pngdec->output_state->info, buffer,
@@ -198,13 +195,14 @@
 
     data = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
     offset = row_num * GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);
-    GST_LOG ("got row %u, copying in buffer %p at offset %" G_GSIZE_FORMAT,
-        (guint) row_num, pngdec->current_frame->output_buffer, offset);
-    width = GST_ROUND_UP_4 (png_get_rowbytes (pngdec->png, pngdec->info));
-    memcpy (data + offset, new_row, width);
+    GST_LOG ("got row %u at pass %d, copying in buffer %p at offset %"
+        G_GSIZE_FORMAT, (guint) row_num, pass,
+        pngdec->current_frame->output_buffer, offset);
+    png_progressive_combine_row (pngdec->png, data + offset, new_row);
     gst_video_frame_unmap (&frame);
     pngdec->ret = GST_FLOW_OK;
-  }
+  } else
+    pngdec->ret = GST_FLOW_OK;
 }
 
 static void
@@ -286,6 +284,8 @@
     png_set_palette_to_rgb (pngdec->png);
   }
 
+  png_set_interlace_handling (pngdec->png);
+
   /* Update the info structure */
   png_read_update_info (pngdec->png, pngdec->info);