This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit ba1aea762b105edc023ed9783466b159612eb66c
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Sat Nov 22 23:56:14 2025 +0100
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Thu Jan 29 14:08:15 2026 +0100

    avcodec/liblc3{dec,enc}: Simplify sample_size, is_planar check
    
    Sample size is always sizeof(float), is planar is a simple if
    given that these codecs only support float and planar float.
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/liblc3dec.c |  9 +++------
 libavcodec/liblc3enc.c | 15 ++++++---------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/libavcodec/liblc3dec.c b/libavcodec/liblc3dec.c
index 293325ba2b..a0989c88b0 100644
--- a/libavcodec/liblc3dec.c
+++ b/libavcodec/liblc3dec.c
@@ -123,8 +123,6 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame 
*frame,
     int channels = avctx->ch_layout.nb_channels;
     uint8_t *in = avpkt->data;
     int block_bytes, ret;
-    size_t sample_size;
-    int is_planar;
 
     frame->nb_samples = av_rescale(
         liblc3->frame_us, liblc3->srate_hz, 1000*1000);
@@ -132,13 +130,12 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame 
*frame,
         return ret;
 
     block_bytes = avpkt->size;
-    is_planar = av_sample_fmt_is_planar(avctx->sample_fmt);
-    sample_size = av_get_bytes_per_sample(avctx->sample_fmt);
+    int is_planar = avctx->sample_fmt == AV_SAMPLE_FMT_FLTP;
 
     for (int ch = 0; ch < channels; ch++) {
         int nbytes = block_bytes / channels + (ch < block_bytes % channels);
-        void *pcm_data = is_planar ? frame->extended_data[ch] :
-                                frame->extended_data[0] + ch * sample_size;
+        float *pcm_data = is_planar ? (float*)frame->extended_data[ch] :
+                                      (float*)frame->extended_data[0] + ch;
         int stride = is_planar ? 1 : channels;
 
         ret = lc3_decode(liblc3->decoder[ch], in, nbytes,
diff --git a/libavcodec/liblc3enc.c b/libavcodec/liblc3enc.c
index 8bdf6bd5d8..e64963b457 100644
--- a/libavcodec/liblc3enc.c
+++ b/libavcodec/liblc3enc.c
@@ -138,13 +138,8 @@ 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;
 
@@ -158,14 +153,16 @@ static int liblc3_encode(AVCodecContext *avctx, AVPacket 
*pkt,
         liblc3->remaining_samples = 0;
     }
 
+    int is_planar = avctx->sample_fmt == AV_SAMPLE_FMT_FLTP;
+
     data_ptr = pkt->data;
     for (int ch = 0; ch < channels; ch++) {
         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 };
+        const float *pcm = frame ?
+                    (is_planar ? (const float*)frame->data[ch] :
+                    (const float*)frame->data[0] + ch) :
+                    (const float[]){ 0 };
 
         int stride = frame ? (is_planar ? 1 : channels) : 0;
 

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

Reply via email to