locked
How to change Output Pin MediaSample Size in Custom Filter RRS feed

  • Question

  • How to change Output Pin MediaSample Size in Custom Filter(CBaseFilter Inherited).

    i have a writen a filter which has 4 Input Pins and one output pin I connect 4 Input pins with video SOurce filters all delivering samples in 320x240 size ..but i need output in 640x480..with all combined 4 video stream in to single..

    Now I can receive all MediaSamples .. But i have to do 2 things next.

    1.I have to change the output size of OutputPin into 640x480.(I tried DecideBuffersize() but its SetProperty giving a Error(can not modify values in COM+ Admin sdk) like that );

    2.I have to process 4 media samples into single Media sample.

    Thanks in advance
    bala


    Friday, July 17, 2009 1:16 PM

Answers

  • First you have to specify the correct bitmapinfoheader on your output pin's GetMediaType(), are you doing that?

    DecideBufferSize() is the correct place to call SetProperties() on the allocator.  Make sure you are calculating the size correctly.  Here's a sample:

    //
    // DecideBufferSize
    //
    // Tell the output pin's allocator what size buffers we
    // require. Can only do this when the input is connected
    //
    HRESULT CCSVideoDecoder::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties)
    {
        // Is the input pin connected
        if (m_pInput->IsConnected() == FALSE) {
            return E_UNEXPECTED;
        }
    
        ASSERT(pAlloc);
        ASSERT(pProperties);
        HRESULT hr = NOERROR;
    
    	// get input dimensions
    	CMediaType outMediaType = m_pOutput->CurrentMediaType();
        if (*outMediaType.FormatType() == FORMAT_VideoInfo)
    	{
    		VIDEOINFOHEADER *vihOut = (VIDEOINFOHEADER *)outMediaType.Format();
    		pProperties->cbBuffer = GetBitmapSize(&vihOut->bmiHeader);
    		ASSERT(pProperties->cbBuffer);
    	}
    
        pProperties->cBuffers = MAX_SAMPLE_QUEUE;
    
        // Ask the allocator to reserve us some sample memory
    
        ALLOCATOR_PROPERTIES Actual;
        hr = pAlloc->SetProperties(pProperties,&Actual);
        if (FAILED(hr)) {
            return hr;
        }
    
        ASSERT( Actual.cBuffers >= 1 );
    
        if (pProperties->cBuffers > Actual.cBuffers ||
                pProperties->cbBuffer > Actual.cbBuffer) {
                    return E_FAIL;
        }
    
    
    	return NOERROR;
    }


    www.chrisnet.net
    Friday, July 17, 2009 1:43 PM