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 731773 - pnmdec: unsupported bit depth is not checked
pnmdec: unsupported bit depth is not checked
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other All
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-06-17 10:45 UTC by Sanjay NM
Modified: 2014-07-21 20:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pnmdec: unsupported bit depth is not checked (984 bytes, patch)
2014-06-17 10:45 UTC, Sanjay NM
reviewed Details | Review
Attached is the test image (59 bytes, image/x-portable-pixmap)
2014-06-17 10:47 UTC, Sanjay NM
  Details
pnmdec: Patch to use max value specified in decoder (2.51 KB, patch)
2014-06-18 06:22 UTC, Sanjay NM
needs-work Details | Review
pnmdec: Patch to handle max value in the PNM decoder (1.29 KB, patch)
2014-06-27 14:29 UTC, Sanjay NM
none Details | Review
pnmdec: Patch to handle max value in PNM decoder (1.29 KB, patch)
2014-06-27 14:34 UTC, Sanjay NM
none Details | Review

Description Sanjay NM 2014-06-17 10:45:51 UTC
Created attachment 278583 [details] [review]
pnmdec: unsupported bit depth is not checked

PNM Decoder does not exit gracefully if its input with any bit depth apart from 8 (max value of 255). Added a check and returning error to fix this issue
Comment 1 Sanjay NM 2014-06-17 10:47:22 UTC
Created attachment 278584 [details]
Attached is the test image

This is the test image for which decoder fails. This opens in gimp. Decoder should return error and exit gracefully
Comment 2 Thiago Sousa Santos 2014-06-17 12:22:57 UTC
Review of attachment 278583 [details] [review]:

Wouldn't it be better to just support it instead of rejecting the images?

Isn't it a matter of converting from range 0-X to 0-255?
Comment 3 Sanjay NM 2014-06-17 13:15:03 UTC
Thanks for the quick review. Will add this support. This will require little time. This bug was throwing the pipeline into infinite loop so did error handlung for now. Will add this feature and resubmit may be in a week
Comment 4 Sanjay NM 2014-06-18 06:22:14 UTC
Created attachment 278654 [details] [review]
pnmdec: Patch to use max value specified in decoder

Added code to limit the max value to the specified amount in the data stream.
Added check to see if max value is out of range.

verified the behavior of decoder, now its working similar to other standard viewers like gimp, gthumb
Comment 5 Thiago Sousa Santos 2014-06-25 14:56:45 UTC
Review of attachment 278654 [details] [review]:

This patch only handles values outside of the range, it should actually convert from the input range to 0-255 range.

::: gst/pnm/gstpnmdec.c
@@ +250,3 @@
+  for (i = 0; i < total_bytes; i++) {
+    if (omap.data[i] > s->mngr.info.max) {
+      omap.data[i] = 255;

This is not correct, it is only clamping values that are above the max to 255.

Imagine you have an input that has a maximum value of 16.

If a pixel has a value of 8 it should be mapped to 127 on the output.

IMHO it would be better to have something like:

if (s->mngr.info.max == 255) just memcpy
else { iterate all pixels doing the conversion from the input range to 0-255 }
Comment 6 Sanjay NM 2014-06-27 14:29:13 UTC
Created attachment 279404 [details] [review]
pnmdec: Patch to handle max value in the PNM decoder

Thanks for reviewing this patch.
As suggested incorporated changes to convert from 0 - max range to 0 - 255 range.
Comment 7 Sanjay NM 2014-06-27 14:34:43 UTC
Created attachment 279406 [details] [review]
pnmdec: Patch to handle max value in PNM decoder

pnmdec: Patch to handle max value in the PNM decoder

Thanks for reviewing this patch.
As suggested incorporated changes to convert from 0 - max range to 0 - 255
range.

Had not checked patch, so resubmitting. Sorry ..
Comment 8 Thiago Sousa Santos 2014-07-21 20:34:18 UTC
Squashed the patches together, added a commit message and pushed. Thanks for the work.


commit 15a2da8ba7a6d5cdc60937f37f31d9651b374227
Author: Sanjay NM <sanjay.nm@samsung.com>
Date:   Wed Jun 18 11:44:54 2014 +0530

    pnmdec: Patch to handle max value
    
    Convert the image values from 0-maxvalue to 0-255 when
    'decoding' the pnm image
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731773