[PATCH 07/18] libmpcodecs/ae_lavc: AVCodec no longer has sample_fmts
Nicolas George <[email protected]> Tue, 28 Jul 2026 20:15:03 +0200
| Newsgroups | gmane.comp.video.mplayer.devel |
|---|---|
| Message-ID | <[email protected]> |
---
libmpcodecs/ae_lavc.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/libmpcodecs/ae_lavc.c b/libmpcodecs/ae_lavc.c
index a9f49d009..6c75be168 100644
--- a/libmpcodecs/ae_lavc.c
+++ b/libmpcodecs/ae_lavc.c
@@ -140,6 +140,10 @@ static int get_frame_size(audio_encoder_t *encoder)
int mpae_init_lavc(audio_encoder_t *encoder)
{
+ const enum AVSampleFormat *sample_fmts;
+ int num_sample_fmts;
+ int ret;
+
encoder->params.samples_per_frame = encoder->params.sample_rate;
encoder->params.bitrate = encoder->params.sample_rate * encoder->params.channels * 2 * 8;
@@ -177,10 +181,15 @@ int mpae_init_lavc(audio_encoder_t *encoder)
lavc_actx->codec_id = lavc_acodec->id;
// put sample parameters
lavc_actx->sample_fmt = AV_SAMPLE_FMT_S16;
- if (lavc_acodec->sample_fmts) {
+
+ ret = avcodec_get_supported_config(lavc_actx, NULL, AV_CODEC_CONFIG_SAMPLE_FORMAT,
+ 0, (const void **) &sample_fmts, &num_sample_fmts);
+ if (ret < 0)
+ return 0;
+ if (sample_fmts) {
const enum AVSampleFormat *fmts;
- lavc_actx->sample_fmt = lavc_acodec->sample_fmts[0]; // fallback to first format
- for (fmts = lavc_acodec->sample_fmts; *fmts != AV_SAMPLE_FMT_NONE; fmts++) {
+ lavc_actx->sample_fmt = sample_fmts[0]; // fallback to first format
+ for (fmts = sample_fmts; fmts < sample_fmts + num_sample_fmts; fmts++) {
if (samplefmt2affmt(av_get_packed_sample_fmt(*fmts)) == encoder->params.sample_format) { // preferred format found
lavc_actx->sample_fmt = *fmts;
break;
--
2.53.0
_______________________________________________
MPlayer-dev-eng mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo/%(_internal_name)s