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

Change-Id: I8deecc5678615a07760a8c9220e7a0dfa3101c37
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index a18dbfe..e918b5e 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -2436,47 +2436,6 @@
     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) {
diff --git a/media/libstagefright/include/media/stagefright/MPEG4Writer.h b/media/libstagefright/include/media/stagefright/MPEG4Writer.h
index 1ff8acf..054a4b8 100644
--- a/media/libstagefright/include/media/stagefright/MPEG4Writer.h
+++ b/media/libstagefright/include/media/stagefright/MPEG4Writer.h
@@ -77,9 +77,6 @@
     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();