Skip to content

Commit

Permalink
Merge pull request #391 from drewnoakes/back-compat
Browse files Browse the repository at this point in the history
Address minor regressions
  • Loading branch information
drewnoakes authored Jan 31, 2024
2 parents 06b0bd0 + 4d7253e commit 877ee15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public sealed class OlympusCameraSettingsMakernoteDescriptor(OlympusCameraSettin
if (Directory.GetObject(OlympusCameraSettingsMakernoteDirectory.TagGradation) is not short[] values || values.Length < 3)
return null;

var ret = (values[0], values[1], values[3]) switch
var ret = (values[0], values[1], values[2]) switch
{
(0, 0, 0) => "n/a",
(-1, -1, 1) => "Low Key",
Expand Down
22 changes: 21 additions & 1 deletion MetadataExtractor/Formats/QuickTime/QuickTimeReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,33 @@ namespace MetadataExtractor.Formats.QuickTime
/// </summary>
public static class QuickTimeReaderExtensions
{
#if NET462 || NETSTANDARD1_3
public static unsafe string Get4ccString(this SequentialReader reader)
#else
public static string Get4ccString(this SequentialReader reader)
#endif
{
// https://en.wikipedia.org/wiki/FourCC

Span<byte> bytes = stackalloc byte[4];
Span<char> chars = stackalloc char[4];

reader.GetBytes(bytes);

return Encoding.ASCII.GetString(bytes);
// NOTE we cannot just use Encoding.ASCII here, as that can replace certain non-printable characters with '?'
chars[0] = (char)bytes[0];
chars[1] = (char)bytes[1];
chars[2] = (char)bytes[2];
chars[3] = (char)bytes[3];

#if NET462 || NETSTANDARD1_3
fixed (char* pChars = chars)
{
return new string(pChars, startIndex: 0, length: 4);
}
#else
return new string(chars);
#endif
}

public static decimal Get16BitFixedPoint(this SequentialReader reader)
Expand Down

0 comments on commit 877ee15

Please sign in to comment.