Medialooks Knowledge Base Support Center

Contact Us

Color management with MColors

You can change brightness, contrast and color parameters of your video with an MColors object. This is a plugin available both in MFormats and MPlatform SDKs.

Structure of the MColors

There are 2 structures you can manage with the plugin. They are color parameters (MG_COLOR_PARAM) - and brightness&contrast (MG_BRIGHT_CONT_PARAM) parameters. And 2 couples of methods to get and set these parameters.

Parameters

Color Parameters - MG_COLOR_PARAM

 Field
 Possible range
 Description
dblUlevel
-1..1. Default value: 0.
U-level
dblUVGain
0..1. Default value: 1.
UV-gain
dblVlevel
-1..1. Default value: 0.
V-level
dblYGain
0..1. Default value: 1.
Y-gain
dblYlevel
-1..1. Default value: 0.
Y-level

Brightness & Contrast parameters - MG_BRIGHT_CONT_PARAM

 Field
 Possible range
 Description
dblBlackLevel
-1..1. Default value: 0.
Black level
dblBrightness
-1..1. Default value: 0.
Brightness
dblColorGain
0..1. Default value: 1.
Color gain
dblContrast
-1..1. Default value: 0.
Contrast
dblWhiteLevel
0..1. Default value: 1.
White level

Note please that when you create a new instance of a structure, all the fields are 0. So you should either set required values by filling the structure or get the original structure with GetBrightContParam and GetColorParam methods.

How to work with MPlatform SDK?

Create an instance of the MColors object:

CoMColorsClass m_objColors = new CoMColorsClass();

Add the object as a plugin to your source:

m_objMLive.PluginsAdd(m_objColors, 0);

Specify parameters:

private void SetColorConversion(object sender, EventArgs e)
{
    MG_COLOR_PARAM colorParam = new MG_COLOR_PARAM
    {
        dblUlevel = 0,
        dblUVGain = 1,
        dblVlevel = 0,
        dblYGain =  1,
        dblYlevel = 0
    };
    m_objColors.SetColorParam(ref colorParam, 1, 0);
}

private void SetBrightnessContrast(object sender, EventArgs e)
{
    MG_BRIGHT_CONT_PARAM brightContParam = new MG_BRIGHT_CONT_PARAM
    {
        dblWhiteLevel = 0,
        dblContrast =   0,
        dblColorGain =  1,
        dblBrightness = 0,
        dblBlackLevel = 1
    };
    m_objColors.SetBrightContParam(ref brightContParam, 1, 0);
}

How to work with MFormats SDK?

Create an instance of the MColors object:

CoMColorsClass m_objColors = new CoMColorsClass();

Specify the plugin parameters the same way as for MPlatform SDK. 

Then grab a frame from your source and process it with the MColors object:

MFFrame sourceFrame;
mySource.SourceFrameGet(-1, out sourceFrame, "");
int framesRest;
MFFrame modifiedFrame;
((IMFProcess)m_objColors).ProcessFrame(sourceFrame, out modifiedFrame, out framesRest, "");

Later you can use the modifiedFrame for output, for example for preview:

((IMFReceiver)myPreview).ReceiverFramePut(modifiedFrame, -1, "");