View Issue Details

IDProjectCategoryView StatusLast Update
0000181fileGeneralpublic2020-08-22 18:31
Reporterabon Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version5.39 
Fixed in Version5.40 
Summary0000181: Minor Opus Tweaks
DescriptionThanks for fixing the Opus output. I've included a diff (opus.diff) that makes the following small changes:

1. Update the Opus specification link to the final version.
2. Add a comma and change %d -> %u in the version string.
3. Specify that the sample rate detected is only the _input_ sample rate, as per the 5th item of https://tools.ietf.org/html/rfc7845#section-5.1
Additional InformationAdditionally, I wanted to add the Output Gain field as well, but I had some issues with using the leshort type on the field, which is a Q7.8 number:

Using (as a first try): >>>>44 leshort !0 \b, %d Output Gain

The above (falsely?) converts the two-byte LE short (#xF1) to an unsigned short instead of what I believe should be a signed short.
FWIW, the attached cast.diff makes `file' produce the result expected (-3840).

Using: >>>>44 leshort/256 !0 \b, %d Output Gain

The above appears to convert the LE short to unsigned before getting to the `mprint' function,
as even with cast.diff applied I get 241 instead of the expected -15.

This is also the case when using the short type, as (>>>>44 short !0 \b, %d Output Gain) yields -3840 (expected),
but (>>>>44 short/256 !0 \b, %d Output Gain) yields 241.

Perhaps it's too much effort for a single field like this, but to fully convert the Q7.8 number there would likely need to be support for this form:

>>>>44 leshort/256.0 !0 \b, %g Output Gain

Where it converts the LE short to a floating point to print the fractional part as well. That or adding a new type, which seems excessive.
TagsNo tags attached.

Activities

abon

2020-08-15 23:06

reporter  

opus.diff (929 bytes)   
diff --git a/magic/Magdir/vorbis b/magic/Magdir/vorbis
index 01a6da08..058d7037 100644
--- a/magic/Magdir/vorbis
+++ b/magic/Magdir/vorbis
@@ -132,11 +132,11 @@
 >>>>>>(84.b+117)	string		20140122	(1.3.4)
 >>>>>>(84.b+117)	string		20150105	(1.3.5)
 
-# non-Vorbis content: Opus https://tools.ietf.org/html/draft-ietf-codec-oggopus-06#section-5
+# non-Vorbis content: Opus https://tools.ietf.org/html/rfc7845#section-5
 >>28		string		OpusHead	\b, Opus audio,
 !:mime		audio/ogg
 >>>36		ubyte		>0x0F		UNKNOWN VERSION %u,
->>>36		ubyte&0x0F	!0		version 0.%d
+>>>36		ubyte&0x0F	!0		version 0.%u,
 >>>>46		ubyte		>1
 >>>>>46		ubyte		!255		unknown channel mapping family %u,
 >>>>>37		ubyte		x		%u channels
@@ -152,4 +152,4 @@
 >>>>>37		ubyte		6		5.1 surround
 >>>>>37		ubyte		7		6.1 surround
 >>>>>37		ubyte		8		7.1 surround
->>>>40		lelong		!0		\b, %u Hz
+>>>>40		lelong		!0		\b, %u Hz (Input Sample Rate)
\ No newline at end of file
opus.diff (929 bytes)   
cast.diff (358 bytes)   
diff --git a/src/softmagic.c b/src/softmagic.c
index 95061e56..233ebf48 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -616,7 +616,7 @@ mprint(struct magic_set *ms, struct magic *m)
 			break;
 		default:
 			if (file_printf(ms, F(ms, desc, "%u"),
-			    CAST(unsigned short, v)) == -1)
+			    CAST(short, v)) == -1)
 				return -1;
 			break;
 		}
cast.diff (358 bytes)   

christos

2020-08-22 18:31

manager   ~0003453

Fixed, thanks!

Issue History

Date Modified Username Field Change
2020-08-15 23:06 abon New Issue
2020-08-15 23:06 abon File Added: opus.diff
2020-08-15 23:06 abon File Added: cast.diff
2020-08-22 18:31 christos Assigned To => christos
2020-08-22 18:31 christos Status new => assigned
2020-08-22 18:31 christos Status assigned => resolved
2020-08-22 18:31 christos Resolution open => fixed
2020-08-22 18:31 christos Fixed in Version => 5.40
2020-08-22 18:31 christos Note Added: 0003453