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 625129 - typefinding: file incorrectly detected as audio/x-dts
typefinding: file incorrectly detected as audio/x-dts
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal minor
: 0.10.33
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-07-23 15:49 UTC by Arun Raghavan
Modified: 2011-01-25 13:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
typefind: add typefind for DEGAS images (2.72 KB, patch)
2011-01-19 19:32 UTC, Vincent Penquerc'h
none Details | Review
add typefind for DEGAS images (2.72 KB, patch)
2011-01-20 11:02 UTC, Vincent Penquerc'h
needs-work Details | Review
typefind: add typefind for DEGAS images (2.80 KB, patch)
2011-01-25 10:22 UTC, Vincent Penquerc'h
committed Details | Review

Description Arun Raghavan 2010-07-23 15:49:18 UTC
http://samples.mplayerhq.hu/image-samples/atarist/degas/HUNDRED.PC1

This sample guessed to be "audio/x-dts, rate=(int)96000, channels=(int)2" and when fed to dtsdec, it causes a segfault.
Comment 1 Vincent Penquerc'h 2011-01-19 19:32:24 UTC
The crash is somewhere in the libdca library that decodes DTS streams. I'm looking at whether I can early out there if a bad bitstream is found. An attempt at checking the max bound of the read wasn't enough to fix that sample crashing it. This is a bug in libdca and should be filed there.

So instead I added a typefind for DEGAS images so your file won't be misdetected as DTS anymore (but it'll still crash if given to dtsdec till libdca is fixed).
Comment 2 Vincent Penquerc'h 2011-01-19 19:32:49 UTC
Created attachment 178767 [details] [review]
typefind: add typefind for DEGAS images

This fixes at least one DEGAS image from being misdetected as DTS audio
(see https://bugzilla.gnome.org/show_bug.cgi?id=625129).
Comment 3 Sebastian Dröge (slomo) 2011-01-19 19:54:48 UTC
Looks good but better use POSSIBLE instead of LIKELY here, at least for the compressed case
Comment 4 Vincent Penquerc'h 2011-01-20 11:02:44 UTC
Created attachment 178823 [details] [review]
add typefind for DEGAS images

Use POSSIBLE + 5 instead of likely, and use a single media type for all of the types.
Comment 5 Tim-Philipp Müller 2011-01-25 00:50:39 UTC
Comment on attachment 178823 [details] [review]
add typefind for DEGAS images

>+  len = gst_type_find_get_length (tf);
>+  if (len < 4)
>+    return;
>+  data = gst_type_find_peek (tf, 0, 4);

Since there's supposed to be a 34-byte header, we may just as well check for that (not that it matters).

>+  resolution = GST_READ_UINT16_BE (data);
>+  if (len == 32034) {
>+    /* could be DEGAS */
>+    if (resolution <= 2)

Isn't resolution a bitfield? (meaning shouldn't it be <= 3?)

>+      gst_type_find_suggest_simple (tf, GST_TYPE_FIND_POSSIBLE + 5,
>+          "image/x-degas", NULL);
>+  } else if (len == 32066) {
>+    /* could be DEGAS Elite */
>+    if (resolution <= 2)
>+      data = gst_type_find_peek (tf, len - 16, 8);
>+    for (n = 0; n < 4; n++) {
>+      if (GST_READ_UINT16_BE (data + n * 2) > 2)
>+        return;
>+      gst_type_find_suggest_simple (tf, GST_TYPE_FIND_POSSIBLE + 5,
>+          "image/x-degas", NULL);
>+    }

Not sure I understand the nesting here.

Shouldn't we bail out (return) if resolution is > 3? (see above re. bitfield)

Or, put differently: shouldn't the data= bit and the whole loop etc. all be in a

  if (resolution <=3) {
    ...
  }

block?

Next, shouldn't the gst_type_find_suggest_simple() be outside the for loop? Otherwise we suggest after the first value already, and not only if all 4 values are ok.


>+  } else if (len >= 66 && len < 32066) {
>+    /* could be compressed DEGAS Elite, but it's compressed and so we can't rely on size,
>+       it does have 4 16 bytes values near the end that are 0-2 though. */
>+    if ((resolution & 0x8000) && (resolution & 0x7fff) <= 2)
>+      data = gst_type_find_peek (tf, len - 16, 8);
>+    for (n = 0; n < 4; n++) {
>+      if (GST_READ_UINT16_BE (data + n * 2) > 2)
>+        return;
>+      gst_type_find_suggest_simple (tf, GST_TYPE_FIND_POSSIBLE + 5,
>+          "image/x-degas", NULL);
>+    }
>+  }

Same questions here re. nesting.

>+}
>+
Comment 6 Vincent Penquerc'h 2011-01-25 10:22:08 UTC
> Since there's supposed to be a 34-byte header, we may just as well check for
> that (not that it matters).

Why not. Done.

> Isn't resolution a bitfield? (meaning shouldn't it be <= 3?)

I think it is not. Rereading the desription, it is indeed not very clear, but the following paragraph seems clear enough to quash the uncertainty (look at the example values given):

1 word          resolution (same as Degas, but high order bit is set;
                i.e., hex 8000 = low res, hex 8001 = medium res,
                hex 8002 = high res).  Other bits may be used in the
                future; use a simple bit test rather than checking
                for specific word values.

> Not sure I understand the nesting here.

"oops". Yes, bad nesting. The other too, it was copy/paste/adapt.
Comment 7 Vincent Penquerc'h 2011-01-25 10:22:37 UTC
Created attachment 179276 [details] [review]
typefind: add typefind for DEGAS images

This fixes at least one DEGAS image from being misdetected as DTS audio
(see https://bugzilla.gnome.org/show_bug.cgi?id=625129).
Comment 8 Tim-Philipp Müller 2011-01-25 13:43:59 UTC
Thanks!

 commit 2acdbdabaa3736ba66b1170e070b3a1bde37f35a
 Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
 Date:   Tue Jan 25 13:39:25 2011 +0000

    typefind: add typefinder for DEGAS images
    
    This fixes at least one DEGAS image from being misdetected as DTS audio.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=625129

(The reason I thought it was a bitfield is some other website than the one you referenced, since that one was down yesterday. Your version/quote makes more sense though)