static int read_channels(AVFilterContext *ctx, int channels, uint8_t *item_str, int *nb, double **c, double **cache)
{
    char *p, *arg, *old_str, *prev_arg = NULL, *saveptr = NULL;
    int i, ret;

    p = old_str = av_strdup(item_str);
    if (!p)
        return AVERROR(ENOMEM);
    for (i = 0; i < channels; i++) {
        if (!(arg = av_strtok(p, "|", &saveptr)))
            arg = prev_arg;

        if (!arg)
            return AVERROR(EINVAL);

        count_coefficients(arg, &nb[i]);

        p = NULL;
        cache[i] = av_calloc(nb[i] + 1, sizeof(double));
        c[i] = av_calloc(nb[i], sizeof(double));
        if (!c[i] || !cache[i])
            return AVERROR(ENOMEM);

        ret = read_coefficients(ctx, arg, nb[i], c[i]);
        if (ret < 0)
            return ret;
        prev_arg = arg;
    }

    av_freep(&old_str);

    return 0;
}