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 730523 - pnmdec: PBM (Bitmap) decoding support is not present
pnmdec: PBM (Bitmap) decoding support is not present
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal enhancement
: 1.3.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-21 13:37 UTC by Sanjay NM
Modified: 2014-06-18 07:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pnmdec: PBM (Bitmap) decoding support Added (2.79 KB, patch)
2014-05-21 13:37 UTC, Sanjay NM
none Details | Review
pnmdec: Support to decode PBM BInary files (5.16 KB, patch)
2014-05-27 12:37 UTC, Sanjay NM
needs-work Details | Review
pnmdec: Added support for PBM Decoding (4.21 KB, patch)
2014-06-17 09:03 UTC, Sanjay NM
committed Details | Review

Description Sanjay NM 2014-05-21 13:37:44 UTC
Created attachment 276936 [details] [review]
pnmdec: PBM (Bitmap) decoding support Added

PNM Decoder does not support PBM - Bitmap decoding.
It was marked as FIXME in the code.
Have added this support and tested with PBM content from http://www.fileformat.info/format/pbm/sample/index.htm (MARBLES.PBM)
It is working well.
Request to please review the patch
Comment 1 Thiago Sousa Santos 2014-05-21 14:52:52 UTC
What pipeline are you using to test this? Doesn't seem to work here.

Also I get a warning: GStreamer-WARNING **: gstpad.c:4618:store_sticky_event:<pnmdec0:src> Sticky event misordering, got 'segment' before 'caps'

Do you get that, too?
Comment 2 Thiago Sousa Santos 2014-05-21 14:53:55 UTC
Another thing, please avoid erasing empty lines or doing code style changes that are unrelated to your patch. Makes it harder to review and track changes.
Comment 3 Sanjay NM 2014-05-21 16:55:19 UTC
I am using 
gst-launch-1.0 filesrc location=MARBLES.PBM ! pnmdec ! filesink location=out.pbm

I get raw output from this. I add PBM header to this raw output and view it in gimp to see if the output if fine. It worked well. Encoding it back to PNM may not work as PNM Encoder may not support Bitmap encoding yet. I can add that support if required.

I am away from my setup, I will test again tomorrow and update on the warning.

Will take care to retain empty lines. To debug I had added printf statements. When I deleted them at the end may be few empty lines got deleted. Sorry for that.
Comment 4 Thiago Sousa Santos 2014-05-21 20:21:04 UTC
I was trying to directly display the decoded data using:

"gst-launch-1.0 filesrc ! pnmdec ! imagefreeze ! autovideosink"

It seems that it didn't even produce data here.
Comment 5 Sanjay NM 2014-05-22 05:55:05 UTC
I am getting the warning you have mentioned.
I tried with original pnmdec without my patch, even with that notice the same thing. Is there anyway I can fix this ?

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...

(gst-launch-1.0:5286): GStreamer-WARNING **: gstpad.c:4618:store_sticky_event:<pnmdec0:src> Sticky event misordering, got 'segment' before 'caps'

(gst-launch-1.0:5286): GStreamer-WARNING **: gstpad.c:4618:store_sticky_event:<filesink0:sink> Sticky event misordering, got 'segment' before 'caps'
Pipeline is PREROLLED ...
Comment 6 Sebastian Dröge (slomo) 2014-05-22 07:05:48 UTC
You would need to delay all events that must be after the caps event to actually come after the caps event. Or just port the decoder to GstVideoDecoder.
Comment 7 Sanjay NM 2014-05-27 12:37:31 UTC
Created attachment 277287 [details] [review]
pnmdec: Support to decode PBM BInary files

Attached is the patch to decode PBM Binary file. It is tested with below pipeline and is working well. It was not possible to render Binary data using the below pipeline, so added code to convert binary to Gray to provide the output.

Still Sticky event warning is seen. Working on moving to GstVideoDecoder. Will submit that as a separate patch

gst-launch-1.0 filesrc location=MARBLES.PBM ! pnmdec ! videoconvert ! imagefreeze ! autovideosink

Request to please review this patch.
Comment 8 Thiago Sousa Santos 2014-05-27 14:30:02 UTC
Review of attachment 277287 [details] [review]:

Your patch is correct and just needs some minor fixes, the issues are all with the code that was already in pnmdec.

Because of the current state of the code I'd strongly suggest that you first get it ported to videodecoder, then we sort out these minor issues to make it properly work with already existing scenarios and then we get the PBM support on top of it. What do you think? This patch of yours would mostly remain unmodified and you would just have to copy and paste the code to the new ported version.

::: gst/pnm/gstpnmdec.c
@@ +103,3 @@
+  gint bytes, i;
+  guchar *bufdatabin, *bufdatagray;
+  GstMemory *smemory, *dmemory;

You don't need to use GstMemory here you can directly map with gst_buffer_map/_unmap, it should make the code simpler.

@@ +105,3 @@
+  GstMemory *smemory, *dmemory;
+
+  GstMapInfo sinfo, dinfo;

Would you mind elaborating this comment a bit more? Mention that the image is a binary (black/white) image and there is no support for it in gstvideo yet?

Put a TODO into the comment so someone know that there is some work pending here. The ideal solution would be to have binary image support in gstvideo in gst-plugins-base and have this conversion happening in videoconvert.

Anyway let's do this by steps so first we get it working here and then we can improve with moving it to -base and videoconvert.

@@ +162,1 @@
   }

This part of your patch is correct with the given state of the code but this whole if(gst_buffer_get_size ...) seems misplaced.

Imagine that you already have some data in s->buf and you receive a new buffer that is exactly s->size. It would get processed before the data that it received before and would likely lead to errors. This is not the usual use case for pnm data but gstreamer elements don't know much about their surroundings and should be resilient to multiple scenarios when possible.

@@ +184,3 @@
+      memset (&s->mngr, 0, sizeof (GstPnmInfoMngr));
+      s->size = 0;
+      s->size = 0;

This is where the buffer size should be checked. And the check should be for >= s->size instead of just for == s->size. (Again, this is not from your patch, it is something that was already there).

The reason is that you might receive more data than you need and pnmdec would process the only s->size data and leave the remaining data there to be merged with any subsequent data it would receive.

This == here is what prevents it from working for me.
Comment 9 Sanjay NM 2014-06-17 09:03:12 UTC
Created attachment 278574 [details] [review]
pnmdec: Added support for PBM Decoding

Updated the patch to work with gstVideoDecoder.
Have tested and works well.

Request to please review
Comment 10 Thiago Sousa Santos 2014-06-17 12:21:51 UTC
Thanks for the patch. Please notice the commit message format for the next contributions:

elementname: short description

commit ed1a6641718320972658da3bbccfeaf5329a86ee
Author: Sanjay NM <sanjay.nm@samsung.com>
Date:   Tue Jun 17 12:50:17 2014 +0530

    pnmdec: Added PBM Support
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730523
Comment 11 m][sko 2014-06-18 07:19:51 UTC
plz fix Makefile.am for dependency on GstAdapter

libgstpnm_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) -lgstvideo-@GST_API_VERSION@