+ if( !mt_count && p_enummt->Reset() == S_OK )
+ {
+ // VLC did not find any supported MEDIATYPE for this output pin.
+ // However the graph builder might insert converter filters in
+ // the graph if we use a different codec in VLC filter input pin.
+ // however, in order to avoid nasty surprises, make use of this
+ // facility only for known unsupported codecs.
+
+ while( !mt_count && p_enummt->Next( 1, &p_mt, NULL ) == S_OK )
+ {
+ // the first four bytes of subtype GUID contains the codec FOURCC
+ const char *pfcc = (char *)&p_mt->subtype;
+ int i_current_fourcc = VLC_FOURCC(pfcc[0], pfcc[1], pfcc[2], pfcc[3]);
+ if( VLC_FOURCC('H','C','W','2') == i_current_fourcc
+ && p_mt->majortype == MEDIATYPE_Video )
+ {
+ // output format for 'Hauppauge WinTV PVR PCI II Capture'
+ // try I420 as an input format
+ i_current_fourcc = VLC_FOURCC('I','4','2','0');
+ if( !i_fourcc || i_fourcc == i_current_fourcc )
+ {
+ // return alternative media type
+ AM_MEDIA_TYPE mtr;
+ VIDEOINFOHEADER vh;
+
+ mtr.majortype = MEDIATYPE_Video;
+ mtr.subtype = MEDIASUBTYPE_I420;
+ mtr.bFixedSizeSamples = TRUE;
+ mtr.bTemporalCompression = FALSE;
+ mtr.pUnk = NULL;
+ mtr.formattype = FORMAT_VideoInfo;
+ mtr.cbFormat = sizeof(vh);
+ mtr.pbFormat = (BYTE *)&vh;
+
+ memset(&vh, 0, sizeof(vh));
+
+ vh.bmiHeader.biSize = sizeof(vh.bmiHeader);
+ vh.bmiHeader.biWidth = i_width > 0 ? i_width :
+ ((VIDEOINFOHEADER *)p_mt->pbFormat)->bmiHeader.biWidth;
+ vh.bmiHeader.biHeight = i_height > 0 ? i_height :
+ ((VIDEOINFOHEADER *)p_mt->pbFormat)->bmiHeader.biHeight;
+ vh.bmiHeader.biPlanes = 3;
+ vh.bmiHeader.biBitCount = 12;
+ vh.bmiHeader.biCompression = VLC_FOURCC('I','4','2','0');
+ vh.bmiHeader.biSizeImage = vh.bmiHeader.biWidth * 12 *
+ vh.bmiHeader.biHeight / 8;
+ mtr.lSampleSize = vh.bmiHeader.biSizeImage;
+
+ msg_Dbg( p_this, "EnumDeviceCaps: input pin media: using 'I420' in place of unsupported format 'HCW2'");
+
+ if( SUCCEEDED(CopyMediaType(mt+mt_count, &mtr)) )
+ ++mt_count;
+ }
+ }
+ FreeMediaType( *p_mt );
+ }
+ }
+