Skip to content

Commit e28dc1f

Browse files
committed
Update patchset
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
1 parent b0de1dc commit e28dc1f

1 file changed

Lines changed: 270 additions & 12 deletions

File tree

ffmpeg.patch

Lines changed: 270 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,9 @@ index e536d1a449..0c4a46bf79 100644
99
-set(OPTIONS "--enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect")
1010
+set(OPTIONS "--enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect")
1111
+
12-
+# Only enable what is used by shadPS4
12+
+# Only enable what is used by MarathonRecomp
1313
+string(APPEND OPTIONS " --disable-everything")
14-
+string(APPEND OPTIONS " --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=atrac9 --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8")
15-
+string(APPEND OPTIONS " --enable-decoder=mov --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-decoder=hevc")
16-
+string(APPEND OPTIONS " --enable-encoder=pcm_s16le")
17-
+string(APPEND OPTIONS " --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-encoder=ljpeg --enable-encoder=mjpeg")
18-
+string(APPEND OPTIONS " --enable-muxer=avi")
19-
+string(APPEND OPTIONS " --enable-demuxer=h265 --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=mov --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav")
20-
+string(APPEND OPTIONS " --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm")
21-
+string(APPEND OPTIONS " --enable-protocol=file")
22-
+string(APPEND OPTIONS " --enable-bsf=mjpeg2jpeg")
23-
+string(APPEND OPTIONS " --enable-indev=dshow")
14+
+string(APPEND OPTIONS " --enable-decoder=xmaframes")
2415

2516
if(VCPKG_TARGET_IS_MINGW)
2617
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
@@ -46,5 +37,272 @@ index e536d1a449..0c4a46bf79 100644
4637
set(ldrsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/ldflags.rsp")
4738
string(REGEX REPLACE "-arch [A-Za-z0-9_]+" "" VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE_SANITIZED "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}")
4839
--
49-
2.37.3.windows.1
5040

41+
diff --git a/configure b/configure
42+
index 63d11de207793..00756b66198f4 100755
43+
--- a/configure
44+
+++ b/configure
45+
@@ -3171,6 +3171,7 @@ wmv3_decoder_select="vc1_decoder"
46+
wmv3image_decoder_select="wmv3_decoder"
47+
xma1_decoder_select="wmapro_decoder"
48+
xma2_decoder_select="wmapro_decoder"
49+
+xmaframes_decoder_select="wmapro_decoder"
50+
ylc_decoder_select="bswapdsp"
51+
zerocodec_decoder_select="inflate_wrapper"
52+
zlib_decoder_select="inflate_wrapper"
53+
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
54+
index 215577f7c9f15..065c35c85615c 100644
55+
--- a/libavcodec/Makefile
56+
+++ b/libavcodec/Makefile
57+
@@ -851,6 +851,7 @@ OBJS-$(CONFIG_XFACE_ENCODER) += xfaceenc.o xface.o
58+
OBJS-$(CONFIG_XL_DECODER) += xl.o
59+
OBJS-$(CONFIG_XMA1_DECODER) += wmaprodec.o wma.o wma_common.o
60+
OBJS-$(CONFIG_XMA2_DECODER) += wmaprodec.o wma.o wma_common.o
61+
+OBJS-$(CONFIG_XMAFRAMES_DECODER) += wmaprodec.o wma.o wma_common.o
62+
OBJS-$(CONFIG_XPM_DECODER) += xpmdec.o
63+
OBJS-$(CONFIG_XSUB_DECODER) += xsubdec.o
64+
OBJS-$(CONFIG_XSUB_ENCODER) += xsubenc.o
65+
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
66+
index 7b01453ca28df..d8b2c499eba9b 100644
67+
--- a/libavcodec/allcodecs.c
68+
+++ b/libavcodec/allcodecs.c
69+
@@ -557,6 +557,7 @@ extern const FFCodec ff_wmavoice_decoder;
70+
extern const FFCodec ff_ws_snd1_decoder;
71+
extern const FFCodec ff_xma1_decoder;
72+
extern const FFCodec ff_xma2_decoder;
73+
+extern const FFCodec ff_xmaframes_decoder;
74+
75+
/* PCM codecs */
76+
extern const FFCodec ff_pcm_alaw_encoder;
77+
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
78+
index dae229668937d..2352168d365e5 100644
79+
--- a/libavcodec/codec_desc.c
80+
+++ b/libavcodec/codec_desc.c
81+
@@ -3298,6 +3298,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
82+
.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 2"),
83+
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
84+
},
85+
+ {
86+
+ .id = AV_CODEC_ID_XMAFRAMES,
87+
+ .type = AVMEDIA_TYPE_AUDIO,
88+
+ .name = "xmaframes",
89+
+ .long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio raw frames"),
90+
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
91+
+ },
92+
{
93+
.id = AV_CODEC_ID_DST,
94+
.type = AVMEDIA_TYPE_AUDIO,
95+
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
96+
index d00d3fe121ea0..5e492a5b65844 100644
97+
--- a/libavcodec/codec_id.h
98+
+++ b/libavcodec/codec_id.h
99+
@@ -528,6 +528,7 @@ enum AVCodecID {
100+
AV_CODEC_ID_INTERPLAY_ACM,
101+
AV_CODEC_ID_XMA1,
102+
AV_CODEC_ID_XMA2,
103+
+ AV_CODEC_ID_XMAFRAMES,
104+
AV_CODEC_ID_DST,
105+
AV_CODEC_ID_ATRAC3AL,
106+
AV_CODEC_ID_ATRAC3PAL,
107+
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
108+
index d87ed0433e19e..a2ac771b50cb3 100644
109+
--- a/libavcodec/wmaprodec.c
110+
+++ b/libavcodec/wmaprodec.c
111+
@@ -400,6 +400,11 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu
112+
s->bits_per_sample = 16;
113+
channel_mask = 0; /* would need to aggregate from all streams */
114+
s->nb_channels = edata_ptr[8 + 20*num_stream + 17]; /* nth stream config */
115+
+ } else if (avctx->codec_id == AV_CODEC_ID_XMAFRAMES) {
116+
+ s->decode_flags = 0x10d6;
117+
+ s->bits_per_sample = 16;
118+
+ channel_mask = 0;
119+
+ s->nb_channels = avctx->ch_layout.nb_channels;
120+
} else if (avctx->codec_id == AV_CODEC_ID_WMAPRO && avctx->extradata_size >= 18) {
121+
s->decode_flags = AV_RL16(edata_ptr+14);
122+
channel_mask = AV_RL32(edata_ptr+2);
123+
@@ -2082,6 +2087,82 @@ static void xma_flush(AVCodecContext *avctx)
124+
s->flushed = 0;
125+
}
126+
127+
+static av_cold int xmaframes_decode_init(AVCodecContext* avctx)
128+
+{
129+
+ WMAProDecodeCtx *s = avctx->priv_data;
130+
+
131+
+ avctx->block_align = 2048;
132+
+
133+
+ return decode_init(s, avctx, 0);
134+
+}
135+
+
136+
+static av_cold int xmaframes_decode_end(AVCodecContext* avctx)
137+
+{
138+
+ WMAProDecodeCtx *s = avctx->priv_data;
139+
+
140+
+ decode_end(s);
141+
+
142+
+ return 0;
143+
+}
144+
+
145+
+/**
146+
+ *@brief Decode a single WMA frame. Packet parsing is out of this decoders scope.
147+
+ *@param avctx codec context
148+
+ *@param data the output buffer
149+
+ *@param avpkt input packet. the data is preceeded by one byte that contains bit padding information
150+
+ *@return number of bytes that were read from the input buffer
151+
+ */
152+
+static int xmaframes_decode_packet(AVCodecContext *avctx, void *data,
153+
+ int *got_frame_ptr, AVPacket *avpkt)
154+
+{
155+
+ WMAProDecodeCtx *s = avctx->priv_data;
156+
+ GetBitContext* gb = &s->gb;
157+
+ AVFrame *frame = data;
158+
+ int ret, xma_frame_len = 0;
159+
+ uint8_t padding_start, padding_end = 0;
160+
+
161+
+ if (avpkt->size < 3) {
162+
+ av_log(avctx, AV_LOG_ERROR, "XMA Frame is to small, %d bytes\n", avpkt->size);
163+
+ return AVERROR_INVALIDDATA;
164+
+ }
165+
+
166+
+ s->buf_bit_size = avpkt->size << 3;
167+
+ init_get_bits(gb, avpkt->data, s->buf_bit_size);
168+
+
169+
+ /** get padding sizes from first byte */
170+
+ padding_start = get_bits(gb, 3);
171+
+ padding_end = get_bits(gb, 3);
172+
+ skip_bits(gb, 2);
173+
+
174+
+ /** move bit reader to start of xma frame */
175+
+ skip_bits(gb, padding_start);
176+
+
177+
+
178+
+ /** validate buffer size */
179+
+ xma_frame_len = show_bits(gb, s->log2_frame_size);
180+
+ if (s->buf_bit_size !=
181+
+ 8 + padding_start + xma_frame_len + padding_end) {
182+
+ av_log(avctx, AV_LOG_ERROR, "XMA Frame sizing incorrent: \n"
183+
+ " s->buf_bit_size != (8 + padding_start + xma_frame_len + padding_end)\n"
184+
+ "=> %d != 8 + (%d + %d + %d)\n",
185+
+ s->buf_bit_size, padding_start, xma_frame_len, padding_end);
186+
+ return AVERROR_INVALIDDATA;
187+
+ }
188+
+
189+
+ save_bits(s, gb, xma_frame_len, 0);
190+
+
191+
+ /** get output buffer */
192+
+ frame->nb_samples = s->samples_per_frame;
193+
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
194+
+ s->packet_loss = 1;
195+
+ return 0;
196+
+ }
197+
+
198+
+ decode_frame(s, data, got_frame_ptr);
199+
+
200+
+ return avpkt->size;
201+
+}
202+
+
203+
/**
204+
*@brief wmapro decoder
205+
*/
206+
@@ -2129,3 +2210,18 @@ const FFCodec ff_xma2_decoder = {
207+
CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP),
208+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
209+
};
210+
+
211+
+const FFCodec ff_xmaframes_decoder = {
212+
+ .p.name = "xmaframes",
213+
+ CODEC_LONG_NAME("Xbox Media Audio raw frames"),
214+
+ .p.type = AVMEDIA_TYPE_AUDIO,
215+
+ .p.id = AV_CODEC_ID_XMAFRAMES,
216+
+ .priv_data_size = sizeof(WMAProDecodeCtx),
217+
+ .init = xmaframes_decode_init,
218+
+ .close = xmaframes_decode_end,
219+
+ FF_CODEC_DECODE_CB(xmaframes_decode_packet),
220+
+ .flush = wmapro_flush,
221+
+ .p.capabilities = AV_CODEC_CAP_DR1,
222+
+ CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP),
223+
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
224+
+};
225+
226+
From 6bc3d67e53e91d6656a9194f7b3873da73c04883 Mon Sep 17 00:00:00 2001
227+
From: Isaac Marovitz <isaacryu@icloud.com>
228+
Date: Sun, 6 Jul 2025 13:36:28 +0100
229+
Subject: [PATCH 2/4] Fix version.c
230+
231+
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
232+
---
233+
libavcodec/version.c | 2 +-
234+
1 file changed, 1 insertion(+), 1 deletion(-)
235+
236+
diff --git a/libavcodec/version.c b/libavcodec/version.c
237+
index 8a0398f28ff3b..ba8fdac457e04 100644
238+
--- a/libavcodec/version.c
239+
+++ b/libavcodec/version.c
240+
@@ -35,7 +35,7 @@ unsigned avcodec_version(void)
241+
AV_CODEC_ID_PCM_SGA == 65572 &&
242+
AV_CODEC_ID_ADPCM_XMD == 69683 &&
243+
AV_CODEC_ID_CBD2_DPCM == 81928 &&
244+
- AV_CODEC_ID_QOA == 86121 &&
245+
+ AV_CODEC_ID_QOA == 86122 &&
246+
AV_CODEC_ID_IVTV_VBI == 94234 &&
247+
AV_CODEC_ID_SMPTE_2038 == 98315,
248+
"Don't insert new codec ids in the middle of a list");
249+
250+
From b48478c1c0766eb19a713cb771b87d8cb10d7d75 Mon Sep 17 00:00:00 2001
251+
From: Isaac Marovitz <isaacryu@icloud.com>
252+
Date: Sun, 6 Jul 2025 13:38:26 +0100
253+
Subject: [PATCH 3/4] Fix signature
254+
255+
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
256+
---
257+
libavcodec/wmaprodec.c | 10 +---------
258+
1 file changed, 1 insertion(+), 9 deletions(-)
259+
260+
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
261+
index a2ac771b50cb3..a8db563a6addc 100644
262+
--- a/libavcodec/wmaprodec.c
263+
+++ b/libavcodec/wmaprodec.c
264+
@@ -2105,19 +2105,11 @@ static av_cold int xmaframes_decode_end(AVCodecContext* avctx)
265+
return 0;
266+
}
267+
268+
-/**
269+
- *@brief Decode a single WMA frame. Packet parsing is out of this decoders scope.
270+
- *@param avctx codec context
271+
- *@param data the output buffer
272+
- *@param avpkt input packet. the data is preceeded by one byte that contains bit padding information
273+
- *@return number of bytes that were read from the input buffer
274+
- */
275+
-static int xmaframes_decode_packet(AVCodecContext *avctx, void *data,
276+
+static int xmaframes_decode_packet(AVCodecContext *avctx, AVFrame *frame,
277+
int *got_frame_ptr, AVPacket *avpkt)
278+
{
279+
WMAProDecodeCtx *s = avctx->priv_data;
280+
GetBitContext* gb = &s->gb;
281+
- AVFrame *frame = data;
282+
int ret, xma_frame_len = 0;
283+
uint8_t padding_start, padding_end = 0;
284+
285+
286+
From 706d3a4d746b03ffd05b76c869814ccb7fb50541 Mon Sep 17 00:00:00 2001
287+
From: Isaac Marovitz <isaacryu@icloud.com>
288+
Date: Sun, 6 Jul 2025 13:41:51 +0100
289+
Subject: [PATCH 4/4] Typo
290+
291+
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
292+
---
293+
libavcodec/wmaprodec.c | 2 +-
294+
1 file changed, 1 insertion(+), 1 deletion(-)
295+
296+
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
297+
index a8db563a6addc..6cd81ce5cebf1 100644
298+
--- a/libavcodec/wmaprodec.c
299+
+++ b/libavcodec/wmaprodec.c
300+
@@ -2150,7 +2150,7 @@ static int xmaframes_decode_packet(AVCodecContext *avctx, AVFrame *frame,
301+
return 0;
302+
}
303+
304+
- decode_frame(s, data, got_frame_ptr);
305+
+ decode_frame(s, frame, got_frame_ptr);
306+
307+
return avpkt->size;
308+
}

0 commit comments

Comments
 (0)