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 767402 - OpenJPEG decoder: use new sampling field to determine channel order for j2c and jpc streams
OpenJPEG decoder: use new sampling field to determine channel order for j2c a...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.9.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-08 15:26 UTC by Aaron Boxer
Modified: 2016-06-21 08:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
use sampling field to determine RGB channel order (4.75 KB, patch)
2016-06-12 02:43 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (6.98 KB, patch)
2016-06-12 15:21 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (6.96 KB, patch)
2016-06-13 11:46 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (5.19 KB, patch)
2016-06-14 02:30 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (5.09 KB, patch)
2016-06-14 02:40 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (5.10 KB, patch)
2016-06-14 02:57 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (5.06 KB, patch)
2016-06-14 18:11 UTC, Aaron Boxer
none Details | Review
use sampling field to determine RGB channel order (5.55 KB, patch)
2016-06-17 20:42 UTC, Aaron Boxer
committed Details | Review

Description Aaron Boxer 2016-06-08 15:26:03 UTC
Currently, there is now way of knowing from a j2c or jpc stream what the channel order is. jp2 streams will store this information in the channel definition box.

However, using the "sampling" field, the channel order can be determined.
Comment 1 Aaron Boxer 2016-06-12 02:41:25 UTC
This only applies to sRGB streams.
Comment 2 Aaron Boxer 2016-06-12 02:43:08 UTC
Created attachment 329628 [details] [review]
use sampling field to determine RGB channel order
Comment 3 Sebastian Dröge (slomo) 2016-06-12 07:08:07 UTC
(In reply to boxerab@gmail.com from comment #1)
> This only applies to sRGB streams.

For the other cases it could use sampling instead of colorspace to know the component type.


Also for the future it could potentially use the sampling for distinguishing YCbCr-X:X:X and YCrCb-X:X:X
Comment 4 Sebastian Dröge (slomo) 2016-06-12 07:08:59 UTC
Review of attachment 329628 [details] [review]:

::: ext/openjpeg/gstopenjpegdec.c
@@ +688,3 @@
+          if (self->sampling)
+            format =
+                reverse_rgb_channels (self->sampling) ? GST_VIDEO_FORMAT_BGRA :

You seem to have forgotten to add this function :)
Comment 5 Aaron Boxer 2016-06-12 14:13:12 UTC
(In reply to Sebastian Dröge (slomo) from comment #4)
> Review of attachment 329628 [details] [review] [review]:
> 
> ::: ext/openjpeg/gstopenjpegdec.c
> @@ +688,3 @@
> +          if (self->sampling)
> +            format =
> +                reverse_rgb_channels (self->sampling) ?
> GST_VIDEO_FORMAT_BGRA :
> 
> You seem to have forgotten to add this function :)

It's up there at the top. Just a small helper method :)
Comment 6 Aaron Boxer 2016-06-12 15:21:17 UTC
Created attachment 329639 [details] [review]
use sampling field to determine RGB channel order

now also using sampling field, if present, to determine jpeg 2000 colour space
Comment 7 Sebastian Dröge (slomo) 2016-06-13 06:36:02 UTC
Review of attachment 329639 [details] [review]:

::: ext/openjpeg/gstopenjpegdec.c
@@ +208,3 @@
   }
 
+  if ((sampling = gst_structure_get_string (s, "sampling"))) {

Should we add sampling instead of colorspace to the caps? A parser can always be used.

Alternatively we should warn below if sampling is not provided because everything else is guesswork then

@@ +224,3 @@
   }
 
+  self->sampling = gst_structure_get_string (s, "sampling");

You need to g_strdup() here. The returned string is only valid as long as you have a strong reference to the structure
Comment 8 Aaron Boxer 2016-06-13 11:37:51 UTC
(In reply to Sebastian Dröge (slomo) from comment #7)
> Review of attachment 329639 [details] [review] [review]:
> 
> ::: ext/openjpeg/gstopenjpegdec.c
> @@ +208,3 @@
>    }
>  
> +  if ((sampling = gst_structure_get_string (s, "sampling"))) {
> 
> Should we add sampling instead of colorspace to the caps? A parser can
> always be used.

Good idea.
Comment 9 Aaron Boxer 2016-06-13 11:46:35 UTC
Created attachment 329685 [details] [review]
use sampling field to determine RGB channel order

require sampling field in sink caps
Comment 10 Sebastian Dröge (slomo) 2016-06-13 20:39:05 UTC
Review of attachment 329685 [details] [review]:

Why do you have the unrelated gstopenjpegenc.h changes in here? Also don't run gst-indent on headers, it does ugly things with headers :)

::: ext/openjpeg/gstopenjpegdec.c
@@ +715,3 @@
+                GST_VIDEO_FORMAT_RGBA;
+          else
+            format = GST_VIDEO_FORMAT_ARGB;

How can self->sampling be NULL now? And why would it be BGRA or RGBA with sampling, but ARGB otherwise? :)
Comment 11 Aaron Boxer 2016-06-13 21:13:16 UTC
(In reply to Sebastian Dröge (slomo) from comment #10)
> Review of attachment 329685 [details] [review] [review]:
> 
> Why do you have the unrelated gstopenjpegenc.h changes in here? Also don't
> run gst-indent on headers, it does ugly things with headers :)

Thanks, will fix this.

> 
> ::: ext/openjpeg/gstopenjpegdec.c
> @@ +715,3 @@
> +                GST_VIDEO_FORMAT_RGBA;
> +          else
> +            format = GST_VIDEO_FORMAT_ARGB;
> 
> How can self->sampling be NULL now? 

Good point, let me check on this

And why would it be BGRA or RGBA with
> sampling, but ARGB otherwise? :)

Well, ARGB is the default when we don't know the channel order. Otherwise, we can use the sampling to decide on the order.
Comment 12 Aaron Boxer 2016-06-14 02:30:24 UTC
Created attachment 329746 [details] [review]
use sampling field to determine RGB channel order

cleaned up patch
Comment 13 Aaron Boxer 2016-06-14 02:40:35 UTC
Created attachment 329747 [details] [review]
use sampling field to determine RGB channel order

self-sampling is never null.
Comment 14 Aaron Boxer 2016-06-14 02:57:37 UTC
Created attachment 329748 [details] [review]
use sampling field to determine RGB channel order

require sampling field for JP2 streams. This can be ensured by placing a j2k parser in front of the decoder.
Comment 15 Sebastian Dröge (slomo) 2016-06-14 06:20:40 UTC
Review of attachment 329748 [details] [review]:

::: ext/openjpeg/gstopenjpegdec.c
@@ +86,2 @@
         "image/x-jpc, "
+        GST_RTP_J2K_SAMPLING_LIST "; " "image/jp2, " GST_RTP_J2K_SAMPLING_LIST)

For JP2 we don't really need anything, right? And adding this restriction here can only make sense (if at all) after the parser actually supports it :)
Comment 16 Aaron Boxer 2016-06-14 18:11:31 UTC
Created attachment 329815 [details] [review]
use sampling field to determine RGB channel order

Thanks for the review - here are the changes.
Comment 17 Sebastian Dröge (slomo) 2016-06-17 09:55:02 UTC
Review of attachment 329815 [details] [review]:

Just one minor thing left :)

::: ext/openjpeg/gstopenjpegdec.c
@@ +205,3 @@
   }
 
+  self->sampling = g_strdup (gst_structure_get_string (s, "sampling"));

As you g_strdup() this, you will have to free the string when needed (i.e. when shutting down and when set_format is called another time).
Comment 18 Aaron Boxer 2016-06-17 20:38:45 UTC
Thanks for the review. Changes arriving shortly.
Comment 19 Aaron Boxer 2016-06-17 20:42:55 UTC
Created attachment 329972 [details] [review]
use sampling field to determine RGB channel order

changes following latest review.
Comment 20 Sebastian Dröge (slomo) 2016-06-21 08:43:30 UTC
commit 74dcb59025615960dd114d52ca1b0fa3d08b6237
Author: Aaron Boxer <boxerab@gmail.com>
Date:   Mon Jun 13 22:29:39 2016 -0400

    openjpegdec: use sampling field to determine RGB channel
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767402