static int scaling_list_data(HEVCContext *s, ScalingList *sl)
{
    GetBitContext *gb = &s->HEVClc.gb;
    uint8_t scaling_list_pred_mode_flag[4][6];
    int32_t scaling_list_dc_coef[2][6];
    int size_id, matrix_id, i, pos;
    for (size_id = 0; size_id < 4; size_id++)
        for (matrix_id = 0; matrix_id < (size_id == 3 ? 2 : 6); matrix_id++) {
            scaling_list_pred_mode_flag[size_id][matrix_id] = get_bits1(gb);
            if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {
                unsigned int delta = get_ue_golomb_long(gb);
                if (delta) {
                    if (matrix_id < delta) {
                        av_log(s->avctx, AV_LOG_ERROR,
                               "Invalid delta in scaling list data: %d.\n", delta);
                        return AVERROR_INVALIDDATA;
                    }
                    memcpy(sl->sl[size_id][matrix_id],
                           sl->sl[size_id][matrix_id - delta],
                           size_id > 0 ? 64 : 16);
                    if (size_id > 1)
                        sl->sl_dc[size_id - 2][matrix_id] = sl->sl_dc[size_id - 2][matrix_id - delta];
                }
            } else {
                int next_coef, coef_num;
                int32_t scaling_list_delta_coef;
                next_coef = 8;
                coef_num  = FFMIN(64, 1 << (4 + (size_id << 1)));
                if (size_id > 1) {
                    scaling_list_dc_coef[size_id - 2][matrix_id] = get_se_golomb(gb) + 8;
                    next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
                    sl->sl_dc[size_id - 2][matrix_id] = next_coef;
                }
                for (i = 0; i < coef_num; i++) {
                    if (size_id == 0)
                        pos = 4 * ff_hevc_diag_scan4x4_y[i] +
                                  ff_hevc_diag_scan4x4_x[i];
                    else
                        pos = 8 * ff_hevc_diag_scan8x8_y[i] +
                                  ff_hevc_diag_scan8x8_x[i];
                    scaling_list_delta_coef = get_se_golomb(gb);
                    next_coef = (next_coef + scaling_list_delta_coef + 256) % 256;
                    sl->sl[size_id][matrix_id][pos] = next_coef;
                }
            }
        }
    return 0;
}
['static int scaling_list_data(HEVCContext *s, ScalingList *sl)\n{\n    GetBitContext *gb = &s->HEVClc.gb;\n    uint8_t scaling_list_pred_mode_flag[4][6];\n    int32_t scaling_list_dc_coef[2][6];\n    int size_id, matrix_id, i, pos;\n    for (size_id = 0; size_id < 4; size_id++)\n        for (matrix_id = 0; matrix_id < (size_id == 3 ? 2 : 6); matrix_id++) {\n            scaling_list_pred_mode_flag[size_id][matrix_id] = get_bits1(gb);\n            if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {\n                unsigned int delta = get_ue_golomb_long(gb);\n                if (delta) {\n                    if (matrix_id < delta) {\n                        av_log(s->avctx, AV_LOG_ERROR,\n                               "Invalid delta in scaling list data: %d.\\n", delta);\n                        return AVERROR_INVALIDDATA;\n                    }\n                    memcpy(sl->sl[size_id][matrix_id],\n                           sl->sl[size_id][matrix_id - delta],\n                           size_id > 0 ? 64 : 16);\n                    if (size_id > 1)\n                        sl->sl_dc[size_id - 2][matrix_id] = sl->sl_dc[size_id - 2][matrix_id - delta];\n                }\n            } else {\n                int next_coef, coef_num;\n                int32_t scaling_list_delta_coef;\n                next_coef = 8;\n                coef_num  = FFMIN(64, 1 << (4 + (size_id << 1)));\n                if (size_id > 1) {\n                    scaling_list_dc_coef[size_id - 2][matrix_id] = get_se_golomb(gb) + 8;\n                    next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];\n                    sl->sl_dc[size_id - 2][matrix_id] = next_coef;\n                }\n                for (i = 0; i < coef_num; i++) {\n                    if (size_id == 0)\n                        pos = 4 * ff_hevc_diag_scan4x4_y[i] +\n                                  ff_hevc_diag_scan4x4_x[i];\n                    else\n                        pos = 8 * ff_hevc_diag_scan8x8_y[i] +\n                                  ff_hevc_diag_scan8x8_x[i];\n                    scaling_list_delta_coef = get_se_golomb(gb);\n                    next_coef = (next_coef + scaling_list_delta_coef + 256) % 256;\n                    sl->sl[size_id][matrix_id][pos] = next_coef;\n                }\n            }\n        }\n    return 0;\n}']