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

Commit 3ac36cbd authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['android-review.googlesource.com/3034915'] into 24Q2-release.

Change-Id: I8deecc5678615a07760a8c9220e7a0dfa3101c37
parents d0fc8b1d 6197e41b
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();