static int on2avc_read_channel_data(On2AVCContext *c, BitstreamContext *bc, int ch)
{
    int ret;
    int w, b, band_idx;
    float *coeff_ptr;
    if ((ret = on2avc_decode_band_types(c, bc)) < 0)
        return ret;
    if ((ret = on2avc_decode_band_scales(c, bc)) < 0)
        return ret;
    coeff_ptr = c->coeffs[ch];
    band_idx  = 0;
    memset(coeff_ptr, 0, ON2AVC_SUBFRAME_SIZE * sizeof(*coeff_ptr));
    for (w = 0; w < c->num_windows; w++) {
        for (b = 0; b < c->num_bands; b++) {
            int band_size = c->band_start[b + 1] - c->band_start[b];
            int band_type = c->band_type[band_idx + b];
            if (!band_type) {
                coeff_ptr += band_size;
                continue;
            }
            if (band_type < 9)
                on2avc_decode_quads(c, bc, coeff_ptr, band_size, band_type,
                                    c->band_scales[band_idx + b]);
            else
                on2avc_decode_pairs(c, bc, coeff_ptr, band_size, band_type,
                                    c->band_scales[band_idx + b]);
            coeff_ptr += band_size;
        }
        band_idx += c->num_bands;
    }
    return 0;
}
['static int on2avc_decode_frame(AVCodecContext * avctx, void *data,\n                               int *got_frame_ptr, AVPacket *avpkt)\n{\n    AVFrame *frame     = data;\n    const uint8_t *buf = avpkt->data;\n    int buf_size       = avpkt->size;\n    On2AVCContext *c   = avctx->priv_data;\n    GetByteContext gb;\n    int num_frames = 0, frame_size, audio_off;\n    int ret;\n    if (c->is_av500) {\n        frame->nb_samples = ON2AVC_SUBFRAME_SIZE;\n        if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {\n            av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n            return ret;\n        }\n        if ((ret = on2avc_decode_subframe(c, buf, buf_size, frame, 0)) < 0)\n            return ret;\n    } else {\n        bytestream2_init(&gb, buf, buf_size);\n        while (bytestream2_get_bytes_left(&gb) > 2) {\n            frame_size = bytestream2_get_le16(&gb);\n            if (!frame_size || frame_size > bytestream2_get_bytes_left(&gb)) {\n                av_log(avctx, AV_LOG_ERROR, "Invalid subframe size %d\\n",\n                       frame_size);\n                return AVERROR_INVALIDDATA;\n            }\n            num_frames++;\n            bytestream2_skip(&gb, frame_size);\n        }\n        if (!num_frames) {\n            av_log(avctx, AV_LOG_ERROR, "No subframes present\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        frame->nb_samples = ON2AVC_SUBFRAME_SIZE * num_frames;\n        if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {\n            av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n            return ret;\n        }\n        audio_off = 0;\n        bytestream2_init(&gb, buf, buf_size);\n        while (bytestream2_get_bytes_left(&gb) > 2) {\n            frame_size = bytestream2_get_le16(&gb);\n            if ((ret = on2avc_decode_subframe(c, gb.buffer, frame_size,\n                                              frame, audio_off)) < 0)\n                return ret;\n            audio_off += ON2AVC_SUBFRAME_SIZE;\n            bytestream2_skip(&gb, frame_size);\n        }\n    }\n    *got_frame_ptr = 1;\n    return buf_size;\n}', 'static int on2avc_decode_subframe(On2AVCContext *c, const uint8_t *buf,\n                                  int buf_size, AVFrame *dst, int offset)\n{\n    BitstreamContext bc;\n    int i, ret;\n    bitstream_init8(&bc, buf, buf_size);\n    if (bitstream_read_bit(&bc)) {\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      = bitstream_read(&bc, 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] = !bitstream_read_bit(&bc);\n    on2avc_read_ms_info(c, &bc);\n    for (i = 0; i < c->avctx->channels; i++)\n        if ((ret = on2avc_read_channel_data(c, &bc, 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 int on2avc_read_channel_data(On2AVCContext *c, BitstreamContext *bc, int ch)\n{\n    int ret;\n    int w, b, band_idx;\n    float *coeff_ptr;\n    if ((ret = on2avc_decode_band_types(c, bc)) < 0)\n        return ret;\n    if ((ret = on2avc_decode_band_scales(c, bc)) < 0)\n        return ret;\n    coeff_ptr = c->coeffs[ch];\n    band_idx  = 0;\n    memset(coeff_ptr, 0, ON2AVC_SUBFRAME_SIZE * sizeof(*coeff_ptr));\n    for (w = 0; w < c->num_windows; w++) {\n        for (b = 0; b < c->num_bands; b++) {\n            int band_size = c->band_start[b + 1] - c->band_start[b];\n            int band_type = c->band_type[band_idx + b];\n            if (!band_type) {\n                coeff_ptr += band_size;\n                continue;\n            }\n            if (band_type < 9)\n                on2avc_decode_quads(c, bc, coeff_ptr, band_size, band_type,\n                                    c->band_scales[band_idx + b]);\n            else\n                on2avc_decode_pairs(c, bc, coeff_ptr, band_size, band_type,\n                                    c->band_scales[band_idx + b]);\n            coeff_ptr += band_size;\n        }\n        band_idx += c->num_bands;\n    }\n    return 0;\n}']