GNOME Bugzilla – Bug 625129
typefinding: file incorrectly detected as audio/x-dts
Last modified: 2011-01-25 13:44:16 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.
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).
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).
Looks good but better use POSSIBLE instead of LIKELY here, at least for the compressed case
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 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. >+} >+
> 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.
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).
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)