static int compute_mask(int step, uint32_t *mask)

{

    int i, z, ret = 0;

    int counter_size = sizeof(uint32_t) * (2 * step + 1);

    uint32_t *temp1_counter, *temp2_counter, **counter;

    temp1_counter = av_mallocz(counter_size);

    if (!temp1_counter) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    temp2_counter = av_mallocz(counter_size);

    if (!temp2_counter) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    counter = av_mallocz_array(2 * step + 1, sizeof(uint32_t *));

    if (!counter) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    for (i = 0; i < 2 * step + 1; i++) {

        counter[i] = av_mallocz(counter_size);

        if (!counter[i]) {

            ret = AVERROR(ENOMEM);

            goto end;

        }

    }

    for (i = 0; i < 2 * step + 1; i++) {

        memset(temp1_counter, 0, counter_size);

        temp1_counter[i] = 1;

        for (z = 0; z < step * 2; z += 2) {

            add_mask_counter(temp2_counter, counter[z], temp1_counter, step * 2);

            memcpy(counter[z], temp1_counter, counter_size);

            add_mask_counter(temp1_counter, counter[z + 1], temp2_counter, step * 2);

            memcpy(counter[z + 1], temp2_counter, counter_size);

        }

    }

    memcpy(mask, temp1_counter, counter_size);

end:

    av_freep(&temp1_counter);

    av_freep(&temp2_counter);

    for (i = 0; i < 2 * step + 1; i++) {

        av_freep(&counter[i]);

    }

    av_freep(&counter);

    return ret;

}

static int compute_mask(int step, uint32_t *mask)

{

    int i, z, ret = 0;

    int counter_size = sizeof(uint32_t) * (2 * step + 1);

    uint32_t *temp1_counter, *temp2_counter, **counter;

    temp1_counter = av_mallocz(counter_size);

    if (!temp1_counter) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    temp2_counter = av_mallocz(counter_size);

    if (!temp2_counter) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    counter = av_mallocz_array(2 * step + 1, sizeof(uint32_t *));

    if (!counter) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    for (i = 0; i < 2 * step + 1; i++) {

        counter[i] = av_mallocz(counter_size);

        if (!counter[i]) {

            ret = AVERROR(ENOMEM);

            goto end;

        }

    }

    for (i = 0; i < 2 * step + 1; i++) {

        memset(temp1_counter, 0, counter_size);

        temp1_counter[i] = 1;

        for (z = 0; z < step * 2; z += 2) {

            add_mask_counter(temp2_counter, counter[z], temp1_counter, step * 2);

            memcpy(counter[z], temp1_counter, counter_size);

            add_mask_counter(temp1_counter, counter[z + 1], temp2_counter, step * 2);

            memcpy(counter[z + 1], temp2_counter, counter_size);

        }

    }

    memcpy(mask, temp1_counter, counter_size);

end:

    av_freep(&temp1_counter);

    av_freep(&temp2_counter);

    for (i = 0; i < 2 * step + 1; i++) {

        av_freep(&counter[i]);

    }

    av_freep(&counter);

    return ret;

}

    uint32_t *temp1_counter, *temp2_counter, **counter;     for (i = 0; i < 2 * step + 1; i++) {
static int FUNC_0(int VAR_0, uint32_t *VAR_1)

{

    int VAR_2, VAR_3, VAR_4 = 0;

    int VAR_5 = sizeof(uint32_t) * (2 * VAR_0 + 1);

    uint32_t *temp1_counter, *temp2_counter, **counter;

    temp1_counter = av_mallocz(VAR_5);

    if (!temp1_counter) {

        VAR_4 = AVERROR(ENOMEM);

        goto end;

    }

    temp2_counter = av_mallocz(VAR_5);

    if (!temp2_counter) {

        VAR_4 = AVERROR(ENOMEM);

        goto end;

    }

    counter = av_mallocz_array(2 * VAR_0 + 1, sizeof(uint32_t *));

    if (!counter) {

        VAR_4 = AVERROR(ENOMEM);

        goto end;

    }

    for (VAR_2 = 0; VAR_2 < 2 * VAR_0 + 1; VAR_2++) {

        counter[VAR_2] = av_mallocz(VAR_5);

        if (!counter[VAR_2]) {

            VAR_4 = AVERROR(ENOMEM);

            goto end;

        }

    }

    for (VAR_2 = 0; VAR_2 < 2 * VAR_0 + 1; VAR_2++) {

        memset(temp1_counter, 0, VAR_5);

        temp1_counter[VAR_2] = 1;

        for (VAR_3 = 0; VAR_3 < VAR_0 * 2; VAR_3 += 2) {

            add_mask_counter(temp2_counter, counter[VAR_3], temp1_counter, VAR_0 * 2);

            memcpy(counter[VAR_3], temp1_counter, VAR_5);

            add_mask_counter(temp1_counter, counter[VAR_3 + 1], temp2_counter, VAR_0 * 2);

            memcpy(counter[VAR_3 + 1], temp2_counter, VAR_5);

        }

    }

    memcpy(VAR_1, temp1_counter, VAR_5);

end:

    av_freep(&temp1_counter);

    av_freep(&temp2_counter);

    for (VAR_2 = 0; VAR_2 < 2 * VAR_0 + 1; VAR_2++) {

        av_freep(&counter[VAR_2]);

    }

    av_freep(&counter);

    return VAR_4;

}

static int FUNC_0(int VAR_0, uint32_t *VAR_1)
{ int VAR_2, VAR_3, VAR_4 = 0; int VAR_5 = sizeof(uint32_t) * (2 * VAR_0 + 1); uint32_t *temp1_counter, *temp2_counter, **counter; temp1_counter = av_mallocz(VAR_5); if (!temp1_counter) { VAR_4 = AVERROR(ENOMEM); goto end; } temp2_counter = av_mallocz(VAR_5); if (!temp2_counter) { VAR_4 = AVERROR(ENOMEM); goto end; } counter = av_mallocz_array(2 * VAR_0 + 1, sizeof(uint32_t *)); if (!counter) { VAR_4 = AVERROR(ENOMEM); goto end; } for (VAR_2 = 0; VAR_2 < 2 * VAR_0 + 1; VAR_2++) { counter[VAR_2] = av_mallocz(VAR_5); if (!counter[VAR_2]) { VAR_4 = AVERROR(ENOMEM); goto end; } } for (VAR_2 = 0; VAR_2 < 2 * VAR_0 + 1; VAR_2++) { memset(temp1_counter, 0, VAR_5); temp1_counter[VAR_2] = 1; for (VAR_3 = 0; VAR_3 < VAR_0 * 2; VAR_3 += 2) { add_mask_counter(temp2_counter, counter[VAR_3], temp1_counter, VAR_0 * 2); memcpy(counter[VAR_3], temp1_counter, VAR_5); add_mask_counter(temp1_counter, counter[VAR_3 + 1], temp2_counter, VAR_0 * 2); memcpy(counter[VAR_3 + 1], temp2_counter, VAR_5); } } memcpy(VAR_1, temp1_counter, VAR_5); end:
av_freep(&temp1_counter); av_freep(&temp2_counter); for (VAR_2 = 0; VAR_2 < 2 * VAR_0 + 1; VAR_2++) { av_freep(&counter[VAR_2]); } av_freep(&counter); return VAR_4; }