[FFmpeg-devel] [PATCH 1/7] avcodec/pcm: Remove always-false check

Ramiro Polla ramiro.polla at gmail.com
Sat Mar 15 04:14:54 EET 2025


On 3/13/25 06:49, Andreas Rheinhardt wrote:
> Patches attached.


[PATCH 2/7] avcodec/pcm: Cache sample_size value

> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index 5d8dcb8ff0..620acf0f46 100644
> --- a/libavcodec/pcm.c
> +++ b/libavcodec/pcm.c
> @@ -328,17 +335,14 @@ static int pcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
>      int buf_size       = avpkt->size;
>      PCMDecode *s       = avctx->priv_data;
>      int channels       = avctx->ch_layout.nb_channels;
> -    int sample_size, c, n, ret, samples_per_block;
> +    int sample_size = s->sample_size, c, n, ret, samples_per_block;
>      uint8_t *samples;
>      int32_t *dst_int32_t;

Could you put sample_size on its own line? It gets a little confusing 
with the first variable being initialized, but the subsequent variables 
being uninitialized.


[PATCH 3/7] avcodec/pcm: Remove duplication from FFCodec define macros

> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index 620acf0f46..6c1feecca3 100644
> --- a/libavcodec/pcm.c
> +++ b/libavcodec/pcm.c
[...]
> +//       AV_CODEC_ID_*       pcm_* name
> +//                 AV_SAMPLE_FMT_*               long name
> +PCM_CODEC  (ALAW,         S16, alaw,         "PCM A-law / G.711 A-law");
> +PCM_DECODER(F16LE,        FLT, f16le,        "PCM 16.8 floating point little-endian");

The labels don't align with the fields.

And in the next patch ([PATCH 4/7] avcodec/pcm: Don't allocate LUT when 
unused), with the introduction of PCM_CODEC_EXT(), the alignment of 
PCM_CODEC/PCM_DECODER/PCM_CODEC_EXT is lost.

Ramiro



More information about the ffmpeg-devel mailing list