[File] [PATCH] of Magdir/images for MPEG sequence as Targa image

Jörg Jenderek joerg.jen.der.ek at gmx.net
Wed Jul 8 12:52:55 UTC 2020


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

some days ago i tried to play DVD on a windows 10 system.
Because i do not succeed, i also run file command version 5.39 on
Video files (*.vob), some concerned audio files (*.adx) and some
Targa images (*.tga). With -k option i get an output like:

earth_UTP16_ARGB.tga:   Targa image data - RGBA 512 x 512 x 16
			- 1-bit alpha
HV001T01.EVO:           Targa image data - Map 63555 x 65536 x 1
			+260 +40196 - 11-bit alpha -
			top - right - four way interleave
			MPEG sequence, v2, program multiplex
R03T-15552.adx:         CRI ADX ADPCM audio v3,
			standard ADX, 44100 Hz
			lif file
			(Lepton 2.x), scale 0-0,
			spot sensor temperature 0.000000,
			unit celsius, color scheme 0,
			calibration: offset 0.000000, slope 0.000000
R04HT.adx:              CRI ADX ADPCM audio v3,
			standard ADX, 44100 Hz
			lif file
rgb32_top_left_rle.tga: data
VIDEO_TS.BUP:           Video manager, v10
			(Lepton 2.x), scale 0-0,
			spot sensor temperature 0.000000,
			unit celsius, color scheme 0,
			calibration: offset 0.000000, slope 0.000000
VIDEO_TS.IFO:           Video manager, v10
			(Lepton 2.x), scale 0-0,
			spot sensor temperature 0.000000,
			unit celsius, color scheme 0,
			calibration: offset 0.000000, slope 0.000000
VIDEO_TS.VOB:           Targa image data - Map 63683 x 65536 x 1
			+260 +35073 - 11-bit alpha -
			top - right - four way interleave
			MPEG sequence, v2, program multiplex
VTS_08_0.IFO:           Video title set, v10
			(Lepton 3.x), scale 14-46954,
			spot sensor temperature
			477833287852429700000000000000000000.000000,
			color scheme 0,
			calibration: offset 0.000000, slope 0.000000
VTS_08_2.VOB:           Targa image data - Map 63683 x 65536 x 1
			+23877 +35073 -
			top - reserved
			MPEG sequence, v2, program multiplex
winnicki.mpg:           Targa image data - Map 63683 x 65536 x 1
			+260 +35073 - 11-bit alpha -
			top - right - four way interleave
			MPEG sequence, v2, program multiplex

Many of such video files are misidentified as Targa image by
Magdir/images. For TGA images exist no concrete magic pattern.
But luckily the displaying part is encapsulated by sub routine
tga-image. So just more test lines must be added or modified.

The bits 3-0 of the Image descriptor byte give the alpha channel
depth. This is described in subroutine by line like
 >17	ubyte&0x0F	>0		- %d-bit alpha
The file format documentation give no restriction on that value, but
typical values are 1 or 8. Maybe multiple of two maybe possible, but
an odd number like 11 does not make any sense. So skip some
misidentified MPEG sequence like *.vob, HV001T01.EVO and winnicki.mpg
with unacceptable alpha channel depth 11 before last test for low
pixel depth by additional test line like
 >>>>17	ubyte&0x0F		!11

According to some documentation the 2 upper bits of the image
descriptor byte are used for storage interleave behaviour. Where no
bit set means no interleave, the lower bit set means interleave and
the upper bit means four way interleave is used. The documentation is
not very precisely. If both bits are set then this is described as
reserved. This is described in sub routine by lines like:
 >17	ubyte&0xC0	0x40		- interleave
 >17	ubyte&0xC0	0x80		- four way interleave
 >17	ubyte&0xC0	0xC0		- reserved
I myself even found no examples with interleave modus. Then an maybe
more possible exotic variant where both interleave bits are set seem
for me very unlikely, especially when considering misidentification.
So i skip some MPEG sequences *.vob and some ADX samples with
improbable interleave bits by additional test line like:
 >17	ubyte&0xC0		!0xC0

The valid Targa image rgb32_top_left_rle.tga is described as data.
By file command version 5.32 this was identified correctly. To skip
CRI ADX ADPCM audios a line in Magdir/images is used that looks like
 >(2.S-2) belong	!0x28632943
According to  Magdir/images for ADX audios at that position the
string (c)CRI ( in hexadecimal 286329435249) is stored. So by that
line such audio sample are skipped. For Targa image at that
position the Image type byte and part of Index of first color map
entry is stored. When interpreting values as pointer this maybe
jumps to non existing positions. Then this test fails and the next
test lines calling subroutine tga-image are never executed. So i
cancelled this pointer expression and replaced it with line testing
for improbable
interleave bits.

After applying the above mentioned modifications by patch
file-5.39-images-tga.diff then misidentification vanish and
undetected TGA examples are described correctly and i get a output
like:

earth_UTP16_ARGB.tga:   Targa image data - RGBA 512 x 512 x 16
			- 1-bit alpha
HV001T01.EVO:           MPEG sequence, v2, program multiplex
R03T-15552.adx:         CRI ADX ADPCM audio v3, standard ADX,
			44100 Hz
R04HT.adx:              CRI ADX ADPCM audio v3, standard ADX,
			44100 Hz
rgb32_top_left_rle.tga: Targa image data - RGBA - RLE 64 x 64 x 32
			+16448
			- 8-bit alpha - top
VIDEO_TS.BUP:           Video manager, v10
VIDEO_TS.IFO:           Video manager, v10
VIDEO_TS.VOB:           MPEG sequence, v2, program multiplex
VTS_08_0.IFO:           Video title set, v10
VTS_08_2.VOB:           MPEG sequence, v2, program multiplex
winnicki.mpg:           MPEG sequence, v2, program multiplex

When running file command with -m Magdir/animation and --extension
option only ??? for video examples are displayed.
So i add after MPEG sequence a line to show file name extension by
additional line
 !:ext	vob/evo/mpg/mpeg
And after Video title set and Video manager show file name extension
by additional line
 !:ext	ifo/bup
Furthermore show user defined mime type by additional line like
 !:mime	video/x-ifo

I hope my 2 diff files can be applied in future version of
file utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek





-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXwXBfwAKCRCv8rHJQhrU
1tJiAKDceiLMLSija8YENyCAeOiBKjepHQCgixmOCveSkfItdT11JWv7Wuwr3gk=
=bJl8
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.39/magic/Magdir/images.old	2020-05-31 10:34:40 +0000
+++ file-5.39/magic/Magdir/images	2020-07-06 14:35:46 +0000
@@ -32,3 +32,6 @@
 # Prevent conflicts with CRI ADX.
->(2.S-2) belong	!0x28632943
+#>(2.S-2) belong	!0x28632943
+# above line does not work for rgb32_top_left_rle.tga
+# skip some MPEG sequence *.vob and some CRI ADX audio with improbable interleave bits
+>17	ubyte&0xC0		!0xC0
 # skip more garbage like *.iso by looking for positive image type
@@ -37,15 +40,17 @@
 >>>2	ubyte			<34
+# skip some MPEG sequence *.vob HV001T01.EVO winnicki.mpg with unacceptable alpha channel depth 11
+>>>>17	ubyte&0x0F		!11
 # skip arches.3200 , Finder.Root , Slp.1 by looking for low pixel depth 1 8 15 16 24 32
->>>>16	ubyte			1
->>>>>0		use		tga-image
->>>>16	ubyte			8
->>>>>0		use		tga-image
->>>>16	ubyte			15
->>>>>0		use		tga-image
->>>>16	ubyte			16
->>>>>0		use		tga-image
->>>>16	ubyte			24
->>>>>0		use		tga-image
->>>>16	ubyte			32
->>>>>0		use		tga-image
+>>>>>16	ubyte			1
+>>>>>>0		use		tga-image
+>>>>>16	ubyte			8
+>>>>>>0		use		tga-image
+>>>>>16	ubyte			15
+>>>>>>0		use		tga-image
+>>>>>16	ubyte			16
+>>>>>>0		use		tga-image
+>>>>>16	ubyte			24
+>>>>>>0		use		tga-image
+>>>>>16	ubyte			32
+>>>>>>0		use		tga-image
 #	display tga bitmap image information
@@ -90,2 +95,3 @@
 # Image descriptor: bits 3-0 give the alpha channel depth, bits 5-4 give direction
+# alpha depth like: 1 8
 >17	ubyte&0x0F	>0		- %d-bit alpha
-------------- next part --------------
--- file-5.39/magic/Magdir/animation.old	2020-05-31 10:34:40 +0000
+++ file-5.39/magic/Magdir/animation	2020-07-07 23:25:58 +0000
@@ -235,4 +235,7 @@
 >3       byte               0xBA           MPEG sequence
 !:mime  video/mpeg
+# http://fileformats.archiveteam.org/wiki/Enhanced_VOB
+# https://reposcope.com/mimetype/video/mpeg
+!:ext	vob/evo/mpg/mpeg
 >>4      byte               &0x40          \b, v2, program multiplex
 >>4      byte               ^0x40          \b, v1, system multiplex
@@ -907,7 +910,13 @@
 
 # From: "Stefan A. Haubenthal" <polluks at web.de>
+# Update: Joerg Jenderek
+# URL: https://en.wikipedia.org/wiki/VOB
 0	string		DVDVIDEO-VTS	Video title set,
+!:mime	video/x-ifo
+!:ext	ifo/bup
 >0x21	byte		x		v%x
 0	string		DVDVIDEO-VMG	Video manager,
+!:mime	video/x-ifo
+!:ext	ifo/bup
 >0x21	byte		x		v%x
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.39-images-tga.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200708/6c858045/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.39-animation-vob_ifo.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200708/6c858045/attachment-0001.obj>


More information about the File mailing list