掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
VideoInfoをVideoInfo2に変換するには? (ID:73476)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
皆さん、始めまして。 VideoInfoをVideoInfo2に変換するためには、「ConvertVideoInfoToVideoInfo2」を使ってDirectsowのFilterを作くればいいことが分かったので、「http://www.independence-sys.com/weblog/item/158」を参考にしました。 GetMediaTypeで、「ConvertVideoInfoToVideoInfo2」の処理を入れれば良いと思ったのですが、映像が斜めのシマシマ映像になってしまい行き詰っています。 大きく変えた所は以下のとおりです。 御教授願えませんでしょうか。 HRESULT CTransEffectFilter::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { if (CanPerformTransform(mtIn)) { if (*mtOut->Subtype() == *mtIn->Subtype()) return S_OK; else return VFW_E_TYPE_NOT_ACCEPTED; //return S_OK; } return VFW_E_TYPE_NOT_ACCEPTED; } HRESULT CTransEffectFilter::GetMediaType(int iPosition, CMediaType *pMediaType) { if(iPosition == 0) { CopyMediaType(pMediaType,&(m_pInput->CurrentMediaType())); pMediaType->SetSubtype(&MEDIASUBTYPE_UYVY); ConvertVideoInfoToVideoInfo2(pMediaType); return S_OK; } return VFW_S_NO_MORE_ITEMS; } HRESULT CTransEffectFilter::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pPropInputRequest) { IMemAllocator *InAlloc; ALLOCATOR_PROPERTIES InProps; CheckPointer(pAlloc,E_POINTER); CheckPointer(pPropInputRequest,E_POINTER); // Is the input pin connected if(m_pInput->IsConnected() == FALSE) { return E_UNEXPECTED; } HRESULT hr = NOERROR; pPropInputRequest->cBuffers = 1; pPropInputRequest->cbBuffer; m_pInput->CurrentMediaType().GetSampleSize(); HRESULT result; result = m_pInput->GetAllocator(&InAlloc); if(SUCCEEDED(result)) { result = InAlloc->GetProperties(&InProps); if(SUCCEEDED(result)) { pPropInputRequest->cbBuffer = InProps.cbBuffer; InAlloc = NULL; } } ////THIS WHOLE //CHECK GOES OK if(FAILED(result)) return S_FALSE; // Ask the allocator to reserve us some sample memory, NOTE the function // can succeed (that is return NOERROR) but still not have allocated the // memory that we requested, so we must check we got whatever we wanted ALLOCATOR_PROPERTIES Actual; hr = pAlloc->SetProperties(pPropInputRequest,&Actual); if(FAILED(hr)) { return hr; } ////THIS ONE FAILS ASSERT(Actual.cBuffers == 1); if(pPropInputRequest->cBuffers > Actual.cBuffers ||pPropInputRequest->cbBuffer > Actual.cbBuffer) { return E_FAIL; } ///FAILS TOO! return NOERROR; } HRESULT CTransEffectFilter::Transform(IMediaSample *pIn, IMediaSample *pOut) { LPDWORD pSrc, pDest; long act_size; //unsigned int grey; DWORD r,g,b; pIn->GetPointer((BYTE**)&pSrc); pOut->GetPointer((BYTE**)&pDest); act_size = pIn->GetActualDataLength(); //ここでは適当にグレーに変換 for(LONG y=0; y<m_Vih.bmiHeader.biHeight; y++) { for(LONG x=0; x<m_Vih.bmiHeader.biWidth; x++) { r = ((*pSrc) & 0xff0000) >> 16; g = ((*pSrc) & 0xff00) >> 8; b = (*pSrc) & 0xff; /*grey = (30 * r + 59 * g + 11 * b) / 100; r = g = b = (BYTE) grey;*/ *pDest = (r << 16) | (g << 8) | (b); pSrc++; pDest++; } } //サンプルタイムの設定 LONGLONG media_start, media_end; pIn->GetMediaTime(&media_start, &media_end); pOut->SetMediaTime(&media_start, &media_end); REFERENCE_TIME ref_start, ref_end; pIn->GetTime(&ref_start, &ref_end); pOut->SetTime(&ref_start, &ref_end); //同期ポイントのプロパティ設定 pOut->SetSyncPoint(TRUE); //データ長設定 pOut->SetActualDataLength(act_size); return S_OK; }
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.