Pls Help: Problem in video using YUY2 source filter

Pls Help: Problem in video using YUY2 source filter

Post by akhilesh.k » Wed, 21 Jul 2004 03:54:08


i,

I am writing a source filter, which spit YUY2 (4:2:2)at its output
pin,
Filter is connected and working fine except for the, Video I see is
completly garbled, I am not sure What I am doing Wrong. I have 480X260
YUY2 video, in the CheckMediaType I am using
abs(pvi->bmiHeader.biHeight) absolute value to check
the height is that OK, Without abs() Pin does not connect. Frame rate
is
30FPS( per second). I have tried every thing possible, likr Setting
Time for each sample as well as without setting Time I am not sure
Where the problem is.

Can some help me by looking in to my code to find out what the problem
is.
I am including the major snippet of the code but if some body
interested I
can send My sample project with a samll media file.

Help apriciated.
Thanks
Akhilesh

//To reduce the size erroe cheching portion has been removed

CVTKVdeoStream(HRESULT *phr, CVTKVideoSourceFilter *pParent, LPCWSTR
pPinName)
: CSourceStream(NAME("VTK Video"),phr, pParent, pPinName)

{
m_BitmapInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
m_BitmapInfoHeader.biWidth = 480;
m_BitmapInfoHeader.biHeight = 260;
m_BitmapInfoHeader.biPlanes = 1;
m_BitmapInfoHeader.biBitCount = 16;
m_BitmapInfoHeader.biCompression = '2YUY';
m_BitmapInfoHeader.biSizeImage = 249600;//518400;//
m_BitmapInfoHeader.biXPelsPerMeter = 0;
m_BitmapInfoHeader.biYPelsPerMeter = 0;
m_BitmapInfoHeader.biClrUsed = 0;
m_BitmapInfoHeader.biClrImportant = 0;
m_rtFrameLength = 10^7/30;
m_Starttime = 0;
m_fp = NULL;
m_fp = fopen("c:\\video.mp4", "rb"); //Contains only fixed size video
sample

}

HRESULT CVTKVideoStream::FillBuffer(IMediaSample *pms)
{
BYTE *pData;
long cbData;
IReferenceClock *pClock = NULL;;
HRESULT hr = m_pFilter->GetSyncSource(&pClock);

pms->GetPointer(&pData);
cbData = pms->GetSize();
pms->SetActualDataLength(m_BitmapInfoHeader.biSizeImage);

if(m_fp && (cbData >= m_BitmapInfoHeader.biSizeImage))
{
size_t sRead = 0;
sRead = fread(pData, 1, m_BitmapInfoHeader.biSizeImage, m_fp);
}
CRefTime sampleTime = m_Starttime + m_rtFrameLength;
hr = pms->SetTime((REFERENCE_TIME *)&m_Starttime, (REFERENCE_TIME
*)&sampleTime);
//pms->SetSyncPoint(TRUE);
m_Starttime = m_Starttime + m_rtFrameLength;
return S_OK;
}
HRESULT CVTKVideoStream::DecideBufferSize(IMemAllocator *pIMemAlloc,
ALLOCATOR_PROPERTIES *pProperties)
{
VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *)m_mt.Format();
if (pProperties->cBuffers == 0)
{
pProperties->cBuffers = 1;
}
pProperties->cbBuffer = pvi->bmiHeader.biSizeImage;
ALLOCATOR_PROPERTIES Actual;
hr = pIMemAlloc->SetProperties(pProperties, &Actual);
if (FAILED(hr))
{
return hr;
}
// Is this allocator unsuitable?
if (Actual.cbBuffer < pProperties->cbBuffer)
{
return E_FAIL;
return S_OK;
}
HRESULT CVTKVideoStream::SetMediaType(const CMediaType *pMediaType)
{
HRESULT hr = CSourceStream::SetMediaType(pMediaType);
return hr;
}
// Check that we can support a given proposed type
HRESULT CVTKVideoStream::CheckMediaType(const CMediaType *pMediaType)
{
CheckPointer(pMediaType,E_POINTER);
if((*(pMediaType->Type()) != MEDIATYPE_Video) || // we only output
video
!(pMediaType->IsFixedSize())) // in fixed size
samples
{
 
 
 

Pls Help: Problem in video using YUY2 source filter

Post by Thore Karl » Wed, 21 Jul 2004 06:56:40

On 19 Jul 2004 11:54:08 -0700, XXXX@XXXXX.COM (Akhi DS



If you are connecting to the video renderer, it may present you with a
surface that is wider than you anticipate. You need to account for the
stride of the surface by checking the value of biWidth in the media type
you're connected with.

If that's not the problem, what does your graph look like?

--
New to newsgroups? Read: http://www.yqcomputer.com/