Skip to content

Commit

Permalink
DShowPlugin: Choose closest elgato res
Browse files Browse the repository at this point in the history
  • Loading branch information
jp9000 committed Oct 3, 2014
1 parent 0ef092a commit 0753749
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion DShowPlugin/DeviceSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

#include "DShowPlugin.h"

struct ResSize
{
UINT cx;
UINT cy;
};

#undef DEFINE_GUID
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID DECLSPEC_SELECTANY name \
Expand Down Expand Up @@ -691,8 +697,26 @@ bool DeviceSource::LoadFilters()

//------------------------------------------------
// change elgato resolution
if (elgato && bUseCustomResolution)
if (elgato)
{
/* choose closest matching elgato resolution */
if (!bUseCustomResolution)
{
UINT baseCX, baseCY;
UINT closest = 0xFFFFFFFF;
API->GetBaseSize(baseCX, baseCY);

const ResSize resolutions[] = {{480, 360}, {640, 480}, {1280, 720}, {1920, 1080}};
for (const ResSize &res : resolutions) {
UINT val = (UINT)labs((long)res.cy - (long)baseCY);
if (val < closest) {
elgatoCX = res.cx;
elgatoCY = res.cy;
closest = val;
}
}
}

IElgatoVideoCaptureFilter3 *elgatoFilter = nullptr;
VIDEO_CAPTURE_FILTER_SETTINGS settings;

Expand Down

0 comments on commit 0753749

Please sign in to comment.