[BETA] macOS support

This commit is contained in:
wuggy 2026-04-04 15:51:31 +01:00
commit 2ab5bcf93d
32 changed files with 393 additions and 1386 deletions

View file

@ -0,0 +1,40 @@
#pragma once
/*
* Consolidated macOS ffvpx config.
*
* Include defaults first to provide 0-valued fallbacks for missing CONFIG_*
* symbols, then include generated platform config so enabled features keep
* their configured values.
*/
#include "defaults_disabled.h"
#include "config_darwin64.h"
#include "config_common.h"
/*
* UXP macOS build policy: keep ffvpx software-only for H.264 paths.
* Force these toggles off even if upstream-generated headers enable them.
*/
#undef CONFIG_H264_D3D11VA_HWACCEL
#define CONFIG_H264_D3D11VA_HWACCEL 0
#undef CONFIG_H264_DXVA2_HWACCEL
#define CONFIG_H264_DXVA2_HWACCEL 0
#undef CONFIG_H264_VAAPI_HWACCEL
#define CONFIG_H264_VAAPI_HWACCEL 0
#undef CONFIG_H264_VDA_HWACCEL
#define CONFIG_H264_VDA_HWACCEL 0
#undef CONFIG_H264_VIDEOTOOLBOX_HWACCEL
#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0
#undef CONFIG_H264_VDPAU_HWACCEL
#define CONFIG_H264_VDPAU_HWACCEL 0
#undef CONFIG_H264_VDPAU_DECODER
#define CONFIG_H264_VDPAU_DECODER 0
/* Keep transform APIs enabled because avcodec.symbols exports them. */
#undef CONFIG_DCT
#define CONFIG_DCT 1
#undef CONFIG_MDCT
#define CONFIG_MDCT 1
#undef CONFIG_RDFT
#define CONFIG_RDFT 1

View file

@ -112,3 +112,10 @@ if CONFIG['CLANG_CL']:
'-fmodules-cache-path=' + TOPOBJDIR + '/media/ffpvx',
'-fbuiltin-module-map',
]
if CONFIG['OS_TARGET'] == 'Darwin':
LOCAL_INCLUDES += [
'/media/ffvpx',
]
CFLAGS += ['-include', 'config_darwin_new.h']
CXXFLAGS += ['-include', 'config_darwin_new.h']

View file

@ -59,6 +59,20 @@
av_register_codec_parser(&ff_##x##_parser); \
}
#ifdef __APPLE__
#undef REGISTER_ENCODER
#undef REGISTER_DECODER
#undef REGISTER_ENCDEC
#undef REGISTER_HWACCEL
#undef REGISTER_PARSER
#define REGISTER_ENCODER(X, x) do { } while (0)
#define REGISTER_DECODER(X, x) do { } while (0)
#define REGISTER_ENCDEC(X, x) do { } while (0)
#define REGISTER_HWACCEL(X, x) do { } while (0)
#define REGISTER_PARSER(X, x) do { } while (0)
#endif
static void register_all(void)
{
/* hardware accelerators */

View file

@ -3,77 +3,82 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
SOURCES += [
'aacpsdsp.asm',
'aacpsdsp_init.c',
'bswapdsp.asm',
'bswapdsp_init.c',
'constants.c',
'dct32.asm',
'dct_init.c',
'fdct.c',
'fdctdsp_init.c',
'fft.asm',
'fft_init.c',
'flacdsp.asm',
'flacdsp_init.c',
'fpel.asm',
'h264_chromamc.asm',
'h264_chromamc_10bit.asm',
'h264_deblock.asm',
'h264_deblock_10bit.asm',
'h264_idct.asm',
'h264_idct_10bit.asm',
'h264_intrapred.asm',
'h264_intrapred_10bit.asm',
'h264_intrapred_init.c',
'h264_qpel.c',
'h264_qpel_10bit.asm',
'h264_qpel_8bit.asm',
'h264_weight.asm',
'h264_weight_10bit.asm',
'h264chroma_init.c',
'h264dsp_init.c',
'hevc_add_res.asm',
'hevc_deblock.asm',
'hevc_idct.asm',
'hevc_mc.asm',
'hevc_sao.asm',
'hevc_sao_10bit.asm',
'hevcdsp_init.c',
'idctdsp.asm',
'idctdsp_init.c',
'imdct36.asm',
'mdct15.asm',
'mdct15_init.c',
'me_cmp.asm',
'me_cmp_init.c',
'mpegaudiodsp.c',
'pixblockdsp.asm',
'pixblockdsp_init.c',
'qpel.asm',
'sbrdsp.asm',
'sbrdsp_init.c',
'simple_idct.asm',
'simple_idct10.asm',
'videodsp.asm',
'videodsp_init.c',
'vp8dsp.asm',
'vp8dsp_init.c',
'vp8dsp_loopfilter.asm',
'vp9dsp_init.c',
'vp9dsp_init_10bpp.c',
'vp9dsp_init_12bpp.c',
'vp9dsp_init_16bpp.c',
'vp9intrapred.asm',
'vp9intrapred_16bpp.asm',
'vp9itxfm.asm',
'vp9itxfm_16bpp.asm',
'vp9lpf.asm',
'vp9lpf_16bpp.asm',
'vp9mc.asm',
'vp9mc_16bpp.asm',
]
if CONFIG['OS_TARGET'] == 'Darwin':
SOURCES += [
'x86util_stub.c',
]
else:
SOURCES += [
'aacpsdsp.asm',
'aacpsdsp_init.c',
'bswapdsp.asm',
'bswapdsp_init.c',
'constants.c',
'dct32.asm',
'dct_init.c',
'fdct.c',
'fdctdsp_init.c',
'fft.asm',
'fft_init.c',
'flacdsp.asm',
'flacdsp_init.c',
'fpel.asm',
'h264_chromamc.asm',
'h264_chromamc_10bit.asm',
'h264_deblock.asm',
'h264_deblock_10bit.asm',
'h264_idct.asm',
'h264_idct_10bit.asm',
'h264_intrapred.asm',
'h264_intrapred_10bit.asm',
'h264_intrapred_init.c',
'h264_qpel.c',
'h264_qpel_10bit.asm',
'h264_qpel_8bit.asm',
'h264_weight.asm',
'h264_weight_10bit.asm',
'h264chroma_init.c',
'h264dsp_init.c',
'hevc_add_res.asm',
'hevc_deblock.asm',
'hevc_idct.asm',
'hevc_mc.asm',
'hevc_sao.asm',
'hevc_sao_10bit.asm',
'hevcdsp_init.c',
'idctdsp.asm',
'idctdsp_init.c',
'imdct36.asm',
'mdct15.asm',
'mdct15_init.c',
'me_cmp.asm',
'me_cmp_init.c',
'mpegaudiodsp.c',
'pixblockdsp.asm',
'pixblockdsp_init.c',
'qpel.asm',
'sbrdsp.asm',
'sbrdsp_init.c',
'simple_idct.asm',
'simple_idct10.asm',
'videodsp.asm',
'videodsp_init.c',
'vp8dsp.asm',
'vp8dsp_init.c',
'vp8dsp_loopfilter.asm',
'vp9dsp_init.c',
'vp9dsp_init_10bpp.c',
'vp9dsp_init_12bpp.c',
'vp9dsp_init_16bpp.c',
'vp9intrapred.asm',
'vp9intrapred_16bpp.asm',
'vp9itxfm.asm',
'vp9itxfm_16bpp.asm',
'vp9lpf.asm',
'vp9lpf_16bpp.asm',
'vp9mc.asm',
'vp9mc_16bpp.asm',
]
FINAL_LIBRARY = 'mozavcodec'

View file

@ -0,0 +1,37 @@
// Stub x86 init hooks for Darwin when x86 asm objects are disabled.
#include <stdint.h>
#include "libavcodec/avcodec.h"
#include "libavcodec/dct.h"
#include "libavcodec/fdctdsp.h"
#include "libavcodec/fft.h"
#include "libavcodec/idctdsp.h"
void ff_dct_init_x86(DCTContext *s) {
(void)s;
}
void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth) {
(void)c;
(void)avctx;
(void)high_bit_depth;
}
void ff_fft_init_x86(FFTContext *s) {
(void)s;
}
int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
enum idct_permutation_type perm_type) {
(void)idct_permutation;
(void)perm_type;
return 0;
}
void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth) {
(void)c;
(void)avctx;
(void)high_bit_depth;
}

View file

@ -468,6 +468,8 @@ av_xtea_init
av_xtea_le_crypt
av_xtea_le_init
avpriv_alloc_fixed_dsp
avpriv_atomic_int_add_and_fetch
avpriv_atomic_ptr_cas
avpriv_cga_font
avpriv_dict_set_timestamp
avpriv_float_dsp_alloc

View file

@ -8,9 +8,8 @@
if CONFIG['FFVPX_ASFLAGS']:
DIRS += ['x86']
# 'dummy_funcs.c',
SharedLibrary('mozavutil')
SOURCES += [
'adler32.c',
'aes.c',
@ -43,7 +42,7 @@ SOURCES += [
'hash.c',
'hmac.c',
'hwcontext.c',
'hwcontext_cuda.c',
# 'hwcontext_cuda.c', # DISABLED: macOS does not support CUDA/NVCUVID
'imgutils.c',
'integer.c',
'intmath.c',
@ -83,7 +82,7 @@ SOURCES += [
'xtea.c',
]
SYMBOLS_FILE = 'avutil.symbols'
SYMBOLS_FILE = 'avutil.symbols'
NO_VISIBILITY_FLAGS = True
OS_LIBS += CONFIG['REALTIME_LIBS']

View file

@ -75,7 +75,7 @@ typedef int x86_reg;
#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
#define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
#if ARCH_X86_64 && defined(PIC)
#if ARCH_X86_64 && (defined(PIC) || defined(__PIC__) || defined(__pic__))
# define BROKEN_RELOCATIONS 1
#endif
@ -103,7 +103,7 @@ typedef int x86_reg;
#define LABEL_MANGLE(a) EXTERN_PREFIX #a
// Use rip-relative addressing if compiling PIC code on x86-64.
#if ARCH_X86_64 && defined(PIC)
#if ARCH_X86_64 && (defined(PIC) || defined(__PIC__) || defined(__pic__))
# define LOCAL_MANGLE(a) #a "(%%rip)"
#else
# define LOCAL_MANGLE(a) #a

View file

@ -3,19 +3,24 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
SOURCES += [
'cpu.c',
'cpuid.asm',
'emms.asm',
'fixed_dsp.asm',
'fixed_dsp_init.c',
'float_dsp.asm',
'float_dsp_init.c',
'imgutils.asm',
'imgutils_init.c',
'lls.asm',
'lls_init.c'
]
if CONFIG['OS_TARGET'] == 'Darwin':
SOURCES += [
'x86util_stub.c',
]
else:
SOURCES += [
'cpu.c',
'cpuid.asm',
'emms.asm',
'fixed_dsp.asm',
'fixed_dsp_init.c',
'float_dsp.asm',
'float_dsp_init.c',
'imgutils.asm',
'imgutils_init.c',
'lls.asm',
'lls_init.c',
]
FINAL_LIBRARY = 'mozavutil'

View file

@ -0,0 +1,22 @@
// Empty stub to satisfy build system on macOS
#include <stdint.h>
// CPU flags: return 0 (no SIMD)
int ff_get_cpu_flags_x86(void) {
return 0;
}
// Fixed DSP: do nothing
void ff_fixed_dsp_init_x86(void *dsp) {
(void)dsp;
}
// Float DSP: do nothing
void ff_float_dsp_init_x86(void *fdsp) {
(void)fdsp;
}
// LLS init: do nothing
void ff_init_lls_x86(void *lls) {
(void)lls;
}