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 773172 - typefinding: mis-detects iTunes artwork cache ( .itc ) file as audio/mpeg
typefinding: mis-detects iTunes artwork cache ( .itc ) file as audio/mpeg
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: Reynaldo H. Verdejo Pinochet
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-10-18 17:32 UTC by gnome.vrb
Modified: 2016-11-21 19:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot with rhythmbox importing and playing ( random noise ) itc files. (77.72 KB, image/png)
2016-10-18 17:33 UTC, gnome.vrb
  Details
Attached the first 6 files ( tar.gz ) mentioned in the bug description (1.82 MB, application/gzip)
2016-10-18 17:55 UTC, gnome.vrb
  Details
typefind: add typefinder for Apple/iTunes itc artwork files (2.45 KB, patch)
2016-11-16 22:18 UTC, Reynaldo H. Verdejo Pinochet
none Details | Review
add typefinder for Apple/iTunes itc artwork files (2.45 KB, patch)
2016-11-16 22:30 UTC, Reynaldo H. Verdejo Pinochet
none Details | Review
add typefinder for Apple/iTunes itc artwork files (2.98 KB, patch)
2016-11-18 22:42 UTC, Reynaldo H. Verdejo Pinochet
committed Details | Review

Description gnome.vrb 2016-10-18 17:32:34 UTC
dev@unstable:~/Music/iTunes/Album Artwork/Cache$ find . -type f | xargs gst-typefind-1.0 2>&1 | grep audio
./900E2E35296E478E/00/09/09/900E2E35296E478E-FA98AEF9DE671990.itc - audio/mpeg, mpegversion=(int)1, layer=(int)3, parsed=(boolean)false
./900E2E35296E478E/00/12/15/900E2E35296E478E-8A75DB96D95AFFC0.itc - audio/mpeg, mpegversion=(int)1, layer=(int)3, parsed=(boolean)false
./900E2E35296E478E/01/06/02/900E2E35296E478E-9D15631A66A4F261.itc - audio/mpeg, mpegversion=(int)1, layer=(int)2, parsed=(boolean)false
./900E2E35296E478E/01/11/04/900E2E35296E478E-F47BDEC2F52CE4B1.itc - audio/mpeg, framed=(boolean)false, mpegversion=(int)4, stream-format=(string)adts, level=(string)2, base-profile=(string)ltp, profile=(string)ltp, channels=(int)8, rate=(int)8000
./900E2E35296E478E/04/09/09/900E2E35296E478E-B9A0A86977666994.itc - audio/mpeg, mpegversion=(int)1, layer=(int)1, parsed=(boolean)false
./900E2E35296E478E/06/12/10/900E2E35296E478E-72CF0EEA7F262AC6.itc - audio/mpeg, mpegversion=(int)1, layer=(int)2, parsed=(boolean)false
./900E2E35296E478E/07/08/08/900E2E35296E478E-CD92D349348A5887.itc - audio/mpeg, mpegversion=(int)1, layer=(int)2, parsed=(boolean)false

Here, iTunes is a symlink to iTunes dir in OSX partition.
Comment 1 gnome.vrb 2016-10-18 17:33:36 UTC
Created attachment 337955 [details]
Screenshot with rhythmbox importing and playing ( random noise ) itc files.
Comment 2 Tim-Philipp Müller 2016-10-18 17:47:59 UTC
Thanks for the bug report. Could you please attach a few such files? Thanks!
Comment 3 gnome.vrb 2016-10-18 17:55:27 UTC
Created attachment 337958 [details]
Attached the first 6 files ( tar.gz ) mentioned in the bug description
Comment 4 Reynaldo H. Verdejo Pinochet 2016-11-16 22:18:51 UTC
Created attachment 340088 [details] [review]
typefind: add typefinder for Apple/iTunes itc artwork files

Avoids mpeg/audio false-positive described at:
Comment 5 Reynaldo H. Verdejo Pinochet 2016-11-16 22:30:40 UTC
Created attachment 340089 [details] [review]
add typefinder for Apple/iTunes itc artwork files
Comment 6 Tim-Philipp Müller 2016-11-17 01:05:38 UTC
Comment on attachment 340089 [details] [review]
add typefinder for Apple/iTunes itc artwork files

Thanks for working on this.

>+/*** application/itc ***/
>+static GstStaticCaps itc_caps = GST_STATIC_CAPS ("application/itc");
>+#define ITC_CAPS (gst_static_caps_get(&itc_caps))

OOC, is this a media type that is used elsewhere, or made-up?

>+  /* take 1x magic at start as a good hint */
>+  if (!memcmp (c.data, magic, 8)) {
>+    itc_prob = GST_TYPE_FIND_MAXIMUM - 3;
>+    data_scan_ctx_advance (tf, &c, 8);
>+  } else
>+    goto done;

I think it'd be nicer to read if it was reflowed as


  if (memcmp () != 0)
    return;

  ...

What is the meaning of these 'preamble' bytes? Do they always exist once, twice, three times? (and in a row?)

My gut feeling is that the probability advertised here is a bit too high for the kind of data checked.
Comment 7 Reynaldo H. Verdejo Pinochet 2016-11-17 03:34:13 UTC
(In reply to Tim-Philipp Müller from comment #6)
> Comment on attachment 340089 [details] [review] [review]
> add typefinder for Apple/iTunes itc artwork files
> 
> Thanks for working on this.
> 
> >+/*** application/itc ***/
> >+static GstStaticCaps itc_caps = GST_STATIC_CAPS ("application/itc");
> >+#define ITC_CAPS (gst_static_caps_get(&itc_caps))
> 
> OOC, is this a media type that is used elsewhere, or made-up?

Made up

> [...] 
> What is the meaning of these 'preamble' bytes? Do they always exist once,
> twice, three times? (and in a row?)

Happens 3 times in a row after the magic on all samples.

> 
> My gut feeling is that the probability advertised here is a bit too high for
> the kind of data checked.

It can be extended a bit to incorporate more checks. Will post an updated
patch latter. Thanks for taking a look.
Comment 8 Reynaldo H. Verdejo Pinochet 2016-11-18 22:42:46 UTC
Created attachment 340275 [details] [review]
add typefinder for Apple/iTunes itc artwork files

Added two more tests and went with more modest scores this time around
Comment 9 Sebastian Dröge (slomo) 2016-11-21 07:43:10 UTC
Comment on attachment 340275 [details] [review]
add typefinder for Apple/iTunes itc artwork files

Looks good to me
Comment 10 Reynaldo H. Verdejo Pinochet 2016-11-21 19:01:22 UTC
Review of attachment 340275 [details] [review]:

Thanks for taking a look Sebastian. Pushed as

7e14875458c6f2d.. typefind: add typefinder for Apple/iTunes itc artwork files