PR #23758 opened by caozilong1
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23758
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23758.patch

Both encoders accept only a single sample rate (8000/16000 Hz) and mono,
and error out on anything else at init. Advertise these via
supported_samplerates and ch_layouts so callers can query them and pick a
valid configuration before opening the encoder.

Signed-off-by: caozilong1 <[email protected]>

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 59496387a9bcc1a7455fc6d9bc420a349d9ce3ac Mon Sep 17 00:00:00 2001
From: caozilong1 <[email protected]>
Date: Thu, 9 Jul 2026 21:49:08 +0800
Subject: [PATCH] avcodec/libopencore-amr, libvo-amrwbenc: declare supported
 samplerates and channel layouts

Both encoders accept only a single sample rate (8000/16000 Hz) and mono,
and error out on anything else at init. Advertise these via
supported_samplerates and ch_layouts so callers can query them and pick a
valid configuration before opening the encoder.

Signed-off-by: caozilong1 <[email protected]>
---
 libavcodec/libopencore-amr.c | 2 ++
 libavcodec/libvo-amrwbenc.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c
index 95c7b9b137..c14d484628 100644
--- a/libavcodec/libopencore-amr.c
+++ b/libavcodec/libopencore-amr.c
@@ -303,6 +303,8 @@ const FFCodec ff_libopencore_amrnb_encoder = {
     FF_CODEC_ENCODE_CB(amr_nb_encode_frame),
     .close          = amr_nb_encode_close,
     CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_S16),
+    CODEC_SAMPLERATES(8000),
+    CODEC_CH_LAYOUTS(AV_CHANNEL_LAYOUT_MONO),
     .p.priv_class   = &amrnb_class,
 };
 #endif /* CONFIG_LIBOPENCORE_AMRNB_ENCODER */
diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c
index c68b66fc43..394d16d71c 100644
--- a/libavcodec/libvo-amrwbenc.c
+++ b/libavcodec/libvo-amrwbenc.c
@@ -154,4 +154,6 @@ const FFCodec ff_libvo_amrwbenc_encoder = {
     FF_CODEC_ENCODE_CB(amr_wb_encode_frame),
     .close          = amr_wb_encode_close,
     CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_S16),
+    CODEC_SAMPLERATES(16000),
+    CODEC_CH_LAYOUTS(AV_CHANNEL_LAYOUT_MONO),
 };
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to