@@ -182,56 +182,74 @@ def id(self):
182182 @property
183183 def frame_rates (self ):
184184 """A list of supported frame rates (:class:`fractions.Fraction`), or ``None``."""
185- if not self .ptr .supported_framerates :
185+ out : cython .p_void = cython .NULL
186+ num : cython .int = 0
187+ lib .avcodec_get_supported_config (
188+ cython .NULL ,
189+ self .ptr ,
190+ lib .AV_CODEC_CONFIG_FRAME_RATE ,
191+ 0 ,
192+ cython .address (out ),
193+ cython .address (num ),
194+ )
195+ if not out :
186196 return
187-
188- ret : list = []
189- i : cython .int = 0
190- while self .ptr .supported_framerates [i ].denum :
191- ret .append (
192- avrational_to_fraction (cython .address (self .ptr .supported_framerates [i ]))
193- )
194- i += 1
195- return ret
197+ rates = cython .cast (cython .pointer [lib .AVRational ], out )
198+ return [avrational_to_fraction (cython .address (rates [i ])) for i in range (num )]
196199
197200 @property
198201 def audio_rates (self ):
199202 """A list of supported audio sample rates (``int``), or ``None``."""
200- if not self .ptr .supported_samplerates :
203+ out : cython .p_void = cython .NULL
204+ num : cython .int = 0
205+ lib .avcodec_get_supported_config (
206+ cython .NULL ,
207+ self .ptr ,
208+ lib .AV_CODEC_CONFIG_SAMPLE_RATE ,
209+ 0 ,
210+ cython .address (out ),
211+ cython .address (num ),
212+ )
213+ if not out :
201214 return
202-
203- ret : list = []
204- i : cython .int = 0
205- while self .ptr .supported_samplerates [i ]:
206- ret .append (self .ptr .supported_samplerates [i ])
207- i += 1
208- return ret
215+ rates = cython .cast (cython .pointer [cython .int ], out )
216+ return [rates [i ] for i in range (num )]
209217
210218 @property
211219 def video_formats (self ):
212220 """A list of supported :class:`.VideoFormat`, or ``None``."""
213- if not self .ptr .pix_fmts :
221+ out : cython .p_void = cython .NULL
222+ num : cython .int = 0
223+ lib .avcodec_get_supported_config (
224+ cython .NULL ,
225+ self .ptr ,
226+ lib .AV_CODEC_CONFIG_PIX_FORMAT ,
227+ 0 ,
228+ cython .address (out ),
229+ cython .address (num ),
230+ )
231+ if not out :
214232 return
215-
216- ret : list = []
217- i : cython .int = 0
218- while self .ptr .pix_fmts [i ] != - 1 :
219- ret .append (get_video_format (self .ptr .pix_fmts [i ], 0 , 0 ))
220- i += 1
221- return ret
233+ fmts = cython .cast (cython .pointer [lib .AVPixelFormat ], out )
234+ return [get_video_format (fmts [i ], 0 , 0 ) for i in range (num )]
222235
223236 @property
224237 def audio_formats (self ):
225238 """A list of supported :class:`.AudioFormat`, or ``None``."""
226- if not self .ptr .sample_fmts :
239+ out : cython .p_void = cython .NULL
240+ num : cython .int = 0
241+ lib .avcodec_get_supported_config (
242+ cython .NULL ,
243+ self .ptr ,
244+ lib .AV_CODEC_CONFIG_SAMPLE_FORMAT ,
245+ 0 ,
246+ cython .address (out ),
247+ cython .address (num ),
248+ )
249+ if not out :
227250 return
228-
229- ret : list = []
230- i : cython .int = 0
231- while self .ptr .sample_fmts [i ] != - 1 :
232- ret .append (get_audio_format (self .ptr .sample_fmts [i ]))
233- i += 1
234- return ret
251+ fmts = cython .cast (cython .pointer [lib .AVSampleFormat ], out )
252+ return [get_audio_format (fmts [i ]) for i in range (num )]
235253
236254 @property
237255 def hardware_configs (self ):
0 commit comments