Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Sources/Video.DirectShow/VideoCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,25 @@ static internal VideoCapabilities[] FromStreamConfig( IAMStreamConfig videoStrea
throw new NotSupportedException( "Unable to retrieve video device capabilities. This video device requires a larger VideoStreamConfigCaps structure." );

// group capabilities with similar parameters
Dictionary<uint, VideoCapabilities> videocapsList = new Dictionary<uint, VideoCapabilities>( );
Dictionary<ulong, VideoCapabilities> videocapsList = new Dictionary<ulong, VideoCapabilities>();

for ( int i = 0; i < count; i++ )
for (int i = 0; i < count; i++)
{
try
{
VideoCapabilities vc = new VideoCapabilities( videoStreamConfig, i );
VideoCapabilities vc = new VideoCapabilities(videoStreamConfig, i);

uint key = ( ( (uint) vc.FrameSize.Height ) << 32 ) |
( ( (uint) vc.FrameSize.Width ) << 16 );
ulong key = (((uint)vc.AverageFrameRate) << 48) |
(((uint)vc.FrameSize.Height) << 32) |
(((uint)vc.FrameSize.Width) << 16);

if ( !videocapsList.ContainsKey( key ) )
if (!videocapsList.ContainsKey(key))
{
videocapsList.Add( key, vc );
videocapsList.Add(key, vc);
}
else
{
if ( vc.BitCount > videocapsList[key].BitCount )
if (vc.BitCount > videocapsList[key].BitCount)
{
videocapsList[key] = vc;
}
Expand All @@ -105,6 +106,7 @@ static internal VideoCapabilities[] FromStreamConfig( IAMStreamConfig videoStrea
}
}


VideoCapabilities[] videocaps = new VideoCapabilities[videocapsList.Count];
videocapsList.Values.CopyTo( videocaps, 0 );

Expand Down