static int on2avc_decode_band_scales(On2AVCContext *c, GetBitContext *gb)

{

    int w, w2, b, scale, first = 1;

    int band_off = 0;



    for (w = 0; w < c->num_windows; w++) {

        if (!c->grouping[w]) {

            memcpy(c->band_scales + band_off,

                   c->band_scales + band_off - c->num_bands,

                   c->num_bands * sizeof(*c->band_scales));

            band_off += c->num_bands;

            continue;

        }

        for (b = 0; b < c->num_bands; b++) {

            if (!c->band_type[band_off]) {

                int all_zero = 1;

                for (w2 = w + 1; w2 < c->num_windows; w2++) {

                    if (c->grouping[w2])

                        break;

                    if (c->band_type[w2 * c->num_bands + b]) {

                        all_zero = 0;

                        break;

                    }

                }

                if (all_zero) {

                    c->band_scales[band_off++] = 0;

                    continue;

                }

            }

            if (first) {

                scale = get_bits(gb, 7);

                first = 0;

            } else {

                scale += get_vlc2(gb, c->scale_diff.table, 9, 3) - 60;

            }

            if (scale < 0 || scale > 128) {

                av_log(c->avctx, AV_LOG_ERROR, "Invalid scale value %d\n",

                       scale);

                return AVERROR_INVALIDDATA;

            }

            c->band_scales[band_off++] = c->scale_tab[scale];

        }

    }



    return 0;

}

static int on2avc_decode_band_scales(On2AVCContext *c, GetBitContext *gb)

{

    int w, w2, b, scale, first = 1;

    int band_off = 0;



    for (w = 0; w < c->num_windows; w++) {

        if (!c->grouping[w]) {

            memcpy(c->band_scales + band_off,

                   c->band_scales + band_off - c->num_bands,

                   c->num_bands * sizeof(*c->band_scales));

            band_off += c->num_bands;

            continue;

        }

        for (b = 0; b < c->num_bands; b++) {

            if (!c->band_type[band_off]) {

                int all_zero = 1;

                for (w2 = w + 1; w2 < c->num_windows; w2++) {

                    if (c->grouping[w2])

                        break;

                    if (c->band_type[w2 * c->num_bands + b]) {

                        all_zero = 0;

                        break;

                    }

                }

                if (all_zero) {

                    c->band_scales[band_off++] = 0;

                    continue;

                }

            }

            if (first) {

                scale = get_bits(gb, 7);

                first = 0;

            } else {

                scale += get_vlc2(gb, c->scale_diff.table, 9, 3) - 60;

            }

            if (scale < 0 || scale > 128) {

                av_log(c->avctx, AV_LOG_ERROR, "Invalid scale value %d\n",

                       scale);

                return AVERROR_INVALIDDATA;

            }

            c->band_scales[band_off++] = c->scale_tab[scale];

        }

    }



    return 0;

}

static int FUNC_0(On2AVCContext *VAR_0, GetBitContext *VAR_1)

{

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6 = 1;

    int VAR_7 = 0;



    for (VAR_2 = 0; VAR_2 < VAR_0->num_windows; VAR_2++) {

        if (!VAR_0->grouping[VAR_2]) {

            memcpy(VAR_0->band_scales + VAR_7,

                   VAR_0->band_scales + VAR_7 - VAR_0->num_bands,

                   VAR_0->num_bands * sizeof(*VAR_0->band_scales));

            VAR_7 += VAR_0->num_bands;

            continue;

        }

        for (VAR_4 = 0; VAR_4 < VAR_0->num_bands; VAR_4++) {

            if (!VAR_0->band_type[VAR_7]) {

                int all_zero = 1;

                for (VAR_3 = VAR_2 + 1; VAR_3 < VAR_0->num_windows; VAR_3++) {

                    if (VAR_0->grouping[VAR_3])

                        break;

                    if (VAR_0->band_type[VAR_3 * VAR_0->num_bands + VAR_4]) {

                        all_zero = 0;

                        break;

                    }

                }

                if (all_zero) {

                    VAR_0->band_scales[VAR_7++] = 0;

                    continue;

                }

            }

            if (VAR_6) {

                VAR_5 = get_bits(VAR_1, 7);

                VAR_6 = 0;

            } else {

                VAR_5 += get_vlc2(VAR_1, VAR_0->scale_diff.table, 9, 3) - 60;

            }

            if (VAR_5 < 0 || VAR_5 > 128) {

                av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid VAR_5 value %d\n",

                       VAR_5);

                return AVERROR_INVALIDDATA;

            }

            VAR_0->band_scales[VAR_7++] = VAR_0->scale_tab[VAR_5];

        }

    }



    return 0;

}

static int FUNC_0(On2AVCContext *VAR_0, GetBitContext *VAR_1)
{ int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6 = 1; int VAR_7 = 0; for (VAR_2 = 0; VAR_2 < VAR_0->num_windows; VAR_2++) { if (!VAR_0->grouping[VAR_2]) { memcpy(VAR_0->band_scales + VAR_7,
VAR_0->band_scales + VAR_7 - VAR_0->num_bands,
VAR_0->num_bands * sizeof(*VAR_0->band_scales)); VAR_7 += VAR_0->num_bands; continue; } for (VAR_4 = 0; VAR_4 < VAR_0->num_bands; VAR_4++) { if (!VAR_0->band_type[VAR_7]) { int all_zero = 1; for (VAR_3 = VAR_2 + 1; VAR_3 < VAR_0->num_windows; VAR_3++) { if (VAR_0->grouping[VAR_3])
break; if (VAR_0->band_type[VAR_3 * VAR_0->num_bands + VAR_4]) { all_zero = 0; break; } } if (all_zero) { VAR_0->band_scales[VAR_7++] = 0; continue; } } if (VAR_6) { VAR_5 = get_bits(VAR_1, 7); VAR_6 = 0; } else { VAR_5 += get_vlc2(VAR_1, VAR_0->scale_diff.table, 9, 3) - 60; } if (VAR_5 < 0 || VAR_5 > 128) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid VAR_5 value %d\n",
VAR_5); return AVERROR_INVALIDDATA; } VAR_0->band_scales[VAR_7++] = VAR_0->scale_tab[VAR_5]; } } return 0; }