Address webcam sidecar review feedback

This commit is contained in:
EtienneLescot
2026-05-22 21:20:51 +02:00
parent ef5855f1f4
commit 10614c2950
5 changed files with 86 additions and 5 deletions
@@ -379,8 +379,11 @@ void DirectShowWebcamCapture::storeFrame(const BYTE* buffer, long length) {
}
if (width_ % 2 == 1) {
const int x = width_ - 1;
const BYTE* pair = source + (x - 1) * 2;
const auto color = yuvToBgr(pair[2], pair[1], pair[3]);
const int previousPairStart = ((x - 1) / 2) * 4;
const BYTE y = source[x * 2];
const BYTE u = source[previousPairStart + 1];
const BYTE v = source[previousPairStart + 3];
const auto color = yuvToBgr(y, u, v);
BYTE* pixel = destination + x * 4;
pixel[0] = color[0];
pixel[1] = color[1];
@@ -267,7 +267,12 @@ bool MFEncoder::copyBgraFrameToBuffer(const BgraFrameView& frame, BYTE* destinat
}
if (frame.width == width_ && frame.height == height_) {
std::memcpy(destination, frame.data, requiredBytes);
for (DWORD i = 0; i < requiredBytes; i += 4) {
destination[i] = frame.data[i];
destination[i + 1] = frame.data[i + 1];
destination[i + 2] = frame.data[i + 2];
destination[i + 3] = 255;
}
return true;
}