Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6197e41b authored by Harish Mahendrakar's avatar Harish Mahendrakar Committed by Android Build Coastguard Worker
Browse files

MPEG4Writer: Remove timestamp validation

Timestamp validation method that was added doesn't work as expected
when system time is sent as timestamp to the MPEG4Writer.

Bug: 331723380
Test: atest CtsMediaMuxerTestCases
Test: atest CtsMediaV2TestCases:MuxerTest
Test: atest CtsMediaV2TestCases:MuxerUnitTest
(cherry picked from https://android-review.googlesource.com/q/commit:f909d513c7bcb4c5e1db6da6440ed3e043b3657f)
Merged-In: I9cf28cae0c4836035290123ae33cf6d94052585e
Change-Id: I9cf28cae0c4836035290123ae33cf6d94052585e
parent d0fc8b1d
Loading
Loading
Loading
Loading
+0 −41
Original line number Diff line number Diff line
@@ -2436,47 +2436,6 @@ status_t MPEG4Writer::setNextFd(int fd) {
    return OK;
}

bool MPEG4Writer::isSampleMetadataValid(size_t trackIndex, int64_t timeUs) {
    // Track Index starts from zero, so it should be at least 1 less than size.
    if (trackIndex >= mTracks.size()) {
        ALOGE("Incorrect trackIndex %zu, mTracks->size() %zu", trackIndex, mTracks.size());
        return false;
    }

    List<Track *>::iterator it = mTracks.begin();

    // (*it) is already pointing to trackIndex 0.
    for (int i = 1; i <= trackIndex; i++) {
        it++;
    }

    return (*it)->isTimestampValid(timeUs);
}

bool MPEG4Writer::Track::isTimestampValid(int64_t timeUs) {
    // No timescale if HEIF
    if (mIsHeif) {
        return true;
    }

    // Make sure abs(timeUs) does not overflow
    if (timeUs == INT64_MIN) {
       return false;
    }

    // Ensure that the timeUs value does not have extremely low or high values
    // that would cause an underflow or overflow, like in the calculation -
    // mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6
    if (abs(timeUs) >= (INT64_MAX - 5E5) / mTimeScale) {
        return false;
    }
    // Limit check for calculations in ctts box
    if (abs(timeUs) + kMaxCttsOffsetTimeUs >= INT64_MAX / mTimeScale) {
        return false;
    }
    return true;
}

bool MPEG4Writer::Track::isExifData(
        MediaBufferBase *buffer, uint32_t *tiffHdrOffset) const {
    if (!mIsHeif) {
+0 −3
Original line number Diff line number Diff line
@@ -77,9 +77,6 @@ public:
    virtual void setStartTimeOffsetMs(int ms) { mStartTimeOffsetMs = ms; }
    virtual int32_t getStartTimeOffsetMs() const { return mStartTimeOffsetMs; }
    virtual status_t setNextFd(int fd);
    // Returns true if the timestamp is valid which is compatible with the Mpeg4.
    // Note that this overloads that method in the base class.
    bool isSampleMetadataValid(size_t trackIndex, int64_t timeUs) override;

protected:
    virtual ~MPEG4Writer();