Skip to content

Commit 19c0e62

Browse files
committed
fix: Better logs, and ignore gray8 when de-duping.
1 parent 9742238 commit 19c0e62

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

LibDmd/Frame/DmdFrame.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public DmdFrame Update(DmdFrame frame)
138138
Dimensions = frame.Dimensions;
139139
Data = frame.Data;
140140
BitLength = frame.BitLength;
141-
IsIdentifyFrame = false;
141+
IsIdentifyFrame = frame.IsIdentifyFrame;
142142

143143
#if DEBUG
144144
AssertData();
@@ -741,6 +741,27 @@ public void Dump(string path, string prefix = null)
741741
}
742742
}
743743

744+
public uint DataHash()
745+
{
746+
const uint fnvPrime = 16777619;
747+
uint hash = 2166136261;
748+
749+
for (int i = 0; i < Data.Length; i++)
750+
{
751+
hash ^= Data[i];
752+
hash *= fnvPrime;
753+
}
754+
755+
// Final avalanche (mix bits for better distribution)
756+
hash += hash << 13;
757+
hash ^= hash >> 7;
758+
hash += hash << 3;
759+
hash ^= hash >> 17;
760+
hash += hash << 5;
761+
762+
return hash;
763+
}
764+
744765
#endregion
745766
}
746767
}

LibDmd/Input/Passthrough/PassthroughGray4Source.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void NextFrame(DmdFrame frame)
4242
_framesGray4Duped.OnNext(frame);
4343

4444
// de-dupe frame
45-
if (_lastFrameFormat.Value == FrameFormat.Gray4 && _lastFrame == frame) {
45+
if ((_lastFrameFormat.Value == FrameFormat.Gray4 || _lastFrameFormat.Value == FrameFormat.Gray8) && _lastFrame == frame) {
4646
return;
4747
}
4848

@@ -52,11 +52,11 @@ public void NextFrame(DmdFrame frame)
5252
}
5353

5454
public IObservable<DmdFrame> GetGray4Frames(bool dedupe, bool skipIdentificationFrames) => dedupe
55-
? (skipIdentificationFrames ? _framesGray4Deduped.Where(f => !f.IsIdentifyFrame) : _framesGray4Deduped)
56-
: (skipIdentificationFrames ? _framesGray4Duped.Where(f => !f.IsIdentifyFrame) : _framesGray4Duped);
55+
? skipIdentificationFrames ? _framesGray4Deduped.Where(f => !f.IsIdentifyFrame) : _framesGray4Deduped
56+
: skipIdentificationFrames ? _framesGray4Duped.Where(f => !f.IsIdentifyFrame) : _framesGray4Duped;
5757

5858
public void NextGameName(string gameName) => _gameName.OnNext(gameName);
5959

6060
public IObservable<string> GetGameName() => _gameName;
6161
}
62-
}
62+
}

LibDmd/Output/FileOutput/RawOutput.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class RawOutput : IGray2Destination, IGray4Destination, IResizableDestina
1111
public string Name => "Raw Output";
1212
public bool IsAvailable => !string.IsNullOrEmpty(_gameName);
1313
public bool NeedsDuplicateFrames => false;
14-
public bool NeedsIdentificationFrames => false;
14+
public bool NeedsIdentificationFrames => true;
1515

1616
private string _gameName;
1717

@@ -76,4 +76,4 @@ public void Dispose()
7676
_writer?.Dispose();
7777
}
7878
}
79-
}
79+
}

LibDmd/RenderGraph.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ public IDisposable StartRendering(Action onCompleted, Action<Exception> onError
344344
// For the output, the converter acts as ISource, implementing the specific
345345
// interfaces supported. Currently the following output sources are supported:
346346
//
347-
// IColoredGray2Source, IColoredGray4Source, IColoredGray6Source and IRgb24Source.
347+
// IColoredGray2Source, IColoredGray4Source, IColoredGray6Source,
348+
// IRgb565Source and IRgb24Source.
348349
//
349350
// Other types don't make much sense (i.e. you don't convert *down* to
350351
// IGray2Source).
@@ -356,7 +357,7 @@ public IDisposable StartRendering(Action onCompleted, Action<Exception> onError
356357
// will get the IColoredGray4Source converted up to RGB24.
357358
if (Converter != null) {
358359

359-
Logger.Info($" ** Linking converter {Converter.Name} to {dest.Name}...");
360+
Logger.Info($" ** Connecting converter {Converter.Name} to {dest.Name}...");
360361

361362
// if converter emits colored gray-2 frames..
362363
if (Converter is IColoredGray2Source sourceConverterColoredGray2 && !Converter.IsConnected(dest, FrameFormat.ColoredGray2)) {
@@ -476,6 +477,7 @@ public IDisposable StartRendering(Action onCompleted, Action<Exception> onError
476477
if (Converter.IsConnected(dest)) {
477478
continue;
478479
}
480+
Logger.Info($" -- Converter {Converter.Name} could not be linked with a compatible frame format to {dest.Name}.");
479481
}
480482

481483
// Now here we need to find the most efficient way of passing data from the source
@@ -1070,7 +1072,6 @@ private void Connect(ISource source, IDestination dest, FrameFormat from, FrameF
10701072
destBitmap.RenderBitmap);
10711073
break;
10721074

1073-
10741075
default:
10751076
throw new ArgumentOutOfRangeException(nameof(to), to, null);
10761077
}
@@ -1966,4 +1967,4 @@ public IniNotFoundException(string path) : base("Could not find DmdDevice.ini at
19661967
}
19671968

19681969
#endregion
1969-
}
1970+
}

0 commit comments

Comments
 (0)