Skip to content

Commit 8cafdec

Browse files
committed
Fix orientation
1 parent 3ca793d commit 8cafdec

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/ccap_imp_windows.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,24 @@ HRESULT STDMETHODCALLTYPE ProviderDirectShow::SampleCB(double sampleTime, IMedia
761761
// biHeight may be negative. Negative height indicates top-to-bottom orientation.
762762
// Positive height indicates bottom-to-top orientation (standard Windows DIB format).
763763
m_frameProp.height = abs(vih->bmiHeader.biHeight);
764-
if (vih->bmiHeader.biHeight < 0) {
764+
765+
// For YUV formats, always assume TopToBottom orientation regardless of biHeight
766+
// This fixes issues with some virtual cameras (like OBS) that report positive biHeight
767+
// but actually deliver TopToBottom data
768+
auto info = findPixelFormatInfo(mt.subtype);
769+
bool isYUVFormat = (info.pixelFormat & kPixelFormatYUVColorBit) != 0;
770+
771+
if (isYUVFormat) {
772+
// YUV data is typically TopToBottom, ignore biHeight sign
773+
m_inputOrientation = FrameOrientation::TopToBottom;
774+
CCAP_LOG_V("ccap: YUV format detected, using TopToBottom orientation (biHeight=%d)\n", vih->bmiHeader.biHeight);
775+
} else if (vih->bmiHeader.biHeight < 0) {
765776
m_inputOrientation = FrameOrientation::TopToBottom;
766777
} else {
767778
m_inputOrientation = FrameOrientation::BottomToTop;
768779
}
780+
769781
m_frameProp.fps = 10000000.0 / vih->AvgTimePerFrame;
770-
auto info = findPixelFormatInfo(mt.subtype);
771782
if (info.pixelFormat != PixelFormat::Unknown) {
772783
m_frameProp.cameraPixelFormat = info.pixelFormat;
773784
}

0 commit comments

Comments
 (0)