static int on2avc_decode_subframe(On2AVCContext *c, const uint8_t *buf,
                                  int buf_size, AVFrame *dst, int offset)
{
    GetBitContext gb;
    int i, ret;
    init_get_bits(&gb, buf, buf_size * 8);
    if (get_bits1(&gb)) {
        av_log(c->avctx, AV_LOG_ERROR, "enh bit set\n");
        return AVERROR_INVALIDDATA;
    }
    c->prev_window_type = c->window_type;
    c->window_type      = get_bits(&gb, 3);
    if (c->window_type >= WINDOW_TYPE_EXT4 && c->avctx->channels == 1) {
        av_log(c->avctx, AV_LOG_ERROR, "stereo mode window for mono audio\n");
        return AVERROR_INVALIDDATA;
    }
    c->band_start  = c->modes[c->window_type].band_start;
    c->num_windows = c->modes[c->window_type].num_windows;
    c->num_bands   = c->modes[c->window_type].num_bands;
    c->is_long     = (c->window_type != WINDOW_TYPE_8SHORT);
    c->grouping[0] = 1;
    for (i = 1; i < c->num_windows; i++)
        c->grouping[i] = !get_bits1(&gb);
    on2avc_read_ms_info(c, &gb);
    for (i = 0; i < c->avctx->channels; i++)
        if ((ret = on2avc_read_channel_data(c, &gb, i)) < 0)
            return AVERROR_INVALIDDATA;
    if (c->avctx->channels == 2 && c->ms_present)
        on2avc_apply_ms(c);
    if (c->window_type < WINDOW_TYPE_EXT4) {
        for (i = 0; i < c->avctx->channels; i++)
            on2avc_reconstruct_channel(c, i, dst, offset);
    } else {
        on2avc_reconstruct_stereo(c, dst, offset);
    }
    return 0;
}
['static int on2avc_decode_subframe(On2AVCContext *c, const uint8_t *buf,\n                                  int buf_size, AVFrame *dst, int offset)\n{\n    GetBitContext gb;\n    int i, ret;\n    init_get_bits(&gb, buf, buf_size * 8);\n    if (get_bits1(&gb)) {\n        av_log(c->avctx, AV_LOG_ERROR, "enh bit set\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    c->prev_window_type = c->window_type;\n    c->window_type      = get_bits(&gb, 3);\n    if (c->window_type >= WINDOW_TYPE_EXT4 && c->avctx->channels == 1) {\n        av_log(c->avctx, AV_LOG_ERROR, "stereo mode window for mono audio\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    c->band_start  = c->modes[c->window_type].band_start;\n    c->num_windows = c->modes[c->window_type].num_windows;\n    c->num_bands   = c->modes[c->window_type].num_bands;\n    c->is_long     = (c->window_type != WINDOW_TYPE_8SHORT);\n    c->grouping[0] = 1;\n    for (i = 1; i < c->num_windows; i++)\n        c->grouping[i] = !get_bits1(&gb);\n    on2avc_read_ms_info(c, &gb);\n    for (i = 0; i < c->avctx->channels; i++)\n        if ((ret = on2avc_read_channel_data(c, &gb, i)) < 0)\n            return AVERROR_INVALIDDATA;\n    if (c->avctx->channels == 2 && c->ms_present)\n        on2avc_apply_ms(c);\n    if (c->window_type < WINDOW_TYPE_EXT4) {\n        for (i = 0; i < c->avctx->channels; i++)\n            on2avc_reconstruct_channel(c, i, dst, offset);\n    } else {\n        on2avc_reconstruct_stereo(c, dst, offset);\n    }\n    return 0;\n}', 'static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                int bit_size)\n{\n    int buffer_size;\n    int ret = 0;\n    if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {\n        bit_size    = 0;\n        buffer      = NULL;\n        ret         = AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    s->buffer             = buffer;\n    s->size_in_bits       = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end         = buffer + buffer_size;\n    s->index              = 0;\n    return ret;\n}', 'static inline unsigned int get_bits1(GetBitContext *s)\n{\n    unsigned int index = s->index;\n    uint8_t result     = s->buffer[index >> 3];\n#ifdef BITSTREAM_READER_LE\n    result >>= index & 7;\n    result  &= 1;\n#else\n    result <<= index & 7;\n    result >>= 8 - 1;\n#endif\n#if !UNCHECKED_BITSTREAM_READER\n    if (s->index < s->size_in_bits_plus8)\n#endif\n        index++;\n    s->index = index;\n    return result;\n}']