1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
https://github.com/PCSX2/pcsx2/pull/14831
--- a/pcsx2/GS/GSCapture.cpp
+++ b/pcsx2/GS/GSCapture.cpp
@@ -69,2 +69,3 @@
X(avcodec_get_hw_config) \
+ X(avcodec_get_supported_config) \
X(av_codec_iterate) \
@@ -456,10 +457,12 @@
AVPixelFormat sw_pix_fmt = preferred_sw_pix_fmt;
- if (vcodec->pix_fmts)
+ const AVPixelFormat* supported_pix_fmts = nullptr;
+ if (wrap_avcodec_get_supported_config(nullptr, vcodec, AV_CODEC_CONFIG_PIX_FORMAT, 0,
+ reinterpret_cast<const void**>(&supported_pix_fmts), nullptr) == 0 && supported_pix_fmts)
{
- sw_pix_fmt = vcodec->pix_fmts[0];
- for (u32 i = 0; vcodec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
+ sw_pix_fmt = supported_pix_fmts[0];
+ for (u32 i = 0; supported_pix_fmts[i] != AV_PIX_FMT_NONE; i++)
{
- if (vcodec->pix_fmts[i] == preferred_sw_pix_fmt)
+ if (supported_pix_fmts[i] == preferred_sw_pix_fmt)
{
- sw_pix_fmt = vcodec->pix_fmts[i];
+ sw_pix_fmt = supported_pix_fmts[i];
break;
@@ -688,10 +691,18 @@
bool supports_format = false;
- for (const AVSampleFormat* p = acodec->sample_fmts; *p != AV_SAMPLE_FMT_NONE; p++)
+ const AVSampleFormat* supported_sample_fmts = nullptr;
+ if (wrap_avcodec_get_supported_config(nullptr, acodec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
+ reinterpret_cast<const void**>(&supported_sample_fmts), nullptr) == 0 && supported_sample_fmts)
{
- if (*p == s_audio_codec_context->sample_fmt)
+ for (const AVSampleFormat* p = supported_sample_fmts; *p != AV_SAMPLE_FMT_NONE; p++)
{
- supports_format = true;
- break;
+ if (*p == s_audio_codec_context->sample_fmt)
+ {
+ supports_format = true;
+ break;
+ }
}
}
+ else
+ supports_format = true;
+
if (!supports_format)
@@ -699,3 +710,3 @@
Console.WriteLn(fmt::format("Audio codec '{}' does not support S16 samples, using default.", acodec->name));
- s_audio_codec_context->sample_fmt = acodec->sample_fmts[0];
+ s_audio_codec_context->sample_fmt = supported_sample_fmts[0];
s_swr_context = wrap_swr_alloc();
@@ -1534,6 +1545,8 @@
+ const AVPixelFormat* pix_fmts = nullptr;
// rawvideo doesn't have a list of formats.
- if (v_codec->pix_fmts == nullptr)
+ if (wrap_avcodec_get_supported_config(nullptr, v_codec, AV_CODEC_CONFIG_PIX_FORMAT, 0,
+ reinterpret_cast<const void**>(&pix_fmts), nullptr) != 0 || !pix_fmts)
{
- Console.Error("(GetVideoFormatList) v_codec->pix_fmts is null.");
+ Console.Error("(GetVideoFormatList) v_codec has no pixel format list.");
return ret;
@@ -1541,5 +1554,5 @@
- for (int i = 0; v_codec->pix_fmts[i] != AVPixelFormat::AV_PIX_FMT_NONE; i++)
+ for (int i = 0; pix_fmts[i] != AVPixelFormat::AV_PIX_FMT_NONE; i++)
{
- ret.emplace_back(v_codec->pix_fmts[i], wrap_av_get_pix_fmt_name(v_codec->pix_fmts[i]));
+ ret.emplace_back(pix_fmts[i], wrap_av_get_pix_fmt_name(pix_fmts[i]));
}
|