mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibMedia: Port to Windows
This commit is contained in:
parent
f143a9b971
commit
49c5c0bb8a
Notes:
github-actions[bot]
2025-02-11 11:08:27 +00:00
Author: https://github.com/stasoid Commit: https://github.com/LadybirdBrowser/ladybird/commit/49c5c0bb8a3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2959 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/R-Goc
2 changed files with 15 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
include(audio)
|
||||
|
||||
if (NOT ANDROID AND NOT WIN32)
|
||||
if (NOT ANDROID)
|
||||
include(ffmpeg)
|
||||
endif()
|
||||
|
||||
|
@ -20,7 +20,7 @@ set(SOURCES
|
|||
serenity_lib(LibMedia media)
|
||||
target_link_libraries(LibMedia PRIVATE LibCore LibCrypto LibRIFF LibIPC LibGfx LibThreading LibUnicode)
|
||||
|
||||
if (NOT ANDROID AND NOT WIN32)
|
||||
if (NOT ANDROID)
|
||||
target_sources(LibMedia PRIVATE
|
||||
Audio/FFmpegLoader.cpp
|
||||
FFmpeg/FFmpegVideoDecoder.cpp
|
||||
|
|
|
@ -10,6 +10,13 @@
|
|||
|
||||
#include "VideoFrame.h"
|
||||
|
||||
#ifdef AK_OS_WINDOWS
|
||||
# define aligned_alloc(alignment, size) _aligned_malloc(size, alignment)
|
||||
# define aligned_free _aligned_free
|
||||
#else
|
||||
# define aligned_free free
|
||||
#endif
|
||||
|
||||
namespace Media {
|
||||
|
||||
ErrorOr<NonnullOwnPtr<SubsampledYUVFrame>> SubsampledYUVFrame::try_create(
|
||||
|
@ -23,10 +30,9 @@ ErrorOr<NonnullOwnPtr<SubsampledYUVFrame>> SubsampledYUVFrame::try_create(
|
|||
size_t alignment_size = max(bit_depth > 8 ? sizeof(u16) : sizeof(u8), sizeof(void*));
|
||||
|
||||
auto alloc_buffer = [&](size_t size) -> ErrorOr<u8*> {
|
||||
void* buffer = nullptr;
|
||||
auto result = posix_memalign(&buffer, alignment_size, size);
|
||||
if (result != 0)
|
||||
return Error::from_errno(result);
|
||||
void* buffer = aligned_alloc(alignment_size, round_up_to_power_of_two(size, alignment_size));
|
||||
if (!buffer)
|
||||
return Error::from_errno(ENOMEM);
|
||||
return reinterpret_cast<u8*>(buffer);
|
||||
};
|
||||
|
||||
|
@ -64,9 +70,9 @@ ErrorOr<NonnullOwnPtr<SubsampledYUVFrame>> SubsampledYUVFrame::try_create_from_d
|
|||
|
||||
SubsampledYUVFrame::~SubsampledYUVFrame()
|
||||
{
|
||||
free(m_y_buffer);
|
||||
free(m_u_buffer);
|
||||
free(m_v_buffer);
|
||||
aligned_free(m_y_buffer);
|
||||
aligned_free(m_u_buffer);
|
||||
aligned_free(m_v_buffer);
|
||||
}
|
||||
|
||||
template<u32 subsampling_horizontal, typename T>
|
||||
|
|
Loading…
Add table
Reference in a new issue