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 756897 - qtdemux: cenc aux_info_type endianness issue
qtdemux: cenc aux_info_type endianness issue
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 1.6.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
http://html5.cablelabs.com:8100/cenc/...
1.6.4
Depends on:
Blocks:
 
 
Reported: 2015-10-21 10:05 UTC by Philippe Normand
Modified: 2016-04-14 17:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot from a hex editor showing seemingly fine siao box (392.55 KB, image/png)
2016-02-19 16:51 UTC, Brendan Long
  Details
proposed patch (1.23 KB, patch)
2016-02-22 08:11 UTC, Philippe Normand
committed Details | Review
Test file that exhibits the problem (1.36 MB, video/mp4)
2016-02-23 15:14 UTC, Greg Rutz
  Details

Description Philippe Normand 2015-10-21 10:05:55 UTC
Fragments available through this dash manifest expose a 'cnec' aux_info_type according to qtdemux:

qtdemux.c:3323:qtdemux_parse_saio:<qtdemux1> aux_info_type: 'cnec', aux_info_type_parameter:  000000

Perhaps we should use the ntohl() function to convert the value to host endianness or is this fragment simply invalid?
Comment 1 Sebastian Dröge (slomo) 2015-10-21 10:13:31 UTC
Instead of nothl(), rather use GST_READ_UINT32_BE() or similar. For the actual bug, I don't know :) Someone will have to check the spec.
Comment 2 Philippe Normand 2015-10-21 10:36:58 UTC
Well, maybe we should rather use the QT_FOURCC macro? Since this is interpreted as a FOURCC field in the end.
Comment 3 Tim-Philipp Müller 2015-10-29 00:14:14 UTC
Could you make available a hexdump of the relevant part of the fragment? (i.e. the saio box).

Is this log from a little endian system or a big endian system?
Comment 4 Tim-Philipp Müller 2015-10-29 00:16:17 UTC
Nevermind, the URL of the initdata is in the URL field above.
Comment 5 Philippe Normand 2015-10-29 09:49:49 UTC
(In reply to Tim-Philipp Müller from comment #3)
> Could you make available a hexdump of the relevant part of the fragment?
> (i.e. the saio box).
> 
> Is this log from a little endian system or a big endian system?

Little endian :)
Comment 6 Tim-Philipp Müller 2015-10-29 10:01:59 UTC
At first glance this looks like the fourcc was written wrongly, but I didn't really look at it properly.
Comment 7 Philippe Normand 2016-02-19 11:42:30 UTC
Adding Brendan in CC, as this manifest is hosted by CableLabs, maybe he can shed some light on this issue.
Comment 8 Brendan Long 2016-02-19 16:51:20 UTC
Created attachment 321674 [details]
Screenshot from a hex editor showing seemingly fine siao box

Which segment has this problem? I downloaded a few segments and the 'saio' box looked fine in a hex editor (screenshot attached). I wasn't able to find any example of 'cnec' in the files.
Comment 9 Brendan Long 2016-02-19 16:52:16 UTC
CC'ing Greg Rutz, since he created this file and I don't see to have a copy of the MPEG-CE spec.
Comment 10 Greg Rutz 2016-02-19 17:28:02 UTC
The current implementation of GST_FOURCC_ARGS() macro expects the fourcc data to be a guint32 in LE format.  Looks to me like there is one of two problems:

1) GST_FOURCC_ARGS macro that is used in the offending debug statement is wrong and should be expecting a BE guint32.  I am doubtful that this is the case, since I'm sure this macro is used in other places.

2) GST_FOURCC_ARGS is correct and the guint32 aux_info_type should be read as LE using gst_byte_reader_get_uint32_le()
Comment 11 Greg Rutz 2016-02-19 17:46:12 UTC
Also note that other areas of the code use QT_FOURCC to read fourcc byte data which is implemented as:

#define QT_FOURCC(a)  (GST_READ_UINT32_LE(a))
Comment 12 Sebastian Dröge (slomo) 2016-02-20 08:59:45 UTC
Does 2) fix it? Can you provide a patch? :)
Comment 13 Sebastian Dröge (slomo) 2016-02-20 09:00:00 UTC
And if it does, why doesn't it fail generally on all files?
Comment 14 Greg Rutz 2016-02-22 04:14:00 UTC
It doesn't look like the aux_info_type parameter is really used (just one comparison to 0U).  So, it is likely that the problem has always produced the log statement reported in this bug, it just doesn't affect the pipeline's ability to play the content.
Comment 15 Sebastian Dröge (slomo) 2016-02-22 07:50:11 UTC
Phil, can you compare that with what you see in the stream?
Comment 16 Philippe Normand 2016-02-22 08:03:40 UTC
(In reply to Greg Rutz from comment #14)
> It doesn't look like the aux_info_type parameter is really used (just one
> comparison to 0U).  So, it is likely that the problem has always produced
> the log statement reported in this bug, it just doesn't affect the
> pipeline's ability to play the content.

IIRC this isn't right. When I reported this bug, playback was actually prevented by this issue, because the parse_saio() function sets the info_type wrongly and that triggers an error in the parse_moof() function because info_type is not FOURCC_cenc.

(In reply to Greg Rutz from comment #11)
> Also note that other areas of the code use QT_FOURCC to read fourcc byte
> data which is implemented as:
> 
> #define QT_FOURCC(a)  (GST_READ_UINT32_LE(a))

This is what I was suggesting to use in comment 2. And I've been using it without issues so far :)
Comment 17 Sebastian Dröge (slomo) 2016-02-22 08:06:15 UTC
Can you provide a patch for that then?
Comment 18 Philippe Normand 2016-02-22 08:11:09 UTC
Created attachment 321811 [details] [review]
proposed patch
Comment 19 Sebastian Dröge (slomo) 2016-02-22 08:28:02 UTC
Review of attachment 321811 [details] [review]:

::: gst/isomp4/qtdemux.c
@@ +3379,2 @@
     if (!gst_byte_reader_get_uint32_be (br, &aux_info_type_parameter))
       return FALSE;

So the type is a fourcc in LE, the other parts are still in big endian? Can someone check if this actually makes sense and is what the spec says? I'll push it then.
Comment 20 Greg Rutz 2016-02-22 14:28:51 UTC
All multi-byte fields, including FOURCCs, in ISOBMFF files (MOV, MP4, QT, etc) are big-endian.

FWIW, the comment in the definition for GST_MAKE_FOURCC says:

"Transform four characters into a #guint32 fourcc value with host endianness"

If this were true, I would expect that this function would be different on platforms with different endianness.  But I don't think that is the case.  Seems like the decision was made at some point to always store FOURCC values in GStreamer as little-endian.
Comment 21 Sebastian Dröge (slomo) 2016-02-23 09:04:10 UTC
So is the patch correct then and the documentation also should be updated? Can someone provide part of a file with this box for reproducing and having it here for historical reasons?
Comment 22 Greg Rutz 2016-02-23 15:13:02 UTC
(In reply to Sebastian Dröge (slomo) from comment #21)
> So is the patch correct then and the documentation also should be updated?

That is my opinion, but I would sure like someone else to jump in to say that they agree with me.  I only had time to do a very brief examination of the code.

> Can someone provide part of a file with this box for reproducing and having
> it here for historical reasons?

I can try.  The smallest file I have right now is 1.4M.  I can't remember if Bugzilla will let me attach a file that size.
Comment 23 Sebastian Dröge (slomo) 2016-02-23 15:14:06 UTC
You could put it on dropbox or similar :)
Comment 24 Greg Rutz 2016-02-23 15:14:11 UTC
Created attachment 321982 [details]
Test file that exhibits the problem
Comment 25 Sebastian Dröge (slomo) 2016-02-24 08:56:41 UTC
commit 459ef195bbc77cee5e407facc3172b77cb29d9a3
Author: Philippe Normand <philn@igalia.com>
Date:   Wed Oct 21 16:21:45 2015 +0200

    qtdemux: read saio aux_info_type as a FOURCC
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756897
Comment 26 Tim-Philipp Müller 2016-02-24 17:32:23 UTC
(I'm sure I looked at the hexdump when looking at it originally, sorry for any noise! :))