Lucsa@BJ

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.



Re: DirectShow Development adjust Brightness of media file with dshow

KingofKings

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





Re: DirectShow Development adjust Brightness of media file with dshow

Bowljoman

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.





Re: DirectShow Development adjust Brightness of media file with dshow

Lucsa@BJ

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 .





Re: DirectShow Development adjust Brightness of media file with dshow

Michel Roujansky

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.






Re: DirectShow Development adjust Brightness of media file with dshow

Lucsa@BJ

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.





Re: DirectShow Development adjust Brightness of media file with dshow

Lucsa@BJ

do i need to write a transform filter

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





Re: DirectShow Development adjust Brightness of media file with dshow

Lucsa@BJ

i just want to add the code to the media player classic source code,how can i do





Re: DirectShow Development adjust Brightness of media file with dshow

Bowljoman

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)));