public void TestGetNumberOfDeinterlaceModes()
        {
            int hr       = 0;
            int numModes = 0;

            videoDesc = GetVideoDesc7();

            hr = deinterlaceControl.GetNumberOfDeinterlaceModes(ref videoDesc, ref numModes, null);
            DsError.ThrowExceptionForHR(hr);

            deinterlaceModes = new Guid[numModes];

            hr = deinterlaceControl.GetNumberOfDeinterlaceModes(ref videoDesc, ref numModes, deinterlaceModes);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(hr == 0, "IVMRDeinterlaceControl.GetNumberOfDeinterlaceModes");
        }
        // this method is an implementation of the procedure describe in this page :
        // http://msdn.microsoft.com/library/en-us/directshow/htm/settingdeinterlacepreferences.asp?frame=true
        private VMRVideoDesc GetVideoDesc7()
        {
            int          hr        = 0;
            AMMediaType  mediaType = new AMMediaType();
            VMRVideoDesc vDesc     = new VMRVideoDesc();

            vDesc.dwSize = Marshal.SizeOf(typeof(VMRVideoDesc));

            IPin pinIn = DsFindPin.ByDirection(vmr, PinDirection.Input, 0);

            hr = pinIn.ConnectionMediaType(mediaType);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(pinIn);

            if (mediaType.formatType == FormatType.VideoInfo2)
            {
                VideoInfoHeader2 videoHeader = (VideoInfoHeader2)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader2));
                if ((videoHeader.InterlaceFlags & AMInterlace.IsInterlaced) != 0)
                {
                    vDesc.dwSampleWidth        = videoHeader.BmiHeader.Width;
                    vDesc.dwSampleHeight       = videoHeader.BmiHeader.Height;
                    vDesc.SingleFieldPerSample = ((videoHeader.InterlaceFlags & AMInterlace.OneFieldPerSample) != 0);
                    vDesc.dwFourCC             = videoHeader.BmiHeader.Compression;

                    switch (videoHeader.AvgTimePerFrame)
                    {
                    case 166833:
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 60000;
                        vDesc.InputSampleFreq.dwDenominator = 1001;
                        break;
                    }

                    case 333667:
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 30000;
                        vDesc.InputSampleFreq.dwDenominator = 1001;
                        break;
                    }

                    case 333666: // this value is not define in the paper but is returned by testme.iso
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 30000;
                        vDesc.InputSampleFreq.dwDenominator = 1001;
                        break;
                    }

                    case 417188:
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 24000;
                        vDesc.InputSampleFreq.dwDenominator = 1001;
                        break;
                    }

                    case 200000:
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 50;
                        vDesc.InputSampleFreq.dwDenominator = 1;
                        break;
                    }

                    case 400000:
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 25;
                        vDesc.InputSampleFreq.dwDenominator = 1;
                        break;
                    }

                    case 416667:
                    {
                        vDesc.InputSampleFreq.dwNumerator   = 24;
                        vDesc.InputSampleFreq.dwDenominator = 1;
                        break;
                    }

                    default:
                    {
                        throw new ApplicationException("Unknown AvgTimePerFrame : " + videoHeader.AvgTimePerFrame);
                    }
                    }

                    // Video is interleaved
                    vDesc.OutputFrameFreq.dwNumerator   = vDesc.InputSampleFreq.dwNumerator * 2;
                    vDesc.OutputFrameFreq.dwDenominator = vDesc.InputSampleFreq.dwDenominator;
                }
                else
                {
                    throw new ApplicationException("Only interlaced formats");
                }
            }
            else
            {
                throw new ApplicationException("Only VIDEOINFOHEADER2 formats can be interlaced");
            }

            DsUtils.FreeAMMediaType(mediaType);
            return(vDesc);
        }