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 782337 - jpeg2000parse: parse main level from j2k code stream and add to caps
jpeg2000parse: parse main level from j2k code stream and add to caps
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other Windows
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-05-08 15:20 UTC by Aaron Boxer
Modified: 2017-06-07 07:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Parse JPEG 2000 capabilities tag (2.96 KB, patch)
2017-05-12 19:30 UTC, Aaron Boxer
none Details | Review
Parse profile, main level and sub-level and put in source caps (9.38 KB, patch)
2017-05-16 18:04 UTC, Aaron Boxer
none Details | Review
Updated comments on last patch (9.39 KB, patch)
2017-05-16 19:51 UTC, Aaron Boxer
none Details | Review
Updated patch (9.85 KB, patch)
2017-05-17 14:38 UTC, Aaron Boxer
none Details | Review
Final version of patch (9.86 KB, patch)
2017-05-18 00:38 UTC, Aaron Boxer
none Details | Review
One last tweak (9.86 KB, application/mbox)
2017-05-18 00:45 UTC, Aaron Boxer
  Details
Problem with the last patch (9.86 KB, application/mbox)
2017-05-18 00:47 UTC, Aaron Boxer
  Details
Patch wasn't working from windows box, trying Ubuntu (9.85 KB, patch)
2017-05-18 00:49 UTC, Aaron Boxer
committed Details | Review

Description Aaron Boxer 2017-05-08 15:20:20 UTC
The j2k RSIZ box contains a capabilities tag with information about profile and bit rate. For broadcast streams, the caps contains the profile number and the main level (bit rate) 

The parser can read the main level and add to caps as property.
Comment 1 Aaron Boxer 2017-05-08 15:25:58 UTC
The muxer can then read the property and fill in j2k video descriptor.

Is there an existing caps field for bit rate ?
Comment 2 Aaron Boxer 2017-05-08 15:27:18 UTC
It would also be nice to be able to "transcode" a series of non-broadcast images by changing the profile to broadcast + a specified bit rate
Comment 3 Aaron Boxer 2017-05-12 19:30:26 UTC
Created attachment 351746 [details] [review]
Parse JPEG 2000 capabilities tag
Comment 4 Aaron Boxer 2017-05-12 19:58:59 UTC
I decided to store the complete 16 bit capabilities value in the jpeg2000parse source caps. The mpegts muxer can easily extract the bit rate, and also 
enforce broadcast profile as specified by standard ( there are several possible J2K profiles, but only broadcast single tile is allowed by standard) .
Comment 5 Aaron Boxer 2017-05-16 11:01:51 UTC
Need this patch to continue work on #753323 :)
Comment 6 Sebastian Dröge (slomo) 2017-05-16 11:56:19 UTC
Review of attachment 351746 [details] [review]:

::: gst/videoparsers/gstjpeg2000parse.c
@@ +74,3 @@
         GST_JPEG2000_SAMPLING_LIST ","
+        GST_JPEG2000_COLORSPACE_LIST ","
+        " capabilities = (int)[1, MAX]," " parsed = (boolean) true")

Do you *always* add it? And valid is [0, 65535] I guess, not [1, MAX] :)

@@ +369,3 @@
+    goto beach;
+
+  if (!gst_byte_reader_get_uint16_be (&reader, &capabilities))

What exactly does this integer contain? Would it make sense to split it into multiple fields, or to attach it opaquely as a GstBuffer?
Comment 7 Aaron Boxer 2017-05-16 12:13:38 UTC
Thanks for the review.

(In reply to Sebastian Dröge (slomo) from comment #6)
> Review of attachment 351746 [details] [review] [review]:
> 
> ::: gst/videoparsers/gstjpeg2000parse.c
> @@ +74,3 @@
>          GST_JPEG2000_SAMPLING_LIST ","
> +        GST_JPEG2000_COLORSPACE_LIST ","
> +        " capabilities = (int)[1, MAX]," " parsed = (boolean) true")
> 
> Do you *always* add it? And valid is [0, 65535] I guess, not [1, MAX] :)
> 

Yes, all J2K code streams must have this tag, so it makes sense to always add it. And yes, should be [0, 65535] .


> @@ +369,3 @@
> +    goto beach;
> +
> +  if (!gst_byte_reader_get_uint16_be (&reader, &capabilities))
> 
> What exactly does this integer contain? Would it make sense to split it into
> multiple fields, or to attach it opaquely as a GstBuffer?

This integer contains two fields : JPEG 2000 profile (profile 0, profile 1, broadcast, IMF)  and main level (a number from 0 to 11 that corresponds to maximum bit rate). The logic for extracting the profile and main level varies depending on what profile we are dealing with.

The MPEG TS muxer needs both fields to create a compliant stream.
Comment 8 Sebastian Dröge (slomo) 2017-05-16 12:20:43 UTC
So let's better have both fields then as separate integers, and also give the appropriate ranges. This way decoders can e.g. specify in their caps that they only handle profile 0 for example.
Comment 9 Aaron Boxer 2017-05-16 12:37:18 UTC
Ok, good idea​. How about "j2k_profile" and "bit_rate" ?
Comment 10 Sebastian Dröge (slomo) 2017-05-16 12:40:33 UTC
"profile" and "level" or "main-level"? Why call it bitrate if you call it "main level" above? :)
Comment 11 Aaron Boxer 2017-05-16 13:16:58 UTC
"profile" and "main-level" sounds good. 
For profile, there are only around 4 or 5 possible values, so I will treat it the same as the sampling field.  

I will put all of the #defines for profile and main level in the
parser header file.

Patch coming shortly :)
Comment 12 Aaron Boxer 2017-05-16 14:54:09 UTC
Note: there are two parts to the JPEG 2000 standard - we will only support profiles for Part 1, as our encoder and decoder don't support Part 2.
Comment 13 Aaron Boxer 2017-05-16 18:04:37 UTC
Created attachment 351988 [details] [review]
Parse profile, main level and sub-level and put in source caps

Parse J2K capabilities, and detect profile and main level (broadcast)
and sub-level(broadcast and IMF).

Do sanity checks on profile, main level and sub level.

Put profile in source caps, and optionally put main level and sub level in caps.
Comment 14 Aaron Boxer 2017-05-16 18:10:56 UTC
Note: main level and sub level are optional - main level is present for broadcast and IMF profiles, and sub level is only present for IMF profile.
Comment 15 Aaron Boxer 2017-05-16 19:51:02 UTC
Created attachment 351990 [details] [review]
Updated comments on last patch
Comment 16 Aaron Boxer 2017-05-17 14:38:19 UTC
Created attachment 352034 [details] [review]
Updated patch

Do not reject Part 2 code stream, just because we can't handle
it in gstreamer
Comment 17 Aaron Boxer 2017-05-18 00:38:34 UTC
Created attachment 352052 [details] [review]
Final version of patch
Comment 18 Aaron Boxer 2017-05-18 00:45:45 UTC
Created attachment 352053 [details]
One last tweak
Comment 19 Aaron Boxer 2017-05-18 00:47:01 UTC
Created attachment 352054 [details]
Problem with the last patch
Comment 20 Aaron Boxer 2017-05-18 00:49:07 UTC
Created attachment 352055 [details] [review]
Patch wasn't working from windows box, trying Ubuntu
Comment 21 Aaron Boxer 2017-05-19 11:29:16 UTC
I have a few other patches queued that rely on this patch :) .......
Comment 22 Aaron Boxer 2017-05-19 11:30:06 UTC
(patches for other issues - this patch is ready to go)
Comment 23 Aaron Boxer 2017-05-29 17:22:54 UTC
Hi Sebastian,

Does this patch look OK? I can't really move forward
on the J2K MPEG-TS issue until this one gets resolved.

Thanks!
Aaron
Comment 24 Aaron Boxer 2017-06-06 17:01:46 UTC
a very polite <ping/> for this patch :)
if anyone has time to take a look.
Comment 25 Sebastian Dröge (slomo) 2017-06-06 17:23:15 UTC
Review of attachment 352055 [details] [review]:

Generally looks good to me

::: gst/videoparsers/gstjpeg2000parse.c
@@ +103,3 @@
         GST_JPEG2000_SAMPLING_LIST ","
+        GST_JPEG2000_COLORSPACE_LIST ","
+        " profile = (int)[0, 49151]," " parsed = (boolean) true")

Will we always add the profile in any case, and it's something between those two values (and including them)?
Comment 26 Sebastian Dröge (slomo) 2017-06-06 17:24:53 UTC
Comment on attachment 352055 [details] [review]
Patch wasn't working from windows box, trying Ubuntu

Answering my own question, yes. Going to merge later. Thanks!
Comment 27 Aaron Boxer 2017-06-06 18:00:31 UTC
Great, thanks!
Comment 28 Sebastian Dröge (slomo) 2017-06-07 07:06:55 UTC
commit 9ec2b7ce131bee726289ca1dda91d09e59775684
Author: Aaron Boxer <boxerab@gmail.com>
Date:   Fri May 12 15:28:46 2017 -0400

    jpeg2000parse: parse RSIZ capabilities and put profile/level into the caps
    
    The RSIZ capabilities tag stores the JPEG 2000 profile. In the case of
    broadcast profiles, it also stores the broadcast main level, which
    specifies the bit rate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782337