Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8a5e1e2 authored by Antoine Soulier's avatar Antoine Soulier Committed by Jakub Pawlowski
Browse files

Rename `pitch` to `stride`, that is more common audio vocabulary

Test: compilation
Bug: 150670922
Change-Id: I93806d545ae2a3894124a765e996a8b6dc95f5db
parent 65034755
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -245,13 +245,13 @@ lc3_encoder_t lc3_setup_encoder(
 * Encode a frame
 * encoder         Handle of the encoder
 * fmt             PCM input format
 * pcm, pitch      Input PCM samples, and count between two consecutives
 * pcm, stride     Input PCM samples, and count between two consecutives
 * nbytes          Target size, in bytes, of the frame (20 to 400)
 * out             Output buffer of `nbytes` size
 * return          0: On success  -1: Wrong parameters
 */
int lc3_encode(lc3_encoder_t encoder,
    enum lc3_pcm_format fmt, const void *pcm, int pitch, int nbytes, void *out);
int lc3_encode(lc3_encoder_t encoder, enum lc3_pcm_format fmt,
    const void *pcm, int stride, int nbytes, void *out);

/**
 * Return size needed for an decoder
@@ -286,11 +286,11 @@ lc3_decoder_t lc3_setup_decoder(
 * decoder         Handle of the decoder
 * in, nbytes      Input bitstream, and size in bytes, NULL performs PLC
 * fmt             PCM output format
 * pcm, pitch      Output PCM samples, and count between two consecutives
 * pcm, stride     Output PCM samples, and count between two consecutives
 * return          0: On success  1: PLC operated  -1: Wrong parameters
 */
int lc3_decode(lc3_decoder_t decoder,
    const void *in, int nbytes, enum lc3_pcm_format fmt, void *pcm, int pitch);
int lc3_decode(lc3_decoder_t decoder, const void *in, int nbytes,
    enum lc3_pcm_format fmt, void *pcm, int stride);


#ifdef __cplusplus
+18 −18
Original line number Diff line number Diff line
@@ -147,10 +147,10 @@ int lc3_delay_samples(int dt_us, int sr_hz)
/**
 * Input PCM Samples from signed 16 bits
 * encoder         Encoder state
 * pcm, pitch      Input PCM samples, and count between two consecutives
 * pcm, stride     Input PCM samples, and count between two consecutives
 */
static void load_s16(
    struct lc3_encoder *encoder, const void *_pcm, int pitch)
    struct lc3_encoder *encoder, const void *_pcm, int stride)
{
    const int16_t *pcm = _pcm;

@@ -160,16 +160,16 @@ static void load_s16(
    int ns = LC3_NS(dt, sr);

    for (int i = 0; i < ns; i++)
        xs[i] = pcm[i*pitch];
        xs[i] = pcm[i*stride];
}

/**
 * Input PCM Samples from signed 24 bits
 * encoder         Encoder state
 * pcm, pitch      Input PCM samples, and count between two consecutives
 * pcm, stride     Input PCM samples, and count between two consecutives
 */
static void load_s24(
    struct lc3_encoder *encoder, const void *_pcm, int pitch)
    struct lc3_encoder *encoder, const void *_pcm, int stride)
{
    const int32_t *pcm = _pcm;

@@ -179,7 +179,7 @@ static void load_s24(
    int ns = LC3_NS(dt, sr);

    for (int i = 0; i < ns; i++)
        xs[i] = ldexpf(pcm[i*pitch], -8);
        xs[i] = ldexpf(pcm[i*stride], -8);
}

/**
@@ -316,8 +316,8 @@ struct lc3_encoder *lc3_setup_encoder(
/**
 * Encode a frame
 */
int lc3_encode(struct lc3_encoder *encoder,
    enum lc3_pcm_format fmt, const void *pcm, int pitch, int nbytes, void *out)
int lc3_encode(struct lc3_encoder *encoder, enum lc3_pcm_format fmt,
    const void *pcm, int stride, int nbytes, void *out)
{
    static void (* const load[])(struct lc3_encoder *, const void *, int) = {
        [LC3_PCM_FORMAT_S16] = load_s16,
@@ -335,7 +335,7 @@ int lc3_encode(struct lc3_encoder *encoder,
    struct side_data side;
    int16_t xq[LC3_NE(encoder->dt, encoder->sr)];

    load[fmt](encoder, pcm, pitch);
    load[fmt](encoder, pcm, stride);

    analyze(encoder, nbytes, &side, xq);

@@ -352,10 +352,10 @@ int lc3_encode(struct lc3_encoder *encoder,
/**
 * Output PCM Samples to signed 16 bits
 * decoder         Decoder state
 * pcm, pitch      Output PCM samples, and count between two consecutives
 * pcm, stride     Output PCM samples, and count between two consecutives
 */
static void store_s16(
    struct lc3_decoder *decoder, void *_pcm, int pitch)
    struct lc3_decoder *decoder, void *_pcm, int stride)
{
    int16_t *pcm = _pcm;

@@ -364,7 +364,7 @@ static void store_s16(
    float *xs = decoder->xs;
    int ns = LC3_NS(dt, sr);

    for ( ; ns > 0; ns--, xs++, pcm += pitch) {
    for ( ; ns > 0; ns--, xs++, pcm += stride) {
        int s = *xs >= 0 ? (int)(*xs + 0.5f) : (int)(*xs - 0.5f);
        *pcm = LC3_CLIP(s, INT16_MIN, INT16_MAX);
    }
@@ -373,10 +373,10 @@ static void store_s16(
/**
 * Output PCM Samples to signed 24 bits
 * decoder         Decoder state
 * pcm, pitch      Output PCM samples, and count between two consecutives
 * pcm, stride     Output PCM samples, and count between two consecutives
 */
static void store_s24(
    struct lc3_decoder *decoder, void *_pcm, int pitch)
    struct lc3_decoder *decoder, void *_pcm, int stride)
{
    int32_t *pcm = _pcm;
    const int32_t int24_max =  (1 << 23) - 1;
@@ -387,7 +387,7 @@ static void store_s24(
    float *xs = decoder->xs;
    int ns = LC3_NS(dt, sr);

    for ( ; ns > 0; ns--, xs++, pcm += pitch) {
    for ( ; ns > 0; ns--, xs++, pcm += stride) {
        int32_t s = *xs >= 0 ? (int32_t)(ldexpf(*xs, 8) + 0.5f)
                             : (int32_t)(ldexpf(*xs, 8) - 0.5f);
        *pcm = LC3_CLIP(s, int24_min, int24_max);
@@ -536,8 +536,8 @@ struct lc3_decoder *lc3_setup_decoder(
/**
 * Decode a frame
 */
int lc3_decode(struct lc3_decoder *decoder,
    const void *in, int nbytes, enum lc3_pcm_format fmt, void *pcm, int pitch)
int lc3_decode(struct lc3_decoder *decoder, const void *in, int nbytes,
    enum lc3_pcm_format fmt, void *pcm, int stride)
{
    static void (* const store[])(struct lc3_decoder *, void *, int) = {
        [LC3_PCM_FORMAT_S16] = store_s16,
@@ -561,7 +561,7 @@ int lc3_decode(struct lc3_decoder *decoder,

    synthesize(decoder, ret ? NULL : &side, nbytes);

    store[fmt](decoder, pcm, pitch);
    store[fmt](decoder, pcm, stride);

    return ret;
}