def resync_subs(params, subs, mask=None, fs=1000, cut_start=0, cut_end=90060990):
    """Re-synchronize the subtitle object given the transformation parameters.

    Parameters
    ----------
        params : `list` [float], required
            transformation parameters
        subs : `pysubs2.ssafile.SSAFile`, required
            subtitle object with all the subtitle events
        mask : `np.array` [float]
            mask with cluster id values for each sample in the input subtitle signal
        fs : float
            Sampling rate in Hz (default: 1 kHz)
        cut_start : int
            Minimum timestamp value (ms) to include (default: 0)
        cut_end : int
            Maximum timestamp value (ms) to include (default: 90060990)
    
    Returns
    -------
        `pysubs2.ssafile.SSAFile` : subtitle object with all the re-synchronized subtitle events
    """
    target_ratio = fs / 1000.
    max_duration = int(subs[-1].end + 3600000)
    for sub, i in zip(subs, range(len(subs))):
        input_start = int(sub.start * target_ratio)
        input_end = int(sub.end * target_ratio)
        start =  params[0]*input_start + params[1]
        end = params[0]*input_end + params[1]
        # non-rigid
        if len(params) != 2:
            if mask is None:
                idx_start =  input_start
                idx_end = input_end
            else:
                idx_start = int(mask[input_start])
                idx_end = int(mask[input_end])
            start = start + params[2][idx_start]
            end = end + params[2][idx_end]
        if (cut_start < sub.start) & (sub.end < cut_end):
            # updating subtitle file
            subs[i].start = min(max(0, int(start/target_ratio)), max_duration)
            subs[i].end = min(max(0, int(end/target_ratio)), max_duration)

    return subs