mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-22 16:25:39 +00:00
MediaCapture: Handle BGRA for MediaFoundation
This commit is contained in:
parent
422a0a0ead
commit
8ad912c340
|
@ -585,7 +585,7 @@ private:
|
||||||
Error* error);
|
Error* error);
|
||||||
bool GetAudioTypes(std::string_view codec, ComPtr<IMFMediaType>* input_type, ComPtr<IMFMediaType>* output_type,
|
bool GetAudioTypes(std::string_view codec, ComPtr<IMFMediaType>* input_type, ComPtr<IMFMediaType>* output_type,
|
||||||
u32 sample_rate, u32 bitrate, Error* error);
|
u32 sample_rate, u32 bitrate, Error* error);
|
||||||
static void ConvertVideoFrame(u8* dst, size_t dst_stride, const u8* src, size_t src_stride, u32 width, u32 height);
|
void ConvertVideoFrame(u8* dst, size_t dst_stride, const u8* src, size_t src_stride, u32 width, u32 height) const;
|
||||||
|
|
||||||
bool ProcessVideoOutputSamples(Error* error); // synchronous
|
bool ProcessVideoOutputSamples(Error* error); // synchronous
|
||||||
bool ProcessVideoEvents(Error* error); // asynchronous
|
bool ProcessVideoEvents(Error* error); // asynchronous
|
||||||
|
@ -1041,18 +1041,19 @@ MediaCaptureMF::ComPtr<IMFTransform> MediaCaptureMF::CreateVideoEncodeTransform(
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE_RELEASE void MediaCaptureMF::ConvertVideoFrame(u8* dst, size_t dst_stride, const u8* src,
|
ALWAYS_INLINE_RELEASE void MediaCaptureMF::ConvertVideoFrame(u8* dst, size_t dst_stride, const u8* src,
|
||||||
size_t src_stride, u32 width, u32 height)
|
size_t src_stride, u32 width, u32 height) const
|
||||||
{
|
{
|
||||||
// need to convert rgba -> bgra, as well as flipping vertically
|
|
||||||
const u32 vector_width = 4;
|
|
||||||
const u32 aligned_width = Common::AlignDownPow2(width, vector_width);
|
|
||||||
|
|
||||||
if (!g_gpu_device->UsesLowerLeftOrigin())
|
if (!g_gpu_device->UsesLowerLeftOrigin())
|
||||||
{
|
{
|
||||||
src += src_stride * (height - 1);
|
src += src_stride * (height - 1);
|
||||||
src_stride = static_cast<size_t>(-static_cast<std::make_signed_t<size_t>>(src_stride));
|
src_stride = static_cast<size_t>(-static_cast<std::make_signed_t<size_t>>(src_stride));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_video_render_texture_format == GPUTexture::Format::RGBA8)
|
||||||
|
{
|
||||||
|
// need to convert rgba -> bgra, as well as flipping vertically
|
||||||
|
const u32 vector_width = 4;
|
||||||
|
const u32 aligned_width = Common::AlignDownPow2(width, vector_width);
|
||||||
for (u32 remaining_rows = height;;)
|
for (u32 remaining_rows = height;;)
|
||||||
{
|
{
|
||||||
const u8* row_src = src;
|
const u8* row_src = src;
|
||||||
|
@ -1085,6 +1086,24 @@ ALWAYS_INLINE_RELEASE void MediaCaptureMF::ConvertVideoFrame(u8* dst, size_t dst
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// only flip
|
||||||
|
const u32 copy_width = sizeof(u32) * width;
|
||||||
|
for (u32 remaining_rows = height;;)
|
||||||
|
{
|
||||||
|
const u8* row_src = src;
|
||||||
|
u8* row_dst = dst;
|
||||||
|
std::memcpy(row_dst, row_src, copy_width);
|
||||||
|
src += src_stride;
|
||||||
|
dst += dst_stride;
|
||||||
|
|
||||||
|
remaining_rows--;
|
||||||
|
if (remaining_rows == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MediaCaptureMF::ClearState()
|
void MediaCaptureMF::ClearState()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue