package androidx.media3.exoplayer;

import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;

/* JADX INFO: loaded from: classes.dex */
@UnstableApi
public final class SeekParameters {
    public static final SeekParameters CLOSEST_SYNC;
    public static final SeekParameters DEFAULT;
    public static final SeekParameters EXACT;
    public static final SeekParameters NEXT_SYNC;
    public static final SeekParameters PREVIOUS_SYNC;
    public final long toleranceAfterUs;
    public final long toleranceBeforeUs;

    static {
        SeekParameters seekParameters = new SeekParameters(0L, 0L);
        EXACT = seekParameters;
        CLOSEST_SYNC = new SeekParameters(Long.MAX_VALUE, Long.MAX_VALUE);
        PREVIOUS_SYNC = new SeekParameters(Long.MAX_VALUE, 0L);
        NEXT_SYNC = new SeekParameters(0L, Long.MAX_VALUE);
        DEFAULT = seekParameters;
    }

    public SeekParameters(long j4, long j6) {
        Assertions.checkArgument(j4 >= 0);
        Assertions.checkArgument(j6 >= 0);
        this.toleranceBeforeUs = j4;
        this.toleranceAfterUs = j6;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && SeekParameters.class == obj.getClass()) {
            SeekParameters seekParameters = (SeekParameters) obj;
            if (this.toleranceBeforeUs == seekParameters.toleranceBeforeUs && this.toleranceAfterUs == seekParameters.toleranceAfterUs) {
                return true;
            }
        }
        return false;
    }

    public int hashCode() {
        return (((int) this.toleranceBeforeUs) * 31) + ((int) this.toleranceAfterUs);
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0051 A[RETURN] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public long resolveSeekPositionUs(long j4, long j6, long j7) {
        long j8 = this.toleranceBeforeUs;
        if (j8 == 0 && this.toleranceAfterUs == 0) {
            return j4;
        }
        long jSubtractWithOverflowDefault = Util.subtractWithOverflowDefault(j4, j8, Long.MIN_VALUE);
        long jAddWithOverflowDefault = Util.addWithOverflowDefault(j4, this.toleranceAfterUs, Long.MAX_VALUE);
        boolean z6 = false;
        boolean z7 = jSubtractWithOverflowDefault <= j6 && j6 <= jAddWithOverflowDefault;
        if (jSubtractWithOverflowDefault <= j7 && j7 <= jAddWithOverflowDefault) {
            z6 = true;
        }
        if (!z7 || !z6) {
            if (!z7) {
                return z6 ? j7 : jSubtractWithOverflowDefault;
            }
            return j6;
        }
        if (Math.abs(j6 - j4) <= Math.abs(j7 - j4)) {
            return j6;
        }
    }
}
