Repository: ggerganov/whisper.cpp
File: src/whisper.cpp (C++)

Code before:
            return entry.processed_time < time;
        }
    );

    // If exact match found
    if (upper->processed_time == processed_time) {
        return upper->original_time;
    }

    // Need to interpolate between two points
    auto lower = upper - 1;

    int64_t processed_diff = upper->processed_time - lower->processed_time;
    int64_t original_diff = upper->original_time - lower->original_time;
    int64_t offset = processed_time - lower->processed_time;

    if (processed_diff == 0) {
        return lower->original_time;
    }

    // Perform linear interpolation
    return lower->original_time + (offset * original_diff) / processed_diff;
}

// Function to get the starting timestamp of a segment
int64_t whisper_full_get_segment_t0_from_state(struct whisper_state* state, int i_segment) {
    // If VAD wasn't used, return the original timestamp
    if (!state->has_vad_segments || !state->vad_mapping_table_initialized ||
        state->vad_mapping_table.empty()) {
        return state->result_all[i_segment].t0;
    }

    // Get the processed timestamp
    int64_t t0 = state->result_all[i_segment].t0;

    // Map to original time using the mapping table
    return map_processed_to_original_time(t0, state->vad_mapping_table);
}

// Function to get the ending timestamp of a segment
int64_t whisper_full_get_segment_t1_from_state(struct whisper_state* state, int i_segment) {
    // If VAD wasn't used, return the original timestamp
    if (!state->has_vad_segments || !state->vad_mapping_table_initialized ||
        state->vad_mapping_table.empty()) {
        return state->result_all[i_segment].t1;
    }

    // Get the processed timestamp
    int64_t t1 = state->result_all[i_segment].t1;

    // Map to original time using the mapping table

Review comment (suggestion):
```suggestion
int64_t whisper_full_get_segment_t0_from_state(struct whisper_state * state, int i_segment) {
```

Code after:
    );

    // If exact match found
    if (upper->processed_time == processed_time) {
        return upper->original_time;
    }

    // Need to interpolate between two points
    auto lower = upper - 1;

    int64_t processed_diff = upper->processed_time - lower->processed_time;
    int64_t original_diff = upper->original_time - lower->original_time;
    int64_t offset = processed_time - lower->processed_time;

    if (processed_diff == 0) {
        return lower->original_time;
    }

    // Perform linear interpolation
    return lower->original_time + (offset * original_diff) / processed_diff;
}

// Function to get the starting timestamp of a segment
int64_t whisper_full_get_segment_t0_from_state(struct whisper_state * state, int i_segment) {
    // If VAD wasn't used, return the original timestamp
    if (!state->has_vad_segments || state->vad_mapping_table.empty()) {
        return state->result_all[i_segment].t0;
    }

    // Get the processed timestamp
    int64_t t0 = state->result_all[i_segment].t0;

    // Map to original time using the mapping table
    return map_processed_to_original_time(t0, state->vad_mapping_table);
}

// Function to get the ending timestamp of a segment
int64_t whisper_full_get_segment_t1_from_state(struct whisper_state * state, int i_segment) {
    // If VAD wasn't used, return the original timestamp
    if (!state->has_vad_segments || state->vad_mapping_table.empty()) {
        return state->result_all[i_segment].t1;
    }

    // Get the processed timestamp
    int64_t t1 = state->result_all[i_segment].t1;

    // Map to original time using the mapping table
    int64_t orig_t1 = map_processed_to_original_time(t1, state->vad_mapping_table);

    // Get the corresponding t0 for this segment
    int64_t orig_t0 = whisper_full_get_segment_t0_from_state(state, i_segment);