Fixed camera frame acquisition on Windows 7
Fixes https://github.com/libsdl-org/SDL/issues/12210
This commit is contained in:
@@ -600,23 +600,18 @@ static SDL_CameraFrameResult MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SD
|
|||||||
IMF2DBuffer2_Unlock2D(buffer2d2);
|
IMF2DBuffer2_Unlock2D(buffer2d2);
|
||||||
}
|
}
|
||||||
IMF2DBuffer2_Release(buffer2d2);
|
IMF2DBuffer2_Release(buffer2d2);
|
||||||
} else if (SUCCEEDED(IMFMediaBuffer_QueryInterface(buffer, &SDL_IID_IMF2DBuffer, (void **)&buffer2d))) {
|
} else if (frame->format != SDL_PIXELFORMAT_MJPG &&
|
||||||
|
SUCCEEDED(IMFMediaBuffer_QueryInterface(buffer, &SDL_IID_IMF2DBuffer, (void **)&buffer2d))) {
|
||||||
ret = IMF2DBuffer_Lock2D(buffer2d, &pixels, &pitch);
|
ret = IMF2DBuffer_Lock2D(buffer2d, &pixels, &pitch);
|
||||||
if (FAILED(ret)) {
|
if (FAILED(ret)) {
|
||||||
result = SDL_CAMERA_FRAME_ERROR;
|
result = SDL_CAMERA_FRAME_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (frame->format == SDL_PIXELFORMAT_MJPG) {
|
BYTE *bufstart = pixels;
|
||||||
// FIXME: How big is this frame?
|
const DWORD buflen = SDL_abs((int)pitch) * frame->h;
|
||||||
const DWORD buflen = 0;
|
if (pitch < 0) { // image rows are reversed.
|
||||||
result = MEDIAFOUNDATION_CopyFrame(frame, pixels, pitch, buflen);
|
bufstart += -pitch * (frame->h - 1);
|
||||||
} else {
|
|
||||||
BYTE *bufstart = pixels;
|
|
||||||
const DWORD buflen = (SDL_abs((int)pitch) * frame->w) * frame->h;
|
|
||||||
if (pitch < 0) { // image rows are reversed.
|
|
||||||
bufstart += -pitch * (frame->h - 1);
|
|
||||||
}
|
|
||||||
result = MEDIAFOUNDATION_CopyFrame(frame, bufstart, pitch, buflen);
|
|
||||||
}
|
}
|
||||||
|
result = MEDIAFOUNDATION_CopyFrame(frame, bufstart, pitch, buflen);
|
||||||
IMF2DBuffer_Unlock2D(buffer2d);
|
IMF2DBuffer_Unlock2D(buffer2d);
|
||||||
}
|
}
|
||||||
IMF2DBuffer_Release(buffer2d);
|
IMF2DBuffer_Release(buffer2d);
|
||||||
|
|||||||
Reference in New Issue
Block a user