@@ -64,22 +64,43 @@ AVMediaType Codec::type() const
64
64
65
65
std::deque<Rational> Codec::supportedFramerates () const
66
66
{
67
- deque<Rational> frameRates;
68
67
if (!m_raw)
69
- return frameRates;
70
- array_to_container (m_raw->supported_framerates , frameRates, [](const Rational& rate) {
68
+ return {};
69
+ deque<Rational> frameRates;
70
+ const AVRational *frameRatesRaw = nullptr ;
71
+ #if USE_AVCODEC_GET_SUPPORTED_CONFIG
72
+ avcodec_get_supported_config (nullptr , m_raw, AV_CODEC_CONFIG_FRAME_RATE, 0 , reinterpret_cast <const void **>(&frameRatesRaw), nullptr );
73
+ #else
74
+ frameRatesRaw = m_raw->supported_framerates ;
75
+ #endif
76
+
77
+ if (!frameRatesRaw)
78
+ return {};
79
+
80
+ array_to_container (frameRatesRaw, frameRates, [](const Rational& rate) {
71
81
return rate == Rational ();
72
82
});
73
83
return frameRates;
74
84
}
75
85
76
86
std::deque<PixelFormat> Codec::supportedPixelFormats () const
77
87
{
78
- deque<PixelFormat> pixFmts;
79
88
if (!m_raw)
80
- return pixFmts;
89
+ return {};
90
+
91
+ deque<PixelFormat> pixFmts;
92
+ const enum AVPixelFormat *pixFmtsRaw = nullptr ;
81
93
82
- array_to_container (m_raw->pix_fmts , pixFmts, [](PixelFormat pixFmt) {
94
+ #if USE_AVCODEC_GET_SUPPORTED_CONFIG
95
+ avcodec_get_supported_config (nullptr , m_raw, AV_CODEC_CONFIG_PIX_FORMAT, 0 , reinterpret_cast <const void **>(&pixFmtsRaw), nullptr );
96
+ #else
97
+ pixFmtsRaw = m_raw->pix_fmts ;
98
+ #endif
99
+
100
+ if (!pixFmtsRaw)
101
+ return {};
102
+
103
+ array_to_container (pixFmtsRaw, pixFmts, [](PixelFormat pixFmt) {
83
104
return pixFmt == AV_PIX_FMT_NONE;
84
105
});
85
106
@@ -88,11 +109,22 @@ std::deque<PixelFormat> Codec::supportedPixelFormats() const
88
109
89
110
std::deque<int > Codec::supportedSamplerates () const
90
111
{
91
- deque<int > sampleRates;
92
112
if (!m_raw)
93
- return sampleRates;
113
+ return {};
114
+
115
+ deque<int > sampleRates;
116
+ const int *sampleRatesRaw = nullptr ;
94
117
95
- array_to_container (m_raw->supported_samplerates , sampleRates, [](int sampleRate) {
118
+ #if USE_AVCODEC_GET_SUPPORTED_CONFIG
119
+ avcodec_get_supported_config (nullptr , m_raw, AV_CODEC_CONFIG_SAMPLE_RATE, 0 , reinterpret_cast <const void **>(&sampleRatesRaw), nullptr );
120
+ #else
121
+ sampleRatesRaw = m_raw->supported_samplerates ;
122
+ #endif
123
+
124
+ if (!sampleRatesRaw)
125
+ return {};
126
+
127
+ array_to_container (sampleRatesRaw, sampleRates, [](int sampleRate) {
96
128
return sampleRate == 0 ;
97
129
});
98
130
@@ -101,11 +133,22 @@ std::deque<int> Codec::supportedSamplerates() const
101
133
102
134
std::deque<SampleFormat> Codec::supportedSampleFormats () const
103
135
{
104
- deque<SampleFormat> sampleFmts;
105
136
if (!m_raw)
106
- return sampleFmts ;
137
+ return {} ;
107
138
108
- array_to_container (m_raw->sample_fmts , sampleFmts, [](SampleFormat sampleFmt) {
139
+ deque<SampleFormat> sampleFmts;
140
+ const enum AVSampleFormat *sampleFmtsRaw = nullptr ;
141
+
142
+ #if USE_AVCODEC_GET_SUPPORTED_CONFIG
143
+ avcodec_get_supported_config (nullptr , m_raw, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0 , reinterpret_cast <const void **>(&sampleFmtsRaw), nullptr );
144
+ #else
145
+ sampleFmtsRaw = m_raw->sample_fmts ;
146
+ #endif
147
+
148
+ if (!sampleFmtsRaw)
149
+ return {};
150
+
151
+ array_to_container (sampleFmtsRaw, sampleFmts, [](SampleFormat sampleFmt) {
109
152
return sampleFmt == AV_SAMPLE_FMT_NONE;
110
153
});
111
154
@@ -114,12 +157,24 @@ std::deque<SampleFormat> Codec::supportedSampleFormats() const
114
157
115
158
std::deque<uint64_t > Codec::supportedChannelLayouts () const
116
159
{
117
- deque<uint64_t > channelLayouts;
118
160
if (!m_raw)
119
- return channelLayouts;
161
+ return {};
162
+
163
+ deque<uint64_t > channelLayouts;
120
164
121
165
#if API_NEW_CHANNEL_LAYOUT
122
- array_to_container (m_raw->ch_layouts , channelLayouts, [](auto & layout) {
166
+ const AVChannelLayout *channelLayoutsRaw = nullptr ;
167
+
168
+ #if USE_AVCODEC_GET_SUPPORTED_CONFIG
169
+ avcodec_get_supported_config (nullptr , m_raw, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0 , reinterpret_cast <const void **>(&channelLayoutsRaw), nullptr );
170
+ #else
171
+ channelLayoutsRaw = m_raw->ch_layouts ;
172
+ #endif
173
+
174
+ if (!channelLayoutsRaw)
175
+ return {};
176
+
177
+ array_to_container (channelLayoutsRaw, channelLayouts, [](auto & layout) {
123
178
static const AVChannelLayout zeroed{};
124
179
return !memcmp (&layout, &zeroed, sizeof (zeroed));
125
180
}, [](auto &layout) {
@@ -137,11 +192,19 @@ std::deque<uint64_t> Codec::supportedChannelLayouts() const
137
192
#if API_NEW_CHANNEL_LAYOUT
138
193
std::deque<ChannelLayoutView> Codec::supportedChannelLayouts2 () const
139
194
{
140
- deque<ChannelLayoutView> channelLayouts;
141
195
if (!m_raw)
142
- return channelLayouts;
196
+ return {};
197
+
198
+ deque<ChannelLayoutView> channelLayouts;
199
+ const AVChannelLayout *channelLayoutsRaw = nullptr ;
200
+
201
+ #if USE_AVCODEC_GET_SUPPORTED_CONFIG
202
+ avcodec_get_supported_config (nullptr , m_raw, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0 , reinterpret_cast <const void **>(&channelLayoutsRaw), nullptr );
203
+ #else
204
+ channelLayoutsRaw = m_raw->ch_layouts ;
205
+ #endif
143
206
144
- array_to_container (m_raw-> ch_layouts , channelLayouts, [](const auto & layout) {
207
+ array_to_container (channelLayoutsRaw , channelLayouts, [](const auto & layout) {
145
208
return layout.nb_channels == 0 ;
146
209
});
147
210
0 commit comments