Re: about Color Format transformation
- From: Iain <Iain@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Apr 2005 11:37:44 +0100
On Tue, 12 Apr 2005 20:11:57 +0500, Yeghia Dolbakyan wrote:
As I read the code, it will accept RGB or YUV in and allow RGB out only.
Having said that your code will not reject YUV output if a downstream
filter proposes that (you don't check mtOut in CheckTransform), so a
renderer may still propose a YUV type if it doesn't want to connect up RGB
and this code will accept it.
Iain
> Hi Iain
>
> The code I have follows. Is there anything wrong?
>
> HRESULT CVideoProcessorFilter::GetMediaType(int iPosition, CMediaType
> *pMediaType)
> {
> // Is the input pin connected
> if (!m_pInput->IsConnected())
> return E_UNEXPECTED;
>
> // This should never happen
> if (iPosition < 0)
> return E_INVALIDARG;
>
> // Do we have more items to offer
> if (iPosition > 0)
> return VFW_S_NO_MORE_ITEMS;
>
> CheckPointer(pMediaType,E_POINTER);
>
> VIDEOINFOHEADER2 *pVih = (VIDEOINFOHEADER2
> *)pMediaType->AllocFormatBuffer(4096);
> memset(pVih, 0, sizeof(VIDEOINFOHEADER2));
> pVih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
> pVih->bmiHeader.biWidth = 720;
> pVih->bmiHeader.biHeight = 576;
> pVih->bmiHeader.biBitCount = 24;
> pVih->bmiHeader.biPlanes = 1;
> pVih->bmiHeader.biCompression = BI_RGB;
> pVih->bmiHeader.biSizeImage = GetBitmapSize(&pVih->bmiHeader);
> pVih->bmiHeader.biClrImportant = 0;
>
> SetRect(&pVih->rcSource, 0, 0, 720, 576);
> SetRect(&pVih->rcTarget, 0, 0, 720, 576);
>
> pMediaType->SetType(&MEDIATYPE_Video);
> pMediaType->SetFormatType(&FORMAT_VideoInfo2);
> pMediaType->SetTemporalCompression(FALSE);
> pMediaType->SetFormat((BYTE *)pVih, sizeof(VIDEOINFOHEADER2));
>
> // Work out the GUID for the subtype from the header info.
> const GUID SubTypeGUID = GetBitmapSubtype(&pVih->bmiHeader);
> pMediaType->SetSubtype(&SubTypeGUID);
> pMediaType->SetSampleSize(pVih->bmiHeader.biSizeImage);
>
> return S_OK;
> }
>
>
> HRESULT CVideoProcessorFilter::CheckTransform(const CMediaType *mtIn, const
> CMediaType *mtOut)
> {
> CheckPointer(mtIn, E_POINTER);
> CheckPointer(mtOut, E_POINTER);
>
> BOOL bResult = FALSE;
> if (IsEqualGUID(*mtIn->Type(), MEDIATYPE_Video))
> {
> bResult = IsEqualGUID(*mtIn->Subtype(), MEDIASUBTYPE_RGB24) ||
> IsEqualGUID(*mtIn->Subtype(), MEDIASUBTYPE_RGB32) ||
> IsEqualGUID(*mtIn->Subtype(), MEDIASUBTYPE_YUY2);
> }
>
> return bResult ? NOERROR : E_FAIL;
> }
>
> BOOL CVideoProcessorFilter::CanPerformVideoProcessor(const CMediaType
> *pMediaType) const
> {
> CheckPointer(pMediaType,FALSE);
>
>
> return FALSE;
> }
>
> Regards
> Yeghia
>
> "Iain" <Iain@xxxxxxxxxxxxxxxxxx> wrote in message
> news:13pjrcnhacju6$.1brx4p7f94pwa$.dlg@xxxxxxxxxxxxx
>> On Mon, 11 Apr 2005 23:41:57 +0500, Yeghia Dolbakyan wrote:
>>
>>> Hi guys
>>>
>>> I have to develop transform filter which make conversion from YUY2 (or
>>> basicly any YUV format) to RGB24. My problem is that I don't understand
>>> what should I do to make my output pin report its type as RGB24. It
>>> always
>>> shows YUY2 (the same as input format). I need to work on the frame n RGB
>>> format.
>>>
>>> What you can offer me? Is there any similar sample (except of Microsoft's
>>> EZRGBxxx samples)
>>>
>>> Thanks for your help
>>>
>>> Regards
>>> Yeghia
>>
>> Simply put you need to do 2 things.
>>
>> IMpleement a GetMediaType Method and implement a CHeckTransform method.
>>
>> This is covered in 'Step 3. Support Media Type Negotiation' in the Writing
>> Transform Filters section of the docs.
>>
>> Iain
>> --
>> Iain Downs (DirectShow MVP)
>> Software Product Consultant
>> www.idcl.co.uk
--
Iain Downs (DirectShow MVP)
Software Product Consultant
www.idcl.co.uk
.
- Follow-Ups:
- Re: about Color Format transformation
- From: Yeghia Dolbakyan
- Re: about Color Format transformation
- References:
- about Color Format transformation
- From: Yeghia Dolbakyan
- Re: about Color Format transformation
- From: Iain
- Re: about Color Format transformation
- From: Yeghia Dolbakyan
- about Color Format transformation
- Prev by Date: Re: Getting width from DVCam connected to VMR9
- Next by Date: Re: about Color Format transformation
- Previous by thread: Re: about Color Format transformation
- Next by thread: Re: about Color Format transformation
- Index(es):
Relevant Pages
|