def transform_bbox(coords):
    """
    Derive CCT-formatted bounding boxes from the SamaSource coordinate system.
    
    SamaSource provides a list of four points (x,y) that should make a box.
    
    CCT coordinates are absolute, with the origin at the upper-left, as x,y,w,h.
    """
    
    # Make sure this is really a box
    assert len(coords) == 4
    assert all(len(coord) == 2 for coord in coords)
    assert coords[0][1] == coords[1][1]
    assert coords[2][1] == coords[3][1]
    assert coords[0][0] == coords[2][0]
    assert coords[1][0] == coords[3][0]
    
    # Transform to CCT format
    x = coords[0][0]
    y = coords[0][1]
    h = coords[2][1] - coords[0][1]
    w = coords[1][0] - coords[0][0]
    return [x, y, w, h]