HRESULT CKalmTrack::CheckTransform(const CMediaType *mtIn,const CMediaType *mtOut) { HRESULT hr; if (FAILED(hr = CheckInputType(mtIn))) { return hr; } // format must be a VIDEOINFOHEADER if (*mtOut->FormatType() != FORMAT_VideoInfo) { return E_INVALIDARG; } // formats must be big enough if (mtIn->FormatLength() < sizeof(VIDEOINFOHEADER) || mtOut->FormatLength() < sizeof(VIDEOINFOHEADER)) return E_INVALIDARG; VIDEOINFO *pInput = (VIDEOINFO *) mtIn->Format(); VIDEOINFO *pOutput = (VIDEOINFO *) mtOut->Format(); if (memcmp(&pInput->bmiHeader,&pOutput->bmiHeader,sizeof(BITMAPINFOHEADER)) == 0) { return NOERROR; } return E_INVALIDARG; } // CheckTransform
HRESULT CDeCSSFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut) { return SUCCEEDED(CheckInputType(mtIn)) && mtOut->majortype == MEDIATYPE_MPEG2_PACK || mtOut->majortype == MEDIATYPE_MPEG2_PES ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; }
HRESULT CCorePNGEncoderFilter::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { HRESULT hr = CheckInputType(mtIn); if(hr == S_FALSE) { return hr; } return NOERROR; };
HRESULT CG729EncoderFilter::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { CheckPointer( mtIn, E_POINTER ); CheckPointer( mtOut, E_POINTER ); HRESULT hr = CheckInputType( mtIn ); if ( FAILED(hr) ) return hr; return NOERROR; }
HRESULT CCorePNGSubtitlerFilter::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { HRESULT hr = CheckInputType(mtIn); if (mtOut->majortype != MEDIATYPE_Video || mtOut->subtype != MEDIASUBTYPE_RGB24) return S_FALSE; if(hr == S_FALSE) { return hr; } return NOERROR; };
HRESULT CCINVideoDecompressor::CheckTransform( const CMediaType *mtIn, const CMediaType *mtOut ) { // Check and validate the pointers CheckPointer(mtIn, E_POINTER); ValidateReadPtr(mtIn, sizeof(CMediaType)); CheckPointer(mtOut, E_POINTER); ValidateReadPtr(mtOut, sizeof(CMediaType)); // Check if the input media type is acceptable HRESULT hr = CheckInputType(mtIn); if (hr != S_OK) return hr; // Check if the output format is acceptable if ( !IsEqualGUID(*mtOut->Type(), MEDIATYPE_Video ) || !IsEqualGUID(*mtOut->Subtype(), MEDIASUBTYPE_RGB8 ) || !IsEqualGUID(*mtOut->FormatType(), FORMAT_VideoInfo ) ) return VFW_E_TYPE_NOT_ACCEPTED; // Get the media types' format blocks CIN_HEADER *pInFormat = (CIN_HEADER*)mtIn->Format(); VIDEOINFO *pOutFormat = (VIDEOINFO*)mtOut->Format(); // Check if the format length is enough if (mtOut->FormatLength() < sizeof(VIDEOINFO)) return VFW_E_TYPE_NOT_ACCEPTED; // Check the compatibility of the formats DWORD cbFrame = pInFormat->dwVideoWidth * pInFormat->dwVideoHeight; return ( //(pOutFormat->AvgTimePerFrame == UNITS / CIN_FPS ) && (pOutFormat->bmiHeader.biWidth == (LONG)pInFormat->dwVideoWidth ) && (pOutFormat->bmiHeader.biHeight == -(LONG)pInFormat->dwVideoHeight ) && (pOutFormat->bmiHeader.biPlanes == 1 ) && (pOutFormat->bmiHeader.biBitCount == 8 ) && (pOutFormat->bmiHeader.biCompression == BI_RGB ) && (pOutFormat->bmiHeader.biSizeImage == cbFrame ) ) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; }
HRESULT CWavPackDSDecoder::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { if ((*mtOut->Type() != MEDIATYPE_Audio) || (*mtOut->Subtype() != MEDIASUBTYPE_PCM) || (*mtOut->FormatType() != FORMAT_WaveFormatEx)) { return VFW_E_TYPE_NOT_ACCEPTED; } WAVEFORMATEX *pwfxin = (WAVEFORMATEX *)mtIn->Format(); WAVEFORMATEX *pwfxout = (WAVEFORMATEX *)mtOut->Format(); if ((pwfxin->nSamplesPerSec != pwfxout->nSamplesPerSec) || (pwfxin->nChannels != pwfxout->nChannels) || (pwfxin->wBitsPerSample != pwfxout->wBitsPerSample)) { return VFW_E_TYPE_NOT_ACCEPTED; } return CheckInputType(mtIn); }
HRESULT CG729Codec::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { CheckPointer( mtIn, E_POINTER ); CheckPointer( mtOut, E_POINTER ); HRESULT hr = CheckInputType( mtIn ); if ( FAILED(hr) ) return hr; if ( mtIn->subtype == MEDIASUBTYPE_PCM && mtOut->subtype == MEDIASUBTYPE_G729AAudio ) { return NOERROR; } if ( mtIn->subtype == MEDIASUBTYPE_G729AAudio && mtOut->subtype == MEDIASUBTYPE_PCM ) { return NOERROR; } return VFW_E_TYPE_NOT_ACCEPTED; }
HRESULT CMVEADPCMDecompressor::CheckTransform( const CMediaType *mtIn, const CMediaType *mtOut ) { // Check and validate the pointers CheckPointer(mtIn, E_POINTER); ValidateReadPtr(mtIn, sizeof(CMediaType)); CheckPointer(mtOut, E_POINTER); ValidateReadPtr(mtOut, sizeof(CMediaType)); // Check if the input media type is acceptable HRESULT hr = CheckInputType(mtIn); if (hr != S_OK) return hr; // Check if the output format is acceptable if ( !IsEqualGUID(*mtOut->Type(), MEDIATYPE_Audio ) || !IsEqualGUID(*mtOut->Subtype(), MEDIASUBTYPE_PCM ) || !IsEqualGUID(*mtOut->FormatType(), FORMAT_WaveFormatEx ) ) return VFW_E_TYPE_NOT_ACCEPTED; // Get the media types' format blocks MVE_AUDIO_INFO *pInFormat = (MVE_AUDIO_INFO*)mtIn->Format(); WAVEFORMATEX *pOutFormat = (WAVEFORMATEX*)mtOut->Format(); // Compare the format blocks return ( (pOutFormat->wFormatTag == WAVE_FORMAT_PCM ) && (pOutFormat->nChannels == (pInFormat->wFlags & MVE_AUDIO_STEREO) ? 2 : 1 ) && (pOutFormat->nSamplesPerSec == pInFormat->wSampleRate ) && (pOutFormat->wBitsPerSample == (pInFormat->wFlags & MVE_AUDIO_16BIT) ? 16 : 8 ) ) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; }
HRESULT CWavDestFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut) { return CheckInputType(mtIn); }
HRESULT CHWMFT::SetInputType( DWORD dwInputStreamID, IMFMediaType* pType, DWORD dwFlags) { /***************************************** ** See http://msdn.microsoft.com/en-us/library/ms700113(v=VS.85).aspx *****************************************/ HRESULT hr = S_OK; IMFMediaType* pMT = NULL; do { if(IsLocked() != FALSE) { hr = MF_E_TRANSFORM_ASYNC_LOCKED; break; } if(pType == NULL) { hr = E_POINTER; break; } /***************************************** ** Todo: If your MFT supports more than one ** stream, make sure you modify ** MFT_MAX_STREAMS and adjust this function ** accordingly *****************************************/ if(dwInputStreamID >= MFT_MAX_STREAMS) { hr = MF_E_INVALIDSTREAMNUMBER; break; } hr = CheckInputType(pType); if(FAILED(hr)) { break; } /******************************************* ** Store a copy of the media type, not the ** one passed in by the caller. This way the ** caller is unable to modify the internal ** media type *******************************************/ hr = MFCreateMediaType(&pMT); if(FAILED(hr)) { break; } hr = DuplicateAttributes(pMT, pType); if(FAILED(hr)) { break; } { CAutoLock lock(&m_csLock); SAFERELEASE(m_pInputMT); m_pInputMT = pMT; m_pInputMT->AddRef(); } IsMFTReady(); }while(false); SAFERELEASE(pMT); return hr; }