// https://github.com/libretro/common-shaders/blob/master/xbr/super-xbr-6p-small-details.cgp // https://github.com/libretro/common-shaders/blob/master/xbr/shaders/super-xbr/super-xbr-small-details-pass0.cg // https://github.com/libretro/common-shaders/blob/master/xbr/shaders/super-xbr/super-xbr-small-details-pass1.cg // https://github.com/libretro/common-shaders/blob/master/xbr/shaders/super-xbr/super-xbr-small-details-pass2.cg private void Scale(ReadOnlySpan <Color16> source, Vector2I sourceSize, Span <Color16> target, Vector2I targetSize) { var source0 = Fixed16.ConvertToReal(source.Elements()).Cast <float, Float4>(); var target0 = SpanExt.Make <Float4>(source.Length); var pass0 = new Passes.Pass0(Configuration, sourceSize, sourceSize); pass0.Pass(source0, target0); var target1 = SpanExt.Make <Float4>(target.Length); var pass1 = new Passes.Pass1(Configuration, sourceSize, targetSize); pass1.Pass(source0, target0, target1); var target2 = SpanExt.Make <Float4>(target.Length); var pass2 = new Passes.Pass2(Configuration, targetSize, targetSize); pass2.Pass(target1, target2); for (int i = 0; i < target2.Length; ++i) { target[i].R = target2[i].R.ScalarToValue16(); target[i].G = target2[i].G.ScalarToValue16(); target[i].B = target2[i].B.ScalarToValue16(); target[i].A = target2[i].A.ScalarToValue16(); } }
private bool Compare(Fixed16 reference, Fixed16 lower, Fixed16 higher) { return ((lower != higher) && ( (lower == reference && Math.Abs(higher.Value - reference.Value) <= Threshold) || (higher == reference && Math.Abs(lower.Value - reference.Value) <= Threshold) )); }
private void _read() { _version = m_io.ReadU1(); _flags = m_io.ReadBytes(3); _creationTime = m_io.ReadU4be(); _modificationTime = m_io.ReadU4be(); _timeScale = m_io.ReadU4be(); _duration = m_io.ReadU4be(); _preferredRate = new Fixed32(m_io, this, m_root); _preferredVolume = new Fixed16(m_io, this, m_root); _reserved1 = m_io.ReadBytes(10); _matrix = m_io.ReadBytes(36); _previewTime = m_io.ReadU4be(); _previewDuration = m_io.ReadU4be(); _posterTime = m_io.ReadU4be(); _selectionTime = m_io.ReadU4be(); _selectionDuration = m_io.ReadU4be(); _currentTime = m_io.ReadU4be(); _nextTrackId = m_io.ReadU4be(); }
private static Fixed16 BlendComponent(int n, int m, Fixed16 inComponent, Fixed16 setComponent) { #if XBRZ_WIDE_BLEND var blend = setComponent.Value.asSigned() * n + inComponent.Value.asSigned() * (m - n); var outChan = (blend / m).asUnsigned() & 0xFFFF; // Value is now in the range of 0 to 0xFFFF return((Fixed16)outChan); #else // XBRZ_WIDE_BLEND /* * var inChan = (int)((((uint)inPixel) >> shift) & 0xFF); * var setChan = (int)((((uint)setPixel) >> shift) & 0xFF); * var blend = setChan * n + inChan * (m - n); * var component = (((uint)(blend / m)) & 0xFF) << shift; * return component; */ var blend = (long)setComponent.Value * n + (long)inComponent.Value * (m - n); var component = (Fixed16)(blend / m); return(component); #endif // XBRZ_WIDE_BLEND }
internal Fixed16 Linearize(Fixed16 value) => Linearize(value.Value);
internal Fixed16 Delinearize(Fixed16 value) => Delinearize(value.Value);
internal static Fixed16 Min(this Fixed16 a, Fixed16 b) => Math.Min(a.Value, b.Value);
internal static Fixed16 Clamp(this Fixed16 v, Fixed16 min, Fixed16 max) => Math.Clamp(v.Value, min.Value, max.Value);
internal static Fixed16 Max(Fixed16 a, Fixed16 b, Fixed16 c) => Max(a, Max(b, c));
internal static Fixed16 Min(Fixed16 a, Fixed16 b, Fixed16 c) => Min(a, Min(b, c));