After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740058 - pngparse: improve parsing of the image
pngparse: improve parsing of the image
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-13 10:20 UTC by Vineeth
Modified: 2015-04-21 06:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pngparse improvements (2.56 KB, patch)
2014-11-13 10:27 UTC, Vineeth
rejected Details | Review
pngparse improvements (3.60 KB, patch)
2014-11-19 04:18 UTC, Vineeth
needs-work Details | Review
pngparse improvements (3.60 KB, patch)
2014-11-27 04:21 UTC, Vineeth
none Details | Review

Description Vineeth 2014-11-13 10:20:23 UTC
Everytime a buffer is being provided from baseparse, we are parsing all the data from the beginning.
 But since we would have already parsed some of the data in the previous iterations,
 it doesnt make much sense to keep parsing the same everytime.
 Hence skipping the data which is already read in previous iterations to improve the parsing performance.


  On testing with the sample image MARBLE24.PNG(2.1 MB) @ http://www.fileformat.info/format/png/sample/index.htm

  The data chunks being read using the for loop is being called 4610 times with the present implementation.
  On applying my patch it will be reduced to 518 times.
Comment 1 Vineeth 2014-11-13 10:27:10 UTC
Created attachment 290620 [details] [review]
pngparse improvements
Comment 2 Luis de Bethencourt 2014-11-18 18:03:27 UTC
Looks good to me.

Could you please change the commit message so no line is longer than 80 characters?
Comment 3 Tim-Philipp Müller 2014-11-18 18:16:58 UTC
Comment on attachment 290620 [details] [review]
pngparse improvements

Does not look good to me. Without even looking at the other changes, this you can't do:

>-  guint width = 0, height = 0;
>+  static guint width = 0, height = 0;

or you get problems when running multiple pngparse elements, and you also can't reset these properly, etc.
Comment 4 Vineeth 2014-11-19 04:18:03 UTC
Created attachment 290955 [details] [review]
pngparse improvements

Removed static declaration of width and height and added new logic to check for change in width and height.

Please verify if this is proper.
Comment 5 Reynaldo H. Verdejo Pinochet 2014-11-20 12:26:04 UTC
Comment on attachment 290955 [details] [review]
pngparse improvements


> [...]
>diff --git a/gst/videoparsers/gstpngparse.h b/gst/videoparsers/gstpngparse.h
>index 3574481..2e8f234 100644
>--- a/gst/videoparsers/gstpngparse.h
>+++ b/gst/videoparsers/gstpngparse.h
>@@ -49,6 +49,8 @@ struct _GstPngParse
> 
>   guint width;
>   guint height;

wouldn't hurt making this explicitly guint32 to match the
spec? I understand PNG uses 32 bits unsigned integers for
these values. Just a nit anyway.

>+  guint32 skip_length;

Coming from the above I'd make this guint64 or, unless my
understanding is wrong, you risk overflowing at reading
perfectly valid (albeit rather big) png frames.
Comment 6 Tim-Philipp Müller 2014-11-20 12:35:31 UTC
> >   guint width;
> >   guint height;
> 
> wouldn't hurt making this explicitly guint32 to match the
> spec? I understand PNG uses 32 bits unsigned integers for
> these values. Just a nit anyway.

Rule #1 of patch club: don't change existing things that don't need changing, keep the changeset as small as possible :)
Comment 7 Vineeth 2014-11-26 02:58:31 UTC
Should i change anything with respect to the patch?
as per Tims' comment, there is no need to change.
Comment 8 Reynaldo H. Verdejo Pinochet 2014-11-26 14:29:29 UTC
No change to width & height needed (I actually mistakenly
read those as part of the changeset) but going with guint64
for skip_length would still be better choice IMHO.
Comment 9 Vineeth 2014-11-27 04:21:20 UTC
Created attachment 291609 [details] [review]
pngparse improvements

Changing skip_length to unit64
Comment 10 Vineeth 2014-12-17 09:56:36 UTC
can someone check this and commit the patch as it is already reviewed :)