static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
{
    int      smp = bd->block_length - 1;
    int32_t  val = *bd->raw_samples;
    int32_t *dst = bd->raw_samples + 1;
    for (; smp; smp--)
        *dst++ = val;
}
['static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)\n{\n    ALSSpecificConfig *sconf = &ctx->sconf;\n    AVCodecContext *avctx    = ctx->avctx;\n    GetBitContext *gb = &ctx->gb;\n    unsigned int div_blocks[32];\n    unsigned int c;\n    unsigned int js_blocks[2];\n    uint32_t bs_info = 0;\n    int ret;\n    if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)\n        skip_bits_long(gb, 32);\n    if (sconf->mc_coding && sconf->joint_stereo) {\n        ctx->js_switch = get_bits1(gb);\n        align_get_bits(gb);\n    }\n    if (!sconf->mc_coding || ctx->js_switch) {\n        int independent_bs = !sconf->joint_stereo;\n        for (c = 0; c < avctx->channels; c++) {\n            js_blocks[0] = 0;\n            js_blocks[1] = 0;\n            get_block_sizes(ctx, div_blocks, &bs_info);\n            if (sconf->joint_stereo && sconf->block_switching)\n                if (bs_info >> 31)\n                    independent_bs = 2;\n            if (c == avctx->channels - 1)\n                independent_bs = 1;\n            if (independent_bs) {\n                ret = decode_blocks_ind(ctx, ra_frame, c,\n                                        div_blocks, js_blocks);\n                if (ret < 0)\n                    return ret;\n                independent_bs--;\n            } else {\n                ret = decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);\n                if (ret < 0)\n                    return ret;\n                c++;\n            }\n            memmove(ctx->raw_samples[c] - sconf->max_order,\n                    ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,\n                    sizeof(*ctx->raw_samples[c]) * sconf->max_order);\n        }\n    } else {\n        ALSBlockData   bd = { 0 };\n        int            b, ret;\n        int            *reverted_channels = ctx->reverted_channels;\n        unsigned int   offset             = 0;\n        for (c = 0; c < avctx->channels; c++)\n            if (ctx->chan_data[c] < ctx->chan_data_buffer) {\n                av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data!\\n");\n                return AVERROR_INVALIDDATA;\n            }\n        memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);\n        bd.ra_block         = ra_frame;\n        bd.prev_raw_samples = ctx->prev_raw_samples;\n        get_block_sizes(ctx, div_blocks, &bs_info);\n        for (b = 0; b < ctx->num_blocks; b++) {\n            bd.block_length = div_blocks[b];\n            for (c = 0; c < avctx->channels; c++) {\n                bd.const_block = ctx->const_block + c;\n                bd.shift_lsbs  = ctx->shift_lsbs + c;\n                bd.opt_order   = ctx->opt_order + c;\n                bd.store_prev_samples = ctx->store_prev_samples + c;\n                bd.use_ltp     = ctx->use_ltp + c;\n                bd.ltp_lag     = ctx->ltp_lag + c;\n                bd.ltp_gain    = ctx->ltp_gain[c];\n                bd.lpc_cof     = ctx->lpc_cof[c];\n                bd.quant_cof   = ctx->quant_cof[c];\n                bd.raw_samples = ctx->raw_samples[c] + offset;\n                bd.raw_other   = NULL;\n                if ((ret = read_block(ctx, &bd)) < 0)\n                    return ret;\n                if ((ret = read_channel_data(ctx, ctx->chan_data[c], c)) < 0)\n                    return ret;\n            }\n            for (c = 0; c < avctx->channels; c++) {\n                ret = revert_channel_correlation(ctx, &bd, ctx->chan_data,\n                                                 reverted_channels, offset, c);\n                if (ret < 0)\n                    return ret;\n            }\n            for (c = 0; c < avctx->channels; c++) {\n                bd.const_block = ctx->const_block + c;\n                bd.shift_lsbs  = ctx->shift_lsbs + c;\n                bd.opt_order   = ctx->opt_order + c;\n                bd.store_prev_samples = ctx->store_prev_samples + c;\n                bd.use_ltp     = ctx->use_ltp + c;\n                bd.ltp_lag     = ctx->ltp_lag + c;\n                bd.ltp_gain    = ctx->ltp_gain[c];\n                bd.lpc_cof     = ctx->lpc_cof[c];\n                bd.quant_cof   = ctx->quant_cof[c];\n                bd.raw_samples = ctx->raw_samples[c] + offset;\n                if ((ret = decode_block(ctx, &bd)) < 0)\n                    return ret;\n            }\n            memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));\n            offset      += div_blocks[b];\n            bd.ra_block  = 0;\n        }\n        for (c = 0; c < avctx->channels; c++)\n            memmove(ctx->raw_samples[c] - sconf->max_order,\n                    ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,\n                    sizeof(*ctx->raw_samples[c]) * sconf->max_order);\n    }\n    return 0;\n}', 'static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,\n                            uint32_t *bs_info)\n{\n    ALSSpecificConfig *sconf     = &ctx->sconf;\n    GetBitContext *gb            = &ctx->gb;\n    unsigned int *ptr_div_blocks = div_blocks;\n    unsigned int b;\n    if (sconf->block_switching) {\n        unsigned int bs_info_len = 1 << (sconf->block_switching + 2);\n        *bs_info = get_bits_long(gb, bs_info_len);\n        *bs_info <<= (32 - bs_info_len);\n    }\n    ctx->num_blocks = 0;\n    parse_bs_info(*bs_info, 0, 0, &ptr_div_blocks, &ctx->num_blocks);\n    for (b = 0; b < ctx->num_blocks; b++)\n        div_blocks[b] = ctx->sconf.frame_length >> div_blocks[b];\n    if (ctx->cur_frame_length != ctx->sconf.frame_length) {\n        unsigned int remaining = ctx->cur_frame_length;\n        for (b = 0; b < ctx->num_blocks; b++) {\n            if (remaining <= div_blocks[b]) {\n                div_blocks[b] = remaining;\n                ctx->num_blocks = b + 1;\n                break;\n            }\n            remaining -= div_blocks[b];\n        }\n    }\n}', 'static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,\n                             unsigned int c, const unsigned int *div_blocks,\n                             unsigned int *js_blocks)\n{\n    int ret;\n    unsigned int b;\n    ALSBlockData bd = { 0 };\n    bd.ra_block         = ra_frame;\n    bd.const_block      = ctx->const_block;\n    bd.shift_lsbs       = ctx->shift_lsbs;\n    bd.opt_order        = ctx->opt_order;\n    bd.store_prev_samples = ctx->store_prev_samples;\n    bd.use_ltp          = ctx->use_ltp;\n    bd.ltp_lag          = ctx->ltp_lag;\n    bd.ltp_gain         = ctx->ltp_gain[0];\n    bd.quant_cof        = ctx->quant_cof[0];\n    bd.lpc_cof          = ctx->lpc_cof[0];\n    bd.prev_raw_samples = ctx->prev_raw_samples;\n    bd.raw_samples      = ctx->raw_samples[c];\n    for (b = 0; b < ctx->num_blocks; b++) {\n        bd.block_length     = div_blocks[b];\n        if ((ret = read_decode_block(ctx, &bd)) < 0) {\n            zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples);\n            return ret;\n        }\n        bd.raw_samples += div_blocks[b];\n        bd.ra_block     = 0;\n    }\n    return 0;\n}', 'static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)\n{\n    int ret;\n    if ((ret = read_block(ctx, bd)) < 0)\n        return ret;\n    return decode_block(ctx, bd);\n}', 'static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)\n{\n    unsigned int smp;\n    int ret = 0;\n    if (*bd->const_block)\n        decode_const_block_data(ctx, bd);\n    else\n        ret = decode_var_block_data(ctx, bd);\n    if (ret < 0)\n        return ret;\n    if (*bd->shift_lsbs)\n        for (smp = 0; smp < bd->block_length; smp++)\n            bd->raw_samples[smp] <<= *bd->shift_lsbs;\n    return 0;\n}', 'static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)\n{\n    int      smp = bd->block_length - 1;\n    int32_t  val = *bd->raw_samples;\n    int32_t *dst = bd->raw_samples + 1;\n    for (; smp; smp--)\n        *dst++ = val;\n}']