avgetbytespersample
av_get_bytes_per_sample is a helper function in FFmpeg’s libavutil that returns the number of bytes required to store a single sample for a given AVSampleFormat. It is commonly used when allocating or processing audio buffers to understand how much memory one sample occupies per channel.
The function signature is int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt). It returns the number of bytes per sample
Typical results are as follows: AV_SAMPLE_FMT_U8 and AV_SAMPLE_FMT_U8P yield 1 byte per sample; AV_SAMPLE_FMT_S16 and AV_SAMPLE_FMT_S16P
In practice, the value is used to compute total buffer sizes. For example, total_bytes = frames_per_channel * channels