The left shift effect is featured in my fake paranormal video. What the ShlEffect does is shift each color channel in a frame's pixels an arbitrary number of bits left. That strips the data off the top and makes for interesting effects based on underlying shading.
It is also one way someone could flush out moving "invisible" gradient structures, such as when they found that huge leak at the natural gas field in LA. I used to play around with that with fire clouds and pictures I took. One could see they extended beyond the reach of the visible cloud.
Here is an example:
Capture from live video via USB converter from HDMI @ 1920 x 1080, with color channels shifted left by three. |
It should be noted that the some areas, when drilled down, will carry a texture of randomness. Here is a picture of plotted random numbers for recognition purposes.
Distributions and frequency of set of 50 million of my random numbers. |
Anyhow here is the code. There are three main properties RedShift, GreenShift, and BlueShift. The three values are amounts to shift left on each color channel.
public sealed class ShlEffect : IBasicVideoEffect
{
private int frameCount = 0;
private bool skipWrite;
private int[] BGRd;
public bool TimeIndependent { get { return true; } }
public MediaMemoryTypes SupportedMemoryTypes { get { return MediaMemoryTypes.Gpu; } }
public bool IsReadOnly { get { return false; } }
private CanvasDevice canvasDevice;
public IReadOnlyList<VideoEncodingProperties> SupportedEncodingProperties
{
get
{
var encodingProperties = new VideoEncodingProperties();
encodingProperties.Subtype = "ARGB32";
return new List<VideoEncodingProperties>() { encodingProperties };
}
}
public void SetEncodingProperties(VideoEncodingProperties encodingProperties, IDirect3DDevice device)
{
canvasDevice = CanvasDevice.CreateFromDirect3D11Device(device);
}
public void SetProperties(IPropertySet configuration)
{
BGRd = new int[3];
if (configuration.TryGetValue("BlueDepth", out object rd))
{
BGRd[0] = (int)rd;
}
else
{
BGRd[0] = 0;
}
if (configuration.TryGetValue("GreenDepth", out object gd))
{
BGRd[1] = (int)gd;
}
else
{
BGRd[1] = 0;
}
if (configuration.TryGetValue("RedDepth", out object bd))
{
BGRd[2] = (int)bd;
}
else
{
BGRd[2] = 0;
}
if (configuration.TryGetValue("SkipWrite", out object sw))
{
skipWrite = (bool)sw;
}
else
{
skipWrite = false;
}
}
public void DiscardQueuedFrames()
{
frameCount = 0;
}
public void Close(MediaEffectClosedReason reason)
{
}
public void ProcessFrame(ProcessVideoFrameContext context)
{
if (skipWrite)
{
using (CanvasBitmap inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice, context.InputFrame.Direct3DSurface))
using (CanvasRenderTarget renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(canvasDevice, context.OutputFrame.Direct3DSurface))
{
renderTarget.CopyPixelsFromBitmap(inputBitmap);
}
return;
}
long lo = DateTime.Now.Ticks;
frameCount += 1;
using (CanvasBitmap inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice, context.InputFrame.Direct3DSurface))
{
using (CanvasRenderTarget renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(canvasDevice, context.OutputFrame.Direct3DSurface))
{
Byte[] bt2 = inputBitmap.GetPixelBytes();
for (int lt1 = 0; lt1 < bt2.Length; lt1 += 4)
{
for (int ofs = lt1; ofs < lt1 + 3; ofs++)
{
bt2[ofs] = (byte)(bt2[ofs] << BGRd[ofs % 4]);
}
}
renderTarget.SetPixelBytes(bt2);
}
}
Debug.WriteLine(frameCount + " " + (DateTime.Now.Ticks - lo) / 10000);
}
}
Guess that's about it. Have fun!
Note about code listing. When copied the right arrow (<) and left arrow (>) may not show up properly, and instead be represented by the string literals (<) and (>) respectively. Replace those four character literals with the correct arrow in that case.
Disclaimer: This is free for personal use only. Place of origin, California, US.