The branch, master has been updated
via 1120b3db302165d7ed40df1473e6ae84db61c0f8 (commit)
from 0eb572f080176151154380b17335bbb96ceba9db (commit)
- Log -----------------------------------------------------------------
commit 1120b3db302165d7ed40df1473e6ae84db61c0f8
Author: cenzhanquan1 <[email protected]>
AuthorDate: Mon Oct 20 12:04:01 2025 +0800
Commit: cenzhanquan1 <[email protected]>
CommitDate: Thu Oct 23 14:42:50 2025 +0000
avcodec/liblc3enc: support packed float (AV_SAMPLE_FMT_FLT) input.
Previously, the LC3 encoder only accepted planar float (AV_SAMPLE_FMT_FLTP).
This change extends support to packed float (AV_SAMPLE_FMT_FLT) by properly
handling channel layout and sample stride.
The pcm data pointer and stride are now calculated based on the sample
format: for planar, use frame->data[ch]; for packed, use frame->data[0]
with channel offset. The stride is set to 1 for planar and number of
channels for packed layout.
This enables encoding from common packed audio sources without requiring
a prior planar conversion, improving usability and efficiency.
Signed-off-by: cenzhanquan1 <[email protected]>
diff --git a/libavcodec/liblc3enc.c b/libavcodec/liblc3enc.c
index 72c117b993..8bdf6bd5d8 100644
--- a/libavcodec/liblc3enc.c
+++ b/libavcodec/liblc3enc.c
@@ -138,8 +138,13 @@ static int liblc3_encode(AVCodecContext *avctx, AVPacket
*pkt,
int block_bytes = liblc3->block_bytes;
int channels = avctx->ch_layout.nb_channels;
uint8_t *data_ptr;
+ size_t sample_size;
+ int is_planar;
int ret;
+ is_planar = av_sample_fmt_is_planar(avctx->sample_fmt);
+ sample_size = av_get_bytes_per_sample(avctx->sample_fmt);
+
if ((ret = ff_get_encode_buffer(avctx, pkt, block_bytes, 0)) < 0)
return ret;
@@ -155,10 +160,15 @@ static int liblc3_encode(AVCodecContext *avctx, AVPacket
*pkt,
data_ptr = pkt->data;
for (int ch = 0; ch < channels; ch++) {
- const float *pcm = frame ? (const float*)frame->data[ch] : (const
float[]){ 0 };
- int stride = !!frame; // use a stride of zero to send a zero frame
int nbytes = block_bytes / channels + (ch < block_bytes % channels);
+ const void *pcm = frame ?
+ (is_planar ? frame->data[ch] :
+ frame->data[0] + ch * sample_size) :
+ (const void *)(const float[]){ 0 };
+
+ int stride = frame ? (is_planar ? 1 : channels) : 0;
+
lc3_encode(liblc3->encoder[ch],
LC3_PCM_FORMAT_FLOAT, pcm, stride, nbytes, data_ptr);
@@ -198,7 +208,7 @@ const FFCodec ff_liblc3_encoder = {
.p.priv_class = &class,
.p.wrapper_name = "liblc3",
CODEC_SAMPLERATES(96000, 48000, 32000, 24000, 16000, 8000),
- CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP),
+ CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT),
.priv_data_size = sizeof(LibLC3EncContext),
.init = liblc3_encode_init,
.close = liblc3_encode_close,
-----------------------------------------------------------------------
Summary of changes:
libavcodec/liblc3enc.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
hooks/post-receive
--
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]