Skip to main content

 none
adjust Brightness of media file with dshow RRS feed

  • Question

  •  

    I need to adjust brightness of the media file with directshow,but i do not know how to complete it.Any help will be appreciated.

                                             Thanks.

    Wednesday, October 31, 2007 10:11 AM

Answers

  • I grab the sample with the sample grabber, then I loop through the pixles, adding a value(params[10]) to each color value.


    Code Block

    char *CAutoMix::AddGain(char * pBuffer)
    {
       
        RGBQUAD * scratch=(RGBQUAD*)pBuffer;
        int k=0;
        for(int i=0;i<240;i++)
        {
            for(int j=0;j<320;j++)
            {
                if((scratch[0].rgbBlue + TheParams[10])>255)scratch[0].rgbBlue=255;
                else scratch[0].rgbBlue += TheParams[10];
                            if((scratch[0].rgbRed + TheParams[10])>255)scratch[0].rgbRed=255;
                else scratch[0].rgbRed  += TheParams[10];
                            if((scratch[0].rgbGreen  + TheParams[10])>255)scratch[0].rgbGreen=255;
                else scratch[0].rgbGreen += TheParams[10];
              scratch++;
            };


        };

    return pBuffer;
    }


    With this function , I can white out the entire sample, using a slider control dynamically, while running the clip.
    Wednesday, October 31, 2007 5:30 PM

All replies

  • u can use IVMR9MixerControl9::SetProcAmpControl() function setting VMR9ProcAmpControl structure

     

    Wednesday, October 31, 2007 1:46 PM
  • I grab the sample with the sample grabber, then I loop through the pixles, adding a value(params[10]) to each color value.


    Code Block

    char *CAutoMix::AddGain(char * pBuffer)
    {
       
        RGBQUAD * scratch=(RGBQUAD*)pBuffer;
        int k=0;
        for(int i=0;i<240;i++)
        {
            for(int j=0;j<320;j++)
            {
                if((scratch[0].rgbBlue + TheParams[10])>255)scratch[0].rgbBlue=255;
                else scratch[0].rgbBlue += TheParams[10];
                            if((scratch[0].rgbRed + TheParams[10])>255)scratch[0].rgbRed=255;
                else scratch[0].rgbRed  += TheParams[10];
                            if((scratch[0].rgbGreen  + TheParams[10])>255)scratch[0].rgbGreen=255;
                else scratch[0].rgbGreen += TheParams[10];
              scratch++;
            };


        };

    return pBuffer;
    }


    With this function , I can white out the entire sample, using a slider control dynamically, while running the clip.
    Wednesday, October 31, 2007 5:30 PM
  • hi,everyone,thank you.

    But i need adjust most of the media file format(rmvb,avi,asf,wmv..),and is there a way to complete them at once,as i do not want to write a transform for every one format,

    any suggest will be much appreciated,thanks . 

    Friday, November 2, 2007 1:44 AM
  • The example given by Bowljoman works for all formats. The grabber/transform must be set to accept only RGB32. Insert the grabber in the recompression graph.You must adapt the width and height to the actual values for the sample being processed.

    Friday, November 2, 2007 7:33 AM
    Moderator
  • hi,Bowljoman ,Thanks to your advise.

    i am a newer about dshow,and i do not know how to use the function you put up,can you tell me two answer about the question:

    1.what is the params? am_media_type?

    2.what is the return value?

     

    i think the two questions are the same to each other,in a word, please explain the function and the context.

    Friday, November 2, 2007 9:33 AM
  • do i need to write a transform filter?

    if i used the sample grabber filter,will the program spend much cpu? 

    Sunday, November 4, 2007 6:46 AM
  • i just want to add the code to the media player classic source code,how can i do?

    Sunday, November 4, 2007 7:14 AM
  • The function comes from a mfc application with a slider control. params is updated by the slider value, between 0 and 255, which I can adjust while watching the media file.

    And yes, For sure the example is a 320*240*32 bit media sample.

    Now, I resample the video frame rate as well, and I have the sample grabber in buffered mode, but that part is up to you.

    What matters is getting the media sample.

    Code Block

    long bs;

    hr=iGrabber->GetCurrentBuffer (&bs,NULL);
    char *buff1=new char[bs];

    iGrabber->GetCurrentBuffer (&bs,(long*)buff1);


    AddGain(buff1);


    //the return is just a pointer to the buffer.

    //to use in a filter for instance.

    char* pTransformed=new char[pMediaSample->GetSize ()];

    pMediaSample->GetPointer(&pBuffer);

    memcpy(pTransformed,AddGain(pBuffer),pMediaSample->GetSize ());

    //or some variety of that. The returned pointer providing just one less line of code.





    By returning the buffer pointer I can stack processing
    Code Block

    AddGain(posterize(setAlpha(pBuffer)));



    Sunday, November 4, 2007 7:31 AM
  • hi, you can't use ProcAmpControl, you can use the wmp control.

    then you can using IWMPVideoSettingsCtrl to change the video settings.

    article: http://www.codeproject.com/KB/audio-video/IWMEqualizerSettingsCtrl2.aspx

    here is the sample: http://www.wmpexsoft.com

     

    Thursday, July 3, 2008 9:16 AM