- Posts: 3
- Joined: Wed Apr 03, 2024 2:29 am
- Real Name: BAEK TAE SEONG
I'm using C#.
I did the following before I rendered the Frame for this task, which works as desired. However, because the operation is performed every frame, it results in the Frame being lowered.
I found another way, if my understanding is correct, is Chroma able to achieve the above effect?
However, this also doesn't work, throwing an error called System.NotImplementedException. Both Input/Output will throw an error.
I have verified that the code below works fine.
is there any other solution that I haven't found?
I'm eagerly anticipating your assistance.
I did the following before I rendered the Frame for this task, which works as desired. However, because the operation is performed every frame, it results in the Frame being lowered.
- Code: Select all
public IDeckLinkVideoFrame ProcessFrame(IDeckLinkVideoFrame rawFrame, float brightnessFactor, float redFactor, float greenFactor, float blueFactor)
{
IntPtr pFrameBuffer;
rawFrame.GetBytes(out pFrameBuffer);
int width = rawFrame.GetWidth();
int height = rawFrame.GetHeight();
int rowBytes = rawFrame.GetRowBytes();
// Reuse the frameBytes array if possible, otherwise create a new one
byte[] frameBytes = new byte[rowBytes * height];
// Copy frame data to managed array
Marshal.Copy(pFrameBuffer, frameBytes, 0, frameBytes.Length);
float redBrightnessFactor = redFactor * brightnessFactor;
float greenBrightnessFactor = greenFactor * brightnessFactor;
float blueBrightnessFactor = blueFactor * brightnessFactor;
// Process each pixel
Parallel.For(0, height, y =>
{
for (int x = 0; x < width; x++)
{
int offset = (y * rowBytes) + (x * 4);
// BGRA format
byte blue = frameBytes[offset];
byte green = frameBytes[offset + 1];
byte red = frameBytes[offset + 2];
// Apply factors
red = (byte)Math.Min(255, red * redBrightnessFactor);
green = (byte)Math.Min(255, green * greenBrightnessFactor);
blue = (byte)Math.Min(255, blue * blueBrightnessFactor);
frameBytes[offset] = blue;
frameBytes[offset + 1] = green;
frameBytes[offset + 2] = red;
}
});
// Copy modified data back to frame buffer
Marshal.Copy(frameBytes, 0, pFrameBuffer, frameBytes.Length);
return rawFrame;
}
I found another way, if my understanding is correct, is Chroma able to achieve the above effect?
- Code: Select all
IDeckLinkConfiguration deckLinkConfiguration = m_deckLink as IDeckLinkConfiguration;
//deckLinkConfiguration.GetFloat(_BMDDeckLinkConfigurationID.bmdDeckLinkConfigVideoOutputComponentChromaRedGain, out double value);
deckLinkConfiguration.SetFloat(_BMDDeckLinkConfigurationID.bmdDeckLinkConfigVideoInputComponentChromaRedGain, 1.0f);
However, this also doesn't work, throwing an error called System.NotImplementedException. Both Input/Output will throw an error.
I have verified that the code below works fine.
is there any other solution that I haven't found?
- Code: Select all
deckLinkConfiguration.SetString(_BMDDeckLinkConfigurationID.bmdDeckLinkConfigDeviceInformationCompany, "TESTCOMPANY"); deckLinkConfiguration.GetString(_BMDDeckLinkConfigurationID.bmdDeckLinkConfigDeviceInformationCompany, out string value);
I'm eagerly anticipating your assistance.