Repository navigation
Expand file tree
/
Copy pathffmpeg.patch
More file actions
239 lines (237 loc) · 9.36 KB
/
Copy pathffmpeg.patch
File metadata and controls
239 lines (237 loc) · 9.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
diff --git a/ports/ffmpeg/0008-xmaframes.patch b/ports/ffmpeg/0008-xmaframes.patch
new file mode 100644
index 0000000000..6b8f105a19
--- /dev/null
+++ b/ports/ffmpeg/0008-xmaframes.patch
@@ -0,0 +1,193 @@
+From d06b12453b9bd4b36d248af618a1569c2a2355fa Mon Sep 17 00:00:00 2001
+From: Isaac Marovitz <isaacmarovitz@proton.me>
+Date: Sat, 21 Nov 2026 17:26:18 -0500
+Subject: [PATCH] xmaframes
+
+---
+ configure | 1 +
+ libavcodec/Makefile | 1 +
+ libavcodec/allcodecs.c | 1 +
+ libavcodec/codec_desc.c | 7 ++++
+ libavcodec/codec_id.h | 2 +
+ libavcodec/wmaprodec.c | 87 +++++++++++++++++++++++++++++++++++++++++
+ 6 files changed, 99 insertions(+)
+
+diff --git a/configure b/configure
+index 1759694274..9eb8d034ec 100755
+--- a/configure
++++ b/configure
+@@ -3325,6 +3325,7 @@ wmv3_decoder_select="vc1_decoder"
+ wmv3image_decoder_select="wmv3_decoder"
+ xma1_decoder_select="wmapro_decoder"
+ xma2_decoder_select="wmapro_decoder"
++xmaframes_decoder_select="wmapro_decoder"
+ ylc_decoder_select="bswapdsp"
+ zerocodec_decoder_select="inflate_wrapper"
+ zlib_decoder_select="inflate_wrapper"
+diff --git a/libavcodec/Makefile b/libavcodec/Makefile
+index 1410bd8142..6d20e21159 100644
+--- a/libavcodec/Makefile
++++ b/libavcodec/Makefile
+@@ -873,6 +873,7 @@ OBJS-$(CONFIG_XFACE_ENCODER) += xfaceenc.o xface.o
+ OBJS-$(CONFIG_XL_DECODER) += xl.o
+ OBJS-$(CONFIG_XMA1_DECODER) += wmaprodec.o wma.o wma_common.o
+ OBJS-$(CONFIG_XMA2_DECODER) += wmaprodec.o wma.o wma_common.o
++OBJS-$(CONFIG_XMAFRAMES_DECODER) += wmaprodec.o wma.o wma_common.o
+ OBJS-$(CONFIG_XPM_DECODER) += xpmdec.o
+ OBJS-$(CONFIG_XSUB_DECODER) += xsubdec.o
+ OBJS-$(CONFIG_XSUB_ENCODER) += xsubenc.o
+diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
+index 695214f192..bdc651e883 100644
+--- a/libavcodec/allcodecs.c
++++ b/libavcodec/allcodecs.c
+@@ -564,6 +564,7 @@ extern const FFCodec ff_wmavoice_decoder;
+ extern const FFCodec ff_ws_snd1_decoder;
+ extern const FFCodec ff_xma1_decoder;
+ extern const FFCodec ff_xma2_decoder;
++extern const FFCodec ff_xmaframes_decoder;
+
+ /* PCM codecs */
+ extern const FFCodec ff_pcm_alaw_encoder;
+diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
+index a9f21f8152..b75fab58f2 100644
+--- a/libavcodec/codec_desc.c
++++ b/libavcodec/codec_desc.c
+@@ -3567,6 +3567,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
+ .long_name = NULL_IF_CONFIG_SMALL("CRI AHX"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ },
++ {
++ .id = AV_CODEC_ID_XMAFRAMES,
++ .type = AVMEDIA_TYPE_AUDIO,
++ .name = "xmaframes",
++ .long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio raw frames"),
++ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
++ },
+
+ /* subtitle codecs */
+ {
+diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
+index 6529f0a6bc..e68ede90d4 100644
+--- a/libavcodec/codec_id.h
++++ b/libavcodec/codec_id.h
+@@ -566,6 +566,8 @@ enum AVCodecID {
+ AV_CODEC_ID_LC3,
+ AV_CODEC_ID_G728,
+ AV_CODEC_ID_AHX,
++ AV_CODEC_ID_XMAFRAMES,
++
+
+ /* subtitle codecs */
+ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
+diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
+index dd33c56e54..1577b3f279 100644
+--- a/libavcodec/wmaprodec.c
++++ b/libavcodec/wmaprodec.c
+@@ -401,6 +401,11 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu
+ s->bits_per_sample = 16;
+ channel_mask = 0; /* would need to aggregate from all streams */
+ s->nb_channels = edata_ptr[8 + 20*num_stream + 17]; /* nth stream config */
++ } else if (avctx->codec_id == AV_CODEC_ID_XMAFRAMES) {
++ s->decode_flags = 0x10d6;
++ s->bits_per_sample = 16;
++ channel_mask = 0;
++ s->nb_channels = avctx->ch_layout.nb_channels;
+ } else if (avctx->codec_id == AV_CODEC_ID_WMAPRO && avctx->extradata_size >= 18) {
+ s->decode_flags = AV_RL16(edata_ptr+14);
+ channel_mask = AV_RL32(edata_ptr+2);
+@@ -2083,6 +2088,74 @@ static av_cold void xma_flush(AVCodecContext *avctx)
+ s->flushed = 0;
+ }
+
++static av_cold int xmaframes_decode_init(AVCodecContext* avctx)
++{
++ WMAProDecodeCtx *s = avctx->priv_data;
++
++ avctx->block_align = 2048;
++
++ return decode_init(s, avctx, 0);
++}
++
++static av_cold int xmaframes_decode_end(AVCodecContext* avctx)
++{
++ WMAProDecodeCtx *s = avctx->priv_data;
++
++ decode_end(s);
++
++ return 0;
++}
++
++static int xmaframes_decode_packet(AVCodecContext *avctx, AVFrame *frame,
++ int *got_frame_ptr, AVPacket *avpkt)
++{
++ WMAProDecodeCtx *s = avctx->priv_data;
++ GetBitContext* gb = &s->gb;
++ int ret, xma_frame_len = 0;
++ uint8_t padding_start, padding_end = 0;
++
++ if (avpkt->size < 3) {
++ av_log(avctx, AV_LOG_ERROR, "XMA Frame is to small, %d bytes\n", avpkt->size);
++ return AVERROR_INVALIDDATA;
++ }
++
++ s->buf_bit_size = avpkt->size << 3;
++ init_get_bits(gb, avpkt->data, s->buf_bit_size);
++
++ /** get padding sizes from first byte */
++ padding_start = get_bits(gb, 3);
++ padding_end = get_bits(gb, 3);
++ skip_bits(gb, 2);
++
++ /** move bit reader to start of xma frame */
++ skip_bits(gb, padding_start);
++
++
++ /** validate buffer size */
++ xma_frame_len = show_bits(gb, s->log2_frame_size);
++ if (s->buf_bit_size !=
++ 8 + padding_start + xma_frame_len + padding_end) {
++ av_log(avctx, AV_LOG_ERROR, "XMA Frame sizing incorrent: \n"
++ " s->buf_bit_size != (8 + padding_start + xma_frame_len + padding_end)\n"
++ "=> %d != 8 + (%d + %d + %d)\n",
++ s->buf_bit_size, padding_start, xma_frame_len, padding_end);
++ return AVERROR_INVALIDDATA;
++ }
++
++ save_bits(s, gb, xma_frame_len, 0);
++
++ /** get output buffer */
++ frame->nb_samples = s->samples_per_frame;
++ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
++ s->packet_loss = 1;
++ return 0;
++ }
++
++ decode_frame(s, frame, got_frame_ptr);
++
++ return avpkt->size;
++}
++
+ /**
+ *@brief wmapro decoder
+ */
+@@ -2127,3 +2200,17 @@ const FFCodec ff_xma2_decoder = {
+ .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ };
++
++const FFCodec ff_xmaframes_decoder = {
++ .p.name = "xmaframes",
++ CODEC_LONG_NAME("Xbox Media Audio raw frames"),
++ .p.type = AVMEDIA_TYPE_AUDIO,
++ .p.id = AV_CODEC_ID_XMAFRAMES,
++ .priv_data_size = sizeof(WMAProDecodeCtx),
++ .init = xmaframes_decode_init,
++ .close = xmaframes_decode_end,
++ FF_CODEC_DECODE_CB(xmaframes_decode_packet),
++ .flush = wmapro_flush,
++ .p.capabilities = AV_CODEC_CAP_DR1,
++ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
++};
+--
+2.54.0 (Apple Git-157)
+
diff --git a/ports/ffmpeg/portfile.cmake b/ports/ffmpeg/portfile.cmake
index fa73a16e0f..a7dea025a2 100644
--- a/ports/ffmpeg/portfile.cmake
+++ b/ports/ffmpeg/portfile.cmake
@@ -10,6 +10,7 @@ vcpkg_from_github(
0004-dependencies.patch
0005-fix-nasm.patch
0007-fix-lib-naming.patch
+ 0008-xmaframes.patch
0013-define-WINVER.patch
0024-fix-osx-host-c11.patch
0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch # Do not remove this patch. It is required by chromium
@@ -35,6 +36,13 @@ endif()
set(OPTIONS "--enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect")
+# Only enable what is used by MarathonRecomp
+string(APPEND OPTIONS " --disable-everything")
+string(APPEND OPTIONS " --enable-decoder=xmaframes,xma1,xma2,wmv3,wmav2,wmapro,theora,vorbis,h264,aac,flac,opus,mp3float,pcm_s16le,pcm_s24le,pcm_f32le")
+string(APPEND OPTIONS " --enable-demuxer=asf,ogg,mov,wav,flac,mp3")
+string(APPEND OPTIONS " --enable-parser=vorbis,h264,aac,flac,opus,mpegaudio")
+string(APPEND OPTIONS " --enable-protocol=file")
+
if(VCPKG_TARGET_IS_MINGW)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
string(APPEND OPTIONS " --target-os=mingw32")
@@ -772,6 +780,11 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
# We use response files here as the only known way to handle spaces in paths
set(crsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/cflags.rsp")
string(REGEX REPLACE "-arch [A-Za-z0-9_]+" "" VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED "${VCPKG_COMBINED_C_FLAGS_RELEASE}")
+ if(VCPKG_TARGET_IS_OSX)
+ # macosx-version-min version is set with current macOS version. So replace them to 11.0
+ string(REGEX REPLACE "-mmacosx-version-min=[0-9]+.[0-9]+" "" VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED "${VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED}")
+ string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED " -mmacosx-version-min=11.0")
+ endif()
file(WRITE "${crsp}" "${VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED}")
set(ldrsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/ldflags.rsp")
string(REGEX REPLACE "-arch [A-Za-z0-9_]+" "" VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE_SANITIZED "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}")
--
2.54.0 (Apple Git-157)