GNOME Bugzilla – Bug 731773
pnmdec: unsupported bit depth is not checked
Last modified: 2014-07-21 20:34:41 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
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
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?
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
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
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 }
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.
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 ..
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