Discussion:
How to render NV12 format in DirectShow?
(too old to reply)
v***@gmail.com
2007-01-05 12:54:23 UTC
Permalink
Hi All,

I am working with a DirectShow transform which converts compressed
video frame into NV12 uncompressed data. I have set output pin of the
transform as MEDIATYPE_Video, MEDIASUBTYPE_NV12. However, I am not able
to connect this output pin directly to a renderer. Instead, the output
pin gets connected to AVI decompresser and then to renderer. When I
press play in GraphEdit, it crashes.

If I convert NV12 into YUV2, then I am able to render the output pin of
transform filter. But converting takes lot of time. Please let me know
if I can render NV12 format directly without such conversion.

Thanks,
Vikram

Below is the code segment I am using:
---------------------------------------------------------------
//-------------------------------------------------------------------------------------------
// GetMediaType - Returns the media type supported by the output pin.
//-------------------------------------------------------------------------------------------
HRESULT CH264TransFilter::GetMediaType(int iPosition,CMediaType
*pMediaType)
{
if (m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;

if(iPosition < 0) return E_INVALIDARG;
if(iPosition >= 1) return VFW_S_NO_MORE_ITEMS;

pMediaType->majortype = MEDIATYPE_Video;
pMediaType->subtype = MEDIASUBTYPE_NV12;

BITMAPINFOHEADER bihOut;
memset(&bihOut, 0, sizeof(bihOut));
bihOut.biSize = sizeof(bihOut);
bihOut.biWidth = m_cWidth;
bihOut.biHeight = m_cHeight;
bihOut.biPlanes = 1;
bihOut.biBitCount = BPP;
bihOut.biCompression = '2YUY';
bihOut.biSizeImage = m_cWidth*m_cHeight*1.5;

....
Iain
2007-01-05 14:12:46 UTC
Permalink
Post by v***@gmail.com
Hi All,
I am working with a DirectShow transform which converts compressed
video frame into NV12 uncompressed data. I have set output pin of the
transform as MEDIATYPE_Video, MEDIASUBTYPE_NV12. However, I am not able
to connect this output pin directly to a renderer. Instead, the output
pin gets connected to AVI decompresser and then to renderer. When I
press play in GraphEdit, it crashes.
If I convert NV12 into YUV2, then I am able to render the output pin of
transform filter. But converting takes lot of time. Please let me know
if I can render NV12 format directly without such conversion.
This depends on the the facilities of the video card. If it can support
NV12 surfaces then it will, otherwise it will need to convert.

The other thing to consider is upside-down-ness. You may be rejecting
upside down surfaces which will prevent some media types connecting.

Iain
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk
v***@gmail.com
2007-01-05 14:28:20 UTC
Permalink
Thanks for the reply, Iain
I am new when it comes to rendering in DirectShow.
Post by Iain
This depends on the the facilities of the video card. If it can support
NV12 surfaces then it will, otherwise it will need to convert.
How can I check if my video card supports NV12 surfaces?

also,
Post by Iain
The other thing to consider is upside-down-ness. You may be rejecting
upside down surfaces which will prevent some media types connecting.
I am not sure about this upside-down-ness.

Any hint regarding these will be very helpful.

Regards,
Vikram
Post by Iain
Post by v***@gmail.com
Hi All,
I am working with a DirectShow transform which converts compressed
video frame into NV12 uncompressed data. I have set output pin of the
transform as MEDIATYPE_Video, MEDIASUBTYPE_NV12. However, I am not able
to connect this output pin directly to a renderer. Instead, the output
pin gets connected to AVI decompresser and then to renderer. When I
press play in GraphEdit, it crashes.
If I convert NV12 into YUV2, then I am able to render the output pin of
transform filter. But converting takes lot of time. Please let me know
if I can render NV12 format directly without such conversion.
This depends on the the facilities of the video card. If it can support
NV12 surfaces then it will, otherwise it will need to convert.
The other thing to consider is upside-down-ness. You may be rejecting
upside down surfaces which will prevent some media types connecting.
Iain
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk
Iain
2007-01-05 16:00:42 UTC
Permalink
Post by v***@gmail.com
Thanks for the reply, Iain
I am new when it comes to rendering in DirectShow.
Post by Iain
This depends on the the facilities of the video card. If it can support
NV12 surfaces then it will, otherwise it will need to convert.
How can I check if my video card supports NV12 surfaces?
I think I mentioned DxDiag (comes with DirectX sdk and *may* come with the
run time)
Post by v***@gmail.com
also,
Post by Iain
The other thing to consider is upside-down-ness. You may be rejecting
upside down surfaces which will prevent some media types connecting.
I am not sure about this upside-down-ness.
Any hint regarding these will be very helpful.
See 'Handling format changes from the video renderer' in the docs


Iain
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk
Loading...