Added
Link Here
|
1 |
diff -urN cmake/modules/FindFFMPEG.cmake.orig cmake/modules/FindFFMPEG.cmake |
2 |
--- cmake/modules/FindFFMPEG.cmake.orig 2023-03-11 22:16:38.000000000 +0000 |
3 |
+++ cmake/modules/FindFFMPEG.cmake 2023-03-16 21:56:53.268867000 +0000 |
4 |
@@ -151,14 +151,14 @@ |
5 |
set(REQUIRED_FFMPEG_VERSION undef) |
6 |
else() |
7 |
# required ffmpeg library versions |
8 |
- set(REQUIRED_FFMPEG_VERSION 4.4.1) |
9 |
- set(_avcodec_ver ">=58.134.100") |
10 |
- set(_avfilter_ver ">=7.110.100") |
11 |
- set(_avformat_ver ">=58.76.100") |
12 |
- set(_avutil_ver ">=56.70.100") |
13 |
- set(_postproc_ver ">=55.9.100") |
14 |
- set(_swresample_ver ">=3.9.100") |
15 |
- set(_swscale_ver ">=5.9.100") |
16 |
+ set(REQUIRED_FFMPEG_VERSION 6.0.0) |
17 |
+ set(_avcodec_ver ">=60.2.100") |
18 |
+ set(_avfilter_ver ">=9.3.100") |
19 |
+ set(_avformat_ver ">=60.3.100") |
20 |
+ set(_avutil_ver ">=58.2.100") |
21 |
+ set(_postproc_ver ">=57.1.100") |
22 |
+ set(_swresample_ver ">=4.10.100") |
23 |
+ set(_swscale_ver ">=7.1.100") |
24 |
endif() |
25 |
|
26 |
# Allows building with external ffmpeg not found in system paths, |
27 |
diff -urN tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch.orig tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch |
28 |
--- tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch.orig 2023-03-11 22:16:38.000000000 +0000 |
29 |
+++ tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch 2023-03-16 21:56:20.716741000 +0000 |
30 |
@@ -11,7 +11,7 @@ |
31 |
index d7a3f507e8..4b85e881b1 100755 |
32 |
--- a/configure |
33 |
+++ b/configure |
34 |
-@@ -6530,6 +6530,8 @@ enabled openssl && { check_pkg_config openssl openssl openssl/ssl.h OP |
35 |
+@@ -6728,6 +6728,8 @@ enabled openssl && { check_pkg_config openssl openssl openssl/ssl.h OP |
36 |
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto || |
37 |
check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 || |
38 |
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || |
39 |
diff -urN tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch.orig tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch |
40 |
--- tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch.orig 2023-03-11 22:16:38.000000000 +0000 |
41 |
+++ tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch 2023-03-16 21:56:20.716863000 +0000 |
42 |
@@ -11,16 +11,16 @@ |
43 |
index 4b85e881b1..da457705d1 100755 |
44 |
--- a/configure |
45 |
+++ b/configure |
46 |
-@@ -7627,6 +7627,9 @@ print_config CONFIG_ "$config_files" $CONFIG_LIST \ |
47 |
+@@ -7825,6 +7825,9 @@ print_config CONFIG_ "$config_files" $CONFIG_LIST \ |
48 |
+ print_config CONFIG_ "$config_files" $CONFIG_LIST \ |
49 |
$CONFIG_EXTRA \ |
50 |
- $ALL_COMPONENTS \ |
51 |
|
52 |
+echo "#if defined(HAVE_UNISTD_H) && HAVE_UNISTD_H == 0" >> $TMPH |
53 |
+echo "#undef HAVE_UNISTD_H" >> $TMPH |
54 |
+echo "#endif" >> $TMPH |
55 |
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH |
56 |
- echo "endif # FFMPEG_CONFIG_MAK" >> ffbuild/config.mak |
57 |
|
58 |
+ # Do not overwrite an unchanged config.h to avoid superfluous rebuilds. |
59 |
-- |
60 |
2.29.2 |
61 |
|
62 |
diff -urN tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch.orig tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch |
63 |
--- tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch.orig 2023-03-11 22:16:38.000000000 +0000 |
64 |
+++ tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch 2023-03-16 21:56:20.716987000 +0000 |
65 |
@@ -11,7 +11,7 @@ |
66 |
index da457705d1..e3a8f45ff4 100755 |
67 |
--- a/configure |
68 |
+++ b/configure |
69 |
-@@ -5440,6 +5440,8 @@ case $target_os in |
70 |
+@@ -5566,6 +5566,8 @@ case $target_os in |
71 |
enabled shared && ! enabled small && test_cmd $windres --version && enable gnu_windres |
72 |
enabled x86_32 && check_ldflags -Wl,--large-address-aware |
73 |
shlibdir_default="$bindir_default" |
74 |
@@ -20,7 +20,7 @@ |
75 |
SLIBPREF="" |
76 |
SLIBSUF=".dll" |
77 |
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' |
78 |
-@@ -5489,6 +5491,8 @@ case $target_os in |
79 |
+@@ -5615,6 +5617,8 @@ case $target_os in |
80 |
fi |
81 |
enabled x86_32 && check_ldflags -LARGEADDRESSAWARE |
82 |
shlibdir_default="$bindir_default" |
83 |
diff -urN tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch.orig tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch |
84 |
--- tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch.orig 2023-03-11 22:16:38.000000000 +0000 |
85 |
+++ tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch 2023-03-16 21:56:20.717110000 +0000 |
86 |
@@ -11,7 +11,7 @@ |
87 |
index e3a8f45ff4..983d7e1078 100755 |
88 |
--- a/configure |
89 |
+++ b/configure |
90 |
-@@ -6358,7 +6358,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && |
91 |
+@@ -6541,7 +6541,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && |
92 |
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } |
93 |
enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas |
94 |
enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2 |
95 |
diff -urN tools/depends/target/ffmpeg/CMakeLists.txt.orig tools/depends/target/ffmpeg/CMakeLists.txt |
96 |
--- tools/depends/target/ffmpeg/CMakeLists.txt.orig 2023-03-11 22:16:38.000000000 +0000 |
97 |
+++ tools/depends/target/ffmpeg/CMakeLists.txt 2023-03-16 21:56:20.716595000 +0000 |
98 |
@@ -92,6 +92,7 @@ |
99 |
elseif(CORE_SYSTEM_NAME STREQUAL darwin_embedded) |
100 |
list(APPEND ffmpeg_conf --disable-crystalhd |
101 |
--enable-videotoolbox |
102 |
+ --disable-filter=yadif_videotoolbox |
103 |
--target-os=darwin |
104 |
) |
105 |
elseif(CORE_SYSTEM_NAME STREQUAL osx) |
106 |
diff -urN tools/depends/target/ffmpeg/FFMPEG-VERSION.orig tools/depends/target/ffmpeg/FFMPEG-VERSION |
107 |
--- tools/depends/target/ffmpeg/FFMPEG-VERSION.orig 2023-03-11 22:16:38.000000000 +0000 |
108 |
+++ tools/depends/target/ffmpeg/FFMPEG-VERSION 2023-03-16 22:05:45.344450000 +0000 |
109 |
@@ -1,5 +1,5 @@ |
110 |
LIBNAME=ffmpeg |
111 |
-BASE_URL=https://github.com/xbmc/FFmpeg |
112 |
-VERSION=4.4.1-Nexus-Alpha1 |
113 |
+VERSION=6.0 |
114 |
ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz |
115 |
-SHA512=8beb04d577b5251e74b0d52f4d130997a8ba94bbd488c7c8309e6b45095c27807e150212888ce3a384b23dff52f8df1a7bde5407bae924ddc363f8125c0616c5 |
116 |
+SHA512=b3214328f2792364353f38c6b46a71d4970c071d8656b20780abf0e02950167d0933eae825c09102cf8fb19fc679ac444bf1f41a448b624eaa5ea6b0f0bdf4f5 |
117 |
+ |
118 |
diff -urN xbmc/cdrip/EncoderFFmpeg.cpp.orig xbmc/cdrip/EncoderFFmpeg.cpp |
119 |
--- xbmc/cdrip/EncoderFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
120 |
+++ xbmc/cdrip/EncoderFFmpeg.cpp 2023-03-16 21:56:20.710403000 +0000 |
121 |
@@ -11,6 +11,7 @@ |
122 |
#include "ServiceBroker.h" |
123 |
#include "addons/Addon.h" |
124 |
#include "addons/AddonManager.h" |
125 |
+#include "cores/FFmpeg.h" |
126 |
#include "settings/Settings.h" |
127 |
#include "settings/SettingsComponent.h" |
128 |
#include "utils/StringUtils.h" |
129 |
@@ -19,24 +20,9 @@ |
130 |
#include "utils/log.h" |
131 |
|
132 |
using namespace KODI::CDRIP; |
133 |
+using FFMPEG_HELP_TOOLS::FFMpegErrorToString; |
134 |
+using FFMPEG_HELP_TOOLS::FFMpegException; |
135 |
|
136 |
-namespace |
137 |
-{ |
138 |
- |
139 |
-struct EncoderException : public std::exception |
140 |
-{ |
141 |
- std::string s; |
142 |
- template<typename... Args> |
143 |
- EncoderException(const std::string& fmt, Args&&... args) |
144 |
- : s(StringUtils::Format(fmt, std::forward<Args>(args)...)) |
145 |
- { |
146 |
- } |
147 |
- ~EncoderException() throw() {} // Updated |
148 |
- const char* what() const throw() { return s.c_str(); } |
149 |
-}; |
150 |
- |
151 |
-} /* namespace */ |
152 |
- |
153 |
bool CEncoderFFmpeg::Init() |
154 |
{ |
155 |
try |
156 |
@@ -54,7 +40,7 @@ |
157 |
} |
158 |
else |
159 |
{ |
160 |
- throw EncoderException("Could not get add-on: {}", addonId); |
161 |
+ throw FFMpegException("Could not get add-on: {}", addonId); |
162 |
} |
163 |
|
164 |
// Hack fix about PTS on generated files. |
165 |
@@ -66,50 +52,50 @@ |
166 |
else if (addonId == "audioencoder.kodi.builtin.wma") |
167 |
m_samplesCountMultiply = 1000; |
168 |
else |
169 |
- throw EncoderException("Internal add-on id \"{}\" not known as usable", addonId); |
170 |
+ throw FFMpegException("Internal add-on id \"{}\" not known as usable", addonId); |
171 |
|
172 |
const std::string filename = URIUtils::GetFileName(m_strFile); |
173 |
|
174 |
m_formatCtx = avformat_alloc_context(); |
175 |
if (!m_formatCtx) |
176 |
- throw EncoderException("Could not allocate output format context"); |
177 |
+ throw FFMpegException("Could not allocate output format context"); |
178 |
|
179 |
m_bcBuffer = static_cast<uint8_t*>(av_malloc(BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE)); |
180 |
if (!m_bcBuffer) |
181 |
- throw EncoderException("Could not allocate buffer"); |
182 |
+ throw FFMpegException("Could not allocate buffer"); |
183 |
|
184 |
m_formatCtx->pb = avio_alloc_context(m_bcBuffer, BUFFER_SIZE, AVIO_FLAG_WRITE, this, nullptr, |
185 |
avio_write_callback, avio_seek_callback); |
186 |
if (!m_formatCtx->pb) |
187 |
- throw EncoderException("Failed to allocate ByteIOContext"); |
188 |
+ throw FFMpegException("Failed to allocate ByteIOContext"); |
189 |
|
190 |
/* Guess the desired container format based on the file extension. */ |
191 |
m_formatCtx->oformat = av_guess_format(nullptr, filename.c_str(), nullptr); |
192 |
if (!m_formatCtx->oformat) |
193 |
- throw EncoderException("Could not find output file format"); |
194 |
+ throw FFMpegException("Could not find output file format"); |
195 |
|
196 |
m_formatCtx->url = av_strdup(filename.c_str()); |
197 |
if (!m_formatCtx->url) |
198 |
- throw EncoderException("Could not allocate url"); |
199 |
+ throw FFMpegException("Could not allocate url"); |
200 |
|
201 |
/* Find the encoder to be used by its name. */ |
202 |
- AVCodec* codec = avcodec_find_encoder(m_formatCtx->oformat->audio_codec); |
203 |
+ const AVCodec* codec = avcodec_find_encoder(m_formatCtx->oformat->audio_codec); |
204 |
if (!codec) |
205 |
- throw EncoderException("Unable to find a suitable FFmpeg encoder"); |
206 |
+ throw FFMpegException("Unable to find a suitable FFmpeg encoder"); |
207 |
|
208 |
/* Create a new audio stream in the output file container. */ |
209 |
m_stream = avformat_new_stream(m_formatCtx, nullptr); |
210 |
if (!m_stream) |
211 |
- throw EncoderException("Failed to allocate AVStream context"); |
212 |
+ throw FFMpegException("Failed to allocate AVStream context"); |
213 |
|
214 |
m_codecCtx = avcodec_alloc_context3(codec); |
215 |
if (!m_codecCtx) |
216 |
- throw EncoderException("Failed to allocate the encoder context"); |
217 |
+ throw FFMpegException("Failed to allocate the encoder context"); |
218 |
|
219 |
/* Set the basic encoder parameters. |
220 |
* The input file's sample rate is used to avoid a sample rate conversion. */ |
221 |
- m_codecCtx->channels = m_iInChannels; |
222 |
- m_codecCtx->channel_layout = av_get_default_channel_layout(m_iInChannels); |
223 |
+ av_channel_layout_uninit(&m_codecCtx->ch_layout); |
224 |
+ av_channel_layout_default(&m_codecCtx->ch_layout, m_iInChannels); |
225 |
m_codecCtx->sample_rate = m_iInSampleRate; |
226 |
m_codecCtx->sample_fmt = codec->sample_fmts[0]; |
227 |
m_codecCtx->bit_rate = bitrate; |
228 |
@@ -128,14 +114,14 @@ |
229 |
|
230 |
int err = avcodec_open2(m_codecCtx, codec, nullptr); |
231 |
if (err < 0) |
232 |
- throw EncoderException("Failed to open the codec {} (error '{}')", |
233 |
- codec->long_name ? codec->long_name : codec->name, |
234 |
- FFmpegErrorToString(err)); |
235 |
+ throw FFMpegException("Failed to open the codec {} (error '{}')", |
236 |
+ codec->long_name ? codec->long_name : codec->name, |
237 |
+ FFMpegErrorToString(err)); |
238 |
|
239 |
err = avcodec_parameters_from_context(m_stream->codecpar, m_codecCtx); |
240 |
if (err < 0) |
241 |
- throw EncoderException("Failed to copy encoder parameters to output stream (error '{}')", |
242 |
- FFmpegErrorToString(err)); |
243 |
+ throw FFMpegException("Failed to copy encoder parameters to output stream (error '{}')", |
244 |
+ FFMpegErrorToString(err)); |
245 |
|
246 |
m_inFormat = GetInputFormat(m_iInBitsPerSample); |
247 |
m_outFormat = m_codecCtx->sample_fmt; |
248 |
@@ -150,44 +136,48 @@ |
249 |
|
250 |
m_bufferFrame = av_frame_alloc(); |
251 |
if (!m_bufferFrame || !m_buffer) |
252 |
- throw EncoderException("Failed to allocate necessary buffers"); |
253 |
+ throw FFMpegException("Failed to allocate necessary buffers"); |
254 |
|
255 |
m_bufferFrame->nb_samples = m_codecCtx->frame_size; |
256 |
m_bufferFrame->format = m_inFormat; |
257 |
- m_bufferFrame->channel_layout = m_codecCtx->channel_layout; |
258 |
+ |
259 |
+ av_channel_layout_uninit(&m_bufferFrame->ch_layout); |
260 |
+ av_channel_layout_copy(&m_bufferFrame->ch_layout, &m_codecCtx->ch_layout); |
261 |
+ |
262 |
m_bufferFrame->sample_rate = m_codecCtx->sample_rate; |
263 |
|
264 |
err = av_frame_get_buffer(m_bufferFrame, 0); |
265 |
if (err < 0) |
266 |
- throw EncoderException("Could not allocate output frame samples (error '{}')", |
267 |
- FFmpegErrorToString(err)); |
268 |
+ throw FFMpegException("Could not allocate output frame samples (error '{}')", |
269 |
+ FFMpegErrorToString(err)); |
270 |
|
271 |
avcodec_fill_audio_frame(m_bufferFrame, m_iInChannels, m_inFormat, m_buffer, m_neededBytes, 0); |
272 |
|
273 |
if (m_needConversion) |
274 |
{ |
275 |
- m_swrCtx = swr_alloc_set_opts(nullptr, m_codecCtx->channel_layout, m_outFormat, |
276 |
- m_codecCtx->sample_rate, m_codecCtx->channel_layout, m_inFormat, |
277 |
+ int ret = swr_alloc_set_opts2(&m_swrCtx, &m_codecCtx->ch_layout, m_outFormat, |
278 |
+ m_codecCtx->sample_rate, &m_codecCtx->ch_layout, m_inFormat, |
279 |
m_codecCtx->sample_rate, 0, nullptr); |
280 |
- if (!m_swrCtx || swr_init(m_swrCtx) < 0) |
281 |
- throw EncoderException("Failed to initialize the resampler"); |
282 |
+ if (ret || swr_init(m_swrCtx) < 0) |
283 |
+ throw FFMpegException("Failed to initialize the resampler"); |
284 |
|
285 |
m_resampledBufferSize = |
286 |
av_samples_get_buffer_size(nullptr, m_iInChannels, m_neededFrames, m_outFormat, 0); |
287 |
m_resampledBuffer = static_cast<uint8_t*>(av_malloc(m_resampledBufferSize)); |
288 |
m_resampledFrame = av_frame_alloc(); |
289 |
if (!m_resampledBuffer || !m_resampledFrame) |
290 |
- throw EncoderException("Failed to allocate a frame for resampling"); |
291 |
+ throw FFMpegException("Failed to allocate a frame for resampling"); |
292 |
|
293 |
m_resampledFrame->nb_samples = m_neededFrames; |
294 |
m_resampledFrame->format = m_outFormat; |
295 |
- m_resampledFrame->channel_layout = m_codecCtx->channel_layout; |
296 |
+ av_channel_layout_uninit(&m_resampledFrame->ch_layout); |
297 |
+ av_channel_layout_copy(&m_resampledFrame->ch_layout, &m_codecCtx->ch_layout); |
298 |
m_resampledFrame->sample_rate = m_codecCtx->sample_rate; |
299 |
|
300 |
err = av_frame_get_buffer(m_resampledFrame, 0); |
301 |
if (err < 0) |
302 |
- throw EncoderException("Could not allocate output resample frame samples (error '{}')", |
303 |
- FFmpegErrorToString(err)); |
304 |
+ throw FFMpegException("Could not allocate output resample frame samples (error '{}')", |
305 |
+ FFMpegErrorToString(err)); |
306 |
|
307 |
avcodec_fill_audio_frame(m_resampledFrame, m_iInChannels, m_outFormat, m_resampledBuffer, |
308 |
m_resampledBufferSize, 0); |
309 |
@@ -204,7 +194,7 @@ |
310 |
/* write the header */ |
311 |
err = avformat_write_header(m_formatCtx, nullptr); |
312 |
if (err != 0) |
313 |
- throw EncoderException("Failed to write the header (error '{}')", FFmpegErrorToString(err)); |
314 |
+ throw FFMpegException("Failed to write the header (error '{}')", FFMpegErrorToString(err)); |
315 |
|
316 |
CLog::Log(LOGDEBUG, "CEncoderFFmpeg::{} - Successfully initialized with muxer {} and codec {}", |
317 |
__func__, |
318 |
@@ -212,16 +202,19 @@ |
319 |
: m_formatCtx->oformat->name, |
320 |
codec->long_name ? codec->long_name : codec->name); |
321 |
} |
322 |
- catch (EncoderException& caught) |
323 |
+ catch (const FFMpegException& caught) |
324 |
{ |
325 |
CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what()); |
326 |
|
327 |
av_freep(&m_buffer); |
328 |
+ av_channel_layout_uninit(&m_bufferFrame->ch_layout); |
329 |
av_frame_free(&m_bufferFrame); |
330 |
swr_free(&m_swrCtx); |
331 |
+ av_channel_layout_uninit(&m_resampledFrame->ch_layout); |
332 |
av_frame_free(&m_resampledFrame); |
333 |
av_freep(&m_resampledBuffer); |
334 |
av_free(m_bcBuffer); |
335 |
+ av_channel_layout_uninit(&m_codecCtx->ch_layout); |
336 |
avcodec_free_context(&m_codecCtx); |
337 |
if (m_formatCtx) |
338 |
{ |
339 |
@@ -299,7 +292,7 @@ |
340 |
if (swr_convert(m_swrCtx, m_resampledFrame->data, m_neededFrames, |
341 |
const_cast<const uint8_t**>(m_bufferFrame->extended_data), |
342 |
m_neededFrames) < 0) |
343 |
- throw EncoderException("Error resampling audio"); |
344 |
+ throw FFMpegException("Error resampling audio"); |
345 |
|
346 |
frame = m_resampledFrame; |
347 |
} |
348 |
@@ -316,8 +309,8 @@ |
349 |
m_bufferSize = 0; |
350 |
err = avcodec_send_frame(m_codecCtx, frame); |
351 |
if (err < 0) |
352 |
- throw EncoderException("Error sending a frame for encoding (error '{}')", __func__, |
353 |
- FFmpegErrorToString(err)); |
354 |
+ throw FFMpegException("Error sending a frame for encoding (error '{}')", |
355 |
+ FFMpegErrorToString(err)); |
356 |
|
357 |
while (err >= 0) |
358 |
{ |
359 |
@@ -329,19 +322,18 @@ |
360 |
} |
361 |
else if (err < 0) |
362 |
{ |
363 |
- throw EncoderException("Error during encoding (error '{}')", __func__, |
364 |
- FFmpegErrorToString(err)); |
365 |
+ throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err)); |
366 |
} |
367 |
|
368 |
err = av_write_frame(m_formatCtx, pkt); |
369 |
if (err < 0) |
370 |
- throw EncoderException("Failed to write the frame data (error '{}')", __func__, |
371 |
- FFmpegErrorToString(err)); |
372 |
+ throw FFMpegException("Failed to write the frame data (error '{}')", |
373 |
+ FFMpegErrorToString(err)); |
374 |
|
375 |
av_packet_unref(pkt); |
376 |
} |
377 |
} |
378 |
- catch (EncoderException& caught) |
379 |
+ catch (const FFMpegException& caught) |
380 |
{ |
381 |
CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what()); |
382 |
} |
383 |
@@ -366,8 +358,10 @@ |
384 |
|
385 |
/* Flush if needed */ |
386 |
av_freep(&m_buffer); |
387 |
+ av_channel_layout_uninit(&m_bufferFrame->ch_layout); |
388 |
av_frame_free(&m_bufferFrame); |
389 |
swr_free(&m_swrCtx); |
390 |
+ av_channel_layout_uninit(&m_resampledFrame->ch_layout); |
391 |
av_frame_free(&m_resampledFrame); |
392 |
av_freep(&m_resampledBuffer); |
393 |
m_needConversion = false; |
394 |
@@ -379,6 +373,7 @@ |
395 |
|
396 |
/* cleanup */ |
397 |
av_free(m_bcBuffer); |
398 |
+ av_channel_layout_uninit(&m_codecCtx->ch_layout); |
399 |
avcodec_free_context(&m_codecCtx); |
400 |
av_freep(&m_formatCtx->pb); |
401 |
avformat_free_context(m_formatCtx); |
402 |
@@ -400,14 +395,6 @@ |
403 |
case 32: |
404 |
return AV_SAMPLE_FMT_S32; |
405 |
default: |
406 |
- throw EncoderException("Invalid input bits per sample"); |
407 |
+ throw FFMpegException("Invalid input bits per sample"); |
408 |
} |
409 |
-} |
410 |
- |
411 |
-std::string CEncoderFFmpeg::FFmpegErrorToString(int err) |
412 |
-{ |
413 |
- std::string text; |
414 |
- text.reserve(AV_ERROR_MAX_STRING_SIZE); |
415 |
- av_strerror(err, text.data(), AV_ERROR_MAX_STRING_SIZE); |
416 |
- return text; |
417 |
} |
418 |
diff -urN xbmc/cdrip/EncoderFFmpeg.h.orig xbmc/cdrip/EncoderFFmpeg.h |
419 |
--- xbmc/cdrip/EncoderFFmpeg.h.orig 2023-03-11 22:16:38.000000000 +0000 |
420 |
+++ xbmc/cdrip/EncoderFFmpeg.h 2023-03-16 21:56:20.696794000 +0000 |
421 |
@@ -39,7 +39,6 @@ |
422 |
void SetTag(const std::string& tag, const std::string& value); |
423 |
bool WriteFrame(); |
424 |
AVSampleFormat GetInputFormat(int inBitsPerSample); |
425 |
- std::string FFmpegErrorToString(int err); |
426 |
|
427 |
AVFormatContext* m_formatCtx{nullptr}; |
428 |
AVCodecContext* m_codecCtx{nullptr}; |
429 |
diff -urN xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp.orig xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp |
430 |
--- xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
431 |
+++ xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp 2023-03-16 21:56:20.710706000 +0000 |
432 |
@@ -10,14 +10,25 @@ |
433 |
#define DTS_ENCODE_BITRATE 1411200 |
434 |
|
435 |
#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h" |
436 |
-#include "cores/AudioEngine/Utils/AEUtil.h" |
437 |
+ |
438 |
#include "ServiceBroker.h" |
439 |
-#include "utils/log.h" |
440 |
+#include "cores/AudioEngine/Utils/AEUtil.h" |
441 |
+#include "cores/FFmpeg.h" |
442 |
#include "settings/Settings.h" |
443 |
#include "settings/SettingsComponent.h" |
444 |
-#include <string.h> |
445 |
+#include "utils/log.h" |
446 |
+ |
447 |
+extern "C" |
448 |
+{ |
449 |
+#include <libavutil/channel_layout.h> |
450 |
+} |
451 |
+ |
452 |
#include <cassert> |
453 |
+#include <string.h> |
454 |
|
455 |
+using FFMPEG_HELP_TOOLS::FFMpegErrorToString; |
456 |
+using FFMPEG_HELP_TOOLS::FFMpegException; |
457 |
+ |
458 |
CAEEncoderFFmpeg::CAEEncoderFFmpeg() : m_CodecCtx(NULL), m_SwrCtx(NULL) |
459 |
{ |
460 |
} |
461 |
@@ -26,6 +37,7 @@ |
462 |
{ |
463 |
Reset(); |
464 |
swr_free(&m_SwrCtx); |
465 |
+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); |
466 |
avcodec_free_context(&m_CodecCtx); |
467 |
} |
468 |
|
469 |
@@ -81,7 +93,7 @@ |
470 |
|
471 |
bool ac3 = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_AUDIOOUTPUT_AC3PASSTHROUGH); |
472 |
|
473 |
- AVCodec *codec = NULL; |
474 |
+ const AVCodec* codec = nullptr; |
475 |
|
476 |
/* fallback to ac3 if we support it, we might not have DTS support */ |
477 |
if (ac3) |
478 |
@@ -102,7 +114,8 @@ |
479 |
|
480 |
m_CodecCtx->bit_rate = m_BitRate; |
481 |
m_CodecCtx->sample_rate = format.m_sampleRate; |
482 |
- m_CodecCtx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK; |
483 |
+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); |
484 |
+ av_channel_layout_from_mask(&m_CodecCtx->ch_layout, AV_CH_LAYOUT_5POINT1_BACK); |
485 |
|
486 |
/* select a suitable data format */ |
487 |
if (codec->sample_fmts) |
488 |
@@ -179,22 +192,28 @@ |
489 |
LOGERROR, |
490 |
"CAEEncoderFFmpeg::Initialize - Unable to find a suitable data format for the codec ({})", |
491 |
m_CodecName); |
492 |
+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); |
493 |
avcodec_free_context(&m_CodecCtx); |
494 |
return false; |
495 |
} |
496 |
} |
497 |
|
498 |
- m_CodecCtx->channels = BuildChannelLayout(m_CodecCtx->channel_layout, m_Layout); |
499 |
+ uint64_t mask = m_CodecCtx->ch_layout.u.mask; |
500 |
+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); |
501 |
+ av_channel_layout_from_mask(&m_CodecCtx->ch_layout, mask); |
502 |
+ m_CodecCtx->ch_layout.nb_channels = BuildChannelLayout(mask, m_Layout); |
503 |
|
504 |
/* open the codec */ |
505 |
if (avcodec_open2(m_CodecCtx, codec, NULL)) |
506 |
{ |
507 |
+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); |
508 |
avcodec_free_context(&m_CodecCtx); |
509 |
return false; |
510 |
} |
511 |
|
512 |
format.m_frames = m_CodecCtx->frame_size; |
513 |
- format.m_frameSize = m_CodecCtx->channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3); |
514 |
+ int channels = m_CodecCtx->ch_layout.nb_channels; |
515 |
+ format.m_frameSize = channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3); |
516 |
format.m_channelLayout = m_Layout; |
517 |
|
518 |
m_CurrentFormat = format; |
519 |
@@ -204,14 +223,14 @@ |
520 |
|
521 |
if (m_NeedConversion) |
522 |
{ |
523 |
- m_SwrCtx = swr_alloc_set_opts(NULL, |
524 |
- m_CodecCtx->channel_layout, m_CodecCtx->sample_fmt, m_CodecCtx->sample_rate, |
525 |
- m_CodecCtx->channel_layout, AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate, |
526 |
- 0, NULL); |
527 |
- if (!m_SwrCtx || swr_init(m_SwrCtx) < 0) |
528 |
+ int ret = swr_alloc_set_opts2(&m_SwrCtx, &m_CodecCtx->ch_layout, m_CodecCtx->sample_fmt, |
529 |
+ m_CodecCtx->sample_rate, &m_CodecCtx->ch_layout, |
530 |
+ AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate, 0, NULL); |
531 |
+ if (ret || swr_init(m_SwrCtx) < 0) |
532 |
{ |
533 |
CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Initialize - Failed to initialise resampler."); |
534 |
swr_free(&m_SwrCtx); |
535 |
+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); |
536 |
avcodec_free_context(&m_CodecCtx); |
537 |
return false; |
538 |
} |
539 |
@@ -242,62 +261,78 @@ |
540 |
|
541 |
int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_size) |
542 |
{ |
543 |
- int got_output; |
544 |
- AVFrame *frame; |
545 |
+ int size = 0; |
546 |
+ int err = AVERROR_UNKNOWN; |
547 |
+ AVFrame* frame = nullptr; |
548 |
+ AVPacket* pkt = nullptr; |
549 |
|
550 |
if (!m_CodecCtx) |
551 |
- return 0; |
552 |
+ return size; |
553 |
|
554 |
- /* allocate the input frame |
555 |
- * sadly, we have to alloc/dealloc it everytime since we have no guarantee the |
556 |
- * data argument will be constant over iterated calls and the frame needs to |
557 |
- * setup pointers inside data */ |
558 |
- frame = av_frame_alloc(); |
559 |
- if (!frame) |
560 |
- return 0; |
561 |
+ try |
562 |
+ { |
563 |
+ /* allocate the input frame and output packet |
564 |
+ * sadly, we have to alloc/dealloc it everytime since we have no guarantee the |
565 |
+ * data argument will be constant over iterated calls and the frame needs to |
566 |
+ * setup pointers inside data */ |
567 |
+ frame = av_frame_alloc(); |
568 |
+ pkt = av_packet_alloc(); |
569 |
+ if (!frame || !pkt) |
570 |
+ throw FFMpegException( |
571 |
+ "Failed to allocate \"AVFrame\" or \"AVPacket\" for encoding (error '{}')", |
572 |
+ strerror(errno)); |
573 |
|
574 |
- frame->nb_samples = m_CodecCtx->frame_size; |
575 |
- frame->format = m_CodecCtx->sample_fmt; |
576 |
- frame->channel_layout = m_CodecCtx->channel_layout; |
577 |
- frame->channels = m_CodecCtx->channels; |
578 |
+ frame->nb_samples = m_CodecCtx->frame_size; |
579 |
+ frame->format = m_CodecCtx->sample_fmt; |
580 |
+ av_channel_layout_uninit(&frame->ch_layout); |
581 |
+ av_channel_layout_copy(&frame->ch_layout, &m_CodecCtx->ch_layout); |
582 |
+ int channelNum = m_CodecCtx->ch_layout.nb_channels; |
583 |
|
584 |
- avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, |
585 |
- in, in_size, 0); |
586 |
+ avcodec_fill_audio_frame(frame, channelNum, m_CodecCtx->sample_fmt, in, in_size, 0); |
587 |
|
588 |
- /* initialize the output packet */ |
589 |
- AVPacket* pkt = av_packet_alloc(); |
590 |
- if (!pkt) |
591 |
- { |
592 |
- CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - av_packet_alloc failed: {}", __FUNCTION__, |
593 |
- strerror(errno)); |
594 |
- av_frame_free(&frame); |
595 |
- return 0; |
596 |
- } |
597 |
+ pkt->size = out_size; |
598 |
+ pkt->data = out; |
599 |
|
600 |
- pkt->size = out_size; |
601 |
- pkt->data = out; |
602 |
+ /* encode it */ |
603 |
+ err = avcodec_send_frame(m_CodecCtx, frame); |
604 |
+ if (err < 0) |
605 |
+ throw FFMpegException("Error sending a frame for encoding (error '{}')", |
606 |
+ FFMpegErrorToString(err)); |
607 |
|
608 |
- /* encode it */ |
609 |
- int ret = avcodec_encode_audio2(m_CodecCtx, pkt, frame, &got_output); |
610 |
+ while (err >= 0) |
611 |
+ { |
612 |
+ err = avcodec_receive_packet(m_CodecCtx, pkt); |
613 |
+ if (err == AVERROR(EAGAIN) || err == AVERROR_EOF) |
614 |
+ { |
615 |
+ av_channel_layout_uninit(&frame->ch_layout); |
616 |
+ av_frame_free(&frame); |
617 |
+ av_packet_free(&pkt); |
618 |
+ return (err == AVERROR(EAGAIN)) ? -1 : 0; |
619 |
+ } |
620 |
+ else if (err < 0) |
621 |
+ { |
622 |
+ throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err)); |
623 |
+ } |
624 |
|
625 |
- int size = pkt->size; |
626 |
+ av_packet_unref(pkt); |
627 |
+ } |
628 |
|
629 |
+ size = pkt->size; |
630 |
+ } |
631 |
+ catch (const FFMpegException& caught) |
632 |
+ { |
633 |
+ CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - {}", __func__, caught.what()); |
634 |
+ } |
635 |
+ |
636 |
/* free temporary data */ |
637 |
av_frame_free(&frame); |
638 |
|
639 |
/* free the packet */ |
640 |
av_packet_free(&pkt); |
641 |
|
642 |
- if (ret < 0 || !got_output) |
643 |
- { |
644 |
- CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Encode - Encoding failed"); |
645 |
- return 0; |
646 |
- } |
647 |
- |
648 |
/* return the number of frames used */ |
649 |
return size; |
650 |
} |
651 |
- |
652 |
|
653 |
int CAEEncoderFFmpeg::GetData(uint8_t **data) |
654 |
{ |
655 |
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp |
656 |
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
657 |
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp 2023-03-16 21:56:20.711552000 +0000 |
658 |
@@ -16,17 +16,16 @@ |
659 |
#include "ActiveAESound.h" |
660 |
#include "ActiveAEStream.h" |
661 |
#include "ServiceBroker.h" |
662 |
+#include "cores/AudioEngine/AEResampleFactory.h" |
663 |
+#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h" |
664 |
#include "cores/AudioEngine/Interfaces/IAudioCallback.h" |
665 |
-#include "cores/AudioEngine/Utils/AEUtil.h" |
666 |
#include "cores/AudioEngine/Utils/AEStreamData.h" |
667 |
#include "cores/AudioEngine/Utils/AEStreamInfo.h" |
668 |
-#include "cores/AudioEngine/AEResampleFactory.h" |
669 |
-#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h" |
670 |
- |
671 |
+#include "cores/AudioEngine/Utils/AEUtil.h" |
672 |
#include "settings/Settings.h" |
673 |
#include "settings/SettingsComponent.h" |
674 |
-#include "windowing/WinSystem.h" |
675 |
#include "utils/log.h" |
676 |
+#include "windowing/WinSystem.h" |
677 |
|
678 |
using namespace std::chrono_literals; |
679 |
|
680 |
@@ -3043,8 +3042,8 @@ |
681 |
AVFormatContext *fmt_ctx = nullptr; |
682 |
AVCodecContext *dec_ctx = nullptr; |
683 |
AVIOContext *io_ctx; |
684 |
- AVInputFormat *io_fmt = nullptr; |
685 |
- AVCodec *dec = nullptr; |
686 |
+ const AVInputFormat* io_fmt = nullptr; |
687 |
+ const AVCodec* dec = nullptr; |
688 |
SampleConfig config; |
689 |
|
690 |
// No custom deleter until sound is registered |
691 |
@@ -3096,8 +3095,8 @@ |
692 |
AVCodecID codecId = fmt_ctx->streams[0]->codecpar->codec_id; |
693 |
dec = avcodec_find_decoder(codecId); |
694 |
config.sample_rate = fmt_ctx->streams[0]->codecpar->sample_rate; |
695 |
- config.channels = fmt_ctx->streams[0]->codecpar->channels; |
696 |
- config.channel_layout = fmt_ctx->streams[0]->codecpar->channel_layout; |
697 |
+ config.channels = fmt_ctx->streams[0]->codecpar->ch_layout.nb_channels; |
698 |
+ config.channel_layout = fmt_ctx->streams[0]->codecpar->ch_layout.u.mask; |
699 |
} |
700 |
} |
701 |
if (dec == nullptr) |
702 |
@@ -3113,10 +3112,14 @@ |
703 |
|
704 |
dec_ctx = avcodec_alloc_context3(dec); |
705 |
dec_ctx->sample_rate = config.sample_rate; |
706 |
- dec_ctx->channels = config.channels; |
707 |
+ AVChannelLayout layout = {}; |
708 |
if (!config.channel_layout) |
709 |
- config.channel_layout = av_get_default_channel_layout(config.channels); |
710 |
- dec_ctx->channel_layout = config.channel_layout; |
711 |
+ av_channel_layout_default(&layout, config.channels); |
712 |
+ else |
713 |
+ av_channel_layout_from_mask(&layout, config.channel_layout); |
714 |
+ config.channel_layout = layout.u.mask; |
715 |
+ av_channel_layout_copy(&dec_ctx->ch_layout, &layout); |
716 |
+ av_channel_layout_uninit(&layout); |
717 |
|
718 |
AVPacket* avpkt = av_packet_alloc(); |
719 |
if (!avpkt) |
720 |
@@ -3183,6 +3186,7 @@ |
721 |
|
722 |
av_packet_free(&avpkt); |
723 |
av_frame_free(&decoded_frame); |
724 |
+ av_channel_layout_uninit(&dec_ctx->ch_layout); |
725 |
avcodec_free_context(&dec_ctx); |
726 |
avformat_close_input(&fmt_ctx); |
727 |
if (io_ctx) |
728 |
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp |
729 |
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
730 |
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp 2023-03-16 21:56:20.711812000 +0000 |
731 |
@@ -12,8 +12,8 @@ |
732 |
#include <algorithm> |
733 |
|
734 |
extern "C" { |
735 |
-#include <libavfilter/avfilter.h> |
736 |
#include <libavcodec/avcodec.h> |
737 |
+#include <libavfilter/avfilter.h> |
738 |
#include <libavfilter/buffersink.h> |
739 |
#include <libavfilter/buffersrc.h> |
740 |
#include <libswresample/swresample.h> |
741 |
@@ -171,7 +171,10 @@ |
742 |
} |
743 |
|
744 |
if (m_pOutFrame) |
745 |
+ { |
746 |
+ av_channel_layout_uninit(&m_pOutFrame->ch_layout); |
747 |
av_frame_free(&m_pOutFrame); |
748 |
+ } |
749 |
|
750 |
if (m_pConvertFrame) |
751 |
av_frame_free(&m_pConvertFrame); |
752 |
@@ -205,10 +208,9 @@ |
753 |
if (!frame) |
754 |
return -1; |
755 |
|
756 |
- int channels = av_get_channel_layout_nb_channels(m_channelLayout); |
757 |
- |
758 |
- frame->channel_layout = m_channelLayout; |
759 |
- frame->channels = channels; |
760 |
+ av_channel_layout_uninit(&frame->ch_layout); |
761 |
+ av_channel_layout_from_mask(&frame->ch_layout, m_channelLayout); |
762 |
+ int channels = frame->ch_layout.nb_channels; |
763 |
frame->sample_rate = m_sampleRate; |
764 |
frame->nb_samples = src_samples; |
765 |
frame->format = m_sampleFormat; |
766 |
@@ -224,6 +226,7 @@ |
767 |
src_buffer[0], src_bufsize, 16); |
768 |
if (result < 0) |
769 |
{ |
770 |
+ av_channel_layout_uninit(&frame->ch_layout); |
771 |
av_frame_free(&frame); |
772 |
CLog::Log(LOGERROR, "CActiveAEFilter::ProcessFilter - avcodec_fill_audio_frame failed"); |
773 |
m_filterEof = true; |
774 |
@@ -231,6 +234,7 @@ |
775 |
} |
776 |
|
777 |
result = av_buffersrc_write_frame(m_pFilterCtxIn, frame); |
778 |
+ av_channel_layout_uninit(&frame->ch_layout); |
779 |
av_frame_free(&frame); |
780 |
if (result < 0) |
781 |
{ |
782 |
@@ -284,7 +288,8 @@ |
783 |
{ |
784 |
av_frame_unref(m_pOutFrame); |
785 |
m_pOutFrame->format = m_sampleFormat; |
786 |
- m_pOutFrame->channel_layout = m_channelLayout; |
787 |
+ av_channel_layout_uninit(&m_pOutFrame->ch_layout); |
788 |
+ av_channel_layout_from_mask(&m_pOutFrame->ch_layout, m_channelLayout); |
789 |
m_pOutFrame->sample_rate = m_sampleRate; |
790 |
result = swr_convert_frame(m_pConvertCtx, m_pOutFrame, m_pConvertFrame); |
791 |
av_frame_unref(m_pConvertFrame); |
792 |
@@ -302,7 +307,10 @@ |
793 |
|
794 |
if (m_hasData) |
795 |
{ |
796 |
- int channels = av_get_channel_layout_nb_channels(m_channelLayout); |
797 |
+ AVChannelLayout layout = {}; |
798 |
+ av_channel_layout_from_mask(&layout, m_channelLayout); |
799 |
+ int channels = layout.nb_channels; |
800 |
+ av_channel_layout_uninit(&layout); |
801 |
int planes = av_sample_fmt_is_planar(m_sampleFormat) ? channels : 1; |
802 |
int samples = std::min(dst_samples, m_pOutFrame->nb_samples - m_sampleOffset); |
803 |
int bytes = samples * av_get_bytes_per_sample(m_sampleFormat) * channels / planes; |
804 |
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp |
805 |
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
806 |
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp 2023-03-16 21:56:20.712034000 +0000 |
807 |
@@ -49,15 +49,30 @@ |
808 |
m_doesResample = true; |
809 |
|
810 |
if (m_dst_chan_layout == 0) |
811 |
- m_dst_chan_layout = av_get_default_channel_layout(m_dst_channels); |
812 |
+ { |
813 |
+ AVChannelLayout layout = {}; |
814 |
+ av_channel_layout_default(&layout, m_dst_channels); |
815 |
+ m_dst_chan_layout = layout.u.mask; |
816 |
+ av_channel_layout_uninit(&layout); |
817 |
+ } |
818 |
if (m_src_chan_layout == 0) |
819 |
- m_src_chan_layout = av_get_default_channel_layout(m_src_channels); |
820 |
+ { |
821 |
+ AVChannelLayout layout = {}; |
822 |
+ av_channel_layout_default(&layout, m_src_channels); |
823 |
+ m_src_chan_layout = layout.u.mask; |
824 |
+ av_channel_layout_uninit(&layout); |
825 |
+ } |
826 |
|
827 |
- m_pContext = swr_alloc_set_opts(NULL, m_dst_chan_layout, m_dst_fmt, m_dst_rate, |
828 |
- m_src_chan_layout, m_src_fmt, m_src_rate, |
829 |
- 0, NULL); |
830 |
+ AVChannelLayout dstChLayout = {}; |
831 |
+ AVChannelLayout srcChLayout = {}; |
832 |
|
833 |
- if (!m_pContext) |
834 |
+ av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout); |
835 |
+ av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout); |
836 |
+ |
837 |
+ int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt, m_dst_rate, &srcChLayout, |
838 |
+ m_src_fmt, m_src_rate, 0, NULL); |
839 |
+ |
840 |
+ if (ret) |
841 |
{ |
842 |
CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context failed"); |
843 |
return false; |
844 |
@@ -126,10 +141,12 @@ |
845 |
else if (upmix && m_src_channels == 2 && m_dst_channels > 2) |
846 |
{ |
847 |
memset(m_rematrix, 0, sizeof(m_rematrix)); |
848 |
+ av_channel_layout_uninit(&dstChLayout); |
849 |
+ av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout); |
850 |
for (int out=0; out<m_dst_channels; out++) |
851 |
{ |
852 |
- uint64_t out_chan = av_channel_layout_extract_channel(m_dst_chan_layout, out); |
853 |
- switch(out_chan) |
854 |
+ AVChannel outChan = av_channel_layout_channel_from_index(&dstChLayout, out); |
855 |
+ switch (outChan) |
856 |
{ |
857 |
case AV_CH_FRONT_LEFT: |
858 |
case AV_CH_BACK_LEFT: |
859 |
@@ -153,6 +170,8 @@ |
860 |
break; |
861 |
} |
862 |
} |
863 |
+ |
864 |
+ av_channel_layout_uninit(&dstChLayout); |
865 |
|
866 |
if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0) |
867 |
{ |
868 |
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp |
869 |
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
870 |
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp 2023-03-16 21:56:20.705902000 +0000 |
871 |
@@ -88,7 +88,7 @@ |
872 |
for(unsigned int i=0; i<m_format.m_channelLayout.Count(); i++) |
873 |
{ |
874 |
avLast = avCur; |
875 |
- avCur = CAEUtil::GetAVChannel(m_format.m_channelLayout[i]); |
876 |
+ avCur = CAEUtil::GetAVChannelMask(m_format.m_channelLayout[i]); |
877 |
if(avCur < avLast) |
878 |
{ |
879 |
needRemap = true; |
880 |
diff -urN xbmc/cores/AudioEngine/Utils/AEUtil.cpp.orig xbmc/cores/AudioEngine/Utils/AEUtil.cpp |
881 |
--- xbmc/cores/AudioEngine/Utils/AEUtil.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
882 |
+++ xbmc/cores/AudioEngine/Utils/AEUtil.cpp 2023-03-16 21:56:20.712279000 +0000 |
883 |
@@ -19,10 +19,6 @@ |
884 |
#include <xmmintrin.h> |
885 |
#endif |
886 |
|
887 |
-extern "C" { |
888 |
-#include <libavutil/channel_layout.h> |
889 |
-} |
890 |
- |
891 |
void AEDelayStatus::SetDelay(double d) |
892 |
{ |
893 |
delay = d; |
894 |
@@ -550,34 +546,64 @@ |
895 |
} |
896 |
} |
897 |
|
898 |
-uint64_t CAEUtil::GetAVChannel(enum AEChannel aechannel) |
899 |
+uint64_t CAEUtil::GetAVChannelMask(enum AEChannel aechannel) |
900 |
{ |
901 |
+ enum AVChannel ch = GetAVChannel(aechannel); |
902 |
+ if (ch == AV_CHAN_NONE) |
903 |
+ return 0; |
904 |
+ return (1ULL << ch); |
905 |
+} |
906 |
+ |
907 |
+enum AVChannel CAEUtil::GetAVChannel(enum AEChannel aechannel) |
908 |
+{ |
909 |
switch (aechannel) |
910 |
{ |
911 |
- case AE_CH_FL: return AV_CH_FRONT_LEFT; |
912 |
- case AE_CH_FR: return AV_CH_FRONT_RIGHT; |
913 |
- case AE_CH_FC: return AV_CH_FRONT_CENTER; |
914 |
- case AE_CH_LFE: return AV_CH_LOW_FREQUENCY; |
915 |
- case AE_CH_BL: return AV_CH_BACK_LEFT; |
916 |
- case AE_CH_BR: return AV_CH_BACK_RIGHT; |
917 |
- case AE_CH_FLOC: return AV_CH_FRONT_LEFT_OF_CENTER; |
918 |
- case AE_CH_FROC: return AV_CH_FRONT_RIGHT_OF_CENTER; |
919 |
- case AE_CH_BC: return AV_CH_BACK_CENTER; |
920 |
- case AE_CH_SL: return AV_CH_SIDE_LEFT; |
921 |
- case AE_CH_SR: return AV_CH_SIDE_RIGHT; |
922 |
- case AE_CH_TC: return AV_CH_TOP_CENTER; |
923 |
- case AE_CH_TFL: return AV_CH_TOP_FRONT_LEFT; |
924 |
- case AE_CH_TFC: return AV_CH_TOP_FRONT_CENTER; |
925 |
- case AE_CH_TFR: return AV_CH_TOP_FRONT_RIGHT; |
926 |
- case AE_CH_TBL: return AV_CH_TOP_BACK_LEFT; |
927 |
- case AE_CH_TBC: return AV_CH_TOP_BACK_CENTER; |
928 |
- case AE_CH_TBR: return AV_CH_TOP_BACK_RIGHT; |
929 |
- default: |
930 |
- return 0; |
931 |
+ case AE_CH_FL: |
932 |
+ return AV_CHAN_FRONT_LEFT; |
933 |
+ case AE_CH_FR: |
934 |
+ return AV_CHAN_FRONT_RIGHT; |
935 |
+ case AE_CH_FC: |
936 |
+ return AV_CHAN_FRONT_CENTER; |
937 |
+ case AE_CH_LFE: |
938 |
+ return AV_CHAN_LOW_FREQUENCY; |
939 |
+ case AE_CH_BL: |
940 |
+ return AV_CHAN_BACK_LEFT; |
941 |
+ case AE_CH_BR: |
942 |
+ return AV_CHAN_BACK_RIGHT; |
943 |
+ case AE_CH_FLOC: |
944 |
+ return AV_CHAN_FRONT_LEFT_OF_CENTER; |
945 |
+ case AE_CH_FROC: |
946 |
+ return AV_CHAN_FRONT_RIGHT_OF_CENTER; |
947 |
+ case AE_CH_BC: |
948 |
+ return AV_CHAN_BACK_CENTER; |
949 |
+ case AE_CH_SL: |
950 |
+ return AV_CHAN_SIDE_LEFT; |
951 |
+ case AE_CH_SR: |
952 |
+ return AV_CHAN_SIDE_RIGHT; |
953 |
+ case AE_CH_TC: |
954 |
+ return AV_CHAN_TOP_CENTER; |
955 |
+ case AE_CH_TFL: |
956 |
+ return AV_CHAN_TOP_FRONT_LEFT; |
957 |
+ case AE_CH_TFC: |
958 |
+ return AV_CHAN_TOP_FRONT_CENTER; |
959 |
+ case AE_CH_TFR: |
960 |
+ return AV_CHAN_TOP_FRONT_RIGHT; |
961 |
+ case AE_CH_TBL: |
962 |
+ return AV_CHAN_TOP_BACK_LEFT; |
963 |
+ case AE_CH_TBC: |
964 |
+ return AV_CHAN_TOP_BACK_CENTER; |
965 |
+ case AE_CH_TBR: |
966 |
+ return AV_CHAN_TOP_BACK_RIGHT; |
967 |
+ default: |
968 |
+ return AV_CHAN_NONE; |
969 |
} |
970 |
} |
971 |
|
972 |
int CAEUtil::GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout) |
973 |
{ |
974 |
- return av_get_channel_layout_channel_index(layout, GetAVChannel(aechannel)); |
975 |
+ AVChannelLayout ch_layout = {}; |
976 |
+ av_channel_layout_from_mask(&ch_layout, layout); |
977 |
+ int idx = av_channel_layout_index_from_channel(&ch_layout, GetAVChannel(aechannel)); |
978 |
+ av_channel_layout_uninit(&ch_layout); |
979 |
+ return idx; |
980 |
} |
981 |
diff -urN xbmc/cores/AudioEngine/Utils/AEUtil.h.orig xbmc/cores/AudioEngine/Utils/AEUtil.h |
982 |
--- xbmc/cores/AudioEngine/Utils/AEUtil.h.orig 2023-03-11 22:16:38.000000000 +0000 |
983 |
+++ xbmc/cores/AudioEngine/Utils/AEUtil.h 2023-03-16 21:56:20.712441000 +0000 |
984 |
@@ -13,6 +13,7 @@ |
985 |
#include <math.h> |
986 |
|
987 |
extern "C" { |
988 |
+#include <libavutil/channel_layout.h> |
989 |
#include <libavutil/samplefmt.h> |
990 |
} |
991 |
|
992 |
@@ -171,6 +172,7 @@ |
993 |
static uint64_t GetAVChannelLayout(const CAEChannelInfo &info); |
994 |
static CAEChannelInfo GetAEChannelLayout(uint64_t layout); |
995 |
static AVSampleFormat GetAVSampleFormat(AEDataFormat format); |
996 |
- static uint64_t GetAVChannel(enum AEChannel aechannel); |
997 |
+ static uint64_t GetAVChannelMask(enum AEChannel aechannel); |
998 |
+ static enum AVChannel GetAVChannel(enum AEChannel aechannel); |
999 |
static int GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout); |
1000 |
}; |
1001 |
diff -urN xbmc/cores/FFmpeg.cpp.orig xbmc/cores/FFmpeg.cpp |
1002 |
--- xbmc/cores/FFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1003 |
+++ xbmc/cores/FFmpeg.cpp 2023-03-16 21:56:20.712628000 +0000 |
1004 |
@@ -16,11 +16,29 @@ |
1005 |
#include "utils/StringUtils.h" |
1006 |
#include "utils/log.h" |
1007 |
|
1008 |
+extern "C" |
1009 |
+{ |
1010 |
+#include <libavcodec/bsf.h> |
1011 |
+} |
1012 |
+ |
1013 |
#include <map> |
1014 |
#include <mutex> |
1015 |
|
1016 |
static thread_local CFFmpegLog* CFFmpegLogTls; |
1017 |
|
1018 |
+namespace FFMPEG_HELP_TOOLS |
1019 |
+{ |
1020 |
+ |
1021 |
+std::string FFMpegErrorToString(int err) |
1022 |
+{ |
1023 |
+ std::string text; |
1024 |
+ text.resize(AV_ERROR_MAX_STRING_SIZE); |
1025 |
+ av_strerror(err, text.data(), AV_ERROR_MAX_STRING_SIZE); |
1026 |
+ return text; |
1027 |
+} |
1028 |
+ |
1029 |
+} // namespace FFMPEG_HELP_TOOLS |
1030 |
+ |
1031 |
void CFFmpegLog::SetLogLevel(int level) |
1032 |
{ |
1033 |
CFFmpegLog::ClearLogLevel(); |
1034 |
@@ -117,3 +135,128 @@ |
1035 |
buffer.erase(0, start); |
1036 |
} |
1037 |
|
1038 |
+std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt, |
1039 |
+ const AVCodecParserContext* parserCtx, |
1040 |
+ AVCodecContext* codecCtx) |
1041 |
+{ |
1042 |
+ constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE); |
1043 |
+ |
1044 |
+ if (!pkt) |
1045 |
+ return std::make_tuple(nullptr, 0); |
1046 |
+ |
1047 |
+ uint8_t* extraData = nullptr; |
1048 |
+ int extraDataSize = 0; |
1049 |
+ |
1050 |
+ /* extract_extradata bitstream filter is implemented only |
1051 |
+ * for certain codecs, as noted in discussion of PR#21248 |
1052 |
+ */ |
1053 |
+ |
1054 |
+ AVCodecID codecId = codecCtx->codec_id; |
1055 |
+ |
1056 |
+ // clang-format off |
1057 |
+ if ( |
1058 |
+ codecId != AV_CODEC_ID_MPEG1VIDEO && |
1059 |
+ codecId != AV_CODEC_ID_MPEG2VIDEO && |
1060 |
+ codecId != AV_CODEC_ID_H264 && |
1061 |
+ codecId != AV_CODEC_ID_HEVC && |
1062 |
+ codecId != AV_CODEC_ID_MPEG4 && |
1063 |
+ codecId != AV_CODEC_ID_VC1 && |
1064 |
+ codecId != AV_CODEC_ID_AV1 && |
1065 |
+ codecId != AV_CODEC_ID_AVS2 && |
1066 |
+ codecId != AV_CODEC_ID_AVS3 && |
1067 |
+ codecId != AV_CODEC_ID_CAVS |
1068 |
+ ) |
1069 |
+ // clang-format on |
1070 |
+ return std::make_tuple(nullptr, 0); |
1071 |
+ |
1072 |
+ const AVBitStreamFilter* f = av_bsf_get_by_name("extract_extradata"); |
1073 |
+ if (!f) |
1074 |
+ return std::make_tuple(nullptr, 0); |
1075 |
+ |
1076 |
+ AVBSFContext* bsf = nullptr; |
1077 |
+ int ret = av_bsf_alloc(f, &bsf); |
1078 |
+ if (ret < 0) |
1079 |
+ return std::make_tuple(nullptr, 0); |
1080 |
+ |
1081 |
+ bsf->par_in->codec_id = codecId; |
1082 |
+ |
1083 |
+ ret = av_bsf_init(bsf); |
1084 |
+ if (ret < 0) |
1085 |
+ { |
1086 |
+ av_bsf_free(&bsf); |
1087 |
+ return std::make_tuple(nullptr, 0); |
1088 |
+ } |
1089 |
+ |
1090 |
+ AVPacket* dstPkt = av_packet_alloc(); |
1091 |
+ if (!dstPkt) |
1092 |
+ { |
1093 |
+ CLog::LogF(LOGERROR, "failed to allocate packet"); |
1094 |
+ |
1095 |
+ av_bsf_free(&bsf); |
1096 |
+ return std::make_tuple(nullptr, 0); |
1097 |
+ } |
1098 |
+ AVPacket* pktRef = dstPkt; |
1099 |
+ |
1100 |
+ ret = av_packet_ref(pktRef, pkt); |
1101 |
+ if (ret < 0) |
1102 |
+ { |
1103 |
+ av_bsf_free(&bsf); |
1104 |
+ av_packet_free(&dstPkt); |
1105 |
+ return std::make_tuple(nullptr, 0); |
1106 |
+ } |
1107 |
+ |
1108 |
+ ret = av_bsf_send_packet(bsf, pktRef); |
1109 |
+ if (ret < 0) |
1110 |
+ { |
1111 |
+ av_packet_unref(pktRef); |
1112 |
+ av_bsf_free(&bsf); |
1113 |
+ av_packet_free(&dstPkt); |
1114 |
+ return std::make_tuple(nullptr, 0); |
1115 |
+ } |
1116 |
+ |
1117 |
+ ret = 0; |
1118 |
+ while (ret >= 0) |
1119 |
+ { |
1120 |
+ ret = av_bsf_receive_packet(bsf, pktRef); |
1121 |
+ if (ret < 0) |
1122 |
+ { |
1123 |
+ if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) |
1124 |
+ break; |
1125 |
+ |
1126 |
+ continue; |
1127 |
+ } |
1128 |
+ |
1129 |
+ size_t retExtraDataSize = 0; |
1130 |
+ uint8_t* retExtraData = |
1131 |
+ av_packet_get_side_data(pktRef, AV_PKT_DATA_NEW_EXTRADATA, &retExtraDataSize); |
1132 |
+ if (retExtraData && retExtraDataSize > 0 && retExtraDataSize < FF_MAX_EXTRADATA_SIZE) |
1133 |
+ { |
1134 |
+ extraData = static_cast<uint8_t*>(av_malloc(retExtraDataSize + AV_INPUT_BUFFER_PADDING_SIZE)); |
1135 |
+ if (!extraData) |
1136 |
+ { |
1137 |
+ CLog::LogF(LOGERROR, "failed to allocate {} bytes for extradata", retExtraDataSize); |
1138 |
+ |
1139 |
+ av_packet_unref(pktRef); |
1140 |
+ av_bsf_free(&bsf); |
1141 |
+ av_packet_free(&dstPkt); |
1142 |
+ return std::make_tuple(nullptr, 0); |
1143 |
+ } |
1144 |
+ |
1145 |
+ CLog::LogF(LOGDEBUG, "fetching extradata, extradata_size({})", retExtraDataSize); |
1146 |
+ |
1147 |
+ memcpy(extraData, retExtraData, retExtraDataSize); |
1148 |
+ memset(extraData + retExtraDataSize, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
1149 |
+ extraDataSize = retExtraDataSize; |
1150 |
+ |
1151 |
+ av_packet_unref(pktRef); |
1152 |
+ break; |
1153 |
+ } |
1154 |
+ |
1155 |
+ av_packet_unref(pktRef); |
1156 |
+ } |
1157 |
+ |
1158 |
+ av_bsf_free(&bsf); |
1159 |
+ av_packet_free(&dstPkt); |
1160 |
+ |
1161 |
+ return std::make_tuple(extraData, extraDataSize); |
1162 |
+} |
1163 |
diff -urN xbmc/cores/FFmpeg.h.orig xbmc/cores/FFmpeg.h |
1164 |
--- xbmc/cores/FFmpeg.h.orig 2023-03-11 22:16:38.000000000 +0000 |
1165 |
+++ xbmc/cores/FFmpeg.h 2023-03-16 21:56:20.712753000 +0000 |
1166 |
@@ -10,6 +10,7 @@ |
1167 |
|
1168 |
#include "ServiceBroker.h" |
1169 |
#include "utils/CPUInfo.h" |
1170 |
+#include "utils/StringUtils.h" |
1171 |
|
1172 |
extern "C" { |
1173 |
#include <libavcodec/avcodec.h> |
1174 |
@@ -21,6 +22,26 @@ |
1175 |
#include <libpostproc/postprocess.h> |
1176 |
} |
1177 |
|
1178 |
+#include <tuple> |
1179 |
+ |
1180 |
+namespace FFMPEG_HELP_TOOLS |
1181 |
+{ |
1182 |
+ |
1183 |
+struct FFMpegException : public std::exception |
1184 |
+{ |
1185 |
+ std::string s; |
1186 |
+ template<typename... Args> |
1187 |
+ FFMpegException(const std::string& fmt, Args&&... args) |
1188 |
+ : s(StringUtils::Format(fmt, std::forward<Args>(args)...)) |
1189 |
+ { |
1190 |
+ } |
1191 |
+ const char* what() const noexcept override { return s.c_str(); } |
1192 |
+}; |
1193 |
+ |
1194 |
+std::string FFMpegErrorToString(int err); |
1195 |
+ |
1196 |
+} // namespace FFMPEG_HELP_TOOLS |
1197 |
+ |
1198 |
inline int PPCPUFlags() |
1199 |
{ |
1200 |
unsigned int cpuFeatures = CServiceBroker::GetCPUInfo()->GetCPUFeatures(); |
1201 |
@@ -51,3 +72,6 @@ |
1202 |
int level; |
1203 |
}; |
1204 |
|
1205 |
+std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt, |
1206 |
+ const AVCodecParserContext* parserCtx, |
1207 |
+ AVCodecContext* codecCtx); |
1208 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp |
1209 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1210 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp 2023-03-16 21:56:53.273377000 +0000 |
1211 |
@@ -7,14 +7,16 @@ |
1212 |
*/ |
1213 |
|
1214 |
#include "DVDAudioCodecFFmpeg.h" |
1215 |
-#include "ServiceBroker.h" |
1216 |
+ |
1217 |
#include "../../DVDStreamInfo.h" |
1218 |
-#include "utils/log.h" |
1219 |
+#include "DVDCodecs/DVDCodecs.h" |
1220 |
+#include "ServiceBroker.h" |
1221 |
+#include "cores/AudioEngine/Utils/AEUtil.h" |
1222 |
+#include "cores/FFmpeg.h" |
1223 |
#include "settings/AdvancedSettings.h" |
1224 |
#include "settings/Settings.h" |
1225 |
#include "settings/SettingsComponent.h" |
1226 |
-#include "DVDCodecs/DVDCodecs.h" |
1227 |
-#include "cores/AudioEngine/Utils/AEUtil.h" |
1228 |
+#include "utils/log.h" |
1229 |
|
1230 |
extern "C" { |
1231 |
#include <libavutil/opt.h> |
1232 |
@@ -44,7 +46,7 @@ |
1233 |
return false; |
1234 |
} |
1235 |
|
1236 |
- AVCodec* pCodec = NULL; |
1237 |
+ const AVCodec* pCodec = nullptr; |
1238 |
bool allowdtshddecode = true; |
1239 |
|
1240 |
// set any special options |
1241 |
@@ -71,13 +73,28 @@ |
1242 |
m_pCodecContext->debug = 0; |
1243 |
m_pCodecContext->workaround_bugs = 1; |
1244 |
|
1245 |
+#if LIBAVCODEC_VERSION_MAJOR < 60 |
1246 |
if (pCodec->capabilities & AV_CODEC_CAP_TRUNCATED) |
1247 |
m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED; |
1248 |
+#endif |
1249 |
|
1250 |
m_matrixEncoding = AV_MATRIX_ENCODING_NONE; |
1251 |
m_channels = 0; |
1252 |
- m_pCodecContext->channels = hints.channels; |
1253 |
- m_hint_layout = hints.channellayout; |
1254 |
+ av_channel_layout_uninit(&m_pCodecContext->ch_layout); |
1255 |
+ |
1256 |
+ if (hints.channels > 0 && hints.channellayout > 0) |
1257 |
+ { |
1258 |
+ m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE; |
1259 |
+ m_pCodecContext->ch_layout.nb_channels = hints.channels; |
1260 |
+ m_pCodecContext->ch_layout.u.mask = hints.channellayout; |
1261 |
+ } |
1262 |
+ else if (hints.channels > 0) |
1263 |
+ { |
1264 |
+ av_channel_layout_default(&m_pCodecContext->ch_layout, hints.channels); |
1265 |
+ } |
1266 |
+ |
1267 |
+ m_hint_layout = m_pCodecContext->ch_layout.u.mask; |
1268 |
+ |
1269 |
m_pCodecContext->sample_rate = hints.samplerate; |
1270 |
m_pCodecContext->block_align = hints.blockalign; |
1271 |
m_pCodecContext->bit_rate = hints.bitrate; |
1272 |
@@ -259,12 +276,13 @@ |
1273 |
m_format.m_frameSize = m_format.m_channelLayout.Count() * |
1274 |
CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3; |
1275 |
|
1276 |
- int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? m_pFrame->channels : 1; |
1277 |
+ int channels = m_pFrame->ch_layout.nb_channels; |
1278 |
+ int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? channels : 1; |
1279 |
+ |
1280 |
for (int i=0; i<planes; i++) |
1281 |
dst[i] = m_pFrame->extended_data[i]; |
1282 |
|
1283 |
- return m_pFrame->nb_samples * m_pFrame->channels * |
1284 |
- av_get_bytes_per_sample(m_pCodecContext->sample_fmt); |
1285 |
+ return m_pFrame->nb_samples * channels * av_get_bytes_per_sample(m_pCodecContext->sample_fmt); |
1286 |
} |
1287 |
|
1288 |
return 0; |
1289 |
@@ -278,7 +296,7 @@ |
1290 |
|
1291 |
int CDVDAudioCodecFFmpeg::GetChannels() |
1292 |
{ |
1293 |
- return m_pCodecContext->channels; |
1294 |
+ return m_pCodecContext->ch_layout.nb_channels; |
1295 |
} |
1296 |
|
1297 |
int CDVDAudioCodecFFmpeg::GetSampleRate() |
1298 |
@@ -345,28 +363,33 @@ |
1299 |
|
1300 |
void CDVDAudioCodecFFmpeg::BuildChannelMap() |
1301 |
{ |
1302 |
- if (m_channels == m_pCodecContext->channels && m_layout == m_pCodecContext->channel_layout) |
1303 |
+ int codecChannels = m_pCodecContext->ch_layout.nb_channels; |
1304 |
+ uint64_t codecChannelLayout = m_pCodecContext->ch_layout.u.mask; |
1305 |
+ if (m_channels == codecChannels && m_layout == codecChannelLayout) |
1306 |
return; //nothing to do here |
1307 |
|
1308 |
- m_channels = m_pCodecContext->channels; |
1309 |
- m_layout = m_pCodecContext->channel_layout; |
1310 |
+ m_channels = codecChannels; |
1311 |
+ m_layout = codecChannelLayout; |
1312 |
|
1313 |
int64_t layout; |
1314 |
|
1315 |
- int bits = count_bits(m_pCodecContext->channel_layout); |
1316 |
- if (bits == m_pCodecContext->channels) |
1317 |
- layout = m_pCodecContext->channel_layout; |
1318 |
+ int bits = count_bits(codecChannelLayout); |
1319 |
+ if (bits == codecChannels) |
1320 |
+ layout = codecChannelLayout; |
1321 |
else |
1322 |
{ |
1323 |
CLog::Log(LOGINFO, |
1324 |
"CDVDAudioCodecFFmpeg::GetChannelMap - FFmpeg reported {} channels, but the layout " |
1325 |
"contains {} - trying hints", |
1326 |
- m_pCodecContext->channels, bits); |
1327 |
- if (static_cast<int>(count_bits(m_hint_layout)) == m_pCodecContext->channels) |
1328 |
+ codecChannels, bits); |
1329 |
+ if (static_cast<int>(count_bits(m_hint_layout)) == codecChannels) |
1330 |
layout = m_hint_layout; |
1331 |
else |
1332 |
{ |
1333 |
- layout = av_get_default_channel_layout(m_pCodecContext->channels); |
1334 |
+ AVChannelLayout def_layout = {}; |
1335 |
+ av_channel_layout_default(&def_layout, codecChannels); |
1336 |
+ layout = def_layout.u.mask; |
1337 |
+ av_channel_layout_uninit(&def_layout); |
1338 |
CLog::Log(LOGINFO, "Using default layout..."); |
1339 |
} |
1340 |
} |
1341 |
@@ -392,7 +415,7 @@ |
1342 |
if (layout & AV_CH_TOP_BACK_CENTER ) m_channelLayout += AE_CH_BC ; |
1343 |
if (layout & AV_CH_TOP_BACK_RIGHT ) m_channelLayout += AE_CH_BR ; |
1344 |
|
1345 |
- m_channels = m_pCodecContext->channels; |
1346 |
+ m_channels = codecChannels; |
1347 |
} |
1348 |
|
1349 |
CAEChannelInfo CDVDAudioCodecFFmpeg::GetChannelMap() |
1350 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp |
1351 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1352 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp 2023-03-16 21:56:20.713197000 +0000 |
1353 |
@@ -10,6 +10,7 @@ |
1354 |
|
1355 |
#include "DVDOverlayImage.h" |
1356 |
#include "DVDStreamInfo.h" |
1357 |
+#include "cores/FFmpeg.h" |
1358 |
#include "cores/VideoPlayer/Interface/DemuxPacket.h" |
1359 |
#include "cores/VideoPlayer/Interface/TimingConstants.h" |
1360 |
#include "utils/EndianSwap.h" |
1361 |
@@ -39,7 +40,7 @@ |
1362 |
if (hints.codec == AV_CODEC_ID_EIA_608) |
1363 |
return false; |
1364 |
|
1365 |
- AVCodec* pCodec = avcodec_find_decoder(hints.codec); |
1366 |
+ const AVCodec* pCodec = avcodec_find_decoder(hints.codec); |
1367 |
if (!pCodec) |
1368 |
{ |
1369 |
CLog::Log(LOGDEBUG, "{} - Unable to find codec {}", __FUNCTION__, hints.codec); |
1370 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp |
1371 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1372 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2023-03-16 21:56:53.273710000 +0000 |
1373 |
@@ -12,6 +12,7 @@ |
1374 |
#include "DVDCodecs/DVDFactoryCodec.h" |
1375 |
#include "DVDStreamInfo.h" |
1376 |
#include "ServiceBroker.h" |
1377 |
+#include "cores/FFmpeg.h" |
1378 |
#include "cores/VideoPlayer/Interface/TimingConstants.h" |
1379 |
#include "cores/VideoPlayer/VideoRenderers/RenderManager.h" |
1380 |
#include "cores/VideoSettings.h" |
1381 |
@@ -27,12 +28,13 @@ |
1382 |
#include <mutex> |
1383 |
|
1384 |
extern "C" { |
1385 |
-#include <libavutil/opt.h> |
1386 |
-#include <libavutil/mastering_display_metadata.h> |
1387 |
#include <libavfilter/avfilter.h> |
1388 |
#include <libavfilter/buffersink.h> |
1389 |
#include <libavfilter/buffersrc.h> |
1390 |
+#include <libavutil/mastering_display_metadata.h> |
1391 |
+#include <libavutil/opt.h> |
1392 |
#include <libavutil/pixdesc.h> |
1393 |
+#include <libavutil/video_enc_params.h> |
1394 |
} |
1395 |
|
1396 |
#ifndef TARGET_POSIX |
1397 |
@@ -327,7 +329,7 @@ |
1398 |
m_hints = hints; |
1399 |
m_options = options; |
1400 |
|
1401 |
- AVCodec* pCodec = nullptr; |
1402 |
+ const AVCodec* pCodec = nullptr; |
1403 |
|
1404 |
m_iOrientation = hints.orientation; |
1405 |
|
1406 |
@@ -367,6 +369,7 @@ |
1407 |
m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT; |
1408 |
m_pCodecContext->get_format = GetFormat; |
1409 |
m_pCodecContext->codec_tag = hints.codec_tag; |
1410 |
+ m_pCodecContext->flags = AV_CODEC_FLAG_COPY_OPAQUE; |
1411 |
|
1412 |
// setup threading model |
1413 |
if (!(hints.codecOptions & CODEC_FORCE_SOFTWARE)) |
1414 |
@@ -543,19 +546,6 @@ |
1415 |
CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: {}", m_name); |
1416 |
} |
1417 |
|
1418 |
-union pts_union |
1419 |
-{ |
1420 |
- double pts_d; |
1421 |
- int64_t pts_i; |
1422 |
-}; |
1423 |
- |
1424 |
-static int64_t pts_dtoi(double pts) |
1425 |
-{ |
1426 |
- pts_union u; |
1427 |
- u.pts_d = pts; |
1428 |
- return u.pts_i; |
1429 |
-} |
1430 |
- |
1431 |
bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet) |
1432 |
{ |
1433 |
if (!m_pCodecContext) |
1434 |
@@ -573,7 +563,6 @@ |
1435 |
m_started = true; |
1436 |
|
1437 |
m_dts = packet.dts; |
1438 |
- m_pCodecContext->reordered_opaque = pts_dtoi(packet.pts); |
1439 |
|
1440 |
AVPacket* avpkt = av_packet_alloc(); |
1441 |
if (!avpkt) |
1442 |
@@ -1048,24 +1037,27 @@ |
1443 |
pVideoPicture->qscale_type = 0; |
1444 |
|
1445 |
AVFrameSideData* sd; |
1446 |
- sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_QP_TABLE_PROPERTIES); |
1447 |
+ |
1448 |
+ // https://github.com/FFmpeg/FFmpeg/blob/991d417692/doc/APIchanges#L18-L20 |
1449 |
+ sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_VIDEO_ENC_PARAMS); |
1450 |
if (sd) |
1451 |
{ |
1452 |
- struct qp_properties |
1453 |
- { |
1454 |
- int stride; |
1455 |
- int type; |
1456 |
- }; |
1457 |
+ unsigned int mb_h = (m_pFrame->height + 15) / 16; |
1458 |
+ unsigned int mb_w = (m_pFrame->width + 15) / 16; |
1459 |
+ unsigned int nb_mb = mb_h * mb_w; |
1460 |
+ unsigned int block_idx; |
1461 |
|
1462 |
- auto qp = reinterpret_cast<qp_properties*>(sd->data); |
1463 |
- |
1464 |
- sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_QP_TABLE_DATA); |
1465 |
- if (sd && sd->buf && qp) |
1466 |
+ auto par = reinterpret_cast<AVVideoEncParams*>(sd->data); |
1467 |
+ if (par->type == AV_VIDEO_ENC_PARAMS_MPEG2 && (par->nb_blocks == 0 || par->nb_blocks == nb_mb)) |
1468 |
{ |
1469 |
- // this seems wrong but it's what ffmpeg does internally |
1470 |
- pVideoPicture->qp_table = reinterpret_cast<int8_t*>(sd->buf->data); |
1471 |
- pVideoPicture->qstride = qp->stride; |
1472 |
- pVideoPicture->qscale_type = qp->type; |
1473 |
+ pVideoPicture->qstride = mb_w; |
1474 |
+ pVideoPicture->qscale_type = par->type; |
1475 |
+ pVideoPicture->qp_table = static_cast<int8_t*>(av_malloc(nb_mb)); |
1476 |
+ for (block_idx = 0; block_idx < nb_mb; block_idx++) |
1477 |
+ { |
1478 |
+ AVVideoBlockParams* b = av_video_enc_params_block(par, block_idx); |
1479 |
+ pVideoPicture->qp_table[block_idx] = par->qp + b->delta_qp; |
1480 |
+ } |
1481 |
} |
1482 |
} |
1483 |
|
1484 |
@@ -1159,8 +1151,9 @@ |
1485 |
const AVFilter* outFilter = avfilter_get_by_name("buffersink"); // should be last filter in the graph for now |
1486 |
|
1487 |
std::string args = StringUtils::Format( |
1488 |
- "{}:{}:{}:{}:{}:{}:{}", m_pCodecContext->width, m_pCodecContext->height, |
1489 |
- m_pCodecContext->pix_fmt, m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1, |
1490 |
+ "video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", m_pCodecContext->width, |
1491 |
+ m_pCodecContext->height, m_pCodecContext->pix_fmt, |
1492 |
+ m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1, |
1493 |
m_pCodecContext->time_base.num ? m_pCodecContext->time_base.den : 1, |
1494 |
m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.num : 1, |
1495 |
m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.den : 1); |
1496 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp |
1497 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1498 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp 2023-03-16 21:56:20.713709000 +0000 |
1499 |
@@ -118,6 +118,8 @@ |
1500 |
m_pMode, m_pContext, |
1501 |
pSource->pict_type | pSource->qscale_type ? PP_PICT_TYPE_QP2 : 0); |
1502 |
|
1503 |
+ // https://github.com/FFmpeg/FFmpeg/blob/991d417692/doc/APIchanges#L18-L20 |
1504 |
+ av_free(pSource->qp_table); |
1505 |
|
1506 |
pPicture->SetParams(*pSource); |
1507 |
if (pPicture->videoBuffer) |
1508 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp |
1509 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1510 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp 2023-03-16 21:56:53.271687000 +0000 |
1511 |
@@ -973,7 +973,8 @@ |
1512 |
m_event.Set(); |
1513 |
m_avD3D11Context = av_d3d11va_alloc_context(); |
1514 |
m_avD3D11Context->cfg = reinterpret_cast<D3D11_VIDEO_DECODER_CONFIG*>(av_mallocz(sizeof(D3D11_VIDEO_DECODER_CONFIG))); |
1515 |
- m_avD3D11Context->surface = reinterpret_cast<ID3D11VideoDecoderOutputView**>(av_mallocz_array(32, sizeof(ID3D11VideoDecoderOutputView*))); |
1516 |
+ m_avD3D11Context->surface = reinterpret_cast<ID3D11VideoDecoderOutputView**>( |
1517 |
+ av_calloc(32, sizeof(ID3D11VideoDecoderOutputView*))); |
1518 |
m_bufferPool.reset(); |
1519 |
|
1520 |
DX::Windowing()->Register(this); |
1521 |
@@ -1537,8 +1538,6 @@ |
1522 |
m_state = DXVA_RESET; |
1523 |
return -1; |
1524 |
} |
1525 |
- |
1526 |
- pic->reordered_opaque = avctx->reordered_opaque; |
1527 |
|
1528 |
for (unsigned i = 0; i < 4; i++) |
1529 |
{ |
1530 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp |
1531 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1532 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp 2023-03-16 21:56:53.274356000 +0000 |
1533 |
@@ -868,7 +868,6 @@ |
1534 |
} |
1535 |
pic->buf[0] = buffer; |
1536 |
|
1537 |
- pic->reordered_opaque = avctx->reordered_opaque; |
1538 |
va->Acquire(); |
1539 |
return 0; |
1540 |
} |
1541 |
@@ -1259,7 +1258,9 @@ |
1542 |
|
1543 |
IHardwareDecoder* CDecoder::Create(CDVDStreamInfo &hint, CProcessInfo &processInfo, AVPixelFormat fmt) |
1544 |
{ |
1545 |
- if (fmt == AV_PIX_FMT_VAAPI_VLD && CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_USEVAAPI)) |
1546 |
+ // https://github.com/FFmpeg/FFmpeg/blob/56450a0ee4fdda160f4039fc2ae33edfd27765c9/doc/APIchanges#L18-L26 |
1547 |
+ if (fmt == AV_PIX_FMT_VAAPI && |
1548 |
+ CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_USEVAAPI)) |
1549 |
return new VAAPI::CDecoder(processInfo); |
1550 |
|
1551 |
return nullptr; |
1552 |
@@ -2966,10 +2967,11 @@ |
1553 |
const AVFilter* srcFilter = avfilter_get_by_name("buffer"); |
1554 |
const AVFilter* outFilter = avfilter_get_by_name("buffersink"); |
1555 |
|
1556 |
- std::string args = StringUtils::Format("{}:{}:{}:{}:{}:{}:{}", m_config.vidWidth, |
1557 |
- m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1, |
1558 |
- (m_config.aspect.num != 0) ? m_config.aspect.num : 1, |
1559 |
- (m_config.aspect.num != 0) ? m_config.aspect.den : 1); |
1560 |
+ std::string args = |
1561 |
+ StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", |
1562 |
+ m_config.vidWidth, m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1, |
1563 |
+ (m_config.aspect.num != 0) ? m_config.aspect.num : 1, |
1564 |
+ (m_config.aspect.num != 0) ? m_config.aspect.den : 1); |
1565 |
|
1566 |
if (avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args.c_str(), NULL, m_pFilterGraph) < 0) |
1567 |
{ |
1568 |
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp |
1569 |
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1570 |
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp 2023-03-16 21:56:53.273163000 +0000 |
1571 |
@@ -1045,7 +1045,6 @@ |
1572 |
} |
1573 |
pic->buf[0] = buffer; |
1574 |
|
1575 |
- pic->reordered_opaque= avctx->reordered_opaque; |
1576 |
return 0; |
1577 |
} |
1578 |
|
1579 |
diff -urN xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp.orig xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp |
1580 |
--- xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1581 |
+++ xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp 2023-03-16 21:56:20.714592000 +0000 |
1582 |
@@ -10,13 +10,13 @@ |
1583 |
|
1584 |
#include "DVDDemuxUtils.h" |
1585 |
#include "DVDInputStreams/DVDInputStream.h" |
1586 |
+#include "cores/FFmpeg.h" |
1587 |
#include "cores/VideoPlayer/Interface/TimingConstants.h" |
1588 |
#include "utils/log.h" |
1589 |
|
1590 |
+#include <tuple> |
1591 |
#include <utility> |
1592 |
|
1593 |
-#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) |
1594 |
- |
1595 |
class CDemuxStreamClientInternal |
1596 |
{ |
1597 |
public: |
1598 |
@@ -130,7 +130,7 @@ |
1599 |
|
1600 |
if (stream->m_context == nullptr) |
1601 |
{ |
1602 |
- AVCodec *codec = avcodec_find_decoder(st->codec); |
1603 |
+ const AVCodec* codec = avcodec_find_decoder(st->codec); |
1604 |
if (codec == nullptr) |
1605 |
{ |
1606 |
CLog::Log(LOGERROR, "{} - can't find decoder", __FUNCTION__); |
1607 |
@@ -149,17 +149,26 @@ |
1608 |
stream->m_context->time_base.den = DVD_TIME_BASE; |
1609 |
} |
1610 |
|
1611 |
- if (stream->m_parser_split && stream->m_parser->parser->split) |
1612 |
+ if (stream->m_parser_split && stream->m_parser && stream->m_parser->parser) |
1613 |
{ |
1614 |
- int len = stream->m_parser->parser->split(stream->m_context, pkt->pData, pkt->iSize); |
1615 |
- if (len > 0 && len < FF_MAX_EXTRADATA_SIZE) |
1616 |
+ AVPacket* avpkt = av_packet_alloc(); |
1617 |
+ if (!avpkt) |
1618 |
{ |
1619 |
+ CLog::LogF(LOGERROR, "av_packet_alloc failed: {}", strerror(errno)); |
1620 |
+ return false; |
1621 |
+ } |
1622 |
+ |
1623 |
+ avpkt->data = pkt->pData; |
1624 |
+ avpkt->size = pkt->iSize; |
1625 |
+ avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; |
1626 |
+ |
1627 |
+ auto [retExtraData, len] = GetPacketExtradata(avpkt, stream->m_parser, stream->m_context); |
1628 |
+ if (len > 0) |
1629 |
+ { |
1630 |
st->changes++; |
1631 |
st->disabled = false; |
1632 |
st->ExtraSize = len; |
1633 |
- st->ExtraData = std::make_unique<uint8_t[]>(len + AV_INPUT_BUFFER_PADDING_SIZE); |
1634 |
- memcpy(st->ExtraData.get(), pkt->pData, len); |
1635 |
- memset(st->ExtraData.get() + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
1636 |
+ st->ExtraData = std::unique_ptr<uint8_t[]>(retExtraData); |
1637 |
stream->m_parser_split = false; |
1638 |
change = true; |
1639 |
CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - split extradata"); |
1640 |
@@ -167,21 +176,12 @@ |
1641 |
// Allow ffmpeg to transport codec information to stream->m_context |
1642 |
if (!avcodec_open2(stream->m_context, stream->m_context->codec, nullptr)) |
1643 |
{ |
1644 |
- AVPacket* avpkt = av_packet_alloc(); |
1645 |
- if (!avpkt) |
1646 |
- { |
1647 |
- CLog::Log(LOGERROR, "CDVDDemuxClient::{} - av_packet_alloc failed: {}", __FUNCTION__, |
1648 |
- strerror(errno)); |
1649 |
- return false; |
1650 |
- } |
1651 |
- avpkt->data = pkt->pData; |
1652 |
- avpkt->size = pkt->iSize; |
1653 |
- avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; |
1654 |
avcodec_send_packet(stream->m_context, avpkt); |
1655 |
avcodec_close(stream->m_context); |
1656 |
- av_packet_free(&avpkt); |
1657 |
} |
1658 |
} |
1659 |
+ |
1660 |
+ av_packet_free(&avpkt); |
1661 |
} |
1662 |
|
1663 |
uint8_t *outbuf = nullptr; |
1664 |
@@ -219,10 +219,12 @@ |
1665 |
case STREAM_AUDIO: |
1666 |
{ |
1667 |
CDemuxStreamClientInternalTpl<CDemuxStreamAudio>* sta = static_cast<CDemuxStreamClientInternalTpl<CDemuxStreamAudio>*>(st); |
1668 |
- if (stream->m_context->channels != sta->iChannels && stream->m_context->channels != 0) |
1669 |
+ int streamChannels = stream->m_context->ch_layout.nb_channels; |
1670 |
+ if (streamChannels != sta->iChannels && streamChannels != 0) |
1671 |
{ |
1672 |
- CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - ({}) channels changed from {} to {}", st->uniqueId, sta->iChannels, stream->m_context->channels); |
1673 |
- sta->iChannels = stream->m_context->channels; |
1674 |
+ CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - ({}) channels changed from {} to {}", |
1675 |
+ st->uniqueId, sta->iChannels, streamChannels); |
1676 |
+ sta->iChannels = streamChannels; |
1677 |
sta->changes++; |
1678 |
sta->disabled = false; |
1679 |
} |
1680 |
@@ -234,7 +236,7 @@ |
1681 |
sta->changes++; |
1682 |
sta->disabled = false; |
1683 |
} |
1684 |
- if (stream->m_context->channels) |
1685 |
+ if (streamChannels) |
1686 |
st->changes = -1; // stop parsing |
1687 |
break; |
1688 |
} |
1689 |
diff -urN xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp |
1690 |
--- xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
1691 |
+++ xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2023-03-16 21:56:53.267762000 +0000 |
1692 |
@@ -34,10 +34,12 @@ |
1693 |
|
1694 |
#include <mutex> |
1695 |
#include <sstream> |
1696 |
+#include <tuple> |
1697 |
#include <utility> |
1698 |
|
1699 |
extern "C" |
1700 |
{ |
1701 |
+#include "libavutil/channel_layout.h" |
1702 |
#include "libavutil/pixdesc.h" |
1703 |
} |
1704 |
|
1705 |
@@ -104,8 +106,6 @@ |
1706 |
} |
1707 |
} // namespace |
1708 |
|
1709 |
-#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) |
1710 |
- |
1711 |
std::string CDemuxStreamAudioFFmpeg::GetStreamName() |
1712 |
{ |
1713 |
if (!m_stream) |
1714 |
@@ -235,7 +235,7 @@ |
1715 |
|
1716 |
bool CDVDDemuxFFmpeg::Open(const std::shared_ptr<CDVDInputStream>& pInput, bool fileinfo) |
1717 |
{ |
1718 |
- AVInputFormat* iformat = NULL; |
1719 |
+ const AVInputFormat* iformat = nullptr; |
1720 |
std::string strFile; |
1721 |
m_streaminfo = !pInput->IsRealtime() && !m_reopen; |
1722 |
m_reopen = false; |
1723 |
@@ -323,7 +323,6 @@ |
1724 |
} |
1725 |
if (result < 0) |
1726 |
{ |
1727 |
- m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT; |
1728 |
if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0) |
1729 |
{ |
1730 |
CLog::Log(LOGDEBUG, "Error, could not open file {}", CURL::GetRedacted(strFile)); |
1731 |
@@ -335,7 +334,6 @@ |
1732 |
avformat_close_input(&m_pFormatContext); |
1733 |
m_pFormatContext = avformat_alloc_context(); |
1734 |
m_pFormatContext->interrupt_callback = int_cb; |
1735 |
- m_pFormatContext->flags &= ~AVFMT_FLAG_PRIV_OPT; |
1736 |
AVDictionary* options = GetFFMpegOptionsFromInput(); |
1737 |
av_dict_set_int(&options, "load_all_variants", 0, AV_OPT_SEARCH_CHILDREN); |
1738 |
if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0) |
1739 |
@@ -422,9 +420,7 @@ |
1740 |
// is present, we assume it is PCM audio. |
1741 |
// AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS |
1742 |
// may be just padded. |
1743 |
- AVInputFormat* iformat2; |
1744 |
- iformat2 = av_find_input_format("spdif"); |
1745 |
- |
1746 |
+ const AVInputFormat* iformat2 = av_find_input_format("spdif"); |
1747 |
if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4) |
1748 |
{ |
1749 |
iformat = iformat2; |
1750 |
@@ -544,12 +540,6 @@ |
1751 |
m_streaminfo = true; |
1752 |
} |
1753 |
|
1754 |
- if (iformat && (strcmp(iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0)) |
1755 |
- { |
1756 |
- if (URIUtils::IsRemote(strFile)) |
1757 |
- m_pFormatContext->iformat->flags |= AVFMT_NOGENSEARCH; |
1758 |
- } |
1759 |
- |
1760 |
// we need to know if this is matroska, avi or sup later |
1761 |
m_bMatroska = strncmp(m_pFormatContext->iformat->name, "matroska", 8) == 0; // for "matroska.webm" |
1762 |
m_bAVI = strcmp(m_pFormatContext->iformat->name, "avi") == 0; |
1763 |
@@ -604,9 +594,6 @@ |
1764 |
// if format can be nonblocking, let's use that |
1765 |
m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK; |
1766 |
|
1767 |
- // deprecated, will be always set in future versions |
1768 |
- m_pFormatContext->flags |= AVFMT_FLAG_KEEP_SIDE_DATA; |
1769 |
- |
1770 |
UpdateCurrentPTS(); |
1771 |
|
1772 |
// select the correct program if requested |
1773 |
@@ -647,7 +634,10 @@ |
1774 |
{ |
1775 |
int idx = m_pFormatContext->programs[i]->stream_index[j]; |
1776 |
AVStream* st = m_pFormatContext->streams[idx]; |
1777 |
- if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 0) || |
1778 |
+ // Related to https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210429143825.53040-1-jamrial@gmail.com/ |
1779 |
+ // has been replaced with AVSTREAM_EVENT_FLAG_NEW_PACKETS. |
1780 |
+ if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && |
1781 |
+ (st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)) || |
1782 |
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate > 0)) |
1783 |
{ |
1784 |
nProgram = i; |
1785 |
@@ -1218,8 +1208,11 @@ |
1786 |
else if (stream->type == STREAM_AUDIO) |
1787 |
{ |
1788 |
CDemuxStreamAudioFFmpeg* audiostream = dynamic_cast<CDemuxStreamAudioFFmpeg*>(stream); |
1789 |
- if (audiostream && (audiostream->iChannels != m_pFormatContext->streams[pPacket->iStreamId]->codecpar->channels || |
1790 |
- audiostream->iSampleRate != m_pFormatContext->streams[pPacket->iStreamId]->codecpar->sample_rate)) |
1791 |
+ int codecparChannels = |
1792 |
+ m_pFormatContext->streams[pPacket->iStreamId]->codecpar->ch_layout.nb_channels; |
1793 |
+ if (audiostream && (audiostream->iChannels != codecparChannels || |
1794 |
+ audiostream->iSampleRate != |
1795 |
+ m_pFormatContext->streams[pPacket->iStreamId]->codecpar->sample_rate)) |
1796 |
{ |
1797 |
// content has changed |
1798 |
stream = AddStream(pPacket->iStreamId); |
1799 |
@@ -1401,9 +1394,10 @@ |
1800 |
if (idx >= 0) |
1801 |
{ |
1802 |
AVStream* stream = m_pFormatContext->streams[idx]; |
1803 |
- if (stream && stream->cur_dts != (int64_t)AV_NOPTS_VALUE) |
1804 |
+ |
1805 |
+ if (stream && m_pkt.pkt.dts != (int64_t)AV_NOPTS_VALUE) |
1806 |
{ |
1807 |
- double ts = ConvertTimestamp(stream->cur_dts, stream->time_base.den, stream->time_base.num); |
1808 |
+ double ts = ConvertTimestamp(m_pkt.pkt.dts, stream->time_base.den, stream->time_base.num); |
1809 |
m_currentPts = ts; |
1810 |
} |
1811 |
} |
1812 |
@@ -1614,14 +1608,20 @@ |
1813 |
{ |
1814 |
CDemuxStreamAudioFFmpeg* st = new CDemuxStreamAudioFFmpeg(pStream); |
1815 |
stream = st; |
1816 |
- st->iChannels = pStream->codecpar->channels; |
1817 |
+ int codecparChannels = pStream->codecpar->ch_layout.nb_channels; |
1818 |
+ int codecparChannelLayout = pStream->codecpar->ch_layout.u.mask; |
1819 |
+ st->iChannels = codecparChannels; |
1820 |
+ st->iChannelLayout = codecparChannelLayout; |
1821 |
st->iSampleRate = pStream->codecpar->sample_rate; |
1822 |
st->iBlockAlign = pStream->codecpar->block_align; |
1823 |
st->iBitRate = static_cast<int>(pStream->codecpar->bit_rate); |
1824 |
st->iBitsPerSample = pStream->codecpar->bits_per_raw_sample; |
1825 |
- st->iChannelLayout = pStream->codecpar->channel_layout; |
1826 |
char buf[32] = {}; |
1827 |
- av_get_channel_layout_string(buf, 31, st->iChannels, st->iChannelLayout); |
1828 |
+ // https://github.com/FFmpeg/FFmpeg/blob/6ccc3989d15/doc/APIchanges#L50-L53 |
1829 |
+ AVChannelLayout layout = {}; |
1830 |
+ av_channel_layout_from_mask(&layout, st->iChannelLayout); |
1831 |
+ av_channel_layout_describe(&layout, buf, sizeof(buf)); |
1832 |
+ av_channel_layout_uninit(&layout); |
1833 |
st->m_channelLayoutName = buf; |
1834 |
if (st->iBitsPerSample == 0) |
1835 |
st->iBitsPerSample = pStream->codecpar->bits_per_coded_sample; |
1836 |
@@ -1663,16 +1663,6 @@ |
1837 |
st->iFpsScale = 0; |
1838 |
} |
1839 |
|
1840 |
- if (pStream->codec_info_nb_frames > 0 && |
1841 |
- pStream->codec_info_nb_frames <= 2 && |
1842 |
- m_pInput->IsStreamType(DVDSTREAM_TYPE_DVD)) |
1843 |
- { |
1844 |
- CLog::Log(LOGDEBUG, "{} - fps may be unreliable since ffmpeg decoded only {} frame(s)", |
1845 |
- __FUNCTION__, pStream->codec_info_nb_frames); |
1846 |
- st->iFpsRate = 0; |
1847 |
- st->iFpsScale = 0; |
1848 |
- } |
1849 |
- |
1850 |
st->iWidth = pStream->codecpar->width; |
1851 |
st->iHeight = pStream->codecpar->height; |
1852 |
st->fAspect = SelectAspect(pStream, st->bForcedAspect); |
1853 |
@@ -1693,7 +1683,8 @@ |
1854 |
st->colorRange = pStream->codecpar->color_range; |
1855 |
st->hdr_type = DetermineHdrType(pStream); |
1856 |
|
1857 |
- int size = 0; |
1858 |
+ // https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/APIchanges |
1859 |
+ size_t size = 0; |
1860 |
uint8_t* side_data = nullptr; |
1861 |
|
1862 |
side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size); |
1863 |
@@ -2103,7 +2094,7 @@ |
1864 |
return strName; |
1865 |
} |
1866 |
|
1867 |
- AVCodec* codec = avcodec_find_decoder(stream->codec); |
1868 |
+ const AVCodec* codec = avcodec_find_decoder(stream->codec); |
1869 |
if (codec) |
1870 |
strName = avcodec_get_name(codec->id); |
1871 |
} |
1872 |
@@ -2158,8 +2149,8 @@ |
1873 |
if (m_pFormatContext->streams[idx]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) |
1874 |
{ |
1875 |
CDemuxStreamAudioFFmpeg* audiostream = dynamic_cast<CDemuxStreamAudioFFmpeg*>(stream); |
1876 |
- if (audiostream && |
1877 |
- m_pFormatContext->streams[idx]->codecpar->channels != audiostream->iChannels) |
1878 |
+ int codecparChannels = m_pFormatContext->streams[idx]->codecpar->ch_layout.nb_channels; |
1879 |
+ if (audiostream && codecparChannels != audiostream->iChannels) |
1880 |
{ |
1881 |
return true; |
1882 |
} |
1883 |
@@ -2279,7 +2270,7 @@ |
1884 |
|
1885 |
parser->second->m_parserCtx = av_parser_init(st->codecpar->codec_id); |
1886 |
|
1887 |
- AVCodec* codec = avcodec_find_decoder(st->codecpar->codec_id); |
1888 |
+ const AVCodec* codec = avcodec_find_decoder(st->codecpar->codec_id); |
1889 |
if (codec == nullptr) |
1890 |
{ |
1891 |
CLog::Log(LOGERROR, "{} - can't find decoder", __FUNCTION__); |
1892 |
@@ -2295,45 +2286,37 @@ |
1893 |
|
1894 |
if (parser->second->m_parserCtx && |
1895 |
parser->second->m_parserCtx->parser && |
1896 |
- parser->second->m_parserCtx->parser->split && |
1897 |
!st->codecpar->extradata) |
1898 |
{ |
1899 |
- int i = parser->second->m_parserCtx->parser->split(parser->second->m_codecCtx, pkt->data, pkt->size); |
1900 |
- if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) |
1901 |
+ auto [retExtraData, i] = |
1902 |
+ GetPacketExtradata(pkt, parser->second->m_parserCtx, parser->second->m_codecCtx); |
1903 |
+ if (i > 0) |
1904 |
{ |
1905 |
- st->codecpar->extradata = (uint8_t*)av_malloc(i + AV_INPUT_BUFFER_PADDING_SIZE); |
1906 |
- if (st->codecpar->extradata) |
1907 |
+ st->codecpar->extradata_size = i; |
1908 |
+ st->codecpar->extradata = retExtraData; |
1909 |
+ |
1910 |
+ if (parser->second->m_parserCtx->parser->parser_parse) |
1911 |
{ |
1912 |
- CLog::Log(LOGDEBUG, |
1913 |
- "CDVDDemuxFFmpeg::ParsePacket() fetching extradata, extradata_size({})", i); |
1914 |
- st->codecpar->extradata_size = i; |
1915 |
- memcpy(st->codecpar->extradata, pkt->data, i); |
1916 |
- memset(st->codecpar->extradata + i, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
1917 |
+ parser->second->m_codecCtx->extradata = st->codecpar->extradata; |
1918 |
+ parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size; |
1919 |
+ const uint8_t* outbufptr; |
1920 |
+ int bufSize; |
1921 |
+ parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES; |
1922 |
+ parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx, |
1923 |
+ parser->second->m_codecCtx, &outbufptr, |
1924 |
+ &bufSize, pkt->data, pkt->size); |
1925 |
+ parser->second->m_codecCtx->extradata = nullptr; |
1926 |
+ parser->second->m_codecCtx->extradata_size = 0; |
1927 |
|
1928 |
- if (parser->second->m_parserCtx->parser->parser_parse) |
1929 |
+ if (parser->second->m_parserCtx->width != 0) |
1930 |
{ |
1931 |
- parser->second->m_codecCtx->extradata = st->codecpar->extradata; |
1932 |
- parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size; |
1933 |
- const uint8_t* outbufptr; |
1934 |
- int bufSize; |
1935 |
- parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES; |
1936 |
- parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx, |
1937 |
- parser->second->m_codecCtx, |
1938 |
- &outbufptr, &bufSize, |
1939 |
- pkt->data, pkt->size); |
1940 |
- parser->second->m_codecCtx->extradata = nullptr; |
1941 |
- parser->second->m_codecCtx->extradata_size = 0; |
1942 |
- |
1943 |
- if (parser->second->m_parserCtx->width != 0) |
1944 |
- { |
1945 |
- st->codecpar->width = parser->second->m_parserCtx->width; |
1946 |
- st->codecpar->height = parser->second->m_parserCtx->height; |
1947 |
- } |
1948 |
- else |
1949 |
- { |
1950 |
- CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height"); |
1951 |
- } |
1952 |
+ st->codecpar->width = parser->second->m_parserCtx->width; |
1953 |
+ st->codecpar->height = parser->second->m_parserCtx->height; |
1954 |
} |
1955 |
+ else |
1956 |
+ { |
1957 |
+ CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height"); |
1958 |
+ } |
1959 |
} |
1960 |
} |
1961 |
} |
1962 |
@@ -2357,7 +2340,8 @@ |
1963 |
{ |
1964 |
if (!m_startTime) |
1965 |
{ |
1966 |
- m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; |
1967 |
+ m_startTime = |
1968 |
+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; |
1969 |
m_seekStream = idx; |
1970 |
} |
1971 |
return TRANSPORT_STREAM_STATE::READY; |
1972 |
@@ -2377,7 +2361,8 @@ |
1973 |
{ |
1974 |
if (!m_startTime) |
1975 |
{ |
1976 |
- m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; |
1977 |
+ m_startTime = |
1978 |
+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; |
1979 |
m_seekStream = i; |
1980 |
} |
1981 |
return TRANSPORT_STREAM_STATE::READY; |
1982 |
@@ -2410,7 +2395,8 @@ |
1983 |
{ |
1984 |
if (!m_startTime) |
1985 |
{ |
1986 |
- m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; |
1987 |
+ m_startTime = |
1988 |
+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; |
1989 |
m_seekStream = idx; |
1990 |
} |
1991 |
return TRANSPORT_STREAM_STATE::READY; |
1992 |
@@ -2430,7 +2416,8 @@ |
1993 |
{ |
1994 |
if (!m_startTime) |
1995 |
{ |
1996 |
- m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; |
1997 |
+ m_startTime = |
1998 |
+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; |
1999 |
m_seekStream = i; |
2000 |
} |
2001 |
return TRANSPORT_STREAM_STATE::READY; |
2002 |
diff -urN xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp.orig xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp |
2003 |
--- xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
2004 |
+++ xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp 2023-03-16 21:56:20.715583000 +0000 |
2005 |
@@ -12,6 +12,7 @@ |
2006 |
#include "addons/addoninfo/AddonType.h" |
2007 |
#include "addons/binary-addons/AddonDll.h" |
2008 |
#include "addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h" |
2009 |
+#include "cores/FFmpeg.h" |
2010 |
#include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" |
2011 |
#include "cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h" |
2012 |
#include "cores/VideoPlayer/Interface/DemuxCrypto.h" |
2013 |
@@ -392,7 +393,7 @@ |
2014 |
return nullptr; |
2015 |
|
2016 |
std::string codecName(stream->m_codecName); |
2017 |
- AVCodec* codec = nullptr; |
2018 |
+ const AVCodec* codec = nullptr; |
2019 |
|
2020 |
if (stream->m_streamType != INPUTSTREAM_TYPE_TELETEXT && |
2021 |
stream->m_streamType != INPUTSTREAM_TYPE_RDS && stream->m_streamType != INPUTSTREAM_TYPE_ID3) |
2022 |
diff -urN xbmc/filesystem/AudioBookFileDirectory.cpp.orig xbmc/filesystem/AudioBookFileDirectory.cpp |
2023 |
--- xbmc/filesystem/AudioBookFileDirectory.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
2024 |
+++ xbmc/filesystem/AudioBookFileDirectory.cpp 2023-03-16 21:56:20.715726000 +0000 |
2025 |
@@ -11,6 +11,7 @@ |
2026 |
#include "TextureDatabase.h" |
2027 |
#include "URL.h" |
2028 |
#include "Util.h" |
2029 |
+#include "cores/FFmpeg.h" |
2030 |
#include "filesystem/File.h" |
2031 |
#include "guilib/LocalizeStrings.h" |
2032 |
#include "music/tags/MusicInfoTag.h" |
2033 |
@@ -149,7 +150,7 @@ |
2034 |
|
2035 |
m_ioctx->max_packet_size = 32768; |
2036 |
|
2037 |
- AVInputFormat* iformat=nullptr; |
2038 |
+ const AVInputFormat* iformat = nullptr; |
2039 |
av_probe_input_buffer(m_ioctx, &iformat, url.Get().c_str(), nullptr, 0, 0); |
2040 |
|
2041 |
bool contains = false; |
2042 |
diff -urN xbmc/guilib/FFmpegImage.cpp.orig xbmc/guilib/FFmpegImage.cpp |
2043 |
--- xbmc/guilib/FFmpegImage.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
2044 |
+++ xbmc/guilib/FFmpegImage.cpp 2023-03-16 21:56:53.271294000 +0000 |
2045 |
@@ -52,7 +52,7 @@ |
2046 |
AVFrame* frame_temporary = nullptr; |
2047 |
SwsContext* sws = nullptr; |
2048 |
AVCodecContext* avOutctx = nullptr; |
2049 |
- AVCodec* codec = nullptr; |
2050 |
+ const AVCodec* codec = nullptr; |
2051 |
~ThumbDataManagement() |
2052 |
{ |
2053 |
av_free(intermediateBuffer); |
2054 |
@@ -198,7 +198,7 @@ |
2055 |
bool is_png = (bufSize > 3 && buffer[1] == 'P' && buffer[2] == 'N' && buffer[3] == 'G'); |
2056 |
bool is_tiff = (bufSize > 2 && buffer[0] == 'I' && buffer[1] == 'I' && buffer[2] == '*'); |
2057 |
|
2058 |
- AVInputFormat* inp = nullptr; |
2059 |
+ const AVInputFormat* inp = nullptr; |
2060 |
if (is_jpeg) |
2061 |
inp = av_find_input_format("image2"); |
2062 |
else if (m_strMimeType == "image/apng") |
2063 |
@@ -236,7 +236,7 @@ |
2064 |
return false; |
2065 |
} |
2066 |
AVCodecParameters* codec_params = m_fctx->streams[0]->codecpar; |
2067 |
- AVCodec* codec = avcodec_find_decoder(codec_params->codec_id); |
2068 |
+ const AVCodec* codec = avcodec_find_decoder(codec_params->codec_id); |
2069 |
m_codec_ctx = avcodec_alloc_context3(codec); |
2070 |
if (!m_codec_ctx) |
2071 |
{ |
2072 |
@@ -294,7 +294,8 @@ |
2073 |
return nullptr; |
2074 |
} |
2075 |
//we need milliseconds |
2076 |
- frame->pkt_duration = av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{ 1, 1000 }); |
2077 |
+ frame->duration = |
2078 |
+ av_rescale_q(frame->duration, m_fctx->streams[0]->time_base, AVRational{1, 1000}); |
2079 |
m_height = frame->height; |
2080 |
m_width = frame->width; |
2081 |
m_originalWidth = m_width; |
2082 |
@@ -745,7 +746,7 @@ |
2083 |
if (avframe == nullptr) |
2084 |
return nullptr; |
2085 |
std::shared_ptr<Frame> frame(new Frame()); |
2086 |
- frame->m_delay = (unsigned int)avframe->pkt_duration; |
2087 |
+ frame->m_delay = (unsigned int)avframe->duration; |
2088 |
frame->m_pitch = avframe->width * 4; |
2089 |
frame->m_pImage = (unsigned char*) av_malloc(avframe->height * frame->m_pitch); |
2090 |
DecodeFrame(avframe, avframe->width, avframe->height, frame->m_pitch, frame->m_pImage); |
2091 |
diff -urN xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp.orig xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp |
2092 |
--- xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
2093 |
+++ xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp 2023-03-16 21:56:20.716138000 +0000 |
2094 |
@@ -58,7 +58,7 @@ |
2095 |
if (file.IoControl(IOCTRL_SEEK_POSSIBLE, NULL) != 1) |
2096 |
ioctx->seekable = 0; |
2097 |
|
2098 |
- AVInputFormat* iformat=NULL; |
2099 |
+ const AVInputFormat* iformat = nullptr; |
2100 |
av_probe_input_buffer(ioctx, &iformat, strFileName.c_str(), NULL, 0, 0); |
2101 |
|
2102 |
if (avformat_open_input(&fctx, strFileName.c_str(), iformat, NULL) < 0) |
2103 |
diff -urN xbmc/video/tags/VideoTagLoaderFFmpeg.cpp.orig xbmc/video/tags/VideoTagLoaderFFmpeg.cpp |
2104 |
--- xbmc/video/tags/VideoTagLoaderFFmpeg.cpp.orig 2023-03-11 22:16:38.000000000 +0000 |
2105 |
+++ xbmc/video/tags/VideoTagLoaderFFmpeg.cpp 2023-03-16 21:56:20.716302000 +0000 |
2106 |
@@ -65,7 +65,7 @@ |
2107 |
if (m_file->IoControl(IOCTRL_SEEK_POSSIBLE, nullptr) != 1) |
2108 |
m_ioctx->seekable = 0; |
2109 |
|
2110 |
- AVInputFormat* iformat = nullptr; |
2111 |
+ const AVInputFormat* iformat = nullptr; |
2112 |
av_probe_input_buffer(m_ioctx, &iformat, m_item.GetPath().c_str(), nullptr, 0, 0); |
2113 |
if (avformat_open_input(&m_fctx, m_item.GetPath().c_str(), iformat, nullptr) < 0) |
2114 |
{ |