MediaCapture: Handle BGRA for MediaFoundation
This commit is contained in:
parent
422a0a0ead
commit
8ad912c340
|
@ -585,7 +585,7 @@ private:
|
|||
Error* error);
|
||||
bool GetAudioTypes(std::string_view codec, ComPtr<IMFMediaType>* input_type, ComPtr<IMFMediaType>* output_type,
|
||||
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 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,
|
||||
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())
|
||||
{
|
||||
src += src_stride * (height - 1);
|
||||
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;;)
|
||||
{
|
||||
const u8* row_src = src;
|
||||
|
@ -1084,6 +1085,24 @@ ALWAYS_INLINE_RELEASE void MediaCaptureMF::ConvertVideoFrame(u8* dst, size_t dst
|
|||
if (remaining_rows == 0)
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue