Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address minor regressions #391

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading